index.js 768 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811
  1. /**
  2. * Name: Metaverse
  3. * Date: 2022/4/12
  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$Z() {
  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$Z()) {
  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$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); }; }
  855. 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; } }
  856. var XverseError = /*#__PURE__*/function (_Error) {
  857. _inherits(XverseError, _Error);
  858. var _super = _createSuper$Y(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$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); }; }
  889. 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; } }
  890. var ParamError$2 = /*#__PURE__*/function (_XverseError) {
  891. _inherits(ParamError, _XverseError);
  892. var _super = _createSuper$X(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$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); }; }
  900. 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; } }
  901. var InternalError$1 = /*#__PURE__*/function (_XverseError) {
  902. _inherits(InternalError, _XverseError);
  903. var _super = _createSuper$W(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$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); }; }
  911. 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; } }
  912. var TimeoutError$1 = /*#__PURE__*/function (_XverseError) {
  913. _inherits(TimeoutError, _XverseError);
  914. var _super = _createSuper$V(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$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); }; }
  922. 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; } }
  923. var AuthenticationError$1 = /*#__PURE__*/function (_XverseError) {
  924. _inherits(AuthenticationError, _XverseError);
  925. var _super = _createSuper$U(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$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); }; }
  933. 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; } }
  934. var TokenExpiredError$1 = /*#__PURE__*/function (_XverseError) {
  935. _inherits(TokenExpiredError, _XverseError);
  936. var _super = _createSuper$T(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$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); }; }
  944. 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; } }
  945. var UnsupportedError$1 = /*#__PURE__*/function (_XverseError) {
  946. _inherits(UnsupportedError, _XverseError);
  947. var _super = _createSuper$S(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$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); }; }
  955. 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; } }
  956. var InitNetworkTimeoutError$1 = /*#__PURE__*/function (_XverseError) {
  957. _inherits(InitNetworkTimeoutError, _XverseError);
  958. var _super = _createSuper$R(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$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); }; }
  966. 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; } }
  967. var InitDecoderTimeoutError$1 = /*#__PURE__*/function (_XverseError) {
  968. _inherits(InitDecoderTimeoutError, _XverseError);
  969. var _super = _createSuper$Q(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$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); }; }
  977. 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; } }
  978. var InitConfigTimeoutError$1 = /*#__PURE__*/function (_XverseError) {
  979. _inherits(InitConfigTimeoutError, _XverseError);
  980. var _super = _createSuper$P(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$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); }; }
  988. 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; } }
  989. var InitEngineTimeoutError$1 = /*#__PURE__*/function (_XverseError) {
  990. _inherits(InitEngineTimeoutError, _XverseError);
  991. var _super = _createSuper$O(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$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); }; }
  999. 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; } }
  1000. var InitEngineError$1 = /*#__PURE__*/function (_XverseError) {
  1001. _inherits(InitEngineError, _XverseError);
  1002. var _super = _createSuper$N(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$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); }; }
  1010. 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; } }
  1011. var ActionBlockedError = /*#__PURE__*/function (_XverseError) {
  1012. _inherits(ActionBlockedError, _XverseError);
  1013. var _super = _createSuper$M(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$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); }; }
  1021. 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; } }
  1022. var PreloadCanceledError$1 = /*#__PURE__*/function (_XverseError) {
  1023. _inherits(PreloadCanceledError, _XverseError);
  1024. var _super = _createSuper$L(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$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); }; }
  1032. 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; } }
  1033. var FrequencyLimitError$1 = /*#__PURE__*/function (_XverseError) {
  1034. _inherits(FrequencyLimitError, _XverseError);
  1035. var _super = _createSuper$K(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$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); }; }
  1043. 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; } }
  1044. var UsersUpperLimitError = /*#__PURE__*/function (_XverseError) {
  1045. _inherits(UsersUpperLimitError, _XverseError);
  1046. var _super = _createSuper$J(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$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); }; }
  1054. 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; } }
  1055. var RoomsUpperLimitError = /*#__PURE__*/function (_XverseError) {
  1056. _inherits(RoomsUpperLimitError, _XverseError);
  1057. var _super = _createSuper$I(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$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); }; }
  1065. 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; } }
  1066. var ServerParamError = /*#__PURE__*/function (_XverseError) {
  1067. _inherits(ServerParamError, _XverseError);
  1068. var _super = _createSuper$H(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$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); }; }
  1076. 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; } }
  1077. var LackOfTokenError = /*#__PURE__*/function (_XverseError) {
  1078. _inherits(LackOfTokenError, _XverseError);
  1079. var _super = _createSuper$G(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$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); }; }
  1087. 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; } }
  1088. var LoginFailedError = /*#__PURE__*/function (_XverseError) {
  1089. _inherits(LoginFailedError, _XverseError);
  1090. var _super = _createSuper$F(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$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); }; }
  1098. 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; } }
  1099. var VerifyServiceDownError = /*#__PURE__*/function (_XverseError) {
  1100. _inherits(VerifyServiceDownError, _XverseError);
  1101. var _super = _createSuper$E(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$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); }; }
  1109. 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; } }
  1110. var CreateSessionFailedError = /*#__PURE__*/function (_XverseError) {
  1111. _inherits(CreateSessionFailedError, _XverseError);
  1112. var _super = _createSuper$D(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$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); }; }
  1120. 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; } }
  1121. var RtcConnectionError = /*#__PURE__*/function (_XverseError) {
  1122. _inherits(RtcConnectionError, _XverseError);
  1123. var _super = _createSuper$C(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$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); }; }
  1131. 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; } }
  1132. var DoActionFailedError = /*#__PURE__*/function (_XverseError) {
  1133. _inherits(DoActionFailedError, _XverseError);
  1134. var _super = _createSuper$B(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$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); }; }
  1142. 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; } }
  1143. var StateSyncFailedError = /*#__PURE__*/function (_XverseError) {
  1144. _inherits(StateSyncFailedError, _XverseError);
  1145. var _super = _createSuper$A(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$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); }; }
  1153. 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; } }
  1154. var BroadcastFailedError = /*#__PURE__*/function (_XverseError) {
  1155. _inherits(BroadcastFailedError, _XverseError);
  1156. var _super = _createSuper$z(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$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); }; }
  1164. 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; } }
  1165. var DataAbnormalError = /*#__PURE__*/function (_XverseError) {
  1166. _inherits(DataAbnormalError, _XverseError);
  1167. var _super = _createSuper$y(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$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); }; }
  1175. 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; } }
  1176. var GetOnVehicleError = /*#__PURE__*/function (_XverseError) {
  1177. _inherits(GetOnVehicleError, _XverseError);
  1178. var _super = _createSuper$x(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$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); }; }
  1186. 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; } }
  1187. var RepeatLoginError = /*#__PURE__*/function (_XverseError) {
  1188. _inherits(RepeatLoginError, _XverseError);
  1189. var _super = _createSuper$w(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$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); }; }
  1197. 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; } }
  1198. var RoomDoseNotExistError = /*#__PURE__*/function (_XverseError) {
  1199. _inherits(RoomDoseNotExistError, _XverseError);
  1200. var _super = _createSuper$v(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$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); }; }
  1208. 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; } }
  1209. var TicketExpireError = /*#__PURE__*/function (_XverseError) {
  1210. _inherits(TicketExpireError, _XverseError);
  1211. var _super = _createSuper$u(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$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); }; }
  1219. 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; } }
  1220. var ServerRateLimitError = /*#__PURE__*/function (_XverseError) {
  1221. _inherits(ServerRateLimitError, _XverseError);
  1222. var _super = _createSuper$t(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$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); }; }
  1230. 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; } }
  1231. var DoActionBlockedError = /*#__PURE__*/function (_XverseError) {
  1232. _inherits(DoActionBlockedError, _XverseError);
  1233. var _super = _createSuper$s(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$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); }; }
  1241. 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; } }
  1242. var ActionMaybeDelayError = /*#__PURE__*/function (_XverseError) {
  1243. _inherits(ActionMaybeDelayError, _XverseError);
  1244. var _super = _createSuper$r(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$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); }; }
  1252. 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; } }
  1253. var ActionResponseTimeoutError$1 = /*#__PURE__*/function (_XverseError) {
  1254. _inherits(ActionResponseTimeoutError, _XverseError);
  1255. var _super = _createSuper$q(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$2,
  1264. 1002: InternalError$1,
  1265. 1003: TimeoutError$1,
  1266. 1004: AuthenticationError$1,
  1267. 1005: TokenExpiredError$1,
  1268. 1006: UnsupportedError$1,
  1269. 1007: InitNetworkTimeoutError$1,
  1270. 1008: InitDecoderTimeoutError$1,
  1271. 1009: InitConfigTimeoutError$1,
  1272. 1010: InitEngineTimeoutError$1,
  1273. 1011: InitEngineError$1,
  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. 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); }; }
  1299. 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; } }
  1300. var InternalError = /*#__PURE__*/function (_XverseError) {
  1301. _inherits(InternalError, _XverseError);
  1302. var _super = _createSuper$p(InternalError);
  1303. function InternalError(e) {
  1304. _classCallCheck(this, InternalError);
  1305. return _super.call(this, 1002, e || "\u5185\u90E8\u9519\u8BEF");
  1306. }
  1307. return _createClass(InternalError);
  1308. }(XverseError);
  1309. var util = {
  1310. uuid() {
  1311. return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (i) {
  1312. var e = Math.random() * 16 | 0;
  1313. return (i === "x" ? e : e & 3 | 8).toString(16);
  1314. });
  1315. },
  1316. getFormattedDate(i) {
  1317. var e = i.getMonth() + 1,
  1318. t = i.getDate(),
  1319. r = i.getHours(),
  1320. n = i.getMinutes(),
  1321. o = i.getSeconds(),
  1322. a = i.getMilliseconds(),
  1323. s = (e < 10 ? "0" : "") + e,
  1324. l = (t < 10 ? "0" : "") + t,
  1325. u = (r < 10 ? "0" : "") + r,
  1326. c = (n < 10 ? "0" : "") + n,
  1327. h = (o < 10 ? "0" : "") + o;
  1328. return i.getFullYear() + "-" + s + "-" + l + " " + u + ":" + c + ":" + h + "." + a;
  1329. },
  1330. createInstance(i) {
  1331. var e = new Axios(i),
  1332. t = bind(Axios.prototype.request, e);
  1333. return utils.extend(t, Axios.prototype, e), utils.extend(t, e), t.create = function (n) {
  1334. return createInstance(mergeConfig(i, n));
  1335. }, t;
  1336. },
  1337. mapLimit(i, e, t) {
  1338. return new Promise(function (r, n) {
  1339. var o = i.length;
  1340. var a = e - 1,
  1341. s = 0;
  1342. var l = function l(u) {
  1343. u.forEach(function (c) {
  1344. t(c).then(function () {
  1345. if (s++, s === o) {
  1346. r();
  1347. return;
  1348. }
  1349. a++;
  1350. var h = i[a];
  1351. h && l([h]);
  1352. }, function (h) {
  1353. n(h);
  1354. });
  1355. });
  1356. };
  1357. l(i.slice(0, e));
  1358. });
  1359. },
  1360. isWebAssemblySupported() {
  1361. try {
  1362. if (typeof WebAssembly == "object" && typeof WebAssembly.instantiate == "function") {
  1363. var i = new WebAssembly.Module(Uint8Array.of(0, 97, 115, 109, 1, 0, 0, 0));
  1364. if (i instanceof WebAssembly.Module) return new WebAssembly.Instance(i) instanceof WebAssembly.Instance;
  1365. }
  1366. } catch (_unused) {}
  1367. return console.log("wasm is not supported"), !1;
  1368. },
  1369. isSupported() {
  1370. return typeof RTCPeerConnection == "function" && this.isWebAssemblySupported();
  1371. },
  1372. objectParseFloat(i) {
  1373. var e = {};
  1374. return i && Object.keys(i).forEach(function (t) {
  1375. e[t] = parseFloat(i[t]);
  1376. }), e;
  1377. },
  1378. getRandomItem(i) {
  1379. i.length === 0 ? null : i[Math.floor(Math.random() * i.length)];
  1380. },
  1381. getErrorByCode(i) {
  1382. if (i === Codes.Success) return InternalError;
  1383. var e = CodeErrorMap[i];
  1384. return e || console.warn("unkown code", i), e || InternalError;
  1385. },
  1386. getDistance(i, e) {
  1387. var t = i.x,
  1388. r = i.y,
  1389. n = i.z,
  1390. o = e.x,
  1391. a = e.y,
  1392. s = e.z;
  1393. return Math.sqrt(Math.pow(Math.abs(t - o), 2) + Math.pow(Math.abs(r - a), 2) + Math.pow(Math.abs(n - s), 2));
  1394. }
  1395. };
  1396. 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); }; }
  1397. 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; } }
  1398. var Reporter = /*#__PURE__*/function (_EventEmitter) {
  1399. _inherits(Reporter, _EventEmitter);
  1400. var _super = _createSuper$o(Reporter);
  1401. function Reporter() {
  1402. var _this;
  1403. _classCallCheck(this, Reporter);
  1404. _this = _super.call(this);
  1405. _this._header = {};
  1406. _this._body = {};
  1407. _this._queue = [];
  1408. _this._disabled = !1;
  1409. _this._interval = null;
  1410. _this._reportUrl = null;
  1411. _this.isDocumentLoaded = function () {
  1412. return document.readyState === "complete";
  1413. };
  1414. _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 () {
  1415. _this._flushReport();
  1416. }, 10 * 1e3);
  1417. return _this;
  1418. }
  1419. _createClass(Reporter, [{
  1420. key: "disable",
  1421. value: function disable() {
  1422. this._disabled = !0, this._interval && window.clearInterval(this._interval);
  1423. }
  1424. }, {
  1425. key: "updateHeader",
  1426. value: function updateHeader(e) {
  1427. Object.assign(this._header, e);
  1428. }
  1429. }, {
  1430. key: "updateBody",
  1431. value: function updateBody(e) {
  1432. Object.assign(this._body, e);
  1433. }
  1434. }, {
  1435. key: "updateReportUrl",
  1436. value: function updateReportUrl(e) {
  1437. this._reportUrl = e;
  1438. }
  1439. }, {
  1440. key: "report",
  1441. value: function report(e, t, r) {
  1442. var _this2 = this;
  1443. if (this._disabled) return;
  1444. r || (r = {});
  1445. var _r = r,
  1446. n = _r.immediate,
  1447. o = _r.sampleRate;
  1448. if (o && o > Math.random()) return;
  1449. this.updateBody({
  1450. logTime: util.getFormattedDate(new Date()),
  1451. logTimestamp: Date.now()
  1452. });
  1453. var a = function a(s) {
  1454. var l = oe(le(oe({}, _this2._body), {
  1455. type: e
  1456. }), s);
  1457. _this2._queue.push(l), e === "measurement" && _this2.emit("report", s);
  1458. };
  1459. Array.isArray(t) ? t.forEach(function (s) {
  1460. return a(s);
  1461. }) : a(t), (n || this._queue.length >= REPORT_NUM_PER_REQUEST) && this._flushReport();
  1462. }
  1463. }, {
  1464. key: "_flushReport",
  1465. value: function _flushReport() {
  1466. if (this._disabled || !this._queue.length || !this.isDocumentLoaded()) return;
  1467. var e = {
  1468. header: this._header,
  1469. body: this._queue.splice(0, REPORT_NUM_PER_REQUEST)
  1470. };
  1471. this._post(e);
  1472. }
  1473. }, {
  1474. key: "_post",
  1475. value: function _post(e) {
  1476. var t = this._reportUrl || REPORT_URL.DEV;
  1477. return new Promise(function (r, n) {
  1478. var o = new XMLHttpRequest();
  1479. o.open("POST", t), o.setRequestHeader("Content-Type", "application/json");
  1480. try {
  1481. o.send(JSON.stringify(e));
  1482. } catch (a) {
  1483. console.error(a);
  1484. }
  1485. o.addEventListener("readystatechange", function () {
  1486. if (o.readyState == 4) return o.status == 200 ? r(o) : n("Unable to send log");
  1487. });
  1488. });
  1489. }
  1490. }]);
  1491. return Reporter;
  1492. }(EventEmitter);
  1493. var reporter$1 = new Reporter();
  1494. function _arrayLikeToArray$7(arr, len) {
  1495. if (len == null || len > arr.length) len = arr.length;
  1496. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  1497. arr2[i] = arr[i];
  1498. }
  1499. return arr2;
  1500. }
  1501. function _arrayWithoutHoles(arr) {
  1502. if (Array.isArray(arr)) return _arrayLikeToArray$7(arr);
  1503. }
  1504. function _iterableToArray(iter) {
  1505. if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
  1506. }
  1507. function _unsupportedIterableToArray$7(o, minLen) {
  1508. if (!o) return;
  1509. if (typeof o === "string") return _arrayLikeToArray$7(o, minLen);
  1510. var n = Object.prototype.toString.call(o).slice(8, -1);
  1511. if (n === "Object" && o.constructor) n = o.constructor.name;
  1512. if (n === "Map" || n === "Set") return Array.from(o);
  1513. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$7(o, minLen);
  1514. }
  1515. function _nonIterableSpread() {
  1516. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  1517. }
  1518. function _toConsumableArray(arr) {
  1519. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray$7(arr) || _nonIterableSpread();
  1520. }
  1521. var Logger = /*#__PURE__*/function () {
  1522. function Logger(e) {
  1523. _classCallCheck(this, Logger);
  1524. this.level = 3;
  1525. this.module = e;
  1526. }
  1527. _createClass(Logger, [{
  1528. key: "setLevel",
  1529. value: function setLevel(e) {
  1530. this.level = e;
  1531. }
  1532. }, {
  1533. key: "atleast",
  1534. value: function atleast(e) {
  1535. return e >= this.level && e >= this.level;
  1536. }
  1537. }, {
  1538. key: "print",
  1539. value: function print(e, t) {
  1540. for (var _len = arguments.length, r = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  1541. r[_key - 2] = arguments[_key];
  1542. }
  1543. if (this.atleast(t)) {
  1544. var _console$n;
  1545. var n = e == "debug" ? "info" : e,
  1546. o = this.prefix(e);
  1547. (_console$n = console[n]).call.apply(_console$n, [null, o].concat(r));
  1548. }
  1549. if (e !== "debug" && e !== "info") {
  1550. var _n = r.map(function (o) {
  1551. if (o instanceof Object) try {
  1552. return JSON.stringify(o);
  1553. } catch (_unused) {
  1554. return o;
  1555. } else return o;
  1556. }).join(",");
  1557. reporter$1.report("log", {
  1558. message: _n,
  1559. level: e,
  1560. module: this.module
  1561. });
  1562. }
  1563. }
  1564. }, {
  1565. key: "debug",
  1566. value: function debug() {
  1567. for (var _len2 = arguments.length, e = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  1568. e[_key2] = arguments[_key2];
  1569. }
  1570. return this.print.apply(this, ["debug", 1].concat(e));
  1571. }
  1572. }, {
  1573. key: "info",
  1574. value: function info() {
  1575. for (var _len3 = arguments.length, e = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  1576. e[_key3] = arguments[_key3];
  1577. }
  1578. return this.print.apply(this, ["info", 2].concat(e));
  1579. }
  1580. }, {
  1581. key: "infoAndReportLog",
  1582. value: function infoAndReportLog(e) {
  1583. for (var _len4 = arguments.length, t = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
  1584. t[_key4 - 1] = arguments[_key4];
  1585. }
  1586. var r = e.reportOptions;
  1587. delete e.reportOptions, reporter$1.report("log", e, r), t.length || (t = [e.message]), this.debug.apply(this, _toConsumableArray(t));
  1588. }
  1589. }, {
  1590. key: "infoAndReportMeasurement",
  1591. value: function infoAndReportMeasurement(e) {
  1592. for (var _len5 = arguments.length, t = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
  1593. t[_key5 - 1] = arguments[_key5];
  1594. }
  1595. var n;
  1596. var r = e.reportOptions;
  1597. if (e.startTime) {
  1598. var o = Date.now();
  1599. e.value === void 0 && (e.endTime = o), e.value === void 0 && (e.value = o - e.startTime);
  1600. }
  1601. 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) {
  1602. this.error.apply(this, _toConsumableArray(t));
  1603. return;
  1604. }
  1605. this.warn.apply(this, _toConsumableArray(t));
  1606. }
  1607. }, {
  1608. key: "warn",
  1609. value: function warn() {
  1610. for (var _len6 = arguments.length, e = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
  1611. e[_key6] = arguments[_key6];
  1612. }
  1613. return this.print.apply(this, ["warn", 3].concat(e));
  1614. }
  1615. }, {
  1616. key: "error",
  1617. value: function error() {
  1618. for (var _len7 = arguments.length, e = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
  1619. e[_key7] = arguments[_key7];
  1620. }
  1621. return this.print.apply(this, ["error", 4].concat(e));
  1622. }
  1623. }, {
  1624. key: "prefix",
  1625. value: function prefix(e) {
  1626. return "[".concat(this.module, "][").concat(e, "] ").concat(util.getFormattedDate(new Date()), ":");
  1627. }
  1628. }], [{
  1629. key: "setLevel",
  1630. value: function setLevel(e) {
  1631. this.level = e;
  1632. }
  1633. }]);
  1634. return Logger;
  1635. }();
  1636. var logger$1 = new Logger();
  1637. var AxiosCanceler = /*#__PURE__*/function () {
  1638. function AxiosCanceler() {
  1639. _classCallCheck(this, AxiosCanceler);
  1640. this.pendingMap = new Map();
  1641. }
  1642. _createClass(AxiosCanceler, [{
  1643. key: "addPending",
  1644. value: function addPending(e) {
  1645. var _this = this;
  1646. return new axios.CancelToken(function (t) {
  1647. _this.pendingMap.has(e) || _this.pendingMap.set(e, t);
  1648. });
  1649. }
  1650. }, {
  1651. key: "removeAllPending",
  1652. value: function removeAllPending() {
  1653. this.pendingMap.forEach(function (e) {
  1654. e && isFunction(e) && e();
  1655. }), this.pendingMap.clear();
  1656. }
  1657. }, {
  1658. key: "removePending",
  1659. value: function removePending(e) {
  1660. if (this.pendingMap.has(e)) {
  1661. var t = this.pendingMap.get(e);
  1662. t && t(e), this.pendingMap.delete(e);
  1663. }
  1664. }
  1665. }, {
  1666. key: "removeCancelToken",
  1667. value: function removeCancelToken(e) {
  1668. this.pendingMap.has(e) && this.pendingMap.delete(e);
  1669. }
  1670. }, {
  1671. key: "reset",
  1672. value: function reset() {
  1673. this.pendingMap = new Map();
  1674. }
  1675. }]);
  1676. return AxiosCanceler;
  1677. }();
  1678. 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); }; }
  1679. 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; } }
  1680. var Http1 = /*#__PURE__*/function (_EventEmitter) {
  1681. _inherits(Http1, _EventEmitter);
  1682. var _super = _createSuper$n(Http1);
  1683. function Http1() {
  1684. var _this;
  1685. _classCallCheck(this, Http1);
  1686. _this = _super.call(this);
  1687. _this.instatnce = axios.create(), _this.canceler = new AxiosCanceler();
  1688. return _this;
  1689. }
  1690. _createClass(Http1, [{
  1691. key: "requestConstant",
  1692. value: function requestConstant() {
  1693. return {
  1694. x_nounce: this.randomString(),
  1695. x_timestamp: new Date().getTime(),
  1696. x_os: "web"
  1697. };
  1698. }
  1699. }, {
  1700. key: "requestParams",
  1701. value: function requestParams(e) {
  1702. return oe({}, e.params);
  1703. }
  1704. }, {
  1705. key: "get",
  1706. value: function get(e) {
  1707. return this.request(le(oe({}, e), {
  1708. method: "GET"
  1709. }));
  1710. }
  1711. }, {
  1712. key: "post",
  1713. value: function post(e) {
  1714. return this.request(le(oe({}, e), {
  1715. method: "POST"
  1716. }));
  1717. }
  1718. }, {
  1719. key: "request",
  1720. value: function request(e) {
  1721. var _this2 = this;
  1722. var t = e.url,
  1723. _e$timeout = e.timeout,
  1724. r = _e$timeout === void 0 ? 1e4 : _e$timeout,
  1725. n = e.method,
  1726. o = e.key,
  1727. a = e.beforeRequest,
  1728. s = e.responseType,
  1729. l = e.data;
  1730. var _e$retry = e.retry,
  1731. u = _e$retry === void 0 ? 0 : _e$retry;
  1732. var c = this.patchUrl(t),
  1733. h = this.canceler.addPending(t);
  1734. a && isFunction(a) && a(e);
  1735. var f = this.requestParams(e);
  1736. var d = {
  1737. url: c,
  1738. method: n,
  1739. timeout: r,
  1740. cancelToken: h,
  1741. responseType: s,
  1742. params: f
  1743. };
  1744. n === "POST" && (d = oe({
  1745. data: l
  1746. }, d));
  1747. var _ = Date.now(),
  1748. g = function g() {
  1749. return _this2.instatnce.request(d).then(function (m) {
  1750. return o && logger$1.infoAndReportMeasurement({
  1751. metric: "http",
  1752. startTime: _,
  1753. extra: t,
  1754. group: "http",
  1755. tag: o
  1756. }), _this2.canceler.removeCancelToken(t), m;
  1757. }).catch(function (m) {
  1758. var v = axios.isCancel(m);
  1759. return u > 0 && !v ? (u--, logger$1.warn("request ".concat(t, " retry, left retry count"), u), g()) : (logger$1.infoAndReportMeasurement({
  1760. metric: "http",
  1761. startTime: _,
  1762. error: m,
  1763. extra: {
  1764. url: t,
  1765. isCanceled: v
  1766. },
  1767. tag: o,
  1768. group: "http"
  1769. }), _this2.canceler.removeCancelToken(t), Promise.reject(m));
  1770. });
  1771. };
  1772. return g();
  1773. }
  1774. }, {
  1775. key: "patchUrl",
  1776. value: function patchUrl(e) {
  1777. return e;
  1778. }
  1779. }, {
  1780. key: "randomString",
  1781. value: function randomString() {
  1782. var e = "";
  1783. var t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
  1784. r = t.length;
  1785. for (var n = 0; n < 8; n++) {
  1786. e += t.charAt(Math.floor(Math.random() * r));
  1787. }
  1788. return e;
  1789. }
  1790. }]);
  1791. return Http1;
  1792. }(EventEmitter);
  1793. var http1 = new Http1();
  1794. var ModelManager = /*#__PURE__*/function () {
  1795. function ModelManager(e, t) {
  1796. _classCallCheck(this, ModelManager);
  1797. this.avatarModelList = [];
  1798. this.skinList = [];
  1799. this.applicationConfig = null;
  1800. this.config = null;
  1801. this.appId = e, this.releaseId = t;
  1802. }
  1803. _createClass(ModelManager, [{
  1804. key: "findSkinConfig",
  1805. value: function () {
  1806. var _findSkinConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  1807. var t, n;
  1808. return regenerator.wrap(function _callee$(_context) {
  1809. while (1) {
  1810. switch (_context.prev = _context.next) {
  1811. case 0:
  1812. t = null;
  1813. _context.next = 3;
  1814. return this.getSkinsList();
  1815. case 3:
  1816. t = (this.skinList = _context.sent).find(function (n) {
  1817. return n.id === e;
  1818. });
  1819. if (!t) {
  1820. _context.next = 6;
  1821. break;
  1822. }
  1823. return _context.abrupt("return", t);
  1824. case 6:
  1825. n = "skin is invalid: skinId: ".concat(e);
  1826. return _context.abrupt("return", Promise.reject(new ParamError(n)));
  1827. case 8:
  1828. case "end":
  1829. return _context.stop();
  1830. }
  1831. }
  1832. }, _callee, this);
  1833. }));
  1834. function findSkinConfig(_x) {
  1835. return _findSkinConfig.apply(this, arguments);
  1836. }
  1837. return findSkinConfig;
  1838. }()
  1839. }, {
  1840. key: "findRoute",
  1841. value: function () {
  1842. var _findRoute = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e, t) {
  1843. var n, o;
  1844. return regenerator.wrap(function _callee2$(_context2) {
  1845. while (1) {
  1846. switch (_context2.prev = _context2.next) {
  1847. case 0:
  1848. _context2.next = 2;
  1849. return this.findSkinConfig(e);
  1850. case 2:
  1851. n = _context2.sent.routeList.find(function (o) {
  1852. return o.pathName === t;
  1853. });
  1854. if (n) {
  1855. _context2.next = 6;
  1856. break;
  1857. }
  1858. o = "find path failed: skinId: ".concat(e, ", pathName: ").concat(t);
  1859. return _context2.abrupt("return", Promise.reject(new ParamError(o)));
  1860. case 6:
  1861. return _context2.abrupt("return", (logger$1.debug("find route success", n), n));
  1862. case 7:
  1863. case "end":
  1864. return _context2.stop();
  1865. }
  1866. }
  1867. }, _callee2, this);
  1868. }));
  1869. function findRoute(_x2, _x3) {
  1870. return _findRoute.apply(this, arguments);
  1871. }
  1872. return findRoute;
  1873. }()
  1874. }, {
  1875. key: "findAssetList",
  1876. value: function () {
  1877. var _findAssetList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  1878. var r, n;
  1879. return regenerator.wrap(function _callee3$(_context3) {
  1880. while (1) {
  1881. switch (_context3.prev = _context3.next) {
  1882. case 0:
  1883. _context3.next = 2;
  1884. return this.findSkinConfig(e);
  1885. case 2:
  1886. r = _context3.sent.assetList;
  1887. if (r) {
  1888. _context3.next = 6;
  1889. break;
  1890. }
  1891. n = "find path failed: skinId: ".concat(e);
  1892. return _context3.abrupt("return", Promise.reject(new ParamError(n)));
  1893. case 6:
  1894. return _context3.abrupt("return", (logger$1.debug("find route success", r), r));
  1895. case 7:
  1896. case "end":
  1897. return _context3.stop();
  1898. }
  1899. }
  1900. }, _callee3, this);
  1901. }));
  1902. function findAssetList(_x4) {
  1903. return _findAssetList.apply(this, arguments);
  1904. }
  1905. return findAssetList;
  1906. }()
  1907. }, {
  1908. key: "findAsset",
  1909. value: function () {
  1910. var _findAsset = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e, t) {
  1911. var r,
  1912. n,
  1913. o,
  1914. a,
  1915. _args4 = arguments;
  1916. return regenerator.wrap(function _callee4$(_context4) {
  1917. while (1) {
  1918. switch (_context4.prev = _context4.next) {
  1919. case 0:
  1920. r = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : "id";
  1921. _context4.next = 3;
  1922. return this.findSkinConfig(e);
  1923. case 3:
  1924. n = _context4.sent;
  1925. if (!Array.isArray(t)) {
  1926. _context4.next = 6;
  1927. break;
  1928. }
  1929. return _context4.abrupt("return", t.map(function (a) {
  1930. return n.models.find(function (s) {
  1931. return s[r] === a;
  1932. });
  1933. }).filter(Boolean));
  1934. case 6:
  1935. o = n.models.find(function (a) {
  1936. return a[r] === t;
  1937. });
  1938. if (o) {
  1939. _context4.next = 10;
  1940. break;
  1941. }
  1942. a = "find asset failed: skinId: ".concat(e, ", keyValue: ").concat(t);
  1943. return _context4.abrupt("return", Promise.reject(new ParamError(a)));
  1944. case 10:
  1945. return _context4.abrupt("return", (logger$1.debug("find asset success", o), o));
  1946. case 11:
  1947. case "end":
  1948. return _context4.stop();
  1949. }
  1950. }
  1951. }, _callee4, this);
  1952. }));
  1953. function findAsset(_x5, _x6) {
  1954. return _findAsset.apply(this, arguments);
  1955. }
  1956. return findAsset;
  1957. }()
  1958. }, {
  1959. key: "findPoint",
  1960. value: function () {
  1961. var _findPoint = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(e, t) {
  1962. var n, o;
  1963. return regenerator.wrap(function _callee5$(_context5) {
  1964. while (1) {
  1965. switch (_context5.prev = _context5.next) {
  1966. case 0:
  1967. _context5.next = 2;
  1968. return this.findSkinConfig(e);
  1969. case 2:
  1970. n = _context5.sent.pointList.find(function (o) {
  1971. return o.id === t;
  1972. });
  1973. if (n) {
  1974. _context5.next = 6;
  1975. break;
  1976. }
  1977. o = "find point failed: skinId: ".concat(e, ", id: ").concat(t);
  1978. return _context5.abrupt("return", Promise.reject(new ParamError(o)));
  1979. case 6:
  1980. return _context5.abrupt("return", (logger$1.debug("find point success", n), n));
  1981. case 7:
  1982. case "end":
  1983. return _context5.stop();
  1984. }
  1985. }
  1986. }, _callee5, this);
  1987. }));
  1988. function findPoint(_x7, _x8) {
  1989. return _findPoint.apply(this, arguments);
  1990. }
  1991. return findPoint;
  1992. }()
  1993. }, {
  1994. key: "requestConfig",
  1995. value: function () {
  1996. var _requestConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6() {
  1997. var t, r, _ref, n, o;
  1998. return regenerator.wrap(function _callee6$(_context6) {
  1999. while (1) {
  2000. switch (_context6.prev = _context6.next) {
  2001. case 0:
  2002. if (!this.config) {
  2003. _context6.next = 2;
  2004. break;
  2005. }
  2006. return _context6.abrupt("return", this.config);
  2007. case 2:
  2008. // let e = `https://static.xverse.cn/console/config/${this.appId}/config.json`;
  2009. // this.releaseId && (e = `https://static.xverse.cn/console/config/${this.appId}/${this.releaseId}/config.json`);
  2010. // const t = Xverse.USE_TME_CDN ? "https://static.xverse.cn/tmeland/config/tme_config.json" : e;
  2011. t = './assets/config.json';
  2012. _context6.prev = 3;
  2013. _context6.next = 6;
  2014. return http1.get({
  2015. url: "".concat(t, "?t=").concat(Date.now()),
  2016. key: "config",
  2017. timeout: 6e3,
  2018. retry: 2
  2019. });
  2020. case 6:
  2021. r = _context6.sent;
  2022. _ref = r.data.data || {}, n = _ref.config, o = _ref.preload;
  2023. if (n) {
  2024. _context6.next = 10;
  2025. break;
  2026. }
  2027. throw new Error("config data parse error" + r.data);
  2028. case 10:
  2029. return _context6.abrupt("return", (this.config = {
  2030. config: n,
  2031. preload: o
  2032. }, logger$1.debug("get config success", this.config), this.config));
  2033. case 13:
  2034. _context6.prev = 13;
  2035. _context6.t0 = _context6["catch"](3);
  2036. return _context6.abrupt("return", Promise.reject(_context6.t0));
  2037. case 16:
  2038. case "end":
  2039. return _context6.stop();
  2040. }
  2041. }
  2042. }, _callee6, this, [[3, 13]]);
  2043. }));
  2044. function requestConfig() {
  2045. return _requestConfig.apply(this, arguments);
  2046. }
  2047. return requestConfig;
  2048. }()
  2049. }, {
  2050. key: "getApplicationConfig",
  2051. value: function () {
  2052. var _getApplicationConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7() {
  2053. var e;
  2054. return regenerator.wrap(function _callee7$(_context7) {
  2055. while (1) {
  2056. switch (_context7.prev = _context7.next) {
  2057. case 0:
  2058. if (!this.applicationConfig) {
  2059. _context7.next = 2;
  2060. break;
  2061. }
  2062. return _context7.abrupt("return", this.applicationConfig);
  2063. case 2:
  2064. _context7.prev = 2;
  2065. _context7.next = 5;
  2066. return this.requestConfig();
  2067. case 5:
  2068. e = _context7.sent;
  2069. return _context7.abrupt("return", (this.applicationConfig = e.config, this.applicationConfig));
  2070. case 9:
  2071. _context7.prev = 9;
  2072. _context7.t0 = _context7["catch"](2);
  2073. return _context7.abrupt("return", Promise.reject(_context7.t0));
  2074. case 12:
  2075. case "end":
  2076. return _context7.stop();
  2077. }
  2078. }
  2079. }, _callee7, this, [[2, 9]]);
  2080. }));
  2081. function getApplicationConfig() {
  2082. return _getApplicationConfig.apply(this, arguments);
  2083. }
  2084. return getApplicationConfig;
  2085. }()
  2086. }, {
  2087. key: "getAvatarModelList",
  2088. value: function () {
  2089. var _getAvatarModelList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8() {
  2090. var _yield$this$getApplic, e;
  2091. return regenerator.wrap(function _callee8$(_context8) {
  2092. while (1) {
  2093. switch (_context8.prev = _context8.next) {
  2094. case 0:
  2095. if (!this.avatarModelList.length) {
  2096. _context8.next = 2;
  2097. break;
  2098. }
  2099. return _context8.abrupt("return", this.avatarModelList);
  2100. case 2:
  2101. _context8.prev = 2;
  2102. _context8.next = 5;
  2103. return this.getApplicationConfig();
  2104. case 5:
  2105. _yield$this$getApplic = _context8.sent;
  2106. e = _yield$this$getApplic.avatars;
  2107. return _context8.abrupt("return", (this.avatarModelList = e.map(function (t) {
  2108. return {
  2109. name: t.name,
  2110. id: t.id,
  2111. modelUrl: t.url,
  2112. gender: t.gender,
  2113. components: t.components
  2114. };
  2115. }), this.avatarModelList));
  2116. case 10:
  2117. _context8.prev = 10;
  2118. _context8.t0 = _context8["catch"](2);
  2119. return _context8.abrupt("return", (logger$1.error(_context8.t0), []));
  2120. case 13:
  2121. case "end":
  2122. return _context8.stop();
  2123. }
  2124. }
  2125. }, _callee8, this, [[2, 10]]);
  2126. }));
  2127. function getAvatarModelList() {
  2128. return _getAvatarModelList.apply(this, arguments);
  2129. }
  2130. return getAvatarModelList;
  2131. }()
  2132. }, {
  2133. key: "getSkinsList",
  2134. value: function () {
  2135. var _getSkinsList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9() {
  2136. var _yield$this$getApplic2, e;
  2137. return regenerator.wrap(function _callee9$(_context9) {
  2138. while (1) {
  2139. switch (_context9.prev = _context9.next) {
  2140. case 0:
  2141. if (!this.skinList.length) {
  2142. _context9.next = 2;
  2143. break;
  2144. }
  2145. return _context9.abrupt("return", this.skinList);
  2146. case 2:
  2147. _context9.prev = 2;
  2148. _context9.next = 5;
  2149. return this.getApplicationConfig();
  2150. case 5:
  2151. _yield$this$getApplic2 = _context9.sent;
  2152. e = _yield$this$getApplic2.skins;
  2153. return _context9.abrupt("return", (this.skinList = e.map(function (t) {
  2154. var r;
  2155. return {
  2156. name: t.name,
  2157. dataVersion: t.id + t.versionId,
  2158. id: t.id,
  2159. fov: parseInt(t.fov || 90),
  2160. models: t.assetList.map(function (n) {
  2161. var o = n.assetId,
  2162. a = n.url,
  2163. s = n.thumbnailUrl,
  2164. l = n.typeName,
  2165. u = n.className;
  2166. return {
  2167. id: o,
  2168. modelUrl: a,
  2169. name: n.name,
  2170. thumbnailUrl: s,
  2171. typeName: l,
  2172. className: u === "\u4F4E\u6A21" ? "\u7C97\u6A21" : u
  2173. };
  2174. }),
  2175. routeList: (r = t.routeList) == null ? void 0 : r.map(function (n) {
  2176. var o = n.areaName,
  2177. a = n.attitude,
  2178. s = n.id,
  2179. l = n.pathName,
  2180. u = n.step,
  2181. c = n.birthPointList;
  2182. return {
  2183. areaName: o,
  2184. attitude: a,
  2185. id: s,
  2186. pathName: l,
  2187. step: u,
  2188. birthPointList: c.map(function (h) {
  2189. return {
  2190. camera: h.camera && {
  2191. position: util.objectParseFloat(h.camera.position),
  2192. angle: util.objectParseFloat(h.camera.rotation)
  2193. },
  2194. player: h.player && {
  2195. position: util.objectParseFloat(h.player.position),
  2196. angle: util.objectParseFloat(h.player.rotation)
  2197. }
  2198. };
  2199. })
  2200. };
  2201. }),
  2202. pointList: t.pointList.map(function (n) {
  2203. return le(oe({}, n), {
  2204. position: util.objectParseFloat(n.position),
  2205. rotation: util.objectParseFloat(n.rotation)
  2206. });
  2207. }),
  2208. versionId: t.versionId,
  2209. isEnable: t.isEnable,
  2210. assetList: t.assetList,
  2211. visibleRules: t.visibleRules,
  2212. animationList: t.animationList
  2213. };
  2214. }), this.skinList));
  2215. case 10:
  2216. _context9.prev = 10;
  2217. _context9.t0 = _context9["catch"](2);
  2218. return _context9.abrupt("return", (logger$1.error(_context9.t0), []));
  2219. case 13:
  2220. case "end":
  2221. return _context9.stop();
  2222. }
  2223. }
  2224. }, _callee9, this, [[2, 10]]);
  2225. }));
  2226. function getSkinsList() {
  2227. return _getSkinsList.apply(this, arguments);
  2228. }
  2229. return getSkinsList;
  2230. }()
  2231. }, {
  2232. key: "getBreathPointTextrueList",
  2233. value: function () {
  2234. var _getBreathPointTextrueList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10() {
  2235. return regenerator.wrap(function _callee10$(_context10) {
  2236. while (1) {
  2237. switch (_context10.prev = _context10.next) {
  2238. case 0:
  2239. return _context10.abrupt("return", [{
  2240. url: TEXTURE_URL
  2241. }]);
  2242. case 1:
  2243. case "end":
  2244. return _context10.stop();
  2245. }
  2246. }
  2247. }, _callee10);
  2248. }));
  2249. function getBreathPointTextrueList() {
  2250. return _getBreathPointTextrueList.apply(this, arguments);
  2251. }
  2252. return getBreathPointTextrueList;
  2253. }()
  2254. }], [{
  2255. key: "getInstance",
  2256. value: function getInstance(e, t) {
  2257. //getInstance(e, t) {
  2258. return this.instance || (this.instance = new ModelManager(e, t)), this.instance;
  2259. }
  2260. }, {
  2261. key: "findModels",
  2262. value: function findModels(e, t, r) {
  2263. //findModels(e, t, r) {
  2264. return e.filter(function (o) {
  2265. return o.typeName === t && o.className === r;
  2266. });
  2267. }
  2268. }, {
  2269. key: "findModel",
  2270. value: function findModel(e, t, r) {
  2271. //findModel(e, t, r) {
  2272. var n = e.filter(function (o) {
  2273. return o.typeName === t && o.className === r;
  2274. })[0];
  2275. return n || null;
  2276. }
  2277. }]);
  2278. return ModelManager;
  2279. }();
  2280. // export { modelManager };
  2281. var JoyStick = /*#__PURE__*/function () {
  2282. function JoyStick(e) {
  2283. _classCallCheck(this, JoyStick);
  2284. this._zone = document.createElement("div");
  2285. this._joystick = null;
  2286. this._room = e;
  2287. }
  2288. _createClass(JoyStick, [{
  2289. key: "init",
  2290. value: function init(e) {
  2291. var _this = this;
  2292. var _e$interval = e.interval,
  2293. t = _e$interval === void 0 ? 33 : _e$interval,
  2294. _e$triggerDistance = e.triggerDistance,
  2295. r = _e$triggerDistance === void 0 ? 25 : _e$triggerDistance,
  2296. _e$style = e.style,
  2297. n = _e$style === void 0 ? {
  2298. left: 0,
  2299. bottom: 0
  2300. } : _e$style,
  2301. o = function o(u, c) {
  2302. _this._room.actionsHandler.joystick({
  2303. degree: Math.floor(u),
  2304. level: Math.floor(c / 5)
  2305. });
  2306. },
  2307. a = this._zone;
  2308. 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({
  2309. zone: a,
  2310. mode: "static",
  2311. position: {
  2312. left: "50%",
  2313. top: "50%"
  2314. },
  2315. color: "white"
  2316. });
  2317. var s, l;
  2318. return this._joystick.on("move", function (u, c) {
  2319. s = c;
  2320. }), this._joystick.on("start", function () {
  2321. l = window.setInterval(function () {
  2322. s && s.distance > r && o && o(s.angle.degree, s.distance);
  2323. }, t);
  2324. }), this._joystick.on("end", function () {
  2325. l && window.clearInterval(l), l = void 0;
  2326. }), this._joystick;
  2327. }
  2328. }, {
  2329. key: "show",
  2330. value: function show() {
  2331. if (!this._joystick) throw new Error("joystick is not created");
  2332. this._zone.style.display = "block";
  2333. }
  2334. }, {
  2335. key: "hide",
  2336. value: function hide() {
  2337. if (!this._joystick) throw new Error("joystick is not created");
  2338. this._zone.style.display = "none";
  2339. }
  2340. }]);
  2341. return JoyStick;
  2342. }();
  2343. var CoreBroadcastType$1 = {
  2344. PlayAnimation: 'PlayAnimation'
  2345. };
  2346. var AvatarGroup = {
  2347. Npc: 'npc',
  2348. User: 'user'
  2349. };
  2350. var MessageHandleType$1 = {
  2351. MHT_Undefined: 0,
  2352. MHT_RoomMulticast: 1,
  2353. MHT_FollowListMulticast: 2,
  2354. MHT_CustomTargetSync: 3
  2355. };
  2356. var Broadcast$1 = /*#__PURE__*/function () {
  2357. function Broadcast(e, t) {
  2358. _classCallCheck(this, Broadcast);
  2359. this.room = e;
  2360. this.handlers = [];
  2361. this.init(t);
  2362. }
  2363. _createClass(Broadcast, [{
  2364. key: "init",
  2365. value: function init(t) {
  2366. this.handlers.push(t);
  2367. }
  2368. }, {
  2369. key: "handleBroadcast",
  2370. value: function () {
  2371. var _handleBroadcast = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  2372. return regenerator.wrap(function _callee$(_context) {
  2373. while (1) {
  2374. switch (_context.prev = _context.next) {
  2375. case 0:
  2376. _context.prev = 1;
  2377. JSON.parse(e.broadcastAction.data);
  2378. _context.next = 9;
  2379. break;
  2380. case 5:
  2381. _context.prev = 5;
  2382. _context.t0 = _context["catch"](1);
  2383. logger$1.error(_context.t0);
  2384. return _context.abrupt("return");
  2385. case 9:
  2386. case "end":
  2387. return _context.stop();
  2388. }
  2389. }
  2390. }, _callee, null, [[1, 5]]);
  2391. }));
  2392. function handleBroadcast(_x) {
  2393. return _handleBroadcast.apply(this, arguments);
  2394. }
  2395. return handleBroadcast;
  2396. }()
  2397. }, {
  2398. key: "broadcast",
  2399. value: function broadcast(e) {
  2400. var t = e.data,
  2401. _e$msgType = e.msgType,
  2402. r = _e$msgType === void 0 ? MessageHandleType$1.MHT_FollowListMulticast : _e$msgType,
  2403. n = e.targetUserIds;
  2404. return this.room.actionsHandler.broadcast({
  2405. data: t,
  2406. msgType: r,
  2407. targetUserIds: n
  2408. });
  2409. }
  2410. }]);
  2411. return Broadcast;
  2412. }();
  2413. var XAvatarLoader = /*#__PURE__*/function () {
  2414. function XAvatarLoader() {
  2415. _classCallCheck(this, XAvatarLoader);
  2416. E(this, "containers", new Map());
  2417. E(this, "meshes", new Map());
  2418. E(this, "animations", new Map());
  2419. E(this, "aniPath", new Map());
  2420. E(this, "binPath", new Map());
  2421. E(this, "texPath", new Map());
  2422. E(this, "matPath", new Map());
  2423. E(this, "mshPath", new Map());
  2424. E(this, "rootPath", new Map());
  2425. E(this, "meshTexList", new Map());
  2426. E(this, "_enableIdb", !0);
  2427. E(this, "_mappings", new Map());
  2428. E(this, "_sharedTex", new Map());
  2429. E(this, "avaliableAnimation", new Map());
  2430. E(this, "enableShareTexture", !0);
  2431. E(this, "enableShareAnimation", !0);
  2432. E(this, "fillEmptyLod", !0);
  2433. var e = new BABYLON.GLTFFileLoader();
  2434. BABYLON.SceneLoader.RegisterPlugin(e), e.preprocessUrlAsync = function (t) {
  2435. var r = avatarLoader._mappings.get(t);
  2436. return r ? Promise.resolve(r) : Promise.resolve(t);
  2437. };
  2438. }
  2439. _createClass(XAvatarLoader, [{
  2440. key: "getParsedUrl",
  2441. value: function getParsedUrl(e, t, r) {
  2442. var _this = this;
  2443. return new Promise(function (o, a) {
  2444. if (!r || r.indexOf(".zip") === -1) return o(r);
  2445. var s = _this.rootPath.get(r);
  2446. if (s) return o(s);
  2447. {
  2448. var l = ".zip",
  2449. u = r.replace(l, "") + COMPONENT_LIST_PREFIX;
  2450. e.urlTransformer(u, !0).then(function (c) {
  2451. if (!c) return a("Loading Failed");
  2452. new Response(c).json().then(function (h) {
  2453. var _, g, m, v, y, b, T;
  2454. var f = r.replace(l, ""),
  2455. d = f + ((_ = h == null ? void 0 : h.components) == null ? void 0 : _.url.replace("./", ""));
  2456. 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) {
  2457. var A = f + "/" + C.url;
  2458. _this.matPath.set(C.name, A);
  2459. }), h.bin) {
  2460. var C = f + "/" + h.bin.url;
  2461. _this.binPath.set(t, C);
  2462. var A = f + "/" + h.bin.url_lod2;
  2463. _this.binPath.set(t + "_" + avatarSetting.lod[1].level, A);
  2464. var S = f + "/" + h.bin.url_lod4;
  2465. _this.binPath.set(t + "_" + avatarSetting.lod[2].level, S);
  2466. }
  2467. return h.textures && h.textures.forEach(function (C) {
  2468. var A = f + "/" + C.url;
  2469. _this.texPath.set(C.url, A);
  2470. var S = _this.meshTexList.get(h.components.url);
  2471. C.type === "png" && (S ? S.find(function (P) {
  2472. return P === C.name;
  2473. }) || S.push(C.url) : _this.meshTexList.set(t, [C.name]));
  2474. }), o(d);
  2475. }).catch(function (h) {
  2476. logger$1.error("[Engine] parse json file error,".concat(h));
  2477. });
  2478. }).catch(function (c) {
  2479. logger$1.error("[Engine] ulrtransform error, cannot find resource in db,".concat(c));
  2480. });
  2481. }
  2482. });
  2483. }
  2484. }, {
  2485. key: "parse",
  2486. value: function () {
  2487. var _parse = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e, t) {
  2488. var _this2 = this;
  2489. var r;
  2490. return regenerator.wrap(function _callee$(_context) {
  2491. while (1) {
  2492. switch (_context.prev = _context.next) {
  2493. case 0:
  2494. r = [];
  2495. t.forEach(function (n) {
  2496. _this2._setAnimationList(n.id, n.animations), r.push(_this2.getParsedUrl(e, n.id, n.url)), n.components.forEach(function (o) {
  2497. o.units.forEach(function (a) {
  2498. r.push(_this2.getParsedUrl(e, a.name, a.url));
  2499. });
  2500. });
  2501. });
  2502. _context.next = 4;
  2503. return Promise.all(r);
  2504. case 4:
  2505. case "end":
  2506. return _context.stop();
  2507. }
  2508. }
  2509. }, _callee);
  2510. }));
  2511. function parse(_x, _x2) {
  2512. return _parse.apply(this, arguments);
  2513. }
  2514. return parse;
  2515. }()
  2516. }, {
  2517. key: "_setAnimationList",
  2518. value: function _setAnimationList(e, t) {
  2519. var _this3 = this;
  2520. t ? t.forEach(function (r) {
  2521. _this3.aniPath.set(e + "_" + r.name, r.url);
  2522. }) : logger$1.error("[Engine] no animation list exist, please check config for details");
  2523. }
  2524. }, {
  2525. key: "disposeContainer",
  2526. value: function disposeContainer() {
  2527. var _this4 = this;
  2528. this.containers.forEach(function (e, t) {
  2529. 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));
  2530. }), this._sharedTex.forEach(function (e, t) {
  2531. e.xReferenceCount == 0 && (e.dispose(), _this4._sharedTex.delete(t));
  2532. });
  2533. }
  2534. }, {
  2535. key: "enableIdb",
  2536. set: function set(e) {
  2537. this._enableIdb = e;
  2538. }
  2539. }, {
  2540. key: "getGlbPath",
  2541. value: function getGlbPath(e) {
  2542. return this.aniPath.get(e + ".glb");
  2543. }
  2544. }, {
  2545. key: "getGltfPath",
  2546. value: function getGltfPath(e) {
  2547. return this.mshPath.get(e + ".gltf");
  2548. }
  2549. }, {
  2550. key: "getPngUrl",
  2551. value: function getPngUrl(e) {
  2552. return this.texPath.get(e + ".png");
  2553. }
  2554. }, {
  2555. key: "getMeshUrl",
  2556. value: function getMeshUrl(e) {
  2557. return this.mshPath.get(e);
  2558. }
  2559. }, {
  2560. key: "_getSourceKey",
  2561. value: function _getSourceKey(e, t) {
  2562. return t && avatarSetting.lod[t] ? e + avatarSetting.lod[t].fileName.split(".")[0] : e;
  2563. }
  2564. }, {
  2565. key: "_getAnimPath",
  2566. value: function _getAnimPath(e, t) {
  2567. var r = this.aniPath.get(t + "_animations_" + t.split("_")[1]);
  2568. return r || (r = this.aniPath.get(t + "_" + e)), r;
  2569. }
  2570. }, {
  2571. key: "load",
  2572. value: function load(e, t, r, n) {
  2573. var _this5 = this;
  2574. return new Promise(function (o, a) {
  2575. _this5.loadGlb(e, t, r).then(function (s) {
  2576. return s ? o(s) : a("[Engine] container load failed");
  2577. }).catch(function () {
  2578. return a("[Engine] container load failed");
  2579. });
  2580. });
  2581. }
  2582. }, {
  2583. key: "_searchAnimation",
  2584. value: function _searchAnimation(e, t) {
  2585. var r;
  2586. return this.containers.forEach(function (n, o) {
  2587. var a = t.split("_")[0];
  2588. o.indexOf(a) != -1 && o.indexOf(e) != -1 && (r = n);
  2589. }), r;
  2590. }
  2591. }, {
  2592. key: "loadAnimRes",
  2593. value: function loadAnimRes(e, t, r) {
  2594. var _this6 = this;
  2595. return new Promise(function (n, o) {
  2596. var a = _this6._getAnimPath(t, r),
  2597. s = getAnimationKey(t, r);
  2598. if (a && _this6.containers.get(a)) return n(_this6.containers.get(a));
  2599. if (a) _this6._loadGlbFromBlob(e, s, a).then(function (l) {
  2600. return l.animationGroups.length == 0 ? (_this6.containers.delete(s), l.dispose(), Promise.reject("container does not contains animation data")) : n(l);
  2601. });else return o("no such url");
  2602. });
  2603. }
  2604. }, {
  2605. key: "loadGlb",
  2606. value: function loadGlb(e, t, r) {
  2607. var n = this.getMeshUrl(this._getSourceKey(t, r));
  2608. 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");
  2609. }
  2610. }, {
  2611. key: "loadGltf",
  2612. value: function loadGltf(e, t, r, n) {
  2613. var o = this._getSourceKey(t, r || 0);
  2614. var a = this.getGltfPath(o);
  2615. 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();
  2616. }
  2617. }, {
  2618. key: "loadSubsequence",
  2619. value: function loadSubsequence() {}
  2620. }, {
  2621. key: "loadVAT",
  2622. value: function loadVAT() {}
  2623. }, {
  2624. key: "getResourceName",
  2625. value: function getResourceName(e) {
  2626. return this.meshTexList.get(e);
  2627. }
  2628. }, {
  2629. key: "_loadGltfFromUrl",
  2630. value: function _loadGltfFromUrl(e, t, r) {
  2631. return BABYLON.SceneLoader.LoadAssetContainerAsync(r, t + ".gltf", e.Scene, null, ".gltf");
  2632. }
  2633. }, {
  2634. key: "_loadGlbFromBlob",
  2635. value: function _loadGlbFromBlob(e, t, r) {
  2636. var _this7 = this;
  2637. return new Promise(function (n, o) {
  2638. e.urlTransformer(r).then(function (a) {
  2639. BABYLON.SceneLoader.LoadAssetContainerAsync("", a, e.Scene, null, ".glb").then(function (s) {
  2640. if (s) {
  2641. if (_this7.enableShareTexture && s.textures.length > 0) {
  2642. var l = t.indexOf("_lod") != -1 ? t.slice(0, -5) : t,
  2643. u = _this7._sharedTex.get(l);
  2644. u ? (s.meshes[1].material._albedoTexture = u, s.textures.forEach(function (c) {
  2645. c.dispose();
  2646. }), s.textures = [u], u.xReferenceCount++) : (_this7._sharedTex.set(l, s.textures[0]), s.textures[0].xReferenceCount = 1);
  2647. }
  2648. return s.addAllToScene(), s.xReferenceCount = 0, s.meshes.forEach(function (l) {
  2649. l.setEnabled(!1);
  2650. }), _this7.containers.set(r, s), n(s);
  2651. } else o("glb file load failed");
  2652. });
  2653. });
  2654. });
  2655. }
  2656. }, {
  2657. key: "_loadGlbFromUrl",
  2658. value: function _loadGlbFromUrl(e, t, r) {
  2659. var _this8 = this;
  2660. return new Promise(function (n, o) {
  2661. BABYLON.SceneLoader.LoadAssetContainerAsync("", r, e.Scene, null, ".glb").then(function (a) {
  2662. if (a) {
  2663. if (a.addAllToScene(), a.meshes.forEach(function (s) {
  2664. s.setEnabled(!1);
  2665. }), _this8.enableShareTexture && a.textures.length > 0) {
  2666. var s = t.indexOf("_lod") != -1 ? t.slice(0, -5) : t,
  2667. l = _this8._sharedTex.get(s);
  2668. l ? (a.meshes[1].material._albedoTexture = l, a.textures.forEach(function (u) {
  2669. u.dispose();
  2670. }), a.textures = [l], l.xReferenceCount++) : (_this8._sharedTex.set(s, a.textures[0]), a.textures[0].xReferenceCount = 1);
  2671. }
  2672. return a.xReferenceCount = 0, _this8.containers.set(r, a), n(a);
  2673. } else o("glb file load failed");
  2674. });
  2675. });
  2676. }
  2677. }, {
  2678. key: "_loadGltfFromBlob",
  2679. value: function _loadGltfFromBlob(e, t, r, n) {
  2680. var _this9 = this;
  2681. return new Promise(function (o, a) {
  2682. var s = [];
  2683. var l = _this9._getSourceKey(t, r),
  2684. u = _this9.getGltfPath(l);
  2685. 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."));
  2686. var c = _this9.mshPath.get(l + ".gltf");
  2687. if (!c) return a("cannot find asset mshPath");
  2688. var h = _this9.binPath.get(l + ".bin");
  2689. if (!h) return a("cannot find asset binPath");
  2690. if (!n) {
  2691. var _ = _this9.meshTexList.get(t);
  2692. if (!_ || _.length == 0) return a("cannot find texture");
  2693. n = _[0];
  2694. }
  2695. var f = _this9.texPath.get(n + ".png");
  2696. if (!f) return a();
  2697. var d = _this9.texPath.get(n + "-astc.ktx");
  2698. if (!d) return a();
  2699. 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 () {
  2700. var _ = u.replace(l + ".gltf", "");
  2701. BABYLON.SceneLoader.LoadAssetContainerAsync(_, l + ".gltf", e.Scene, null, ".gltf").then(function (g) {
  2702. var v;
  2703. _this9.containers.set(u, g), g.addAllToScene(), g.meshes.forEach(function (y) {
  2704. y.setEnabled(!1);
  2705. });
  2706. var m = _this9._sharedTex.get(t);
  2707. 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);
  2708. });
  2709. });
  2710. });
  2711. }
  2712. }, {
  2713. key: "_blobMapping",
  2714. value: function _blobMapping(e, t) {
  2715. var _this10 = this;
  2716. return new Promise(function (r, n) {
  2717. e.urlTransformer(t).then(function (o) {
  2718. return o ? (_this10._mappings.set(t, o), r(t)) : n("[Engine] url urlTransformer parse error ".concat(t));
  2719. });
  2720. });
  2721. }
  2722. }]);
  2723. return XAvatarLoader;
  2724. }();
  2725. var avatarLoader = new XAvatarLoader();
  2726. var SyncEventType = {
  2727. Reset: 0,
  2728. Appear: 1,
  2729. Disappear: 2,
  2730. Move: 3,
  2731. ChangeRenderInfo: 4,
  2732. KeepAlive: 5,
  2733. Rotate: 6,
  2734. ET_RemoveVisitor: 7
  2735. };
  2736. var GetStateTypes = {
  2737. Default: 0,
  2738. Event: 1
  2739. };
  2740. var EAvatarRelationRank = {
  2741. Self: 0,
  2742. Npc: 1,
  2743. Friend: 2,
  2744. Stranger: 3,
  2745. Robot: 4,
  2746. Unknown: 5
  2747. };
  2748. var Person = {
  2749. Third: 0,
  2750. First: 1
  2751. };
  2752. var MotionType = {
  2753. Walk: 'walk',
  2754. Run: 'run',
  2755. Fly: 'fly'
  2756. };
  2757. var Queue = /*#__PURE__*/function () {
  2758. function Queue() {
  2759. _classCallCheck(this, Queue);
  2760. E(this, "queue", []);
  2761. E(this, "currentAction");
  2762. }
  2763. _createClass(Queue, [{
  2764. key: "append",
  2765. value: function () {
  2766. var _append = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  2767. var t, r;
  2768. return regenerator.wrap(function _callee$(_context) {
  2769. while (1) {
  2770. switch (_context.prev = _context.next) {
  2771. case 0:
  2772. if (!(this.queue.length === 0 || ((t = this.currentAction) == null ? void 0 : t.type) === e.type && this.queue.length === 1)) {
  2773. _context.next = 7;
  2774. break;
  2775. }
  2776. this.queue = [];
  2777. this.queue.push(e);
  2778. _context.next = 5;
  2779. return this.go();
  2780. case 5:
  2781. _context.next = 8;
  2782. break;
  2783. case 7:
  2784. ((r = this.queue[this.queue.length - 1]) == null ? void 0 : r.type) === e.type && this.queue.pop(), this.queue.push(e);
  2785. case 8:
  2786. case "end":
  2787. return _context.stop();
  2788. }
  2789. }
  2790. }, _callee, this);
  2791. }));
  2792. function append(_x) {
  2793. return _append.apply(this, arguments);
  2794. }
  2795. return append;
  2796. }()
  2797. }, {
  2798. key: "go",
  2799. value: function () {
  2800. var _go = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  2801. var e;
  2802. return regenerator.wrap(function _callee2$(_context2) {
  2803. while (1) {
  2804. switch (_context2.prev = _context2.next) {
  2805. case 0:
  2806. if (!(this.queue.length !== 0)) {
  2807. _context2.next = 9;
  2808. break;
  2809. }
  2810. e = this.queue[0];
  2811. this.currentAction = e;
  2812. _context2.next = 5;
  2813. return e.action();
  2814. case 5:
  2815. this.currentAction = void 0;
  2816. this.queue.splice(0, 1);
  2817. _context2.next = 9;
  2818. return this.go();
  2819. case 9:
  2820. case "end":
  2821. return _context2.stop();
  2822. }
  2823. }
  2824. }, _callee2, this);
  2825. }));
  2826. function go() {
  2827. return _go.apply(this, arguments);
  2828. }
  2829. return go;
  2830. }()
  2831. }, {
  2832. key: "reject",
  2833. value: function () {
  2834. var _reject = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
  2835. return regenerator.wrap(function _callee3$(_context3) {
  2836. while (1) {
  2837. switch (_context3.prev = _context3.next) {
  2838. case 0:
  2839. this.queue = [];
  2840. case 1:
  2841. case "end":
  2842. return _context3.stop();
  2843. }
  2844. }
  2845. }, _callee3, this);
  2846. }));
  2847. function reject() {
  2848. return _reject.apply(this, arguments);
  2849. }
  2850. return reject;
  2851. }()
  2852. }]);
  2853. return Queue;
  2854. }();
  2855. function _createForOfIteratorHelper$6(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$6(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; } } }; }
  2856. function _unsupportedIterableToArray$6(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$6(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$6(o, minLen); }
  2857. function _arrayLikeToArray$6(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; }
  2858. 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); }; }
  2859. 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; } }
  2860. var XverseAvatar = /*#__PURE__*/function (_EventEmitter) {
  2861. _inherits(XverseAvatar, _EventEmitter);
  2862. var _super = _createSuper$m(XverseAvatar);
  2863. function XverseAvatar(_ref) {
  2864. var _this;
  2865. var e = _ref.userId,
  2866. t = _ref.isHost,
  2867. r = _ref.room,
  2868. n = _ref.avatarId,
  2869. o = _ref.isSelf,
  2870. _ref$group = _ref.group,
  2871. a = _ref$group === void 0 ? AvatarGroup.Npc : _ref$group;
  2872. _classCallCheck(this, XverseAvatar);
  2873. _this = _super.call(this);
  2874. E(_assertThisInitialized(_this), "xAvatar");
  2875. E(_assertThisInitialized(_this), "_isHost", !1);
  2876. E(_assertThisInitialized(_this), "_room");
  2877. E(_assertThisInitialized(_this), "_withModel", !1);
  2878. E(_assertThisInitialized(_this), "_userId");
  2879. E(_assertThisInitialized(_this), "group", AvatarGroup.User);
  2880. E(_assertThisInitialized(_this), "state", "idle");
  2881. E(_assertThisInitialized(_this), "isLoading", !0);
  2882. E(_assertThisInitialized(_this), "_isMoving", !1);
  2883. E(_assertThisInitialized(_this), "_isRotating", !1);
  2884. E(_assertThisInitialized(_this), "_failed", !1);
  2885. E(_assertThisInitialized(_this), "disconnected", !1);
  2886. E(_assertThisInitialized(_this), "_avatarId");
  2887. E(_assertThisInitialized(_this), "prioritySync", !1);
  2888. E(_assertThisInitialized(_this), "priority", EAvatarRelationRank.Stranger);
  2889. E(_assertThisInitialized(_this), "_avatarModel");
  2890. E(_assertThisInitialized(_this), "_motionType", MotionType.Walk);
  2891. E(_assertThisInitialized(_this), "isSelf", !1);
  2892. E(_assertThisInitialized(_this), "_lastAnimTraceId", "");
  2893. E(_assertThisInitialized(_this), "statusSyncQueue", new Queue());
  2894. E(_assertThisInitialized(_this), "extraInfo", {});
  2895. E(_assertThisInitialized(_this), "setPosition", function (e) {
  2896. var t;
  2897. !_this._room.signal.isUpdatedYUV || (t = _this.xAvatar) == null || t.setPosition(positionPrecisionProtect(e));
  2898. });
  2899. E(_assertThisInitialized(_this), "setRotation", function (e) {
  2900. var t;
  2901. !_this._room.signal.isUpdatedYUV || (t = _this.xAvatar) == null || t.setRotation(rotationPrecisionProtect(e));
  2902. });
  2903. E(_assertThisInitialized(_this), "stopAnimation", function () {
  2904. var e, t;
  2905. (t = (e = _this.xAvatar) == null ? void 0 : e.controller) == null || t.stopAnimation();
  2906. });
  2907. E(_assertThisInitialized(_this), "_playAnimation", /*#__PURE__*/function () {
  2908. var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  2909. var t,
  2910. r,
  2911. o,
  2912. n,
  2913. _a,
  2914. _args = arguments;
  2915. return regenerator.wrap(function _callee$(_context) {
  2916. while (1) {
  2917. switch (_context.prev = _context.next) {
  2918. case 0:
  2919. t = _args.length > 1 && _args[1] !== undefined ? _args[1] : !0;
  2920. r = _args.length > 2 && _args[2] !== undefined ? _args[2] : !1;
  2921. if (_this._room.signal.isUpdatedYUV) {
  2922. _context.next = 4;
  2923. break;
  2924. }
  2925. return _context.abrupt("return");
  2926. case 4:
  2927. if (!(_this.state !== "idle" && !r)) {
  2928. _context.next = 6;
  2929. break;
  2930. }
  2931. return _context.abrupt("return", (logger$1.debug("_playAnimation", "state is not idle"), Promise.resolve("_playAnimation, state is not idle")));
  2932. case 6:
  2933. n = Date.now();
  2934. _context.prev = 7;
  2935. if ((o = _this.xAvatar) != null && o.controller) {
  2936. _context.next = 10;
  2937. break;
  2938. }
  2939. return _context.abrupt("return", Promise.reject(new InternalError("[avatar: ".concat(_this.userId, "] Play animation failed: ").concat(e, ", no controller"))));
  2940. case 10:
  2941. _this.isSelf && setTimeout(function () {
  2942. logger$1.infoAndReportMeasurement({
  2943. tag: e,
  2944. startTime: n,
  2945. value: 0,
  2946. metric: "playAnimationStart"
  2947. });
  2948. });
  2949. _a = util.uuid();
  2950. _this._lastAnimTraceId = _a;
  2951. _context.next = 15;
  2952. return _this.xAvatar.controller.playAnimation(e, t);
  2953. case 15:
  2954. _a === _this._lastAnimTraceId && !_this.isMoving && !t && e !== "Idle" && _this.xAvatar.controller.playAnimation("Idle", t).catch(function (s) {
  2955. logger$1.error("[avatar: ".concat(_this.userId, "] Play animation failed [force idle]"), s);
  2956. });
  2957. _this.isSelf && logger$1.infoAndReportMeasurement({
  2958. tag: e,
  2959. startTime: n,
  2960. extra: {
  2961. loop: t
  2962. },
  2963. metric: "playAnimationEnd"
  2964. });
  2965. _context.next = 22;
  2966. break;
  2967. case 19:
  2968. _context.prev = 19;
  2969. _context.t0 = _context["catch"](7);
  2970. return _context.abrupt("return", (logger$1.error("[avatar: ".concat(_this.userId, "] Play animation failed: ").concat(e), _context.t0), _this.isSelf && logger$1.infoAndReportMeasurement({
  2971. tag: e,
  2972. startTime: n,
  2973. metric: "playAnimationEnd",
  2974. error: _context.t0,
  2975. extra: {
  2976. loop: t
  2977. }
  2978. }), Promise.reject(_context.t0)));
  2979. case 22:
  2980. case "end":
  2981. return _context.stop();
  2982. }
  2983. }
  2984. }, _callee, null, [[7, 19]]);
  2985. }));
  2986. return function (_x) {
  2987. return _ref2.apply(this, arguments);
  2988. };
  2989. }());
  2990. E(_assertThisInitialized(_this), "changeComponents", /*#__PURE__*/function () {
  2991. var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e) {
  2992. var _ref4, t, _ref4$endAnimation, r, n, o;
  2993. return regenerator.wrap(function _callee2$(_context2) {
  2994. while (1) {
  2995. switch (_context2.prev = _context2.next) {
  2996. case 0:
  2997. _ref4 = e || {}, t = _ref4.mode, _ref4$endAnimation = _ref4.endAnimation, r = _ref4$endAnimation === void 0 ? "" : _ref4$endAnimation, n = JSON.parse(JSON.stringify(e.avatarComponents));
  2998. o = avatarComponentsValidate(n, _this._avatarModel);
  2999. return _context2.abrupt("return", (!ChangeComponentsMode[t] && !o && (o = new ParamError("changeComponents failed, mode: ".concat(t, " is invalid"))), o ? (logger$1.error(o), Promise.reject(o)) : _this._changeComponents({
  3000. avatarComponents: n,
  3001. mode: t,
  3002. endAnimation: r
  3003. }).then(function () {
  3004. _this.isSelf && t !== ChangeComponentsMode.Preview && _this.avatarComponentsSync(_this.avatarComponents);
  3005. })));
  3006. case 3:
  3007. case "end":
  3008. return _context2.stop();
  3009. }
  3010. }
  3011. }, _callee2);
  3012. }));
  3013. return function (_x2) {
  3014. return _ref3.apply(this, arguments);
  3015. };
  3016. }());
  3017. E(_assertThisInitialized(_this), "_changeComponents", /*#__PURE__*/function () {
  3018. var _ref5 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  3019. var o, _ref6, _ref6$avatarComponent, t, r, n, _a2, s, l, _iterator, _step, u, c, h, f, d;
  3020. return regenerator.wrap(function _callee3$(_context3) {
  3021. while (1) {
  3022. switch (_context3.prev = _context3.next) {
  3023. case 0:
  3024. _ref6 = e || {}, _ref6$avatarComponent = _ref6.avatarComponents, t = _ref6$avatarComponent === void 0 ? [] : _ref6$avatarComponent, r = _ref6.mode, n = Date.now();
  3025. _context3.prev = 1;
  3026. if (_this.xAvatar) {
  3027. _context3.next = 4;
  3028. break;
  3029. }
  3030. return _context3.abrupt("return", Promise.reject(new InternalError("changeComponents failed, without instance: xAvatar")));
  3031. case 4:
  3032. _context3.next = 6;
  3033. return avatarComponentsModify(_this._avatarModel, t);
  3034. case 6:
  3035. _a2 = _context3.sent;
  3036. s = [];
  3037. _context3.next = 10;
  3038. return avatarComponentsParser(_this._avatarModel, _a2, _this.avatarComponents);
  3039. case 10:
  3040. l = _context3.sent;
  3041. if (!(l.length === 0)) {
  3042. _context3.next = 13;
  3043. break;
  3044. }
  3045. return _context3.abrupt("return", _this.avatarComponents);
  3046. case 13:
  3047. _context3.next = 15;
  3048. return _this.beforeChangeComponentsHook(e);
  3049. case 15:
  3050. _iterator = _createForOfIteratorHelper$6(l);
  3051. try {
  3052. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  3053. u = _step.value;
  3054. c = u.id, h = u.type, f = u.url, d = u.suitComb;
  3055. s.push((o = _this.xAvatar) == null ? void 0 : o.addComponent(c, h, f, d));
  3056. }
  3057. } catch (err) {
  3058. _iterator.e(err);
  3059. } finally {
  3060. _iterator.f();
  3061. }
  3062. _context3.next = 19;
  3063. return Promise.all(s);
  3064. case 19:
  3065. _this.emit("componentsChanged", {
  3066. components: _this.avatarComponents,
  3067. mode: r
  3068. });
  3069. _this.isSelf && logger$1.infoAndReportMeasurement({
  3070. tag: "changeComponents",
  3071. startTime: n,
  3072. metric: "changeComponents",
  3073. extra: {
  3074. inputComponents: t,
  3075. finalComponents: _this.avatarComponents,
  3076. mode: ChangeComponentsMode[r]
  3077. }
  3078. });
  3079. return _context3.abrupt("return", _this.avatarComponents);
  3080. case 24:
  3081. _context3.prev = 24;
  3082. _context3.t0 = _context3["catch"](1);
  3083. return _context3.abrupt("return", (_this.isSelf && logger$1.infoAndReportMeasurement({
  3084. tag: "changeComponents",
  3085. startTime: n,
  3086. metric: "changeComponents",
  3087. error: _context3.t0,
  3088. extra: {
  3089. inputComponents: t,
  3090. finalComponents: _this.avatarComponents,
  3091. mode: ChangeComponentsMode[r]
  3092. }
  3093. }), Promise.reject(_context3.t0)));
  3094. case 27:
  3095. case "end":
  3096. return _context3.stop();
  3097. }
  3098. }
  3099. }, _callee3, null, [[1, 24]]);
  3100. }));
  3101. return function (_x3) {
  3102. return _ref5.apply(this, arguments);
  3103. };
  3104. }());
  3105. E(_assertThisInitialized(_this), "avatarComponentsSync", function (e) {
  3106. e = e.map(function (t) {
  3107. return {
  3108. type: t.type,
  3109. id: t.id
  3110. };
  3111. }), _this._room.actionsHandler.avatarComponentsSync(e);
  3112. });
  3113. E(_assertThisInitialized(_this), "hide", function () {
  3114. var e;
  3115. if ((e = _this.xAvatar) != null && e.hide()) return Promise.resolve("avatar: ".concat(_this.userId, " hide success"));
  3116. {
  3117. var _t = "avatar: ".concat(_this.userId, " hide failed ").concat(!_this.xAvatar && "without instance: xAvatar");
  3118. return logger$1.warn(_t), Promise.reject(_t);
  3119. }
  3120. });
  3121. E(_assertThisInitialized(_this), "show", function () {
  3122. var e;
  3123. if ((e = _this.xAvatar) != null && e.show()) return Promise.resolve("avatar: ".concat(_this.userId, " show success"));
  3124. {
  3125. var _t2 = "avatar: ".concat(_this.userId, " show failed ").concat(!_this.xAvatar && "without instance: xAvatar");
  3126. return logger$1.warn(_t2), Promise.reject(_t2);
  3127. }
  3128. });
  3129. E(_assertThisInitialized(_this), "sayTimer");
  3130. _this._userId = e, _this._room = r, _this.isSelf = o || !1, _this._withModel = !!n, _this._isHost = t || !1, _this._avatarId = n, _this.group = a, _this._room.modelManager.getAvatarModelList().then(function (s) {
  3131. var l = s.find(function (u) {
  3132. return u.id === n;
  3133. });
  3134. l && (_this._avatarModel = l);
  3135. });
  3136. return _this;
  3137. }
  3138. _createClass(XverseAvatar, [{
  3139. key: "avatarId",
  3140. get: function get() {
  3141. return this._avatarId;
  3142. }
  3143. }, {
  3144. key: "isRender",
  3145. get: function get() {
  3146. var e;
  3147. return !!((e = this.xAvatar) != null && e.isRender);
  3148. }
  3149. }, {
  3150. key: "isHidden",
  3151. get: function get() {
  3152. var e;
  3153. return !!((e = this.xAvatar) != null && e.isHide);
  3154. }
  3155. }, {
  3156. key: "motionType",
  3157. get: function get() {
  3158. return this._motionType;
  3159. },
  3160. set: function set(e) {
  3161. this._motionType = e;
  3162. }
  3163. }, {
  3164. key: "nickname",
  3165. get: function get() {
  3166. var e;
  3167. return (e = this.xAvatar) == null ? void 0 : e.nickName;
  3168. }
  3169. }, {
  3170. key: "words",
  3171. get: function get() {
  3172. var e;
  3173. return (e = this.xAvatar) == null ? void 0 : e.words;
  3174. }
  3175. }, {
  3176. key: "isHost",
  3177. get: function get() {
  3178. return this._isHost;
  3179. }
  3180. }, {
  3181. key: "failed",
  3182. get: function get() {
  3183. return this._failed;
  3184. }
  3185. }, {
  3186. key: "scale",
  3187. get: function get() {
  3188. var e;
  3189. return (e = this.xAvatar) == null ? void 0 : e.scale;
  3190. }
  3191. }, {
  3192. key: "animations",
  3193. get: function get() {
  3194. var e;
  3195. return !this.xAvatar || !this.xAvatar.controller ? [] : ((e = this.xAvatar) == null ? void 0 : e.getAvaliableAnimations()) || [];
  3196. }
  3197. }, {
  3198. key: "position",
  3199. get: function get() {
  3200. var e;
  3201. return (e = this.xAvatar) == null ? void 0 : e.position;
  3202. }
  3203. }, {
  3204. key: "rotation",
  3205. get: function get() {
  3206. var e;
  3207. return (e = this.xAvatar) == null ? void 0 : e.rotation;
  3208. }
  3209. }, {
  3210. key: "pose",
  3211. get: function get() {
  3212. return {
  3213. position: this.position,
  3214. angle: this.rotation
  3215. };
  3216. }
  3217. }, {
  3218. key: "id",
  3219. get: function get() {
  3220. return this.userId;
  3221. }
  3222. }, {
  3223. key: "isMoving",
  3224. get: function get() {
  3225. return this._isMoving;
  3226. },
  3227. set: function set(e) {
  3228. this._isMoving = e, this.state = e ? "moving" : "idle";
  3229. }
  3230. }, {
  3231. key: "isRotating",
  3232. get: function get() {
  3233. return this._isRotating;
  3234. },
  3235. set: function set(e) {
  3236. this._isRotating = e, this.state = e ? "rotating" : "idle";
  3237. }
  3238. }, {
  3239. key: "withModel",
  3240. get: function get() {
  3241. return this._withModel;
  3242. }
  3243. }, {
  3244. key: "avatarComponents",
  3245. get: function get() {
  3246. var e;
  3247. return JSON.parse(JSON.stringify(((e = this.xAvatar) == null ? void 0 : e.clothesList) || []));
  3248. }
  3249. }, {
  3250. key: "userId",
  3251. get: function get() {
  3252. return this._userId;
  3253. }
  3254. }, {
  3255. key: "removeWhenDisconnected",
  3256. get: function get() {
  3257. return this.extraInfo && this.extraInfo.removeWhenDisconnected !== void 0 ? this.extraInfo.removeWhenDisconnected : !0;
  3258. }
  3259. }, {
  3260. key: "setConnectionStatus",
  3261. value: function setConnectionStatus(e) {
  3262. this.disconnected !== e && (this.disconnected = e, e ? this.emit("disconnected") : this.emit("reconnected"), logger$1.warn("avatar ".concat(this.userId, " status changed, disconnected:"), e));
  3263. }
  3264. }, {
  3265. key: "setScale",
  3266. value: function setScale(e) {
  3267. var t;
  3268. (t = this.xAvatar) == null || t.setScale(e > 0 ? e : 1);
  3269. }
  3270. }, {
  3271. key: "playAnimation",
  3272. value: function () {
  3273. var _playAnimation = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  3274. var _this2 = this;
  3275. var _ref7, t, r, n, o;
  3276. return regenerator.wrap(function _callee4$(_context4) {
  3277. while (1) {
  3278. switch (_context4.prev = _context4.next) {
  3279. case 0:
  3280. _ref7 = e || {}, t = _ref7.animationName, r = _ref7.loop, n = _ref7.extra;
  3281. if (!this.isSelf) {
  3282. _context4.next = 13;
  3283. break;
  3284. }
  3285. if (!this.isMoving) {
  3286. _context4.next = 11;
  3287. break;
  3288. }
  3289. _context4.prev = 3;
  3290. _context4.next = 6;
  3291. return this.stopMoving();
  3292. case 6:
  3293. _context4.next = 11;
  3294. break;
  3295. case 8:
  3296. _context4.prev = 8;
  3297. _context4.t0 = _context4["catch"](3);
  3298. return _context4.abrupt("return", (logger$1.error("stopMoving error before playAnimation ".concat(t), _context4.t0), Promise.reject("stopMoving error before playAnimation ".concat(t))));
  3299. case 11:
  3300. o = {
  3301. info: {
  3302. userId: this.userId,
  3303. animation: t,
  3304. loop: r,
  3305. extra: encodeURIComponent(n || "")
  3306. },
  3307. broadcastType: CoreBroadcastType.PlayAnimation
  3308. };
  3309. this._room.avatarManager.broadcast.broadcast({
  3310. data: o
  3311. });
  3312. case 13:
  3313. return _context4.abrupt("return", (this.emit("animationStart", {
  3314. animationName: t,
  3315. extra: safeDecodeURIComponent(n || "")
  3316. }), this._playAnimation(t, r).then(function () {
  3317. _this2.emit("animationEnd", {
  3318. animationName: t,
  3319. extra: safeDecodeURIComponent(n || "")
  3320. });
  3321. })));
  3322. case 14:
  3323. case "end":
  3324. return _context4.stop();
  3325. }
  3326. }
  3327. }, _callee4, this, [[3, 8]]);
  3328. }));
  3329. function playAnimation(_x4) {
  3330. return _playAnimation.apply(this, arguments);
  3331. }
  3332. return playAnimation;
  3333. }()
  3334. }, {
  3335. key: "beforeChangeComponentsHook",
  3336. value: function () {
  3337. var _beforeChangeComponentsHook = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(e) {
  3338. return regenerator.wrap(function _callee5$(_context5) {
  3339. while (1) {
  3340. switch (_context5.prev = _context5.next) {
  3341. case 0:
  3342. case "end":
  3343. return _context5.stop();
  3344. }
  3345. }
  3346. }, _callee5);
  3347. }));
  3348. function beforeChangeComponentsHook(_x5) {
  3349. return _beforeChangeComponentsHook.apply(this, arguments);
  3350. }
  3351. return beforeChangeComponentsHook;
  3352. }()
  3353. }, {
  3354. key: "turnTo",
  3355. value: function turnTo(e) {
  3356. var _this3 = this;
  3357. if (this._room.viewMode === "observer") {
  3358. this._room.sceneManager.cameraComponent.MainCamera.setTarget(ue4Position2Xverse(e.point));
  3359. return;
  3360. }
  3361. return this._room.actionsHandler.turnTo(e).then(function () {
  3362. _this3.emit("viewChanged", {
  3363. extra: (e == null ? void 0 : e.extra) || ""
  3364. });
  3365. });
  3366. }
  3367. }, {
  3368. key: "moveTo",
  3369. value: function () {
  3370. var _moveTo = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e) {
  3371. var _ref8, t, _ref8$extra, r, a, o;
  3372. return regenerator.wrap(function _callee6$(_context6) {
  3373. while (1) {
  3374. switch (_context6.prev = _context6.next) {
  3375. case 0:
  3376. _ref8 = e || {}, t = _ref8.point, _ref8$extra = _ref8.extra, r = _ref8$extra === void 0 ? "" : _ref8$extra;
  3377. if (this.position) {
  3378. _context6.next = 3;
  3379. break;
  3380. }
  3381. return _context6.abrupt("return", Promise.reject(new ParamError("avatar position is empty")));
  3382. case 3:
  3383. if (!(typeof r != "string" || typeof r == "string" && r.length > 64)) {
  3384. _context6.next = 6;
  3385. break;
  3386. }
  3387. a = "extra shoud be string which length less than 64";
  3388. return _context6.abrupt("return", (logger$1.warn(a), Promise.reject(new ParamError(a))));
  3389. case 6:
  3390. o = util.getDistance(this.position, t) / 100 > 100 ? MotionType.Run : MotionType.Walk;
  3391. return _context6.abrupt("return", this._room.actionsHandler.moveTo({
  3392. point: t,
  3393. motionType: o,
  3394. extra: r
  3395. }));
  3396. case 8:
  3397. case "end":
  3398. return _context6.stop();
  3399. }
  3400. }
  3401. }, _callee6, this);
  3402. }));
  3403. function moveTo(_x6) {
  3404. return _moveTo.apply(this, arguments);
  3405. }
  3406. return moveTo;
  3407. }()
  3408. }, {
  3409. key: "stopMoving",
  3410. value: function () {
  3411. var _stopMoving = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7() {
  3412. return regenerator.wrap(function _callee7$(_context7) {
  3413. while (1) {
  3414. switch (_context7.prev = _context7.next) {
  3415. case 0:
  3416. return _context7.abrupt("return", this._room.actionsHandler.stopMoving());
  3417. case 1:
  3418. case "end":
  3419. return _context7.stop();
  3420. }
  3421. }
  3422. }, _callee7, this);
  3423. }));
  3424. function stopMoving() {
  3425. return _stopMoving.apply(this, arguments);
  3426. }
  3427. return stopMoving;
  3428. }()
  3429. }, {
  3430. key: "rotateTo",
  3431. value: function rotateTo(e) {
  3432. return this._room.actionsHandler.rotateTo(e);
  3433. }
  3434. }, {
  3435. key: "setRayCast",
  3436. value: function setRayCast(e) {
  3437. this.xAvatar && (this.xAvatar.isRayCastEnable = e);
  3438. }
  3439. }, {
  3440. key: "say",
  3441. value: function say(e, t) {
  3442. var _this4 = this;
  3443. if (this.sayTimer && window.clearTimeout(this.sayTimer), !this.xAvatar) {
  3444. logger$1.error("say failed, without instance: xAvatar");
  3445. return;
  3446. }
  3447. this.xAvatar.say(e, {
  3448. scale: this.xAvatar.scale,
  3449. isUser: this.group === AvatarGroup.User
  3450. }), !(t === void 0 || t <= 0) && (this.sayTimer = window.setTimeout(function () {
  3451. _this4.silent();
  3452. }, t));
  3453. }
  3454. }, {
  3455. key: "silent",
  3456. value: function silent() {
  3457. var e;
  3458. if (!this.xAvatar) {
  3459. logger$1.error("silent failed, without instance: xAvatar");
  3460. return;
  3461. }
  3462. (e = this.xAvatar) == null || e.silent();
  3463. }
  3464. }, {
  3465. key: "setMotionType",
  3466. value: function setMotionType(_ref9) {
  3467. var _this5 = this;
  3468. var _ref9$type = _ref9.type,
  3469. e = _ref9$type === void 0 ? MotionType.Walk : _ref9$type;
  3470. return this.motionType === e ? Promise.resolve() : this._room.actionsHandler.setMotionType(e).then(function () {
  3471. _this5._motionType = e;
  3472. });
  3473. }
  3474. }, {
  3475. key: "setNickname",
  3476. value: function setNickname(e) {
  3477. return this._room.actionsHandler.setNickName(encodeURIComponent(e));
  3478. }
  3479. }, {
  3480. key: "_setNickname",
  3481. value: function _setNickname(e) {
  3482. var r, n;
  3483. if (!e) return;
  3484. var t = safeDecodeURIComponent(e);
  3485. ((r = this.xAvatar) == null ? void 0 : r.nickName) !== t && (this.isSelf && (this._room.updateCurrentNetworkOptions({
  3486. nickname: t
  3487. }), this._room.options.nickname = t), (n = this.xAvatar) == null || n.setNickName(t, {
  3488. scale: this.xAvatar.scale
  3489. }));
  3490. }
  3491. }, {
  3492. key: "_move",
  3493. value: function _move(e) {
  3494. var s;
  3495. var _ref10 = e || {},
  3496. t = _ref10.start,
  3497. r = _ref10.end,
  3498. n = _ref10.walkSpeed,
  3499. _ref10$moveAnimation = _ref10.moveAnimation,
  3500. o = _ref10$moveAnimation === void 0 ? "Walking" : _ref10$moveAnimation,
  3501. _ref10$inter = _ref10.inter,
  3502. a = _ref10$inter === void 0 ? [] : _ref10$inter;
  3503. return (s = this.xAvatar) == null ? void 0 : s.move(t, r, n, o, a);
  3504. }
  3505. }, {
  3506. key: "setPickBoxScale",
  3507. value: function setPickBoxScale() {
  3508. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
  3509. return this.xAvatar ? (this.xAvatar.setPickBoxScale(e), !0) : (logger$1.error("setPickBoxScale failed, without instance: xAvatar"), !1);
  3510. }
  3511. }, {
  3512. key: "transfer",
  3513. value: function transfer(e) {
  3514. var t = e.player,
  3515. r = e.camera,
  3516. n = e.areaName,
  3517. o = e.attitude,
  3518. a = e.pathName;
  3519. return this._room.actionsHandler.transfer({
  3520. renderType: RenderType.RotationVideo,
  3521. player: t,
  3522. camera: r,
  3523. areaName: n,
  3524. attitude: o,
  3525. pathName: a,
  3526. tag: "transfer"
  3527. });
  3528. }
  3529. }, {
  3530. key: "avatarLoadedHook",
  3531. value: function avatarLoadedHook() {}
  3532. }, {
  3533. key: "avatarStartMovingHook",
  3534. value: function avatarStartMovingHook() {}
  3535. }, {
  3536. key: "avatarStopMovingHook",
  3537. value: function avatarStopMovingHook() {}
  3538. }, {
  3539. key: "statusSync",
  3540. value: function () {
  3541. var _statusSync = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8(e) {
  3542. var _this6 = this;
  3543. var t, r, n, _e$event$rotateEvent, o, s, _o, _a3, _s;
  3544. return regenerator.wrap(function _callee8$(_context8) {
  3545. while (1) {
  3546. switch (_context8.prev = _context8.next) {
  3547. case 0:
  3548. _context8.prev = 0;
  3549. if (!((t = e.event) != null && t.rotateEvent)) {
  3550. _context8.next = 10;
  3551. break;
  3552. }
  3553. _e$event$rotateEvent = e.event.rotateEvent, o = _e$event$rotateEvent.angle, s = this.motionType === MotionType.Run ? "Running" : "Walking";
  3554. _context8.t0 = this.rotation;
  3555. if (!_context8.t0) {
  3556. _context8.next = 10;
  3557. break;
  3558. }
  3559. this.rotation.yaw = this.rotation.yaw % 360;
  3560. o.yaw - this.rotation.yaw > 180 && (o.yaw = 180 - o.yaw);
  3561. this.isRotating = !0;
  3562. _context8.next = 10;
  3563. return this.xAvatar.rotateTo(o, this.rotation, s).then(function () {
  3564. _this6._playAnimation("Idle", !0), _this6.isRotating = !1;
  3565. });
  3566. case 10:
  3567. if (!(e.event && (((r = e.event) == null ? void 0 : r.points.length) || 0) > 1 && !this.isSelf)) {
  3568. _context8.next = 17;
  3569. break;
  3570. }
  3571. this.isMoving = !0, e.playerState.attitude && (this._motionType = e.playerState.attitude);
  3572. _o = this.motionType === MotionType.Run ? "Running" : "Walking", _a3 = this._room.skin.routeList.find(function (l) {
  3573. return l.areaName === _this6._room.currentState.areaName;
  3574. }), _s = ((_a3 == null ? void 0 : _a3.step) || 7.5) * 30 * (25 / 30);
  3575. _context8.t1 = this.position;
  3576. if (!_context8.t1) {
  3577. _context8.next = 17;
  3578. break;
  3579. }
  3580. _context8.next = 17;
  3581. return this._move({
  3582. start: this.position,
  3583. end: e.event.points[e.event.points.length - 1],
  3584. walkSpeed: _s,
  3585. moveAnimation: _o,
  3586. inter: (n = e.event) == null ? void 0 : n.points.slice(0, -1)
  3587. }).then(function () {
  3588. _this6.isMoving = !1;
  3589. });
  3590. case 17:
  3591. _context8.next = 22;
  3592. break;
  3593. case 19:
  3594. _context8.prev = 19;
  3595. _context8.t2 = _context8["catch"](0);
  3596. return _context8.abrupt("return");
  3597. case 22:
  3598. case "end":
  3599. return _context8.stop();
  3600. }
  3601. }
  3602. }, _callee8, this, [[0, 19]]);
  3603. }));
  3604. function statusSync(_x7) {
  3605. return _statusSync.apply(this, arguments);
  3606. }
  3607. return statusSync;
  3608. }()
  3609. }]);
  3610. return XverseAvatar;
  3611. }(EventEmitter);
  3612. 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); }; }
  3613. 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; } }
  3614. var TimeoutError = /*#__PURE__*/function (_XverseError) {
  3615. _inherits(TimeoutError, _XverseError);
  3616. var _super = _createSuper$l(TimeoutError);
  3617. function TimeoutError(e) {
  3618. _classCallCheck(this, TimeoutError);
  3619. return _super.call(this, 1003, e || "\u8D85\u65F6");
  3620. }
  3621. return _createClass(TimeoutError);
  3622. }(XverseError);
  3623. 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); }; }
  3624. 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; } }
  3625. var XverseAvatarManager = /*#__PURE__*/function (_EventEmitter) {
  3626. _inherits(XverseAvatarManager, _EventEmitter);
  3627. var _super = _createSuper$k(XverseAvatarManager);
  3628. function XverseAvatarManager(e) {
  3629. var _this;
  3630. _classCallCheck(this, XverseAvatarManager);
  3631. _this = _super.call(this);
  3632. _this.xAvatarManager = null;
  3633. _this.avatars = new Map();
  3634. _this.syncAvatarsLength = 0;
  3635. _this._room = e;
  3636. _this._usersStatistics();
  3637. _this.broadcast = _this.setupBroadcast();
  3638. e.on("skinChanged", function () {
  3639. _this.avatars.forEach(function (t) {
  3640. t.disconnected && _this.removeAvatar(t.userId, !0);
  3641. });
  3642. });
  3643. return _this;
  3644. }
  3645. _createClass(XverseAvatarManager, [{
  3646. key: "setupBroadcast",
  3647. value: function setupBroadcast() {
  3648. var _this2 = this;
  3649. return new Broadcast$1(this._room, /*#__PURE__*/function () {
  3650. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  3651. var t, r, n, o, a, _r$loop, s, l;
  3652. return regenerator.wrap(function _callee$(_context) {
  3653. while (1) {
  3654. switch (_context.prev = _context.next) {
  3655. case 0:
  3656. t = e.broadcastType, r = e.info;
  3657. if (!(t !== CoreBroadcastType$1.PlayAnimation)) {
  3658. _context.next = 3;
  3659. break;
  3660. }
  3661. return _context.abrupt("return");
  3662. case 3:
  3663. 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);
  3664. _context.t0 = l && !l.isSelf;
  3665. if (!_context.t0) {
  3666. _context.next = 10;
  3667. break;
  3668. }
  3669. l.emit("animationStart", {
  3670. animationName: o,
  3671. extra: decodeURIComponent(a)
  3672. });
  3673. _context.next = 9;
  3674. return l == null ? void 0 : l._playAnimation(o, s);
  3675. case 9:
  3676. l.emit("animationEnd", {
  3677. animationName: o,
  3678. extra: decodeURIComponent(a)
  3679. });
  3680. case 10:
  3681. case "end":
  3682. return _context.stop();
  3683. }
  3684. }
  3685. }, _callee);
  3686. }));
  3687. return function (_x) {
  3688. return _ref.apply(this, arguments);
  3689. };
  3690. }());
  3691. }
  3692. }, {
  3693. key: "hideAll",
  3694. value: function hideAll() {
  3695. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !0;
  3696. this.xAvatarManager.hideAll(e);
  3697. }
  3698. }, {
  3699. key: "showAll",
  3700. value: function showAll() {
  3701. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !0;
  3702. this.xAvatarManager.showAll(e);
  3703. }
  3704. }, {
  3705. key: "init",
  3706. value: function () {
  3707. var _init = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  3708. var e, t;
  3709. return regenerator.wrap(function _callee2$(_context2) {
  3710. while (1) {
  3711. switch (_context2.prev = _context2.next) {
  3712. case 0:
  3713. this.xAvatarManager = this._room.sceneManager.avatarComponent;
  3714. _context2.prev = 1;
  3715. _context2.next = 4;
  3716. return this._room.modelManager.getApplicationConfig();
  3717. case 4:
  3718. e = _context2.sent;
  3719. t = e.avatars;
  3720. if (!t) {
  3721. _context2.next = 10;
  3722. break;
  3723. }
  3724. _context2.next = 9;
  3725. return avatarLoader.parse(this._room.sceneManager, t);
  3726. case 9:
  3727. return _context2.abrupt("return");
  3728. case 10:
  3729. return _context2.abrupt("return", Promise.reject("cannot find avatar config list"));
  3730. case 13:
  3731. _context2.prev = 13;
  3732. _context2.t0 = _context2["catch"](1);
  3733. return _context2.abrupt("return", (logger$1.error(_context2.t0), Promise.reject("avatar mananger init error!")));
  3734. case 16:
  3735. case "end":
  3736. return _context2.stop();
  3737. }
  3738. }
  3739. }, _callee2, this, [[1, 13]]);
  3740. }));
  3741. function init() {
  3742. return _init.apply(this, arguments);
  3743. }
  3744. return init;
  3745. }()
  3746. }, {
  3747. key: "handleAvatar",
  3748. value: function () {
  3749. var _handleAvatar2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  3750. var _this3 = this;
  3751. var r, t, n, o, _n, a;
  3752. return regenerator.wrap(function _callee3$(_context3) {
  3753. while (1) {
  3754. switch (_context3.prev = _context3.next) {
  3755. case 0:
  3756. if (!(this._room.viewMode === "simple" || !this._room.joined || !e.newUserStates)) {
  3757. _context3.next = 2;
  3758. break;
  3759. }
  3760. return _context3.abrupt("return");
  3761. case 2:
  3762. t = e.newUserStates;
  3763. if (((r = this._room._userAvatar) == null ? void 0 : r.isMoving) && this._room._userAvatar.motionType === MotionType.Run) {
  3764. n = t.filter(function (a) {
  3765. return a.userId === _this3._room.userId;
  3766. }), o = t.filter(function (a) {
  3767. return a.userId !== _this3._room.userId;
  3768. }).slice(0, 2);
  3769. t = n.concat(o);
  3770. }
  3771. if (e.getStateType === GetStateTypes.Event) {
  3772. this.syncAvatarsLength = (t || []).length;
  3773. _n = this._room.avatars.filter(function (s) {
  3774. return s.group == AvatarGroup.User;
  3775. });
  3776. _n.filter(function (s) {
  3777. return !(t != null && t.find(function (l) {
  3778. return l.userId == s.userId;
  3779. }));
  3780. }).forEach(function (s) {
  3781. _this3.removeAvatar(s.userId);
  3782. });
  3783. a = t.filter(function (s) {
  3784. return !_n.find(function (l) {
  3785. return l.userId == s.userId;
  3786. });
  3787. });
  3788. this._handleAvatar(a);
  3789. }
  3790. this._handleAvatar(t);
  3791. case 6:
  3792. case "end":
  3793. return _context3.stop();
  3794. }
  3795. }
  3796. }, _callee3, this);
  3797. }));
  3798. function handleAvatar(_x2) {
  3799. return _handleAvatar2.apply(this, arguments);
  3800. }
  3801. return handleAvatar;
  3802. }()
  3803. }, {
  3804. key: "_handleAvatar",
  3805. value: function () {
  3806. var _handleAvatar3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  3807. var _this4 = this;
  3808. return regenerator.wrap(function _callee4$(_context4) {
  3809. while (1) {
  3810. switch (_context4.prev = _context4.next) {
  3811. case 0:
  3812. e == null || e.forEach(function (t) {
  3813. var n, o, a, s, l, u, c, h, f;
  3814. var r = _this4._room.userId === t.userId;
  3815. if (((n = t.event) == null ? void 0 : n.type) === SyncEventType.ET_RemoveVisitor) {
  3816. var d = (a = (o = t.event) == null ? void 0 : o.removeVisitorEvent) == null ? void 0 : a.removeVisitorEvent,
  3817. _ = JSON.parse(safeDecodeURIComponent(((l = (s = t.event) == null ? void 0 : s.removeVisitorEvent) == null ? void 0 : l.extraInfo) || "")),
  3818. g = _.code,
  3819. m = _.msg;
  3820. d === RemoveVisitorType.RVT_ChangeToObserver ? _this4._room.audienceViewModeHook() : d === RemoveVisitorType.RVT_MoveOutOfTheRoom && _this4._room.leave(), _this4._room.emit("visitorStatusChanged", {
  3821. code: g,
  3822. msg: m
  3823. });
  3824. }
  3825. if (t.event && [SyncEventType.Appear, SyncEventType.Reset].includes(t.event.type) || !t.event) {
  3826. var _d = _this4.avatars.get(t.userId);
  3827. if (t.playerState.avatarId && (_d == null ? void 0 : _d.avatarId) !== t.playerState.avatarId && (_d = void 0, _this4.removeAvatar(t.userId)), _d) {
  3828. 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) {
  3829. var _2 = safeParseComponents(t.playerState.avatarComponents);
  3830. _d._changeComponents({
  3831. avatarComponents: _2,
  3832. mode: ChangeComponentsMode.Preview
  3833. });
  3834. }
  3835. } else {
  3836. var _t$playerState$player = t.playerState.player,
  3837. _3 = _t$playerState$player.position,
  3838. _g = _t$playerState$player.angle,
  3839. _m = t.playerState.avatarId,
  3840. v = t.playerState.prioritySync,
  3841. y = safelyJsonParse(t.playerState.extra);
  3842. if (!_m) return;
  3843. var b = safeParseComponents(t.playerState.avatarComponents),
  3844. T = safeDecodeURIComponent(t.playerState.nickName),
  3845. C = _this4.calculatePriority(t.userId, y);
  3846. _this4.addAvatar({
  3847. userId: t.userId,
  3848. isHost: t.playerState.isHost,
  3849. nickname: T,
  3850. avatarPosition: _3,
  3851. avatarRotation: _g,
  3852. avatarScale: t.playerState.avatarSize,
  3853. avatarId: _m,
  3854. avatarComponents: t.playerState.person === Person.First ? [] : b,
  3855. priority: C,
  3856. group: AvatarGroup.User,
  3857. prioritySync: v,
  3858. extraInfo: y
  3859. }).then(function () {
  3860. var A;
  3861. (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"));
  3862. }).catch(function (A) {
  3863. r && (_this4.xAvatarManager.setMainAvatar(t.userId), _this4._room.emit("userAvatarFailed", {
  3864. error: A
  3865. }), logger$1.error("userAvatarFailed", A));
  3866. });
  3867. }
  3868. }
  3869. 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) {
  3870. (h = t == null ? void 0 : t.event) != null && h.id && _this4._room.actionsHandler.confirmEvent(t.event.id);
  3871. var _d2 = _this4.avatars.get(t.userId);
  3872. _d2 && _d2.withModel && !_d2.isLoading && _this4.updateAvatarPositionAndRotation(t);
  3873. }
  3874. if (!r && ((f = t.event) == null ? void 0 : f.type) === SyncEventType.Rotate) {
  3875. var _d3 = _this4.avatars.get(t.userId);
  3876. _d3.statusSyncQueue.append({
  3877. type: QueueType.Rotate,
  3878. action: function action() {
  3879. return _d3.statusSync(t);
  3880. }
  3881. });
  3882. }
  3883. });
  3884. case 1:
  3885. case "end":
  3886. return _context4.stop();
  3887. }
  3888. }
  3889. }, _callee4);
  3890. }));
  3891. function _handleAvatar(_x3) {
  3892. return _handleAvatar3.apply(this, arguments);
  3893. }
  3894. return _handleAvatar;
  3895. }()
  3896. }, {
  3897. key: "calculatePriority",
  3898. value: function calculatePriority(e, t) {
  3899. var n;
  3900. return e === this._room.userId ? EAvatarRelationRank.Self : (n = this._room.options.firends) != null && n.includes(e) ? EAvatarRelationRank.Friend : EAvatarRelationRank.Stranger;
  3901. }
  3902. }, {
  3903. key: "updateAvatarPositionAndRotation",
  3904. value: function updateAvatarPositionAndRotation(e) {
  3905. var t, r;
  3906. if ((t = e == null ? void 0 : e.playerState) != null && t.player) {
  3907. var _e$playerState$player = e.playerState.player,
  3908. n = _e$playerState$player.position,
  3909. o = _e$playerState$player.angle;
  3910. var a = this.avatars.get(e.userId);
  3911. if (!a) return;
  3912. 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({
  3913. type: QueueType.Move,
  3914. action: function action() {
  3915. return a.statusSync(e);
  3916. }
  3917. }), e.renderInfo && a.isSelf) {
  3918. var _e$renderInfo = e.renderInfo,
  3919. s = _e$renderInfo.isMoving,
  3920. l = _e$renderInfo.isRotating;
  3921. this._updateAvatarMovingStatus({
  3922. id: e.userId,
  3923. isMoving: !!s,
  3924. isRotating: !!l
  3925. });
  3926. }
  3927. }
  3928. }
  3929. }, {
  3930. key: "addAvatar",
  3931. value: function () {
  3932. var _addAvatar = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(e) {
  3933. 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;
  3934. return regenerator.wrap(function _callee5$(_context5) {
  3935. while (1) {
  3936. switch (_context5.prev = _context5.next) {
  3937. case 0:
  3938. 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;
  3939. g = this.avatars.get(t);
  3940. if (!g) {
  3941. _context5.next = 4;
  3942. break;
  3943. }
  3944. return _context5.abrupt("return", Promise.resolve(g));
  3945. case 4:
  3946. if (!(g = new XverseAvatarManager.subAvatar({
  3947. userId: t,
  3948. isHost: r,
  3949. isSelf: _,
  3950. room: this._room,
  3951. avatarComponents: l,
  3952. avatarId: o,
  3953. nickname: s,
  3954. group: c
  3955. }), this.avatars.set(t, g), !g.withModel)) {
  3956. _context5.next = 6;
  3957. break;
  3958. }
  3959. return _context5.abrupt("return", (g.isLoading = !1, g.avatarLoadedHook(), this._room.emit("avatarChanged", {
  3960. avatars: this._room.avatars
  3961. }), g));
  3962. case 6:
  3963. _context5.next = 8;
  3964. return this._room.modelManager.getAvatarModelList();
  3965. case 8:
  3966. v = _context5.sent.find(function (b) {
  3967. return b.id === o;
  3968. });
  3969. y = Date.now();
  3970. if (v) {
  3971. _context5.next = 12;
  3972. break;
  3973. }
  3974. return _context5.abrupt("return", (this._room.emit("avatarChanged", {
  3975. avatars: this._room.avatars
  3976. }), this.avatars.delete(t), Promise.reject("no such avatar model with id: ".concat(o))));
  3977. case 12:
  3978. _context5.prev = 12;
  3979. _context5.next = 15;
  3980. return avatarComponentsModify(v, l);
  3981. case 15:
  3982. b = _context5.sent;
  3983. b = b.filter(function (A) {
  3984. return A.type != "pendant";
  3985. });
  3986. _context5.next = 19;
  3987. return avatarComponentsParser(v, b);
  3988. case 19:
  3989. T = _context5.sent;
  3990. _context5.next = 22;
  3991. return this.xAvatarManager.loadAvatar({
  3992. id: t,
  3993. avatarType: o,
  3994. priority: u,
  3995. avatarManager: this.xAvatarManager,
  3996. assets: T,
  3997. status: {
  3998. avatarPosition: n,
  3999. avatarRotation: a,
  4000. avatarScale: h
  4001. }
  4002. })._timeout(8e3, new TimeoutError("loadAvatar timeout(8s)"));
  4003. case 22:
  4004. C = _context5.sent;
  4005. 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", {
  4006. avatars: this._room.avatars
  4007. }), s && g._setNickname(s), t === this._room.userId && (logger$1.infoAndReportMeasurement({
  4008. metric: "avatarLoadDuration",
  4009. startTime: y,
  4010. group: "costs"
  4011. }), logger$1.infoAndReportMeasurement({
  4012. metric: "avatarLoadAt",
  4013. startTime: this._room._startTime,
  4014. group: "costs"
  4015. })), g));
  4016. case 26:
  4017. _context5.prev = 26;
  4018. _context5.t0 = _context5["catch"](12);
  4019. return _context5.abrupt("return", (g.isLoading = !1, this._room.emit("avatarChanged", {
  4020. avatars: this._room.avatars
  4021. }), logger$1.error(_context5.t0), Promise.reject(_context5.t0)));
  4022. case 29:
  4023. case "end":
  4024. return _context5.stop();
  4025. }
  4026. }
  4027. }, _callee5, this, [[12, 26]]);
  4028. }));
  4029. function addAvatar(_x4) {
  4030. return _addAvatar.apply(this, arguments);
  4031. }
  4032. return addAvatar;
  4033. }()
  4034. }, {
  4035. key: "removeAvatar",
  4036. value: function removeAvatar(e) {
  4037. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
  4038. var r = this.avatars.get(e);
  4039. if (!!r) {
  4040. if (r.removeWhenDisconnected || t) {
  4041. r.xAvatar && this.xAvatarManager.deleteAvatar(r.xAvatar), this.avatars.delete(e), this._room.emit("avatarChanged", {
  4042. avatars: this._room.avatars
  4043. });
  4044. return;
  4045. }
  4046. r.setConnectionStatus(!0);
  4047. }
  4048. }
  4049. }, {
  4050. key: "clearOtherUsers",
  4051. value: function clearOtherUsers() {
  4052. var _this5 = this;
  4053. this.avatars.forEach(function (e) {
  4054. !e.isSelf && e.group === AvatarGroup.User && _this5.removeAvatar(e.userId);
  4055. });
  4056. }
  4057. }, {
  4058. key: "_updateAvatarMovingStatus",
  4059. value: function () {
  4060. var _updateAvatarMovingStatus2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e) {
  4061. var t, r, n, o, a, _a;
  4062. return regenerator.wrap(function _callee6$(_context6) {
  4063. while (1) {
  4064. switch (_context6.prev = _context6.next) {
  4065. case 0:
  4066. t = e.id, r = e.isMoving, n = e.isRotating, o = this.avatars.get(t);
  4067. if (!!o) {
  4068. if (o.isRotating !== n) {
  4069. o.isRotating = n;
  4070. a = "Idle";
  4071. n && (a = "Walking", o.motionType === MotionType.Run && (a = "Running")), o._playAnimation(a, !0, !0), logger$1.infoAndReportMeasurement({
  4072. startTime: Date.now(),
  4073. value: 0,
  4074. metric: n ? "userAvatarStartRotating" : "userAvatarStopRotating",
  4075. extra: {
  4076. motionType: o.motionType,
  4077. moveToExtra: this._room.moveToExtra
  4078. }
  4079. });
  4080. }
  4081. if (o.isMoving !== r) {
  4082. o.isMoving = r;
  4083. _a = "Idle";
  4084. r && (_a = "Walking", o.motionType === MotionType.Run && (_a = "Running")), r ? (o.avatarStartMovingHook(), o.emit("startMoving", {
  4085. target: o,
  4086. extra: this._room.moveToExtra
  4087. })) : (o.avatarStopMovingHook(), o.emit("stopMoving", {
  4088. target: o,
  4089. extra: this._room.moveToExtra
  4090. })), o._playAnimation(_a, !0, !0), logger$1.infoAndReportMeasurement({
  4091. startTime: Date.now(),
  4092. value: 0,
  4093. metric: r ? "userAvatarStartMoving" : "userAvatarStopMoving",
  4094. extra: {
  4095. motionType: o.motionType,
  4096. moveToExtra: this._room.moveToExtra
  4097. }
  4098. });
  4099. }
  4100. }
  4101. case 2:
  4102. case "end":
  4103. return _context6.stop();
  4104. }
  4105. }
  4106. }, _callee6, this);
  4107. }));
  4108. function _updateAvatarMovingStatus(_x5) {
  4109. return _updateAvatarMovingStatus2.apply(this, arguments);
  4110. }
  4111. return _updateAvatarMovingStatus;
  4112. }()
  4113. }, {
  4114. key: "_usersStatistics",
  4115. value: function _usersStatistics() {
  4116. var _this6 = this;
  4117. this.on("userAvatarLoaded", function () {
  4118. window.setInterval(function () {
  4119. var e = _this6._room.avatars.filter(function (r) {
  4120. return r.group === AvatarGroup.User;
  4121. }).length || 0,
  4122. t = _this6._room.avatars.filter(function (r) {
  4123. return r.group === AvatarGroup.User && r.isRender;
  4124. }).length || 0;
  4125. _this6._room.stats.assign({
  4126. userNum: e,
  4127. syncUserNum: _this6.syncAvatarsLength,
  4128. renderedUserNum: t
  4129. });
  4130. }, 3e3);
  4131. });
  4132. }
  4133. }]);
  4134. return XverseAvatarManager;
  4135. }(EventEmitter);
  4136. E(XverseAvatarManager, "subAvatar", XverseAvatar);
  4137. var PathManager = /*#__PURE__*/function () {
  4138. function PathManager() {
  4139. _classCallCheck(this, PathManager);
  4140. this.currentArea = '';
  4141. this.currentPathName = '';
  4142. this.currentAttitude = '';
  4143. this.speed = 0;
  4144. }
  4145. _createClass(PathManager, [{
  4146. key: "getSpeed",
  4147. value: function getSpeed(e) {
  4148. var t = {
  4149. guangchang: {
  4150. [MotionType.Walk]: 17,
  4151. [MotionType.Run]: 51
  4152. },
  4153. tower: {
  4154. [MotionType.Walk]: 12.5,
  4155. [MotionType.Run]: 25
  4156. },
  4157. zhiboting: {
  4158. [MotionType.Walk]: 12.5,
  4159. [MotionType.Run]: 25
  4160. },
  4161. youxiting: {
  4162. [MotionType.Walk]: 12.5,
  4163. [MotionType.Run]: 25
  4164. },
  4165. diqing: {
  4166. [MotionType.Walk]: 12.5,
  4167. [MotionType.Run]: 25
  4168. }
  4169. },
  4170. r = t[this.currentArea] || t.guangchang;
  4171. return this.speed = r[e] * 30, this.speed;
  4172. }
  4173. }]);
  4174. return PathManager;
  4175. }();
  4176. var CameraStates = {
  4177. Normal: 0,
  4178. ItemView: 1,
  4179. CGView: 2,
  4180. PathView: 3
  4181. };
  4182. var EImageQuality = {
  4183. low: 0,
  4184. mid: 1,
  4185. high: 2
  4186. };
  4187. var Actions = {
  4188. Clicking: 1,
  4189. PlayCG: 6,
  4190. Back: 7,
  4191. ChangeRoom: 8,
  4192. ChangeSkin: 13,
  4193. Joystick: 15,
  4194. Transfer: 18,
  4195. GetOnVehicle: 22,
  4196. GetOffVehicle: 23,
  4197. StopMoving: 34,
  4198. UnaryActionLine: 1e3,
  4199. Init: 1001,
  4200. Exit: 1002,
  4201. SetIFrameInfo: 1003,
  4202. GetNeighborPoints: 1004,
  4203. ReserveSeat: 1005,
  4204. GetReserveStatus: 1006,
  4205. ChangeNickname: 1007,
  4206. ChangeBitRateInfo: 1008,
  4207. Echo: 1009,
  4208. SetPlayerState: 1010,
  4209. TurnTo: 1011,
  4210. TurnToFace: 1012,
  4211. RotateTo: 1013,
  4212. Rotation: 1014,
  4213. CameraTurnTo: 1015,
  4214. ConfirmEvent: 1016,
  4215. Broadcast: 1017,
  4216. NotifyActionLine: 2e4,
  4217. AudienceChangeToVisitor: 1020,
  4218. VisitorChangeToAudience: 1021,
  4219. RemoveVisitor: 1022,
  4220. GetUserWithAvatar: 1023
  4221. };
  4222. 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); }; }
  4223. 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; } }
  4224. var Camera = /*#__PURE__*/function (_EventEmitter) {
  4225. _inherits(Camera, _EventEmitter);
  4226. var _super = _createSuper$j(Camera);
  4227. function Camera(e) {
  4228. var _this;
  4229. _classCallCheck(this, Camera);
  4230. _this = _super.call(this);
  4231. _this.initialFov = 0;
  4232. _this._state = CameraStates.Normal;
  4233. _this._person = Person.Third;
  4234. _this._cameraFollowing = !0;
  4235. _this._room = e;
  4236. return _this;
  4237. }
  4238. _createClass(Camera, [{
  4239. key: "checkPointOnLeftOrRight",
  4240. value: function checkPointOnLeftOrRight(e) {
  4241. var t = ue4Position2Xverse(e);
  4242. if (!t || this.checkPointInView(e)) return;
  4243. var o = this._room.scene.activeCamera;
  4244. if (!o) return;
  4245. var a = [o.target.x, o.target.y, o.target.z],
  4246. s = [o.position.x, o.position.y, o.position.z],
  4247. l = t.x,
  4248. u = t.y,
  4249. c = t.z,
  4250. h = calNormVector(s, a),
  4251. f = calNormVector(s, [l, u, c]);
  4252. return vectorCrossMulti(h, f) < 0 ? Direction.Right : Direction.Left;
  4253. }
  4254. }, {
  4255. key: "checkPointInView",
  4256. value: function checkPointInView(e, t, r) {
  4257. var n = ue4Position2Xverse({
  4258. x: e,
  4259. y: t,
  4260. z: r
  4261. });
  4262. if (!n) return !1;
  4263. for (var o = 0; o < 6; o++) {
  4264. if (this._room.scene.frustumPlanes[o].dotCoordinate(n) < 0) return !1;
  4265. }
  4266. return !0;
  4267. }
  4268. }, {
  4269. key: "person",
  4270. get: function get() {
  4271. return this._person;
  4272. }
  4273. }, {
  4274. key: "state",
  4275. get: function get() {
  4276. return this._state;
  4277. }
  4278. }, {
  4279. key: "pose",
  4280. get: function get() {
  4281. return this._room.currentClickingState.camera;
  4282. }
  4283. }, {
  4284. key: "cameraFollowing",
  4285. get: function get() {
  4286. return this._cameraFollowing;
  4287. },
  4288. set: function set(e) {
  4289. logger$1.info("cameraFollowing setter", e), this.setCameraFollowing({
  4290. isFollowHost: e
  4291. });
  4292. }
  4293. }, {
  4294. key: "setCameraFollowing",
  4295. value: function setCameraFollowing(_ref) {
  4296. _ref.isFollowHost;
  4297. }
  4298. }, {
  4299. key: "handleRenderInfo",
  4300. value: function handleRenderInfo(e) {
  4301. var t = e.renderInfo.cameraStateType,
  4302. r = this._room.sceneManager;
  4303. 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", {
  4304. state: t
  4305. })), this._room.isHost) return;
  4306. var n = e.playerState.isFollowHost;
  4307. !!n !== this._cameraFollowing && (this._cameraFollowing = !!n, this.emit("cameraFollowingChanged", {
  4308. cameraFollowing: !!n
  4309. }));
  4310. }
  4311. }, {
  4312. key: "setCameraState",
  4313. value: function setCameraState(_ref2) {
  4314. var e = _ref2.state;
  4315. if (this._state === e) {
  4316. logger$1.warn("You are already in ".concat(CameraStates[e], " camera state"));
  4317. return;
  4318. }
  4319. e === CameraStates.Normal || this._state === CameraStates.ItemView && logger$1.warn("CloseUp camera state can only be triggerd by room internally");
  4320. }
  4321. }, {
  4322. key: "turnToFace",
  4323. value: function turnToFace(_ref3) {
  4324. var _ref3$extra = _ref3.extra,
  4325. e = _ref3$extra === void 0 ? "" : _ref3$extra,
  4326. _ref3$offset = _ref3.offset,
  4327. t = _ref3$offset === void 0 ? 0 : _ref3$offset;
  4328. var r = {
  4329. action_type: Actions.TurnToFace,
  4330. turn_to_face_action: {
  4331. offset: t
  4332. }
  4333. };
  4334. return this.emit("viewChanged", {
  4335. extra: e
  4336. }), this._room.actionsHandler.sendData({
  4337. data: r
  4338. });
  4339. }
  4340. }, {
  4341. key: "isInDefaultView",
  4342. value: function isInDefaultView() {
  4343. if (!this._room.isHost) {
  4344. logger$1.warn("It is recommended to call the function on the host side");
  4345. return;
  4346. }
  4347. if (!this._room._currentClickingState) return logger$1.error("CurrentState should not be empty"), !1;
  4348. var _this$_room$_currentC = this._room._currentClickingState,
  4349. e = _this$_room$_currentC.camera,
  4350. t = _this$_room$_currentC.player;
  4351. return Math.abs(t.angle.yaw - 180 - e.angle.yaw) % 360 <= 4;
  4352. }
  4353. }, {
  4354. key: "screenShot",
  4355. value: function () {
  4356. var _screenShot = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(_ref4) {
  4357. var e, _ref4$autoSave, t, r, n, o;
  4358. return regenerator.wrap(function _callee$(_context) {
  4359. while (1) {
  4360. switch (_context.prev = _context.next) {
  4361. case 0:
  4362. e = _ref4.name, _ref4$autoSave = _ref4.autoSave, t = _ref4$autoSave === void 0 ? !1 : _ref4$autoSave;
  4363. r = this._room.scene.getEngine(), n = this._room.scene.activeCamera;
  4364. _context.prev = 2;
  4365. this._room.sceneManager.setImageQuality(EImageQuality.high);
  4366. _context.next = 6;
  4367. return CreateScreenshotAsync(r, n, {
  4368. precision: 1
  4369. });
  4370. case 6:
  4371. o = _context.sent;
  4372. return _context.abrupt("return", (this._room.sceneManager.setImageQuality(EImageQuality.low), t === !0 && downloadFileByBase64(o, e), Promise.resolve(o)));
  4373. case 10:
  4374. _context.prev = 10;
  4375. _context.t0 = _context["catch"](2);
  4376. return _context.abrupt("return", (this._room.sceneManager.setImageQuality(EImageQuality.low), Promise.reject(_context.t0)));
  4377. case 13:
  4378. case "end":
  4379. return _context.stop();
  4380. }
  4381. }
  4382. }, _callee, this, [[2, 10]]);
  4383. }));
  4384. function screenShot(_x) {
  4385. return _screenShot.apply(this, arguments);
  4386. }
  4387. return screenShot;
  4388. }()
  4389. }, {
  4390. key: "changeToFirstPerson",
  4391. value: function changeToFirstPerson(e, t, r) {
  4392. var _this2 = this;
  4393. var n = e.camera,
  4394. o = e.player,
  4395. a = e.attitude,
  4396. s = e.areaName,
  4397. l = e.pathName;
  4398. return this._room.actionsHandler.requestPanorama({
  4399. camera: n,
  4400. player: o,
  4401. attitude: a,
  4402. areaName: s,
  4403. pathName: l
  4404. }, t, r).then(function () {
  4405. _this2._room.networkController.rtcp.workers.changePanoMode(!0);
  4406. var _ref5 = o || {},
  4407. u = _ref5.position,
  4408. c = _ref5.angle;
  4409. _this2._room.sceneManager.cameraComponent.changeToFirstPersonView({
  4410. position: u,
  4411. rotation: c
  4412. });
  4413. });
  4414. }
  4415. }, {
  4416. key: "setPerson",
  4417. value: function setPerson(e) {
  4418. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
  4419. camera: this._room._currentClickingState.camera,
  4420. player: this._room._currentClickingState.player
  4421. };
  4422. var r = Date.now();
  4423. return this._setPerson(e, t).then(function (n) {
  4424. return logger$1.infoAndReportMeasurement({
  4425. tag: Person[e],
  4426. startTime: r,
  4427. metric: "setPerson"
  4428. }), n;
  4429. }).catch(function (n) {
  4430. return logger$1.infoAndReportMeasurement({
  4431. tag: Person[e],
  4432. startTime: r,
  4433. metric: "setPerson",
  4434. error: n
  4435. }), Promise.reject(n);
  4436. });
  4437. }
  4438. }, {
  4439. key: "_setPerson",
  4440. value: function _setPerson(e) {
  4441. var _this3 = this;
  4442. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
  4443. camera: this._room._currentClickingState.camera,
  4444. player: this._room._currentClickingState.player
  4445. };
  4446. return e !== Person.First && e !== Person.Third ? Promise.reject("invalid person " + e) : !t.camera || !t.player ? Promise.reject(new ParamError("wrong camera or player")) : e === Person.First ? this._room.panorama.access({
  4447. camera: t.camera,
  4448. player: t.player,
  4449. tag: "setPerson"
  4450. }).then(function () {
  4451. var o, a;
  4452. _this3._person = e, (o = _this3._room._userAvatar) == null || o.hide();
  4453. var _ref6 = ((a = _this3._room.currentClickingState) == null ? void 0 : a.camera) || {},
  4454. r = _ref6.position,
  4455. n = _ref6.angle;
  4456. !r || !n || _this3._room.sceneManager.cameraComponent.changeToFirstPersonView({
  4457. position: r,
  4458. rotation: n
  4459. });
  4460. }) : this._room.panorama.exit({
  4461. camera: t.camera,
  4462. player: t.player
  4463. }).then(function () {
  4464. var r, n;
  4465. _this3._person = e, (r = _this3._room._userAvatar) != null && r.xAvatar && ((n = _this3._room._userAvatar) == null || n.xAvatar.show());
  4466. });
  4467. }
  4468. }, {
  4469. key: "setCameraPose",
  4470. value: function setCameraPose(e) {
  4471. this._room.sceneManager.cameraComponent.setCameraPose({
  4472. position: e.position,
  4473. rotation: e.angle
  4474. });
  4475. }
  4476. }, {
  4477. key: "setMainCameraRotationLimit",
  4478. value: function setMainCameraRotationLimit(e) {
  4479. var t = e.limitAxis,
  4480. r = e.limitRotation;
  4481. this._room.sceneManager.cameraComponent.setMainCameraRotationLimit(t, r);
  4482. }
  4483. }]);
  4484. return Camera;
  4485. }(EventEmitter);
  4486. 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); }; }
  4487. 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; } }
  4488. var numberFormat = new Intl.NumberFormat(window.navigator.language, {
  4489. maximumFractionDigits: 0
  4490. });
  4491. var Stats = /*#__PURE__*/function (_EventEmitter) {
  4492. _inherits(Stats, _EventEmitter);
  4493. var _super = _createSuper$i(Stats);
  4494. function Stats(e) {
  4495. var _this;
  4496. _classCallCheck(this, Stats);
  4497. _this = _super.call(this);
  4498. _this._netInterval = null;
  4499. _this._disabled = !1;
  4500. _this._show = !1;
  4501. _this._aggregatedStats = {};
  4502. _this._displayElement = null;
  4503. _this._extraStats = {};
  4504. _this._networkSamples = [];
  4505. _this.externalStats = null;
  4506. _this.constructedTime = null;
  4507. _this.room = e, _this.constructedTime = Date.now(), _this._interval = window.setInterval(function () {
  4508. var t, r, n;
  4509. _this._disabled || _this.onStats((n = (r = (t = e.networkController) == null ? void 0 : t.rtcp) == null ? void 0 : r.workers) == null ? void 0 : n.uploadDataToServer());
  4510. }, 1e3), _this._netInterval = window.setInterval(function () {
  4511. _this.getIsWeakNet();
  4512. }, NET_INTERVAL * 1e3);
  4513. return _this;
  4514. }
  4515. _createClass(Stats, [{
  4516. key: "isShow",
  4517. get: function get() {
  4518. return this._show;
  4519. }
  4520. }, {
  4521. key: "assign",
  4522. value: function assign(e) {
  4523. Object.assign(this._extraStats, e), ((e == null ? void 0 : e.hb) || (e == null ? void 0 : e.rtt)) && this.startStatsNetSamples();
  4524. }
  4525. }, {
  4526. key: "appendExternalStats",
  4527. value: function appendExternalStats(e) {
  4528. var _this2 = this;
  4529. var t = {};
  4530. if (!e || typeof e != "object") {
  4531. console.warn("appendExternalStats should be plain object");
  4532. return;
  4533. }
  4534. Object.keys(e).forEach(function (r) {
  4535. Object.prototype.hasOwnProperty.call(_this2._aggregatedStats, r) ? console.warn("".concat(r, " is duplicate with internal stats")) : t[r] = e[r];
  4536. }), !(Object.keys(t).length > 10) && (this.externalStats = t);
  4537. }
  4538. }, {
  4539. key: "getRtt",
  4540. value: function getRtt() {
  4541. var e = this._extraStats.rtt;
  4542. return typeof e != "number" ? 0 : e > 999 ? 999 : e;
  4543. }
  4544. }, {
  4545. key: "enable",
  4546. value: function enable() {
  4547. this._disabled = !1;
  4548. }
  4549. }, {
  4550. key: "disable",
  4551. value: function disable() {
  4552. this._disabled = !0;
  4553. }
  4554. }, {
  4555. key: "disableNet",
  4556. value: function disableNet() {
  4557. this._netInterval && window.clearInterval(this._netInterval);
  4558. }
  4559. }, {
  4560. key: "show",
  4561. value: function show() {
  4562. this._show = !0, this._render();
  4563. }
  4564. }, {
  4565. key: "hide",
  4566. value: function hide() {
  4567. this._show = !1, this._displayElement && document.body.removeChild(this._displayElement), this._displayElement = null;
  4568. }
  4569. }, {
  4570. key: "getIsWeakNet",
  4571. value: function getIsWeakNet() {
  4572. var _this3 = this;
  4573. var e = !1;
  4574. var t = this._networkSamples.length - 1;
  4575. if (t < 0) return;
  4576. var r = this._networkSamples[t].time,
  4577. n = this._networkSamples[0].time,
  4578. o = r - n,
  4579. a = 1e3 * (DURATION - 2);
  4580. if (o < a) return;
  4581. var s = this._networkSamples.map(function (g) {
  4582. return _this3.isNetDelay(g, "rtt");
  4583. }),
  4584. l = this._networkSamples.map(function (g) {
  4585. return _this3.isNetDelay(g, "hb");
  4586. }),
  4587. u = s.reduce(function (g, m) {
  4588. return g + m;
  4589. }, 0),
  4590. c = l.reduce(function (g, m) {
  4591. return g + m;
  4592. }, 0),
  4593. h = Math.floor(u / this._networkSamples.length) * 100,
  4594. f = Math.floor(c / this._networkSamples.length) * 100,
  4595. d = 70;
  4596. (h >= d || f >= d) && (e = !0);
  4597. var _ = this.room.viewMode === "observer" || this.room.viewMode === "serverless";
  4598. e && !_ && (logger$1.infoAndReportMeasurement({
  4599. metric: "weakNetwork",
  4600. startTime: Date.now(),
  4601. extra: {
  4602. msg: this._networkSamples.slice(20),
  4603. netDelayRTTValues: u,
  4604. netDelayHBValues: c
  4605. }
  4606. }), this.emit("weakNetwork"));
  4607. }
  4608. }, {
  4609. key: "startStatsNetSamples",
  4610. value: function startStatsNetSamples() {
  4611. var _this$_extraStats = this._extraStats,
  4612. e = _this$_extraStats.rtt,
  4613. t = _this$_extraStats.hb;
  4614. if (e || t) {
  4615. var r = {
  4616. rtt: e,
  4617. hb: t,
  4618. time: new Date().getTime()
  4619. };
  4620. this._networkSamples.push(r);
  4621. var n = this._networkSamples.length - 1;
  4622. if (n < 0) return;
  4623. var o = this._networkSamples[n].time,
  4624. a = 1e3 * DURATION;
  4625. this._networkSamples = this._networkSamples.filter(function (s) {
  4626. return s.time > o - a;
  4627. });
  4628. }
  4629. }
  4630. }, {
  4631. key: "isNetDelay",
  4632. value: function isNetDelay(e, t) {
  4633. return t === "rtt" ? e.rtt > RTT_MAX_VALUE ? 1 : 0 : t === "hb" && e.hb > HB_MAX_VALUE ? 1 : 0;
  4634. }
  4635. }, {
  4636. key: "getPreciesTimer",
  4637. value: function getPreciesTimer(e, t) {
  4638. var r = t * 1e3,
  4639. n = new Date().getTime();
  4640. var o = 0;
  4641. o++;
  4642. var a = new Date().getTime() - (n + o * 1e3),
  4643. s = r - a,
  4644. l = setTimeout(function () {
  4645. clearTimeout(l), e();
  4646. }, s);
  4647. }
  4648. }, {
  4649. key: "_render",
  4650. value: function _render() {
  4651. var c, h, f, d, _, g, m, v, y, b, T, C, A, S, P, R, M, x, I, w;
  4652. if (!this._aggregatedStats) return;
  4653. 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));
  4654. var e = [],
  4655. t = Date.now() - this.constructedTime,
  4656. r = Math.floor(t / 1e3 % 60),
  4657. n = Math.floor(t / (1e3 * 60) % 60),
  4658. o = Math.floor(t / (1e3 * 60 * 60) % 24),
  4659. a = o < 10 ? "0" + o.toString() : o.toString(),
  4660. s = n < 10 ? "0" + n : n,
  4661. l = r < 10 ? "0" + r : r;
  4662. e.push({
  4663. key: new Date(Math.floor(this._aggregatedStats.timestamp || 0)).toLocaleString("en-GB"),
  4664. value: a + ":" + s + ":" + l
  4665. }), e.push({
  4666. key: "rtt: " + this._extraStats.rtt + " hb: " + this._extraStats.hb,
  4667. value: "FPS: " + this._extraStats.fps + " avatar: " + ((c = this.room._userAvatar) == null ? void 0 : c.state)
  4668. }), e.push({
  4669. key: "SDK: " + Xverse$1.SUB_PACKAGE_VERSION,
  4670. value: "ENGINE:" + VERSION$1 + " uid:" + this._extraStats.userId
  4671. }), e.push({
  4672. key: "\u540C\u6B65/\u6709\u6548/\u663E\u793A\u73A9\u5BB6",
  4673. value: "".concat(this._extraStats.syncUserNum || 0, "/").concat(this._extraStats.userNum || 0, "/").concat(this._extraStats.renderedUserNum || 0)
  4674. }), e.push({
  4675. key: "media/meta bitrate(kbps)",
  4676. value: numberFormat.format(this._aggregatedStats.mediaBitrate || 0) + "/" + numberFormat.format(this._aggregatedStats.metaBitrate || 0)
  4677. }), e.push({
  4678. key: ":----------------Decoding---------------",
  4679. value: ""
  4680. }), e.push({
  4681. key: "-max/avg decodeTime(ms)",
  4682. value: numberFormat.format(this._aggregatedStats.decodeTimeMaxFrame || 0) + "/" + numberFormat.format(this._aggregatedStats.decodeTimePerFrame || 0)
  4683. }), e.push({
  4684. key: "-frmAwait/Lost/Drop",
  4685. 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
  4686. }), e.push({
  4687. key: ":----------------FrameLoop-------------",
  4688. value: ""
  4689. }), e.push({
  4690. key: "interval(max/avg/>40)",
  4691. 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
  4692. }), e.push({
  4693. key: "systemStuck",
  4694. value: this._extraStats.systemStuckCnt
  4695. }), e.push({
  4696. key: "--update",
  4697. value: (this._aggregatedStats.maxGraphicTime.toFixed(1) || 0) + "/" + (((d = this._aggregatedStats.averageGraphicTime) == null ? void 0 : d.toFixed(0)) || 0)
  4698. }), e.push({
  4699. key: "--timeout",
  4700. value: (((_ = this._extraStats.maxTimeoutTime) == null ? void 0 : _.toFixed(1)) || 0) + "/" + ((g = this._extraStats.avgTimeoutTime) == null ? void 0 : g.toFixed(0)) || 0
  4701. }), e.push({
  4702. key: "--render",
  4703. value: (((m = this._extraStats.maxRenderFrameTime) == null ? void 0 : m.toFixed(1)) || 0) + "/" + (((v = this._extraStats.renderFrameTime) == null ? void 0 : v.toFixed(0)) || 0)
  4704. }), e.push({
  4705. key: "---anim/regBR/clip(avg ms)",
  4706. value: (this._extraStats.animationTime.toFixed(2) || 0) + " / " + (this._extraStats.registerBeforeRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.meshSelectTime.toFixed(2) || 0)
  4707. }), e.push({
  4708. key: "---anim/regBR/clip(max ms)",
  4709. value: (this._extraStats.maxAnimationTime.toFixed(2) || 0) + " / " + (this._extraStats.maxRegisterBeforeRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.maxMeshSelectTime.toFixed(2) || 0)
  4710. }), e.push({
  4711. key: "---rTR/drC/regAF(avg ms)",
  4712. value: (this._extraStats.renderTargetRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.drawcallTime.toFixed(2) || 0) + " / " + (this._extraStats.registerAfterRenderTime.toFixed(2) || 0)
  4713. }), e.push({
  4714. key: "---rTR/drC/regAF(max ms)",
  4715. value: (this._extraStats.maxRenderTargetRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.maxDrawcallTime.toFixed(2) || 0) + " / " + (this._extraStats.maxRegisterAfterRenderTime.toFixed(2) || 0)
  4716. }), e.push({
  4717. key: "--tri/drC/pati/bones/anim(Num)",
  4718. 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)
  4719. }), e.push({
  4720. key: "--rootN/mesh/geo/tex/mat(Num)",
  4721. 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)
  4722. }), e.push({
  4723. key: "--registerBF/AF(Num)",
  4724. value: (this._extraStats.registerBeforeCount.toFixed(0) || 0) + " / " + (this._extraStats.registerAfterCount.toFixed(0) || 0)
  4725. }), e.push({
  4726. key: ":----------------Rotation-------------------",
  4727. value: ""
  4728. }), e.push({
  4729. key: "Total(ms/miss)",
  4730. value: (((y = this._aggregatedStats.avgOverallTime) == null ? void 0 : y.toFixed(2)) || 0) + "/" + (this._aggregatedStats.responseMissPs + this._aggregatedStats.processMissPs + this._aggregatedStats.displayMissPs)
  4731. }), e.push({
  4732. key: "--rotateRsp",
  4733. value: (((b = this._aggregatedStats.avgResponseTime) == null ? void 0 : b.toFixed(1)) || 0) + "/" + this._aggregatedStats.responseMissPs
  4734. }), e.push({
  4735. key: "--rotateProc",
  4736. value: (((T = this._aggregatedStats.avgProcessTime) == null ? void 0 : T.toFixed(1)) || 0) + "/" + this._aggregatedStats.processMissPs
  4737. }), e.push({
  4738. key: "--rotateShow",
  4739. value: (((C = this._aggregatedStats.avgDisplayTime) == null ? void 0 : C.toFixed(1)) || 0) + "/" + this._aggregatedStats.displayMissPs
  4740. }), ((A = this.room._userAvatar) == null ? void 0 : A.state) == "moving", e.push({
  4741. key: ":----------------Move----------------------",
  4742. value: ""
  4743. }), e.push({
  4744. key: "-startDelay",
  4745. 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)
  4746. }), (((S = this.room._userAvatar) == null ? void 0 : S.state) == "moving" || this._aggregatedStats.moveEvent == "GetOnAirship" || this._aggregatedStats.moveEvent == "GetOnVehicle") && e.push({
  4747. key: "-srvInterFrm(max/avg)",
  4748. value: (this._aggregatedStats.maxServerDiff || 0) + "/" + (this._aggregatedStats.avgServerDiff.toFixed(1) || 0)
  4749. }), e.push({
  4750. key: "-interFrameDelay",
  4751. value: "(max/avg/jank)"
  4752. }), e.push({
  4753. key: "--toDisplay",
  4754. 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)
  4755. }), e.push({
  4756. key: "--received",
  4757. 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)
  4758. }), e.push({
  4759. key: "--decoded",
  4760. 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)
  4761. }), e.push({
  4762. key: ":----------------DevInfo-----------------",
  4763. value: ""
  4764. }), e.push({
  4765. key: "sd",
  4766. value: (this._aggregatedStats.sdMoveResponseLongTime.toFixed(1) || 0) + "/" + (this._aggregatedStats.sdMoveProcessLongTime.toFixed(1) || 0) + "/" + (this._aggregatedStats.sdMoveDisplayLongTime.toFixed(1) || 0)
  4767. }), e.push({
  4768. key: "----hardwareInfo",
  4769. value: this._extraStats.hardwareInfo
  4770. });
  4771. var u = "";
  4772. for (var _i = 0, _e = e; _i < _e.length; _i++) {
  4773. var O = _e[_i];
  4774. u += "<div><span>".concat(O.key, "</span>: <span>").concat(O.value, "</span> </div>");
  4775. }
  4776. this._displayElement.innerHTML = u;
  4777. }
  4778. }, {
  4779. key: "onStats",
  4780. value: function onStats(e) {
  4781. var _this4 = this;
  4782. var n;
  4783. if (!e) return;
  4784. var t = {},
  4785. r = this;
  4786. 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) {
  4787. t[o] = _this4.externalStats[o];
  4788. }), r._aggregatedStats = t, this.emit("stats", {
  4789. stats: t
  4790. });
  4791. }
  4792. }]);
  4793. return Stats;
  4794. }(EventEmitter);
  4795. 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); }; }
  4796. 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; } }
  4797. var EventsManager = /*#__PURE__*/function (_EventEmitter) {
  4798. _inherits(EventsManager, _EventEmitter);
  4799. var _super = _createSuper$h(EventsManager);
  4800. function EventsManager() {
  4801. var _this;
  4802. _classCallCheck(this, EventsManager);
  4803. _this = _super.apply(this, arguments);
  4804. E(_assertThisInitialized(_this), "events", new Map());
  4805. E(_assertThisInitialized(_this), "specialEvents", new Map());
  4806. return _this;
  4807. }
  4808. _createClass(EventsManager, [{
  4809. key: "remove",
  4810. value: function remove(e, t, r, n) {
  4811. if (this.specialEvents.has(e) && !n && t === Codes.Success) return;
  4812. this.events.get(e) && (this.emit(e, {
  4813. code: t,
  4814. data: r
  4815. }), this.events.delete(e), this.specialEvents.delete(e));
  4816. }
  4817. }, {
  4818. key: "track",
  4819. value: function () {
  4820. var _track = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e, t) {
  4821. var _this2 = this;
  4822. var r, _ref, n, _ref$noReport, o, a, s, l, u, c;
  4823. return regenerator.wrap(function _callee$(_context) {
  4824. while (1) {
  4825. switch (_context.prev = _context.next) {
  4826. case 0:
  4827. r = e.traceId;
  4828. this.emitTraceIdToDecoder(e);
  4829. _ref = t || {}, n = _ref.sampleRate, _ref$noReport = _ref.noReport, o = _ref$noReport === void 0 ? !1 : _ref$noReport, a = _ref.special;
  4830. if (!(n && Math.random() > n)) {
  4831. _context.next = 5;
  4832. break;
  4833. }
  4834. return _context.abrupt("return", Promise.resolve());
  4835. case 5:
  4836. s = Actions[e.event] + "Action", l = e.tag;
  4837. this.events.set(r, !0), a && this.specialEvents.set(r, !0);
  4838. u = Date.now();
  4839. c = null;
  4840. return _context.abrupt("return", new Promise(function (h, f) {
  4841. if (o) return _this2.off(r), _this2.events.delete(r), h(void 0);
  4842. _this2.on(r, function (_ref2) {
  4843. var _ = _ref2.code,
  4844. g = _ref2.data,
  4845. m = _ref2.msg;
  4846. if (_ === Codes.Success) h(g), _this2.off(r), logger$1.infoAndReportMeasurement({
  4847. metric: s,
  4848. tag: l,
  4849. extra: e.extra,
  4850. startTime: u,
  4851. traceId: r
  4852. });else {
  4853. if (_ === Codes.ActionMaybeDelay) return;
  4854. if (_ === Codes.DoActionBlocked && e.event === Actions.Rotation) {
  4855. logger$1.debug(s + " response code: " + _);
  4856. return;
  4857. }
  4858. var v = util.getErrorByCode(_),
  4859. y = new v(m);
  4860. _this2.off(r), f(y), _this2.emit("actionResponseError", {
  4861. error: y,
  4862. event: e,
  4863. tag: l
  4864. }), logger$1.infoAndReportMeasurement({
  4865. metric: s,
  4866. tag: l,
  4867. extra: e.extra,
  4868. error: y,
  4869. startTime: u,
  4870. traceId: r
  4871. });
  4872. }
  4873. });
  4874. var d = e.timeout || 2e3;
  4875. c = window.setTimeout(function () {
  4876. if (c && clearTimeout(c), !_this2.events.get(r)) return;
  4877. var _ = new ActionResponseTimeoutError("".concat(s, " timeout in ").concat(d, "ms"));
  4878. _this2.emit("actionResponseTimeout", {
  4879. error: _,
  4880. event: e,
  4881. tag: l
  4882. }), f(_), _this2.events.delete(r), _this2.off(r), logger$1.infoAndReportMeasurement({
  4883. metric: s,
  4884. tag: l,
  4885. extra: e.extra,
  4886. error: _,
  4887. startTime: u,
  4888. traceId: r
  4889. });
  4890. }, d);
  4891. }));
  4892. case 10:
  4893. case "end":
  4894. return _context.stop();
  4895. }
  4896. }
  4897. }, _callee, this);
  4898. }));
  4899. function track(_x, _x2) {
  4900. return _track.apply(this, arguments);
  4901. }
  4902. return track;
  4903. }()
  4904. }, {
  4905. key: "emitTraceIdToDecoder",
  4906. value: function emitTraceIdToDecoder(e) {
  4907. if (e.event === Actions.Rotation || e.event === Actions.Clicking || e.event === Actions.GetOnVehicle || e.event === Actions.GetOffVehicle) {
  4908. var t = {
  4909. [Actions.Rotation]: "Rotation",
  4910. [Actions.GetOnVehicle]: "GetOnVehicle",
  4911. [Actions.GetOffVehicle]: "GetOffVehicle",
  4912. [Actions.Clicking]: "MoveTo"
  4913. };
  4914. this.emit("traceId", {
  4915. traceId: e.traceId,
  4916. timestamp: Date.now(),
  4917. event: t[e.event]
  4918. });
  4919. }
  4920. }
  4921. }]);
  4922. return EventsManager;
  4923. }(EventEmitter);
  4924. var eventsManager = new EventsManager();
  4925. var ClickType = {
  4926. Screen: 0,
  4927. ThreeDimension: 1,
  4928. ThreeDimensionQuick: 2,
  4929. IgnoreView: 3
  4930. };
  4931. var QueueActions = [Actions.Transfer, Actions.ChangeSkin, Actions.GetOnVehicle, Actions.GetOffVehicle];
  4932. var ActionsHandler = /*#__PURE__*/function () {
  4933. function ActionsHandler(e) {
  4934. _classCallCheck(this, ActionsHandler);
  4935. this.currentActiveAction = null;
  4936. this.room = e;
  4937. }
  4938. _createClass(ActionsHandler, [{
  4939. key: "avatarComponentsSync",
  4940. value: function () {
  4941. var _avatarComponentsSync = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  4942. var t;
  4943. return regenerator.wrap(function _callee$(_context) {
  4944. while (1) {
  4945. switch (_context.prev = _context.next) {
  4946. case 0:
  4947. t = {
  4948. action_type: Actions.SetPlayerState,
  4949. set_player_state_action: {
  4950. player_state: {
  4951. avatar_components: JSON.stringify(e)
  4952. }
  4953. }
  4954. };
  4955. this.sendData({
  4956. data: t
  4957. });
  4958. case 2:
  4959. case "end":
  4960. return _context.stop();
  4961. }
  4962. }
  4963. }, _callee, this);
  4964. }));
  4965. function avatarComponentsSync(_x) {
  4966. return _avatarComponentsSync.apply(this, arguments);
  4967. }
  4968. return avatarComponentsSync;
  4969. }()
  4970. }, {
  4971. key: "sendData",
  4972. value: function () {
  4973. var _sendData = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e) {
  4974. var _this = this;
  4975. var t, _e$sampleRate, r, _e$timeout, n, o, a, s;
  4976. return regenerator.wrap(function _callee2$(_context2) {
  4977. while (1) {
  4978. switch (_context2.prev = _context2.next) {
  4979. case 0:
  4980. _context2.next = 2;
  4981. return this.beforeSend(e);
  4982. case 2:
  4983. t = util.uuid();
  4984. if (!(this.room.networkController.sendRtcData(le(oe({}, e.data), {
  4985. trace_id: t,
  4986. user_id: this.room.options.userId
  4987. })), e.track === !1)) {
  4988. _context2.next = 5;
  4989. break;
  4990. }
  4991. return _context2.abrupt("return", Promise.resolve(null));
  4992. case 5:
  4993. _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;
  4994. return _context2.abrupt("return", eventsManager.track({
  4995. timeout: n,
  4996. traceId: t,
  4997. event: a.action_type,
  4998. tag: o,
  4999. extra: a
  5000. }, {
  5001. special: s,
  5002. sampleRate: r,
  5003. noReport: this.room.viewMode === "serverless" || this.room.options.viewMode === "serverless"
  5004. }).finally(function () {
  5005. QueueActions.includes(e.data.action_type) && (_this.currentActiveAction = void 0);
  5006. }));
  5007. case 7:
  5008. case "end":
  5009. return _context2.stop();
  5010. }
  5011. }
  5012. }, _callee2, this);
  5013. }));
  5014. function sendData(_x2) {
  5015. return _sendData.apply(this, arguments);
  5016. }
  5017. return sendData;
  5018. }()
  5019. }, {
  5020. key: "beforeSend",
  5021. value: function () {
  5022. var _beforeSend = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  5023. var o, t, r;
  5024. return regenerator.wrap(function _callee3$(_context3) {
  5025. while (1) {
  5026. switch (_context3.prev = _context3.next) {
  5027. case 0:
  5028. t = (o = this.room._userAvatar) == null ? void 0 : o.isMoving, r = e.data.action_type;
  5029. if (!QueueActions.includes(r)) {
  5030. _context3.next = 5;
  5031. break;
  5032. }
  5033. if (!this.currentActiveAction) {
  5034. _context3.next = 4;
  5035. break;
  5036. }
  5037. 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")))));
  5038. case 4:
  5039. this.currentActiveAction = r;
  5040. case 5:
  5041. if (!(t && QueueActions.includes(e.data.action_type))) {
  5042. _context3.next = 14;
  5043. break;
  5044. }
  5045. _context3.prev = 6;
  5046. _context3.next = 9;
  5047. return this.stopMoving();
  5048. case 9:
  5049. _context3.next = 14;
  5050. break;
  5051. case 11:
  5052. _context3.prev = 11;
  5053. _context3.t0 = _context3["catch"](6);
  5054. this.currentActiveAction = void 0, logger$1.error("before action stopMoving failed", _context3.t0);
  5055. case 14:
  5056. case "end":
  5057. return _context3.stop();
  5058. }
  5059. }
  5060. }, _callee3, this, [[6, 11]]);
  5061. }));
  5062. function beforeSend(_x3) {
  5063. return _beforeSend.apply(this, arguments);
  5064. }
  5065. return beforeSend;
  5066. }()
  5067. }, {
  5068. key: "moveTo",
  5069. value: function () {
  5070. var _moveTo = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  5071. var t, _e$extra, r, n, o;
  5072. return regenerator.wrap(function _callee4$(_context4) {
  5073. while (1) {
  5074. switch (_context4.prev = _context4.next) {
  5075. case 0:
  5076. t = e.point, _e$extra = e.extra, r = _e$extra === void 0 ? "" : _e$extra, n = e.motionType, o = {
  5077. action_type: Actions.Clicking,
  5078. clicking_action: {
  5079. clicking_point: t,
  5080. clicking_type: ClickType.IgnoreView,
  5081. extra: encodeURIComponent(r),
  5082. attitude: n
  5083. },
  5084. clicking_state: this.room._currentClickingState
  5085. };
  5086. return _context4.abrupt("return", this.sendData({
  5087. data: o
  5088. }));
  5089. case 2:
  5090. case "end":
  5091. return _context4.stop();
  5092. }
  5093. }
  5094. }, _callee4, this);
  5095. }));
  5096. function moveTo(_x4) {
  5097. return _moveTo.apply(this, arguments);
  5098. }
  5099. return moveTo;
  5100. }()
  5101. }, {
  5102. key: "transfer",
  5103. value: function transfer(e) {
  5104. var _this2 = this;
  5105. var t = e.renderType,
  5106. r = e.player,
  5107. n = e.camera,
  5108. o = e.areaName,
  5109. a = e.attitude,
  5110. s = e.pathName,
  5111. l = e.person,
  5112. u = e.noMedia,
  5113. c = e.timeout,
  5114. h = e.tag,
  5115. f = e.special,
  5116. d = {
  5117. data: {
  5118. action_type: Actions.Transfer,
  5119. transfer_action: {
  5120. render_type: t,
  5121. player: r,
  5122. camera: n,
  5123. areaName: o,
  5124. attitude: a,
  5125. pathName: s,
  5126. person: {
  5127. type: l
  5128. },
  5129. noMedia: u,
  5130. tiles: [0, 1, 2, 4]
  5131. }
  5132. },
  5133. special: f,
  5134. timeout: c || 4e3,
  5135. tag: h
  5136. };
  5137. return this.sendData(d).then(function (_) {
  5138. return typeof l != "undefined" && _this2.room.updateCurrentNetworkOptions({
  5139. person: l,
  5140. rotationRenderType: t
  5141. }), _;
  5142. });
  5143. }
  5144. }, {
  5145. key: "changeRotationRenderType",
  5146. value: function changeRotationRenderType(e) {
  5147. var t = e.renderType,
  5148. r = e.player,
  5149. n = e.camera,
  5150. o = e.areaName,
  5151. a = e.attitude,
  5152. s = e.pathName;
  5153. return this.transfer({
  5154. renderType: t,
  5155. player: r,
  5156. camera: n,
  5157. areaName: o,
  5158. attitude: a,
  5159. pathName: s,
  5160. tag: "changeToRotationVideo"
  5161. });
  5162. }
  5163. }, {
  5164. key: "requestPanorama",
  5165. value: function requestPanorama(e, t, r) {
  5166. var n = e.camera,
  5167. o = e.player,
  5168. a = e.areaName,
  5169. s = e.attitude,
  5170. l = e.pathName,
  5171. u = e.tag;
  5172. return this.transfer({
  5173. renderType: RenderType.ClientRotationPano,
  5174. player: o,
  5175. camera: n,
  5176. person: Person.First,
  5177. areaName: a,
  5178. attitude: s,
  5179. pathName: l,
  5180. noMedia: t,
  5181. timeout: r,
  5182. tag: u || "requestPanorama",
  5183. special: !t
  5184. });
  5185. }
  5186. }, {
  5187. key: "setMotionType",
  5188. value: function setMotionType(e) {
  5189. return this.transfer({
  5190. attitude: e,
  5191. tag: "setMotionType"
  5192. });
  5193. }
  5194. }, {
  5195. key: "setNickName",
  5196. value: function setNickName(e) {
  5197. var t = {
  5198. action_type: Actions.ChangeNickname,
  5199. change_nickname_action: {
  5200. nickname: e
  5201. }
  5202. };
  5203. return this.sendData({
  5204. data: t
  5205. });
  5206. }
  5207. }, {
  5208. key: "getReserveSeat",
  5209. value: function getReserveSeat(_ref) {
  5210. var e = _ref.routeId,
  5211. t = _ref.name;
  5212. var r = {
  5213. action_type: Actions.ReserveSeat,
  5214. reserve_seat_action: {
  5215. route_id: e,
  5216. name: t
  5217. }
  5218. };
  5219. return this.sendData({
  5220. data: r
  5221. });
  5222. }
  5223. }, {
  5224. key: "getReserveStatus",
  5225. value: function getReserveStatus(_ref2) {
  5226. var e = _ref2.routeId,
  5227. t = _ref2.name,
  5228. r = _ref2.need_detail;
  5229. var n = {
  5230. action_type: Actions.GetReserveStatus,
  5231. get_reserve_status_action: {
  5232. route_id: e,
  5233. name: t,
  5234. need_detail: r
  5235. }
  5236. };
  5237. return this.sendData({
  5238. data: n,
  5239. timeout: 2e3
  5240. }).then(function (o) {
  5241. return o.reserveDetail;
  5242. });
  5243. }
  5244. }, {
  5245. key: "stopMoving",
  5246. value: function stopMoving() {
  5247. var e = {
  5248. action_type: Actions.StopMoving,
  5249. stop_move_action: {}
  5250. };
  5251. return this.sendData({
  5252. data: e
  5253. });
  5254. }
  5255. }, {
  5256. key: "getOnVehicle",
  5257. value: function getOnVehicle(_ref3) {
  5258. var e = _ref3.routeId,
  5259. t = _ref3.name,
  5260. r = _ref3.camera;
  5261. var n = {
  5262. action_type: Actions.GetOnVehicle,
  5263. get_on_vehicle_action: {
  5264. route_id: e,
  5265. name: t,
  5266. camera: r
  5267. }
  5268. };
  5269. return this.sendData({
  5270. data: n
  5271. });
  5272. }
  5273. }, {
  5274. key: "getOffVehicle",
  5275. value: function getOffVehicle(_ref4) {
  5276. var e = _ref4.renderType,
  5277. t = _ref4.player,
  5278. r = _ref4.camera;
  5279. var n = {
  5280. action_type: Actions.GetOffVehicle,
  5281. get_off_vehicle_action: {
  5282. render_type: e,
  5283. player: t,
  5284. camera: r
  5285. }
  5286. };
  5287. return this.sendData({
  5288. data: n
  5289. });
  5290. }
  5291. }, {
  5292. key: "confirmEvent",
  5293. value: function confirmEvent(e) {
  5294. var t = {
  5295. action_type: Actions.ConfirmEvent,
  5296. confirm_event_action: {
  5297. id: e
  5298. }
  5299. };
  5300. return this.sendData({
  5301. data: t,
  5302. track: !1
  5303. });
  5304. }
  5305. }, {
  5306. key: "echo",
  5307. value: function echo(e) {
  5308. var t = {
  5309. action_type: Actions.Echo,
  5310. echo_msg: {
  5311. echoMsg: e
  5312. }
  5313. };
  5314. return this.sendData({
  5315. data: t,
  5316. track: !1
  5317. });
  5318. }
  5319. }, {
  5320. key: "changeSkin",
  5321. value: function () {
  5322. var _changeSkin = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e) {
  5323. var _this3 = this;
  5324. var t, r, n, _e$landingType, o, a, s, l, u, c, h, f, d, _, _e$roomTypeId, g, m, y, v;
  5325. return regenerator.wrap(function _callee6$(_context6) {
  5326. while (1) {
  5327. switch (_context6.prev = _context6.next) {
  5328. case 0:
  5329. 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) {
  5330. return y.id === r;
  5331. })[0];
  5332. if (m) {
  5333. _context6.next = 4;
  5334. break;
  5335. }
  5336. y = "skin ".concat(r, " is invalid");
  5337. return _context6.abrupt("return", (logger$1.error(y), Promise.reject(new ParamError(y))));
  5338. case 4:
  5339. v = {
  5340. action_type: Actions.ChangeSkin,
  5341. change_skin_action: {
  5342. skinID: r,
  5343. mode: n === ChangeMode.Preview ? ChangeMode.Preview : ChangeMode.Confirm,
  5344. skin_data_version: r + m.versionId,
  5345. landing_type: o,
  5346. landing_point: a,
  5347. landing_camera: s,
  5348. render_wrapper: {
  5349. render_type: l
  5350. },
  5351. areaName: u,
  5352. attitude: c,
  5353. noMedia: d,
  5354. person: f,
  5355. pathName: h,
  5356. roomTypeId: g
  5357. }
  5358. };
  5359. return _context6.abrupt("return", this.sendData({
  5360. data: v,
  5361. timeout: _ || 6e3,
  5362. special: t
  5363. }).then( /*#__PURE__*/function () {
  5364. var _ref5 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(y) {
  5365. var b, _ref6, T;
  5366. return regenerator.wrap(function _callee5$(_context5) {
  5367. while (1) {
  5368. switch (_context5.prev = _context5.next) {
  5369. case 0:
  5370. if (!(l === RenderType.ClientRotationPano && y)) {
  5371. _context5.next = 8;
  5372. break;
  5373. }
  5374. _context5.next = 3;
  5375. return _this3.room.modelManager.findRoute(r, h);
  5376. case 3:
  5377. b = _context5.sent;
  5378. _ref6 = util.getRandomItem(b.birthPointList) || {};
  5379. T = _ref6.camera;
  5380. _context5.next = 8;
  5381. return _this3.room.panorama.handleReceivePanorama(y, T);
  5382. case 8:
  5383. return _context5.abrupt("return", _this3.handleChangeSkin(e));
  5384. case 9:
  5385. case "end":
  5386. return _context5.stop();
  5387. }
  5388. }
  5389. }, _callee5);
  5390. }));
  5391. return function (_x6) {
  5392. return _ref5.apply(this, arguments);
  5393. };
  5394. }()).catch(function (y) {
  5395. return d ? _this3.handleChangeSkin(e) : Promise.reject(y);
  5396. }));
  5397. case 6:
  5398. case "end":
  5399. return _context6.stop();
  5400. }
  5401. }
  5402. }, _callee6, this);
  5403. }));
  5404. function changeSkin(_x5) {
  5405. return _changeSkin.apply(this, arguments);
  5406. }
  5407. return changeSkin;
  5408. }()
  5409. }, {
  5410. key: "handleChangeSkin",
  5411. value: function handleChangeSkin(e) {
  5412. var _this4 = this;
  5413. var t = e.skinId,
  5414. r = e.mode,
  5415. n = e.renderType,
  5416. o = e.areaName,
  5417. a = e.attitude,
  5418. s = e.pathName;
  5419. return this.room.sceneManager.staticmeshComponent.getCgMesh().show(), this.room.sceneManager.cameraComponent.switchToCgCamera(), this.room.engineProxy._updateSkinAssets(t).then(function () {
  5420. _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({
  5421. pathName: s,
  5422. attitude: a,
  5423. areaName: o
  5424. }), _this4.room.skinChangedHook(), _this4.room.emit("skinChanged", {
  5425. skin: {
  5426. id: t
  5427. },
  5428. mode: r
  5429. }), n === RenderType.ClientRotationPano && _this4.room.sceneManager.cameraComponent.allowMainCameraController();
  5430. });
  5431. }
  5432. }, {
  5433. key: "rotate",
  5434. value: function rotate(_ref7) {
  5435. var e = _ref7.pitch,
  5436. t = _ref7.yaw;
  5437. var n;
  5438. if (this.room.disableRotate || this.room.isPano || ((n = this.room._userAvatar) == null ? void 0 : n._isChangingComponentsMode)) return;
  5439. var r = {
  5440. action_type: Actions.Rotation,
  5441. rotation_action: {
  5442. vertical_move: e,
  5443. horizontal_move: -t
  5444. }
  5445. };
  5446. this.sendData({
  5447. data: r,
  5448. sampleRate: .02
  5449. });
  5450. }
  5451. }, {
  5452. key: "turnTo",
  5453. value: function turnTo(e) {
  5454. var _ref8 = e || {},
  5455. t = _ref8.point,
  5456. _ref8$timeout = _ref8.timeout,
  5457. r = _ref8$timeout === void 0 ? 2e3 : _ref8$timeout,
  5458. _ref8$offset = _ref8.offset,
  5459. n = _ref8$offset === void 0 ? 8 : _ref8$offset,
  5460. o = {
  5461. action_type: Actions.TurnTo,
  5462. turn_to_action: {
  5463. turn_to_point: t,
  5464. offset: n
  5465. }
  5466. };
  5467. return this.sendData({
  5468. data: o,
  5469. timeout: r
  5470. });
  5471. }
  5472. }, {
  5473. key: "rotateTo",
  5474. value: function rotateTo(e) {
  5475. var _ref9 = e || {},
  5476. t = _ref9.point,
  5477. _ref9$offset = _ref9.offset,
  5478. r = _ref9$offset === void 0 ? 0 : _ref9$offset,
  5479. _ref9$speed = _ref9.speed,
  5480. n = _ref9$speed === void 0 ? 3 : _ref9$speed,
  5481. o = {
  5482. action_type: Actions.RotateTo,
  5483. rotate_to_action: {
  5484. rotate_to_point: t,
  5485. offset: r,
  5486. speed: n
  5487. }
  5488. };
  5489. return this.sendData({
  5490. data: o
  5491. });
  5492. }
  5493. }, {
  5494. key: "broadcast",
  5495. value: function broadcast(e) {
  5496. var t = e.data,
  5497. _e$msgType = e.msgType,
  5498. r = _e$msgType === void 0 ? MessageHandleType.MHT_FollowListMulticast : _e$msgType,
  5499. n = e.targetUserIds;
  5500. if (r === MessageHandleType.MHT_CustomTargetSync && !Array.isArray(n)) return Promise.reject(new ParamError("param targetUserIds is required when msgType is ".concat(MessageHandleType[r])));
  5501. var o = {
  5502. action_type: Actions.Broadcast,
  5503. broadcast_action: {
  5504. data: JSON.stringify(t),
  5505. user_id: this.room.options.userId,
  5506. msgType: r
  5507. }
  5508. };
  5509. return Array.isArray(n) && r === MessageHandleType.MHT_CustomTargetSync && (o.broadcast_action.target_user_ids = n), this.room.actionsHandler.sendData({
  5510. data: o,
  5511. tag: t.broadcastType
  5512. });
  5513. }
  5514. }, {
  5515. key: "getNeighborPoints",
  5516. value: function getNeighborPoints(e) {
  5517. var t = e.point,
  5518. _e$containSelf = e.containSelf,
  5519. r = _e$containSelf === void 0 ? !1 : _e$containSelf,
  5520. _e$searchRange = e.searchRange,
  5521. n = _e$searchRange === void 0 ? 500 : _e$searchRange,
  5522. o = {
  5523. action_type: Actions.GetNeighborPoints,
  5524. get_neighbor_points_action: {
  5525. point: t,
  5526. level: 1,
  5527. containSelf: r,
  5528. searchRange: n
  5529. }
  5530. };
  5531. return this.sendData({
  5532. data: o
  5533. }).then(function (a) {
  5534. return a.nps;
  5535. });
  5536. }
  5537. }, {
  5538. key: "playCG",
  5539. value: function playCG(e) {
  5540. var t = {
  5541. action_type: Actions.PlayCG,
  5542. play_cg_action: {
  5543. cg_name: e
  5544. }
  5545. };
  5546. return this.sendData({
  5547. data: t
  5548. });
  5549. }
  5550. }, {
  5551. key: "audienceToVisitor",
  5552. value: function audienceToVisitor(e) {
  5553. var t = e.avatarId,
  5554. r = e.avatarComponents,
  5555. n = e.player,
  5556. o = e.camera,
  5557. a = {
  5558. action_type: Actions.AudienceChangeToVisitor,
  5559. audienceChangeToVisitorAction: {
  5560. avatarID: t,
  5561. avatarComponents: r,
  5562. player: n,
  5563. camera: o
  5564. }
  5565. };
  5566. return logger$1.debug("send data: audience to visitor"), this.sendData({
  5567. data: a
  5568. });
  5569. }
  5570. }, {
  5571. key: "visitorToAudience",
  5572. value: function visitorToAudience(e) {
  5573. var t = e.renderType,
  5574. r = e.player,
  5575. n = e.camera,
  5576. o = e.areaName,
  5577. a = e.attitude,
  5578. s = e.pathName,
  5579. l = e.person,
  5580. u = e.noMedia,
  5581. c = {
  5582. action_type: Actions.VisitorChangeToAudience,
  5583. visitorChangeToAudienceAction: {
  5584. transferAction: {
  5585. render_type: t,
  5586. player: r,
  5587. camera: n,
  5588. areaName: o,
  5589. attitude: a,
  5590. pathName: s,
  5591. person: {
  5592. type: l
  5593. },
  5594. noMedia: u,
  5595. tiles: [0, 1, 2, 4]
  5596. }
  5597. }
  5598. };
  5599. return logger$1.debug("send data: visitor to audience"), this.sendData({
  5600. data: c
  5601. });
  5602. }
  5603. }, {
  5604. key: "removeVisitor",
  5605. value: function removeVisitor(e) {
  5606. var t = e.removeType,
  5607. r = e.userIDList,
  5608. _e$extraInfo = e.extraInfo,
  5609. n = _e$extraInfo === void 0 ? "" : _e$extraInfo,
  5610. o = {
  5611. action_type: Actions.RemoveVisitor,
  5612. removeVisitorAction: {
  5613. removeVisitorEvent: t,
  5614. userIDList: r,
  5615. extraInfo: encodeURIComponent(n)
  5616. }
  5617. };
  5618. return logger$1.debug("send data: remove visitor"), this.sendData({
  5619. data: o
  5620. });
  5621. }
  5622. }, {
  5623. key: "getUserWithAvatar",
  5624. value: function getUserWithAvatar(e, t) {
  5625. var r = {
  5626. action_type: Actions.GetUserWithAvatar,
  5627. getUserWithAvatarAction: {
  5628. userType: e,
  5629. roomID: t
  5630. }
  5631. };
  5632. return logger$1.debug("send data: get user with avatar"), this.sendData({
  5633. data: r
  5634. }).then(function (n) {
  5635. return n.userWithAvatarList;
  5636. });
  5637. }
  5638. }, {
  5639. key: "joystick",
  5640. value: function joystick(e) {
  5641. var t = e.degree,
  5642. _e$level = e.level,
  5643. r = _e$level === void 0 ? 1 : _e$level,
  5644. n = util.uuid();
  5645. var o = -t + 90 + 360;
  5646. o >= 360 && (o -= 360);
  5647. var a = {
  5648. action_type: Actions.Joystick,
  5649. dir_action: {
  5650. move_angle: o,
  5651. speed_level: r
  5652. },
  5653. trace_id: n,
  5654. user_id: this.room.options.userId,
  5655. packet_id: n
  5656. };
  5657. return this.sendData({
  5658. data: a,
  5659. track: !1
  5660. });
  5661. }
  5662. }]);
  5663. return ActionsHandler;
  5664. }();
  5665. var ECurrentShaderMode = {
  5666. default: 0,
  5667. video: 1,
  5668. pano: 2
  5669. };
  5670. var PointType = {
  5671. Path: 0,
  5672. Item: 1,
  5673. Closeup: 2,
  5674. NoValidMatched: 3
  5675. };
  5676. var Signal = /*#__PURE__*/function () {
  5677. function Signal(e) {
  5678. _classCallCheck(this, Signal);
  5679. this.signalHandleActived = !0;
  5680. this.isUpdatedYUV = !0;
  5681. this._room = e;
  5682. }
  5683. _createClass(Signal, [{
  5684. key: "handleSignal",
  5685. value: function handleSignal(e) {
  5686. var _this = this;
  5687. var a, s, l;
  5688. if (!this.signalHandleActived) return;
  5689. var t = e.signal,
  5690. r = e.alreadyUpdateYUV;
  5691. if (this.handleActionResponses(t), this._room.handleSignalHook(t), !r) {
  5692. var u = (a = t.newUserStates) == null ? void 0 : a.find(function (c) {
  5693. return c.userId === _this._room.userId;
  5694. });
  5695. if ((u == null ? void 0 : u.renderInfo) && ((s = this._room._userAvatar) == null ? void 0 : s.isMoving)) {
  5696. logger$1.debug("stream stoped, make avatar to stop");
  5697. var _u$renderInfo = u.renderInfo,
  5698. c = _u$renderInfo.isMoving,
  5699. h = _u$renderInfo.isRotating;
  5700. this._room.avatarManager._updateAvatarMovingStatus({
  5701. id: u.userId,
  5702. isMoving: !!c,
  5703. isRotating: !!h
  5704. });
  5705. }
  5706. return;
  5707. }
  5708. this.isUpdatedYUV = r;
  5709. var n = t;
  5710. if (!t) {
  5711. logger$1.warn("metadata signal is empty");
  5712. return;
  5713. }
  5714. if (n.code === Codes.RepeatLogin) {
  5715. this._room.handleRepetLogin();
  5716. return;
  5717. }
  5718. 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));
  5719. var o = (l = n.newUserStates) == null ? void 0 : l.find(function (u) {
  5720. return u.userId === _this._room.userId;
  5721. });
  5722. if (n.broadcastAction) try {
  5723. var _u = JSON.parse(n.broadcastAction.data);
  5724. Broadcast.handlers.forEach(function (c) {
  5725. return c(_u);
  5726. });
  5727. } catch (u) {
  5728. logger$1.error(u);
  5729. }
  5730. if (n.newUserStates && n.newUserStates.length > 0 && this._room.avatarManager.handleAvatar(n), o != null && o.playerState) {
  5731. this._room._currentClickingState = o.playerState;
  5732. var _o$playerState = o.playerState,
  5733. _u2 = _o$playerState.pathName,
  5734. _c = _o$playerState.attitude,
  5735. _h = _o$playerState.areaName,
  5736. f = _o$playerState.skinId;
  5737. if (_u2 && (this._room.pathManager.currentPathName = _u2, this._room.updateCurrentState({
  5738. pathName: _u2
  5739. })), f && this.udpateSkinInfo(f), _h && this._room.updateCurrentState({
  5740. areaName: _h
  5741. }), _c) {
  5742. var d = this._room.skin.routeList.find(function (g) {
  5743. return g.areaName === _this._room.currentState.areaName;
  5744. }),
  5745. _ = ((d == null ? void 0 : d.step) || 7.5) * 30;
  5746. this._room.updateCurrentState({
  5747. speed: _,
  5748. attitude: _c
  5749. }), this._room.pathManager.currentAttitude = _c, this._room._userAvatar && (this._room._userAvatar.motionType = _c);
  5750. }
  5751. this._room.sceneManager.getCurrentShaderMode() !== ECurrentShaderMode.pano && !this._room.isPano && o.playerState.camera && this._room.camera.setCameraPose(o.playerState.camera);
  5752. }
  5753. if (o != null && o.renderInfo && this._room.camera.handleRenderInfo(o), n.actionType !== void 0) {
  5754. var _u3 = n.actionType,
  5755. _c2 = n.code,
  5756. _h2 = n.echoMsg,
  5757. _f = n.traceId;
  5758. _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);
  5759. }
  5760. }
  5761. }, {
  5762. key: "handleActionResponses",
  5763. value: function handleActionResponses(e) {
  5764. var _this2 = this;
  5765. !(e != null && e.actionResponses) || e.actionResponses.length === 0 || e.actionResponses.forEach(function (t) {
  5766. if (t.actionType == null) return;
  5767. var r = t.pointType,
  5768. n = t.extra,
  5769. o = t.actionType,
  5770. a = t.traceId,
  5771. s = t.code,
  5772. l = t.msg;
  5773. 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));
  5774. });
  5775. }
  5776. }, {
  5777. key: "udpateSkinInfo",
  5778. value: function () {
  5779. var _udpateSkinInfo = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  5780. var t;
  5781. return regenerator.wrap(function _callee$(_context) {
  5782. while (1) {
  5783. switch (_context.prev = _context.next) {
  5784. case 0:
  5785. this._room.updateCurrentState({
  5786. skinId: e
  5787. });
  5788. _context.next = 3;
  5789. return this._room.skinList.find(function (r) {
  5790. return r.id === e;
  5791. });
  5792. case 3:
  5793. t = _context.sent;
  5794. t && this._room.updateCurrentState({
  5795. skin: t
  5796. });
  5797. case 5:
  5798. case "end":
  5799. return _context.stop();
  5800. }
  5801. }
  5802. }, _callee, this);
  5803. }));
  5804. function udpateSkinInfo(_x) {
  5805. return _udpateSkinInfo.apply(this, arguments);
  5806. }
  5807. return udpateSkinInfo;
  5808. }()
  5809. }]);
  5810. return Signal;
  5811. }();
  5812. 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); }; }
  5813. 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; } }
  5814. var XverseEffectManager = /*#__PURE__*/function (_EventEmitter) {
  5815. _inherits(XverseEffectManager, _EventEmitter);
  5816. var _super = _createSuper$g(XverseEffectManager);
  5817. function XverseEffectManager(e) {
  5818. var _this;
  5819. _classCallCheck(this, XverseEffectManager);
  5820. _this = _super.call(this);
  5821. E(_assertThisInitialized(_this), "effects", new Map());
  5822. E(_assertThisInitialized(_this), "room");
  5823. _this.room = e;
  5824. return _this;
  5825. }
  5826. _createClass(XverseEffectManager, [{
  5827. key: "addEffect",
  5828. value: function () {
  5829. var _addEffect = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  5830. var o, t, r, _e$type, n, a;
  5831. return regenerator.wrap(function _callee$(_context) {
  5832. while (1) {
  5833. switch (_context.prev = _context.next) {
  5834. case 0:
  5835. t = e.jsonPath, r = e.id, _e$type = e.type, n = _e$type === void 0 ? IEffectType.SubSequence : _e$type;
  5836. _context.prev = 1;
  5837. this.effects.get(r) && ((o = this.effects.get(r)) == null || o.dispose());
  5838. a = new Ae.subEffect({
  5839. id: r,
  5840. jsonPath: t,
  5841. type: n,
  5842. room: this.room
  5843. });
  5844. this.effects.set(r, a);
  5845. _context.next = 7;
  5846. return a.init();
  5847. case 7:
  5848. return _context.abrupt("return", a);
  5849. case 10:
  5850. _context.prev = 10;
  5851. _context.t0 = _context["catch"](1);
  5852. return _context.abrupt("return", (this.effects.delete(r), logger$1.error(_context.t0), Promise.reject(_context.t0)));
  5853. case 13:
  5854. case "end":
  5855. return _context.stop();
  5856. }
  5857. }
  5858. }, _callee, this, [[1, 10]]);
  5859. }));
  5860. function addEffect(_x) {
  5861. return _addEffect.apply(this, arguments);
  5862. }
  5863. return addEffect;
  5864. }()
  5865. }, {
  5866. key: "clearEffects",
  5867. value: function clearEffects() {
  5868. var _this2 = this;
  5869. this.effects.forEach(function (e) {
  5870. e.dispose(), _this2.effects.delete(e.id);
  5871. });
  5872. }
  5873. }, {
  5874. key: "removeEffect",
  5875. value: function removeEffect(e) {
  5876. var t = this.effects.get(e);
  5877. t == null || t.dispose(), t && this.effects.delete(t.id);
  5878. }
  5879. }]);
  5880. return XverseEffectManager;
  5881. }(EventEmitter);
  5882. 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); }; }
  5883. 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; } }
  5884. var ParamError$1 = /*#__PURE__*/function (_XverseError) {
  5885. _inherits(ParamError, _XverseError);
  5886. var _super = _createSuper$f(ParamError);
  5887. function ParamError(e) {
  5888. _classCallCheck(this, ParamError);
  5889. return _super.call(this, 1001, e || "\u53C2\u6570\u9519\u8BEF");
  5890. }
  5891. return _createClass(ParamError);
  5892. }(XverseError);
  5893. var Heartbeat = /*#__PURE__*/function () {
  5894. function Heartbeat(e) {
  5895. var _this = this;
  5896. _classCallCheck(this, Heartbeat);
  5897. E(this, "_interval", null);
  5898. E(this, "ping", function () {
  5899. var e = Date.now().toString();
  5900. _this.handler.ping(e);
  5901. });
  5902. this.handler = e;
  5903. }
  5904. _createClass(Heartbeat, [{
  5905. key: "ping",
  5906. value: function ping() {
  5907. var e = Date.now().toString();
  5908. this.handler.ping(e);
  5909. }
  5910. }, {
  5911. key: "start",
  5912. value: function start() {
  5913. this.stop(), logger$1.debug("Setting ping interval to ".concat(PING_INTERVAL_MS, "ms")), this._interval = window.setInterval(this.ping, PING_INTERVAL_MS);
  5914. }
  5915. }, {
  5916. key: "stop",
  5917. value: function stop() {
  5918. logger$1.debug("stop heartbeat"), this._interval && window.clearInterval(this._interval);
  5919. }
  5920. }, {
  5921. key: "pong",
  5922. value: function pong(e, t) {
  5923. !e || typeof e == "string" && this.handler.pong(Date.now() - Number(e), t);
  5924. }
  5925. }]);
  5926. return Heartbeat;
  5927. }();
  5928. var Timeout$1 = /*#__PURE__*/function () {
  5929. function Timeout(e, t) {
  5930. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !0;
  5931. _classCallCheck(this, Timeout);
  5932. this._timeout = null;
  5933. this._fn = e, this._delay = t, r && this.start();
  5934. }
  5935. _createClass(Timeout, [{
  5936. key: "delay",
  5937. get: function get() {
  5938. return this._delay;
  5939. }
  5940. }, {
  5941. key: "isSet",
  5942. get: function get() {
  5943. return !!this._timeout;
  5944. }
  5945. }, {
  5946. key: "setDelay",
  5947. value: function setDelay(e) {
  5948. this._delay = e;
  5949. }
  5950. }, {
  5951. key: "start",
  5952. value: function start() {
  5953. var _this = this;
  5954. this.isSet || (this._timeout = window.setTimeout(function () {
  5955. var e = _this._fn;
  5956. _this.clear(), e();
  5957. }, this._delay));
  5958. }
  5959. }, {
  5960. key: "clear",
  5961. value: function clear() {
  5962. window.clearTimeout(this._timeout), this._timeout = void 0;
  5963. }
  5964. }, {
  5965. key: "reset",
  5966. value: function reset() {
  5967. this.clear(), this.start();
  5968. }
  5969. }]);
  5970. return Timeout;
  5971. }();
  5972. 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); }; }
  5973. 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; } }
  5974. var InitNetworkTimeoutError = /*#__PURE__*/function (_XverseError) {
  5975. _inherits(InitNetworkTimeoutError, _XverseError);
  5976. var _super = _createSuper$e(InitNetworkTimeoutError);
  5977. function InitNetworkTimeoutError(e) {
  5978. _classCallCheck(this, InitNetworkTimeoutError);
  5979. return _super.call(this, 1007, e || "\u7F51\u7EDC\u521D\u59CB\u5316\u8D85\u65F6");
  5980. }
  5981. return _createClass(InitNetworkTimeoutError);
  5982. }(XverseError);
  5983. 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); }; }
  5984. 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; } }
  5985. var Socket = /*#__PURE__*/function (_EventEmitter) {
  5986. _inherits(Socket, _EventEmitter);
  5987. var _super = _createSuper$d(Socket);
  5988. function Socket(e) {
  5989. var _this;
  5990. _classCallCheck(this, Socket);
  5991. _this = _super.call(this);
  5992. E(_assertThisInitialized(_this), "_ws");
  5993. E(_assertThisInitialized(_this), "_openTimer");
  5994. E(_assertThisInitialized(_this), "connected", !1);
  5995. E(_assertThisInitialized(_this), "_hasTimeout", !1);
  5996. E(_assertThisInitialized(_this), "heartbeat");
  5997. E(_assertThisInitialized(_this), "latency", function (e, t) {
  5998. return _this.send({
  5999. id: "checkLatency",
  6000. data: JSON.stringify(e),
  6001. packet_id: t
  6002. });
  6003. });
  6004. E(_assertThisInitialized(_this), "send", function (e) {
  6005. if (_this.wsNoReady()) return;
  6006. var t = JSON.stringify(e);
  6007. e.id !== "heartbeat" && logger$1.info("send ws frame", t), _this._ws.send(t);
  6008. });
  6009. E(_assertThisInitialized(_this), "startGame", function () {
  6010. var _this$network$room$cu = _this.network.room.currentNetworkOptions,
  6011. e = _this$network$room$cu.roomId,
  6012. t = _this$network$room$cu.userId,
  6013. r = _this$network$room$cu.avatarId,
  6014. n = _this$network$room$cu.skinId,
  6015. o = _this$network$room$cu.role,
  6016. a = _this$network$room$cu.avatarComponents,
  6017. s = _this$network$room$cu.versionId,
  6018. l = _this$network$room$cu.rotationRenderType,
  6019. u = _this$network$room$cu.isAllSync,
  6020. c = _this$network$room$cu.nickname,
  6021. h = _this$network$room$cu.avatarScale,
  6022. f = _this$network$room$cu.appId,
  6023. d = _this$network$room$cu.camera,
  6024. _ = _this$network$room$cu.player,
  6025. g = _this$network$room$cu.firends,
  6026. m = _this$network$room$cu.syncByEvent,
  6027. v = _this$network$room$cu.areaName,
  6028. y = _this$network$room$cu.attitude,
  6029. b = _this$network$room$cu.pathName,
  6030. T = _this$network$room$cu.person,
  6031. _this$network$room$cu2 = _this$network$room$cu.roomTypeId,
  6032. C = _this$network$room$cu2 === void 0 ? "" : _this$network$room$cu2,
  6033. A = _this$network$room$cu.syncToOthers,
  6034. S = _this$network$room$cu.hasAvatar,
  6035. P = _this$network$room$cu.prioritySync,
  6036. _this$network$room$cu3 = _this$network$room$cu.extra,
  6037. R = _this$network$room$cu3 === void 0 ? {} : _this$network$room$cu3,
  6038. M = _this$network$room$cu.removeWhenDisconnected;
  6039. R.removeWhenDisconnected = M;
  6040. var x = {
  6041. id: "start",
  6042. room_id: e,
  6043. user_id: t,
  6044. trace_id: util.uuid(),
  6045. data: JSON.stringify({
  6046. avatar_components: JSON.stringify(a),
  6047. avatar_id: r,
  6048. skin_id: n,
  6049. is_host: o ? o == "host" : !0,
  6050. skin_data_version: n !== void 0 && s !== void 0 ? n + s : void 0,
  6051. rotation_render_type: l,
  6052. is_all_sync: u,
  6053. nick_name: encodeURIComponent(c || ""),
  6054. app_id: f,
  6055. camera: d,
  6056. player: _,
  6057. person: T,
  6058. firends: JSON.stringify(g),
  6059. sync_by_event: m,
  6060. area_name: v,
  6061. path_name: b,
  6062. attitude: y,
  6063. room_type_id: C,
  6064. syncToOthers: A,
  6065. hasAvatar: S,
  6066. avatarSize: h,
  6067. prioritySync: P,
  6068. extra: JSON.stringify(R)
  6069. })
  6070. };
  6071. _this.send(x), logger$1.warn("startGame", le(oe({}, x), {
  6072. data: JSON.parse(x.data)
  6073. }));
  6074. });
  6075. _this.network = e, _this.heartbeat = new Heartbeat({
  6076. ping: function ping(t) {
  6077. var r;
  6078. if (!_this.connected) {
  6079. _this.heartbeat.stop(), (r = e.room.stats) == null || r.assign({
  6080. rtt: 0
  6081. });
  6082. return;
  6083. }
  6084. _this.send({
  6085. id: "heartbeat",
  6086. data: t
  6087. });
  6088. },
  6089. pong(t) {
  6090. var r;
  6091. (r = e.room.stats) == null || r.assign({
  6092. rtt: t
  6093. });
  6094. }
  6095. });
  6096. return _this;
  6097. }
  6098. _createClass(Socket, [{
  6099. key: "connection",
  6100. get: function get() {
  6101. return this._ws;
  6102. }
  6103. }, {
  6104. key: "start",
  6105. value: function start() {
  6106. var _this2 = this;
  6107. this._hasTimeout = !1;
  6108. var e = this.getAddress();
  6109. logger$1.info("connecting to ".concat(e));
  6110. var t = Date.now();
  6111. this._ws = new WebSocket(e), this._openTimer = new Timeout$1(function () {
  6112. var r = "Failed to open websocket in ".concat(DEFAULT_OPEN_TIMEOUT_MS, " ms");
  6113. _this2._hasTimeout = !0, _this2.emit("socketClosed", new InitNetworkTimeoutError(r));
  6114. }, DEFAULT_OPEN_TIMEOUT_MS), this._ws.onopen = function () {
  6115. var r;
  6116. (r = _this2._openTimer) == null || r.clear(), _this2.connected = !0, _this2.heartbeat.start(), _this2.network.room.currentNetworkOptions.reconnect || (logger$1.infoAndReportMeasurement({
  6117. metric: "wsOpenedAt",
  6118. group: "joinRoom",
  6119. startTime: _this2.network.room._startTime
  6120. }), logger$1.infoAndReportMeasurement({
  6121. metric: "wsOpenedCost",
  6122. group: "joinRoom",
  6123. startTime: t
  6124. }));
  6125. }, this.handleWSEvent();
  6126. }
  6127. }, {
  6128. key: "getAddress",
  6129. value: function getAddress() {
  6130. var _this$network$room$cu4 = this.network.room.currentNetworkOptions,
  6131. e = _this$network$room$cu4.wsServerUrl,
  6132. t = _this$network$room$cu4.reconnect,
  6133. r = _this$network$room$cu4.sessionId,
  6134. n = _this$network$room$cu4.token,
  6135. o = _this$network$room$cu4.roomId,
  6136. a = _this$network$room$cu4.userId,
  6137. s = _this$network$room$cu4.pageSession,
  6138. l = this.network.room.skinId;
  6139. var u = e;
  6140. t && (u = u + "?reconnect=true&lastSessionID=".concat(r));
  6141. var c = "userId=".concat(a, "&roomId=").concat(o, "&pageSession=").concat(s) + (this.network.room.isHost ? "&skinId=".concat(l) : "") + (n ? "&token=".concat(n) : "");
  6142. return u = u.indexOf("?") > -1 ? u + "&" + c : u + "?" + c, u;
  6143. }
  6144. }, {
  6145. key: "handleWSEvent",
  6146. value: function handleWSEvent() {
  6147. var _this3 = this;
  6148. var e = this._ws;
  6149. e.addEventListener("error", function (t) {
  6150. _this3.connected = !1, logger$1.error("webscoket error", t), _this3.emit("socketClosed", new InternalError("connect to address error: " + _this3.network.room.currentNetworkOptions.wsServerUrl));
  6151. }), e.addEventListener("close", function (t) {
  6152. _this3.connected = !1, _this3._onClose(t);
  6153. }), e.addEventListener("message", function (t) {
  6154. if (!t || _this3._hasTimeout || !_this3.connected) return;
  6155. var r = null;
  6156. try {
  6157. r = JSON.parse(t.data);
  6158. } catch (o) {
  6159. logger$1.error(o);
  6160. return;
  6161. }
  6162. if (!r) return;
  6163. var n = r.id;
  6164. if (!!n) switch (n !== "heartbeat" && logger$1.info("receive ws frame: ".concat(t.data)), n) {
  6165. case "fail":
  6166. break;
  6167. case "init":
  6168. try {
  6169. var o = r.data.slice(-37, -1);
  6170. reporter$1.updateBody({
  6171. serverSession: o
  6172. });
  6173. } catch (o) {
  6174. console.error(o);
  6175. }
  6176. _this3.network.rtcp.start();
  6177. break;
  6178. case "heartbeat":
  6179. _this3.heartbeat.pong(r.data);
  6180. break;
  6181. case "offer":
  6182. _this3.network.rtcp.setRemoteDescription(r.data, _this3.network.stream.el);
  6183. break;
  6184. case "ice_candidate":
  6185. _this3.network.rtcp.addCandidate(r.data);
  6186. break;
  6187. case "start":
  6188. _this3.emit("gameRoomAvailable", r);
  6189. break;
  6190. case "error":
  6191. try {
  6192. var _JSON$parse = JSON.parse(r.data),
  6193. _o = _JSON$parse.Code,
  6194. a = _JSON$parse.Msg;
  6195. if (_o) {
  6196. if (_o == 3003) return _this3.emit("socketClosed", new TokenExpiredError());
  6197. if (authenticationErrorCodes.indexOf(_o) > -1) return _this3.emit("socketClosed", new AuthenticationError("\u9274\u6743\u9519\u8BEF:" + a));
  6198. {
  6199. var s = util.getErrorByCode(_o);
  6200. _this3.emit("socketClosed", new s(a));
  6201. }
  6202. }
  6203. } catch (o) {
  6204. logger$1.error(o), _this3.emit("socketClosed", new InternalError(r.data));
  6205. }
  6206. break;
  6207. case "checkLatency":
  6208. {
  6209. var _o2 = r.packet_id,
  6210. _a = r.data.split(",");
  6211. _this3.onLatencyCheck({
  6212. packetId: _o2,
  6213. addresses: _a
  6214. });
  6215. break;
  6216. }
  6217. default:
  6218. logger$1.warn("unkown ws message type", n, r);
  6219. }
  6220. });
  6221. }
  6222. }, {
  6223. key: "onLatencyCheck",
  6224. value: function onLatencyCheck(e) {
  6225. var _this4 = this;
  6226. var t = _toConsumableArray(new Set(e.addresses || []));
  6227. Promise.all(t.map(function (r) {
  6228. return {
  6229. [r]: 9999
  6230. };
  6231. })).then(function (r) {
  6232. var n = Object.assign.apply(Object, [{}].concat(_toConsumableArray(r)));
  6233. _this4.latency(n, e.packetId);
  6234. });
  6235. }
  6236. }, {
  6237. key: "wsNoReady",
  6238. value: function wsNoReady() {
  6239. return this._ws.readyState == WebSocket.CLOSED || this._ws.readyState == WebSocket.CLOSING || this._ws.readyState == WebSocket.CONNECTING;
  6240. }
  6241. }, {
  6242. key: "prepareReconnect",
  6243. value: function prepareReconnect() {
  6244. this._close({
  6245. code: WS_CLOSE_RECONNECT,
  6246. reason: "reconnect"
  6247. });
  6248. }
  6249. }, {
  6250. key: "_onClose",
  6251. value: function _onClose(_ref) {
  6252. var e = _ref.code,
  6253. t = _ref.reason;
  6254. 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"));
  6255. }
  6256. }, {
  6257. key: "_close",
  6258. value: function _close(_ref2) {
  6259. var e = _ref2.code,
  6260. t = _ref2.reason;
  6261. var r;
  6262. (r = this._ws) == null || r.close(e, t);
  6263. }
  6264. }, {
  6265. key: "quit",
  6266. value: function quit() {
  6267. this._close({
  6268. code: WS_CLOSE_NORMAL,
  6269. reason: "quit"
  6270. });
  6271. }
  6272. }]);
  6273. return Socket;
  6274. }(EventEmitter);
  6275. function add(i, e) {
  6276. return e == -1 && (e = 0), i + e;
  6277. }
  6278. function max(i, e) {
  6279. return Math.max(i, e);
  6280. }
  6281. function count_sd(i, e) {
  6282. function t(r, n) {
  6283. var o = 0;
  6284. return n == -1 ? o = 0 : o = (n - e) * (n - e), r + o;
  6285. }
  6286. return Math.sqrt(i.reduce(t, 0) / i.reduce(count_valid, 0)) || 0;
  6287. }
  6288. function count_valid(i, e) {
  6289. var t = 0;
  6290. return e != -1 && (t = 1), i + t;
  6291. }
  6292. function count_less(i, e) {
  6293. function t(r, n) {
  6294. var o = 0;
  6295. return n != -1 && n < e && (o = 1), r + o;
  6296. }
  6297. return i.reduce(t, 0);
  6298. }
  6299. var CircularArray = /*#__PURE__*/function () {
  6300. function CircularArray(e, t, r) {
  6301. _classCallCheck(this, CircularArray);
  6302. 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);
  6303. }
  6304. _createClass(CircularArray, [{
  6305. key: "add",
  6306. value: function add(e) {
  6307. 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);
  6308. }
  6309. }, {
  6310. key: "computeAvg",
  6311. value: function computeAvg(e) {
  6312. return e.reduce(add, 0) / e.reduce(count_valid, 0) || 0;
  6313. }
  6314. }, {
  6315. key: "computeMax",
  6316. value: function computeMax(e) {
  6317. return e.reduce(max, 0) || 0;
  6318. }
  6319. }, {
  6320. key: "computeThreshPercent",
  6321. value: function computeThreshPercent(e) {
  6322. if (this.countLess) {
  6323. var t = count_less(e, this.lessThreshes[0]) || 0,
  6324. r = count_less(e, this.lessThreshes[1]) || 0,
  6325. n = count_less(e, this.lessThreshes[2]) || 0,
  6326. o = count_less(e, this.lessThreshes[3]) || 0,
  6327. a = e.reduce(count_valid, 0);
  6328. return [t, r, n, o, a];
  6329. } else return [0, 0, 0, 0, 0];
  6330. }
  6331. }, {
  6332. key: "getAvg",
  6333. value: function getAvg() {
  6334. var e = this.sum / this.count || 0,
  6335. t = this.computeAvg(this.circularData) || 0;
  6336. return Math.abs(e - t) > .01 && console.error("avg value mismatch: ", e, t), this.computeAvg(this.circularData) || 0;
  6337. }
  6338. }, {
  6339. key: "getMax",
  6340. value: function getMax() {
  6341. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !0;
  6342. var t = this.computeMax(this.circularData) || 0;
  6343. return e && Math.abs(t - this.max) > .01 && console.error("max value mismatch: ", this.max, t), this.computeMax(this.circularData) || 0;
  6344. }
  6345. }, {
  6346. key: "getStandardDeviation",
  6347. value: function getStandardDeviation() {
  6348. return count_sd(this.circularData, this.getAvg());
  6349. }
  6350. }, {
  6351. key: "getThreshPercent",
  6352. value: function getThreshPercent() {
  6353. return this.computeThreshPercent(this.circularData);
  6354. }
  6355. }, {
  6356. key: "getIncomingMax",
  6357. value: function getIncomingMax() {
  6358. return this.computeMax(this.incomingData) || 0;
  6359. }
  6360. }, {
  6361. key: "getIncomingAvg",
  6362. value: function getIncomingAvg() {
  6363. return this.computeAvg(this.incomingData) || 0;
  6364. }
  6365. }, {
  6366. key: "getIncomingStandardDeviation",
  6367. value: function getIncomingStandardDeviation() {
  6368. return count_sd(this.incomingData, this.getIncomingAvg());
  6369. }
  6370. }, {
  6371. key: "getIncomingThreshPercent",
  6372. value: function getIncomingThreshPercent() {
  6373. return this.computeThreshPercent(this.incomingData);
  6374. }
  6375. }, {
  6376. key: "clearFastComputeItem",
  6377. value: function clearFastComputeItem() {
  6378. 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;
  6379. }
  6380. }, {
  6381. key: "clearIncoming",
  6382. value: function clearIncoming() {
  6383. for (; this.incomingData.length > 0;) {
  6384. this.incomingData.pop();
  6385. }
  6386. }
  6387. }, {
  6388. key: "clear",
  6389. value: function clear() {
  6390. this.circularData.fill(-1), this.circularPtr = 0, this.clearFastComputeItem(), this.clearIncoming();
  6391. }
  6392. }]);
  6393. return CircularArray;
  6394. }();
  6395. function _createForOfIteratorHelper$5(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$5(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; } } }; }
  6396. function _unsupportedIterableToArray$5(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$5(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$5(o, minLen); }
  6397. function _arrayLikeToArray$5(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; }
  6398. var defaultLogger = {
  6399. info: console.log,
  6400. debug: console.log,
  6401. error: console.error,
  6402. infoAndReportMeasurement: function infoAndReportMeasurement() {}
  6403. };
  6404. var USER_ID = "987412365",
  6405. PAGE_SESSION = "aaabbbccc",
  6406. SERVER_SESSION = "cccbbbaaa",
  6407. COS_PREFIX = "error-bitstreams-auto-uploaded-from-application/",
  6408. FRAME_COMPOSE_LENGTH = 5;
  6409. var Workers = /*#__PURE__*/function () {
  6410. function Workers(e, t) {
  6411. var _this = this;
  6412. _classCallCheck(this, Workers);
  6413. 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 = {
  6414. x: 0,
  6415. y: 0,
  6416. z: 0,
  6417. tiles: []
  6418. }, 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 () {
  6419. return DECODER_VERSION;
  6420. }, this.downloadBlob = function (r, n, o) {
  6421. var a = new Blob([r], {
  6422. type: o
  6423. }),
  6424. s = window.URL.createObjectURL(a);
  6425. _this.downloadURL(s, n), setTimeout(function () {
  6426. return window.URL.revokeObjectURL(s);
  6427. }, 1e3);
  6428. }, this.downloadURL = function (r, n) {
  6429. var o = document.createElement("a");
  6430. o.href = r, o.download = n, document.body.appendChild(o), o.style.display = "none", o.click(), o.remove();
  6431. }, this.Stringify = function (r) {
  6432. var n = "";
  6433. for (var a = 0; a < r.length / 8192; a++) {
  6434. n += String.fromCharCode.apply(null, r.slice(a * 8192, (a + 1) * 8192));
  6435. }
  6436. return n;
  6437. }, this._rtcp = e;
  6438. }
  6439. _createClass(Workers, [{
  6440. key: "registerLogger",
  6441. value: function registerLogger(e) {//defaultLogger = e
  6442. }
  6443. }, {
  6444. key: "registerFunction",
  6445. value: function registerFunction(e, t) {
  6446. this.functionMap.set(e, t);
  6447. }
  6448. }, {
  6449. key: "hasFrmCntInCache",
  6450. value: function hasFrmCntInCache(e) {
  6451. var t = -1;
  6452. for (var r = 0; r < this.cacheFrameComposes.length; r++) {
  6453. this.cacheFrameComposes[r].frameCnt == e && (t = r);
  6454. }
  6455. return t;
  6456. }
  6457. }, {
  6458. key: "requestPanoramaTest",
  6459. value: function requestPanoramaTest(e, t, r, n, o) {
  6460. var a = o,
  6461. s = {
  6462. action_type: 16,
  6463. change_rotation_render_type_action: {
  6464. render_type: 5,
  6465. player: {
  6466. position: {
  6467. x: 0,
  6468. y: 0,
  6469. z: 0
  6470. },
  6471. angle: {
  6472. yaw: 0,
  6473. pitch: 0,
  6474. roll: 0
  6475. }
  6476. },
  6477. camera: {
  6478. position: {
  6479. x: e,
  6480. y: t,
  6481. z: r
  6482. },
  6483. angle: {
  6484. yaw: 0,
  6485. pitch: 0,
  6486. roll: 0
  6487. }
  6488. },
  6489. client_pano_titles_bitmap: n
  6490. },
  6491. trace_id: a,
  6492. user_id: this.userId_test,
  6493. packet_id: a
  6494. };
  6495. defaultLogger.debug("send data: ", s), this._rtcp.sendData(s);
  6496. }
  6497. }, {
  6498. key: "onRotateInPanoMode",
  6499. value: function onRotateInPanoMode(e) {
  6500. var t = e.traceId,
  6501. r = {};
  6502. r.width = 1280, r.height = 720, r.horz_fov = 92, r.angle = {
  6503. yaw: 100,
  6504. pitch: 30
  6505. };
  6506. var n = new ArrayBuffer(8),
  6507. o = new DataView(n);
  6508. getTilesInView(r, n);
  6509. var a = n.slice(0);
  6510. this.PendingMasks.unshift({
  6511. buffer: a,
  6512. angle: r.angle
  6513. }), MaskSetToOne(18, this.PanoView), operateForDataView(o, this.PanoView, o, function (s, l) {
  6514. return s ^ s & l;
  6515. }), 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);
  6516. }
  6517. }, {
  6518. key: "processMetaWithTraceId",
  6519. value: function processMetaWithTraceId(e) {
  6520. var _iterator = _createForOfIteratorHelper$5(e.traceIds),
  6521. _step;
  6522. try {
  6523. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  6524. var t = _step.value;
  6525. if (this.traceIdMap.has(t)) {
  6526. var r = this.traceIdMap.get(t);
  6527. r != null && (r.receiveTime = Date.now(), r.status = 1);
  6528. }
  6529. if (t == this.PendingMovingTraceId) {
  6530. 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());
  6531. var _r = Date.now();
  6532. this.lastMoveResponseTime = _r, this.lastMoveProcessTime = _r, this.lastMoveDisplayTime = _r, this.frameServerCircular.clear(), this.frameClientCircular.clear();
  6533. }
  6534. }
  6535. } catch (err) {
  6536. _iterator.e(err);
  6537. } finally {
  6538. _iterator.f();
  6539. }
  6540. }
  6541. }, {
  6542. key: "onTraceId",
  6543. value: function onTraceId(e) {
  6544. var _this2 = this;
  6545. var r = e.traceId,
  6546. n = e.timestamp,
  6547. o = e.event;
  6548. if (o === "Rotation") {
  6549. var a = {
  6550. traceId: r,
  6551. pts: 0,
  6552. startTime: n,
  6553. receiveTime: 0,
  6554. readyTime: 0,
  6555. displayTime: 0,
  6556. status: 0
  6557. };
  6558. this.traceIdMap.set(r, a);
  6559. var s = setTimeout(function () {
  6560. if (s && clearTimeout(s), _this2.traceIdMap.has(r)) {
  6561. var l = _this2.traceIdMap.get(r);
  6562. switch (l == null ? void 0 : l.status) {
  6563. case 0:
  6564. {
  6565. _this2.responseMiss += 1;
  6566. break;
  6567. }
  6568. case 1:
  6569. {
  6570. _this2.processMiss += 1;
  6571. var u = l.receiveTime - l.startTime;
  6572. _this2.responseTimeArray.push(u);
  6573. break;
  6574. }
  6575. case 2:
  6576. {
  6577. _this2.displayMiss += 1;
  6578. var _u = l.receiveTime - l.startTime,
  6579. c = l.readyTime - l.receiveTime;
  6580. _this2.responseTimeArray.push(_u), _this2.processTimeArray.push(c);
  6581. break;
  6582. }
  6583. case 3:
  6584. defaultLogger.debug("status is 3");
  6585. }
  6586. }
  6587. }, 1e3);
  6588. } 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();
  6589. }
  6590. }, {
  6591. key: "executeFunction",
  6592. value: function executeFunction(e, t) {
  6593. if (this.functionMap.has(e)) {
  6594. var r = this.functionMap.get(e);
  6595. r != null && r(t);
  6596. }
  6597. }
  6598. }, {
  6599. key: "UpdateStats",
  6600. value: function UpdateStats(e) {
  6601. var _this3 = this;
  6602. var t;
  6603. (t = this._rtcp.connection) == null || t.getStats(null).then(function (r) {
  6604. r.forEach(function (n) {
  6605. n.type == "data-channel" && (_this3.rtcMessageReceived = n.messagesReceived - n.messagesSent, _this3.rtcBytesReceived = n.bytesReceived);
  6606. });
  6607. }), 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;
  6608. }
  6609. }, {
  6610. key: "ReceiveDecodeMessage",
  6611. value: function ReceiveDecodeMessage(e) {
  6612. var n;
  6613. if (!this.firstYUVReceived) {
  6614. this.firstYUVDecoded = e.data.yuv_ts;
  6615. var o = this.firstYUVDecoded - this.rtcp.network.room._startTime;
  6616. defaultLogger.infoAndReportMeasurement({
  6617. metric: "firstYUVDecodedAt",
  6618. value: o,
  6619. group: "joinRoom"
  6620. }), this.firstRender = Date.now();
  6621. var a = this.firstYUVDecoded - this.rtcp.network.room._startTime;
  6622. defaultLogger.infoAndReportMeasurement({
  6623. metric: "firstRenderAt",
  6624. value: a,
  6625. group: "joinRoom"
  6626. }), this.firstYUVReceived = !0, this.lastRenderTs = Date.now();
  6627. }
  6628. !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", {
  6629. stream: this.cachedStreams[this.setPtr],
  6630. width: this.cachedResolution[this.setPtr].width,
  6631. height: this.cachedResolution[this.setPtr].height,
  6632. pts: this.cachedPtss[this.setPtr]
  6633. }), this.executeFunction("signal", {
  6634. signal: this.cachedMetas[this.setPtr],
  6635. pts: this.cachedPtss[this.setPtr],
  6636. alreadyUpdateYUV: !0
  6637. })) : this.updateDropFrame += 1, this.decoderWorker.postMessage({
  6638. t: 2,
  6639. frameCnt: this.cachedPtss[this.setPtr],
  6640. buffer: this.cachedStreams[this.setPtr]
  6641. }, [this.cachedStreams[this.setPtr].buffer])), this.getPtr = (this.getPtr + 1) % this.cachedLength);
  6642. var t = e.data.metadata;
  6643. if ((n = t == null ? void 0 : t.traceIds) != null && n.length) {
  6644. var _iterator2 = _createForOfIteratorHelper$5(t.traceIds),
  6645. _step2;
  6646. try {
  6647. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  6648. var _o = _step2.value;
  6649. if (this.traceIdMap.has(_o)) {
  6650. var _a = this.traceIdMap.get(_o);
  6651. _a != null && (_a.readyTime = Date.now(), _a.status = 2);
  6652. }
  6653. }
  6654. } catch (err) {
  6655. _iterator2.e(err);
  6656. } finally {
  6657. _iterator2.f();
  6658. }
  6659. }
  6660. if (e.data.pts == this.moveStartPts && (this.MoveProcessDelay = Date.now() - this.StartMovingTs), this.userId_test = this.rtcp.network.room.userId, this.inMovingMode) {
  6661. var _o2 = Date.now(),
  6662. _a2 = _o2 - this.lastMoveProcessTime;
  6663. this.moveProcessCircular.add(_a2), this.lastMoveProcessTime = _o2;
  6664. }
  6665. var r = this.setPtr;
  6666. 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] = {
  6667. width: e.data.width,
  6668. height: e.data.height
  6669. }, this.setPtr = (this.setPtr + 1) % this.cachedLength;
  6670. }
  6671. }, {
  6672. key: "SendCacheFrameInfo",
  6673. value: function SendCacheFrameInfo(e) {
  6674. var _this4 = this;
  6675. var h, f, d, _, g, m, v;
  6676. var t = e.data.cachedKey,
  6677. r = e.data.metadata,
  6678. n = t,
  6679. o = r,
  6680. a = (d = (f = (h = o.newUserStates) == null ? void 0 : h.find(function (y) {
  6681. return y.userId === _this4.rtcp.network.room.userId;
  6682. })) == null ? void 0 : f.playerState) == null ? void 0 : d.roomTypeId,
  6683. s = this.rtcp.network.room.skinId,
  6684. l = (v = (m = (g = (_ = o.newUserStates) == null ? void 0 : _.find(function (y) {
  6685. return y.userId === _this4._rtcp.network.room.userId;
  6686. })) == null ? void 0 : g.playerState) == null ? void 0 : m.player) == null ? void 0 : v.position,
  6687. u = {
  6688. MsgType: 1,
  6689. FrameCacheMsg: {
  6690. FrameIndex: n,
  6691. RoomTypeId: a,
  6692. SkinID: s,
  6693. Position: l
  6694. }
  6695. };
  6696. var c = "";
  6697. try {
  6698. c = JSON.stringify(u);
  6699. } catch (y) {
  6700. defaultLogger.error(y);
  6701. return;
  6702. }
  6703. }
  6704. }, {
  6705. key: "ReceivePanoramaDecodeMessage",
  6706. value: function ReceivePanoramaDecodeMessage(e) {
  6707. defaultLogger.info("Receive Panorama Image in Workers.ts"), MaskSetToOne(e.data.tileId, this.PanoView);
  6708. var t = 0,
  6709. r;
  6710. var n = this.PendingMasks.length;
  6711. for (t = 0; t < n; t++) {
  6712. var o = this.PendingMasks[t].buffer,
  6713. a = new DataView(o),
  6714. s = new ArrayBuffer(8),
  6715. l = new DataView(s);
  6716. if (operateForDataView(this.PanoView, a, l, function (u, c) {
  6717. return c ^ u & c;
  6718. }), IsAll0(l)) {
  6719. r = this.PendingMasks[t].angle;
  6720. break;
  6721. }
  6722. }
  6723. for (var _o3 = t; _o3 < n; _o3++) {
  6724. this.PendingMasks.pop();
  6725. }
  6726. this.executeFunction("panorama", {
  6727. data: e.data.data,
  6728. tileId: e.data.tileId,
  6729. pos: {
  6730. x: e.data.x,
  6731. y: e.data.y,
  6732. z: e.data.z
  6733. },
  6734. uuid: e.data.uuid,
  6735. finished: !0,
  6736. matchAngle: r
  6737. });
  6738. }
  6739. }, {
  6740. key: "enable_decoder_queue_logging",
  6741. value: function enable_decoder_queue_logging() {
  6742. this.decoderWorker.postMessage({
  6743. t: 100,
  6744. status: !0
  6745. });
  6746. }
  6747. }, {
  6748. key: "disable_decoder_queue_logging",
  6749. value: function disable_decoder_queue_logging() {
  6750. this.decoderWorker.postMessage({
  6751. t: 100,
  6752. status: !1
  6753. });
  6754. }
  6755. }, {
  6756. key: "init",
  6757. value: function () {
  6758. var _init = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  6759. var _this5 = this;
  6760. var e,
  6761. r,
  6762. n,
  6763. t,
  6764. _args = arguments;
  6765. return regenerator.wrap(function _callee$(_context) {
  6766. while (1) {
  6767. switch (_context.prev = _context.next) {
  6768. case 0:
  6769. e = _args.length > 0 && _args[0] !== undefined ? _args[0] : {
  6770. width: 1280,
  6771. height: 720
  6772. };
  6773. for (r = 0; r < FRAME_COMPOSE_LENGTH; r++) {
  6774. n = {
  6775. buffer: new Uint8Array(2621440),
  6776. size: 0,
  6777. startReceiveTime: 0,
  6778. serverTime: 0,
  6779. frameCnt: -1
  6780. };
  6781. this.cacheFrameComposes.push(n);
  6782. }
  6783. t = new Blob([decoder], {
  6784. type: "application/javascript"
  6785. });
  6786. this.decoderWorker = new Worker(URL.createObjectURL(t));
  6787. this.decoderWorker.postMessage({
  6788. t: 9,
  6789. url: WASM_URLS[WASM_Version],
  6790. jitterLength: DECODER_PASSIVE_JITTER
  6791. });
  6792. this.decoderWorker.postMessage({
  6793. t: 1,
  6794. config: e
  6795. });
  6796. return _context.abrupt("return", new Promise(function (r) {
  6797. _this5.decoderWorker.onmessage = function (n) {
  6798. switch (n.data.t) {
  6799. case 0:
  6800. _this5.ReceiveDecodeMessage(n);
  6801. break;
  6802. case 1:
  6803. _this5.UpdateStats(n);
  6804. break;
  6805. case 2:
  6806. r();
  6807. break;
  6808. case 3:
  6809. _this5.SendCacheFrameInfo(n);
  6810. break;
  6811. case 4:
  6812. {
  6813. var o = new Date().toISOString(),
  6814. a = USER_ID + "-" + PAGE_SESSION + "-" + SERVER_SESSION + "-" + o + ".264";
  6815. uploadStream(COS_PREFIX + a, n.data.fileObj);
  6816. break;
  6817. }
  6818. case 5:
  6819. _this5.executeFunction("signal", {
  6820. signal: n.data.metadata,
  6821. pts: -1,
  6822. alreadyUpdateYUV: !1
  6823. });
  6824. break;
  6825. case 6:
  6826. defaultLogger.infoAndReportMeasurement(n.data), defaultLogger.debug("WASM Ready Cost");
  6827. break;
  6828. case 7:
  6829. _this5.ReceivePanoramaDecodeMessage(n);
  6830. break;
  6831. case 8:
  6832. {
  6833. var _o4 = {
  6834. MstType: 0
  6835. };
  6836. var _a3 = "";
  6837. try {
  6838. _a3 = JSON.stringify(_o4);
  6839. } catch (l) {
  6840. defaultLogger.error(l);
  6841. return;
  6842. }
  6843. var s = "wasm:" + _a3;
  6844. _this5._rtcp.sendStringData(s);
  6845. break;
  6846. }
  6847. case 9:
  6848. {
  6849. defaultLogger.info(n.data.printMsg);
  6850. break;
  6851. }
  6852. case 10:
  6853. {
  6854. defaultLogger.error(n.data.printMsg), _this5.executeFunction("error", {
  6855. code: n.data.code,
  6856. message: n.data.printMsg
  6857. });
  6858. break;
  6859. }
  6860. default:
  6861. defaultLogger.error("Receive unknown message event from decoder"), defaultLogger.debug(n.data);
  6862. break;
  6863. }
  6864. };
  6865. }));
  6866. case 7:
  6867. case "end":
  6868. return _context.stop();
  6869. }
  6870. }
  6871. }, _callee, this);
  6872. }));
  6873. function init() {
  6874. return _init.apply(this, arguments);
  6875. }
  6876. return init;
  6877. }()
  6878. }, {
  6879. key: "UpdateYUV",
  6880. value: function UpdateYUV() {
  6881. var t, r;
  6882. var e = this.getPtr;
  6883. if (this.cachedMetas[e] != null && !this.cachedRender[e]) {
  6884. var n = Date.now();
  6885. if (this.firstUpdateYUV) {
  6886. var h = ((t = this.cachedStreams[e]) == null ? void 0 : t.byteLength) || 0;
  6887. defaultLogger.infoAndReportMeasurement({
  6888. metric: "firstUpdateStreamLength",
  6889. value: h,
  6890. group: "joinRoom"
  6891. }), this.firstUpdateYUV = !1;
  6892. }
  6893. this.cachedStreams[e] != null && this.executeFunction("stream", {
  6894. stream: this.cachedStreams[e],
  6895. width: this.cachedResolution[e].width,
  6896. height: this.cachedResolution[e].height,
  6897. pts: this.cachedPtss[e]
  6898. });
  6899. var o = Date.now();
  6900. this.cachedStreams[e] != null && this.decoderWorker.postMessage({
  6901. t: 2,
  6902. frameCnt: this.cachedPtss[e],
  6903. buffer: this.cachedStreams[e]
  6904. }, [this.cachedStreams[e].buffer]);
  6905. var a = Date.now(),
  6906. s = o - n,
  6907. l = a - o;
  6908. (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;
  6909. var u = o - n;
  6910. this.updateYUVCircular.add(u);
  6911. var c = this.cachedMetas[e];
  6912. if ((r = c == null ? void 0 : c.traceIds) != null && r.length) {
  6913. var _iterator3 = _createForOfIteratorHelper$5(c.traceIds),
  6914. _step3;
  6915. try {
  6916. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  6917. var _h = _step3.value;
  6918. if (this.traceIdMap.has(_h)) {
  6919. var f = this.traceIdMap.get(_h);
  6920. if (f != null) {
  6921. f.displayTime = Date.now(), f.status = 3;
  6922. var d = f.receiveTime - f.startTime,
  6923. _ = f.readyTime - f.receiveTime,
  6924. g = f.displayTime - f.readyTime,
  6925. m = f.displayTime - f.startTime;
  6926. this.responseTimeArray.push(d), this.processTimeArray.push(_), this.displayTimeArray.push(g), this.overallTimeArray.push(m), this.traceIdMap.delete(_h);
  6927. }
  6928. }
  6929. }
  6930. } catch (err) {
  6931. _iterator3.e(err);
  6932. } finally {
  6933. _iterator3.f();
  6934. }
  6935. }
  6936. if (this.cachedPtss[e] == this.moveStartPts && (this.MoveDisplayDelay = Date.now() - this.StartMovingTs), this.inMovingMode) {
  6937. var _h2 = Date.now(),
  6938. _f = _h2 - this.lastMoveDisplayTime;
  6939. this.moveDisplayCircular.add(_f), this.lastMoveDisplayTime = _h2;
  6940. }
  6941. this.executeFunction("signal", {
  6942. signal: this.cachedMetas[e],
  6943. pts: this.cachedPtss[e],
  6944. alreadyUpdateYUV: !0
  6945. }), this.cachedRender[e] = !0, this.getPtr = (this.getPtr + 1) % this.cachedLength;
  6946. }
  6947. }
  6948. }, {
  6949. key: "unmarshalPano",
  6950. value: function unmarshalPano(e) {
  6951. var t = new DataView(e);
  6952. if (t.getUint32(0) != 1723558763) return !1;
  6953. console.log("Receive Pano Message"), t.getUint16(4);
  6954. var n = t.getUint16(6),
  6955. o = t.getUint32(8),
  6956. a = t.getUint32(12) - (1 << 30) * 2,
  6957. s = t.getUint32(16) - (1 << 30) * 2,
  6958. l = t.getUint32(20) - (1 << 30) * 2,
  6959. u = t.getUint32(24),
  6960. c = new Uint8Array(e).subarray(28, 64),
  6961. h = String.fromCharCode.apply(null, c),
  6962. f = t.getUint32(64),
  6963. d = e.byteLength - n;
  6964. if (d == u) {
  6965. var g = {
  6966. data: new Uint8Array(e).subarray(n),
  6967. mediaLen: u,
  6968. tileId: o,
  6969. uuid: h,
  6970. x: a,
  6971. y: s,
  6972. z: l
  6973. };
  6974. this.decoderWorker.postMessage({
  6975. t: 8,
  6976. data: g
  6977. });
  6978. } else {
  6979. var _ = new Uint8Array(e, n, d);
  6980. if (this.cachePanoTileID == o) {
  6981. if (this.panoCacheBuffer.set(_, f), this.panoCacheSize += d, this.panoCacheSize === u) {
  6982. var m = {
  6983. data: new Uint8Array(this.panoCacheBuffer).slice(0, u),
  6984. mediaLen: u,
  6985. tileId: o,
  6986. uuid: h,
  6987. x: a,
  6988. y: s,
  6989. z: l
  6990. };
  6991. this.decoderWorker.postMessage({
  6992. t: 8,
  6993. data: m
  6994. }), this.panoCacheSize = 0;
  6995. }
  6996. } else this.panoCacheBuffer.set(_, f), this.panoCacheSize = d, this.cachePanoTileID = o;
  6997. }
  6998. return !0;
  6999. }
  7000. }, {
  7001. key: "clearMoveArray",
  7002. value: function clearMoveArray() {
  7003. 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 = "";
  7004. }
  7005. }, {
  7006. key: "getIsMoving",
  7007. value: function getIsMoving(e) {
  7008. var t;
  7009. if (typeof e.newUserStates != "undefined") for (var r = 0; r < e.newUserStates.length; r++) {
  7010. var n = e.newUserStates[r];
  7011. if (n.userId == this.rtcp.network.room.userId) {
  7012. t = n.renderInfo.isMoving;
  7013. break;
  7014. }
  7015. }
  7016. return t;
  7017. }
  7018. }, {
  7019. key: "isHeartBeatPacket",
  7020. value: function isHeartBeatPacket(e, t) {
  7021. return new DataView(e).getUint32(0) == 2009889916;
  7022. }
  7023. }, {
  7024. key: "resetSendTimeDiff",
  7025. value: function resetSendTimeDiff() {
  7026. this.prevSenderTs = 0, this.serverSendTimeArray.clear();
  7027. }
  7028. }, {
  7029. key: "calcSendTimeDiff",
  7030. value: function calcSendTimeDiff(e) {
  7031. if (this.prevSenderTs == -1) {
  7032. this.prevSenderTs = e;
  7033. return;
  7034. }
  7035. var t = e - this.prevSenderTs;
  7036. this.serverSendTimeArray.add(t), this.prevSenderTs = e;
  7037. }
  7038. }, {
  7039. key: "unmarshalStream",
  7040. value: function unmarshalStream(e) {
  7041. var _this6 = this;
  7042. var T, C, A, S, P, R, M, x, I, w;
  7043. var t = new DataView(e);
  7044. if (t.getUint32(0) != 1437227610) return !1;
  7045. t.getUint16(4);
  7046. var n = t.getUint16(6),
  7047. o = t.getUint16(8),
  7048. a = o,
  7049. s = t.getUint16(10);
  7050. var l = !1;
  7051. s == 1 && (l = !0);
  7052. var u = t.getUint32(12),
  7053. c = t.getUint32(16),
  7054. h = t.getUint32(20),
  7055. f = t.getUint16(24),
  7056. d = t.getUint16(26),
  7057. _ = t.getUint32(28),
  7058. g = t.getUint32(n - 4),
  7059. m = u + c,
  7060. v = e.byteLength - n,
  7061. y = new Uint8Array(e, n, v);
  7062. this.calcSendTimeDiff(h);
  7063. var b;
  7064. if (this.inPanoMode && (c > 0 || f)) return defaultLogger.error("Stream Protocal Violation: receive illegal stream in Pano mode"), !0;
  7065. if (v === m) {
  7066. this.receivedMedia++;
  7067. var O = new Uint8Array(e).subarray(n);
  7068. h - this.lastServerTS > 60 ? this.serverFrameSlow++ : h - this.lastServerTS < 16 && this.serverFrameFast++;
  7069. var D = Date.now();
  7070. D - this.lastClientTS > 60 ? this.clientFrameSlow++ : D - this.lastClientTS < 16 && this.clientFrameFast++;
  7071. var F = c === 0,
  7072. V = h - this.lastServerTS;
  7073. 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;
  7074. var N = O.subarray(0, u),
  7075. L = Date.now(),
  7076. k = JSON.parse(this.Stringify(N)),
  7077. U = Date.now();
  7078. 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));
  7079. var z = this.getIsMoving(k);
  7080. if (this.inMovingMode && z == 0 && this.lastIsMoving == 1 && this.clearMoveArray(), typeof z != "undefined" && (this.lastIsMoving = z), this.inMovingMode) {
  7081. var G = Date.now(),
  7082. W = G - this.lastMoveResponseTime;
  7083. this.moveResponseCircular.add(W), this.lastMoveResponseTime = G;
  7084. }
  7085. (f || d) && (b = (P = (S = (A = (C = k.newUserStates) == null ? void 0 : C.find(function (G) {
  7086. return G.userId === _this6._rtcp.network.room.userId;
  7087. })) == null ? void 0 : A.playerState) == null ? void 0 : S.player) == null ? void 0 : P.position);
  7088. var H = {
  7089. t: 0,
  7090. data: O,
  7091. mediaLen: c,
  7092. metaLen: u,
  7093. metadata: k,
  7094. frameCnt: a,
  7095. server_ts: h,
  7096. isIDR: l,
  7097. cacheRequest: d,
  7098. cached: f,
  7099. cachedKey: _,
  7100. position: b
  7101. };
  7102. if (this.inPanoMode) return this.executeFunction("signal", {
  7103. signal: k,
  7104. pts: -1,
  7105. alreadyUpdateYUV: !0
  7106. }), !0;
  7107. if (this.decoderWorker.postMessage(H, [O.buffer]), !this.firstMediaReceived) {
  7108. this.firstMediaArraval = Date.now();
  7109. var _G = this.firstMediaArraval - this.rtcp.network.room._startTime;
  7110. defaultLogger.infoAndReportMeasurement({
  7111. metric: "firstMediaArravalAt",
  7112. value: _G,
  7113. group: "joinRoom"
  7114. }), this.firstMediaReceived = !0;
  7115. }
  7116. } else {
  7117. var _O = this.hasFrmCntInCache(a);
  7118. if (_O != -1) {
  7119. if (this.cacheFrameComposes[_O].buffer.set(y, g), this.cacheFrameComposes[_O].size += v, this.cacheFrameComposes[_O].size === m) {
  7120. var _D = new Uint8Array(this.cacheFrameComposes[_O].buffer).slice(0, m);
  7121. 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++;
  7122. var _F = Date.now();
  7123. _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;
  7124. var _V = _D.subarray(0, u),
  7125. _N = Date.now(),
  7126. _L = JSON.parse(this.Stringify(_V)),
  7127. _k = Date.now();
  7128. 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);
  7129. var _U = this.getIsMoving(_L);
  7130. if (this.inMovingMode && _U == 0 && this.lastIsMoving == 1 && this.clearMoveArray(), typeof _U != "undefined" && (this.lastIsMoving = _U), this.inMovingMode) {
  7131. var _H = Date.now(),
  7132. _G2 = _H - this.lastMoveResponseTime;
  7133. this.moveResponseCircular.add(_G2), this.lastMoveResponseTime = _H;
  7134. }
  7135. (f || d) && (b = (w = (I = (x = (M = _L.newUserStates) == null ? void 0 : M.find(function (H) {
  7136. return H.userId === _this6._rtcp.network.room.userId;
  7137. })) == null ? void 0 : x.playerState) == null ? void 0 : I.player) == null ? void 0 : w.position);
  7138. var _z = {
  7139. t: 0,
  7140. data: _D,
  7141. mediaLen: c,
  7142. metaLen: u,
  7143. metadata: _L,
  7144. frameCnt: a,
  7145. server_ts: h,
  7146. isIDR: l,
  7147. cacheRequest: d,
  7148. cached: f,
  7149. cachedKey: _,
  7150. position: b
  7151. };
  7152. if (this.inPanoMode) return this.executeFunction("signal", {
  7153. signal: _L,
  7154. pts: -1,
  7155. alreadyUpdateYUV: !0
  7156. }), !0;
  7157. if (this.decoderWorker.postMessage(_z, [_D.buffer]), !this.firstMediaReceived) {
  7158. this.firstMediaArraval = Date.now();
  7159. var _H2 = this.firstMediaArraval - this.rtcp.network.room._startTime;
  7160. defaultLogger.infoAndReportMeasurement({
  7161. metric: "firstMediaArravalAt",
  7162. value: _H2,
  7163. group: "joinRoom"
  7164. }), this.firstMediaReceived = !0;
  7165. }
  7166. } else this.cacheFrameComposes[_O].size > m && defaultLogger.debug("I frame exceed, cache size is ", this.cacheSize, ", total size is ", m);
  7167. } else if (_O == -1) {
  7168. var _D2 = this.hasFrmCntInCache(-1);
  7169. if (_D2 == -1) {
  7170. var _F2 = Date.now() + 1e18,
  7171. _V2 = -1;
  7172. for (var _N2 = 0; _N2 < this.cacheFrameComposes.length; _N2++) {
  7173. this.cacheFrameComposes[_N2].serverTime < _F2 && (_F2 = this.cacheFrameComposes[_N2].serverTime, _V2 = _N2);
  7174. }
  7175. _D2 = _V2;
  7176. }
  7177. 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;
  7178. }
  7179. }
  7180. return !0;
  7181. }
  7182. }, {
  7183. key: "reset",
  7184. value: function reset() {
  7185. defaultLogger.debug("Worker reset is called"), this.cacheFrameCnt = 0, this.receivedMedia = 0, this.reconnectSignal = !0, this.decoderWorker.postMessage({
  7186. t: 4
  7187. });
  7188. }
  7189. }, {
  7190. key: "dataHandleOff",
  7191. value: function dataHandleOff(e) {
  7192. defaultLogger.debug("hhh");
  7193. }
  7194. }, {
  7195. key: "dataHandle",
  7196. value: function dataHandle(e) {
  7197. this.saveframe && (this.decoderWorker.postMessage({
  7198. t: 6
  7199. }), this.saveframe = !1), this.SaveMediaStream && (this.decoderWorker.postMessage({
  7200. t: 7
  7201. }), this.SaveMediaStream = !1);
  7202. var t = new Uint8Array(e);
  7203. if (t.length >= 4 && this.isHeartBeatPacket(t.buffer, t.length) == !0) return;
  7204. if (t.length > 36 && this.unmarshalStream(t.buffer) == !0) {
  7205. this.reconnectSignal && (this.executeFunction("reconnectedFrame", {}), this.reconnectSignal = !1);
  7206. return;
  7207. }
  7208. if (t.length > 20 && this.unmarshalPano(t.buffer) == !0) return;
  7209. this.noWasmBytesReceived += e.byteLength;
  7210. var r = JSON.parse(this.Stringify(t));
  7211. this.executeFunction("signal", {
  7212. signal: r,
  7213. pts: -1,
  7214. alreadyUpdateYUV: !0
  7215. });
  7216. }
  7217. }, {
  7218. key: "changePanoMode",
  7219. value: function changePanoMode(e) {
  7220. this.inPanoMode = e;
  7221. }
  7222. }, {
  7223. key: "uploadDataToServer",
  7224. value: function uploadDataToServer() {
  7225. this.DynamicPanoTest == !0 && (this.onRotateInPanoMode({
  7226. traceId: "b2e1a296-6438-4371-8a31-687beb724ebe"
  7227. }), this.DynamicPanoTest = !1);
  7228. function e(ie, ee) {
  7229. return ee == -1 && (ee = 0), ie + ee;
  7230. }
  7231. function t(ie, ee) {
  7232. return Math.max(ie, ee);
  7233. }
  7234. var r = this.responseTimeArray.reduce(e, 0) / this.responseTimeArray.length || 0,
  7235. n = this.processTimeArray.reduce(e, 0) / this.processTimeArray.length || 0,
  7236. o = this.displayTimeArray.reduce(e, 0) / this.displayTimeArray.length || 0,
  7237. a = this.overallTimeArray.reduce(e, 0) / this.overallTimeArray.length || 0,
  7238. s = this.overallTimeArray.length;
  7239. this.responseTimeArray = [], this.processTimeArray = [], this.displayTimeArray = [], this.overallTimeArray = [];
  7240. var l = this.moveResponseCircular.getThreshPercent(),
  7241. u = l[0],
  7242. c = l[1],
  7243. h = l[2],
  7244. f = l[3],
  7245. d = l[4],
  7246. _ = d - f,
  7247. g = 1 - c / d || 0,
  7248. m = [u, c - u, h - c, f - h, _],
  7249. v = this.moveProcessCircular.getThreshPercent(),
  7250. y = v[0],
  7251. b = v[1],
  7252. T = v[2],
  7253. C = v[3],
  7254. A = v[4],
  7255. S = A - C,
  7256. P = 1 - b / A || 0,
  7257. R = [y, b - y, T - b, C - T, S],
  7258. M = this.moveDisplayCircular.getThreshPercent(),
  7259. x = M[0],
  7260. I = M[1],
  7261. w = M[2],
  7262. O = M[3],
  7263. D = M[4],
  7264. F = D - O,
  7265. V = 1 - I / D || 0,
  7266. N = [x, I - x, w - I, O - w, F],
  7267. L = x,
  7268. k = I - x,
  7269. U = w - I,
  7270. z = O - w,
  7271. H = F,
  7272. G = this.moveResponseCircular.getAvg(),
  7273. W = this.moveProcessCircular.getAvg(),
  7274. j = this.moveDisplayCircular.getAvg(),
  7275. B = this.moveResponseCircular.getMax(),
  7276. X = this.moveProcessCircular.getMax(),
  7277. $ = this.moveDisplayCircular.getMax(),
  7278. Y = this.moveResponseCircular.getStandardDeviation(),
  7279. K = this.moveProcessCircular.getStandardDeviation(),
  7280. Z = this.moveDisplayCircular.getStandardDeviation();
  7281. 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();
  7282. var q = this.frameServerCircular.getAvg(),
  7283. J = this.frameServerCircular.getMax();
  7284. this.frameClientCircular.getAvg(), this.frameClientCircular.getMax();
  7285. var Q = this.metaParseAraay.reduce(e, 0) / this.metaParseAraay.length || 0,
  7286. te = this.metaParseAraay.reduce(t, 0);
  7287. this.metaParseAraay = [];
  7288. var re = {
  7289. mediaBytesReceived: this.mediaBytesReceived,
  7290. metaBytesReceived: this.metaBytesReceived,
  7291. packetsLost: this.packetsLost,
  7292. timestamp: Date.now(),
  7293. frameHeight: 1280,
  7294. frameWidth: 720,
  7295. framesReceived: this.receivedMedia,
  7296. framesReceivedWorker: this.receivedMedia_worker,
  7297. framesDecoded: this.receivedYUV,
  7298. framesEmited: this.receivedEmit,
  7299. decodeTimePerFrame: this.decodeTimePerFrame,
  7300. decodeTimeMaxFrame: this.decodeTimeMaxFrame,
  7301. packetsDrop: this.packetsDrop,
  7302. framesAwait: this.framesAwait,
  7303. firstMediaArraval: this.firstMediaArraval,
  7304. firstYUVDecoded: this.firstYUVDecoded,
  7305. firstRender: this.firstRender,
  7306. returnFrames: this.returnFrames,
  7307. sendOutBuffer: this.sendOutBuffer,
  7308. maxGraphicTime: this.updateYUVCircular.getMax(),
  7309. averageGraphicTime: this.updateYUVCircular.getAvg(),
  7310. jankTimes: this.JankTimes,
  7311. bigJankTimes: this.bigJankTimes,
  7312. decodeJankTimes: this.DecodeJankTimes,
  7313. bigDecodeJankTimes: this.bigDecodeJankTimes,
  7314. serverFrameSlow: this.serverFrameSlow,
  7315. serverFrameFast: this.serverFrameFast,
  7316. clientFrameSlow: this.clientFrameSlow,
  7317. clientFrameFast: this.clientFrameFast,
  7318. rtcMessageReceived: this.rtcMessageReceived,
  7319. rtcBytesReceived: this.rtcBytesReceived - this.noWasmBytesReceived,
  7320. receiveIframes: this.receiveIframes,
  7321. decodeIframes: this.decodeIframes,
  7322. avgResponseTime: r,
  7323. avgProcessTime: n,
  7324. avgDisplayTime: o,
  7325. avgOverallTime: a,
  7326. overallTimeCount: s,
  7327. responseMiss: this.responseMiss,
  7328. processMiss: this.processMiss,
  7329. displayMiss: this.displayMiss,
  7330. updateDropFrame: this.updateDropFrame,
  7331. moveEvent: this.moveEvent,
  7332. avgResponseMoveDiff: this.moveEvent == "MoveTo" ? G : 0,
  7333. avgProcessMoveDiff: this.moveEvent == "MoveTo" ? W : 0,
  7334. avgDisplayMoveDiff: this.moveEvent == "MoveTo" ? j : 0,
  7335. maxResponseMoveDiff: this.moveEvent == "MoveTo" ? B : 0,
  7336. maxProcessMoveDiff: this.moveEvent == "MoveTo" ? X : 0,
  7337. maxDisplayMoveDiff: this.moveEvent == "MoveTo" ? $ : 0,
  7338. moveResponseJank: this.moveEvent == "MoveTo" ? g : 0,
  7339. moveProcessJank: this.moveEvent == "MoveTo" ? P : 0,
  7340. moveDisplayJank: this.moveEvent == "MoveTo" ? V : 0,
  7341. moveResponseCounts: this.moveEvent == "MoveTo" ? m.toString() : "0,0,0,0,0",
  7342. moveProcessCounts: this.moveEvent == "MoveTo" ? R.toString() : "0,0,0,0,0",
  7343. moveDisplayCounts: this.moveEvent == "MoveTo" ? N.toString() : "0,0,0,0,0",
  7344. MoveDisplayCountGood: this.moveEvent == "MoveTo" ? L.toString() : "0",
  7345. MoveDisplayCountWell: this.moveEvent == "MoveTo" ? k.toString() : "0",
  7346. MoveDisplayCountFair: this.moveEvent == "MoveTo" ? U.toString() : "0",
  7347. MoveDisplayCountBad: this.moveEvent == "MoveTo" ? z.toString() : "0",
  7348. MoveDisplayCountRest: this.moveEvent == "MoveTo" ? H.toString() : "0",
  7349. moveResponseDelay: this.moveEvent == "MoveTo" ? this.MoveResponseDelay : 0,
  7350. moveProcessDelay: this.moveEvent == "MoveTo" ? this.MoveProcessDelay : 0,
  7351. moveDisplayDelay: this.moveEvent == "MoveTo" ? this.MoveDisplayDelay : 0,
  7352. sdMoveResponseLongTime: Y,
  7353. sdMoveProcessLongTime: K,
  7354. sdMoveDisplayLongTime: Z,
  7355. avgResponseFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? G : 0,
  7356. avgProcessFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? W : 0,
  7357. avgDisplayFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? j : 0,
  7358. maxResponseFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? B : 0,
  7359. maxProcessFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? X : 0,
  7360. maxDisplayFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? $ : 0,
  7361. flyResponseJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? g : 0,
  7362. flyProcessJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? P : 0,
  7363. flyDisplayJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? V : 0,
  7364. flyResponseCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? m.toString() : "0,0,0,0,0",
  7365. flyProcessCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? R.toString() : "0,0,0,0,0",
  7366. flyDisplayCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? N.toString() : "0,0,0,0,0",
  7367. flyResponseDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveResponseDelay : 0,
  7368. flyProcessDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveProcessDelay : 0,
  7369. flyDisplayDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveDisplayDelay : 0,
  7370. avgMetaParseTime: Q,
  7371. maxMetaParseTime: te,
  7372. avgServerDiff: q,
  7373. maxServerDiff: J,
  7374. streamType: WASM_Version
  7375. };
  7376. return this.lastReturnFrames = this.returnFrames, this.lastReceivedEmit = this.receivedEmit, re;
  7377. }
  7378. }]);
  7379. return Workers;
  7380. }();
  7381. 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); }; }
  7382. 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; } }
  7383. var Rtcp = /*#__PURE__*/function (_EventEmitter) {
  7384. _inherits(Rtcp, _EventEmitter);
  7385. var _super = _createSuper$c(Rtcp);
  7386. function Rtcp(e) {
  7387. var _this;
  7388. _classCallCheck(this, Rtcp);
  7389. _this = _super.call(this);
  7390. E(_assertThisInitialized(_this), "connection", null);
  7391. E(_assertThisInitialized(_this), "inputChannel", null);
  7392. E(_assertThisInitialized(_this), "mediaStream");
  7393. E(_assertThisInitialized(_this), "socket");
  7394. E(_assertThisInitialized(_this), "connected", !1);
  7395. E(_assertThisInitialized(_this), "candidates", []);
  7396. E(_assertThisInitialized(_this), "isAnswered", !1);
  7397. E(_assertThisInitialized(_this), "isFlushing", !1);
  7398. E(_assertThisInitialized(_this), "inputReady", !1);
  7399. E(_assertThisInitialized(_this), "workers");
  7400. E(_assertThisInitialized(_this), "actived", !0);
  7401. E(_assertThisInitialized(_this), "heartbeat");
  7402. E(_assertThisInitialized(_this), "onIcecandidate", function (e) {
  7403. if (e.candidate != null) {
  7404. var t = JSON.stringify(e.candidate);
  7405. logger$1.debug("Got ice candidate: ".concat(t)), _this.network.socket.send({
  7406. id: "ice_candidate",
  7407. data: btoa(t)
  7408. });
  7409. }
  7410. });
  7411. E(_assertThisInitialized(_this), "onIcecandidateerror", function (e) {
  7412. logger$1.error("onicecandidateerror", e.errorCode, e.errorText, e);
  7413. });
  7414. E(_assertThisInitialized(_this), "onIceStateChange", function (e) {
  7415. switch (e.target.iceGatheringState) {
  7416. case "gathering":
  7417. logger$1.info("ice gathering");
  7418. break;
  7419. case "complete":
  7420. logger$1.info("Ice gathering completed");
  7421. }
  7422. });
  7423. E(_assertThisInitialized(_this), "onIceConnectionStateChange", function () {
  7424. if (!!_this.connection) switch (logger$1.info("iceConnectionState: ".concat(_this.connection.iceConnectionState)), _this.connection.iceConnectionState) {
  7425. case "connected":
  7426. {
  7427. _this.connected = !0;
  7428. break;
  7429. }
  7430. case "disconnected":
  7431. {
  7432. _this.connected = !1, _this.emit("rtcDisconnected");
  7433. break;
  7434. }
  7435. case "failed":
  7436. {
  7437. _this.emit("rtcDisconnected"), _this.connected = !1;
  7438. break;
  7439. }
  7440. }
  7441. });
  7442. E(_assertThisInitialized(_this), "setRemoteDescription", /*#__PURE__*/function () {
  7443. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e, t) {
  7444. var a, s, l, r, n, o, u;
  7445. return regenerator.wrap(function _callee$(_context) {
  7446. while (1) {
  7447. switch (_context.prev = _context.next) {
  7448. case 0:
  7449. if (_this.connection) {
  7450. _context.next = 2;
  7451. break;
  7452. }
  7453. return _context.abrupt("return");
  7454. case 2:
  7455. r = JSON.parse(atob(e)), n = new RTCSessionDescription(r);
  7456. _context.next = 5;
  7457. return _this.connection.setRemoteDescription(n);
  7458. case 5:
  7459. _context.next = 7;
  7460. return _this.connection.createAnswer();
  7461. case 7:
  7462. o = _context.sent;
  7463. 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) {
  7464. u = o.sdp.lastIndexOf("a=mid:1");
  7465. o.sdp = o.sdp.slice(0, u) + "a=mid:2" + o.sdp.slice(u + 7);
  7466. }
  7467. _context.prev = 9;
  7468. _context.next = 12;
  7469. return _this.connection.setLocalDescription(o);
  7470. case 12:
  7471. _context.next = 17;
  7472. break;
  7473. case 14:
  7474. _context.prev = 14;
  7475. _context.t0 = _context["catch"](9);
  7476. logger$1.error("error", _context.t0);
  7477. case 17:
  7478. _this.isAnswered = !0, _this.network.rtcp.flushCandidate(), _this.network.socket.send({
  7479. id: "answer",
  7480. data: btoa(JSON.stringify(o))
  7481. }), t.srcObject = _this.mediaStream;
  7482. case 18:
  7483. case "end":
  7484. return _context.stop();
  7485. }
  7486. }
  7487. }, _callee, null, [[9, 14]]);
  7488. }));
  7489. return function (_x, _x2) {
  7490. return _ref.apply(this, arguments);
  7491. };
  7492. }());
  7493. E(_assertThisInitialized(_this), "flushCandidate", function () {
  7494. _this.isFlushing || !_this.isAnswered || (_this.isFlushing = !0, _this.candidates.forEach(function (e) {
  7495. var t = atob(e),
  7496. r = JSON.parse(t);
  7497. if (/172\./.test(r.candidate)) return;
  7498. var n = new RTCIceCandidate(r);
  7499. _this.connection && _this.connection.addIceCandidate(n).then(function () {}, function (o) {
  7500. logger$1.info("add candidate failed", o);
  7501. });
  7502. }), _this.isFlushing = !1);
  7503. });
  7504. E(_assertThisInitialized(_this), "input", function (e) {
  7505. var t;
  7506. !_this.actived || !_this.inputChannel || _this.inputChannel.readyState === "open" && ((t = _this.inputChannel) == null || t.send(e));
  7507. });
  7508. _this.network = e, _this.workers = new Workers(_assertThisInitialized(_this), logger$1), _this.workers.registerLogger(logger$1), _this.workers.registerFunction("data", function (t) {
  7509. _this.emit("data", t);
  7510. }), _this.heartbeat = new Heartbeat({
  7511. ping: function ping(t) {
  7512. e.room.actionsHandler.echo(t);
  7513. },
  7514. pong(t, r) {
  7515. var n;
  7516. r && t > 500 && logger$1.warn("high hb value ".concat(t, ", traceId:") + r), (n = e.room.stats) == null || n.assign({
  7517. hb: t
  7518. });
  7519. }
  7520. });
  7521. return _this;
  7522. }
  7523. _createClass(Rtcp, [{
  7524. key: "start",
  7525. value: function start() {
  7526. var _this2 = this;
  7527. this.connection = new RTCPeerConnection();
  7528. var e = Date.now();
  7529. this.connection.ondatachannel = function (t) {
  7530. logger$1.info("ondatachannel: ".concat(t.channel.label));
  7531. _this2.inputChannel = t.channel;
  7532. _this2.inputChannel.onopen = function () {
  7533. var r;
  7534. 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({
  7535. metric: "datachannelOpenedAt",
  7536. startTime: _this2.network.room._startTime,
  7537. group: "joinRoom"
  7538. }), logger$1.infoAndReportMeasurement({
  7539. metric: "datachannelOpenedCost",
  7540. startTime: e,
  7541. group: "joinRoom"
  7542. }));
  7543. console.log('this.inputChannel', _this2.inputChannel);
  7544. }, _this2.inputChannel.onclose = function () {
  7545. var r;
  7546. return logger$1.info("The input channel has closed, id:", (r = _this2.inputChannel) == null ? void 0 : r.id);
  7547. }, _this2.inputChannel.onmessage = function (r) {
  7548. // console.log('this.workers',this.workers)
  7549. //console.log('inputChannel',r.data)
  7550. _this2.workers.dataHandle(r.data);
  7551. };
  7552. }, this.connection.oniceconnectionstatechange = this.onIceConnectionStateChange, this.connection.onicegatheringstatechange = this.onIceStateChange, this.connection.onicecandidate = this.onIcecandidate, this.connection.onicecandidateerror = this.onIcecandidateerror, this.network.socket.send({
  7553. id: "init_webrtc",
  7554. data: JSON.stringify({
  7555. is_mobile: !0
  7556. })
  7557. });
  7558. }
  7559. }, {
  7560. key: "addCandidate",
  7561. value: function addCandidate(e) {
  7562. e === "" ? this.network.rtcp.flushCandidate() : this.candidates.push(e);
  7563. }
  7564. }, {
  7565. key: "disconnect",
  7566. value: function disconnect() {
  7567. var e, t, r;
  7568. 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;
  7569. }
  7570. }, {
  7571. key: "sendStringData",
  7572. value: function sendStringData(e) {
  7573. console.log('e', e);
  7574. this.input(e);
  7575. }
  7576. }, {
  7577. key: "sendData",
  7578. value: function sendData(e) {
  7579. var t = "";
  7580. try {
  7581. t = JSON.stringify(e);
  7582. } catch (r) {
  7583. logger$1.error(r);
  7584. return;
  7585. }
  7586. this.input(t);
  7587. }
  7588. }]);
  7589. return Rtcp;
  7590. }(EventEmitter);
  7591. var NetworkMonitor = /*#__PURE__*/function () {
  7592. function NetworkMonitor(e) {
  7593. _classCallCheck(this, NetworkMonitor);
  7594. this._listener = e;
  7595. }
  7596. _createClass(NetworkMonitor, [{
  7597. key: "isOnline",
  7598. get: function get() {
  7599. var e = window.navigator;
  7600. return typeof e.onLine == "boolean" ? e.onLine : !0;
  7601. }
  7602. }, {
  7603. key: "start",
  7604. value: function start() {
  7605. window.addEventListener("online", this._listener), window.addEventListener("offline", this._listener);
  7606. }
  7607. }, {
  7608. key: "stop",
  7609. value: function stop() {
  7610. window.removeEventListener("online", this._listener), window.removeEventListener("offline", this._listener);
  7611. }
  7612. }]);
  7613. return NetworkMonitor;
  7614. }();
  7615. var Stream = /*#__PURE__*/function () {
  7616. function Stream(e) {
  7617. _classCallCheck(this, Stream);
  7618. this.el = null;
  7619. this._streamPlayTimer = null;
  7620. if (!e) {
  7621. this.el = this.createVideoElement();
  7622. return;
  7623. }
  7624. this.el = e;
  7625. }
  7626. _createClass(Stream, [{
  7627. key: "play",
  7628. value: function play() {
  7629. var _this = this;
  7630. return new Promise(function (e, t) {
  7631. _this._streamPlayTimer = new Timeout(function () {
  7632. t(new InternalError("Stream play timeout"));
  7633. }, 5e3), _this.el && _this.el.play().then(function () {
  7634. var r;
  7635. e(), logger$1.info("Media can autoplay"), (r = _this._streamPlayTimer) == null || r.clear();
  7636. }).catch(function (r) {
  7637. var n;
  7638. logger$1.error("Media Failed to autoplay"), logger$1.error(r), t(new InternalError("Media Failed to autoplay")), (n = _this._streamPlayTimer) == null || n.clear();
  7639. });
  7640. });
  7641. }
  7642. }, {
  7643. key: "createVideoElement",
  7644. value: function createVideoElement() {
  7645. var e = document.createElement("video");
  7646. 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;
  7647. }
  7648. }]);
  7649. return Stream;
  7650. }();
  7651. 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); }; }
  7652. 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; } }
  7653. 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 ";
  7654. var NetworkController = /*#__PURE__*/function (_EventEmitter) {
  7655. _inherits(NetworkController, _EventEmitter);
  7656. var _super = _createSuper$b(NetworkController);
  7657. function NetworkController(e) {
  7658. var _this;
  7659. _classCallCheck(this, NetworkController);
  7660. _this = _super.call(this);
  7661. _this.socket = null;
  7662. _this.rtcp = null;
  7663. _this.stream = null;
  7664. _this._state = 'connecting';
  7665. _this._networkMonitor = null;
  7666. _this.blockedActions = [];
  7667. _this.reconnectCount = 0;
  7668. _this.room = e, _this.socket = new Socket(_assertThisInitialized(_this));
  7669. _this.rtcp = new Rtcp(_assertThisInitialized(_this));
  7670. _this.stream = new Stream();
  7671. _this._networkMonitor = new NetworkMonitor(function () {
  7672. 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());
  7673. });
  7674. _this.checkNetworkQuality(_this.room.currentNetworkOptions.wsServerUrl);
  7675. _this._networkMonitor.start();
  7676. new VisibilityChangeHandler().subscribe(function (r) {
  7677. var n, o;
  7678. r ? ((o = _this.room.stats) == null || o.disable(), logger$1.infoAndReportMeasurement({
  7679. metric: "pageHide",
  7680. startTime: Date.now()
  7681. })) : ((n = _this.room.stats) == null || n.enable(), logger$1.infoAndReportMeasurement({
  7682. metric: "pageShow",
  7683. startTime: Date.now(),
  7684. extra: {
  7685. state: _this._state
  7686. }
  7687. }), _this._state === "disconnected" && _this.reconnect());
  7688. });
  7689. return _this;
  7690. }
  7691. _createClass(NetworkController, [{
  7692. key: "startGame",
  7693. value: function startGame() {
  7694. var _this2 = this;
  7695. return new Promise(function (e, t) {
  7696. if (!_this2.rtcp.connected) return t(new InternalError("Game cannot load. Please refresh"));
  7697. if (!_this2.rtcp.inputReady) return t(new InternalError("Game is not ready yet. Please wait"));
  7698. _this2.socket.on("gameRoomAvailable", function (r) {
  7699. _this2.setState("connected"), e(r), _this2.rtcp.heartbeat.start();
  7700. }), _this2.socket.on("socketClosed", function (r) {
  7701. t(r);
  7702. }), _this2.socket.startGame();
  7703. });
  7704. }
  7705. }, {
  7706. key: "addBlockedActions",
  7707. value: function addBlockedActions(e) {
  7708. var _this$blockedActions;
  7709. (_this$blockedActions = this.blockedActions).push.apply(_this$blockedActions, _toConsumableArray(e));
  7710. }
  7711. }, {
  7712. key: "removeBlockedActions",
  7713. value: function removeBlockedActions(e) {
  7714. if (!e) {
  7715. this.blockedActions = [];
  7716. return;
  7717. }
  7718. var t = this.blockedActions.indexOf(e);
  7719. this.blockedActions.splice(t, 1);
  7720. }
  7721. }, {
  7722. key: "setState",
  7723. value: function setState(e) {
  7724. this._state !== e && (logger$1.info("Set network state to ", e), this._state = e);
  7725. }
  7726. }, {
  7727. key: "connectAndStart",
  7728. value: function () {
  7729. var _connectAndStart = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  7730. return regenerator.wrap(function _callee$(_context) {
  7731. while (1) {
  7732. switch (_context.prev = _context.next) {
  7733. case 0:
  7734. return _context.abrupt("return", this.connect(e).then(this.startGame));
  7735. case 1:
  7736. case "end":
  7737. return _context.stop();
  7738. }
  7739. }
  7740. }, _callee, this);
  7741. }));
  7742. function connectAndStart(_x) {
  7743. return _connectAndStart.apply(this, arguments);
  7744. }
  7745. return connectAndStart;
  7746. }()
  7747. }, {
  7748. key: "connect",
  7749. value: function () {
  7750. var _connect = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  7751. var _this3 = this;
  7752. var e,
  7753. _args2 = arguments;
  7754. return regenerator.wrap(function _callee2$(_context2) {
  7755. while (1) {
  7756. switch (_context2.prev = _context2.next) {
  7757. case 0:
  7758. e = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : !1;
  7759. this.room.updateCurrentNetworkOptions({
  7760. reconnect: e
  7761. });
  7762. return _context2.abrupt("return", new Promise(function (t, r) {
  7763. _this3.rtcp.on("rtcConnected", function () {
  7764. _this3.setState("connected"), t();
  7765. }), _this3.rtcp.on("rtcDisconnected", function () {
  7766. 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());
  7767. }), _this3.socket.on("socketQuit", function () {
  7768. logger$1.info("socket quit success"), _this3.setState("closed");
  7769. }), _this3.socket.on("socketClosed", function (n) {
  7770. _this3._state === "connecting" && (_this3.setState("disconnected"), r(n)), r(n);
  7771. }), _this3.socket.start();
  7772. }));
  7773. case 3:
  7774. case "end":
  7775. return _context2.stop();
  7776. }
  7777. }
  7778. }, _callee2, this);
  7779. }));
  7780. function connect() {
  7781. return _connect.apply(this, arguments);
  7782. }
  7783. return connect;
  7784. }()
  7785. }, {
  7786. key: "reconnect",
  7787. value: function reconnect() {
  7788. var _this4 = this;
  7789. if (this.room.viewMode === "observer") return;
  7790. var e = Date.now();
  7791. if (this.reconnectCount++, this.reconnectCount > MAX_RECONNECT_COUNT) {
  7792. logger$1.error("reconnect failed, reached max reconnect count", MAX_RECONNECT_COUNT), this.reconnectCount = 0, this.emit("stateChanged", {
  7793. state: "disconnected"
  7794. });
  7795. return;
  7796. }
  7797. return logger$1.info("start reconnect, count:", this.reconnectCount), this._reconnect().then(function () {
  7798. logger$1.infoAndReportMeasurement({
  7799. startTime: e,
  7800. metric: "reconnect"
  7801. });
  7802. }).catch(function (t) {
  7803. if (logger$1.infoAndReportMeasurement({
  7804. startTime: e,
  7805. metric: "reconnect",
  7806. error: t
  7807. }), t.code === Codes.RepeatLogin) {
  7808. _this4.room.handleRepetLogin();
  7809. return;
  7810. }
  7811. var r = 1e3;
  7812. logger$1.info("reconnect failed, wait " + r + " ms for next reconnect"), setTimeout(function () {
  7813. _this4.reconnect();
  7814. }, r);
  7815. });
  7816. }
  7817. }, {
  7818. key: "_reconnect",
  7819. value: function _reconnect() {
  7820. var _this5 = this;
  7821. 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", {
  7822. state: "reconnecting",
  7823. count: this.reconnectCount
  7824. }), this.socket.off("gameRoomAvailable"), this.socket.off("socketClosed"), this.rtcp.off("rtcDisconnected"), this.rtcp.off("rtcConnected"), this.connectAndStart(!0).then(function (_ref) {
  7825. var e = _ref.session_id;
  7826. _this5.room.updateCurrentNetworkOptions({
  7827. sessionId: e
  7828. }), reporter.updateBody({
  7829. serverSession: e
  7830. }), logger$1.info("reconnect success"), _this5.setState("connected"), _this5.reconnectCount = 0, _this5.emit("stateChanged", {
  7831. state: "reconnected"
  7832. });
  7833. }));
  7834. }
  7835. }, {
  7836. key: "prepareReconnect",
  7837. value: function prepareReconnect() {
  7838. this.rtcp.disconnect(), this.socket.prepareReconnect(), this.prepareReconnectOptions();
  7839. }
  7840. }, {
  7841. key: "prepareReconnectOptions",
  7842. value: function prepareReconnectOptions() {
  7843. var _ref2 = this.room.currentClickingState || {},
  7844. e = _ref2.camera,
  7845. t = _ref2.player;
  7846. e && t && this.room.updateCurrentNetworkOptions({
  7847. camera: e,
  7848. player: t
  7849. });
  7850. }
  7851. }, {
  7852. key: "sendRtcData",
  7853. value: function sendRtcData(e) {
  7854. if (this.blockedActions.includes(e.action_type)) {
  7855. logger$1.info("action: ".concat(Actions[e.action_type], " was blocked"));
  7856. return;
  7857. }
  7858. this.rtcp.sendData(e);
  7859. }
  7860. }, {
  7861. key: "sendSocketData",
  7862. value: function sendSocketData(e) {
  7863. logger$1.debug("ws send ->", e), this.socket.send(e);
  7864. }
  7865. }, {
  7866. key: "quit",
  7867. value: function quit() {
  7868. var e = util.uuid(),
  7869. t = {
  7870. action_type: Actions.Exit,
  7871. trace_id: e,
  7872. exit_action: {},
  7873. user_id: this.room.options.userId,
  7874. packet_id: e
  7875. };
  7876. this.setState("closed"), this.socket.quit(), this.sendRtcData(t);
  7877. }
  7878. }, {
  7879. key: "checkNetworkQuality",
  7880. value: function checkNetworkQuality(i) {
  7881. var worker = null;
  7882. if (!i) return;
  7883. var e = Date.now();
  7884. if (this.pingOthers("https://www.baidu.com", function (t, r) {
  7885. logger$1.infoAndReportMeasurement({
  7886. metric: "baiduRtt",
  7887. group: "http",
  7888. value: r,
  7889. startTime: e
  7890. });
  7891. }), !worker) {
  7892. var t = new Blob([workerSourceCode], {
  7893. type: "application/javascript"
  7894. });
  7895. worker = new Worker(URL.createObjectURL(t)), worker.onmessage = function (r) {
  7896. logger$1.infoAndReportMeasurement({
  7897. metric: "workerRtt",
  7898. group: "http",
  7899. startTime: e,
  7900. value: r.data
  7901. });
  7902. };
  7903. }
  7904. }
  7905. }, {
  7906. key: "pingOthers",
  7907. value: function pingOthers(i, e) {
  7908. var t = !1;
  7909. var r = new Image();
  7910. r.onload = o, r.onerror = a;
  7911. var n = Date.now();
  7912. function o(l) {
  7913. t = !0, s();
  7914. }
  7915. function a(l) {}
  7916. function s() {
  7917. var l = Date.now() - n;
  7918. if (typeof e == "function") return t ? e(null, l) : (console.error("error loading resource"), e("error", l));
  7919. }
  7920. r.src = i + "/favicon.ico?" + +new Date();
  7921. }
  7922. }]);
  7923. return NetworkController;
  7924. }(EventEmitter);
  7925. 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); }; }
  7926. 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; } }
  7927. var InitConfigTimeoutError = /*#__PURE__*/function (_XverseError) {
  7928. _inherits(InitConfigTimeoutError, _XverseError);
  7929. var _super = _createSuper$a(InitConfigTimeoutError);
  7930. function InitConfigTimeoutError(e) {
  7931. _classCallCheck(this, InitConfigTimeoutError);
  7932. return _super.call(this, 1009, e || "\u914D\u7F6E\u521D\u59CB\u5316\u8D85\u65F6");
  7933. }
  7934. return _createClass(InitConfigTimeoutError);
  7935. }(XverseError);
  7936. 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); }; }
  7937. 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; } }
  7938. var InitDecoderTimeoutError = /*#__PURE__*/function (_XverseError) {
  7939. _inherits(InitDecoderTimeoutError, _XverseError);
  7940. var _super = _createSuper$9(InitDecoderTimeoutError);
  7941. function InitDecoderTimeoutError(e) {
  7942. _classCallCheck(this, InitDecoderTimeoutError);
  7943. return _super.call(this, 1008, e || "Decoder \u521D\u59CB\u5316\u8D85\u65F6");
  7944. }
  7945. return _createClass(InitDecoderTimeoutError);
  7946. }(XverseError);
  7947. 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); }; }
  7948. 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; } }
  7949. var InitEngineError = /*#__PURE__*/function (_XverseError) {
  7950. _inherits(InitEngineError, _XverseError);
  7951. var _super = _createSuper$8(InitEngineError);
  7952. function InitEngineError(e) {
  7953. _classCallCheck(this, InitEngineError);
  7954. return _super.call(this, 1011, e || "\u5F15\u64CE\u521D\u59CB\u5316\u9519\u8BEF");
  7955. }
  7956. return _createClass(InitEngineError);
  7957. }(XverseError);
  7958. var AssetTypeName = {
  7959. Config: 'CONFIG',
  7960. Model: 'MODEL',
  7961. Vedio: 'VEDIO',
  7962. Media: 'MEDIA',
  7963. Effects: 'EFFECTS',
  7964. Gift: 'GIFT',
  7965. Textures: 'TEXTURES'
  7966. };
  7967. var AssetClassName = {
  7968. Effects: '\u7279\u6548',
  7969. Tv: 'TV',
  7970. Lpm: '\u7C97\u6A21',
  7971. Reward: '\u571F\u8C6A\u699C',
  7972. Env: '\u73AF\u5883\u5149',
  7973. Gbq: '\u544A\u767D\u5899',
  7974. BreathPoint: '\u547C\u5438\u70B9',
  7975. Gifts: '\u9001\u793C',
  7976. Panorama: '\u5168\u666F\u56FE',
  7977. GiftBubble: '\u9001\u793C\u6C14\u6CE1',
  7978. SayBubble: '\u804A\u5929\u6C14\u6CE1'
  7979. };
  7980. var LoggerLevels$1 = {
  7981. Debug: 1,
  7982. Info: 2,
  7983. Warn: 3,
  7984. Error: 4,
  7985. Off: 5
  7986. };
  7987. var EShaderMode = {
  7988. default: 0,
  7989. video: 1,
  7990. videoAndPano: 2
  7991. };
  7992. var EFitMode = {
  7993. fill: 'fill',
  7994. contain: 'contain',
  7995. cover: 'cover'
  7996. };
  7997. var BaseTable = /*#__PURE__*/function () {
  7998. function BaseTable(e, t) {
  7999. _classCallCheck(this, BaseTable);
  8000. this.db = null;
  8001. this.isCreatingTable = !1;
  8002. this.hasCleared = !1;
  8003. this.dbName = e, this.dbVersion = t;
  8004. }
  8005. _createClass(BaseTable, [{
  8006. key: "clearDataBase",
  8007. value: function () {
  8008. var _clearDataBase = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  8009. var _this = this;
  8010. return regenerator.wrap(function _callee$(_context) {
  8011. while (1) {
  8012. switch (_context.prev = _context.next) {
  8013. case 0:
  8014. return _context.abrupt("return", this.hasCleared || (e && (this.hasCleared = !0), !window.indexedDB.databases) ? Promise.resolve() : new Promise(function (t, r) {
  8015. var n = window.indexedDB.deleteDatabase(_this.dbName);
  8016. n.onsuccess = function () {
  8017. t();
  8018. }, n.onerror = r;
  8019. }));
  8020. case 1:
  8021. case "end":
  8022. return _context.stop();
  8023. }
  8024. }
  8025. }, _callee, this);
  8026. }));
  8027. function clearDataBase(_x) {
  8028. return _clearDataBase.apply(this, arguments);
  8029. }
  8030. return clearDataBase;
  8031. }()
  8032. }, {
  8033. key: "tableName",
  8034. value: function tableName() {
  8035. throw new Error("Derived class have to override 'tableName', and set a proper table name!");
  8036. }
  8037. }, {
  8038. key: "keyPath",
  8039. value: function keyPath() {
  8040. throw new Error("Derived class have to override 'keyPath', and set a proper index name!");
  8041. }
  8042. }, {
  8043. key: "index",
  8044. value: function index() {
  8045. throw new Error("Derived class have to override 'index', and set a proper index name!");
  8046. }
  8047. }, {
  8048. key: "checkAndOpenDatabase",
  8049. value: function () {
  8050. var _checkAndOpenDatabase = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  8051. var _this2 = this;
  8052. return regenerator.wrap(function _callee2$(_context2) {
  8053. while (1) {
  8054. switch (_context2.prev = _context2.next) {
  8055. case 0:
  8056. return _context2.abrupt("return", this.db ? Promise.resolve(this.db) : new Promise(function (e, t) {
  8057. var n = setTimeout(function () {
  8058. logger$1.info("wait db to open for", 200), _this2.db ? e(_this2.db) : e(_this2.checkAndOpenDatabase()), clearTimeout(n);
  8059. }, 200);
  8060. _this2.openDatabase(_this2.dbName, _this2.dbVersion || 1, function () {
  8061. _this2.db && !_this2.isCreatingTable && e(_this2.db), logger$1.info("successCallback called, this.db: ".concat(!!_this2.db, ", this.isCreatingStore: ").concat(_this2.isCreatingTable)), clearTimeout(n);
  8062. }, function () {
  8063. t(new Error("Failed to open database!")), clearTimeout(n);
  8064. }, function () {
  8065. _this2.db && e(_this2.db), clearTimeout(n), logger$1.info("successCallback called, this.db: ".concat(!!_this2.db, ", this.isCreatingStore: ").concat(_this2.isCreatingTable));
  8066. });
  8067. }));
  8068. case 1:
  8069. case "end":
  8070. return _context2.stop();
  8071. }
  8072. }
  8073. }, _callee2, this);
  8074. }));
  8075. function checkAndOpenDatabase() {
  8076. return _checkAndOpenDatabase.apply(this, arguments);
  8077. }
  8078. return checkAndOpenDatabase;
  8079. }()
  8080. }, {
  8081. key: "openDatabase",
  8082. value: function openDatabase(e, t, r, n, o) {
  8083. var _this3 = this;
  8084. if (this.isCreatingTable) return;
  8085. this.isCreatingTable = !0, logger$1.info(e, t);
  8086. var a = window.indexedDB.open(e, t),
  8087. s = this.tableName();
  8088. a.onsuccess = function (l) {
  8089. _this3.db = a.result, logger$1.info("IndexedDb ".concat(e, " is opened.")), _this3.db.objectStoreNames.contains(s) && (_this3.isCreatingTable = !1), r && r(l);
  8090. }, a.onerror = function (l) {
  8091. var u;
  8092. 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);
  8093. }, a.onupgradeneeded = function (l) {
  8094. var u = l.target.result,
  8095. c = _this3.index();
  8096. logger$1.info("Creating table ".concat(s, "."));
  8097. var h = u.objectStoreNames.contains(s);
  8098. if (h) h = u.transaction([s], "readwrite").objectStore(s);else {
  8099. var f = _this3.keyPath();
  8100. h = u.createObjectStore(s, {
  8101. keyPath: f
  8102. });
  8103. }
  8104. c.map(function (f) {
  8105. h.createIndex(f, f, {
  8106. unique: !1
  8107. });
  8108. }), _this3.isCreatingTable = !1, logger$1.info("Table ".concat(s, " opened")), o && o(l);
  8109. };
  8110. }
  8111. }, {
  8112. key: "add",
  8113. value: function () {
  8114. var _add = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  8115. var t, o;
  8116. return regenerator.wrap(function _callee3$(_context3) {
  8117. while (1) {
  8118. switch (_context3.prev = _context3.next) {
  8119. case 0:
  8120. t = this.tableName();
  8121. _context3.next = 3;
  8122. return this.checkAndOpenDatabase();
  8123. case 3:
  8124. o = _context3.sent.transaction([t], "readwrite").objectStore(t).add(e);
  8125. return _context3.abrupt("return", new Promise(function (a, s) {
  8126. o.onsuccess = function (l) {
  8127. a(l);
  8128. }, o.onerror = function (l) {
  8129. var u;
  8130. logger$1.error((u = l.srcElement) == null ? void 0 : u.error), s(l);
  8131. };
  8132. }));
  8133. case 5:
  8134. case "end":
  8135. return _context3.stop();
  8136. }
  8137. }
  8138. }, _callee3, this);
  8139. }));
  8140. function add(_x2) {
  8141. return _add.apply(this, arguments);
  8142. }
  8143. return add;
  8144. }()
  8145. }, {
  8146. key: "put",
  8147. value: function () {
  8148. var _put = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  8149. var t, o;
  8150. return regenerator.wrap(function _callee4$(_context4) {
  8151. while (1) {
  8152. switch (_context4.prev = _context4.next) {
  8153. case 0:
  8154. t = this.tableName();
  8155. _context4.next = 3;
  8156. return this.checkAndOpenDatabase();
  8157. case 3:
  8158. o = _context4.sent.transaction([t], "readwrite").objectStore(t).put(e);
  8159. return _context4.abrupt("return", new Promise(function (a, s) {
  8160. o.onsuccess = function (l) {
  8161. a(l);
  8162. }, o.onerror = function (l) {
  8163. var u;
  8164. logger$1.error("db put error", (u = l.srcElement) == null ? void 0 : u.error), s(l);
  8165. };
  8166. }));
  8167. case 5:
  8168. case "end":
  8169. return _context4.stop();
  8170. }
  8171. }
  8172. }, _callee4, this);
  8173. }));
  8174. function put(_x3) {
  8175. return _put.apply(this, arguments);
  8176. }
  8177. return put;
  8178. }()
  8179. }, {
  8180. key: "delete",
  8181. value: function _delete(e, t, r) {
  8182. var n = this.tableName();
  8183. this.checkAndOpenDatabase().then(function (o) {
  8184. var s = o.transaction([n], "readwrite").objectStore(n).delete(e);
  8185. s.onsuccess = t, s.onerror = r;
  8186. });
  8187. }
  8188. }, {
  8189. key: "update",
  8190. value: function update() {
  8191. this.checkAndOpenDatabase().then(function (e) {});
  8192. }
  8193. }, {
  8194. key: "getAllKeys",
  8195. value: function () {
  8196. var _getAllKeys = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5() {
  8197. var e, t;
  8198. return regenerator.wrap(function _callee5$(_context5) {
  8199. while (1) {
  8200. switch (_context5.prev = _context5.next) {
  8201. case 0:
  8202. e = this.tableName();
  8203. _context5.next = 3;
  8204. return this.checkAndOpenDatabase();
  8205. case 3:
  8206. t = _context5.sent;
  8207. return _context5.abrupt("return", new Promise(function (r, n) {
  8208. var a = t.transaction([e], "readonly").objectStore(e).getAllKeys();
  8209. a.onsuccess = function (s) {
  8210. r(s.target.result);
  8211. }, a.onerror = function (s) {
  8212. logger$1.error("db getAllKeys error", s), n(s);
  8213. };
  8214. }));
  8215. case 5:
  8216. case "end":
  8217. return _context5.stop();
  8218. }
  8219. }
  8220. }, _callee5, this);
  8221. }));
  8222. function getAllKeys() {
  8223. return _getAllKeys.apply(this, arguments);
  8224. }
  8225. return getAllKeys;
  8226. }()
  8227. }, {
  8228. key: "query",
  8229. value: function () {
  8230. var _query = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e, t) {
  8231. var r, n;
  8232. return regenerator.wrap(function _callee6$(_context6) {
  8233. while (1) {
  8234. switch (_context6.prev = _context6.next) {
  8235. case 0:
  8236. r = this.tableName();
  8237. _context6.next = 3;
  8238. return this.checkAndOpenDatabase();
  8239. case 3:
  8240. n = _context6.sent;
  8241. return _context6.abrupt("return", new Promise(function (o, a) {
  8242. var u = n.transaction([r], "readonly").objectStore(r).index(e).get(t);
  8243. u.onsuccess = function (c) {
  8244. var f;
  8245. var h = (f = c == null ? void 0 : c.target) == null ? void 0 : f.result;
  8246. o && o(h);
  8247. }, u.onerror = function (c) {
  8248. logger$1.error("db query error", c), a(c);
  8249. };
  8250. }));
  8251. case 5:
  8252. case "end":
  8253. return _context6.stop();
  8254. }
  8255. }
  8256. }, _callee6, this);
  8257. }));
  8258. function query(_x4, _x5) {
  8259. return _query.apply(this, arguments);
  8260. }
  8261. return query;
  8262. }()
  8263. }, {
  8264. key: "sleep",
  8265. value: function () {
  8266. var _sleep = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7(e) {
  8267. return regenerator.wrap(function _callee7$(_context7) {
  8268. while (1) {
  8269. switch (_context7.prev = _context7.next) {
  8270. case 0:
  8271. return _context7.abrupt("return", new Promise(function (t) {
  8272. setTimeout(function () {
  8273. t("");
  8274. }, e);
  8275. }));
  8276. case 1:
  8277. case "end":
  8278. return _context7.stop();
  8279. }
  8280. }
  8281. }, _callee7);
  8282. }));
  8283. function sleep(_x6) {
  8284. return _sleep.apply(this, arguments);
  8285. }
  8286. return sleep;
  8287. }()
  8288. }]);
  8289. return BaseTable;
  8290. }();
  8291. 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); }; }
  8292. 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; } }
  8293. var ModelTable = /*#__PURE__*/function (_BaseTable) {
  8294. _inherits(ModelTable, _BaseTable);
  8295. var _super = _createSuper$7(ModelTable);
  8296. function ModelTable() {
  8297. _classCallCheck(this, ModelTable);
  8298. return _super.call(this, "XverseDatabase", 1);
  8299. }
  8300. _createClass(ModelTable, [{
  8301. key: "tableName",
  8302. value: function tableName() {
  8303. return "models";
  8304. }
  8305. }, {
  8306. key: "index",
  8307. value: function index() {
  8308. return ["url"];
  8309. }
  8310. }, {
  8311. key: "keyPath",
  8312. value: function keyPath() {
  8313. return "url";
  8314. }
  8315. }]);
  8316. return ModelTable;
  8317. }(BaseTable);
  8318. var modelTable = new ModelTable();
  8319. 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); }; }
  8320. 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; } }
  8321. var isIndexedDbSupported = function isIndexedDbSupported() {
  8322. return (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB) !== void 0;
  8323. };
  8324. var dataURItoBlob = function dataURItoBlob(i) {
  8325. var e;
  8326. i.split(",")[0].indexOf("base64") >= 0 ? e = atob(i.split(",")[1]) : e = unescape(i.split(",")[1]);
  8327. var t = i.split(",")[0].split(":")[1].split(";")[0],
  8328. r = new Uint8Array(e.length);
  8329. for (var o = 0; o < e.length; o++) {
  8330. r[o] = e.charCodeAt(o);
  8331. }
  8332. return new Blob([r], {
  8333. type: t
  8334. });
  8335. };
  8336. var Http = /*#__PURE__*/function (_EventEmitter) {
  8337. _inherits(Http, _EventEmitter);
  8338. var _super = _createSuper$6(Http);
  8339. function Http() {
  8340. _classCallCheck(this, Http);
  8341. return _super.apply(this, arguments);
  8342. }
  8343. _createClass(Http, [{
  8344. key: "get",
  8345. value: function () {
  8346. var _get = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref) {
  8347. var e, _ref$useIndexedDb, t, _ref$timeout, r, n, _ref$isOutPutObjectUR, o, a, s, l;
  8348. return regenerator.wrap(function _callee2$(_context2) {
  8349. while (1) {
  8350. switch (_context2.prev = _context2.next) {
  8351. case 0:
  8352. 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;
  8353. if (!(Xverse.NO_CACHE !== void 0 && (t = !Xverse.NO_CACHE), t)) {
  8354. _context2.next = 25;
  8355. break;
  8356. }
  8357. if (!isIndexedDbSupported()) {
  8358. _context2.next = 22;
  8359. break;
  8360. }
  8361. window.performance.now();
  8362. a = null;
  8363. _context2.prev = 5;
  8364. _context2.next = 8;
  8365. return modelTable.query("url", e);
  8366. case 8:
  8367. a = _context2.sent;
  8368. _context2.next = 14;
  8369. break;
  8370. case 11:
  8371. _context2.prev = 11;
  8372. _context2.t0 = _context2["catch"](5);
  8373. return _context2.abrupt("return", (logger$1.debug(_context2.t0), logger$1.warn("cache query error", e), Promise.resolve(e)));
  8374. case 14:
  8375. if (!(a && a.model)) {
  8376. _context2.next = 19;
  8377. break;
  8378. }
  8379. s = dataURItoBlob(a.model), l = Promise.resolve(o ? URL.createObjectURL(s) : s);
  8380. return _context2.abrupt("return", (window.performance.now(), l));
  8381. case 19:
  8382. return _context2.abrupt("return", this.request({
  8383. url: e,
  8384. timeout: r,
  8385. contentType: "blob",
  8386. key: n
  8387. }).then( /*#__PURE__*/function () {
  8388. var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(s) {
  8389. var l;
  8390. return regenerator.wrap(function _callee$(_context) {
  8391. while (1) {
  8392. switch (_context.prev = _context.next) {
  8393. case 0:
  8394. _context.next = 2;
  8395. return blobToDataURI(s.response);
  8396. case 2:
  8397. l = _context.sent;
  8398. _context.prev = 3;
  8399. _context.next = 6;
  8400. return modelTable.put({
  8401. url: e,
  8402. model: l
  8403. });
  8404. case 6:
  8405. _context.next = 11;
  8406. break;
  8407. case 8:
  8408. _context.prev = 8;
  8409. _context.t0 = _context["catch"](3);
  8410. logger$1.warn("unable to add data to indexedDB", _context.t0);
  8411. case 11:
  8412. return _context.abrupt("return", Promise.resolve(o ? URL.createObjectURL(s.response) : s.response));
  8413. case 12:
  8414. case "end":
  8415. return _context.stop();
  8416. }
  8417. }
  8418. }, _callee, null, [[3, 8]]);
  8419. }));
  8420. return function (_x2) {
  8421. return _ref2.apply(this, arguments);
  8422. };
  8423. }()));
  8424. case 20:
  8425. _context2.next = 23;
  8426. break;
  8427. case 22:
  8428. return _context2.abrupt("return", this.request({
  8429. url: e,
  8430. timeout: r,
  8431. contentType: "blob",
  8432. key: n
  8433. }).then(function (a) {
  8434. var s = a.response;
  8435. return Promise.resolve(o ? URL.createObjectURL(s) : s);
  8436. }).catch(function (a) {
  8437. return Promise.reject(a);
  8438. }));
  8439. case 23:
  8440. _context2.next = 26;
  8441. break;
  8442. case 25:
  8443. return _context2.abrupt("return", this.request({
  8444. url: e,
  8445. timeout: r,
  8446. key: n
  8447. }).then(function (a) {
  8448. return a.getResponseHeader("content-type") === "application/json" ? Promise.resolve(JSON.parse(a.responseText)) : Promise.resolve(a.responseText);
  8449. }));
  8450. case 26:
  8451. case "end":
  8452. return _context2.stop();
  8453. }
  8454. }
  8455. }, _callee2, this, [[5, 11]]);
  8456. }));
  8457. function get(_x) {
  8458. return _get.apply(this, arguments);
  8459. }
  8460. return get;
  8461. }()
  8462. }, {
  8463. key: "request",
  8464. value: function request(e) {
  8465. var _this = this;
  8466. var _e$timeout = e.timeout,
  8467. t = _e$timeout === void 0 ? 3e4 : _e$timeout,
  8468. r = e.contentType;
  8469. e.key;
  8470. var o = e.onRequestStart,
  8471. a = e.url;
  8472. return new Promise(function (s, l) {
  8473. window.performance.now();
  8474. var u = new XMLHttpRequest();
  8475. r && (u.responseType = r), u.timeout = t, u.addEventListener("readystatechange", function () {
  8476. if (u.readyState == 4) {
  8477. if (u.status == 200) return window.performance.now(), _this.emit("loadend", {
  8478. message: "request ".concat(a, " load success")
  8479. }), s(u);
  8480. {
  8481. var c = "Unable to load the request ".concat(a);
  8482. return _this.emit("error", {
  8483. message: c
  8484. }), logger$1.error(c), l(c);
  8485. }
  8486. }
  8487. }), o && o(u), u.open("GET", a), u.send();
  8488. });
  8489. }
  8490. }]);
  8491. return Http;
  8492. }(EventEmitter); // const http = new Http();
  8493. var Logger1 = /*#__PURE__*/function () {
  8494. function Logger1(e) {
  8495. _classCallCheck(this, Logger1);
  8496. E(this, "module");
  8497. this.module = e;
  8498. }
  8499. _createClass(Logger1, [{
  8500. key: "debug",
  8501. value: function debug() {
  8502. var _Logger1$instance;
  8503. return (_Logger1$instance = Logger1.instance).debug.apply(_Logger1$instance, arguments);
  8504. }
  8505. }, {
  8506. key: "info",
  8507. value: function info() {
  8508. var _Logger1$instance2;
  8509. return (_Logger1$instance2 = Logger1.instance).info.apply(_Logger1$instance2, arguments);
  8510. }
  8511. }, {
  8512. key: "warn",
  8513. value: function warn() {
  8514. var _Logger1$instance3;
  8515. return (_Logger1$instance3 = Logger1.instance).warn.apply(_Logger1$instance3, arguments);
  8516. }
  8517. }, {
  8518. key: "error",
  8519. value: function error() {
  8520. var _Logger1$instance4;
  8521. return (_Logger1$instance4 = Logger1.instance).error.apply(_Logger1$instance4, arguments);
  8522. }
  8523. }], [{
  8524. key: "setLogger",
  8525. value: function setLogger(e) {
  8526. Logger1.instance = e;
  8527. }
  8528. }]);
  8529. return Logger1;
  8530. }();
  8531. var XCameraComponent = /*#__PURE__*/function () {
  8532. function XCameraComponent(e, t, r) {
  8533. var _this = this;
  8534. _classCallCheck(this, XCameraComponent);
  8535. E(this, "maincameraRotLimitObserver", null);
  8536. E(this, "mainCamera");
  8537. E(this, "cgCamera");
  8538. E(this, "saveCameraPose");
  8539. E(this, "_cameraPose");
  8540. E(this, "scene");
  8541. E(this, "canvas");
  8542. E(this, "yuvInfo");
  8543. E(this, "forceKeepVertical", !1);
  8544. E(this, "initCamera", function (e) {
  8545. var _e$maxZ = e.maxZ,
  8546. t = _e$maxZ === void 0 ? 1e4 : _e$maxZ,
  8547. _e$minZ = e.minZ,
  8548. r = _e$minZ === void 0 ? .1 : _e$minZ,
  8549. _e$angularSensibility = e.angularSensibility,
  8550. n = _e$angularSensibility === void 0 ? 2e3 : _e$angularSensibility;
  8551. _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);
  8552. });
  8553. E(this, "cameraFovChange", function (e) {
  8554. _this.yuvInfo = e;
  8555. var t = e.width,
  8556. r = e.height,
  8557. n = _this.canvas.width,
  8558. o = _this.canvas.height,
  8559. a = e.fov;
  8560. if (_this.forceKeepVertical == !0) {
  8561. var s = t / (2 * Math.tan(Math.PI * a / 360)),
  8562. l = 2 * Math.atan(r / (2 * s));
  8563. _this.mainCamera.fov = l, _this.cgCamera.fov = l, _this.mainCamera.fovMode = BABYLON.Camera.FOVMODE_VERTICAL_FIXED, _this.cgCamera.fovMode = BABYLON.Camera.FOVMODE_VERTICAL_FIXED;
  8564. } 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) {
  8565. var _s = o,
  8566. _l = n,
  8567. u = _s * t / r / (2 * Math.tan(a * Math.PI / 360)),
  8568. c = 2 * Math.atan(_l / (2 * u));
  8569. _this.mainCamera.fov = c, _this.cgCamera.fov = c;
  8570. } else _this.mainCamera.fov = Math.PI * a / 180, _this.cgCamera.fov = Math.PI * a / 180;
  8571. });
  8572. E(this, "setCameraPose", function (e) {
  8573. var n;
  8574. var t = ue4Position2Xverse(e.position);
  8575. var r = null;
  8576. e.rotation != null && (r = ue4Rotation2Xverse(e.rotation)), _this._cameraPose = {
  8577. position: t
  8578. }, r != null && (_this._cameraPose.rotation = r), _this.scene.activeCamera === _this.mainCamera && !((n = _this.mainCamera) != null && n.isDisposed()) && _this._setCamPositionRotation(_this.mainCamera, _this._cameraPose);
  8579. });
  8580. E(this, "_setCamPositionRotation", function (e, t) {
  8581. var r, n;
  8582. t.position && (e.position = (r = t.position) == null ? void 0 : r.clone()), t.rotation && (e.rotation = (n = t.rotation) == null ? void 0 : n.clone());
  8583. });
  8584. E(this, "switchCamera", function (e) {
  8585. var t;
  8586. (t = _this.scene.activeCamera) == null || t.detachControl(_this.canvas), _this.scene.activeCamera = e;
  8587. });
  8588. E(this, "reCalXYZRot", function (e, t) {
  8589. return e = e % (2 * Math.PI), Math.abs(t - e) >= Math.PI && (e = e - 2 * Math.PI), e;
  8590. });
  8591. E(this, "_moveCam", function (e, t, r, n, o, a, s, l) {
  8592. var u = function u(v, y, b) {
  8593. 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);
  8594. },
  8595. c = function c(v, y, b) {
  8596. 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);
  8597. },
  8598. h = new Animation("myAnimation1", "position", s, Animation.ANIMATIONTYPE_VECTOR3, Animation.ANIMATIONLOOPMODE_CONSTANT);
  8599. var f = [],
  8600. d = t,
  8601. _ = r;
  8602. for (var v = 0; v < a; ++v) {
  8603. f.push({
  8604. frame: v,
  8605. value: c(d, _, v / a)
  8606. });
  8607. }
  8608. f.push({
  8609. frame: f.length,
  8610. value: c(d, _, 1)
  8611. }), h.setKeys(f);
  8612. var g = new Animation("myAnimation2", "rotation", s, Animation.ANIMATIONTYPE_VECTOR3, Animation.ANIMATIONLOOPMODE_CONSTANT);
  8613. f = [], d = n, _ = o;
  8614. for (var _v = 0; _v < a; ++_v) {
  8615. f.push({
  8616. frame: _v,
  8617. value: u(d, _, _v / a)
  8618. });
  8619. }
  8620. f.push({
  8621. frame: f.length,
  8622. value: u(d, _, 1)
  8623. }), g.setKeys(f), e.animations.push(g), e.animations.push(h);
  8624. var m = _this.scene.beginAnimation(e, 0, a, !1);
  8625. m.onAnimationEnd = function () {
  8626. l(), m.stop(), m.animationStarted = !1;
  8627. };
  8628. });
  8629. this.scene = t, this.canvas = e, this.yuvInfo = r.yuvInfo, r.forceKeepVertical != null && (this.forceKeepVertical = r.forceKeepVertical), this.initCamera(r.cameraParam);
  8630. }
  8631. _createClass(XCameraComponent, [{
  8632. key: "MainCamera",
  8633. get: function get() {
  8634. return this.mainCamera;
  8635. }
  8636. }, {
  8637. key: "CgCamera",
  8638. get: function get() {
  8639. return this.cgCamera;
  8640. }
  8641. }, {
  8642. key: "getCameraHorizonFov",
  8643. value: function getCameraHorizonFov() {
  8644. return this.mainCamera.fovMode == BABYLON.Camera.FOVMODE_HORIZONTAL_FIXED ? this.mainCamera.fov : Math.PI * this.yuvInfo.fov / 180;
  8645. }
  8646. }, {
  8647. key: "changeMainCameraRotationDamping",
  8648. value: function changeMainCameraRotationDamping() {
  8649. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2e3;
  8650. this.mainCamera.angularSensibility = e;
  8651. }
  8652. }, {
  8653. key: "removeMainCameraRotationLimit",
  8654. value: function removeMainCameraRotationLimit() {
  8655. this.maincameraRotLimitObserver != null && this.mainCamera.onAfterCheckInputsObservable.remove(this.maincameraRotLimitObserver);
  8656. }
  8657. }, {
  8658. key: "setMainCameraInfo",
  8659. value: function setMainCameraInfo(e) {
  8660. var _e$maxZ2 = e.maxZ,
  8661. t = _e$maxZ2 === void 0 ? 1e4 : _e$maxZ2,
  8662. _e$minZ2 = e.minZ,
  8663. r = _e$minZ2 === void 0 ? .1 : _e$minZ2,
  8664. _e$angularSensibility2 = e.angularSensibility,
  8665. n = _e$angularSensibility2 === void 0 ? 2e3 : _e$angularSensibility2;
  8666. this.mainCamera.maxZ = t, this.mainCamera.minZ = r, this.mainCamera.angularSensibility = n;
  8667. }
  8668. }, {
  8669. key: "getMainCameraInfo",
  8670. value: function getMainCameraInfo() {
  8671. return {
  8672. maxZ: this.mainCamera.maxZ,
  8673. minZ: this.mainCamera.minZ,
  8674. angularSensibility: this.mainCamera.angularSensibility
  8675. };
  8676. }
  8677. }, {
  8678. key: "_limitAngle",
  8679. value: function _limitAngle(e, t) {
  8680. 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;
  8681. }
  8682. }, {
  8683. key: "setMainCameraRotationLimit",
  8684. value: function setMainCameraRotationLimit(e, t) {
  8685. var _this2 = this;
  8686. this.maincameraRotLimitObserver != null && this.removeMainCameraRotationLimit();
  8687. var r = this.mainCamera,
  8688. n = e.yaw,
  8689. o = e.pitch,
  8690. a = e.roll,
  8691. s = t.yaw,
  8692. l = t.pitch,
  8693. u = t.roll;
  8694. if (s < 0 || l < 0 || u < 0) throw new Error("\u76F8\u673A\u65CB\u8F6C\u9650\u5236\u53EA\u80FD\u8BBE\u7F6E\u4E3A\u5927\u4E8E0");
  8695. var c = [o - l, o + l],
  8696. h = [n - s, n + s],
  8697. f = [a - u, a + u];
  8698. this.maincameraRotLimitObserver = r.onAfterCheckInputsObservable.add(function () {
  8699. var _xverseRotation2Ue = xverseRotation2Ue4(r.rotation),
  8700. d = _xverseRotation2Ue.pitch,
  8701. _ = _xverseRotation2Ue.yaw,
  8702. g = _xverseRotation2Ue.roll;
  8703. d = _this2._limitAngle(d, c), _ = _this2._limitAngle(_, h), g = _this2._limitAngle(g, f), r.rotation = ue4Rotation2Xverse({
  8704. pitch: d,
  8705. yaw: _,
  8706. roll: g
  8707. });
  8708. });
  8709. }
  8710. }, {
  8711. key: "setMainCameraRotationLimitByAnchor",
  8712. value: function setMainCameraRotationLimitByAnchor(e, t, r) {
  8713. this.maincameraRotLimitObserver != null && this.removeMainCameraRotationLimit();
  8714. var n = this.mainCamera,
  8715. o = ue4Rotation2Xverse_mesh(t),
  8716. a = ue4Rotation2Xverse_mesh(r);
  8717. a != null && o != null && e.mesh != null && (this.maincameraRotLimitObserver = n.onAfterCheckInputsObservable.add(function () {
  8718. var s = e.mesh.rotation;
  8719. 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));
  8720. }));
  8721. }
  8722. }, {
  8723. key: "getCameraPose",
  8724. value: function getCameraPose() {
  8725. var e = xversePosition2Ue4({
  8726. x: this.mainCamera.position.x,
  8727. y: this.mainCamera.position.y,
  8728. z: this.mainCamera.position.z
  8729. }),
  8730. t = xverseRotation2Ue4({
  8731. x: this.mainCamera.rotation.x,
  8732. y: this.mainCamera.rotation.y,
  8733. z: this.mainCamera.rotation.z
  8734. });
  8735. return {
  8736. position: e,
  8737. rotation: t
  8738. };
  8739. }
  8740. }, {
  8741. key: "changeCameraFov",
  8742. value: function changeCameraFov(e, t) {
  8743. this.mainCamera.fov = e, t != null && (this.mainCamera.fovMode = t == 0 ? BABYLON.Camera.FOVMODE_HORIZONTAL_FIXED : BABYLON.Camera.FOVMODE_VERTICAL_FIXED);
  8744. }
  8745. }, {
  8746. key: "controlCameraRotation",
  8747. value: function controlCameraRotation(e, t) {
  8748. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : .5;
  8749. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : .5;
  8750. var o = {
  8751. pitch: n * t * 180,
  8752. yaw: r * e * 180,
  8753. roll: 0
  8754. };
  8755. this.addRot(o);
  8756. }
  8757. }, {
  8758. key: "addRot",
  8759. value: function addRot(e) {
  8760. var t = this.mainCamera,
  8761. r = ue4Rotation2Xverse_mesh(e);
  8762. r != null && t.rotation.addInPlace(r);
  8763. }
  8764. }, {
  8765. key: "getCameraFov",
  8766. value: function getCameraFov() {
  8767. return this.mainCamera.fov;
  8768. }
  8769. }, {
  8770. key: "allowMainCameraController",
  8771. value: function allowMainCameraController() {
  8772. this.mainCamera.attachControl(this.canvas, !0);
  8773. }
  8774. }, {
  8775. key: "detachMainCameraController",
  8776. value: function detachMainCameraController() {
  8777. this.mainCamera.detachControl(this.canvas);
  8778. }
  8779. }, {
  8780. key: "forceChangeSavedCameraPose",
  8781. value: function forceChangeSavedCameraPose(e) {
  8782. this.saveCameraPose != null && (e.position != null && (this.saveCameraPose.position = ue4Position2Xverse(e.position)), e.rotation != null && (this.saveCameraPose.rotation = ue4Rotation2Xverse(e.rotation)));
  8783. }
  8784. }, {
  8785. key: "changeToFirstPersonView",
  8786. value: function changeToFirstPersonView(e) {
  8787. this.saveCameraPose = {
  8788. position: this.mainCamera.position.clone(),
  8789. rotation: this.mainCamera.rotation.clone()
  8790. }, this.mainCamera.attachControl(this.canvas, !0), e.position != null && (this.mainCamera.position = ue4Position2Xverse(e.position)), e.rotation != null && (this.mainCamera.rotation = ue4Rotation2Xverse(e.rotation));
  8791. }
  8792. }, {
  8793. key: "changeToThirdPersonView",
  8794. value: function changeToThirdPersonView() {
  8795. 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));
  8796. }
  8797. }, {
  8798. key: "switchToMainCamera",
  8799. value: function switchToMainCamera() {
  8800. this.switchCamera(this.mainCamera);
  8801. }
  8802. }, {
  8803. key: "switchToCgCamera",
  8804. value: function switchToCgCamera() {
  8805. this.switchCamera(this.cgCamera);
  8806. }
  8807. }, {
  8808. key: "moveMainCamera",
  8809. value: function moveMainCamera(e, t, r, n, o) {
  8810. this._moveCam(this.mainCamera, this.mainCamera.position, e, this.mainCamera.rotation, t, r, n, o);
  8811. }
  8812. }]);
  8813. return XCameraComponent;
  8814. }();
  8815. var EMeshType = {
  8816. XAvatar: 'XAvatar',
  8817. XStaticMesh: 'XStaticMesh',
  8818. XBreathPoint: 'breathpoint',
  8819. Decal: 'decal',
  8820. Cgplane: 'cgplane',
  8821. Tv: 'tv',
  8822. XSubSequence: 'XSubSequence',
  8823. XBillboard: 'XBillboard'
  8824. };
  8825. var XStaticMesh = /*#__PURE__*/function () {
  8826. function XStaticMesh(_ref) {
  8827. var _this = this;
  8828. var e = _ref.id,
  8829. t = _ref.mesh,
  8830. _ref$group = _ref.group,
  8831. r = _ref$group === void 0 ? "default" : _ref$group,
  8832. _ref$lod = _ref.lod,
  8833. n = _ref$lod === void 0 ? 0 : _ref$lod,
  8834. _ref$xtype = _ref.xtype,
  8835. o = _ref$xtype === void 0 ? EMeshType.XStaticMesh : _ref$xtype,
  8836. _ref$skinInfo = _ref.skinInfo,
  8837. a = _ref$skinInfo === void 0 ? "default" : _ref$skinInfo,
  8838. _ref$url = _ref.url,
  8839. s = _ref$url === void 0 ? "" : _ref$url;
  8840. _classCallCheck(this, XStaticMesh);
  8841. E(this, "_mesh");
  8842. E(this, "_id", "-1");
  8843. E(this, "_group");
  8844. E(this, "_lod");
  8845. E(this, "_isMoving", !1);
  8846. E(this, "_isRotating", !1);
  8847. E(this, "_isVisible", !0);
  8848. E(this, "_skinInfo");
  8849. E(this, "setVisibility", function (e, t) {
  8850. Array.isArray(e) ? e.forEach(function (r) {
  8851. _this.setVisibility(r, t);
  8852. }) : e.isAnInstance || (e.visibility = t);
  8853. });
  8854. E(this, "setPickable", function (e, t) {
  8855. Array.isArray(e) ? e.forEach(function (r) {
  8856. _this.setPickable(r, t);
  8857. }) : ("isPickable" in e && (e.isPickable = t), e.setEnabled(t));
  8858. });
  8859. E(this, "hide", function () {
  8860. var e;
  8861. _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) {
  8862. _this.setVisibility(t, 0), _this.setPickable(t, !1);
  8863. });
  8864. });
  8865. E(this, "show", function () {
  8866. var e;
  8867. _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) {
  8868. _this.setVisibility(t, 1), _this.setPickable(t, !0);
  8869. });
  8870. });
  8871. E(this, "attachToAvatar", function (e) {
  8872. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
  8873. x: 0,
  8874. y: .5,
  8875. z: 0
  8876. };
  8877. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
  8878. yaw: 0,
  8879. pitch: 0,
  8880. roll: 0
  8881. };
  8882. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
  8883. x: .35,
  8884. y: .35,
  8885. z: .35
  8886. };
  8887. var o = ue4Scaling2Xverse(n),
  8888. a = ue4Rotation2Xverse(r),
  8889. s = ue4Position2Xverse(t),
  8890. l = _this._mesh;
  8891. e && l ? (e.setParent(l), e.position = s, e.rotation = a, e.scaling = o) : logger$1.error("[Engine] avatar or attachment not found!");
  8892. });
  8893. E(this, "detachFromAvatar", function (e) {
  8894. _this._mesh && e ? _this._mesh.removeChild(e) : logger$1.error("[Engine] avatar not found!");
  8895. });
  8896. 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;
  8897. }
  8898. _createClass(XStaticMesh, [{
  8899. key: "mesh",
  8900. get: function get() {
  8901. return this._mesh;
  8902. }
  8903. }, {
  8904. key: "position",
  8905. get: function get() {
  8906. var o;
  8907. if (!this._mesh) return null;
  8908. var _ref2 = (o = this._mesh) == null ? void 0 : o.position,
  8909. e = _ref2.x,
  8910. t = _ref2.y,
  8911. r = _ref2.z;
  8912. return xversePosition2Ue4({
  8913. x: e,
  8914. y: t,
  8915. z: r
  8916. });
  8917. }
  8918. }, {
  8919. key: "id",
  8920. get: function get() {
  8921. return this._id;
  8922. }
  8923. }, {
  8924. key: "group",
  8925. get: function get() {
  8926. return this._group;
  8927. }
  8928. }, {
  8929. key: "isMoving",
  8930. get: function get() {
  8931. return this._isMoving;
  8932. }
  8933. }, {
  8934. key: "isVisible",
  8935. get: function get() {
  8936. return this._isVisible;
  8937. }
  8938. }, {
  8939. key: "isRotating",
  8940. get: function get() {
  8941. return this._isRotating;
  8942. }
  8943. }, {
  8944. key: "skinInfo",
  8945. get: function get() {
  8946. return this._skinInfo;
  8947. }
  8948. }, {
  8949. key: "allowMove",
  8950. value: function allowMove() {
  8951. this._mesh != null && (this._mesh.getChildMeshes().forEach(function (e) {
  8952. e.unfreezeWorldMatrix();
  8953. }), this._mesh.unfreezeWorldMatrix());
  8954. }
  8955. }, {
  8956. key: "unallowMove",
  8957. value: function unallowMove() {
  8958. this._mesh != null && (this._mesh.getChildMeshes().forEach(function (e) {
  8959. e.freezeWorldMatrix();
  8960. }), this._mesh.freezeWorldMatrix());
  8961. }
  8962. }, {
  8963. key: "getID",
  8964. value: function getID() {
  8965. return this._id;
  8966. }
  8967. }, {
  8968. key: "setPosition",
  8969. value: function setPosition(e) {
  8970. if (this._mesh) {
  8971. var t = ue4Position2Xverse(e);
  8972. this._mesh.position = t;
  8973. } else logger$1.error("[Engine] no root for positioning");
  8974. }
  8975. }, {
  8976. key: "setRotation",
  8977. value: function setRotation(e) {
  8978. var t = ue4Rotation2Xverse_mesh(e);
  8979. this._mesh ? this._mesh.rotation = t : logger$1.error("[Engine] no root for rotating");
  8980. }
  8981. }, {
  8982. key: "setScale",
  8983. value: function setScale(e) {
  8984. this._mesh ? this._mesh.scaling = new BABYLON.Vector3(e, e, -e) : logger$1.error("[Engine] no root for scaling");
  8985. }
  8986. }, {
  8987. key: "disableAvatar",
  8988. value: function disableAvatar() {
  8989. var e;
  8990. (e = this._mesh) == null || e.setEnabled(!1);
  8991. }
  8992. }, {
  8993. key: "enableAvatar",
  8994. value: function enableAvatar() {
  8995. var e;
  8996. (e = this._mesh) == null || e.setEnabled(!0);
  8997. }
  8998. }, {
  8999. key: "togglePickable",
  9000. value: function togglePickable(e) {
  9001. var t;
  9002. (t = this.mesh) == null || t.getChildMeshes().forEach(function (r) {
  9003. "instances" in r && "isPickable" in r && (r.isPickable = e);
  9004. }), this.mesh != null && "isPickable" in this.mesh && (this.mesh.isPickable = e);
  9005. }
  9006. }, {
  9007. key: "setMaterial",
  9008. value: function setMaterial(e) {
  9009. var t;
  9010. (t = this.mesh) == null || t.getChildMeshes().forEach(function (r) {
  9011. "instances" in r && "material" in r && (r.material = e);
  9012. }), this.mesh != null && "material" in this.mesh && (this.mesh.material = e);
  9013. }
  9014. }, {
  9015. key: "dispose",
  9016. value: function dispose() {
  9017. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !1;
  9018. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
  9019. !this.mesh.isDisposed() && this.mesh.dispose(e, t);
  9020. }
  9021. }]);
  9022. return XStaticMesh;
  9023. }();
  9024. 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); }; }
  9025. 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; } }
  9026. var XLowpolyModelError = /*#__PURE__*/function (_XverseError) {
  9027. _inherits(XLowpolyModelError, _XverseError);
  9028. var _super = _createSuper$5(XLowpolyModelError);
  9029. function XLowpolyModelError(e) {
  9030. _classCallCheck(this, XLowpolyModelError);
  9031. return _super.call(this, 5204, e || "[Engine] \u4F20\u5165\u6A21\u578Burl\u9519\u8BEF");
  9032. }
  9033. return _createClass(XLowpolyModelError);
  9034. }(XverseError);
  9035. var XStaticMeshFromOneGltf = /*#__PURE__*/function () {
  9036. function XStaticMeshFromOneGltf(e, t) {
  9037. var _this = this;
  9038. _classCallCheck(this, XStaticMeshFromOneGltf);
  9039. E(this, "_scene");
  9040. E(this, "_url");
  9041. E(this, "_group");
  9042. E(this, "_pickable");
  9043. E(this, "_meshes");
  9044. E(this, "_id");
  9045. E(this, "_lod");
  9046. E(this, "_groupUuid");
  9047. E(this, "_isInScene");
  9048. E(this, "_skinInfo");
  9049. E(this, "loadMesh", function (e, t) {
  9050. var r = _this._meshes.length,
  9051. n = t ? 1 : 0,
  9052. o = _this._url;
  9053. return BABYLON.SceneLoader.LoadAssetContainerAsync("", o, _this._scene, function () {
  9054. _this._scene.blockMaterialDirtyMechanism = !0;
  9055. }, ".glb").then(function (a) {
  9056. for (var s = a.materials.length - 1; s >= 0; --s) {
  9057. a.materials[s].dispose();
  9058. }
  9059. _this._scene.blockMaterialDirtyMechanism = !0;
  9060. for (var _s = 0; _s < a.meshes.length; ++_s) {
  9061. var l = a.meshes[_s];
  9062. if ("instances" in l) {
  9063. "visibility" in l && (l.visibility = 0), "isPickable" in l && (l.isPickable = _this._pickable), e != null && (l.material = e), "hasVertexAlpha" in l && (l.hasVertexAlpha = !1);
  9064. var u = new XStaticMesh({
  9065. id: _this._groupUuid + "-" + Math.random().toString(36).substr(2, 5),
  9066. mesh: l,
  9067. lod: _this._lod,
  9068. group: _this._group,
  9069. url: _this._url,
  9070. xtype: EMeshType.XStaticMesh,
  9071. skinInfo: _this._skinInfo
  9072. });
  9073. _this._meshes.push(u);
  9074. }
  9075. _this._scene.addMesh(l);
  9076. }
  9077. return !0;
  9078. }).then(function () {
  9079. _this._isInScene = !0;
  9080. for (var a = r; a < _this._meshes.length; ++a) {
  9081. _this._meshes[a].mesh.visibility = n;
  9082. }
  9083. return Promise.resolve(!0);
  9084. }).catch(function (a) {
  9085. logger$1.error("[Engine] input gltf mesh uri error! " + a), Promise.reject(new XLowpolyModelError("[Engine] input gltf mesh uri error! " + a));
  9086. });
  9087. });
  9088. 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;
  9089. }
  9090. _createClass(XStaticMeshFromOneGltf, [{
  9091. key: "isinscene",
  9092. get: function get() {
  9093. return this._isInScene;
  9094. }
  9095. }, {
  9096. key: "groupUuid",
  9097. get: function get() {
  9098. return this._groupUuid;
  9099. }
  9100. }, {
  9101. key: "skinInfo",
  9102. get: function get() {
  9103. return this._skinInfo;
  9104. }
  9105. }, {
  9106. key: "group",
  9107. get: function get() {
  9108. return this._group;
  9109. }
  9110. }, {
  9111. key: "meshes",
  9112. get: function get() {
  9113. return this._meshes;
  9114. }
  9115. }, {
  9116. key: "url",
  9117. get: function get() {
  9118. return this._url;
  9119. }
  9120. }, {
  9121. key: "id",
  9122. get: function get() {
  9123. return this._id;
  9124. }
  9125. }, {
  9126. key: "lod",
  9127. get: function get() {
  9128. return this._lod;
  9129. }
  9130. }, {
  9131. key: "removeFromScene",
  9132. value: function removeFromScene() {
  9133. if (this._isInScene) {
  9134. this._isInScene = !1;
  9135. for (var e = 0, t = this._meshes.length; e < t; ++e) {
  9136. this._meshes[e].mesh != null && this._scene.removeMesh(this._meshes[e].mesh);
  9137. }
  9138. }
  9139. }
  9140. }, {
  9141. key: "addToScene",
  9142. value: function addToScene() {
  9143. if (this._isInScene == !1) {
  9144. this._isInScene = !0;
  9145. for (var e = 0, t = this._meshes.length; e < t; ++e) {
  9146. this._meshes[e].mesh != null && this._scene.addMesh(this._meshes[e].mesh);
  9147. }
  9148. }
  9149. }
  9150. }, {
  9151. key: "toggleVisibility",
  9152. value: function toggleVisibility(e) {
  9153. var t = e ? 1 : 0;
  9154. for (var r = 0, n = this._meshes.length; r < n; ++r) {
  9155. "visibility" in this._meshes[r].mesh && (this._meshes[r].mesh.visibility = t);
  9156. }
  9157. }
  9158. }, {
  9159. key: "togglePickable",
  9160. value: function togglePickable(e) {
  9161. for (var t = 0, r = this._meshes.length; t < r; ++t) {
  9162. "isPickable" in this._meshes[t].mesh && (this._meshes[t].mesh.isPickable = e);
  9163. }
  9164. }
  9165. }, {
  9166. key: "setMaterial",
  9167. value: function setMaterial(e) {
  9168. for (var t = 0, r = this._meshes.length; t < r; ++t) {
  9169. "material" in this._meshes[t].mesh && (this._meshes[t].mesh.material = e);
  9170. }
  9171. }
  9172. }, {
  9173. key: "dispose",
  9174. value: function dispose() {
  9175. for (var e = 0, t = this._meshes.length; e < t; ++e) {
  9176. this._meshes[e].mesh.dispose(!1, !1);
  9177. }
  9178. }
  9179. }]);
  9180. return XStaticMeshFromOneGltf;
  9181. }();
  9182. var XStaticMeshComponent = /*#__PURE__*/function () {
  9183. function XStaticMeshComponent(e) {
  9184. var _this = this;
  9185. _classCallCheck(this, XStaticMeshComponent);
  9186. E(this, "scene");
  9187. E(this, "_staticmeshes");
  9188. E(this, "_lowModel_group");
  9189. E(this, "_CgPlane");
  9190. E(this, "_rootDir");
  9191. E(this, "_abosoluteUrl");
  9192. E(this, "_partMeshSkinInfo");
  9193. E(this, "_meshInfoJson");
  9194. E(this, "_orijson");
  9195. E(this, "_notUsedRegionLists");
  9196. E(this, "_meshInfoKeys");
  9197. E(this, "_currentUpdateRegionCount");
  9198. E(this, "_currentMeshUsedLod");
  9199. E(this, "_currentPartGroup");
  9200. E(this, "_allowRegionUpdate");
  9201. E(this, "_allowRegionForceLod");
  9202. E(this, "_forceLod");
  9203. E(this, "_scenemanager");
  9204. E(this, "regionIdInCamera");
  9205. E(this, "regionIdInCameraConst");
  9206. E(this, "_cameraInRegionId");
  9207. E(this, "_meshVis");
  9208. E(this, "_doMeshVisChangeNumber");
  9209. E(this, "_meshVisTypeName");
  9210. E(this, "_visCheckDurationFrameNumber");
  9211. E(this, "_regionLodRule");
  9212. E(this, "reg_staticmesh_partupdate", function () {
  9213. if (_this._allowRegionUpdate && (_this.scene.getFrameId(), _this._meshUpdateFrame()), _this._allowRegionForceLod) {
  9214. _this.scene.getFrameId() % 2 == 0 && _this.setOneRegionLod(_this._meshInfoKeys[_this._currentUpdateRegionCount % _this._meshInfoKeys.length].toString(), _this._forceLod);
  9215. var t = !0;
  9216. var r = Array.from(_this._currentMeshUsedLod.keys());
  9217. if (r.length > 0) {
  9218. for (var n = 0; n < r.length; ++n) {
  9219. _this._currentMeshUsedLod.get(r[n]) != _this._forceLod && (t = !1);
  9220. }
  9221. t && (_this._allowRegionForceLod = !1);
  9222. }
  9223. }
  9224. });
  9225. E(this, "setMeshInfo", function (e) {
  9226. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
  9227. _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 () {
  9228. _this.startMeshUpdate();
  9229. }));
  9230. });
  9231. E(this, "_meshUpdateFrame", function () {
  9232. {
  9233. var _e = _this._meshInfoKeys[_this._currentUpdateRegionCount % _this._meshInfoKeys.length];
  9234. var t = !0;
  9235. var r = 3;
  9236. if (_this._scenemanager != null && _this._scenemanager.cameraComponent != null) {
  9237. var n = _this._getMainPlayerPosition();
  9238. if (n != null) {
  9239. if (_this._cameraInRegionId >= 0) {
  9240. var a = _this.getRegionIdWhichIncludeCamera(n);
  9241. (_this._cameraInRegionId != a || _this.regionIdInCamera.length == 0) && (_this._cameraInRegionId = a, _this.regionIdInCamera = _this._getNeighborId(_this._cameraInRegionId.toString()), _this.regionIdInCameraConst = _this.regionIdInCamera.slice());
  9242. var s = _this.regionIdInCamera.pop();
  9243. for (; s != null;) {
  9244. if (_this._notUsedRegionLists.indexOf(s) >= 0) s = _this.regionIdInCamera.pop();else break;
  9245. }
  9246. s != null && (_e = s.toString());
  9247. } else _this._cameraInRegionId = _this.getRegionIdWhichIncludeCamera(n);
  9248. if (_this._currentMeshUsedLod.size == 0 || _this._notUsedRegionLists.indexOf(parseInt(_e)) >= 0) {
  9249. _e = _this._cameraInRegionId.toString();
  9250. var _a = _this._getNeighborId(_e);
  9251. for (; _a.length == 0 && (_e = _this.getNearestRegionIdWithCamera(n).toString()), _this._notUsedRegionLists.indexOf(parseInt(_e)) >= 0;) {
  9252. _e = _a.pop().toString();
  9253. }
  9254. }
  9255. var o = _this._meshInfoJson[_this._cameraInRegionId.toString()].lod;
  9256. 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];
  9257. }
  9258. }
  9259. _this.setOneRegionLod(_e, r, t), _this.updateRegionNotInLocalNeighbor(), _this.cleanRootNodes();
  9260. }
  9261. });
  9262. E(this, "updateRegionNotInLocalNeighbor", function () {
  9263. Array.from(_this._currentMeshUsedLod.keys()).forEach(function (t) {
  9264. _this.regionIdInCameraConst.indexOf(parseInt(t)) < 0 && _this.setOneRegionLod(t, -1);
  9265. });
  9266. });
  9267. E(this, "cleanRootNodes", function () {
  9268. if (_this.scene.getFrameId() % 3 == 0) {
  9269. var _e2 = [];
  9270. _this.scene.rootNodes.forEach(function (t) {
  9271. (t.getClassName() == "TransformNode" && t.getChildren().length == 0 || t.getClassName() == "Mesh" && t.name == "__root__" && t.getChildren().length == 0) && _e2.push(t);
  9272. }), _e2.forEach(function (t) {
  9273. t.dispose();
  9274. });
  9275. }
  9276. });
  9277. E(this, "setOneRegionLod", function (e, t) {
  9278. _this._currentUpdateRegionCount++;
  9279. var n = _this._calHashCode(_this._rootDir),
  9280. o = "region_" + n + "_" + e;
  9281. if (t < 0) {
  9282. _this._currentMeshUsedLod.has(e) && (_this._currentMeshUsedLod.delete(e), _this._currentPartGroup.delete(o), _this.deleteMeshesByCustomProperty("group", "region_" + n + "_" + e));
  9283. return;
  9284. }
  9285. var a = _this._rootDir + e + "_lod" + t + "_xverse.glb",
  9286. s = _this._currentMeshUsedLod.get(e);
  9287. _this._currentPartGroup.add(o), s != null ? s != t && (_this._currentMeshUsedLod.set(e, t), _this._scenemanager.addNewLowPolyMesh({
  9288. url: a,
  9289. group: "region_" + n + "_" + e,
  9290. pick: !0,
  9291. lod: t,
  9292. skinInfo: _this._partMeshSkinInfo
  9293. }, [{
  9294. group: "region_" + n + "_" + e,
  9295. mode: 0
  9296. }])) : (_this._currentMeshUsedLod.set(e, t), _this._scenemanager.addNewLowPolyMesh({
  9297. url: a,
  9298. group: "region_" + n + "_" + e,
  9299. pick: !0,
  9300. lod: t,
  9301. skinInfo: _this._partMeshSkinInfo
  9302. }));
  9303. });
  9304. E(this, "checkPointInView", function (_ref) {
  9305. var e = _ref.x,
  9306. t = _ref.y,
  9307. r = _ref.z;
  9308. var n = ue4Position2Xverse({
  9309. x: e,
  9310. y: t,
  9311. z: r
  9312. });
  9313. if (!n) return !1;
  9314. for (var o = 0; o < 6; o++) {
  9315. if (_this.scene.frustumPlanes[o].dotCoordinate(n) < 0) return !1;
  9316. }
  9317. return !0;
  9318. });
  9319. E(this, "addNewLowPolyMesh", function (e, t, r) {
  9320. 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)));
  9321. {
  9322. var n = e.url;
  9323. return new Promise(function (o, a) {
  9324. return _this._scenemanager.urlTransformer(e.url).then(function (s) {
  9325. e.url = s;
  9326. var l = new XStaticMeshFromOneGltf(_this.scene, e),
  9327. u = Date.now();
  9328. return new Promise(function (c, h) {
  9329. l.loadMesh(r, !0).then(function (f) {
  9330. var d = Date.now();
  9331. if (_this._scenemanager.engineRunTimeStats.timeArray_loadStaticMesh.add(d - u), f == !0) {
  9332. var _ = _this.getLowModelType(e);
  9333. var g = 0;
  9334. 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) {
  9335. var m = [];
  9336. for (var v = 0; v < t.length; ++v) {
  9337. m.push(t[v].group), _this.updateLowModelGroup(t[v], _, g);
  9338. }
  9339. }
  9340. _this._scenemanager.engineRunTimeStats.timeArray_updateStaticMesh.add(Date.now() - d), c(!0);
  9341. } else h(new XLowpolyModelError("[Engine] after lowmodel error!"));
  9342. }).catch(function (f) {
  9343. logger$1.error("[Engine] load Mesh [" + n + "] error! " + f), h(new XLowpolyModelError("[Engine] load Mesh [".concat(n, "] error! ").concat(f)));
  9344. });
  9345. });
  9346. }).then(function (s) {
  9347. s == !0 ? (logger$1.info("[Engine] load Mesh [".concat(n, "] successfully.")), o(!0)) : a(!1);
  9348. }).catch(function (s) {
  9349. logger$1.error("[Engine] addNewLowPolyMesh [" + n + "] error! " + s), a(new XLowpolyModelError("[Engine] addNewLowPolyMesh [".concat(n, "] error! ").concat(s)));
  9350. });
  9351. });
  9352. }
  9353. });
  9354. E(this, "toggleLowModelVisibility", function (e) {
  9355. var t = e.vis,
  9356. _e$groupName = e.groupName,
  9357. r = _e$groupName === void 0 ? "" : _e$groupName,
  9358. _e$skinInfo = e.skinInfo,
  9359. n = _e$skinInfo === void 0 ? "" : _e$skinInfo;
  9360. _this._meshVis = t, _this._meshVisTypeName = {
  9361. groupName: r,
  9362. skinInfo: n
  9363. }, _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;
  9364. });
  9365. E(this, "reg_staticmesh_visibility", function () {
  9366. if (_this._doMeshVisChangeNumber >= 0) if (_this._doMeshVisChangeNumber < _this._visCheckDurationFrameNumber) {
  9367. if (_this._doMeshVisChangeNumber = _this._doMeshVisChangeNumber + 1, _this._meshVisTypeName.groupName == Te.ALL_MESHES) _this._lowModel_group.forEach(function (e, t) {
  9368. for (var r = 0, n = e.length; r < n; ++r) {
  9369. e[r].toggleVisibility(_this._meshVis);
  9370. }
  9371. });else {
  9372. if (_this._lowModel_group.has(_this._meshVisTypeName.groupName)) for (var _e3 = 0; _e3 < _this._lowModel_group.get(_this._meshVisTypeName.groupName).length; ++_e3) {
  9373. _this._lowModel_group.get(_this._meshVisTypeName.groupName)[_e3].toggleVisibility(_this._meshVis);
  9374. }
  9375. if (_this._meshVisTypeName.skinInfo != "") for (var _e4 = 0; _e4 < _this._staticmeshes.length; ++_e4) {
  9376. _this._staticmeshes[_e4].skinInfo == _this._meshVisTypeName.skinInfo && _this._staticmeshes[_e4].toggleVisibility(_this._meshVis);
  9377. }
  9378. }
  9379. } else _this._meshVis = !0, _this._meshVisTypeName = {
  9380. groupName: "",
  9381. skinInfo: ""
  9382. }, _this._doMeshVisChangeNumber = -1;
  9383. });
  9384. E(this, "_getMeshesByCustomProperty", function (e, t) {
  9385. var r = [];
  9386. return _this._staticmeshes.forEach(function (n) {
  9387. n[e] != null && n[e] == t && (r = r.concat(n.meshes));
  9388. }), r;
  9389. });
  9390. 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 = {
  9391. groupName: "",
  9392. skinInfo: ""
  9393. }, this._doMeshVisChangeNumber = -1, this._visCheckDurationFrameNumber = -1, this._regionLodRule = [0, 1, 3, 3, -1], this.initCgLowModel(), this._regionPartLoop();
  9394. }
  9395. _createClass(XStaticMeshComponent, [{
  9396. key: "cameraInRegionId",
  9397. get: function get() {
  9398. return this._cameraInRegionId;
  9399. }
  9400. }, {
  9401. key: "setRegionLodRule",
  9402. value: function setRegionLodRule(e) {
  9403. return e.length != 5 ? !1 : (e.forEach(function (t) {}), this._regionLodRule = e, !0);
  9404. }
  9405. }, {
  9406. key: "lowModel_group",
  9407. get: function get() {
  9408. return this._lowModel_group;
  9409. }
  9410. }, {
  9411. key: "_regionPartLoop",
  9412. value: function _regionPartLoop() {
  9413. this.scene.registerBeforeRender(this.reg_staticmesh_partupdate), this.scene.registerAfterRender(this.reg_staticmesh_visibility);
  9414. }
  9415. }, {
  9416. key: "_globalSearchCameraInWhichRegion",
  9417. value: function _globalSearchCameraInWhichRegion(e, t) {
  9418. var r = -1;
  9419. for (var n = 0; n < t.length; ++n) {
  9420. var o = this._meshInfoJson[t[n].toString()].boundingbox,
  9421. a = o[0],
  9422. s = o[1];
  9423. 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]) {
  9424. r = parseInt(t[n].toString());
  9425. break;
  9426. }
  9427. }
  9428. return r;
  9429. }
  9430. }, {
  9431. key: "getRegionIdByPosition",
  9432. value: function getRegionIdByPosition(e) {
  9433. return this.getRegionIdWhichIncludeCamera(e);
  9434. }
  9435. }, {
  9436. key: "getRegionIdWhichIncludeCamera",
  9437. value: function getRegionIdWhichIncludeCamera(e) {
  9438. var t = -1;
  9439. if (this._allowRegionUpdate == !1) return t;
  9440. 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) {
  9441. var r = 1e7;
  9442. for (var n = 0; n < this._meshInfoKeys.length; ++n) {
  9443. var o = this._meshInfoJson[this._meshInfoKeys[n]].center,
  9444. a = Math.abs(e.x - o[0]) + Math.abs(e.y - o[1]);
  9445. r > a && (r = a, t = parseInt(this._meshInfoKeys[n]));
  9446. }
  9447. }
  9448. return t;
  9449. }
  9450. }, {
  9451. key: "getNearestRegionIdWithCamera",
  9452. value: function getNearestRegionIdWithCamera(e) {
  9453. var t = 1,
  9454. r = 1e7;
  9455. for (var n = 0; n < this._meshInfoKeys.length; ++n) {
  9456. if (this._notUsedRegionLists.indexOf(parseInt(this._meshInfoKeys[n])) >= 0) continue;
  9457. var o = this._meshInfoJson[this._meshInfoKeys[n]].center,
  9458. a = Math.abs(e.x - o[0]) + Math.abs(e.y - o[1]);
  9459. r > a && (r = a, t = parseInt(this._meshInfoKeys[n]));
  9460. }
  9461. return t;
  9462. }
  9463. }, {
  9464. key: "_getNeighborId",
  9465. value: function _getNeighborId(e) {
  9466. var t = this._meshInfoJson[e].lod;
  9467. var r = [];
  9468. var n = Object.keys(t);
  9469. for (var o = n.length - 1; o >= 0; --o) {
  9470. r = r.concat(t[n[o]]);
  9471. }
  9472. return r.push(parseInt(e)), r;
  9473. }
  9474. }, {
  9475. key: "_getMainPlayerPosition",
  9476. value: function _getMainPlayerPosition() {
  9477. var e = this._scenemanager.cameraComponent.getCameraPose().position,
  9478. t = this._scenemanager.avatarComponent.getMainAvatar();
  9479. if (t != null && t != null) {
  9480. var r = t.position;
  9481. if (r != null) return r;
  9482. }
  9483. return e;
  9484. }
  9485. }, {
  9486. key: "_calHashCode",
  9487. value: function _calHashCode(e) {
  9488. return hashCode(e) + "_" + this._partMeshSkinInfo;
  9489. }
  9490. }, {
  9491. key: "forceAllRegionLod",
  9492. value: function forceAllRegionLod() {
  9493. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 3;
  9494. e < 0 && (e = 0), e > 3 && (e = 3), this.stopMeshUpdate(), this._allowRegionForceLod = !0, this._forceLod = e;
  9495. }
  9496. }, {
  9497. key: "deleteLastRegionMesh",
  9498. value: function deleteLastRegionMesh() {
  9499. if (this._rootDir != "") {
  9500. var e = this._calHashCode(this._rootDir);
  9501. 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);
  9502. }
  9503. }
  9504. }, {
  9505. key: "startMeshUpdate",
  9506. value: function startMeshUpdate() {
  9507. this._allowRegionUpdate == !1 && this._meshInfoJson != null && this._abosoluteUrl != "" && this._meshInfoKeys.length > 0 && (this._allowRegionUpdate = !0);
  9508. }
  9509. }, {
  9510. key: "stopMeshUpdate",
  9511. value: function stopMeshUpdate() {
  9512. this._allowRegionUpdate = !1;
  9513. }
  9514. }, {
  9515. key: "parseJson",
  9516. value: function parseJson(e) {
  9517. var _this2 = this;
  9518. return new Promise(function (t, r) {
  9519. return _this2._scenemanager.urlTransformer(e).then(function (n) {
  9520. var o = new XMLHttpRequest();
  9521. o.open("get", n), o.send(null), o.onload = function () {
  9522. if (o.status == 200) {
  9523. var a = JSON.parse(o.responseText);
  9524. _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();
  9525. }
  9526. }, o.onerror = function () {
  9527. 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)));
  9528. };
  9529. }).catch(function (n) {
  9530. 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)));
  9531. });
  9532. });
  9533. }
  9534. }, {
  9535. key: "initCgLowModel",
  9536. value: function initCgLowModel() {
  9537. var e = BABYLON.MeshBuilder.CreatePlane("CgPlane", {
  9538. size: 400
  9539. });
  9540. e.position = new BABYLON.Vector3(0, 1010, 0), e.rotation = new BABYLON.Vector3(3 * Math.PI / 2, 0, 0), this._CgPlane = new XStaticMesh({
  9541. id: "CgPlane",
  9542. mesh: e,
  9543. xtype: EMeshType.Cgplane
  9544. }), this._CgPlane.hide();
  9545. }
  9546. }, {
  9547. key: "getLowModelType",
  9548. value: function getLowModelType(e) {
  9549. var t = "";
  9550. return e.group != null ? t = e.group : t = "default", t;
  9551. }
  9552. }, {
  9553. key: "lowmodelGroupMapAddValue",
  9554. value: function lowmodelGroupMapAddValue(e, t) {
  9555. var r = this._lowModel_group.get(e);
  9556. r != null ? (r.push(t), this._lowModel_group.set(e, r)) : this._lowModel_group.set(e, [t]);
  9557. }
  9558. }, {
  9559. key: "updateLowModelGroup",
  9560. value: function updateLowModelGroup(e, t, r) {
  9561. var n = r;
  9562. 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);
  9563. }
  9564. }, {
  9565. key: "toggleVisibleLowModelGroup",
  9566. value: function toggleVisibleLowModelGroup(e, t) {
  9567. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : -1;
  9568. if (this._lowModel_group.has(t)) {
  9569. var n = this._lowModel_group.get(t);
  9570. var o = n.length;
  9571. r >= 0 && o >= r && (o = r);
  9572. for (var a = 0; a < o; ++a) {
  9573. n[a].toggleVisibility(e);
  9574. }
  9575. }
  9576. }
  9577. }, {
  9578. key: "deleteLowModelGroup",
  9579. value: function deleteLowModelGroup(e) {
  9580. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
  9581. if (this._lowModel_group.has(e)) {
  9582. var o = this._lowModel_group.get(e);
  9583. var a = o.length;
  9584. t >= 0 && a >= t && (a = t);
  9585. for (var s = 0; s < a; ++s) {
  9586. o[s].dispose();
  9587. }
  9588. t >= 0 ? this._lowModel_group.set(e, this._lowModel_group.get(e).slice(a)) : this._lowModel_group.delete(e);
  9589. }
  9590. var r = this._lowModel_group.get(e),
  9591. n = [];
  9592. r != null && r.length > 0 ? this._staticmeshes.forEach(function (o) {
  9593. if (o.group != e) n.push(o);else for (var _a2 = 0; _a2 < r.length; ++_a2) {
  9594. o.groupUuid == r[_a2].groupUuid && n.push(o);
  9595. }
  9596. }) : this._staticmeshes.forEach(function (o) {
  9597. o.group != e && n.push(o);
  9598. }), this._staticmeshes = n;
  9599. }
  9600. }, {
  9601. key: "deleteMeshesByGroup",
  9602. value: function deleteMeshesByGroup(e) {
  9603. this.deleteLowModelGroup(e);
  9604. }
  9605. }, {
  9606. key: "deleteMeshesById",
  9607. value: function deleteMeshesById(e) {
  9608. this.deleteMeshesByCustomProperty("id", e);
  9609. }
  9610. }, {
  9611. key: "deleteMeshesByLoD",
  9612. value: function deleteMeshesByLoD(e) {
  9613. this.deleteMeshesByCustomProperty("lod", e);
  9614. }
  9615. }, {
  9616. key: "deleteMeshesBySkinInfo",
  9617. value: function deleteMeshesBySkinInfo(e) {
  9618. this.deleteMeshesByCustomProperty("skinInfo", e);
  9619. }
  9620. }, {
  9621. key: "removeMeshesFromSceneByGroup",
  9622. value: function removeMeshesFromSceneByGroup(e) {
  9623. this.removeMeshesFromSceneByCustomProperty("group", e);
  9624. }
  9625. }, {
  9626. key: "removeMeshesFromSceneById",
  9627. value: function removeMeshesFromSceneById(e) {
  9628. this.removeMeshesFromSceneByCustomProperty("id", e);
  9629. }
  9630. }, {
  9631. key: "addMeshesToSceneByGroup",
  9632. value: function addMeshesToSceneByGroup(e) {
  9633. this.addMeshesToSceneByCustomProperty("group", e);
  9634. }
  9635. }, {
  9636. key: "addMeshesToSceneById",
  9637. value: function addMeshesToSceneById(e) {
  9638. this.addMeshesToSceneByCustomProperty("id", e);
  9639. }
  9640. }, {
  9641. key: "removeMeshesFromSceneByCustomProperty",
  9642. value: function removeMeshesFromSceneByCustomProperty(e, t) {
  9643. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
  9644. this._staticmeshes.forEach(function (n) {
  9645. n.isinscene && n[e] != null && (r ? n[e].indexOf(t) < 0 || n.removeFromScene() : n[e] != t || n.removeFromScene());
  9646. });
  9647. }
  9648. }, {
  9649. key: "addMeshesToSceneByCustomProperty",
  9650. value: function addMeshesToSceneByCustomProperty(e, t) {
  9651. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
  9652. this._staticmeshes.forEach(function (n) {
  9653. n.isinscene == !1 && n[e] != null && (r ? n[e].indexOf(t) < 0 || n.addToScene() : n[e] != t || n.addToScene());
  9654. });
  9655. }
  9656. }, {
  9657. key: "deleteMeshesByCustomProperty",
  9658. value: function deleteMeshesByCustomProperty(e, t) {
  9659. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
  9660. var n = [];
  9661. this._staticmeshes.forEach(function (a) {
  9662. a[e] != null && (r ? a[e].indexOf(t) < 0 ? n.push(a) : a.dispose() : a[e] != t ? n.push(a) : a.dispose());
  9663. }), this._staticmeshes = n;
  9664. var o = Array.from(this._lowModel_group.keys());
  9665. for (var a = 0; a < o.length; ++a) {
  9666. var s = o[a],
  9667. l = this._lowModel_group.get(s);
  9668. if (l != null) {
  9669. var u = [];
  9670. for (var c = 0; c < l.length; ++c) {
  9671. l[c][e] != null && (r ? l[c][e].indexOf(t) < 0 && u.push(l[c]) : l[c][e] != t && u.push(l[c]));
  9672. }
  9673. u.length > 0 ? this._lowModel_group.set(s, u) : this._lowModel_group.delete(s);
  9674. }
  9675. }
  9676. }
  9677. }, {
  9678. key: "getMeshes",
  9679. value: function getMeshes() {
  9680. var e = [];
  9681. for (var t = 0; t < this._staticmeshes.length; ++t) {
  9682. e = e.concat(this._staticmeshes[t].meshes);
  9683. }
  9684. return e;
  9685. }
  9686. }, {
  9687. key: "getCgMesh",
  9688. value: function getCgMesh() {
  9689. return this._CgPlane;
  9690. }
  9691. }, {
  9692. key: "getMeshesByGroup",
  9693. value: function getMeshesByGroup() {
  9694. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "default";
  9695. var t = this._lowModel_group.get(e);
  9696. if (t != null) {
  9697. var r = [];
  9698. for (var n = 0; n < t.length; ++n) {
  9699. r = r.concat(t[n].meshes);
  9700. }
  9701. return r;
  9702. } else return null;
  9703. }
  9704. }, {
  9705. key: "getMeshesByGroup2",
  9706. value: function getMeshesByGroup2() {
  9707. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "default";
  9708. return this._getMeshesByCustomProperty("group", e);
  9709. }
  9710. }]);
  9711. return XStaticMeshComponent;
  9712. }();
  9713. var XVideoRawYUV = /*#__PURE__*/function () {
  9714. function XVideoRawYUV(e, t) {
  9715. var _this = this;
  9716. _classCallCheck(this, XVideoRawYUV);
  9717. E(this, "scene");
  9718. E(this, "_videoRawYUVTexture");
  9719. E(this, "videosResOriArray");
  9720. E(this, "_currentVideoId");
  9721. this.scene = e, this._videoRawYUVTexture = [], this.videosResOriArray = t, this._currentVideoId = -1;
  9722. for (var r = 0; r < t.length; ++r) {
  9723. (function (n) {
  9724. var o = BABYLON.RawTexture.CreateLuminanceTexture(null, t[n].width, t[n].height * 1.5, _this.scene, !1, !0);
  9725. o.name = "videoTex_" + t[n].width + "_" + t[n].height, _this._videoRawYUVTexture.push(o);
  9726. })(r);
  9727. }
  9728. }
  9729. _createClass(XVideoRawYUV, [{
  9730. key: "inRange",
  9731. value: function inRange(e) {
  9732. return e >= 0 && e < this._videoRawYUVTexture.length;
  9733. }
  9734. }, {
  9735. key: "getVideoYUVTex",
  9736. value: function getVideoYUVTex(e) {
  9737. return this.inRange(e) ? this._videoRawYUVTexture[e] : null;
  9738. }
  9739. }, {
  9740. key: "findId",
  9741. value: function findId(e, t) {
  9742. var r = 0;
  9743. for (var n = 0; n < this.videosResOriArray.length; ++n) {
  9744. if (this.videosResOriArray[n].width == e && this.videosResOriArray[n].height == t) {
  9745. r = n;
  9746. break;
  9747. }
  9748. }
  9749. return r;
  9750. }
  9751. }, {
  9752. key: "getCurrentVideoTexId",
  9753. value: function getCurrentVideoTexId() {
  9754. return this._currentVideoId;
  9755. }
  9756. }, {
  9757. key: "setCurrentVideoTexId",
  9758. value: function setCurrentVideoTexId(e) {
  9759. this._currentVideoId = e;
  9760. }
  9761. }]);
  9762. return XVideoRawYUV;
  9763. }();
  9764. var XMaterialComponent = /*#__PURE__*/function () {
  9765. function XMaterialComponent(e, t) {
  9766. var _this = this;
  9767. _classCallCheck(this, XMaterialComponent);
  9768. E(this, "scene");
  9769. E(this, "engine");
  9770. E(this, "yuvInfo");
  9771. E(this, "shaderMode");
  9772. E(this, "_panoInfo");
  9773. E(this, "_dynamic_size");
  9774. E(this, "_dynamic_babylonpose");
  9775. E(this, "_dynamic_textures");
  9776. E(this, "_dynamic_shaders");
  9777. E(this, "_scenemanager");
  9778. E(this, "_videoTexture");
  9779. E(this, "_videoElement");
  9780. E(this, "_lowModelShader");
  9781. E(this, "_defaultShader");
  9782. E(this, "_inputYUV420", !0);
  9783. E(this, "_inputPanoYUV420", !0);
  9784. E(this, "_videoRawYUVTexArray");
  9785. E(this, "_isUpdateYUV", !0);
  9786. E(this, "initMaterial", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  9787. return regenerator.wrap(function _callee$(_context) {
  9788. while (1) {
  9789. switch (_context.prev = _context.next) {
  9790. case 0:
  9791. return _context.abrupt("return", new Promise(function (e, t) {
  9792. _this._initDefaultShader(), _this.shaderMode == 2 ? _this.initDynamicData(_this._panoInfo.dynamicRange, _this._panoInfo.width, _this._panoInfo.height).then(function () {
  9793. _this._initPureVideoShader(), _this._prepareRender(_this.yuvInfo);
  9794. }) : _this.shaderMode == 1 ? (_this._initPureVideoShader(), _this._prepareRender(_this.yuvInfo)) : _this.shaderMode == 0, e(!0);
  9795. }));
  9796. case 1:
  9797. case "end":
  9798. return _context.stop();
  9799. }
  9800. }
  9801. }, _callee);
  9802. })));
  9803. E(this, "_initPureVideoContent", function (e) {
  9804. _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 () {
  9805. _this._changePureVideoLowModelShaderCanvasSize(e);
  9806. })) : (_this._videoElement = e.videoElement, _this._videoTexture || (_this._videoTexture = new VideoTexture("InterVideoTexture", _this._videoElement, _this.scene, !0, !1)), BABYLON.Texture.WhenAllReady([_this._videoTexture], function () {
  9807. _this._changePureVideoLowModelShaderCanvasSize({
  9808. width: _this._videoElement.height,
  9809. height: _this._videoElement.width,
  9810. fov: e.fov
  9811. });
  9812. }), _this._lowModelShader.setTexture("texture_video", _this._videoTexture), _this._lowModelShader.setFloat("isYUV", 0));
  9813. });
  9814. E(this, "_changePureVideoLowModelShaderCanvasSize", function (e) {
  9815. var a;
  9816. var t = e.fov || 50,
  9817. r = e.width || 720,
  9818. n = e.height || 1280,
  9819. o = r / (2 * Math.tan(Math.PI * t / 360));
  9820. (a = _this._lowModelShader) == null || a.setVector3("focal_width_height", new BABYLON.Vector3(o, r, n));
  9821. });
  9822. E(this, "updateRawYUVData", function (e, t, r) {
  9823. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : -1;
  9824. var o, a;
  9825. if (n == -1 && (n = _this.yuvInfo.fov), _this._isUpdateYUV == !0) {
  9826. var s = {
  9827. width: t,
  9828. height: r,
  9829. fov: n
  9830. },
  9831. l = _this._videoRawYUVTexArray.findId(t, r),
  9832. u = _this._videoRawYUVTexArray.getCurrentVideoTexId();
  9833. (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);
  9834. }
  9835. });
  9836. E(this, "_changeVideoRes", function (e) {
  9837. _this._lowModelShader.setTexture("texture_video", _this._videoRawYUVTexArray.getVideoYUVTex(e));
  9838. });
  9839. E(this, "initDynamicData", function (e, t, r) {
  9840. return new Promise(function (n, o) {
  9841. _this.setDynamicSize(e).then(function (a) {
  9842. if (a) {
  9843. for (var s = 0; s < e; ++s) {
  9844. (function (l) {
  9845. _this.initDynamicTexture(l, t, r), _this.initDynamicShaders(l).then(function () {
  9846. _this._updatePanoShaderInput(l);
  9847. });
  9848. })(s);
  9849. }
  9850. n(!0);
  9851. } else o(new XMaterialError("[Engine] DynamicRoomSize (".concat(e, ") is too small")));
  9852. });
  9853. }).catch(function (n) {
  9854. return logger$1.error("[Engine] ".concat(n));
  9855. });
  9856. });
  9857. E(this, "_initDefaultShader", function () {
  9858. _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);
  9859. });
  9860. E(this, "_initPureVideoShader", function () {
  9861. if (_this._lowModelShader == null) {
  9862. var _e = new BABYLON.ShaderMaterial("PureVideoShader", _this.scene, {
  9863. vertexSource: pureVideoVertex,
  9864. fragmentSource: pureVideoFragment
  9865. }, {
  9866. attributes: ["uv", "position", "world0", "world1", "world2", "world3"],
  9867. uniforms: ["view", "projection", "worldViewProjection", "world"],
  9868. defines: ["#define SHADOWFULLFLOAT"]
  9869. });
  9870. _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;
  9871. }
  9872. });
  9873. E(this, "setDynamicSize", function (e) {
  9874. return new Promise(function (t, r) {
  9875. e >= 1 && e <= 100 ? (_this._dynamic_size = e, t(!0)) : (_this._dynamic_size = 1, t(!1));
  9876. });
  9877. });
  9878. E(this, "_isInDynamicRange", function (e) {
  9879. return e < _this._dynamic_size && e >= 0;
  9880. });
  9881. E(this, "initDynamicTexture", function (e, t, r) {
  9882. _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());
  9883. });
  9884. E(this, "initDynamicShaders", function (e) {
  9885. return logger$1.info("[Engine] Material init dynamic shader."), new Promise(function (t, r) {
  9886. _this._dynamic_shaders[e] != null && _this._dynamic_shaders[e].dispose();
  9887. var n = new BABYLON.ShaderMaterial("Pano_Shader_" + e, _this.scene, {
  9888. vertexSource: panoVertex,
  9889. fragmentSource: panoFragment
  9890. }, {
  9891. attributes: ["uv", "position", "world0", "world1", "world2", "world3"],
  9892. uniforms: ["view", "projection", "worldViewProjection", "world"],
  9893. defines: ["#define SHADOWFULLFLOAT"]
  9894. });
  9895. 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);
  9896. });
  9897. });
  9898. 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);
  9899. }
  9900. _createClass(XMaterialComponent, [{
  9901. key: "stopYUVUpdate",
  9902. value: function stopYUVUpdate() {
  9903. this._isUpdateYUV = !1;
  9904. }
  9905. }, {
  9906. key: "allowYUVUpdate",
  9907. value: function allowYUVUpdate() {
  9908. this._isUpdateYUV = !0;
  9909. }
  9910. }, {
  9911. key: "setPanoInfo",
  9912. value: function setPanoInfo(e) {
  9913. this._panoInfo = e;
  9914. }
  9915. }, {
  9916. key: "_prepareRender",
  9917. value: function _prepareRender(e) {
  9918. e && (this._initPureVideoContent(e), this._updatePureVideoShaderInput());
  9919. }
  9920. }, {
  9921. key: "getPureVideoShader",
  9922. value: function getPureVideoShader() {
  9923. return this._lowModelShader;
  9924. }
  9925. }, {
  9926. key: "getDefaultShader",
  9927. value: function getDefaultShader() {
  9928. return this._defaultShader;
  9929. }
  9930. }, {
  9931. key: "updatePanoPartYUV",
  9932. value: function updatePanoPartYUV(e, t, r) {
  9933. var n = t.subarray(0, r.width * r.height),
  9934. o = t.subarray(r.width * r.height, r.width * r.height * 1.25),
  9935. a = t.subarray(r.width * r.height * 1.25),
  9936. s = this._panoInfo.width,
  9937. l = this._panoInfo.height;
  9938. if (this._dynamic_textures[e] != null) {
  9939. var u = this._dynamic_textures[e].getInternalTexture();
  9940. if (u != null && u != null) {
  9941. var c = this.engine._getTextureTarget(u);
  9942. 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);
  9943. }
  9944. }
  9945. }
  9946. }, {
  9947. key: "changePanoImg",
  9948. value: function changePanoImg(e, t) {
  9949. var _this2 = this;
  9950. 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")));
  9951. var r = ue4Position2Xverse(t.pose.position);
  9952. return r && (this._dynamic_babylonpose[e] = {
  9953. position: r
  9954. }), new Promise(function (n, o) {
  9955. try {
  9956. typeof t.data == "string" ? (_this2.setPanoYUV420(!1), _this2._dynamic_textures[e].updateURL(t.data, null, function () {
  9957. _this2._dynamic_textures[e].updateSamplingMode(BABYLON.Texture.NEAREST_SAMPLINGMODE);
  9958. })) : (_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);
  9959. } catch (a) {
  9960. o(new XMaterialError("[Engine] ChangePanoImg Error! ".concat(a)));
  9961. }
  9962. }).then(function (n) {
  9963. 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;
  9964. });
  9965. }
  9966. }, {
  9967. key: "setYUV420",
  9968. value: function setYUV420(e) {
  9969. this._inputYUV420 = e;
  9970. }
  9971. }, {
  9972. key: "isYUV420",
  9973. value: function isYUV420() {
  9974. return this._inputYUV420;
  9975. }
  9976. }, {
  9977. key: "setPanoYUV420",
  9978. value: function setPanoYUV420(e) {
  9979. this._inputPanoYUV420 = e;
  9980. }
  9981. }, {
  9982. key: "isPanoYUV420",
  9983. value: function isPanoYUV420() {
  9984. return this._inputPanoYUV420;
  9985. }
  9986. }, {
  9987. key: "getDynamicShader",
  9988. value: function getDynamicShader(e) {
  9989. return this._dynamic_shaders[e];
  9990. }
  9991. }, {
  9992. key: "_updatePureVideoShaderInput",
  9993. value: function _updatePureVideoShaderInput() {
  9994. var _this3 = this;
  9995. var e, t, r, n, o, a, s, l, u, c;
  9996. 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 () {
  9997. var h;
  9998. _this3._lowModelShader.setFloat("fireworkLight", _this3.scene.getLightByName("fireworkLight").getScaledIntensity()), _this3._lowModelShader.setVector3("fireworkLightPosition", (h = _this3.scene.getLightByName("fireworkLight")) == null ? void 0 : h.position);
  9999. });else {
  10000. var h = new BABYLON.PointLight("fireworkLight", new BABYLON.Vector3(0, 0, 0), this.scene);
  10001. h.intensity = 0;
  10002. }
  10003. }
  10004. }, {
  10005. key: "_updatePanoShaderInput",
  10006. value: function _updatePanoShaderInput(e) {
  10007. var _this4 = this;
  10008. var t, r, n, o, a, s, l, u, c, h;
  10009. 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 () {
  10010. var f;
  10011. _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);
  10012. });else {
  10013. var f = new BABYLON.PointLight("fireworkLight", new BABYLON.Vector3(0, 0, 0), this.scene);
  10014. f.intensity = 0;
  10015. }
  10016. }
  10017. }]);
  10018. return XMaterialComponent;
  10019. }();
  10020. var XStats = /*#__PURE__*/function () {
  10021. function XStats(e) {
  10022. _classCallCheck(this, XStats);
  10023. E(this, "scene");
  10024. E(this, "sceneInstrumentation");
  10025. E(this, "engineInstrumentation");
  10026. E(this, "caps");
  10027. E(this, "engine");
  10028. E(this, "_canvas");
  10029. E(this, "_osversion");
  10030. E(this, "_scenemanager");
  10031. this._scenemanager = e, this.scene = e.Scene, this._canvas = e.canvas, this.initSceneInstrument();
  10032. }
  10033. _createClass(XStats, [{
  10034. key: "initSceneInstrument",
  10035. value: function initSceneInstrument() {
  10036. 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();
  10037. }
  10038. }, {
  10039. key: "getFrameTimeCounter",
  10040. value: function getFrameTimeCounter() {
  10041. return this.sceneInstrumentation.frameTimeCounter.current;
  10042. }
  10043. }, {
  10044. key: "getInterFrameTimeCounter",
  10045. value: function getInterFrameTimeCounter() {
  10046. return this.sceneInstrumentation.interFrameTimeCounter.current;
  10047. }
  10048. }, {
  10049. key: "getActiveMeshEvaluationTime",
  10050. value: function getActiveMeshEvaluationTime() {
  10051. return this.sceneInstrumentation.activeMeshesEvaluationTimeCounter.current;
  10052. }
  10053. }, {
  10054. key: "getDrawCall",
  10055. value: function getDrawCall() {
  10056. return this.sceneInstrumentation.drawCallsCounter.current;
  10057. }
  10058. }, {
  10059. key: "getDrawCallTime",
  10060. value: function getDrawCallTime() {
  10061. return this.sceneInstrumentation.renderTimeCounter.current;
  10062. }
  10063. }, {
  10064. key: "getAnimationTime",
  10065. value: function getAnimationTime() {
  10066. return this.sceneInstrumentation.animationsTimeCounter.current;
  10067. }
  10068. }, {
  10069. key: "getActiveMesh",
  10070. value: function getActiveMesh() {
  10071. return this.scene.getActiveMeshes().length;
  10072. }
  10073. }, {
  10074. key: "getActiveFaces",
  10075. value: function getActiveFaces() {
  10076. return Math.round(this.scene.getActiveIndices() / 3);
  10077. }
  10078. }, {
  10079. key: "getActiveBones",
  10080. value: function getActiveBones() {
  10081. return this.scene.getActiveBones();
  10082. }
  10083. }, {
  10084. key: "getActiveAnimation",
  10085. value: function getActiveAnimation() {
  10086. return this.scene._activeAnimatables.length;
  10087. }
  10088. }, {
  10089. key: "getActiveParticles",
  10090. value: function getActiveParticles() {
  10091. return this.scene.getActiveParticles();
  10092. }
  10093. }, {
  10094. key: "getTotalMaterials",
  10095. value: function getTotalMaterials() {
  10096. return this.scene.materials.length;
  10097. }
  10098. }, {
  10099. key: "getTotalTextures",
  10100. value: function getTotalTextures() {
  10101. return this.scene.textures.length;
  10102. }
  10103. }, {
  10104. key: "getTotalGeometries",
  10105. value: function getTotalGeometries() {
  10106. return this.scene.geometries.length;
  10107. }
  10108. }, {
  10109. key: "getTotalMeshes",
  10110. value: function getTotalMeshes() {
  10111. return this.scene.meshes.length;
  10112. }
  10113. }, {
  10114. key: "getCameraRenderTime",
  10115. value: function getCameraRenderTime() {
  10116. return this.sceneInstrumentation.cameraRenderTimeCounter.current;
  10117. }
  10118. }, {
  10119. key: "getTotalRootNodes",
  10120. value: function getTotalRootNodes() {
  10121. return this.scene.rootNodes.length;
  10122. }
  10123. }, {
  10124. key: "getRenderTargetRenderTime",
  10125. value: function getRenderTargetRenderTime() {
  10126. var e = this.getDrawCallTime(),
  10127. t = this.getActiveMeshEvaluationTime(),
  10128. r = this.getCameraRenderTime() - (t + e);
  10129. return this.getRTT1Time() + r;
  10130. }
  10131. }, {
  10132. key: "getRegisterBeforeRenderTime",
  10133. value: function getRegisterBeforeRenderTime() {
  10134. return this.sceneInstrumentation.registerBeforeTimeCounter.current;
  10135. }
  10136. }, {
  10137. key: "getRegisterAfterRenderTime",
  10138. value: function getRegisterAfterRenderTime() {
  10139. return this.sceneInstrumentation.registerAfterTimeCounter.current;
  10140. }
  10141. }, {
  10142. key: "getRTT1Time",
  10143. value: function getRTT1Time() {
  10144. return this.sceneInstrumentation.getRTT1TimeCounter.current;
  10145. }
  10146. }, {
  10147. key: "getRegisterBeforeRenderObserverLength",
  10148. value: function getRegisterBeforeRenderObserverLength() {
  10149. return this.scene.onBeforeRenderObservable.observers.length;
  10150. }
  10151. }, {
  10152. key: "getRegisterAfterRenderObserverLength",
  10153. value: function getRegisterAfterRenderObserverLength() {
  10154. return this.scene.onAfterRenderObservable.observers.length;
  10155. }
  10156. }, {
  10157. key: "getTotalMeshByType",
  10158. value: function getTotalMeshByType() {
  10159. var e = new Map();
  10160. return this.scene.meshes.forEach(function (t) {
  10161. e.has(t.xtype) ? e.set(t.xtype, e.get(t.xtype) + 1) : e.set(t.xtype, 1);
  10162. }), e;
  10163. }
  10164. }, {
  10165. key: "getHardwareRenderInfo",
  10166. value: function getHardwareRenderInfo() {
  10167. return {
  10168. maxTexturesUnits: this.caps.maxTexturesImageUnits,
  10169. maxVertexTextureImageUnits: this.caps.maxVertexTextureImageUnits,
  10170. maxCombinedTexturesImageUnits: this.caps.maxCombinedTexturesImageUnits,
  10171. maxTextureSize: this.caps.maxTextureSize,
  10172. maxSamples: this.caps.maxSamples,
  10173. maxCubemapTextureSize: this.caps.maxCubemapTextureSize,
  10174. maxRenderTextureSize: this.caps.maxRenderTextureSize,
  10175. maxVertexAttribs: this.caps.maxVertexAttribs,
  10176. maxVaryingVectors: this.caps.maxVaryingVectors,
  10177. maxVertexUniformVectors: this.caps.maxVertexUniformVectors,
  10178. maxFragmentUniformVectors: this.caps.maxFragmentUniformVectors,
  10179. standardDerivatives: this.caps.standardDerivatives,
  10180. supportTextureCompress: {
  10181. s3tc: this.caps.s3tc !== void 0,
  10182. s3tc_srgb: this.caps.s3tc_srgb !== void 0,
  10183. pvrtc: this.caps.pvrtc !== void 0,
  10184. etc1: this.caps.etc1 !== void 0,
  10185. etc2: this.caps.etc2 !== void 0,
  10186. astc: this.caps.astc !== void 0,
  10187. bptc: this.caps.bptc !== void 0
  10188. },
  10189. textureFloat: this.caps.textureFloat,
  10190. vertexArrayObject: this.caps.vertexArrayObject,
  10191. textureAnisotropicFilterExtension: this.caps.textureAnisotropicFilterExtension !== void 0,
  10192. maxAnisotropy: this.caps.maxAnisotropy,
  10193. instancedArrays: this.caps.instancedArrays,
  10194. uintIndices: this.caps.uintIndices,
  10195. highPrecisionShaders: this.caps.highPrecisionShaderSupported,
  10196. fragmentDepth: this.caps.fragmentDepthSupported,
  10197. textureFloatLinearFiltering: this.caps.textureFloatLinearFiltering,
  10198. renderToTextureFloat: this.caps.textureFloatRender,
  10199. textureHalfFloat: this.caps.textureHalfFloat,
  10200. textureHalfFloatLinearFiltering: this.caps.textureHalfFloatLinearFiltering,
  10201. textureHalfFloatRender: this.caps.textureHalfFloatRender,
  10202. textureLOD: this.caps.textureLOD,
  10203. drawBuffersExtension: this.caps.drawBuffersExtension,
  10204. depthTextureExtension: this.caps.depthTextureExtension,
  10205. colorBufferFloat: this.caps.colorBufferFloat,
  10206. supportTimerQuery: this.caps.timerQuery !== void 0,
  10207. canUseTimestampForTimerQuery: this.caps.canUseTimestampForTimerQuery,
  10208. supportOcclusionQuery: this.caps.supportOcclusionQuery,
  10209. multiview: this.caps.multiview,
  10210. oculusMultiview: this.caps.oculusMultiview,
  10211. maxMSAASamples: this.caps.maxMSAASamples,
  10212. blendMinMax: this.caps.blendMinMax,
  10213. canUseGLInstanceID: this.caps.canUseGLInstanceID,
  10214. canUseGLVertexID: this.caps.canUseGLVertexID,
  10215. supportComputeShaders: this.caps.supportComputeShaders,
  10216. supportSRGBBuffers: this.caps.supportSRGBBuffers,
  10217. supportStencil: this.engine.isStencilEnable
  10218. };
  10219. }
  10220. }, {
  10221. key: "getSystemInfo",
  10222. value: function getSystemInfo() {
  10223. return {
  10224. resolution: "real: " + this.engine.getRenderWidth() + "x" + this.engine.getRenderHeight() + " cavs: " + this._canvas.clientWidth + "x" + this._canvas.clientHeight,
  10225. hardwareScalingLevel: this.engine.getHardwareScalingLevel().toFixed(2).toString() + "_" + this._scenemanager.initEngineScaleNumber.toFixed(2).toString(),
  10226. driver: this.engine.getGlInfo().renderer,
  10227. vender: this.engine.getGlInfo().vendor,
  10228. version: this.engine.getGlInfo().version,
  10229. os: this._osversion
  10230. };
  10231. }
  10232. }, {
  10233. key: "getFps",
  10234. value: function getFps() {
  10235. var e = this.sceneInstrumentation.frameTimeCounter.lastSecAverage,
  10236. t = this.sceneInstrumentation.interFrameTimeCounter.lastSecAverage;
  10237. return 1e3 / (e + t);
  10238. }
  10239. }, {
  10240. key: "osVersion",
  10241. value: function osVersion() {
  10242. var e = window.navigator.userAgent;
  10243. var t;
  10244. 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;
  10245. }
  10246. }]);
  10247. return XStats;
  10248. }();
  10249. function _arrayWithHoles(arr) {
  10250. if (Array.isArray(arr)) return arr;
  10251. }
  10252. function _iterableToArrayLimit(arr, i) {
  10253. var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
  10254. if (_i == null) return;
  10255. var _arr = [];
  10256. var _n = true;
  10257. var _d = false;
  10258. var _s, _e;
  10259. try {
  10260. for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
  10261. _arr.push(_s.value);
  10262. if (i && _arr.length === i) break;
  10263. }
  10264. } catch (err) {
  10265. _d = true;
  10266. _e = err;
  10267. } finally {
  10268. try {
  10269. if (!_n && _i["return"] != null) _i["return"]();
  10270. } finally {
  10271. if (_d) throw _e;
  10272. }
  10273. }
  10274. return _arr;
  10275. }
  10276. function _nonIterableRest() {
  10277. throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  10278. }
  10279. function _slicedToArray(arr, i) {
  10280. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray$7(arr, i) || _nonIterableRest();
  10281. }
  10282. var BreathPoint = /*#__PURE__*/function () {
  10283. function BreathPoint(e) {
  10284. _classCallCheck(this, BreathPoint);
  10285. E(this, "_staticmesh");
  10286. E(this, "_id");
  10287. E(this, "_mat");
  10288. E(this, "_type");
  10289. E(this, "_maxVisibleRegion");
  10290. E(this, "_skinInfo");
  10291. E(this, "_scene");
  10292. E(this, "_isInScene");
  10293. var t = e.mesh,
  10294. r = e.id,
  10295. n = e.position,
  10296. o = e.rotation,
  10297. a = e.mat,
  10298. _e$type = e.type,
  10299. s = _e$type === void 0 ? "default" : _e$type,
  10300. _e$maxVisibleRegion = e.maxVisibleRegion,
  10301. l = _e$maxVisibleRegion === void 0 ? -1 : _e$maxVisibleRegion,
  10302. u = e.scene,
  10303. _e$skinInfo = e.skinInfo,
  10304. c = _e$skinInfo === void 0 ? "default" : _e$skinInfo;
  10305. this._id = r, t.mesh.position = ue4Position2Xverse(n), t.mesh.rotation = ue4Rotation2Xverse(o), this._staticmesh = t, this._mat = a, this._type = s, this._maxVisibleRegion = l, this._scene = u, this._skinInfo = c, this._isInScene = !0;
  10306. }
  10307. _createClass(BreathPoint, [{
  10308. key: "isInScene",
  10309. get: function get() {
  10310. return this._isInScene;
  10311. }
  10312. }, {
  10313. key: "skinInfo",
  10314. get: function get() {
  10315. return this._skinInfo;
  10316. }
  10317. }, {
  10318. key: "maxvisibleregion",
  10319. get: function get() {
  10320. return this._maxVisibleRegion;
  10321. }
  10322. }, {
  10323. key: "getMesh",
  10324. value: function getMesh() {
  10325. return this._staticmesh;
  10326. }
  10327. }, {
  10328. key: "mesh",
  10329. get: function get() {
  10330. return this._staticmesh.mesh;
  10331. }
  10332. }, {
  10333. key: "toggleVisibility",
  10334. value: function toggleVisibility(e) {
  10335. e == !0 ? this._staticmesh.show() : this._staticmesh.hide();
  10336. }
  10337. }, {
  10338. key: "changePickable",
  10339. value: function changePickable(e) {
  10340. this._staticmesh.mesh.isPickable = e;
  10341. }
  10342. }, {
  10343. key: "removeFromScene",
  10344. value: function removeFromScene() {
  10345. this._isInScene && (this._staticmesh.mesh != null && this._scene.removeMesh(this._staticmesh.mesh), this._isInScene = !1);
  10346. }
  10347. }, {
  10348. key: "addToScene",
  10349. value: function addToScene() {
  10350. this._isInScene == !1 && (this._staticmesh.mesh != null && this._scene.addMesh(this._staticmesh.mesh), this._isInScene = !0);
  10351. }
  10352. }, {
  10353. key: "dispose",
  10354. value: function dispose() {
  10355. var e;
  10356. (e = this._staticmesh.mesh) == null || e.dispose(!1, !1);
  10357. }
  10358. }, {
  10359. key: "position",
  10360. get: function get() {
  10361. return xversePosition2Ue4(this._staticmesh.mesh.position);
  10362. },
  10363. set: function set(e) {
  10364. this._staticmesh.mesh.position = ue4Position2Xverse(e);
  10365. }
  10366. }, {
  10367. key: "rotation",
  10368. get: function get() {
  10369. return xverseRotation2Ue4(this._staticmesh.mesh.rotation);
  10370. },
  10371. set: function set(e) {
  10372. this._staticmesh.mesh.rotation = ue4Rotation2Xverse(e);
  10373. }
  10374. }]);
  10375. return BreathPoint;
  10376. }();
  10377. 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(_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; } } }; }
  10378. 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); }
  10379. 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; }
  10380. var XBreathPointManager = /*#__PURE__*/function () {
  10381. function XBreathPointManager(e) {
  10382. var _this = this;
  10383. _classCallCheck(this, XBreathPointManager);
  10384. E(this, "_scene");
  10385. E(this, "materialMap", new Map());
  10386. E(this, "breathPoints", new Map());
  10387. E(this, "_sceneManager");
  10388. E(this, "_allIds", new Set());
  10389. E(this, "_loopBPKeys", []);
  10390. E(this, "addBreathPoint", /*#__PURE__*/function () {
  10391. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  10392. 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;
  10393. return regenerator.wrap(function _callee$(_context) {
  10394. while (1) {
  10395. switch (_context.prev = _context.next) {
  10396. case 0:
  10397. t = [{
  10398. url: "https://static.xverse.cn/qqktv/texture.png"
  10399. }];
  10400. if (!(t.length <= 0)) {
  10401. _context.next = 4;
  10402. break;
  10403. }
  10404. logger$1.warn("[Engine] BreathPoint get texture list error: textureList.length <= 0"), new XBreathPointError("[Engine] BreathPoint get texture list error!");
  10405. return _context.abrupt("return");
  10406. case 4:
  10407. 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 ? {
  10408. pitch: -90,
  10409. yaw: 270,
  10410. roll: 0
  10411. } : _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;
  10412. if (!_this.breathPoints.get(n)) {
  10413. _context.next = 8;
  10414. break;
  10415. }
  10416. logger$1.warn("[Engine] Cannot add breathPoint with an existing id: [" + n + "]"), new XBreathPointError("[Engine] Cannot add breathPoint with an existing id: [" + n + "]");
  10417. return _context.abrupt("return");
  10418. case 8:
  10419. if (g) {
  10420. I = _this.castRay(new BABYLON.Vector3(l.x, l.y, l.z)) * scaleFromUE4toXverse;
  10421. I != 0 ? l.z = l.z - I + 1 : l.z = l.z + 1;
  10422. }
  10423. if (_this.materialMap.get(m)) {
  10424. _I = _this.materialMap.get(m);
  10425. _I.count = _I.count + 1, C = _I.mat;
  10426. } else {
  10427. _I2 = new BABYLON.Texture(o, _this._scene, !0, !0, BABYLON.Texture.BILINEAR_SAMPLINGMODE, null, function () {
  10428. logger$1.error("[Engine] Breathpoint create texture error."), new XBreathPointError("[Engine] Breathpoint create texture error.");
  10429. }, null, !0);
  10430. _I2.name = "TexBreathPoint_" + n, C = new BABYLON.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, {
  10431. mat: C,
  10432. count: 1,
  10433. lastRenderTime: Date.now(),
  10434. fps: d,
  10435. spriteWidthNumber: a,
  10436. spriteHeightNumber: s,
  10437. spriteSheet: o,
  10438. texture: _I2
  10439. });
  10440. }
  10441. A = new Array(6);
  10442. for (_I3 = 0; _I3 < 6; _I3++) {
  10443. A[_I3] = new BABYLON.Vector4(0, 0, 0, 0);
  10444. }
  10445. A[0] = new BABYLON.Vector4(0, 0, 1 / a, 1 / s), A[1] = new BABYLON.Vector4(0, 0, 1 / a, 1 / s);
  10446. S = {};
  10447. h > 0 && f > 0 ? S = {
  10448. width: h,
  10449. height: f,
  10450. depth: .01,
  10451. faceUV: A
  10452. } : S = {
  10453. size: c,
  10454. depth: .01,
  10455. faceUV: A
  10456. };
  10457. P = BABYLON.MeshBuilder.CreateBox(n, S, _this._scene);
  10458. P.material = C;
  10459. R = new XStaticMesh({
  10460. id: n,
  10461. mesh: P,
  10462. xtype: EMeshType.XBreathPoint,
  10463. skinInfo: T
  10464. });
  10465. M = u;
  10466. _ && (P.billboardMode = BABYLON.Mesh.BILLBOARDMODE_ALL, R.allowMove(), M = {
  10467. pitch: 0,
  10468. yaw: 270,
  10469. roll: 0
  10470. });
  10471. x = new BreathPoint({
  10472. type: m,
  10473. mesh: R,
  10474. id: n,
  10475. position: l,
  10476. rotation: M,
  10477. mat: C,
  10478. maxVisibleRegion: b,
  10479. scene: _this._scene,
  10480. skinInfo: T
  10481. });
  10482. _this.breathPoints.set(n, x), _this._allIds.add(n), v > 0 && setTimeout(function () {
  10483. _this.clearBreathPoints(n);
  10484. }, v * 1e3);
  10485. case 22:
  10486. case "end":
  10487. return _context.stop();
  10488. }
  10489. }
  10490. }, _callee);
  10491. }));
  10492. return function (_x) {
  10493. return _ref.apply(this, arguments);
  10494. };
  10495. }());
  10496. E(this, "reg_breathpoint_update", function () {
  10497. var e = new Date().getTime();
  10498. if (_this.materialMap != null) {
  10499. var _iterator = _createForOfIteratorHelper$4(_this.materialMap),
  10500. _step;
  10501. try {
  10502. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  10503. var _step$value = _slicedToArray(_step.value, 2),
  10504. t = _step$value[0],
  10505. r = _step$value[1];
  10506. 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);
  10507. }
  10508. } catch (err) {
  10509. _iterator.e(err);
  10510. } finally {
  10511. _iterator.f();
  10512. }
  10513. }
  10514. });
  10515. E(this, "reg_breathpoint_autovisible", function () {
  10516. if (_this._scene.getFrameId() % 2 == 0) if (_this._loopBPKeys.length == 0) _this._loopBPKeys = Array.from(_this._allIds);else {
  10517. var _e = _this._getMainPlayerPosition();
  10518. for (var t = 0; t < 5 && _this._loopBPKeys.length > 0; ++t) {
  10519. var r = _this._loopBPKeys.pop();
  10520. if (r != null) {
  10521. var n = _this.getBreathPoint(r);
  10522. if (n != null && n.maxvisibleregion >= 0 && n.mesh.visibility == 1) {
  10523. var o = n.mesh.position;
  10524. calcDistance3DVector(_e, o) >= n.maxvisibleregion ? n == null || n.removeFromScene() : n == null || n.addToScene();
  10525. }
  10526. }
  10527. }
  10528. }
  10529. });
  10530. this._sceneManager = e, this._scene = e.Scene, this._scene.registerBeforeRender(this.reg_breathpoint_update), this._scene.registerBeforeRender(this.reg_breathpoint_autovisible);
  10531. }
  10532. _createClass(XBreathPointManager, [{
  10533. key: "setAllBreathPointVisibility",
  10534. value: function setAllBreathPointVisibility(e) {
  10535. var _iterator2 = _createForOfIteratorHelper$4(this.breathPoints.entries()),
  10536. _step2;
  10537. try {
  10538. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  10539. var _step2$value = _slicedToArray(_step2.value, 2),
  10540. t = _step2$value[0],
  10541. r = _step2$value[1];
  10542. r.toggleVisibility(e);
  10543. }
  10544. } catch (err) {
  10545. _iterator2.e(err);
  10546. } finally {
  10547. _iterator2.f();
  10548. }
  10549. }
  10550. }, {
  10551. key: "toggleBPVisibilityBySkinInfo",
  10552. value: function toggleBPVisibilityBySkinInfo(e, t) {
  10553. var _iterator3 = _createForOfIteratorHelper$4(this.breathPoints.entries()),
  10554. _step3;
  10555. try {
  10556. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  10557. var _step3$value = _slicedToArray(_step3.value, 2),
  10558. r = _step3$value[0],
  10559. n = _step3$value[1];
  10560. n.skinInfo == e && n.toggleVisibility(t);
  10561. }
  10562. } catch (err) {
  10563. _iterator3.e(err);
  10564. } finally {
  10565. _iterator3.f();
  10566. }
  10567. }
  10568. }, {
  10569. key: "toggleBPVisibilityById",
  10570. value: function toggleBPVisibilityById(e, t) {
  10571. var r = this.getBreathPoint(e);
  10572. r != null && r.toggleVisibility(t);
  10573. }
  10574. }, {
  10575. key: "getBreathPointBySkinInfo",
  10576. value: function getBreathPointBySkinInfo(e) {
  10577. var t = [];
  10578. var _iterator4 = _createForOfIteratorHelper$4(this.breathPoints.entries()),
  10579. _step4;
  10580. try {
  10581. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  10582. var _step4$value = _slicedToArray(_step4.value, 2),
  10583. r = _step4$value[0],
  10584. n = _step4$value[1];
  10585. n.skinInfo == e && t.push(n);
  10586. }
  10587. } catch (err) {
  10588. _iterator4.e(err);
  10589. } finally {
  10590. _iterator4.f();
  10591. }
  10592. return t;
  10593. }
  10594. }, {
  10595. key: "getAllBreathPoint",
  10596. value: function getAllBreathPoint() {
  10597. return this.breathPoints;
  10598. }
  10599. }, {
  10600. key: "getBreathPoint",
  10601. value: function getBreathPoint(e) {
  10602. return this.breathPoints.get(e);
  10603. }
  10604. }, {
  10605. key: "delete",
  10606. value: function _delete(e) {
  10607. var t = this.breathPoints.get(e);
  10608. if (t != null) {
  10609. t.dispose(), this._allIds.delete(e);
  10610. var r = this.materialMap.get(t._type);
  10611. 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);
  10612. }
  10613. }
  10614. }, {
  10615. key: "castRay",
  10616. value: function castRay(e) {
  10617. var s;
  10618. e = ue4Position2Xverse({
  10619. x: e.x,
  10620. y: e.y,
  10621. z: e.z
  10622. });
  10623. var t = new BABYLON.Vector3(0, -1, 0),
  10624. r = new BABYLON.Ray(e, t, length),
  10625. n = [],
  10626. o = (s = this._sceneManager) == null ? void 0 : s.getGround({
  10627. x: e.x,
  10628. y: e.y,
  10629. z: e.z
  10630. });
  10631. var a = r.intersectsMeshes(o);
  10632. if (a.length > 0) {
  10633. var l = a[0];
  10634. if (l && l.pickedMesh) {
  10635. var u = l.distance;
  10636. t.y = 1;
  10637. var c = r.intersectsMeshes(n);
  10638. var h = 1e8;
  10639. if (c.length > 0) {
  10640. var f = c[0];
  10641. return f && f.pickedMesh && (h = -f.distance), h == 1e8 ? u : Math.abs(h) < Math.abs(u) ? h : u;
  10642. }
  10643. }
  10644. } else if (t.y = 1, a = r.intersectsMeshes(n), a.length > 0) {
  10645. var _l = a[0];
  10646. if (_l && _l.pickedMesh) return _l.distance;
  10647. }
  10648. return 0;
  10649. }
  10650. }, {
  10651. key: "changePickable",
  10652. value: function changePickable(e) {
  10653. var _iterator5 = _createForOfIteratorHelper$4(this.breathPoints.entries()),
  10654. _step5;
  10655. try {
  10656. for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
  10657. var _step5$value = _slicedToArray(_step5.value, 2),
  10658. t = _step5$value[0],
  10659. r = _step5$value[1];
  10660. r.changePickable(e);
  10661. }
  10662. } catch (err) {
  10663. _iterator5.e(err);
  10664. } finally {
  10665. _iterator5.f();
  10666. }
  10667. }
  10668. }, {
  10669. key: "clearBreathPoints",
  10670. value: function clearBreathPoints(e) {
  10671. logger$1.info("[Engine] clearBreathPoints: ".concat(e));
  10672. var _iterator6 = _createForOfIteratorHelper$4(this.breathPoints.entries()),
  10673. _step6;
  10674. try {
  10675. for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
  10676. var _step6$value = _slicedToArray(_step6.value, 2),
  10677. t = _step6$value[0],
  10678. r = _step6$value[1];
  10679. (r._type == e || r._id == e) && this.delete(r._id);
  10680. }
  10681. } catch (err) {
  10682. _iterator6.e(err);
  10683. } finally {
  10684. _iterator6.f();
  10685. }
  10686. }
  10687. }, {
  10688. key: "clearBreathPointsBySkinInfo",
  10689. value: function clearBreathPointsBySkinInfo(e) {
  10690. logger$1.info("[Engine] clearBreathPointsBySkinInfo: ".concat(e));
  10691. var _iterator7 = _createForOfIteratorHelper$4(this.breathPoints.entries()),
  10692. _step7;
  10693. try {
  10694. for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
  10695. var _step7$value = _slicedToArray(_step7.value, 2),
  10696. t = _step7$value[0],
  10697. r = _step7$value[1];
  10698. r.skinInfo == e && this.delete(r._id);
  10699. }
  10700. } catch (err) {
  10701. _iterator7.e(err);
  10702. } finally {
  10703. _iterator7.f();
  10704. }
  10705. }
  10706. }, {
  10707. key: "clearAllBreathPoints",
  10708. value: function clearAllBreathPoints() {
  10709. logger$1.info("[Engine] ClearAllBreathPoints");
  10710. var _iterator8 = _createForOfIteratorHelper$4(this.breathPoints.entries()),
  10711. _step8;
  10712. try {
  10713. for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
  10714. var _step8$value = _slicedToArray(_step8.value, 2),
  10715. e = _step8$value[0],
  10716. t = _step8$value[1];
  10717. this.delete(t._id);
  10718. }
  10719. } catch (err) {
  10720. _iterator8.e(err);
  10721. } finally {
  10722. _iterator8.f();
  10723. }
  10724. }
  10725. }, {
  10726. key: "_getMainPlayerPosition",
  10727. value: function _getMainPlayerPosition() {
  10728. var r;
  10729. var e = this._sceneManager.cameraComponent.MainCamera.position,
  10730. t = this._sceneManager.avatarComponent.getMainAvatar();
  10731. if (t != null && t != null) {
  10732. var n = (r = t == null ? void 0 : t.rootNode) == null ? void 0 : r.position;
  10733. if (n != null) return n;
  10734. }
  10735. return e;
  10736. }
  10737. }, {
  10738. key: "changeBreathPointPose",
  10739. value: function changeBreathPointPose(e, t, r) {
  10740. var n = new BABYLON.Vector3(e.position.x, e.position.y, e.position.z);
  10741. if (this.breathPoints.get(r) != null) {
  10742. logger$1.info("[Engine] changeBreathPointPose, id:".concat(r));
  10743. var o = this.breathPoints.get(r),
  10744. a = o.mesh.position;
  10745. var s = a.subtract(n);
  10746. s = BABYLON.Vector3.Normalize(s);
  10747. var l = BABYLON.Vector3.Distance(a, n),
  10748. u = new Ray(n, s, l),
  10749. c = this._scene.multiPickWithRay(u);
  10750. if (c) {
  10751. for (var h = 0; h < c.length; h++) {
  10752. if (c[h].pickedMesh != null && t.mesh.name.indexOf(c[h].pickedMesh.name) >= 0) {
  10753. var f = c[h].pickedPoint;
  10754. o.mesh.position = n.add(f.subtract(n).scale(.99)), this.breathPoints.set(r, o);
  10755. }
  10756. }
  10757. }
  10758. } else logger$1.warn("[Engine] changeBreathPointPose, id:".concat(r, " is not existing!"));
  10759. }
  10760. }]);
  10761. return XBreathPointManager;
  10762. }();
  10763. 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(_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; } } }; }
  10764. 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); }
  10765. 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; }
  10766. var XDecalManager = /*#__PURE__*/function () {
  10767. function XDecalManager(e) {
  10768. _classCallCheck(this, XDecalManager);
  10769. E(this, "scene");
  10770. E(this, "_decal");
  10771. E(this, "_mat");
  10772. E(this, "_sharedMat");
  10773. E(this, "_scenemanager");
  10774. this._decal = new Map(), this._mat = new Map(), this._sharedMat = new Map(), this._scenemanager = e, this.scene = e.Scene;
  10775. }
  10776. _createClass(XDecalManager, [{
  10777. key: "decals",
  10778. get: function get() {
  10779. return Array.from(this._decal.values());
  10780. }
  10781. }, {
  10782. key: "getMesh",
  10783. value: function getMesh() {
  10784. return this._decal;
  10785. }
  10786. }, {
  10787. key: "addDecal",
  10788. value: function () {
  10789. var _addDecal = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  10790. var _this = this;
  10791. var t, r, _e$skinInfo, n;
  10792. return regenerator.wrap(function _callee$(_context) {
  10793. while (1) {
  10794. switch (_context.prev = _context.next) {
  10795. case 0:
  10796. t = e.id, r = e.meshPath, _e$skinInfo = e.skinInfo, n = _e$skinInfo === void 0 ? "default" : _e$skinInfo;
  10797. 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) {
  10798. return _this._scenemanager.urlTransformer(r).then(function (s) {
  10799. return new Promise(function (l, u) {
  10800. if (_this._decal.get(t)) l(!0);else {
  10801. var c = new XDecal({
  10802. id: t,
  10803. scene: _this.scene,
  10804. meshPath: s,
  10805. skinInfo: n
  10806. });
  10807. _this._decal.set(t, c), c.loadModel().then(function () {
  10808. l(!0);
  10809. }).catch(function (h) {
  10810. 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)));
  10811. });
  10812. }
  10813. });
  10814. }).then(function (s) {
  10815. s == !0 ? o(!0) : a(!1);
  10816. }).catch(function (s) {
  10817. 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)));
  10818. });
  10819. })));
  10820. case 2:
  10821. case "end":
  10822. return _context.stop();
  10823. }
  10824. }
  10825. }, _callee, this);
  10826. }));
  10827. function addDecal(_x) {
  10828. return _addDecal.apply(this, arguments);
  10829. }
  10830. return addDecal;
  10831. }()
  10832. }, {
  10833. key: "setDecalTexture",
  10834. value: function setDecalTexture(e) {
  10835. var _this2 = this;
  10836. var t = e.id,
  10837. r = e.buffer,
  10838. _e$isDynamic = e.isDynamic,
  10839. n = _e$isDynamic === void 0 ? !1 : _e$isDynamic,
  10840. _e$width = e.width,
  10841. o = _e$width === void 0 ? 1100 : _e$width,
  10842. _e$height = e.height,
  10843. a = _e$height === void 0 ? 25 : _e$height,
  10844. _e$slots = e.slots,
  10845. s = _e$slots === void 0 ? 1 : _e$slots,
  10846. _e$visibleSlots = e.visibleSlots,
  10847. l = _e$visibleSlots === void 0 ? 1 : _e$visibleSlots,
  10848. u = !0;
  10849. return logger.info("[Engine] setDecalTexture wiht id:[".concat(t, "]")), new Promise(function (c, h) {
  10850. var f = _this2._decal.get(t);
  10851. if (f != null) {
  10852. if (_this2._mat.get(t) != null) _this2.changeDecalTexture({
  10853. id: t,
  10854. buffer: r,
  10855. isUrl: u,
  10856. isDynamic: n,
  10857. width: o,
  10858. height: a,
  10859. slots: s,
  10860. visibleSlots: l
  10861. }), c(!0);else {
  10862. var d = new XDecalMaterial(t, _this2.scene);
  10863. d.setTexture(r, u, n, o, a, s, l).then(function () {
  10864. f.setMat(d.getMat()), _this2._decal.set(t, f), _this2._mat.set(t, d), c(!0);
  10865. }).catch(function (_) {
  10866. logger.error("[Engine] setDecalTexture Error! " + _), h(new XDecalTextureError("[Engine] decal set texture error! ".concat(_)));
  10867. });
  10868. }
  10869. } else logger.error("[Engine] Error! decal id: [" + t + "] is not find!"), h(new XDecalTextureError("[Engine] decal id: [".concat(t, "] is not find!")));
  10870. });
  10871. }
  10872. }, {
  10873. key: "shareDecal",
  10874. value: function () {
  10875. var _shareDecal = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e) {
  10876. var _this3 = this;
  10877. var t, r, n, _e$skinInfo2, o;
  10878. return regenerator.wrap(function _callee2$(_context2) {
  10879. while (1) {
  10880. switch (_context2.prev = _context2.next) {
  10881. case 0:
  10882. t = e.idTar, r = e.meshPath, n = e.idSrc, _e$skinInfo2 = e.skinInfo, o = _e$skinInfo2 === void 0 ? "default" : _e$skinInfo2;
  10883. 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) {
  10884. return _this3._scenemanager.urlTransformer(r).then(function (l) {
  10885. var u = new XDecal({
  10886. id: t,
  10887. scene: _this3.scene,
  10888. meshPath: l,
  10889. skinInfo: o
  10890. }),
  10891. c = _this3._mat.get(n);
  10892. c != null && (u.setMat(c.getMat()), u.sourceMatId = n, _this3._decal.set(t, u), _this3.addSharedMatCount(n)), a(!0);
  10893. }).catch(function (l) {
  10894. s(new XDecalError("[Engine] decal shareDecal error! ".concat(l)));
  10895. });
  10896. })) : (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!"))));
  10897. case 2:
  10898. case "end":
  10899. return _context2.stop();
  10900. }
  10901. }
  10902. }, _callee2, this);
  10903. }));
  10904. function shareDecal(_x2) {
  10905. return _shareDecal.apply(this, arguments);
  10906. }
  10907. return shareDecal;
  10908. }()
  10909. }, {
  10910. key: "changeDecalModel",
  10911. value: function () {
  10912. var _changeDecalModel = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  10913. var _this4 = this;
  10914. var t, r, n;
  10915. return regenerator.wrap(function _callee3$(_context3) {
  10916. while (1) {
  10917. switch (_context3.prev = _context3.next) {
  10918. case 0:
  10919. t = e.id, r = e.meshPath, n = this._decal.get(t);
  10920. return _context3.abrupt("return", new Promise(function (o, a) {
  10921. return n != null ? (logger.info("[Engine] changeDecalModel id:".concat(t)), n.changeModel(r).then(function () {
  10922. _this4._decal.set(t, n), o(!0);
  10923. })) : (logger.warn("[Engine] changeDecalModel id:".concat(t, " is not exist")), a("[Engine] changeDecalModel id:".concat(t, " is not exist")));
  10924. }));
  10925. case 2:
  10926. case "end":
  10927. return _context3.stop();
  10928. }
  10929. }
  10930. }, _callee3, this);
  10931. }));
  10932. function changeDecalModel(_x3) {
  10933. return _changeDecalModel.apply(this, arguments);
  10934. }
  10935. return changeDecalModel;
  10936. }()
  10937. }, {
  10938. key: "changeDecalTexture",
  10939. value: function changeDecalTexture(e) {
  10940. var t = e.id,
  10941. r = e.buffer,
  10942. _e$isUrl = e.isUrl,
  10943. n = _e$isUrl === void 0 ? !1 : _e$isUrl,
  10944. _e$isDynamic2 = e.isDynamic,
  10945. o = _e$isDynamic2 === void 0 ? !1 : _e$isDynamic2,
  10946. _e$width2 = e.width,
  10947. a = _e$width2 === void 0 ? 1110 : _e$width2,
  10948. _e$height2 = e.height,
  10949. s = _e$height2 === void 0 ? 25 : _e$height2,
  10950. _e$slots2 = e.slots,
  10951. l = _e$slots2 === void 0 ? 1 : _e$slots2,
  10952. _e$visibleSlots2 = e.visibleSlots,
  10953. u = _e$visibleSlots2 === void 0 ? 1 : _e$visibleSlots2,
  10954. c = this._mat.get(t);
  10955. 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"));
  10956. }
  10957. }, {
  10958. key: "deleteDecal",
  10959. value: function deleteDecal(e) {
  10960. var t, r;
  10961. if (this._decal.has(e)) {
  10962. var n = this._decal.get(e);
  10963. 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);
  10964. }
  10965. }
  10966. }, {
  10967. key: "deleteDecalBySkinInfo",
  10968. value: function deleteDecalBySkinInfo(e) {
  10969. var _iterator = _createForOfIteratorHelper$3(this._decal.entries()),
  10970. _step;
  10971. try {
  10972. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  10973. var _step$value = _slicedToArray(_step.value, 2),
  10974. t = _step$value[0],
  10975. r = _step$value[1];
  10976. r.skinInfo == e && this.deleteDecal(t);
  10977. }
  10978. } catch (err) {
  10979. _iterator.e(err);
  10980. } finally {
  10981. _iterator.f();
  10982. }
  10983. }
  10984. }, {
  10985. key: "addSharedMatCount",
  10986. value: function addSharedMatCount(e) {
  10987. var t = this._sharedMat.get(e);
  10988. t != null ? this._sharedMat.set(e, t + 1) : this._sharedMat.set(e, 1);
  10989. }
  10990. }, {
  10991. key: "minusSharedMatCount",
  10992. value: function minusSharedMatCount(e) {
  10993. var r;
  10994. var t = this._sharedMat.get(e);
  10995. 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)));
  10996. }
  10997. }, {
  10998. key: "toggle",
  10999. value: function toggle(e, t) {
  11000. var r = this._decal.get(e);
  11001. r == null || r.toggle(t);
  11002. }
  11003. }, {
  11004. key: "toggleDecalBySkinInfo",
  11005. value: function toggleDecalBySkinInfo(e, t) {
  11006. var _iterator2 = _createForOfIteratorHelper$3(this._decal.entries()),
  11007. _step2;
  11008. try {
  11009. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  11010. var _step2$value = _slicedToArray(_step2.value, 2),
  11011. r = _step2$value[0],
  11012. n = _step2$value[1];
  11013. n.skinInfo == e && n.toggle(t);
  11014. }
  11015. } catch (err) {
  11016. _iterator2.e(err);
  11017. } finally {
  11018. _iterator2.f();
  11019. }
  11020. }
  11021. }, {
  11022. key: "updateTexAsWords",
  11023. value: function updateTexAsWords(e, t) {
  11024. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  11025. var _r$clearArea = r.clearArea,
  11026. n = _r$clearArea === void 0 ? !0 : _r$clearArea,
  11027. _r$w = r.w,
  11028. o = _r$w === void 0 ? 480 : _r$w,
  11029. _r$h = r.h,
  11030. a = _r$h === void 0 ? 480 : _r$h,
  11031. _r$y = r.y,
  11032. s = _r$y === void 0 ? a / 2 : _r$y,
  11033. _r$fontsize = r.fontsize,
  11034. l = _r$fontsize === void 0 ? 70 : _r$fontsize,
  11035. _r$slots = r.slots,
  11036. u = _r$slots === void 0 ? 1 : _r$slots,
  11037. _r$visibleSlots = r.visibleSlots,
  11038. c = _r$visibleSlots === void 0 ? 1 : _r$visibleSlots,
  11039. _r$font = r.font,
  11040. h = _r$font === void 0 ? "black-body" : _r$font,
  11041. _r$color = r.color,
  11042. f = _r$color === void 0 ? "white" : _r$color,
  11043. _r$fontweight = r.fontweight,
  11044. d = _r$fontweight === void 0 ? 100 : _r$fontweight;
  11045. var _r$x = r.x,
  11046. _ = _r$x === void 0 ? o / 2 : _r$x;
  11047. var g = this._mat.get(e);
  11048. if (g) {
  11049. _ == -1 && (_ = (g.getUOffset() + c / u) % 1 * o * u);
  11050. var v = g.getMat().diffuseTexture,
  11051. y = v.getContext();
  11052. 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();
  11053. }
  11054. }
  11055. }, {
  11056. key: "updateTexAsImg",
  11057. value: function () {
  11058. var _updateTexAsImg = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e, t) {
  11059. var _this5 = this;
  11060. var r,
  11061. _r$clearArea2,
  11062. n,
  11063. _r$w2,
  11064. o,
  11065. _r$h2,
  11066. a,
  11067. _r$x2,
  11068. s,
  11069. _r$y2,
  11070. l,
  11071. _r$clearW,
  11072. u,
  11073. _r$clearH,
  11074. c,
  11075. _args4 = arguments;
  11076. return regenerator.wrap(function _callee4$(_context4) {
  11077. while (1) {
  11078. switch (_context4.prev = _context4.next) {
  11079. case 0:
  11080. r = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
  11081. _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;
  11082. 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) {
  11083. return _this5._scenemanager.urlTransformer(t).then(function (d) {
  11084. return new Promise(function (_, g) {
  11085. var m = _this5._mat.get(e);
  11086. if (m) {
  11087. var y = m.getMat().diffuseTexture;
  11088. if (typeof t == "string") {
  11089. var b = new Image();
  11090. b.crossOrigin = "anonymous", b.src = d, b.onload = function () {
  11091. var T = y.getContext();
  11092. 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);
  11093. }, b.onerror = function () {
  11094. 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!")));
  11095. };
  11096. } 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!")));
  11097. } 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!")));
  11098. }).then(function (_) {
  11099. _ == !0 ? h(!0) : (logger.error("[Engine] updateTexAsImg Error. id: [".concat(e, "] !")), f(new XDecalError("[Engine] updateTexAsImg error! id: [".concat(e, "]"))));
  11100. }).catch(function (_) {
  11101. logger.error("[Engine] updateTexAsImg Error. id: [".concat(e, "]. ").concat(_));
  11102. });
  11103. });
  11104. }));
  11105. case 3:
  11106. case "end":
  11107. return _context4.stop();
  11108. }
  11109. }
  11110. }, _callee4);
  11111. }));
  11112. function updateTexAsImg(_x4, _x5) {
  11113. return _updateTexAsImg.apply(this, arguments);
  11114. }
  11115. return updateTexAsImg;
  11116. }()
  11117. }, {
  11118. key: "startAnime",
  11119. value: function startAnime(e, t) {
  11120. logger.info("[Engine] Decal Start Anime. [".concat(e, "]"));
  11121. var _t$speed = t.speed,
  11122. r = _t$speed === void 0 ? .001 : _t$speed,
  11123. n = t.callback,
  11124. o = this._mat.get(e);
  11125. 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!")));
  11126. }
  11127. }]);
  11128. return XDecalManager;
  11129. }();
  11130. var PoolObject = /*#__PURE__*/function () {
  11131. function PoolObject(e, t, r) {
  11132. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !0;
  11133. _classCallCheck(this, PoolObject);
  11134. E(this, "data");
  11135. E(this, "nextFree");
  11136. E(this, "previousFree");
  11137. E(this, "free");
  11138. this.data = e, this.nextFree = t, this.previousFree = r, this.free = n;
  11139. }
  11140. _createClass(PoolObject, [{
  11141. key: "dispose",
  11142. value: function dispose() {
  11143. this.data && this.data instanceof BABYLON.Mesh && this.data.dispose(!0, !0), this.previousFree = null, this.nextFree = null, this.data = null;
  11144. }
  11145. }]);
  11146. return PoolObject;
  11147. }();
  11148. var Pool = /*#__PURE__*/function () {
  11149. function Pool(e, t, r, n) {
  11150. _classCallCheck(this, Pool);
  11151. this.lastFree = null;
  11152. this.nextFree = null;
  11153. this._pool = [], this.objCreator = e, this.objReseter = t;
  11154. for (var _len = arguments.length, o = new Array(_len > 4 ? _len - 4 : 0), _key = 4; _key < _len; _key++) {
  11155. o[_key - 4] = arguments[_key];
  11156. }
  11157. for (var a = 0; a < n; a++) {
  11158. this.addNewObject(this.newPoolObject.apply(this, o));
  11159. }
  11160. this.capacity = r;
  11161. }
  11162. _createClass(Pool, [{
  11163. key: "addNewObject",
  11164. value: function addNewObject(e) {
  11165. return this._pool.push(e), this.release(e), e;
  11166. }
  11167. }, {
  11168. key: "release",
  11169. value: function release(e) {
  11170. 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);
  11171. }
  11172. }, {
  11173. key: "getFree",
  11174. value: function getFree() {
  11175. var t = this.nextFree ? this.nextFree : this.addNewObject(this.newPoolObject.apply(this, arguments));
  11176. return t.free = !1, this.nextFree = t.nextFree, this.nextFree || (this.lastFree = null), t;
  11177. }
  11178. }, {
  11179. key: "newPoolObject",
  11180. value: function newPoolObject() {
  11181. var t = this.objCreator.apply(this, arguments);
  11182. return new PoolObject(t, this.nextFree, this.lastFree);
  11183. }
  11184. }, {
  11185. key: "releaseAll",
  11186. value: function releaseAll() {
  11187. var _this = this;
  11188. this._pool.forEach(function (e) {
  11189. return _this.release(e);
  11190. });
  11191. }
  11192. }, {
  11193. key: "clean",
  11194. value: function clean() {
  11195. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  11196. var r = this.nextFree;
  11197. if (!r) return;
  11198. var n = 0;
  11199. for (; r;) {
  11200. n += 1, r = r.nextFree;
  11201. }
  11202. var o = !1;
  11203. if (n > e && this._pool.length > this.capacity && (o = !0), o) for (r = this.nextFree; r;) {
  11204. r.free = !1, this.nextFree = r.nextFree;
  11205. var a = this._pool.indexOf(r);
  11206. this._pool.splice(a, 1), this.nextFree || (this.lastFree = null), r == null || r.dispose(), r = this.nextFree;
  11207. }
  11208. }
  11209. }]);
  11210. return Pool;
  11211. }();
  11212. var BillboardStatus = {
  11213. SHOW: 1,
  11214. HIDE: 0,
  11215. DISPOSE: -1
  11216. };
  11217. 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); }; }
  11218. 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; } }
  11219. var AvatarAnimationError$1 = /*#__PURE__*/function (_XverseError) {
  11220. _inherits(AvatarAnimationError, _XverseError);
  11221. var _super = _createSuper$4(AvatarAnimationError);
  11222. function AvatarAnimationError(e) {
  11223. _classCallCheck(this, AvatarAnimationError);
  11224. return _super.call(this, 5101, e || "[Engine] \u89D2\u8272\u52A8\u753B\u64AD\u653E\u5931\u8D25");
  11225. }
  11226. return _createClass(AvatarAnimationError);
  11227. }(XverseError);
  11228. 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; } } }; }
  11229. 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); }
  11230. 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; }
  11231. var XAnimationController = /*#__PURE__*/function () {
  11232. function XAnimationController(e) {
  11233. var _this = this;
  11234. _classCallCheck(this, XAnimationController);
  11235. E(this, "iBodyAnim");
  11236. E(this, "animations", []);
  11237. E(this, "defaultAnimation", "Idle");
  11238. E(this, "onPlay", "Idle");
  11239. E(this, "loop", !0);
  11240. E(this, "animationExtras", []);
  11241. E(this, "enableBlend", !1);
  11242. E(this, "enableSkLod", !1);
  11243. E(this, "_boneMap", new Map());
  11244. E(this, "_lodMask", new Map());
  11245. E(this, "activeFaceAnimation");
  11246. E(this, "iFaceAnim");
  11247. E(this, "_scene");
  11248. E(this, "_avatar");
  11249. E(this, "onPlayObservable", new Observable());
  11250. E(this, "postObserver");
  11251. E(this, "playAnimation", function (e, t) {
  11252. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  11253. var n = arguments.length > 3 ? arguments[3] : undefined;
  11254. var o = arguments.length > 4 ? arguments[4] : undefined;
  11255. var a = arguments.length > 5 ? arguments[5] : undefined;
  11256. return new Promise(function (s, l) {
  11257. if (_this._isPlaying(e, r) || (_this._registerAnimInfo(e, t, r, n, o, a), !_this._isAnimate())) return s(null);
  11258. _this._prerocess(e, t), _this._avatar.avatarManager.loadAnimation(_this._avatar.avatarType, e).then(function (u) {
  11259. if (!u) return l(new AvatarAnimationError$1("animation group does not exist"));
  11260. var c = _this._mappingSkeleton(u);
  11261. if (!c) return l(new AvatarAnimationError$1("mapping animation failed"));
  11262. if (c && _this._isAnimationValid(c)) return c.dispose(), l(new AvatarAnimationError$1("mapping animation failed"));
  11263. if (_this.enableSkLod && _this.skeletonMask(c, r), _this.detachAnimation(r), r == 0 ? _this.iBodyAnim.animGroup = c : r == 1 && (_this.iFaceAnim.animGroup = c), !_this._playAnimation(r)) return l(new AvatarAnimationError$1("[Engine] play animation failed, animtion resource does not match current character"));
  11264. _this._playEffect(), _this.postObserver = c.onAnimationEndObservable.addOnce(function () {
  11265. return _this._postprocess(r), s(null);
  11266. });
  11267. });
  11268. });
  11269. });
  11270. E(this, "stopAnimation", function () {
  11271. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  11272. var t, r, n, o;
  11273. switch (e) {
  11274. case 0:
  11275. _this.iBodyAnim && _this.iBodyAnim.animGroup && ((t = _this.iBodyAnim) == null || t.animGroup.stop());
  11276. break;
  11277. case 1:
  11278. _this.iFaceAnim && _this.iFaceAnim.animGroup && ((r = _this.iFaceAnim) == null || r.animGroup.stop());
  11279. break;
  11280. case 2:
  11281. _this.iBodyAnim && _this.iBodyAnim.animGroup && ((n = _this.iBodyAnim) == null || n.animGroup.stop()), _this.iFaceAnim && _this.iFaceAnim.animGroup && ((o = _this.iFaceAnim) == null || o.animGroup.stop());
  11282. break;
  11283. }
  11284. });
  11285. E(this, "pauseAnimation", function () {
  11286. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  11287. var t, r, n, o;
  11288. switch (e) {
  11289. case 0:
  11290. _this.iBodyAnim && _this.iBodyAnim.animGroup && ((t = _this.iBodyAnim) == null || t.animGroup.pause());
  11291. break;
  11292. case 1:
  11293. _this.iFaceAnim && _this.iFaceAnim.animGroup && ((r = _this.iFaceAnim) == null || r.animGroup.pause());
  11294. break;
  11295. case 2:
  11296. _this.iBodyAnim && _this.iBodyAnim.animGroup && ((n = _this.iBodyAnim) == null || n.animGroup.pause()), _this.iFaceAnim && _this.iFaceAnim.animGroup && ((o = _this.iFaceAnim) == null || o.animGroup.pause());
  11297. break;
  11298. }
  11299. });
  11300. E(this, "resetAnimation", function () {
  11301. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  11302. var t, r, n, o;
  11303. switch (e) {
  11304. case 0:
  11305. _this.iBodyAnim && _this.iBodyAnim.animGroup && ((t = _this.iBodyAnim) == null || t.animGroup.reset());
  11306. break;
  11307. case 1:
  11308. _this.iFaceAnim && _this.iFaceAnim.animGroup && ((r = _this.iFaceAnim) == null || r.animGroup.reset());
  11309. break;
  11310. case 2:
  11311. _this.iBodyAnim && _this.iBodyAnim.animGroup && ((n = _this.iBodyAnim) == null || n.animGroup.reset()), _this.iFaceAnim && _this.iFaceAnim.animGroup && ((o = _this.iFaceAnim) == null || o.animGroup.reset());
  11312. break;
  11313. }
  11314. });
  11315. this._avatar = e, this._scene = e.avatarManager.scene, this.animationExtras.push(action.Cheering.animName), this._boneMap = new Map();
  11316. }
  11317. _createClass(XAnimationController, [{
  11318. key: "_isPlaying",
  11319. value: function _isPlaying(e, t) {
  11320. return t == 0 && this.iBodyAnim != null && this.iBodyAnim.animGroup && e == this.iBodyAnim.name ? !0 : !!(t == 1 && this.iFaceAnim != null && this.iFaceAnim.animGroup && e == this.iFaceAnim.name);
  11321. }
  11322. }, {
  11323. key: "activeAnimation",
  11324. value: function activeAnimation() {
  11325. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  11326. var t, r;
  11327. switch (e) {
  11328. case 0:
  11329. return (t = this.iBodyAnim) == null ? void 0 : t.animGroup;
  11330. case 1:
  11331. return (r = this.iFaceAnim) == null ? void 0 : r.animGroup;
  11332. default:
  11333. return;
  11334. }
  11335. }
  11336. }, {
  11337. key: "enableAnimationBlend",
  11338. value: function enableAnimationBlend() {
  11339. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : .1;
  11340. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  11341. var r, n, o, a;
  11342. if (t == 0 && ((r = this.iBodyAnim) == null ? void 0 : r.animGroup)) {
  11343. var _iterator = _createForOfIteratorHelper$2((n = this.iBodyAnim) == null ? void 0 : n.animGroup.targetedAnimations),
  11344. _step;
  11345. try {
  11346. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  11347. var s = _step.value;
  11348. s.animation.enableBlending = !0, s.animation.blendingSpeed = e;
  11349. }
  11350. } catch (err) {
  11351. _iterator.e(err);
  11352. } finally {
  11353. _iterator.f();
  11354. }
  11355. } else if (t == 0 && ((o = this.iFaceAnim) == null ? void 0 : o.animGroup)) {
  11356. var _iterator2 = _createForOfIteratorHelper$2((a = this.iFaceAnim) == null ? void 0 : a.animGroup.targetedAnimations),
  11357. _step2;
  11358. try {
  11359. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  11360. var _s = _step2.value;
  11361. _s.animation.enableBlending = !0, _s.animation.blendingSpeed = e;
  11362. }
  11363. } catch (err) {
  11364. _iterator2.e(err);
  11365. } finally {
  11366. _iterator2.f();
  11367. }
  11368. }
  11369. }
  11370. }, {
  11371. key: "disableAnimationBlend",
  11372. value: function disableAnimationBlend() {
  11373. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  11374. var t, r, n, o;
  11375. if (e == 0 && ((t = this.iBodyAnim) == null ? void 0 : t.animGroup)) {
  11376. var _iterator3 = _createForOfIteratorHelper$2((r = this.iBodyAnim) == null ? void 0 : r.animGroup.targetedAnimations),
  11377. _step3;
  11378. try {
  11379. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  11380. var a = _step3.value;
  11381. a.animation.enableBlending = !1;
  11382. }
  11383. } catch (err) {
  11384. _iterator3.e(err);
  11385. } finally {
  11386. _iterator3.f();
  11387. }
  11388. } else if (e == 0 && ((n = this.iFaceAnim) == null ? void 0 : n.animGroup)) {
  11389. var _iterator4 = _createForOfIteratorHelper$2((o = this.iFaceAnim) == null ? void 0 : o.animGroup.targetedAnimations),
  11390. _step4;
  11391. try {
  11392. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  11393. var _a = _step4.value;
  11394. _a.animation.enableBlending = !1;
  11395. }
  11396. } catch (err) {
  11397. _iterator4.e(err);
  11398. } finally {
  11399. _iterator4.f();
  11400. }
  11401. }
  11402. }
  11403. }, {
  11404. key: "skeletonMask",
  11405. value: function skeletonMask(e) {
  11406. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  11407. if (t == 0) {
  11408. var r = this._lodMask.get(this._avatar.distLevel);
  11409. if (r) for (var n = 0; n < e.targetedAnimations.length; ++n) {
  11410. r.includes(e.targetedAnimations[n].target.name) || (e.targetedAnimations.splice(n, 1), n--);
  11411. }
  11412. return !0;
  11413. }
  11414. return !1;
  11415. }
  11416. }, {
  11417. key: "detachAnimation",
  11418. value: function detachAnimation() {
  11419. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2;
  11420. var t, r;
  11421. switch (e) {
  11422. case 0:
  11423. this.iBodyAnim && this.iBodyAnim.animGroup && (this.iBodyAnim.animGroup._parentContainer.xReferenceCount && this.iBodyAnim.animGroup._parentContainer.xReferenceCount--, this.iBodyAnim.animGroup.stop(), this.iBodyAnim.animGroup.dispose(), this.iBodyAnim.animGroup = void 0);
  11424. break;
  11425. case 1:
  11426. this.iFaceAnim && this.iFaceAnim.animGroup && (this.iFaceAnim.animGroup._parentContainer.xReferenceCount && this.iFaceAnim.animGroup._parentContainer.xReferenceCount--, this.iFaceAnim.animGroup.stop(), this.iFaceAnim.animGroup.dispose(), this.iFaceAnim.animGroup = void 0);
  11427. break;
  11428. case 2:
  11429. this.iBodyAnim && this.iBodyAnim.animGroup && (this.iBodyAnim.animGroup._parentContainer.xReferenceCount && this.iBodyAnim.animGroup._parentContainer.xReferenceCount--, (t = this.iBodyAnim) == null || t.animGroup.stop(), (r = this.iBodyAnim) == null || r.animGroup.dispose(), this.iBodyAnim.animGroup = void 0), this.iFaceAnim && this.iFaceAnim.animGroup && (this.iFaceAnim.animGroup._parentContainer.xReferenceCount && this.iFaceAnim.animGroup._parentContainer.xReferenceCount--, this.iFaceAnim.animGroup.stop(), this.iFaceAnim.animGroup.dispose(), this.iFaceAnim.animGroup = void 0);
  11430. break;
  11431. }
  11432. }
  11433. }, {
  11434. key: "blendAnimation",
  11435. value: function blendAnimation() {}
  11436. }, {
  11437. key: "getAnimation",
  11438. value: function getAnimation(e, t) {
  11439. return avatarLoader.animations.get(getAnimationKey(t, e));
  11440. }
  11441. }, {
  11442. key: "_mappingSkeleton",
  11443. value: function _mappingSkeleton(e) {
  11444. var _this2 = this;
  11445. if (e) {
  11446. var t = e.clone(e.name, function (r) {
  11447. var o, a, s;
  11448. var n = r.name.split(" ").length > 2 ? r.name.split(" ")[2] : r.name;
  11449. if (_this2._boneMap.size === ((o = _this2._avatar.skeleton) == null ? void 0 : o.bones.length)) return _this2._boneMap.get(n);
  11450. {
  11451. var l = (s = (a = _this2._avatar.skeleton) == null ? void 0 : a.bones.find(function (u) {
  11452. return u.name === r.name || u.name === r.name.split(" ")[2];
  11453. })) == null ? void 0 : s.getTransformNode();
  11454. return l && (l.name = n, _this2._boneMap.set(n, l)), l;
  11455. }
  11456. });
  11457. return t._parentContainer = e._parentContainer, t;
  11458. } else return;
  11459. }
  11460. }, {
  11461. key: "removeAnimation",
  11462. value: function removeAnimation(e) {
  11463. var t = avatarLoader.containers.get(e.name);
  11464. t && (t.dispose(), avatarLoader.containers.delete(e.name), avatarLoader.animations.delete(getAnimationKey(e.name, e.skType)));
  11465. }
  11466. }, {
  11467. key: "_setPosition",
  11468. value: function _setPosition(e, t) {
  11469. this._avatar.priority === 0 && this._avatar.isRender && e === this.defaultAnimation && e != this.onPlay && !this._avatar.isSelected && this._avatar.setPosition(this._avatar.position, !0);
  11470. }
  11471. }, {
  11472. key: "_registerAnimInfo",
  11473. value: function _registerAnimInfo(e, t) {
  11474. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  11475. var n = arguments.length > 3 ? arguments[3] : undefined;
  11476. var o = arguments.length > 4 ? arguments[4] : undefined;
  11477. var a = arguments.length > 5 ? arguments[5] : undefined;
  11478. var s = {
  11479. name: e,
  11480. skType: this._avatar.avatarType,
  11481. loop: t,
  11482. playSpeed: n,
  11483. currentFrame: 0,
  11484. startFrame: o,
  11485. endFrame: a
  11486. };
  11487. r == 0 ? this.iBodyAnim == null ? this.iBodyAnim = s : (this.iBodyAnim.name = e, this.iBodyAnim.skType = this._avatar.avatarType, this.iBodyAnim.loop = t, this.iBodyAnim.playSpeed = n, this.iBodyAnim.currentFrame = 0, this.iBodyAnim.startFrame = o, this.iBodyAnim.endFrame = a) : r == 1 && (this.iFaceAnim == null ? this.iFaceAnim = s : (this.iFaceAnim.name = e, this.iFaceAnim.skType = this._avatar.avatarType, this.iFaceAnim.loop = t, this.iFaceAnim.playSpeed = n, this.iFaceAnim.currentFrame = 0, this.iFaceAnim.startFrame = o, this.iFaceAnim.endFrame = a)), this.onPlay = e, this.loop = t;
  11488. }
  11489. }, {
  11490. key: "_isAnimate",
  11491. value: function _isAnimate() {
  11492. var e;
  11493. return !(!this._avatar.isRender || !this._avatar.skeleton || ((e = this._avatar.rootNode) == null ? void 0 : e.getChildMeshes().length) == 0);
  11494. }
  11495. }, {
  11496. key: "_prerocess",
  11497. value: function _prerocess(e, t) {
  11498. this._avatar.isRayCastEnable && this._setPosition(e, t), this._avatar.priority === 0 && logger$1.info("start play animation: ".concat(e, " on avatar ").concat(this._avatar.id));
  11499. }
  11500. }, {
  11501. key: "_playEffect",
  11502. value: function _playEffect() {
  11503. var _this3 = this;
  11504. this.animationExtras.indexOf(this.iBodyAnim.name) != -1 && action.Cheering.attachPair.forEach(function (t) {
  11505. _this3._avatar.attachExtraProp(t.obj, t.bone, new BABYLON.Vector3(t.offset.x, t.offset.y, t.offset.z), new BABYLON.Vector3(t.rotate.x, t.rotate.y, t.rotate.z)), _this3._avatar.showExtra(t.obj);
  11506. });
  11507. }
  11508. }, {
  11509. key: "_playAnimation",
  11510. value: function _playAnimation() {
  11511. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  11512. var t, r;
  11513. return e == 0 && this.iBodyAnim && ((t = this.iBodyAnim) == null ? void 0 : t.animGroup) ? (this.onPlayObservable.notifyObservers(this._scene), this.iBodyAnim.animGroup.start(this.loop, this.iBodyAnim.playSpeed, this.iBodyAnim.startFrame, this.iBodyAnim.endFrame, !1), !0) : e == 1 && this.iFaceAnim && ((r = this.iFaceAnim) == null ? void 0 : r.animGroup) ? (this.iFaceAnim.animGroup.start(this.loop, this.iFaceAnim.playSpeed, this.iFaceAnim.startFrame, this.iFaceAnim.endFrame, !1), !0) : !1;
  11514. }
  11515. }, {
  11516. key: "_postprocess",
  11517. value: function _postprocess(e) {
  11518. var r, n;
  11519. var t;
  11520. e == 0 ? t = (r = this.iBodyAnim) == null ? void 0 : r.name : e == 1 && (t = (n = this.iFaceAnim) == null ? void 0 : n.name), t === action.Cheering.animName && this._avatar.disposeExtra();
  11521. }
  11522. }, {
  11523. key: "_isAnimationValid",
  11524. value: function _isAnimationValid(e) {
  11525. for (var t = 0; t < e.targetedAnimations.length; ++t) {
  11526. if (e.targetedAnimations[t].target) return !1;
  11527. }
  11528. return !0;
  11529. }
  11530. }]);
  11531. return XAnimationController;
  11532. }();
  11533. var XAvatarComopnent = /*#__PURE__*/function () {
  11534. function XAvatarComopnent() {
  11535. _classCallCheck(this, XAvatarComopnent);
  11536. E(this, "resourceIdList", []);
  11537. E(this, "skeleton");
  11538. E(this, "extraProp");
  11539. E(this, "extras", []);
  11540. E(this, "body");
  11541. }
  11542. _createClass(XAvatarComopnent, [{
  11543. key: "addBodyComp",
  11544. value: function addBodyComp(e, t) {
  11545. // console.error(this, e, t)
  11546. return !e.rootNode || t.root.getChildMeshes().length === 0 ? (t.isRender = !1, !1) : (this.body = t, this.body.root.parent = e.rootNode, t.isRender = !0, this.body.root.getChildMeshes()[0] && (this.body.root.getChildMeshes()[0].xtype = EMeshType.XAvatar, this.body.root.getChildMeshes()[0].xid = e.id), this.skeleton = t.skeleton, !0);
  11547. }
  11548. }, {
  11549. key: "addClothesComp",
  11550. value: function addClothesComp(e, t) {
  11551. var _this = this;
  11552. // console.error(t.root.name)
  11553. // console.error(this, e, t)
  11554. return !e.rootNode || !this.skeleton || !t.root ? (t.isRender = !1, !1) : (t.root.xtype = EMeshType.XAvatar, t.root.xid = e.id, t.isRender = !0, t.root.parent = e.rootNode.getChildMeshes()[0], this.resourceIdList.push(t), t.root.skeleton = this.skeleton, t.root.getChildMeshes().forEach(function (r) {
  11555. r.skeleton = _this.skeleton;
  11556. }), !0);
  11557. }
  11558. }, {
  11559. key: "clearClothesComp",
  11560. value: function clearClothesComp(e) {
  11561. e.root.getChildMeshes().forEach(function (t) {
  11562. t.skeleton = null, t.dispose(), t.xid = void 0;
  11563. }), e.root.dispose(), this.resourceIdList = this.resourceIdList.filter(function (t) {
  11564. return t.uId != e.uId;
  11565. });
  11566. }
  11567. }, {
  11568. key: "clearAllClothesComps",
  11569. value: function clearAllClothesComps() {
  11570. this.resourceIdList.forEach(function (e) {
  11571. var t;
  11572. e.root.parent = null, e.root._parentContainer.xReferenceCount && (e.root._parentContainer.xReferenceCount--, e.root._parentContainer = null), e.isRender = !1, e.isSelected = !1, e.root.getChildMeshes().forEach(function (r) {
  11573. r.skeleton = null, r.dispose();
  11574. }), (t = e.root.skeleton) == null || t.dispose(), e.root.dispose();
  11575. }), this.resourceIdList = [];
  11576. }
  11577. }, {
  11578. key: "dispose",
  11579. value: function dispose(e) {
  11580. this.body ? (this.body.root._parentContainer.xReferenceCount && (this.body.root._parentContainer.xReferenceCount--, this.body.root._parentContainer = null), this.clearAllClothesComps(), this.body.isRender = !1, this.body.skeleton.dispose(), this.body.skeleton = null, this.body.root.dispose(), this.body = void 0, this.skeleton && (this.skeleton.dispose(), this.skeleton = void 0)) : logger$1.warn("[Engine] no body to dispose");
  11581. }
  11582. }, {
  11583. key: "changeClothesComp",
  11584. value: function changeClothesComp(e, t, r, n, o) {
  11585. var _this2 = this;
  11586. return new Promise(function (a) {
  11587. if (r === "pendant" || _this2.resourceIdList.some(function (s) {
  11588. return s.name === t;
  11589. })) return a();
  11590. if (e.isHide || !e.isRender) o.concat(r).forEach(function (l) {
  11591. e.clothesList = e.clothesList.filter(function (c) {
  11592. return c.type != l;
  11593. });
  11594. var u = {
  11595. type: r,
  11596. id: t,
  11597. url: n,
  11598. lod: 0
  11599. };
  11600. e.clothesList.push(u);
  11601. }), a();else {
  11602. var s = o.concat(r);
  11603. e.avatarManager.loadDecoration(r, t, 0).then(function (l) {
  11604. if (l) {
  11605. e.attachDecoration(l);
  11606. var u = {
  11607. type: r,
  11608. id: t,
  11609. url: n
  11610. };
  11611. e.clothesList.push(u), l.root.setEnabled(!0), s.forEach(function (c) {
  11612. var h = _this2.resourceIdList.filter(function (f) {
  11613. return f.type === c;
  11614. });
  11615. if (h.length > 1) {
  11616. (function () {
  11617. var f = h.filter(function (d) {
  11618. return d.name === t;
  11619. });
  11620. if (f.length > 1) {
  11621. var _loop = function _loop(d) {
  11622. e.detachDecoration(f[d]), e.clothesList = e.clothesList.filter(function (g) {
  11623. return g.id != f[d].name;
  11624. });
  11625. var _ = {
  11626. type: r,
  11627. id: t,
  11628. url: n
  11629. };
  11630. e.clothesList.push(_);
  11631. };
  11632. for (var d = 1; d < f.length; ++d) {
  11633. _loop(d);
  11634. }
  11635. }
  11636. })();
  11637. }
  11638. h[0] && h[0].name != t && _this2._readyToDetach(e, r) && (e.detachDecoration(h[0]), e.clothesList = e.clothesList.filter(function (f) {
  11639. return f.id != h[0].name;
  11640. }));
  11641. });
  11642. }
  11643. return a();
  11644. });
  11645. }
  11646. });
  11647. }
  11648. }, {
  11649. key: "_readyToDetach",
  11650. value: function _readyToDetach(e, t) {
  11651. return !((t == "clothes" || t == "pants") && e.clothesList.filter(function (n) {
  11652. return n.type === "suit";
  11653. }).length == 1 && (!e.clothesList.some(function (n) {
  11654. return n.type === "pants";
  11655. }) || !e.clothesList.some(function (n) {
  11656. return n.type === "clothes";
  11657. })));
  11658. }
  11659. }, {
  11660. key: "addDecoComp",
  11661. value: function addDecoComp(e, t, r, n, o) {
  11662. if (e.isRender) {
  11663. var a = e.avatarManager.extraComps.get(t),
  11664. s = a == null ? void 0 : a.clone(t, void 0);
  11665. if (!a) {
  11666. logger$1.error("\u6CA1\u6709\u5BF9\u5E94\u7684\u7EC4\u4EF6");
  11667. return;
  11668. }
  11669. this.extras.push(s);
  11670. var l = this.skeleton.bones.find(function (u) {
  11671. return u.name === r;
  11672. });
  11673. s.position = n, s.rotation = o, s.attachToBone(l, e.rootNode.getChildMeshes()[0]);
  11674. }
  11675. }
  11676. }, {
  11677. key: "showExtra",
  11678. value: function showExtra(e) {
  11679. this.extras.forEach(function (t) {
  11680. t.name.indexOf(e) > 0 && t.setEnabled(!0);
  11681. });
  11682. }
  11683. }, {
  11684. key: "hideExtra",
  11685. value: function hideExtra(e) {
  11686. this.extras.forEach(function (t) {
  11687. t.name.indexOf(e) > 0 && t.setEnabled(!1);
  11688. });
  11689. }
  11690. }, {
  11691. key: "disposeExtra",
  11692. value: function disposeExtra() {
  11693. this.extras.forEach(function (e) {
  11694. e.dispose();
  11695. }), this.extras = [];
  11696. }
  11697. }]);
  11698. return XAvatarComopnent;
  11699. }();
  11700. var XStateMachine = /*#__PURE__*/function () {
  11701. function XStateMachine(e) {
  11702. _classCallCheck(this, XStateMachine);
  11703. E(this, "state");
  11704. E(this, "isMoving");
  11705. E(this, "isRotating");
  11706. E(this, "_observer");
  11707. E(this, "_movingObserver");
  11708. E(this, "_scene");
  11709. this._scene = e;
  11710. }
  11711. _createClass(XStateMachine, [{
  11712. key: "rotateTo",
  11713. value: function rotateTo(e, t, r, n) {
  11714. var _this = this;
  11715. return new Promise(function (o, a) {
  11716. var h;
  11717. var s = e.avatarManager.scene;
  11718. if (r && e.setRotation(r), t == r) return o();
  11719. e.priority === 0 && logger$1.info("avatar ".concat(e.id, " starts to rotate from ").concat(r, " to ").concat(t));
  11720. var l = 0;
  11721. var u = 1e3 / 25,
  11722. c = calcDistance3DAngle(t, e.rotation) / u;
  11723. _this._movingObserver && s.onBeforeRenderObservable.remove(_this._movingObserver), (h = e.controller) == null || h.playAnimation(n || "Walking", !0), _this._movingObserver = s == null ? void 0 : s.onBeforeRenderObservable.add(function () {
  11724. var f;
  11725. if (l < 1) {
  11726. if (!e.rootNode) return e.setRotation(t), o();
  11727. var d = BABYLON.Vector3.Lerp(e.rootNode.rotation, ue4Rotation2Xverse(t), l);
  11728. e.setRotation(xverseRotation2Ue4(d)), l += u / (c * 1e3);
  11729. } else return s.onBeforeRenderObservable.remove(_this._movingObserver), (f = e.controller) == null || f.playAnimation("Idle", !0), o();
  11730. });
  11731. });
  11732. }
  11733. }, {
  11734. key: "_filterPathPoint",
  11735. value: function _filterPathPoint(e) {
  11736. var t = 0;
  11737. var r = 1e-4;
  11738. if (e.length <= 1) return [];
  11739. for (; t < e.length - 1;) {
  11740. calcDistance3D(e[t], e[t + 1]) < r ? e.splice(t, 1) : t++;
  11741. }
  11742. return e;
  11743. }
  11744. }, {
  11745. key: "moveTo",
  11746. value: function moveTo(e, t, r, n, o, a) {
  11747. var _this2 = this;
  11748. return new Promise(function (s, l) {
  11749. var m;
  11750. var u = e.avatarManager.scene;
  11751. e.priority === 0 && logger$1.info("avatar ".concat(e.id, " starts to move from ").concat(t, " to ").concat(r));
  11752. var c = 0;
  11753. a ? a = a.concat(r) : a = [r], a = _this2._filterPathPoint(a);
  11754. var h = t,
  11755. f = a.shift();
  11756. if (!f) return l("[Engine input path error]");
  11757. var d = calcDistance3D(h, f) / n;
  11758. var _ = 1e3 / 25;
  11759. e.rootNode.lookAt(ue4Position2Xverse(f));
  11760. var g = xverseRotation2Ue4({
  11761. x: e.rootNode.rotation.x,
  11762. y: e.rootNode.rotation.y,
  11763. z: e.rootNode.rotation.z
  11764. });
  11765. g && (g.roll = 0, g.pitch = 0, e.setRotation(g)), _this2._movingObserver && u.onBeforeRenderObservable.remove(_this2._movingObserver), (m = e.controller) == null || m.playAnimation(o, !0), _this2._movingObserver = u == null ? void 0 : u.onBeforeRenderObservable.add(function () {
  11766. var v;
  11767. if (c < 1) {
  11768. var y = BABYLON.Vector3.Lerp(ue4Position2Xverse(h), ue4Position2Xverse(f), c);
  11769. if (e.setPosition(xversePosition2Ue4(y)), !e.rootNode) return e.setPosition(r), s();
  11770. c += _ / (d * 1e3);
  11771. } else if (h = f, f = a.shift(), f) {
  11772. d = calcDistance3D(h, f) / n, e.rootNode.lookAt(ue4Position2Xverse(f));
  11773. var _y = xverseRotation2Ue4({
  11774. x: e.rootNode.rotation.x,
  11775. y: e.rootNode.rotation.y,
  11776. z: e.rootNode.rotation.z
  11777. });
  11778. _y && (_y.roll = 0, _y.pitch = 0, e.setRotation(_y)), c = 0;
  11779. } else return u.onBeforeRenderObservable.remove(_this2._movingObserver), (v = e.controller) == null || v.playAnimation("Idle", !0), s();
  11780. });
  11781. });
  11782. }
  11783. }, {
  11784. key: "lookAt",
  11785. value: function lookAt(e, t, r) {
  11786. return new Promise(function (n) {
  11787. var _, g;
  11788. var o = ue4Position2Xverse(t),
  11789. s = e.rootNode.position.subtract(o).length(),
  11790. l = new BABYLON.Vector3(s * Math.sin(e.rootNode.rotation.y), 0, s * Math.cos(e.rootNode.rotation.y)),
  11791. u = (_ = e.rootNode) == null ? void 0 : _.position.add(l);
  11792. var c = 0;
  11793. var h = r || 1 / 100,
  11794. f = (g = e.rootNode) == null ? void 0 : g.getScene(),
  11795. d = f == null ? void 0 : f.onBeforeRenderObservable.add(function () {
  11796. var y, b;
  11797. var m = (y = e.controller) == null ? void 0 : y.animations.find(function (T) {
  11798. return T.name == "Idle";
  11799. });
  11800. (m == null ? void 0 : m.isPlaying) != !0 && (m == null || m.play());
  11801. var v = BABYLON.Vector3.Lerp(u, o, c);
  11802. c < 1 ? ((b = e.rootNode) == null || b.lookAt(v), c += h) : (d && f.onBeforeRenderObservable.remove(d), n());
  11803. });
  11804. });
  11805. }
  11806. }, {
  11807. key: "sendObjectTo",
  11808. value: function sendObjectTo(e, t, r) {
  11809. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 2;
  11810. var o = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 10;
  11811. var a = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
  11812. x: 0,
  11813. y: 0,
  11814. z: 150
  11815. };
  11816. return new Promise(function (s, l) {
  11817. var u;
  11818. if (!r.loaded) l("Gift has not inited!");else {
  11819. var c = (u = e.rootNode) == null ? void 0 : u.getScene();
  11820. var h = 0;
  11821. var f = 1 / (n * 25),
  11822. d = f,
  11823. _ = o / 100,
  11824. g = 8 * _ * f * f;
  11825. var m = .5 * g / f,
  11826. v = ue4Position2Xverse(e.position);
  11827. var y = ue4Position2Xverse(a),
  11828. b = ue4Position2Xverse(e.position),
  11829. T = c == null ? void 0 : c.onBeforeRenderObservable.add(function () {
  11830. (!t || !e.position || !t.position) && (T && c.onBeforeRenderObservable.remove(T), l("Invalid receiver when shoot gift!")), r.loaded || (T && c.onBeforeRenderObservable.remove(T), s());
  11831. var C = ue4Position2Xverse(t.position),
  11832. A = new BABYLON.Vector3((C.x - b.x) * f, m, (C.z - b.z) * f);
  11833. m = m - g, h < 1 ? (v = v.add(A), r.setPositionVector(v.add(y)), h += d) : (s(), T && c.onBeforeRenderObservable.remove(T));
  11834. });
  11835. }
  11836. });
  11837. }
  11838. }, {
  11839. key: "roll",
  11840. value: function roll(e, t, r, n) {
  11841. var o, a;
  11842. this._observer && ((o = this._scene) == null || o.onBeforeRenderObservable.remove(this._observer)), t && (r = r != null ? r : 1, n = n != null ? n : 1, this._observer = (a = this._scene) == null ? void 0 : a.onBeforeRenderObservable.add(function () {
  11843. e.rootNode.rotation.y += r * .1 * n, e.rootNode.rotation.y %= Math.PI * 2;
  11844. }));
  11845. }
  11846. }, {
  11847. key: "disposeObsever",
  11848. value: function disposeObsever() {
  11849. this._movingObserver && this._scene.onBeforeRenderObservable.remove(this._movingObserver);
  11850. }
  11851. }]);
  11852. return XStateMachine;
  11853. }();
  11854. var XAvatarBillboardComponent = /*#__PURE__*/function () {
  11855. function XAvatarBillboardComponent(e) {
  11856. var _this = this;
  11857. _classCallCheck(this, XAvatarBillboardComponent);
  11858. E(this, "_nickName", "");
  11859. E(this, "_words", "");
  11860. E(this, "_isNameVisible", !0);
  11861. E(this, "_isBubbleVisible", !0);
  11862. E(this, "_isGiftButtonsVisible", !1);
  11863. E(this, "withinVisualRange", !1);
  11864. E(this, "_bubble");
  11865. E(this, "_nameBoard");
  11866. E(this, "_giftButtons", new Map());
  11867. E(this, "_buttonTex", new Map());
  11868. E(this, "_nameLinesLimit", 2);
  11869. E(this, "_nameLengthPerLine", 16);
  11870. E(this, "_scene");
  11871. E(this, "_pickBbox", null);
  11872. E(this, "bbox");
  11873. E(this, "_height", .26);
  11874. E(this, "_attachmentObservers", new Map());
  11875. E(this, "attachToAvatar", function (e, t) {
  11876. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
  11877. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
  11878. x: 0,
  11879. y: 0,
  11880. z: 0
  11881. };
  11882. var o = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : !1;
  11883. var a = arguments.length > 5 ? arguments[5] : undefined;
  11884. var s = arguments.length > 6 ? arguments[6] : undefined;
  11885. var l = e.rootNode;
  11886. if (_this.bbox || e.getBbox(), t && l) {
  11887. var u = a || t.uniqueId;
  11888. var c = _this._attachmentObservers.get(u);
  11889. if (c) if (o) _this._scene.onBeforeRenderObservable.remove(c), _this._attachmentObservers.delete(u);else return;
  11890. var h = ue4Position2Xverse(n);
  11891. r ? (t.setParent(l), t.position = h) : (c = _this._scene.onBeforeRenderObservable.add(function () {
  11892. var f = 0;
  11893. s ? (f = e.rootNode.rotation.y / Math.PI * 180 + 90, e.rootNode.rotation.y && (t.rotation.y = e.rootNode.rotation.y)) : f = e.avatarManager.sceneManager.cameraComponent.getCameraPose().rotation.yaw, f || (f = 0);
  11894. var d = new BABYLON.Vector3(0, _this._height, 0);
  11895. e.controller && e.controller.activeAnimation() && e.controller.activeAnimation().animatables[0] && (_this._height = d.y = (e.controller.activeAnimation().animatables[0].target.position.y * .01 - .66) * e.scale), d.y < .07 * e.scale && (d.y = 0), t.position.x = l.position.x + h.x * Math.sin(f * Math.PI / 180) + h.z * Math.cos(f * Math.PI / 180), t.position.z = l.position.z + h.x * Math.cos(f * Math.PI / 180) - h.z * Math.sin(f * Math.PI / 180), t.position.y = l.position.y + _this.bbox.maximum.y + h.y + d.y;
  11896. }), _this._attachmentObservers.set(u, c));
  11897. } else logger$1.error("avatar or attachment not found!");
  11898. });
  11899. E(this, "detachFromAvatar", function (e, t) {
  11900. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
  11901. var n = _this._attachmentObservers.get(t.uniqueId);
  11902. n && _this._scene.onBeforeRenderObservable.remove(n), e.rootNode ? (t.setEnabled(!1), t.parent = null, r && t.dispose()) : logger$1.error("avatar not found!");
  11903. });
  11904. E(this, "getBbox", function (e) {
  11905. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  11906. var _t$isConst = t.isConst,
  11907. r = _t$isConst === void 0 ? !1 : _t$isConst,
  11908. _t$changeWithAvatar = t.changeWithAvatar,
  11909. n = _t$changeWithAvatar === void 0 ? !1 : _t$changeWithAvatar;
  11910. var _t$localCenter = t.localCenter,
  11911. o = _t$localCenter === void 0 ? {
  11912. x: 0,
  11913. y: 0,
  11914. z: 75
  11915. } : _t$localCenter,
  11916. _t$width = t.width,
  11917. a = _t$width === void 0 ? 1.32 : _t$width,
  11918. _t$height = t.height,
  11919. s = _t$height === void 0 ? 1.5 : _t$height,
  11920. _t$depth = t.depth,
  11921. l = _t$depth === void 0 ? .44 : _t$depth;
  11922. if (n) {
  11923. var u = e.scale;
  11924. o = {
  11925. x: o.x * u,
  11926. y: o.y * u,
  11927. z: o.z * u
  11928. }, a *= u, s *= u, l *= u;
  11929. }
  11930. if (e.rootNode) {
  11931. var _u = new BABYLON.Vector3(0, 0, 0),
  11932. c = new BABYLON.Vector3(0, 0, 0);
  11933. if (r) {
  11934. var f = ue4Position2Xverse(o);
  11935. _u = _u.add(f.add(new BABYLON.Vector3(-a / 2, -s / 2, -l / 2))), c = c.add(f.add(new BABYLON.Vector3(a / 2, s / 2, l / 2)));
  11936. } else if (_u = _u.add(new BABYLON.Vector3(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY)), c = c.add(new BABYLON.Vector3(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY)), e.isRender) {
  11937. e.rootNode.getChildMeshes().forEach(function (_) {
  11938. var g = _.getBoundingInfo().boundingBox.minimum,
  11939. m = _.getBoundingInfo().boundingBox.maximum;
  11940. _u.x = Math.min(_u.x, g.x), c.x = Math.max(c.x, m.x), _u.y = Math.min(_u.y, g.y), c.y = Math.max(c.y, m.y), _u.z = Math.min(_u.z, g.z), c.z = Math.max(c.z, m.z);
  11941. });
  11942. var _f = c.x - _u.x,
  11943. d = c.z - _u.z;
  11944. _u.x -= e.scale * _f / 2, c.x += e.scale * _f / 2, c.y *= e.scale, _u.z -= e.scale * d / 2, c.z += e.scale * d / 2;
  11945. } else {
  11946. var _f2 = e.avatarManager.getMainAvatar();
  11947. _f2 && _f2.bbComponent.bbox && (_u.x = _f2.bbComponent.bbox.minimum.x, c.x = _f2.bbComponent.bbox.maximum.x, _u.y = _f2.bbComponent.bbox.minimum.y, c.y = _f2.bbComponent.bbox.maximum.y, _u.z = _f2.bbComponent.bbox.minimum.z, c.z = _f2.bbComponent.bbox.maximum.z);
  11948. }
  11949. var h = e.rootNode.computeWorldMatrix(!0);
  11950. if (_this.bbox ? _this.bbox.reConstruct(_u, c, h) : _this.bbox = new BABYLON.BoundingBox(_u, c, h), _this._pickBbox == null) {
  11951. var _f3 = _this.createPickBoundingbox(e, _this.bbox);
  11952. _this.attachToAvatar(e, _f3.data, !1, {
  11953. x: 0,
  11954. y: 0,
  11955. z: 0
  11956. }, !1, "pickbox"), _this._pickBbox = _f3;
  11957. }
  11958. } else logger$1.error("avatar not found!");
  11959. });
  11960. this._scene = e;
  11961. }
  11962. _createClass(XAvatarBillboardComponent, [{
  11963. key: "isNameVisible",
  11964. get: function get() {
  11965. return this._isNameVisible;
  11966. }
  11967. }, {
  11968. key: "isBubbleVisible",
  11969. get: function get() {
  11970. return this._isBubbleVisible;
  11971. }
  11972. }, {
  11973. key: "isGiftButtonsVisible",
  11974. get: function get() {
  11975. return this._isGiftButtonsVisible;
  11976. }
  11977. }, {
  11978. key: "words",
  11979. get: function get() {
  11980. return this._words;
  11981. }
  11982. }, {
  11983. key: "nickName",
  11984. get: function get() {
  11985. return this._nickName;
  11986. }
  11987. }, {
  11988. key: "giftButtons",
  11989. get: function get() {
  11990. return this._giftButtons;
  11991. }
  11992. }, {
  11993. key: "bubble",
  11994. get: function get() {
  11995. return this._bubble;
  11996. }
  11997. }, {
  11998. key: "nameBoard",
  11999. get: function get() {
  12000. return this._nameBoard;
  12001. }
  12002. }, {
  12003. key: "setNicknameStatus",
  12004. value: function setNicknameStatus(e) {
  12005. if (this.nameBoard && this.nameBoard.setStatus(e), e == BillboardStatus.DISPOSE) {
  12006. var t = this._attachmentObservers.get("nickname");
  12007. t && (this._scene.onBeforeRenderObservable.remove(t), this._attachmentObservers.delete("nickname"));
  12008. }
  12009. }
  12010. }, {
  12011. key: "setBubbleStatus",
  12012. value: function setBubbleStatus(e) {
  12013. if (this.bubble && this.bubble.setStatus(e), e == BillboardStatus.DISPOSE) {
  12014. var t = this._attachmentObservers.get("bubble");
  12015. t && (this._scene.onBeforeRenderObservable.remove(t), this._attachmentObservers.delete("bubble"));
  12016. }
  12017. }
  12018. }, {
  12019. key: "setButtonsStatus",
  12020. value: function setButtonsStatus(e) {
  12021. var _this2 = this;
  12022. this.giftButtons && this.giftButtons.size != 0 && this.giftButtons.forEach(function (t) {
  12023. if (t.setStatus(e), e == BillboardStatus.DISPOSE && t.getMesh()) {
  12024. var r = "button_" + t.getMesh().xid,
  12025. n = _this2._attachmentObservers.get(r);
  12026. n && (_this2._scene.onBeforeRenderObservable.remove(n), _this2._attachmentObservers.delete(r));
  12027. }
  12028. });
  12029. }
  12030. }, {
  12031. key: "setGiftButtonsVisible",
  12032. value: function setGiftButtonsVisible(e) {
  12033. this.setButtonsStatus(e ? BillboardStatus.SHOW : BillboardStatus.DISPOSE);
  12034. }
  12035. }, {
  12036. key: "dispose",
  12037. value: function dispose(e) {
  12038. var _this3 = this;
  12039. this._attachmentObservers.forEach(function (t) {
  12040. _this3._scene.onBeforeRenderObservable.remove(t);
  12041. }), this._attachmentObservers.clear(), this.updateBillboardStatus(e, BillboardStatus.DISPOSE), this._buttonTex.clear(), this._pickBbox && (e.avatarManager.bboxMeshPool.release(this._pickBbox), this._pickBbox = null);
  12042. }
  12043. }, {
  12044. key: "updateBillboardStatus",
  12045. value: function updateBillboardStatus(e, t) {
  12046. this.bbox || e.getBbox(), e.isRender ? (e.setBubbleStatus(t), e.setButtonsStatus(t), e.setNicknameStatus(t)) : (e.setBubbleStatus(BillboardStatus.DISPOSE), e.setButtonsStatus(BillboardStatus.DISPOSE), e.enableNickname ? e.setNicknameStatus(t) : e.setNicknameStatus(BillboardStatus.DISPOSE));
  12047. }
  12048. }, {
  12049. key: "disposeBillBoard",
  12050. value: function disposeBillBoard(e) {
  12051. var _this4 = this;
  12052. this._attachmentObservers.forEach(function (t) {
  12053. _this4._scene.onBeforeRenderObservable.remove(t);
  12054. }), this._attachmentObservers.clear(), this.updateBillboardStatus(e, BillboardStatus.DISPOSE), this._buttonTex.clear(), this._pickBbox && (e.avatarManager.bboxMeshPool.release(this._pickBbox), this._pickBbox = null);
  12055. }
  12056. }, {
  12057. key: "setPickBoxScale",
  12058. value: function setPickBoxScale(e) {
  12059. this._pickBbox && this._pickBbox.data && (this._pickBbox.data.scaling = new BABYLON.Vector3(e, e, e));
  12060. }
  12061. }, {
  12062. key: "setIsPickable",
  12063. value: function setIsPickable(e, t) {
  12064. e.rootNode && e.rootNode.getChildMeshes().forEach(function (r) {
  12065. r.isPickable = t;
  12066. }), this._pickBbox && this._pickBbox.data && (this._pickBbox.data.isPickable = t);
  12067. }
  12068. }, {
  12069. key: "initNameboard",
  12070. value: function initNameboard(e) {
  12071. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  12072. this._nameBoard == null && (this._nameBoard = e.avatarManager.sceneManager.billboardComponent.addBillboard("name-" + e.id, !1, !0)), this._nameBoard.init("nickname", t / 300, t / 300);
  12073. }
  12074. }, {
  12075. key: "initBubble",
  12076. value: function initBubble(e) {
  12077. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  12078. this._bubble == null && (this._bubble = e.avatarManager.sceneManager.billboardComponent.addBillboard("bubble-" + e.id, !1, !0)), e.isRender && this._bubble.init("bubble", t / 250, t / 250);
  12079. }
  12080. }, {
  12081. key: "say",
  12082. value: function say(e) {
  12083. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this._words;
  12084. var _ref = arguments.length > 2 ? arguments[2] : undefined,
  12085. r = _ref.id,
  12086. n = _ref.isUser,
  12087. o = _ref.background,
  12088. _ref$font = _ref.font,
  12089. a = _ref$font === void 0 ? "Arial" : _ref$font,
  12090. _ref$fontsize = _ref.fontsize,
  12091. s = _ref$fontsize === void 0 ? 38 : _ref$fontsize,
  12092. _ref$fontcolor = _ref.fontcolor,
  12093. l = _ref$fontcolor === void 0 ? "#ffffff" : _ref$fontcolor,
  12094. _ref$fontstyle = _ref.fontstyle,
  12095. u = _ref$fontstyle === void 0 ? "bold" : _ref$fontstyle,
  12096. _ref$linesize = _ref.linesize,
  12097. c = _ref$linesize === void 0 ? 22 : _ref$linesize,
  12098. h = _ref.linelimit,
  12099. _ref$offsets = _ref.offsets,
  12100. f = _ref$offsets === void 0 ? {
  12101. x: 0,
  12102. y: 0,
  12103. z: 40
  12104. } : _ref$offsets,
  12105. d = _ref.scale,
  12106. _ref$compensationZ = _ref.compensationZ,
  12107. _ = _ref$compensationZ === void 0 ? 11.2 : _ref$compensationZ,
  12108. _ref$reregistAnyway = _ref.reregistAnyway,
  12109. g = _ref$reregistAnyway === void 0 ? !0 : _ref$reregistAnyway;
  12110. (!this.bubble || this.bubble.getMesh() == null) && e.initBubble(), this._words = t;
  12111. var m;
  12112. n != null && (m = n ? XBillboardManager.userBubbleUrls : XBillboardManager.npcBubbleUrls), this._bubble && (this._bubble.DEFAULT_CONFIGS = {
  12113. id: r,
  12114. isUser: n,
  12115. background: o || m,
  12116. font: a,
  12117. fontsize: s,
  12118. fontcolor: l,
  12119. fontstyle: u,
  12120. linesize: c,
  12121. linelimit: h,
  12122. offsets: f,
  12123. scale: d,
  12124. compensationZ: _,
  12125. reregistAnyway: g
  12126. }, this._bubble.getMesh() && (this._bubble.drawBillboard({
  12127. imageList: o || m
  12128. }, {
  12129. texts: this._words,
  12130. font: a,
  12131. fontsize: s,
  12132. fontcolor: l,
  12133. fontstyle: u,
  12134. linesize: c
  12135. }, {
  12136. offsets: f,
  12137. scale: d,
  12138. compensationZ: _
  12139. }), this.attachToAvatar(e, this._bubble.getMesh(), !1, this._bubble.offsets, g, "bubble"), r && this._bubble.setId(r))), this.setButtonsStatus(BillboardStatus.DISPOSE);
  12140. }
  12141. }, {
  12142. key: "silent",
  12143. value: function silent() {
  12144. this.setBubbleStatus(BillboardStatus.DISPOSE), this._words = "";
  12145. }
  12146. }, {
  12147. key: "setNickName",
  12148. value: function setNickName(e, t, _ref2) {
  12149. var r = _ref2.id,
  12150. n = _ref2.isUser,
  12151. o = _ref2.background,
  12152. _ref2$font = _ref2.font,
  12153. a = _ref2$font === void 0 ? "Arial" : _ref2$font,
  12154. _ref2$fontsize = _ref2.fontsize,
  12155. s = _ref2$fontsize === void 0 ? 40 : _ref2$fontsize,
  12156. _ref2$fontcolor = _ref2.fontcolor,
  12157. l = _ref2$fontcolor === void 0 ? "#ffffff" : _ref2$fontcolor,
  12158. _ref2$fontstyle = _ref2.fontstyle,
  12159. u = _ref2$fontstyle === void 0 ? "bold" : _ref2$fontstyle,
  12160. _ref2$linesize = _ref2.linesize,
  12161. c = _ref2$linesize === void 0 ? 22 : _ref2$linesize,
  12162. h = _ref2.linelimit,
  12163. _ref2$offsets = _ref2.offsets,
  12164. f = _ref2$offsets === void 0 ? {
  12165. x: 0,
  12166. y: 0,
  12167. z: 15
  12168. } : _ref2$offsets,
  12169. d = _ref2.scale,
  12170. _ref2$compensationZ = _ref2.compensationZ,
  12171. _ = _ref2$compensationZ === void 0 ? 0 : _ref2$compensationZ,
  12172. _ref2$reregistAnyway = _ref2.reregistAnyway,
  12173. g = _ref2$reregistAnyway === void 0 ? !1 : _ref2$reregistAnyway;
  12174. this._nickName = t, (!this.nameBoard || this.nameBoard.getMesh() == null) && this.initNameboard(e), this._nameBoard && this._nameBoard.getMesh() && (this._nameBoard.DEFAULT_CONFIGS = {
  12175. id: r,
  12176. isUser: n,
  12177. background: o,
  12178. font: a,
  12179. fontsize: s,
  12180. fontcolor: l,
  12181. fontstyle: u,
  12182. linesize: c,
  12183. linelimit: h,
  12184. offsets: f,
  12185. scale: d,
  12186. compensationZ: _,
  12187. reregistAnyway: g
  12188. }, this._nameBoard.drawBillboard({}, {
  12189. texts: this._nickName,
  12190. font: a,
  12191. fontsize: s,
  12192. fontcolor: l,
  12193. fontstyle: u,
  12194. linesize: c,
  12195. linelimit: h
  12196. }, {
  12197. offsets: f,
  12198. scale: d,
  12199. compensationZ: 0
  12200. }), this.attachToAvatar(e, this._nameBoard.getMesh(), !1, this._nameBoard.offsets, g, "nickname"), r && this._nameBoard.setId(r));
  12201. }
  12202. }, {
  12203. key: "generateButtons",
  12204. value: function generateButtons(e) {
  12205. var _this5 = this;
  12206. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  12207. var r = arguments.length > 2 ? arguments[2] : undefined;
  12208. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 85;
  12209. if (t && (this._buttonTex = t, this.clearButtons()), this._buttonTex.size == 0) return;
  12210. var o = (this._buttonTex.size - 1) / 2;
  12211. this._buttonTex.forEach(function (a, s) {
  12212. var l = _this5._giftButtons.get(s);
  12213. l || (l = e.avatarManager.sceneManager.billboardComponent.addBillboard("button-" + s + e.id, !0, !1), l.init(s, r / 240, r / 240));
  12214. var u = {
  12215. x: r * o * 70,
  12216. y: 0,
  12217. z: r * (n - 20 * (o * o))
  12218. };
  12219. l.drawBillboard({
  12220. imageList: [a]
  12221. }, {}, {
  12222. offsets: u,
  12223. scale: r
  12224. }), _this5.attachToAvatar(e, l.getMesh(), !1, l.offsets, !0, "button_" + s), _this5._giftButtons.set(s, l), o -= 1;
  12225. }), this.setBubbleStatus(BillboardStatus.DISPOSE);
  12226. }
  12227. }, {
  12228. key: "clearButtons",
  12229. value: function clearButtons() {
  12230. this._giftButtons.forEach(function (e) {
  12231. e.dispose();
  12232. }), this._giftButtons.clear();
  12233. }
  12234. }, {
  12235. key: "createPickBoundingbox",
  12236. value: function createPickBoundingbox(e, t) {
  12237. var r = t.extendSize.x * 2,
  12238. n = t.extendSize.y * 2,
  12239. o = t.extendSize.z * 2,
  12240. a = this._scene,
  12241. s = Math.max(r, o),
  12242. l = e.avatarManager.bboxMeshPool.getFree(a, s, n, s),
  12243. u = l.data;
  12244. return u && (u.position = t.centerWorld, u.setEnabled(!1), u.isPickable = !0, u.xtype = EMeshType.XAvatar, u.xid = e.id), l;
  12245. }
  12246. }]);
  12247. return XAvatarBillboardComponent;
  12248. }();
  12249. var castRayOffsetY = .01;
  12250. var castRayTeleportationOffset = 10;
  12251. var XAvatar = /*#__PURE__*/function () {
  12252. function XAvatar(_ref) {
  12253. var _this = this;
  12254. var e = _ref.id,
  12255. t = _ref.avatarType,
  12256. r = _ref.priority,
  12257. n = _ref.avatarManager,
  12258. o = _ref.assets,
  12259. a = _ref.status;
  12260. _classCallCheck(this, XAvatar);
  12261. E(this, "id", "-1");
  12262. E(this, "priority", 0);
  12263. E(this, "isRender", !1);
  12264. E(this, "distLevel", 0);
  12265. E(this, "isInLoadingList", !1);
  12266. E(this, "isHide", !1);
  12267. E(this, "component");
  12268. E(this, "controller");
  12269. E(this, "stateMachine");
  12270. E(this, "bbComponent");
  12271. E(this, "_avatarType");
  12272. E(this, "clothesList", []);
  12273. E(this, "isSelected", !1);
  12274. E(this, "pendingLod", !1);
  12275. E(this, "_previousReceivedPosition", new BABYLON.Vector3(0, 1e4, 0));
  12276. E(this, "_avatarPosition");
  12277. E(this, "_avatarRotation");
  12278. E(this, "_avatarScale");
  12279. E(this, "rootNode");
  12280. E(this, "distToCam", 1e11);
  12281. E(this, "enableNickname", !0);
  12282. E(this, "distance", 1e11);
  12283. E(this, "isCulling", !1);
  12284. E(this, "reslevel", 0);
  12285. E(this, "isInLoadingQueue", !1);
  12286. E(this, "_isRayCastEnable");
  12287. E(this, "_scene");
  12288. E(this, "_avatarManager");
  12289. E(this, "_transparent", 0);
  12290. E(this, "hide", function () {
  12291. return _this.isHide = !0, _this._hide(), !_this.isRender;
  12292. });
  12293. E(this, "_show", function () {
  12294. var e;
  12295. _this.isHide || (_this.setIsPickable(!0), _this.priority == 0 && (_this.rootNode.setEnabled(!0), _this.isRender = !0, _this.avatarManager._updateBillboardStatus(_this, BillboardStatus.SHOW), (e = _this.controller) == null || e.playAnimation(_this.controller.onPlay, _this.controller.loop)));
  12296. });
  12297. E(this, "show", function () {
  12298. return _this.isHide = !1, _this._show(), !!_this.isRender;
  12299. });
  12300. E(this, "setAnimations", function (e) {
  12301. _this.controller.animations = e;
  12302. });
  12303. E(this, "attachToAvatar", function (e) {
  12304. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
  12305. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
  12306. x: 0,
  12307. y: 0,
  12308. z: 0
  12309. };
  12310. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !1;
  12311. var o = arguments.length > 4 ? arguments[4] : undefined;
  12312. var a = arguments.length > 5 ? arguments[5] : undefined;
  12313. return _this.bbComponent.attachToAvatar(_this, e, t, r, n, o, a);
  12314. });
  12315. E(this, "detachFromAvatar", function (e) {
  12316. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
  12317. return _this.bbComponent.detachFromAvatar(_this, e, t);
  12318. });
  12319. E(this, "getBbox", function () {
  12320. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  12321. return _this.bbComponent.getBbox(_this, e);
  12322. });
  12323. this.id = e, this._avatarManager = n, this._scene = this.avatarManager.scene, this.clothesList = o, this._avatarType = t, this.priority = r || 0, this.controller = new XAnimationController(this), this.component = new XAvatarComopnent(), this.stateMachine = new XStateMachine(this._scene), this.bbComponent = new XAvatarBillboardComponent(this._scene), this.rootNode = new BABYLON.TransformNode(e, this._avatarManager.scene), this._avatarScale = a.avatarScale == null ? 1 : a.avatarScale, this._avatarRotation = a.avatarRotation == null ? {
  12324. pitch: 0,
  12325. yaw: 0,
  12326. roll: 0
  12327. } : a.avatarRotation, this._avatarPosition = a.avatarPosition == null ? {
  12328. x: 0,
  12329. y: 0,
  12330. z: 0
  12331. } : a.avatarPosition, this.setPosition(this._avatarPosition), this.setRotation(this._avatarRotation), this.setScale(this.scale), this._isRayCastEnable = avatarSetting.isRayCastEnable, this._scene.registerBeforeRender(function () {
  12332. _this.tick();
  12333. });
  12334. }
  12335. _createClass(XAvatar, [{
  12336. key: "tick",
  12337. value: function tick() {
  12338. this.cullingTick();
  12339. }
  12340. }, {
  12341. key: "cullingTick",
  12342. value: function cullingTick() {
  12343. var _this2 = this;
  12344. var e;
  12345. this.isCulling && ((e = this.rootNode) == null || e.getChildMeshes().forEach(function (t) {
  12346. _this2.distToCam < 50 ? t.visibility = 0 : t.visibility = _this2._transparent;
  12347. }));
  12348. }
  12349. }, {
  12350. key: "setTransParentThresh",
  12351. value: function setTransParentThresh(e) {
  12352. this._transparent = e;
  12353. }
  12354. }, {
  12355. key: "isNameVisible",
  12356. get: function get() {
  12357. return this.bbComponent.isNameVisible;
  12358. }
  12359. }, {
  12360. key: "isBubbleVisible",
  12361. get: function get() {
  12362. return this.bbComponent.isBubbleVisible;
  12363. }
  12364. }, {
  12365. key: "isGiftButtonsVisible",
  12366. get: function get() {
  12367. return this.bbComponent.isGiftButtonsVisible;
  12368. }
  12369. }, {
  12370. key: "words",
  12371. get: function get() {
  12372. return this.bbComponent.words;
  12373. }
  12374. }, {
  12375. key: "nickName",
  12376. get: function get() {
  12377. return this.bbComponent.nickName;
  12378. }
  12379. }, {
  12380. key: "giftButtons",
  12381. get: function get() {
  12382. return this.bbComponent.giftButtons;
  12383. }
  12384. }, {
  12385. key: "bubble",
  12386. get: function get() {
  12387. return this.bbComponent.bubble;
  12388. }
  12389. }, {
  12390. key: "nameBoard",
  12391. get: function get() {
  12392. return this.bbComponent.nameBoard;
  12393. }
  12394. }, {
  12395. key: "avatarManager",
  12396. get: function get() {
  12397. return this._avatarManager;
  12398. }
  12399. }, {
  12400. key: "withinVisibleRange",
  12401. set: function set(e) {
  12402. this.bbComponent.withinVisualRange = e;
  12403. }
  12404. }, {
  12405. key: "setNicknameStatus",
  12406. value: function setNicknameStatus(e) {
  12407. return this.bbComponent.setNicknameStatus(e);
  12408. }
  12409. }, {
  12410. key: "setBubbleStatus",
  12411. value: function setBubbleStatus(e) {
  12412. return this.bbComponent.setBubbleStatus(e);
  12413. }
  12414. }, {
  12415. key: "setButtonsStatus",
  12416. value: function setButtonsStatus(e) {
  12417. return this.bbComponent.setBubbleStatus(e);
  12418. }
  12419. }, {
  12420. key: "setGiftButtonsVisible",
  12421. value: function setGiftButtonsVisible(e) {
  12422. return this.bbComponent.setGiftButtonsVisible(e);
  12423. }
  12424. }, {
  12425. key: "avatarType",
  12426. get: function get() {
  12427. return this._avatarType;
  12428. }
  12429. }, {
  12430. key: "attachBody",
  12431. value: function attachBody(e) {
  12432. return this.component.addBodyComp(this, e);
  12433. }
  12434. }, {
  12435. key: "attachDecoration",
  12436. value: function attachDecoration(e) {
  12437. return this.component.addClothesComp(this, e);
  12438. }
  12439. }, {
  12440. key: "detachDecoration",
  12441. value: function detachDecoration(e) {
  12442. return this.component.clearClothesComp(e);
  12443. }
  12444. }, {
  12445. key: "detachDecorationAll",
  12446. value: function detachDecorationAll() {
  12447. return this.component.clearAllClothesComps();
  12448. }
  12449. }, {
  12450. key: "skeleton",
  12451. get: function get() {
  12452. return this.component.skeleton;
  12453. }
  12454. }, {
  12455. key: "position",
  12456. get: function get() {
  12457. return this._avatarPosition;
  12458. }
  12459. }, {
  12460. key: "rotation",
  12461. get: function get() {
  12462. return this._avatarRotation;
  12463. }
  12464. }, {
  12465. key: "scale",
  12466. get: function get() {
  12467. return this._avatarScale;
  12468. }
  12469. }, {
  12470. key: "_hide_culling",
  12471. value: function _hide_culling() {
  12472. this.bbComponent.updateBillboardStatus(this, BillboardStatus.HIDE), this.isCulling = !0;
  12473. }
  12474. }, {
  12475. key: "_show_culling",
  12476. value: function _show_culling() {
  12477. this.isCulling && (this.rootNode && this.rootNode.getChildMeshes().forEach(function (e) {
  12478. e.visibility = 1;
  12479. }), this.bbComponent.updateBillboardStatus(this, BillboardStatus.SHOW), this.isCulling = !1);
  12480. }
  12481. }, {
  12482. key: "_hide",
  12483. value: function _hide() {
  12484. !this.isHide || (this.setIsPickable(!1), this.priority == 0 ? (this.rootNode.setEnabled(!1), this.isRender = !1, this.bbComponent.updateBillboardStatus(this, BillboardStatus.HIDE)) : this.isRender && (this.avatarManager.currentLODUsers[this.distLevel]--, this.removeAvatarFromScene()));
  12485. }
  12486. }, {
  12487. key: "rotate",
  12488. value: function rotate(e, t, r) {
  12489. return this.stateMachine.roll(this, e, t, r);
  12490. }
  12491. }, {
  12492. key: "isRayCastEnable",
  12493. get: function get() {
  12494. return this._isRayCastEnable;
  12495. },
  12496. set: function set(e) {
  12497. this._isRayCastEnable = e;
  12498. }
  12499. }, {
  12500. key: "getAvatarId",
  12501. value: function getAvatarId() {
  12502. return this.id;
  12503. }
  12504. }, {
  12505. key: "getAvaliableAnimations",
  12506. value: function getAvaliableAnimations() {
  12507. var e = avatarLoader.avaliableAnimation.get(this.avatarType);
  12508. return e || [];
  12509. }
  12510. }, {
  12511. key: "setPosition",
  12512. value: function setPosition(e) {
  12513. var _this3 = this;
  12514. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
  12515. if (this._avatarPosition = e, this.rootNode) {
  12516. var r = ue4Position2Xverse(this._avatarPosition);
  12517. var n = !1;
  12518. this.avatarManager.getMainAvatar() && (this.id != this.avatarManager.getMainAvatar().id || (Math.abs(r.y - this._previousReceivedPosition.y) > castRayOffsetY && (n = !0), r.subtract(this._previousReceivedPosition).length() > castRayTeleportationOffset && (n = !0))), this._isRayCastEnable ? n || t ? this._castRay(e).then(function (o) {
  12519. _this3.rootNode.position = r, _this3.rootNode.position.y -= o;
  12520. }).catch(function (o) {
  12521. Promise.reject(o);
  12522. }) : (this.rootNode.position.x = r.x, this.rootNode.position.z = r.z) : this.rootNode.position = r, this._previousReceivedPosition = r.clone();
  12523. }
  12524. return Promise.resolve(e);
  12525. }
  12526. }, {
  12527. key: "setRotation",
  12528. value: function setRotation(e) {
  12529. if (this._avatarRotation = e, this.rootNode) {
  12530. var t = {
  12531. pitch: e.pitch,
  12532. yaw: e.yaw + 180,
  12533. roll: e.roll
  12534. },
  12535. r = ue4Rotation2Xverse(t);
  12536. this.rootNode.rotation = r;
  12537. }
  12538. }
  12539. }, {
  12540. key: "setAvatarVisible",
  12541. value: function setAvatarVisible(e) {
  12542. this.rootNode && (this.rootNode.setEnabled(e), this.rootNode.getChildMeshes().forEach(function (t) {
  12543. t.setEnabled(e);
  12544. }));
  12545. }
  12546. }, {
  12547. key: "setScale",
  12548. value: function setScale(e) {
  12549. this._avatarScale = e, this.rootNode && (this.rootNode.scaling = new BABYLON.Vector3(e, e, e)), this.bbComponent.bbox && this.getBbox();
  12550. }
  12551. }, {
  12552. key: "_removeAvatarFromScene",
  12553. value: function _removeAvatarFromScene() {
  12554. var e, t;
  12555. this.isRender = !1, (e = this.controller) == null || e.detachAnimation(), this.component.dispose(this), (t = this.avatarManager.sceneManager) == null || t.lightComponent.removeShadow(this);
  12556. }
  12557. }, {
  12558. key: "removeAvatarFromScene",
  12559. value: function removeAvatarFromScene() {
  12560. this._removeAvatarFromScene(), this._disposeBillBoard();
  12561. }
  12562. }, {
  12563. key: "_disposeBillBoard",
  12564. value: function _disposeBillBoard() {
  12565. this.bbComponent.disposeBillBoard(this);
  12566. }
  12567. }, {
  12568. key: "addComponent",
  12569. value: function addComponent(e, t, r, n) {
  12570. return this.component.changeClothesComp(this, e, t, r, n);
  12571. }
  12572. }, {
  12573. key: "_castRay",
  12574. value: function _castRay(e) {
  12575. var _this4 = this;
  12576. return new Promise(function (t, r) {
  12577. var d;
  12578. var n = ue4Position2Xverse(e),
  12579. o = new BABYLON.Vector3(0, -1, 0),
  12580. a = 1.5 * _this4.scale,
  12581. s = 100 * a,
  12582. l = a,
  12583. u = new BABYLON.Vector3(n.x, n.y + l, +n.z),
  12584. c = new BABYLON.Ray(u, o, s),
  12585. h = (d = _this4.avatarManager.sceneManager) == null ? void 0 : d.getGround(e);
  12586. if (!h || h.length <= 0) return logger.warn("\u89D2\u8272 id= ".concat(_this4.id, " \u627E\u4E0D\u5230\u5730\u9762\uFF0C\u5F53\u524D\u9AD8\u5EA6\u4E3A\u4E0B\u53D1\u9AD8\u5EA6")), t(0);
  12587. var f = c.intersectsMeshes(h);
  12588. if (f.length > 0) return t(f[0].distance - l);
  12589. if (o.y = 1, f = c.intersectsMeshes(h), f.length > 0) return t(-(f[0].distance - l));
  12590. });
  12591. }
  12592. }, {
  12593. key: "setPickBoxScale",
  12594. value: function setPickBoxScale(e) {
  12595. return this.bbComponent.setPickBoxScale(e);
  12596. }
  12597. }, {
  12598. key: "setIsPickable",
  12599. value: function setIsPickable(e) {
  12600. return this.bbComponent.setIsPickable(this, e);
  12601. }
  12602. }, {
  12603. key: "createPickBoundingbox",
  12604. value: function createPickBoundingbox(e) {
  12605. return this.bbComponent.createPickBoundingbox(this, e);
  12606. }
  12607. }, {
  12608. key: "scaleBbox",
  12609. value: function scaleBbox(e) {
  12610. this.bbComponent.bbox && this.bbComponent.bbox.scale(e);
  12611. }
  12612. }, {
  12613. key: "rotateTo",
  12614. value: function rotateTo(e, t, r) {
  12615. return this.stateMachine.rotateTo(this, e, t, r);
  12616. }
  12617. }, {
  12618. key: "faceTo",
  12619. value: function faceTo(e, t) {
  12620. return this.stateMachine.lookAt(this, e, t);
  12621. }
  12622. }, {
  12623. key: "removeObserver",
  12624. value: function removeObserver() {
  12625. this.stateMachine.disposeObsever();
  12626. }
  12627. }, {
  12628. key: "move",
  12629. value: function move(e, t, r, n, o) {
  12630. return this.stateMachine.moveTo(this, e, t, r, n, o);
  12631. }
  12632. }, {
  12633. key: "initNameboard",
  12634. value: function initNameboard() {
  12635. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
  12636. return this.bbComponent.initNameboard(this, e);
  12637. }
  12638. }, {
  12639. key: "initBubble",
  12640. value: function initBubble() {
  12641. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
  12642. return this.bbComponent.initBubble(this, e);
  12643. }
  12644. }, {
  12645. key: "say",
  12646. value: function say(e, _ref2) {
  12647. var t = _ref2.id,
  12648. r = _ref2.isUser,
  12649. n = _ref2.background,
  12650. _ref2$font = _ref2.font,
  12651. o = _ref2$font === void 0 ? "Arial" : _ref2$font,
  12652. _ref2$fontsize = _ref2.fontsize,
  12653. a = _ref2$fontsize === void 0 ? 38 : _ref2$fontsize,
  12654. _ref2$fontcolor = _ref2.fontcolor,
  12655. s = _ref2$fontcolor === void 0 ? "#ffffff" : _ref2$fontcolor,
  12656. _ref2$fontstyle = _ref2.fontstyle,
  12657. l = _ref2$fontstyle === void 0 ? "bold" : _ref2$fontstyle,
  12658. _ref2$linesize = _ref2.linesize,
  12659. u = _ref2$linesize === void 0 ? 22 : _ref2$linesize,
  12660. c = _ref2.linelimit,
  12661. _ref2$offsets = _ref2.offsets,
  12662. h = _ref2$offsets === void 0 ? {
  12663. x: 0,
  12664. y: 0,
  12665. z: 40
  12666. } : _ref2$offsets,
  12667. _ref2$scale = _ref2.scale,
  12668. f = _ref2$scale === void 0 ? this._avatarScale : _ref2$scale,
  12669. _ref2$compensationZ = _ref2.compensationZ,
  12670. d = _ref2$compensationZ === void 0 ? 11.2 : _ref2$compensationZ,
  12671. _ref2$reregistAnyway = _ref2.reregistAnyway,
  12672. _ = _ref2$reregistAnyway === void 0 ? !0 : _ref2$reregistAnyway;
  12673. return this.bbComponent.say(this, e, {
  12674. id: t,
  12675. isUser: r,
  12676. background: n,
  12677. font: o,
  12678. fontsize: a,
  12679. fontcolor: s,
  12680. fontstyle: l,
  12681. linesize: u,
  12682. linelimit: c,
  12683. offsets: h,
  12684. scale: f,
  12685. compensationZ: d,
  12686. reregistAnyway: _
  12687. });
  12688. }
  12689. }, {
  12690. key: "silent",
  12691. value: function silent() {
  12692. return this.bbComponent.silent();
  12693. }
  12694. }, {
  12695. key: "setNickName",
  12696. value: function setNickName(e, _ref3) {
  12697. var t = _ref3.id,
  12698. r = _ref3.isUser,
  12699. n = _ref3.background,
  12700. _ref3$font = _ref3.font,
  12701. o = _ref3$font === void 0 ? "Arial" : _ref3$font,
  12702. _ref3$fontsize = _ref3.fontsize,
  12703. a = _ref3$fontsize === void 0 ? 40 : _ref3$fontsize,
  12704. _ref3$fontcolor = _ref3.fontcolor,
  12705. s = _ref3$fontcolor === void 0 ? "#ffffff" : _ref3$fontcolor,
  12706. _ref3$fontstyle = _ref3.fontstyle,
  12707. l = _ref3$fontstyle === void 0 ? "bold" : _ref3$fontstyle,
  12708. _ref3$linesize = _ref3.linesize,
  12709. u = _ref3$linesize === void 0 ? 22 : _ref3$linesize,
  12710. c = _ref3.linelimit,
  12711. _ref3$offsets = _ref3.offsets,
  12712. h = _ref3$offsets === void 0 ? {
  12713. x: 0,
  12714. y: 0,
  12715. z: 15
  12716. } : _ref3$offsets,
  12717. _ref3$scale = _ref3.scale,
  12718. f = _ref3$scale === void 0 ? this._avatarScale : _ref3$scale,
  12719. _ref3$compensationZ = _ref3.compensationZ,
  12720. d = _ref3$compensationZ === void 0 ? 0 : _ref3$compensationZ,
  12721. _ref3$reregistAnyway = _ref3.reregistAnyway,
  12722. _ = _ref3$reregistAnyway === void 0 ? !1 : _ref3$reregistAnyway;
  12723. return this.bbComponent.setNickName(this, e, {
  12724. id: t,
  12725. isUser: r,
  12726. background: n,
  12727. font: o,
  12728. fontsize: a,
  12729. fontcolor: s,
  12730. fontstyle: l,
  12731. linesize: u,
  12732. linelimit: c,
  12733. offsets: h,
  12734. scale: f,
  12735. compensationZ: d,
  12736. reregistAnyway: _
  12737. });
  12738. }
  12739. }, {
  12740. key: "generateButtons",
  12741. value: function generateButtons() {
  12742. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  12743. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this._avatarScale;
  12744. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 85;
  12745. return this.bbComponent.generateButtons(this, e, t, r);
  12746. }
  12747. }, {
  12748. key: "clearButtons",
  12749. value: function clearButtons() {
  12750. return this.bbComponent.clearButtons();
  12751. }
  12752. }, {
  12753. key: "attachExtraProp",
  12754. value: function attachExtraProp(e, t, r, n) {
  12755. return this.component.addDecoComp(this, e, t, r, n);
  12756. }
  12757. }, {
  12758. key: "showExtra",
  12759. value: function showExtra(e) {
  12760. return this.component.showExtra(e);
  12761. }
  12762. }, {
  12763. key: "hideExtra",
  12764. value: function hideExtra(e) {
  12765. return this.component.hideExtra(e);
  12766. }
  12767. }, {
  12768. key: "disposeExtra",
  12769. value: function disposeExtra() {
  12770. return this.component.disposeExtra();
  12771. }
  12772. }, {
  12773. key: "getSkeletonPositionByName",
  12774. value: function getSkeletonPositionByName(e) {
  12775. var t;
  12776. if (this.skeleton) {
  12777. var r = this.skeleton.bones.find(function (n) {
  12778. return n.name.replace("Clone of ", "") == e;
  12779. });
  12780. if (r && r.getTransformNode() && ((t = r.getTransformNode()) == null ? void 0 : t.position)) {
  12781. var n = r.getTransformNode().position;
  12782. return xversePosition2Ue4({
  12783. x: n.x,
  12784. y: n.y,
  12785. z: n.z
  12786. });
  12787. }
  12788. }
  12789. }
  12790. }, {
  12791. key: "shootTo",
  12792. value: function shootTo(e, t) {
  12793. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2;
  12794. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 10;
  12795. var o = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
  12796. x: 0,
  12797. y: 0,
  12798. z: 150
  12799. };
  12800. return this.stateMachine.sendObjectTo(this, e, t, r, n, o);
  12801. }
  12802. }]);
  12803. return XAvatar;
  12804. }();
  12805. 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; } } }; }
  12806. 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); }
  12807. 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; }
  12808. var XAvatarManager = /*#__PURE__*/function () {
  12809. function XAvatarManager(e) {
  12810. var _this = this;
  12811. _classCallCheck(this, XAvatarManager);
  12812. this.characterMap = new Map();
  12813. this.curAnimList = [];
  12814. this.extraComps = new Map();
  12815. this._mainUser = null;
  12816. this._lodSettings = null;
  12817. this.maxBillBoardDist = 0;
  12818. this.maxAvatarNum = 0;
  12819. this.currentLODUsers = [];
  12820. this.bboxMeshPool = null;
  12821. this._distLevels = [];
  12822. this._maxLODUsers = [];
  12823. this._cullingDistance = 0;
  12824. this._maxDistRange = null;
  12825. this._delayTime = 100;
  12826. this._queueLength = -1;
  12827. this._queue = [];
  12828. this._processList = [];
  12829. this._process = null;
  12830. this._updateLoopObserver = null;
  12831. this._avatarInDistance = [];
  12832. this._renderedAvatar = [];
  12833. this._enableNickname = !0;
  12834. this._tickObserver = null;
  12835. this._tickInterval = null;
  12836. this._defaultAnims = null;
  12837. this._tickDispose = 0;
  12838. this._disposeTime = 100;
  12839. this.avatarLoader = avatarLoader;
  12840. this._scene = e.mainScene;
  12841. this._sceneManager = e;
  12842. this.initAvatarMap();
  12843. this._initSettings();
  12844. 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;
  12845. var t = 0;
  12846. this._tickObserver = this._scene.onAfterRenderObservable.add(function () {
  12847. t += 1, t == _this._tickInterval && (_this.tick(), t = 0);
  12848. });
  12849. }
  12850. _createClass(XAvatarManager, [{
  12851. key: "tick",
  12852. value: function tick() {
  12853. this.bboxMeshPool.clean(0);
  12854. }
  12855. }, {
  12856. key: "createBboxAsset",
  12857. value: function createBboxAsset(e, t, r, n) {
  12858. return BABYLON.MeshBuilder.CreateBox("avatarBbox", {
  12859. width: t,
  12860. height: r,
  12861. depth: n
  12862. }, e);
  12863. }
  12864. }, {
  12865. key: "resetBboxAsset",
  12866. value: function resetBboxAsset(e) {
  12867. var t = e.data;
  12868. return t.setEnabled(!1), t.isPickable = !1, e;
  12869. }
  12870. }, {
  12871. key: "_initSettings",
  12872. value: function _initSettings() {
  12873. this._defaultAnims = avatarSetting.defaultIdle, this._lodSettings = avatarSetting.lod, this._distLevels = avatarSetting.lod.map(function (e) {
  12874. return e.dist;
  12875. }), this._maxLODUsers = avatarSetting.lod.map(function (e) {
  12876. return e.quota;
  12877. }), this.currentLODUsers = new Array(this._distLevels.length).fill(0), this.maxAvatarNum = avatarSetting.maxAvatarNum, this.maxBillBoardDist = avatarSetting.maxBillBoardDist, this._cullingDistance = avatarSetting.cullingDistance;
  12878. }
  12879. }, {
  12880. key: "maxRenderNum",
  12881. value: function maxRenderNum() {
  12882. var e = 0;
  12883. return this._maxLODUsers.forEach(function (t) {
  12884. e += t;
  12885. }), e;
  12886. }
  12887. }, {
  12888. key: "curRenderNum",
  12889. value: function curRenderNum() {
  12890. var e = 0;
  12891. return this.currentLODUsers.forEach(function (t) {
  12892. e += t;
  12893. }), e;
  12894. }
  12895. }, {
  12896. key: "setLoDLevels",
  12897. value: function setLoDLevels(e) {
  12898. this._distLevels = e;
  12899. }
  12900. }, {
  12901. key: "cullingDistance",
  12902. get: function get() {
  12903. return this._cullingDistance;
  12904. },
  12905. set: function set(e) {
  12906. this._cullingDistance = e;
  12907. }
  12908. }, {
  12909. key: "getLoDLevels",
  12910. value: function getLoDLevels() {
  12911. return this._distLevels;
  12912. }
  12913. }, {
  12914. key: "setLodUserLimits",
  12915. value: function setLodUserLimits(e, t) {
  12916. this._maxLODUsers.length > e && (this._maxLODUsers[e] = t);
  12917. }
  12918. }, {
  12919. key: "setLodDist",
  12920. value: function setLodDist(e, t) {
  12921. this._distLevels[e] = t;
  12922. }
  12923. }, {
  12924. key: "setMaxDistRange",
  12925. value: function setMaxDistRange(e) {
  12926. this._maxDistRange = e, this._distLevels[this._distLevels.length - 1] = e;
  12927. }
  12928. }, {
  12929. key: "scene",
  12930. get: function get() {
  12931. return this._scene;
  12932. }
  12933. }, {
  12934. key: "setMainAvatar",
  12935. value: function setMainAvatar(e) {
  12936. var t;
  12937. this._mainUser = (t = this.characterMap.get(0)) == null ? void 0 : t.get(e);
  12938. }
  12939. }, {
  12940. key: "getMainAvatar",
  12941. value: function getMainAvatar() {
  12942. return this._mainUser;
  12943. }
  12944. }, {
  12945. key: "enableAllNickname",
  12946. value: function enableAllNickname(e) {
  12947. var _this2 = this;
  12948. return this.characterMap.forEach(function (t, r) {
  12949. r != 0 && t.forEach(function (n, o) {
  12950. _this2._updateBillboardStatus(n, e ? BillboardStatus.SHOW : BillboardStatus.HIDE);
  12951. });
  12952. }), this._enableNickname = e;
  12953. }
  12954. }, {
  12955. key: "getAvatarById",
  12956. value: function getAvatarById(e) {
  12957. var t;
  12958. return this.characterMap.forEach(function (r, n) {
  12959. r.get(e) && (t = r.get(e));
  12960. }), t;
  12961. }
  12962. }, {
  12963. key: "getAvatarNums",
  12964. value: function getAvatarNums() {
  12965. var e = 0;
  12966. return this.characterMap.forEach(function (t, r) {
  12967. e += t.size;
  12968. }), e;
  12969. }
  12970. }, {
  12971. key: "registerAvatar",
  12972. value: function registerAvatar(e) {
  12973. this.characterMap.get(e.priority).set(e.id, e);
  12974. }
  12975. }, {
  12976. key: "unregisterAvatar",
  12977. value: function unregisterAvatar(e) {
  12978. this.characterMap.get(e.priority).delete(e.id);
  12979. }
  12980. }, {
  12981. key: "initAvatarMap",
  12982. value: function initAvatarMap() {
  12983. 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());
  12984. }
  12985. }, {
  12986. key: "loadAvatar",
  12987. value: function loadAvatar(_ref) {
  12988. var _this3 = this;
  12989. var e = _ref.id,
  12990. t = _ref.avatarType,
  12991. r = _ref.priority,
  12992. n = _ref.avatarManager,
  12993. o = _ref.assets,
  12994. a = _ref.status;
  12995. return new Promise(function (s, l) {
  12996. if (_this3.getAvatarById(e)) return l(new DuplicateAvatarIDError("[Engine] cannot init avatar with the same id = ".concat(e)));
  12997. if (_this3.getAvatarNums() > _this3.maxAvatarNum) return l(new ExceedMaxAvatarNumError("[Engine] \u8D85\u51FA\u6700\u5927\u89D2\u8272\u9650\u5236 ".concat(_this3.maxAvatarNum)));
  12998. var u = new XAvatar({
  12999. id: e,
  13000. avatarType: t,
  13001. priority: r,
  13002. avatarManager: n,
  13003. assets: o,
  13004. status: a
  13005. });
  13006. if (_this3.registerAvatar(u), r == 0) _this3.setMainAvatar(u.id), _this3.addAvatarToScene(u, 0).then(function (c) {
  13007. return logger$1.debug("[Engine] avatar ".concat(u.id, " has been added to scene")), c ? (_this3._updateBillboardStatus(c, BillboardStatus.SHOW), setTimeout(function () {
  13008. _this3.launchProcessLoadingLoop();
  13009. }, _this3._delayTime), s(c)) : (u.removeAvatarFromScene(), l(new AvatarAssetLoadingError()));
  13010. }).catch(function (c) {
  13011. return u.removeAvatarFromScene(), l(new AvatarAssetLoadingError(c));
  13012. });else return s(u);
  13013. });
  13014. }
  13015. }, {
  13016. key: "deleteAvatar",
  13017. value: function deleteAvatar(e) {
  13018. return e.isRender ? (e.removeAvatarFromScene(), this.currentLODUsers[e.distLevel]--) : e.bbComponent.disposeBillBoard(e), this._processList = this._processList.filter(function (t) {
  13019. return t.id !== e.id;
  13020. }), this.unregisterAvatar(e), e.rootNode && (e.rootNode.dispose(), e.rootNode = void 0), e.bbComponent.bbox && e.bbComponent.bbox.dispose(), e.removeObserver(), e;
  13021. }
  13022. }, {
  13023. key: "_checkLODLevel",
  13024. value: function _checkLODLevel(e) {
  13025. if (e < this._distLevels[0]) return 0;
  13026. for (var t = 1; t < this._distLevels.length; ++t) {
  13027. if (e >= this._distLevels[t - 1] && e < this._distLevels[t]) return t;
  13028. }
  13029. return this._distLevels.length - 1;
  13030. }
  13031. }, {
  13032. key: "sceneManager",
  13033. get: function get() {
  13034. return this._sceneManager;
  13035. }
  13036. }, {
  13037. key: "launchProcessLoadingLoop",
  13038. value: function launchProcessLoadingLoop() {
  13039. this._updateAvatarStatus();
  13040. }
  13041. }, {
  13042. key: "stopProcessLoadingLoop",
  13043. value: function stopProcessLoadingLoop() {
  13044. var e;
  13045. this._updateLoopObserver && ((e = this._scene) == null || e.onBeforeRenderObservable.remove(this._updateLoopObserver));
  13046. }
  13047. }, {
  13048. key: "_distToMain",
  13049. value: function _distToMain(e) {
  13050. var n;
  13051. var t = (n = this._mainUser) == null ? void 0 : n.position,
  13052. r = e.position;
  13053. if (r && t) {
  13054. var o = this.sceneManager.cameraComponent.MainCamera.getFrontPosition(1).subtract(this.sceneManager.cameraComponent.MainCamera.position).normalize(),
  13055. a = e.rootNode.position.subtract(this.sceneManager.cameraComponent.MainCamera.position).normalize();
  13056. var s = 1;
  13057. if (o && a) {
  13058. var l = a.multiply(o);
  13059. s = Math.acos(l.x + l.y + l.z) < this.sceneManager.cameraComponent.MainCamera.fov / 2 ? 1 : 1e11;
  13060. }
  13061. return calcDistance3D(t, r) * s;
  13062. } else return logger$1.warn("user position or camera position is not correct!"), 1e11;
  13063. }
  13064. }, {
  13065. key: "_distToCamera",
  13066. value: function _distToCamera(e) {
  13067. var n;
  13068. var t = (n = this._sceneManager) == null ? void 0 : n.cameraComponent.getCameraPose().position,
  13069. r = e.position;
  13070. return r && t ? calcDistance3D(t, r) : (logger$1.warn("user position or camera position is not correct!"), 1e11);
  13071. }
  13072. }, {
  13073. key: "showAll",
  13074. value: function showAll(e) {
  13075. this.characterMap.forEach(function (t, r) {
  13076. e && r == 0 && t.forEach(function (n, o) {
  13077. n.show();
  13078. }), r != 0 && t.forEach(function (n, o) {
  13079. n.show();
  13080. });
  13081. });
  13082. }
  13083. }, {
  13084. key: "hideAll",
  13085. value: function hideAll(e) {
  13086. this.characterMap.forEach(function (t, r) {
  13087. e && r == 0 && t.forEach(function (n, o) {
  13088. n.hide();
  13089. }), r != 0 && t.forEach(function (n, o) {
  13090. n.hide();
  13091. });
  13092. });
  13093. }
  13094. }, {
  13095. key: "_assemblyAvatar",
  13096. value: function _assemblyAvatar(e, t) {
  13097. var _this4 = this;
  13098. var n, o;
  13099. var r = e.get(avatarSetting.body);
  13100. if (r && !t.attachBody(r)) {
  13101. t.isInLoadingList = !1, e.clear();
  13102. return;
  13103. }
  13104. var _iterator = _createForOfIteratorHelper$1(e),
  13105. _step;
  13106. try {
  13107. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  13108. var a = _step.value;
  13109. if (a[0] != avatarSetting.body && a[0] != avatarSetting.animations && !t.attachDecoration(a[1])) {
  13110. t.isInLoadingList = !1, t.removeAvatarFromScene(), e.clear();
  13111. return;
  13112. }
  13113. }
  13114. } catch (err) {
  13115. _iterator.e(err);
  13116. } finally {
  13117. _iterator.f();
  13118. }
  13119. t.isRender = !0, (n = t.controller) == null || n.playAnimation(t.controller.onPlay, t.controller.loop), (o = t.controller) == null || o.onPlayObservable.addOnce(function () {
  13120. var a, s;
  13121. if (!_this4.getAvatarById(t.id)) {
  13122. t.isInLoadingList = !1, t.removeAvatarFromScene(), _this4.currentLODUsers[t.distLevel]--;
  13123. return;
  13124. }
  13125. if (_this4.getAvatarById(t.id).rootNode.getChildMeshes().length < e.size) {
  13126. 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]--;
  13127. return;
  13128. }
  13129. 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));
  13130. });
  13131. }
  13132. }, {
  13133. key: "_disposeUnusedAssets",
  13134. value: function _disposeUnusedAssets() {
  13135. this._tickDispose++, this._tickDispose > this._disposeTime && (avatarLoader.disposeContainer(), this._tickDispose = 0);
  13136. }
  13137. }, {
  13138. key: "_addResourcesToList",
  13139. value: function _addResourcesToList(e, t) {
  13140. var _this5 = this;
  13141. return e.clothesList.forEach(function (r) {
  13142. r.lod = t, _this5._queue.push(r);
  13143. }), this._queue.push({
  13144. type: avatarSetting.animations,
  13145. id: this._defaultAnims
  13146. }), this._queue.push({
  13147. type: avatarSetting.body,
  13148. id: e.avatarType,
  13149. lod: t
  13150. }), !0;
  13151. }
  13152. }, {
  13153. key: "_updateBillboardStatus",
  13154. value: function _updateBillboardStatus(e, t) {
  13155. e.bbComponent.updateBillboardStatus(e, t);
  13156. }
  13157. }, {
  13158. key: "_processLayer",
  13159. value: function _processLayer(e) {
  13160. var _this6 = this;
  13161. var t = this.characterMap.get(e),
  13162. r = [];
  13163. for (t == null || t.forEach(function (n) {
  13164. n.distToCam = _this6._distToCamera(n);
  13165. var o = n.distToCam < _this6._cullingDistance;
  13166. if (n.isRender && (!n.isHide && o ? n._hide_culling() : n._show_culling()), n.priority != 0) {
  13167. n.distance = _this6._distToMain(n);
  13168. var _a = BillboardStatus.SHOW;
  13169. 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));
  13170. }
  13171. }), r.sort(function (n, o) {
  13172. return o.distance - n.distance;
  13173. }); r.length > 0 && this.curRenderNum() < this.maxRenderNum();) {
  13174. var n = r.pop();
  13175. var o = this._checkLODLevel(n.distance),
  13176. a = !1;
  13177. for (var s = 0; s < this._maxLODUsers.length; ++s) {
  13178. if (this.currentLODUsers[s] < this._maxLODUsers[s]) {
  13179. o = s, a = !0;
  13180. break;
  13181. }
  13182. }
  13183. if (!a || n.distance > this._maxDistRange) {
  13184. if (n.isRender) {
  13185. n._removeAvatarFromScene();
  13186. var _s = BillboardStatus.HIDE;
  13187. n.distance < this._maxDistRange && (_s = BillboardStatus.SHOW), this._updateBillboardStatus(n, _s);
  13188. }
  13189. break;
  13190. }
  13191. 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]++;
  13192. }
  13193. return this.curRenderNum() >= this.maxRenderNum() && r.forEach(function (n) {
  13194. if (n.isRender) {
  13195. n._removeAvatarFromScene();
  13196. var _o = BillboardStatus.HIDE;
  13197. n.distance < _this6._maxDistRange && (_o = BillboardStatus.SHOW), _this6._updateBillboardStatus(n, _o);
  13198. }
  13199. }), this.curRenderNum() < this.maxRenderNum();
  13200. }
  13201. }, {
  13202. key: "_updateAvatar",
  13203. value: function _updateAvatar() {
  13204. var _this7 = this;
  13205. this.currentLODUsers = [0, 0, 0];
  13206. var e = [5, 4, 3, 2, 1, 0];
  13207. for (; e.length > 0;) {
  13208. var t = e.pop();
  13209. if (!this._processLayer(t)) {
  13210. e.forEach(function (n) {
  13211. var o;
  13212. (o = _this7.characterMap.get(n)) == null || o.forEach(function (a) {
  13213. a.distance = _this7._distToMain(a);
  13214. var s = BillboardStatus.HIDE;
  13215. a.distToCam < _this7._maxDistRange && (s = BillboardStatus.SHOW, a.isRender && a._removeAvatarFromScene()), _this7._updateBillboardStatus(a, s);
  13216. });
  13217. });
  13218. break;
  13219. }
  13220. }
  13221. }
  13222. }, {
  13223. key: "_updateAvatarStatus",
  13224. value: function _updateAvatarStatus() {
  13225. var _this8 = this;
  13226. var e = new Map();
  13227. this._updateLoopObserver = this.scene.onBeforeRenderObservable.add(function () {
  13228. var t;
  13229. if (_this8._disposeUnusedAssets(), !(_this8.getAvatarNums() <= 0)) {
  13230. if (!_this8._process && _this8._processList.length == 0 && _this8._updateAvatar(), !_this8._process && _this8._processList.length > 0) {
  13231. var r = _this8._processList.shift();
  13232. 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;
  13233. }
  13234. if (e.size === _this8._queueLength && _this8._process) {
  13235. _this8._process.pendingLod && (_this8._process.pendingLod = !1, _this8._process._removeAvatarFromScene());
  13236. var _r = Date.now();
  13237. _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();
  13238. }
  13239. _this8._loadResByList(e);
  13240. }
  13241. });
  13242. }
  13243. }, {
  13244. key: "_loadResByList",
  13245. value: function _loadResByList(e) {
  13246. var _this9 = this;
  13247. var t = 0;
  13248. var r = 5;
  13249. if (!this._process) {
  13250. e.clear();
  13251. return;
  13252. }
  13253. var _loop = function _loop() {
  13254. var n = Date.now(),
  13255. o = _this9._queue.pop();
  13256. setTimeout(function () {
  13257. o ? o.type === avatarSetting.body ? _this9.loadBody(o.type, o.id, o.lod).then(function (a) {
  13258. a && e.set(avatarSetting.body, a), t += Date.now() - n;
  13259. }).catch(function (a) {
  13260. _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);
  13261. }) : o.type === avatarSetting.animations ? _this9.loadAnimation(_this9._process.avatarType, o.id).then(function (a) {
  13262. a && e.set(avatarSetting.animations, a), t += Date.now() - n;
  13263. }).catch(function (a) {
  13264. _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);
  13265. }) : _this9.loadDecoration(o.type, o.id, o.lod).then(function (a) {
  13266. a && e.set(a.type, a), t += Date.now() - n;
  13267. }).catch(function (a) {
  13268. _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);
  13269. }) : t += 100;
  13270. }, 0);
  13271. };
  13272. for (; t < r && this._queue.length > 0;) {
  13273. _loop();
  13274. }
  13275. }
  13276. }, {
  13277. key: "_validateContainer",
  13278. value: function _validateContainer(e) {
  13279. 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;
  13280. }
  13281. }, {
  13282. key: "_getAssetContainer",
  13283. value: function _getAssetContainer(e, t) {
  13284. var _this10 = this;
  13285. return new Promise(function (r, n) {
  13286. var o = _this10._getSourceKey(e, t || 0),
  13287. a = avatarLoader.containers.get(o);
  13288. if (a) return r(a);
  13289. avatarLoader.load(_this10.sceneManager, e, t).then(function (s) {
  13290. 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, ".")));
  13291. }).catch(function (s) {
  13292. return n(new ContainerLoadingFailedError("[Engine] ".concat(s, " :: cannot load body type ").concat(e, ".")));
  13293. });
  13294. });
  13295. }
  13296. }, {
  13297. key: "_clipContainerRes",
  13298. value: function _clipContainerRes(e) {
  13299. e.transformNodes.forEach(function (t) {
  13300. t.dispose();
  13301. }), e.transformNodes = [], e.skeletons.forEach(function (t) {
  13302. t.dispose();
  13303. }), e.skeletons = [];
  13304. }
  13305. }, {
  13306. key: "loadBody",
  13307. value: function loadBody(e, t, r) {
  13308. var _this11 = this;
  13309. return new Promise(function (n, o) {
  13310. return avatarLoader.load(_this11.sceneManager, t, r).then(function (a) {
  13311. if (a) {
  13312. var s = a.instantiateModelsToScene(); // 周恩光加 此时body_man缩放已经0.01
  13313. console.log("body_man缩放", s.rootNodes[0]._children[0]._scaling);
  13314. a.xReferenceCount++;
  13315. var l = {
  13316. isRender: !1,
  13317. uId: Math.random(),
  13318. root: s.rootNodes[0],
  13319. skeletonType: e,
  13320. name: t,
  13321. animations: s.animationGroups,
  13322. skeleton: s.skeletons[0],
  13323. lod: r
  13324. };
  13325. return s.rootNodes[0]._parentContainer = a, s.rootNodes[0].setEnabled(!1), n(l);
  13326. } else return o(new ContainerLoadingFailedError("[Engine] container failed instanciates failed"));
  13327. }).catch(function () {
  13328. return o(new ContainerLoadingFailedError("[Engine] body type ".concat(e, " instanciates failed")));
  13329. });
  13330. });
  13331. }
  13332. }, {
  13333. key: "updateAnimationLists",
  13334. value: function updateAnimationLists(e, t) {
  13335. return new Promise(function (r, n) {
  13336. return avatarLoader.avaliableAnimation.set(t, e), r();
  13337. });
  13338. }
  13339. }, {
  13340. key: "loadAnimation",
  13341. value: function loadAnimation(e, t) {
  13342. var _this12 = this;
  13343. return new Promise(function (r, n) {
  13344. return avatarLoader.loadAnimRes(_this12.sceneManager, t, e).then(function (o) {
  13345. if (o) {
  13346. var a;
  13347. var s = _this12.avatarLoader.animations;
  13348. return o.animationGroups.forEach(function (l) {
  13349. l.stop(), l.name === t && (a = l, a.pContainer = o), s.set(getAnimationKey(l.name, e), l);
  13350. }), _this12._clipContainerRes(o), o.xReferenceCount++, r(a);
  13351. } else return n(new ContainerLoadingFailedError("[Engine] container failed instanciates failed"));
  13352. });
  13353. });
  13354. }
  13355. }, {
  13356. key: "loadDecoration",
  13357. value: function loadDecoration(e, t, r) {
  13358. var _this13 = this;
  13359. return new Promise(function (n, o) {
  13360. return avatarLoader.load(_this13.sceneManager, t, r).then(function (a) {
  13361. if (a) {
  13362. _this13._clipContainerRes(a);
  13363. var s = a.meshes[1].clone(a.meshes[1].name, null); // 周恩光加 装饰模型scale矫正
  13364. s.scaling = new BABYLON.Vector3(-0.01, 0.01, -0.01);
  13365. if (!s) {
  13366. logger$1.warn("[Engine] decoration does not exist!"), n(null);
  13367. return;
  13368. }
  13369. var l = {
  13370. isRender: !1,
  13371. uId: Math.random(),
  13372. root: s,
  13373. type: e,
  13374. name: t,
  13375. isSelected: !1,
  13376. lod: r
  13377. };
  13378. if (a.xReferenceCount++, s._parentContainer = a, a.meshes.length > 1) for (var u = 2; u < a.meshes.length; u++) {
  13379. s.addChild(a.meshes[u].clone(a.meshes[u].name, null));
  13380. }
  13381. s.setEnabled(!1), l.isSelected = !0, n(l);
  13382. } else return o(new ContainerLoadingFailedError("[Engine] container failed, instanciates failed."));
  13383. }).catch(function () {
  13384. return o(new ContainerLoadingFailedError("[Engine] body type ".concat(e, " instanciates failed.")));
  13385. });
  13386. });
  13387. }
  13388. }, {
  13389. key: "_getSourceKey",
  13390. value: function _getSourceKey(e, t) {
  13391. return t && avatarSetting.lod[t] ? e + avatarSetting.lod[t].fileName.split(".")[0] : e;
  13392. }
  13393. }, {
  13394. key: "addAvatarToScene",
  13395. value: function addAvatarToScene(e, t) {
  13396. var _this14 = this;
  13397. var r = Date.now();
  13398. return new Promise(function (n, o) {
  13399. _this14.loadBody(e.avatarType, e.avatarType, t).then(function (a) {
  13400. // console.error(a.root._children[0]._scaling)
  13401. var s;
  13402. if (!a) return e.isInLoadingList = !1, o(new ContainerLoadingFailedError("[Engine] avatar ".concat(e.id, " instanciates failed")));
  13403. if (e.attachBody(a), a.animations.length > 0) return a.animations.forEach(function (l) {
  13404. l.stop();
  13405. }), 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);
  13406. _this14.loadAnimation(e.avatarType, _this14._defaultAnims).then(function (l) {
  13407. if (!l) return e.removeAvatarFromScene(), e.isInLoadingList = !1, o(new AvatarAnimationError());
  13408. var u = [];
  13409. e.clothesList.length > 0 && e.clothesList.forEach(function (c) {
  13410. u.push(_this14.loadDecoration(c.type, c.id, t));
  13411. }), Promise.all(u).then(function (c) {
  13412. var d, _, g, m;
  13413. c.forEach(function (v) {
  13414. if (v && !v.isRender) e.attachDecoration(v);else return e.isInLoadingList = !1, e.removeAvatarFromScene(), o(new AvatarAssetLoadingError());
  13415. }), e.isRender = !0, (d = e.controller) == null || d.playAnimation(e.controller.onPlay, e.controller.loop), e.setAvatarVisible(!0);
  13416. var h = avatarLoader.mshPath.get("meshes/ygb.glb"),
  13417. f = avatarLoader.matPath.get(avatarResources.ygb.mesh);
  13418. h && f ? _this14.loadExtra(f, h).then(function (v) {
  13419. var y;
  13420. e.isRender = !0, e.isInLoadingList = !1, e.distLevel = t, (y = _this14._sceneManager) == null || y.engineRunTimeStats.timeArray_addAvatarToScene.add(Date.now() - r), n(e);
  13421. }) : (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);
  13422. }).catch(function () {
  13423. return o(new AvatarAssetLoadingError("[Engine] avatar ".concat(e.id, " instanciates failed.")));
  13424. });
  13425. }).catch(function () {
  13426. return o(new AvatarAssetLoadingError("[Engine] avatar ".concat(e.id, " instanciates failed.")));
  13427. });
  13428. }).catch(function () {
  13429. return o(new AvatarAssetLoadingError("[Engine] avatar ".concat(e.id, " instanciates failed.")));
  13430. });
  13431. });
  13432. }
  13433. }, {
  13434. key: "loadExtra",
  13435. value: function loadExtra(e, t) {
  13436. var _this15 = this;
  13437. var r = avatarResources.ygb.name;
  13438. return new Promise(function (n, o) {
  13439. var a;
  13440. (a = _this15.sceneManager) == null || a.urlTransformer(e).then(function (s) {
  13441. BABYLON.SceneLoader.LoadAssetContainerAsync("", s, _this15.scene, null, avatarSetting.fileType).then(function (l) {
  13442. var c;
  13443. _this15.extraComps.set(r, l.meshes[0]);
  13444. var u = new NodeMaterial("material_".concat(r), _this15._scene, {
  13445. emitComments: !1
  13446. });
  13447. (c = _this15.sceneManager) == null || c.urlTransformer(t).then(function (h) {
  13448. u.loadAsync(h).then(function () {
  13449. l.meshes[2].material.dispose(!0, !0), u.build(!1), l.meshes[2].material = u, n(l.meshes[2]);
  13450. });
  13451. });
  13452. });
  13453. });
  13454. });
  13455. }
  13456. }, {
  13457. key: "getAvatarList",
  13458. value: function getAvatarList() {
  13459. var e = [];
  13460. return this.characterMap.forEach(function (t, r) {
  13461. t.forEach(function (n, o) {
  13462. e.push(n);
  13463. });
  13464. }), e;
  13465. }
  13466. }, {
  13467. key: "_debug_avatar",
  13468. value: function _debug_avatar() {
  13469. var t, r;
  13470. 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);
  13471. var e = 0;
  13472. this.getAvatarList().forEach(function (n) {
  13473. 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++);
  13474. }), console.error("========= avatar num", e), console.error("loop:", this._updateLoopObserver ? "on" : "false", "=> process", this._process, "===> comp", this._processList), console.error("===>maxLODUsers", this._maxLODUsers);
  13475. }
  13476. }]);
  13477. return XAvatarManager;
  13478. }();
  13479. var XBillboard = /*#__PURE__*/function () {
  13480. function XBillboard(e) {
  13481. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
  13482. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
  13483. _classCallCheck(this, XBillboard);
  13484. E(this, "_mesh", null);
  13485. E(this, "_texture", null);
  13486. E(this, "_scalingFactor", 1);
  13487. E(this, "offsets", null);
  13488. E(this, "_pickable");
  13489. E(this, "_background", null);
  13490. E(this, "_billboardManager");
  13491. E(this, "poolobj", null);
  13492. E(this, "_usePool");
  13493. E(this, "_initMeshScale", new BABYLON.Vector3(1, 1, 1));
  13494. E(this, "_status", -1);
  13495. E(this, "_stageChanged", !1);
  13496. E(this, "DEFAULT_CONFIGS", {});
  13497. this._billboardManager = e, this._pickable = t, this._usePool = r;
  13498. }
  13499. _createClass(XBillboard, [{
  13500. key: "scalingFactor",
  13501. set: function set(e) {
  13502. this._scalingFactor = e;
  13503. }
  13504. }, {
  13505. key: "background",
  13506. set: function set(e) {
  13507. this._background = e;
  13508. }
  13509. }, {
  13510. key: "size",
  13511. get: function get() {
  13512. return -1;
  13513. }
  13514. }, {
  13515. key: "setStatus",
  13516. value: function setStatus(e) {
  13517. e != this._status && (this._stageChanged = !0, this._status = e);
  13518. }
  13519. }, {
  13520. key: "status",
  13521. get: function get() {
  13522. return this._status;
  13523. }
  13524. }, {
  13525. key: "stageChanged",
  13526. get: function get() {
  13527. return this._stageChanged;
  13528. },
  13529. set: function set(e) {
  13530. this._stageChanged = e;
  13531. }
  13532. }, {
  13533. key: "init",
  13534. value: function init() {
  13535. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
  13536. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : .001;
  13537. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : .001;
  13538. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !1;
  13539. var o = this._billboardManager.sceneManager.Scene;
  13540. if (this._usePool) {
  13541. var a = this._billboardManager.billboardPool.getFree(o, t, r, n);
  13542. this._mesh = a.data, this._mesh.isPickable = this._pickable, this._mesh.xid = e, this._mesh.xtype = EMeshType.XBillboard, this._texture = this._mesh.material.diffuseTexture, this.poolobj = a;
  13543. } else this._mesh = this._billboardManager.createBillboardAsset(o, n);
  13544. this._mesh.isPickable = this._pickable, this._initMeshScale.x = t * 1e3, this._initMeshScale.y = r * 1e3, this._mesh.xid = e, this._mesh.xtype = EMeshType.XBillboard, this._texture = this._mesh.material.diffuseTexture, this.setStatus(1), this._stageChanged = !0;
  13545. }
  13546. }, {
  13547. key: "dispose",
  13548. value: function dispose() {
  13549. this._usePool ? this.poolobj && (this._billboardManager.billboardPool.release(this.poolobj), this._mesh = null, this._texture = null, this.poolobj = null) : this._mesh && (this._mesh.dispose(!0, !0), this._mesh = null, this._texture = null), this._background = null;
  13550. }
  13551. }, {
  13552. key: "getMesh",
  13553. value: function getMesh() {
  13554. return this._mesh;
  13555. }
  13556. }, {
  13557. key: "updateImage",
  13558. value: function updateImage(e) {
  13559. var _this = this;
  13560. return new Promise(function (t) {
  13561. if (_this._texture == null) {
  13562. logger$1.error("[Engine]Billboard texture not found");
  13563. return;
  13564. }
  13565. var r = _this._mesh,
  13566. n = _this._texture,
  13567. o = _this._scalingFactor,
  13568. a = _this._initMeshScale.x,
  13569. s = _this._initMeshScale.y,
  13570. l = _this._texture.getContext(),
  13571. u = _this._texture.getSize();
  13572. l.clearRect(0, 0, u.width, u.height);
  13573. var c = new Image();
  13574. c.crossOrigin = "anonymous", c.src = e, c.onload = function () {
  13575. var h = c.width * o,
  13576. f = c.height * o;
  13577. r.scaling.x = h * a, r.scaling.y = f * s, n.scaleTo(h, f), l.drawImage(c, 0, 0, h, f), n.hasAlpha = !0, n.update(), t();
  13578. };
  13579. });
  13580. }
  13581. }, {
  13582. key: "show",
  13583. value: function show() {
  13584. this._mesh && (this._mesh.setEnabled(!0), this._mesh.isPickable = this._pickable);
  13585. }
  13586. }, {
  13587. key: "hide",
  13588. value: function hide() {
  13589. this._mesh && (this._mesh.setEnabled(!1), this._mesh.isPickable = !1);
  13590. }
  13591. }, {
  13592. key: "setId",
  13593. value: function setId(e) {
  13594. this._mesh && (this._mesh.xid = e);
  13595. }
  13596. }, {
  13597. key: "setPosition",
  13598. value: function setPosition(e) {
  13599. if (e && this._mesh) {
  13600. var t = ue4Position2Xverse(e);
  13601. this._mesh.position = t;
  13602. }
  13603. }
  13604. }, {
  13605. key: "updateText",
  13606. value: function updateText(e, t) {
  13607. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !0;
  13608. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
  13609. var o = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 30;
  13610. var a = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : "monospace";
  13611. var s = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : "black";
  13612. var l = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : "bold";
  13613. var u = arguments.length > 8 ? arguments[8] : undefined;
  13614. if (this._texture == null) {
  13615. logger$1.error("[Engine]Billboard texture not found");
  13616. return;
  13617. }
  13618. var c = this._texture,
  13619. h = this._mesh,
  13620. f = this._scalingFactor,
  13621. d = this._initMeshScale.x,
  13622. _ = this._initMeshScale.y;
  13623. if (e != "") {
  13624. var g = this._texture.getContext(),
  13625. m = this._texture.getSize();
  13626. g.clearRect(0, 0, m.width, m.height);
  13627. var v = new Image();
  13628. if (r) {
  13629. t != null ? t ? this._background = this._billboardManager.userBackGroundBlob : this._background = this._billboardManager.npcBackGroundBlob : this._background || (this._background = this._billboardManager.userBackGroundBlob);
  13630. var y = e,
  13631. b = u && u < n.length - 1 ? u : n.length - 1;
  13632. if (this._background) {
  13633. if (b > this._background.length) {
  13634. for (var T = 0; T < b - this._background.length; T++) {
  13635. n.pop();
  13636. }
  13637. b = n.length - 1, y = e.slice(0, n[b] - 1) + String.fromCharCode(8230);
  13638. }
  13639. v.crossOrigin = "anonymous", v.src = this._background[b - 1], v.onload = function () {
  13640. var T = v.width * f,
  13641. C = v.height * f;
  13642. h.scaling.x = T * d, h.scaling.y = C * _, c.scaleTo(T, C), g.textAlign = "center", g.textBaseline = "middle", g.drawImage(v, 0, 0, T, C);
  13643. for (var A = 0; A < b; A++) {
  13644. c.drawText(y.slice(n[0 + A], n[1 + A]), T / 2, C * (A + 1) / (b + 1) + (A - (b - 1) / 2) * f * 10, l + " " + o * f + "px " + a, s, "transparent", !0);
  13645. }
  13646. c.hasAlpha = !0;
  13647. };
  13648. }
  13649. } else {
  13650. var _y = u && u < n.length - 1 ? u : n.length - 1,
  13651. _b = 480 * f,
  13652. _T = 60 * f * _y;
  13653. this._mesh.scaling = new BABYLON.Vector3(_b * d, _T * _, 1), c.scaleTo(_b, _T);
  13654. var C = c.getContext();
  13655. C.textAlign = "center", C.textBaseline = "middle";
  13656. for (var A = 0; A < _y; A++) {
  13657. c.drawText(e.slice(n[0 + A], n[1 + A]), _b / 2 + 2 * f, _T * (A + 1) / (_y + 1) + (A - (_y - 1) / 2) * f * 10 + 2 * f, l + " " + o * f + "px " + a, "#333333", "transparent", !0), c.drawText(e.slice(n[0 + A], n[1 + A]), _b / 2, _T * (A + 1) / (_y + 1) + (A - (_y - 1) / 2) * f * 10, l + " " + o * f + "px " + a, s, "transparent", !0);
  13658. }
  13659. c.hasAlpha = !0;
  13660. }
  13661. } else this.clearText();
  13662. }
  13663. }, {
  13664. key: "drawBillboard",
  13665. value: function drawBillboard(e, t, r) {
  13666. var _this2 = this;
  13667. var m;
  13668. var n = e.imageList,
  13669. o = t.texts,
  13670. _t$font = t.font,
  13671. a = _t$font === void 0 ? "monospace" : _t$font,
  13672. _t$fontsize = t.fontsize,
  13673. s = _t$fontsize === void 0 ? 40 : _t$fontsize,
  13674. _t$fontcolor = t.fontcolor,
  13675. l = _t$fontcolor === void 0 ? "#ffffff" : _t$fontcolor,
  13676. _t$fontstyle = t.fontstyle,
  13677. u = _t$fontstyle === void 0 ? "" : _t$fontstyle,
  13678. _t$linesize = t.linesize,
  13679. c = _t$linesize === void 0 ? 20 : _t$linesize,
  13680. h = t.linelimit,
  13681. f = r.position,
  13682. d = r.offsets,
  13683. _ = r.scale,
  13684. _r$compensationZ = r.compensationZ,
  13685. g = _r$compensationZ === void 0 ? 0 : _r$compensationZ;
  13686. if (this.scalingFactor = _ || 1, d && (this.offsets = {
  13687. x: d.x * this._scalingFactor,
  13688. y: d.y * this._scalingFactor,
  13689. z: d.z * this._scalingFactor
  13690. }), this.offsets || (this.offsets = {
  13691. x: 0,
  13692. y: 0,
  13693. z: 0
  13694. }), this.setPosition(f), n && !o) (m = this._billboardManager.sceneManager) == null || m.urlTransformer(n[0]).then(function (v) {
  13695. _this2.updateImage(v);
  13696. });else if (o && !n) {
  13697. var _getStringBoundaries = getStringBoundaries(o, c, XBillboardManager$1.alphaWidthMap),
  13698. _getStringBoundaries2 = _slicedToArray(_getStringBoundaries, 2),
  13699. v = _getStringBoundaries2[0],
  13700. y = _getStringBoundaries2[1];
  13701. this.offsets.z += this._scalingFactor * g * (y.length - 1), this.updateText(v, void 0, !1, y, s, a, l, u, h);
  13702. } else if (o && n) {
  13703. this.background = n;
  13704. var _getStringBoundaries3 = getStringBoundaries(o, c, XBillboardManager$1.alphaWidthMap),
  13705. _getStringBoundaries4 = _slicedToArray(_getStringBoundaries3, 2),
  13706. _v = _getStringBoundaries4[0],
  13707. _y2 = _getStringBoundaries4[1];
  13708. this.offsets.z += this._scalingFactor * g * (_y2.length - 1), this.updateText(_v, void 0, !0, _y2, s, a, l, u, h);
  13709. }
  13710. this.setStatus(1);
  13711. }
  13712. }, {
  13713. key: "clearText",
  13714. value: function clearText() {
  13715. if (this._texture != null) {
  13716. var e = this._texture.getContext(),
  13717. t = this._texture.getSize();
  13718. e.clearRect(0, 0, t.width, t.height), this._texture.update();
  13719. }
  13720. }
  13721. }]);
  13722. return XBillboard;
  13723. }();
  13724. var texRootDir = "https://app-asset-1258211750.file.myqcloud.com/1/textures/";
  13725. var XBillboardManager$1 = /*#__PURE__*/function () {
  13726. function XBillboardManager(e) {
  13727. var _this = this;
  13728. _classCallCheck(this, XBillboardManager);
  13729. E(this, "billboardMap", new Map());
  13730. E(this, "sceneManager");
  13731. E(this, "billboardPool");
  13732. E(this, "userBackGroundBlob", new Array());
  13733. E(this, "npcBackGroundBlob", new Array());
  13734. E(this, "tickObserver");
  13735. E(this, "tickInterval");
  13736. E(this, "_updateLoopObserver");
  13737. this.sceneManager = e, this.billboardPool = new Pool(this.createBillboardAsset, this.resetBillboardAsset, 0, 60, this.sceneManager.Scene, !1), this.tickInterval = 250;
  13738. var t = 0;
  13739. this.tickObserver = this.sceneManager.Scene.onAfterRenderObservable.add(function () {
  13740. t += 1, t == _this.tickInterval && (_this.tick(), t = 0);
  13741. }), this.launchBillboardStatusLoop();
  13742. }
  13743. _createClass(XBillboardManager, [{
  13744. key: "tick",
  13745. value: function tick() {
  13746. this.billboardPool.clean(0, this.sceneManager.Scene, !1);
  13747. }
  13748. }, {
  13749. key: "createBillboardAsset",
  13750. value: function createBillboardAsset(e) {
  13751. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
  13752. var r = BABYLON.MeshBuilder.CreatePlane("billboard-", {
  13753. height: .001,
  13754. width: .001,
  13755. sideOrientation: BABYLON.Mesh.DOUBLESIDE
  13756. }, e);
  13757. r.isPickable = !0, r.setEnabled(!1);
  13758. var n = new BABYLON.DynamicTexture("billboard-tex-", {
  13759. width: .001 + 1,
  13760. height: .001 + 1
  13761. }, e, t, BABYLON.Texture.BILINEAR_SAMPLINGMODE);
  13762. n.hasAlpha = !0;
  13763. var o = new BABYLON.StandardMaterial("billboard-mat-", e);
  13764. 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;
  13765. }
  13766. }, {
  13767. key: "resetBillboardAsset",
  13768. value: function resetBillboardAsset(e) {
  13769. var t = e.data;
  13770. return t.setEnabled(!1), t.isPickable = !1, e;
  13771. }
  13772. }, {
  13773. key: "loadBackGroundTexToIDB",
  13774. value: function () {
  13775. var _loadBackGroundTexToIDB = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  13776. var _this2 = this;
  13777. return regenerator.wrap(function _callee$(_context) {
  13778. while (1) {
  13779. switch (_context.prev = _context.next) {
  13780. case 0:
  13781. XBillboardManager.userBubbleUrls.forEach(function (r) {
  13782. _this2.sceneManager.urlTransformer(r).then(function (n) {
  13783. _this2.userBackGroundBlob.push(n);
  13784. });
  13785. }), XBillboardManager.npcBubbleUrls.forEach(function (r) {
  13786. _this2.sceneManager.urlTransformer(r).then(function (n) {
  13787. _this2.npcBackGroundBlob.push(n);
  13788. });
  13789. });
  13790. case 1:
  13791. case "end":
  13792. return _context.stop();
  13793. }
  13794. }
  13795. }, _callee);
  13796. }));
  13797. function loadBackGroundTexToIDB() {
  13798. return _loadBackGroundTexToIDB.apply(this, arguments);
  13799. }
  13800. return loadBackGroundTexToIDB;
  13801. }()
  13802. }, {
  13803. key: "addBillboardToMap",
  13804. value: function addBillboardToMap(e, t) {
  13805. this.billboardMap.set(e, t);
  13806. }
  13807. }, {
  13808. key: "addBillboard",
  13809. value: function addBillboard(e, t, r) {
  13810. var n = this.getBillboard(e);
  13811. return n || (n = new XBillboard(this, t, r), this.addBillboardToMap(e, n)), n;
  13812. }
  13813. }, {
  13814. key: "generateStaticBillboard",
  13815. value: function generateStaticBillboard(e, _ref) {
  13816. var _ref$id = _ref.id,
  13817. t = _ref$id === void 0 ? "billboard" : _ref$id,
  13818. r = _ref.isUser,
  13819. n = _ref.background,
  13820. _ref$font = _ref.font,
  13821. o = _ref$font === void 0 ? "Arial" : _ref$font,
  13822. _ref$fontsize = _ref.fontsize,
  13823. a = _ref$fontsize === void 0 ? 40 : _ref$fontsize,
  13824. _ref$fontcolor = _ref.fontcolor,
  13825. s = _ref$fontcolor === void 0 ? "#ffffff" : _ref$fontcolor,
  13826. _ref$fontstyle = _ref.fontstyle,
  13827. l = _ref$fontstyle === void 0 ? "600" : _ref$fontstyle,
  13828. _ref$linesize = _ref.linesize,
  13829. u = _ref$linesize === void 0 ? 16 : _ref$linesize,
  13830. c = _ref.linelimit,
  13831. _ref$scale = _ref.scale,
  13832. h = _ref$scale === void 0 ? 1 : _ref$scale,
  13833. _ref$width = _ref.width,
  13834. f = _ref$width === void 0 ? .01 : _ref$width,
  13835. _ref$height = _ref.height,
  13836. d = _ref$height === void 0 ? .01 : _ref$height,
  13837. _ref$position = _ref.position,
  13838. _ = _ref$position === void 0 ? {
  13839. x: 0,
  13840. y: 0,
  13841. z: 0
  13842. } : _ref$position;
  13843. var g = this.addBillboard(t, !1, !0);
  13844. g.getMesh() == null && g.init(t, f, d);
  13845. var m;
  13846. r != null && (m = r ? XBillboardManager.userBubbleUrls : XBillboardManager.npcBubbleUrls), g && g.getMesh() && (g.DEFAULT_CONFIGS = {
  13847. id: t,
  13848. isUser: r,
  13849. background: n,
  13850. font: o,
  13851. fontsize: a,
  13852. fontcolor: s,
  13853. fontstyle: l,
  13854. linesize: u,
  13855. linelimit: c,
  13856. scale: h,
  13857. width: f,
  13858. height: d,
  13859. position: _
  13860. }, g.drawBillboard({
  13861. imageList: n || m
  13862. }, {
  13863. texts: e,
  13864. font: o,
  13865. fontsize: a,
  13866. fontcolor: s,
  13867. fontstyle: l,
  13868. linesize: u,
  13869. linelimit: c
  13870. }, {
  13871. position: _,
  13872. scale: h
  13873. }), t && g.setId(t), g.setStatus(BillboardStatus.SHOW));
  13874. }
  13875. }, {
  13876. key: "getBillboard",
  13877. value: function getBillboard(e) {
  13878. return this.billboardMap.get(e);
  13879. }
  13880. }, {
  13881. key: "toggle",
  13882. value: function toggle(e, t) {
  13883. var r;
  13884. (r = this.getBillboard(e)) == null || r.setStatus(t ? BillboardStatus.SHOW : BillboardStatus.HIDE);
  13885. }
  13886. }, {
  13887. key: "removeBillboard",
  13888. value: function removeBillboard(e) {
  13889. var t = this.getBillboard(e);
  13890. t && (t.setStatus(BillboardStatus.DISPOSE), this.billboardMap.delete(e));
  13891. }
  13892. }, {
  13893. key: "launchBillboardStatusLoop",
  13894. value: function launchBillboardStatusLoop() {
  13895. var _this3 = this;
  13896. this._updateLoopObserver = this.sceneManager.Scene.onBeforeRenderObservable.add(function () {
  13897. _this3.billboardMap.size <= 0 || _this3.billboardMap.forEach(function (e) {
  13898. e.stageChanged && (e.status == BillboardStatus.SHOW ? e.show() : e.status == BillboardStatus.HIDE ? e.hide() : (e.hide(), e.dispose()), e.stageChanged = !1);
  13899. });
  13900. });
  13901. }
  13902. }]);
  13903. return XBillboardManager;
  13904. }();
  13905. E(XBillboardManager$1, "alphaWidthMap", new Map()), E(XBillboardManager$1, "userBubbleUrls", [texRootDir + "bubble01.png", texRootDir + "bubble02.png", texRootDir + "bubble03.png"]), E(XBillboardManager$1, "npcBubbleUrls", [texRootDir + "bubble01_npc.png", texRootDir + "bubble02_npc.png", texRootDir + "bubble03_npc.png"]);
  13906. var XLightManager = /*#__PURE__*/function () {
  13907. function XLightManager(e) {
  13908. _classCallCheck(this, XLightManager);
  13909. E(this, "_scene");
  13910. E(this, "_envTexture");
  13911. E(this, "_shadowLight");
  13912. E(this, "_shadowGenerator");
  13913. E(this, "_avatarShadowMeshMap");
  13914. E(this, "_cullingShadowObservers");
  13915. E(this, "sceneManager");
  13916. this.sceneManager = e, this._scene = this.sceneManager.Scene, this._envTexture = null, this.shadowLean = .1;
  13917. var t = new BABYLON.Vector3(this.shadowLean, -1, 0),
  13918. r = 1024;
  13919. 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();
  13920. }
  13921. _createClass(XLightManager, [{
  13922. key: "shadowLean",
  13923. set: function set(e) {
  13924. e = Math.min(e, 1), e = Math.max(e, -1), this._shadowLight && (this._shadowLight.direction = new BABYLON.Vector3(e, -1, 0));
  13925. }
  13926. }, {
  13927. key: "setIBL",
  13928. value: function setIBL(e) {
  13929. var _this = this;
  13930. return new Promise(function (t, r) {
  13931. _this.sceneManager.urlTransformer(e).then(function (n) {
  13932. var o;
  13933. if (n == ((o = _this._envTexture) == null ? void 0 : o.url)) return t("env set success");
  13934. _this._envTexture != null && _this.disposeIBL(), _this._envTexture = BABYLON.CubeTexture.CreateFromPrefilteredData(n, _this._scene, ".env"), _this._scene.environmentTexture = _this._envTexture, _this._envTexture.onLoadObservable.addOnce(function () {
  13935. t("env set success"), logger$1.info("env set success");
  13936. });
  13937. }).catch(function () {
  13938. r("env set fail");
  13939. });
  13940. });
  13941. }
  13942. }, {
  13943. key: "disposeIBL",
  13944. value: function disposeIBL() {
  13945. 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"));
  13946. }
  13947. }, {
  13948. key: "removeShadow",
  13949. value: function removeShadow(e) {
  13950. var t;
  13951. if (this._avatarShadowMeshMap.has(e)) {
  13952. this._avatarShadowMeshMap.delete(e), this._cullingShadowObservers.get(e) && (this._scene.onBeforeRenderObservable.remove(this._cullingShadowObservers.get(e)), this._cullingShadowObservers.delete(e));
  13953. var r = e.rootNode;
  13954. r && ((t = this._shadowGenerator) == null || t.removeShadowCaster(r));
  13955. } else return;
  13956. }
  13957. }, {
  13958. key: "setShadow",
  13959. value: function setShadow(e) {
  13960. if (this._avatarShadowMeshMap.has(e)) return;
  13961. e.rootNode && this._avatarShadowMeshMap.set(e, e.rootNode.getChildMeshes());
  13962. var t = 20,
  13963. r = 10,
  13964. n = this.cullingShadow(t, r, e);
  13965. this._cullingShadowObservers.set(e, n);
  13966. }
  13967. }, {
  13968. key: "cullingShadow",
  13969. value: function cullingShadow(e, t, r) {
  13970. var _this2 = this;
  13971. var n = 0;
  13972. var o = function o() {
  13973. var s, l;
  13974. if (n == t) {
  13975. var u = _this2._avatarShadowMeshMap.get(r),
  13976. c = (s = r.rootNode) == null ? void 0 : s.getChildMeshes(),
  13977. h = _this2._scene.activeCamera;
  13978. u == null || u.forEach(function (f) {
  13979. var d;
  13980. (d = _this2._shadowGenerator) == null || d.removeShadowCaster(f, !1);
  13981. }), c == null || c.forEach(function (f) {
  13982. var d;
  13983. (d = _this2._shadowGenerator) == null || d.addShadowCaster(f, !1);
  13984. }), h && r.rootNode && ((l = r.rootNode.position) == null ? void 0 : l.subtract(h.position).length()) > e && (c == null || c.forEach(function (f) {
  13985. var d;
  13986. (d = _this2._shadowGenerator) == null || d.removeShadowCaster(f, !1);
  13987. })), c && _this2._avatarShadowMeshMap.set(r, c), n = 0;
  13988. } else n += 1;
  13989. };
  13990. return this._scene.onBeforeRenderObservable.add(o);
  13991. }
  13992. }, {
  13993. key: "attachLightToCamera",
  13994. value: function attachLightToCamera(e) {
  13995. var _this3 = this;
  13996. var t = e,
  13997. r = 15,
  13998. n = function n() {
  13999. var o = _this3._scene.activeCamera;
  14000. if (o) {
  14001. var a = t.direction,
  14002. s = new BABYLON.Vector3(r * a.x, r * a.y, r * a.z),
  14003. l = o.position;
  14004. t.position = l.subtract(s);
  14005. }
  14006. };
  14007. return t && this._scene.registerBeforeRender(n), n;
  14008. }
  14009. }]);
  14010. return XLightManager;
  14011. }();
  14012. var RunTimeArray = /*#__PURE__*/function () {
  14013. function RunTimeArray() {
  14014. _classCallCheck(this, RunTimeArray);
  14015. E(this, "circularData");
  14016. this.circularData = [];
  14017. }
  14018. _createClass(RunTimeArray, [{
  14019. key: "add",
  14020. value: function add(e) {
  14021. this.circularData.length > 1e3 && this.circularData.shift(), this.circularData.push(e);
  14022. }
  14023. }, {
  14024. key: "getAvg",
  14025. value: function getAvg() {
  14026. var e = 0;
  14027. for (var t = 0; t < this.circularData.length; t++) {
  14028. e += this.circularData[t];
  14029. }
  14030. return {
  14031. sum: e,
  14032. avg: e / this.circularData.length || 0
  14033. };
  14034. }
  14035. }, {
  14036. key: "getMax",
  14037. value: function getMax() {
  14038. var e = 0;
  14039. for (var t = 0; t < this.circularData.length; t++) {
  14040. e < this.circularData[t] && (e = this.circularData[t]);
  14041. }
  14042. return e || 0;
  14043. }
  14044. }, {
  14045. key: "clear",
  14046. value: function clear() {
  14047. this.circularData = [];
  14048. }
  14049. }, {
  14050. key: "getStat",
  14051. value: function getStat() {
  14052. var e = this.getAvg(),
  14053. t = {
  14054. sum: e.sum,
  14055. avg: e.avg,
  14056. max: this.getMax()
  14057. };
  14058. return this.clear(), t;
  14059. }
  14060. }]);
  14061. return RunTimeArray;
  14062. }();
  14063. var XEngineRunTimeStats = /*#__PURE__*/_createClass(function XEngineRunTimeStats() {
  14064. _classCallCheck(this, XEngineRunTimeStats);
  14065. E(this, "timeArray_loadStaticMesh", new RunTimeArray());
  14066. E(this, "timeArray_updateStaticMesh", new RunTimeArray());
  14067. E(this, "timeArray_addAvatarToScene", new RunTimeArray());
  14068. });
  14069. 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; } } }; }
  14070. 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); }
  14071. 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; }
  14072. var getAlphaWidthMap = function getAlphaWidthMap(i, e) {
  14073. var t = new BABYLON.DynamicTexture("test", 3, e),
  14074. r = new Map();
  14075. for (var n = 32; n < 127; n++) {
  14076. var o = String.fromCodePoint(n),
  14077. a = 2 + "px " + i;
  14078. t.drawText(o, null, null, a, "#000000", "#ffffff", !0);
  14079. var s = t.getContext();
  14080. s.font = a;
  14081. var l = s.measureText(o).width;
  14082. r.set(n, l);
  14083. }
  14084. return t.dispose(), r;
  14085. };
  14086. var XSceneManager = /*#__PURE__*/function () {
  14087. function XSceneManager(e, t) {
  14088. var _this = this;
  14089. _classCallCheck(this, XSceneManager);
  14090. E(this, "scene");
  14091. E(this, "engine");
  14092. E(this, "canvas");
  14093. E(this, "gl");
  14094. E(this, "_yuvInfo");
  14095. E(this, "cameraParam");
  14096. E(this, "shaderMode");
  14097. E(this, "panoInfo");
  14098. E(this, "_initEngineScaleNumber");
  14099. E(this, "_forceKeepVertical", !1);
  14100. E(this, "_currentShader");
  14101. E(this, "_currentPanoId");
  14102. E(this, "_renderStatusCheckCount", 0);
  14103. E(this, "_renderStatusNotChecktCount", 0);
  14104. E(this, "_nonlinearCanvasResize", !1);
  14105. E(this, "_bChangeEngineSize", !0);
  14106. E(this, "_cameraManager");
  14107. E(this, "_lowpolyManager");
  14108. E(this, "_materialManager");
  14109. E(this, "_statisticManager");
  14110. E(this, "_breathPointManager");
  14111. E(this, "_skytv");
  14112. E(this, "_mv", []);
  14113. E(this, "_decalManager");
  14114. E(this, "_lightManager");
  14115. E(this, "_avatarManager");
  14116. E(this, "urlTransformer");
  14117. E(this, "_billboardManager");
  14118. E(this, "_backgroundImg");
  14119. E(this, "engineRunTimeStats");
  14120. E(this, "uploadHardwareSystemInfo", function () {
  14121. var e = _this.statisticComponent.getHardwareRenderInfo(),
  14122. t = _this.statisticComponent.getSystemInfo(),
  14123. r = {
  14124. driver: t.driver,
  14125. vender: t.vender,
  14126. webgl: t.version,
  14127. os: t.os
  14128. };
  14129. logger$1.warn(JSON.stringify(e)), logger$1.warn(JSON.stringify(r));
  14130. });
  14131. E(this, "addNewLowPolyMesh", /*#__PURE__*/function () {
  14132. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e, t) {
  14133. return regenerator.wrap(function _callee$(_context) {
  14134. while (1) {
  14135. switch (_context.prev = _context.next) {
  14136. case 0:
  14137. _context.t0 = _this._currentShader == null;
  14138. if (!_context.t0) {
  14139. _context.next = 4;
  14140. break;
  14141. }
  14142. _context.next = 4;
  14143. return _this.initSceneManager();
  14144. case 4:
  14145. return _context.abrupt("return", _this._lowpolyManager.addNewLowPolyMesh(e, t, _this._currentShader));
  14146. case 5:
  14147. case "end":
  14148. return _context.stop();
  14149. }
  14150. }
  14151. }, _callee);
  14152. }));
  14153. return function (_x, _x2) {
  14154. return _ref.apply(this, arguments);
  14155. };
  14156. }());
  14157. E(this, "initSceneManager", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  14158. return regenerator.wrap(function _callee2$(_context2) {
  14159. while (1) {
  14160. switch (_context2.prev = _context2.next) {
  14161. case 0:
  14162. _context2.next = 2;
  14163. return _this._materialManager.initMaterial();
  14164. case 2:
  14165. return _context2.abrupt("return", _this.applyShader());
  14166. case 3:
  14167. case "end":
  14168. return _context2.stop();
  14169. }
  14170. }
  14171. }, _callee2);
  14172. })));
  14173. E(this, "registerAfterRender", function () {
  14174. var e;
  14175. if (_this._forceKeepVertical) {
  14176. var _t = _this.canvas.width,
  14177. _r = _this.canvas.height;
  14178. var _n = 0,
  14179. _o = [[0, 0, 0, 0], [0, 0, 0, 0]];
  14180. 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) {
  14181. _this.gl.enable(_this.gl.SCISSOR_TEST);
  14182. for (var a = 0; a < _o.length; ++a) {
  14183. _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);
  14184. }
  14185. _this.gl.disable(_this.gl.SCISSOR_TEST);
  14186. }
  14187. }
  14188. });
  14189. E(this, "resetRender", function () {
  14190. _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));
  14191. });
  14192. var r = /iphone|ipad/gi.test(window.navigator.userAgent) || t.disableWebGL2,
  14193. n = new BABYLON.Engine(e, !0, {
  14194. preserveDrawingBuffer: !0,
  14195. stencil: !0,
  14196. disableWebGL2Support: r
  14197. }, !0),
  14198. o = new BABYLON.Scene(n);
  14199. 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(), // 周恩光加 调试用工具栏
  14200. this.scene.debugLayer.show({
  14201. embedMode: true
  14202. });
  14203. this.urlTransformer = t.urlTransformer || function (s) {
  14204. return Promise.resolve(s);
  14205. }, t.logger && Logger1.setLogger(t.logger), this.gl = e.getContext("webgl2", {
  14206. preserveDrawingBuffer: !0
  14207. }) || e.getContext("webgl", {
  14208. preserveDrawingBuffer: !0
  14209. }) || e.getContext("experimental-webgl", {
  14210. preserveDrawingBuffer: !0
  14211. }), 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 = {
  14212. width: t.videoResOriArray[0].width,
  14213. height: t.videoResOriArray[0].height,
  14214. fov: 50
  14215. }, t.cameraParam != null && (this.cameraParam = t.cameraParam), t.nonlinearCanvasResize != null && (this._nonlinearCanvasResize = t.nonlinearCanvasResize), this._cameraManager = new XCameraComponent(this.canvas, this.scene, {
  14216. cameraParam: this.cameraParam,
  14217. yuvInfo: this._yuvInfo,
  14218. forceKeepVertical: this._forceKeepVertical
  14219. }), this._lowpolyManager = new XStaticMeshComponent(this), this._materialManager = new XMaterialComponent(this, {
  14220. videoResOriArray: t.videoResOriArray,
  14221. yuvInfo: this._yuvInfo,
  14222. panoInfo: this.panoInfo,
  14223. shaderMode: this.shaderMode
  14224. }), this._statisticManager = new XStats(this), this._breathPointManager = new XBreathPointManager(this), this._decalManager = new XDecalManager(this), this._avatarManager = new XAvatarManager(this), this._billboardManager = new XBillboardManager$1(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 () {
  14225. _this._nonlinearCanvasResize && _this._bChangeEngineSize && (_this.setEngineSize(_this._yuvInfo), _this._bChangeEngineSize = !1);
  14226. }), this.scene.registerAfterRender(function () {
  14227. _this._nonlinearCanvasResize || _this.registerAfterRender();
  14228. }), window.addEventListener("resize", function () {
  14229. _this._nonlinearCanvasResize ? _this._bChangeEngineSize = !0 : _this.engine.resize();
  14230. }), XBillboardManager$1.alphaWidthMap = getAlphaWidthMap("Arial", this.scene), this.uploadHardwareSystemInfo();
  14231. }
  14232. _createClass(XSceneManager, [{
  14233. key: "yuvInfo",
  14234. get: function get() {
  14235. return this.getCurrentShaderMode() == 1 ? this._yuvInfo : {
  14236. width: -1,
  14237. height: -1,
  14238. fov: -1
  14239. };
  14240. },
  14241. set: function set(e) {
  14242. this.getCurrentShaderMode() == 1 && (this._yuvInfo = e, this._cameraManager.cameraFovChange(e));
  14243. }
  14244. }, {
  14245. key: "mainScene",
  14246. get: function get() {
  14247. return this.scene;
  14248. }
  14249. }, {
  14250. key: "cameraComponent",
  14251. get: function get() {
  14252. return this._cameraManager;
  14253. }
  14254. }, {
  14255. key: "staticmeshComponent",
  14256. get: function get() {
  14257. return this._lowpolyManager;
  14258. }
  14259. }, {
  14260. key: "materialComponent",
  14261. get: function get() {
  14262. return this._materialManager;
  14263. }
  14264. }, {
  14265. key: "statisticComponent",
  14266. get: function get() {
  14267. return this._statisticManager;
  14268. }
  14269. }, {
  14270. key: "avatarComponent",
  14271. get: function get() {
  14272. return this._avatarManager;
  14273. }
  14274. }, {
  14275. key: "lightComponent",
  14276. get: function get() {
  14277. return this._lightManager;
  14278. }
  14279. }, {
  14280. key: "Engine",
  14281. get: function get() {
  14282. return this.engine;
  14283. }
  14284. }, {
  14285. key: "Scene",
  14286. get: function get() {
  14287. return this.scene;
  14288. }
  14289. }, {
  14290. key: "billboardComponent",
  14291. get: function get() {
  14292. return this._billboardManager;
  14293. }
  14294. }, {
  14295. key: "breathPointComponent",
  14296. get: function get() {
  14297. return this._breathPointManager;
  14298. }
  14299. }, {
  14300. key: "skytvComponent",
  14301. get: function get() {
  14302. return this._skytv;
  14303. }
  14304. }, {
  14305. key: "mvComponent",
  14306. get: function get() {
  14307. return this._mv;
  14308. }
  14309. }, {
  14310. key: "decalComponent",
  14311. get: function get() {
  14312. return this._decalManager;
  14313. }
  14314. }, {
  14315. key: "currentShader",
  14316. get: function get() {
  14317. return this._currentShader;
  14318. }
  14319. }, {
  14320. key: "initEngineScaleNumber",
  14321. get: function get() {
  14322. return this._initEngineScaleNumber;
  14323. }
  14324. }, {
  14325. key: "setImageQuality",
  14326. value: function setImageQuality(e) {
  14327. 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 + "]"));
  14328. }
  14329. }, {
  14330. key: "setNonlinearCanvasResize",
  14331. value: function setNonlinearCanvasResize(e) {
  14332. this._nonlinearCanvasResize = e, this._bChangeEngineSize = e, e || this.engine.resize();
  14333. }
  14334. }, {
  14335. key: "setBackgroundColor",
  14336. value: function setBackgroundColor(e) {
  14337. this.scene.clearColor = new Color4(e.r, e.g, e.b, e.a);
  14338. }
  14339. }, {
  14340. key: "setBackgroundImg",
  14341. value: function setBackgroundImg(e) {
  14342. var _this2 = this;
  14343. return this._backgroundImg != null && this._backgroundImg.url == e ? Promise.resolve(!0) : new Promise(function (t, r) {
  14344. _this2.urlTransformer(e).then(function (n) {
  14345. _this2._backgroundImg == null ? _this2._backgroundImg = {
  14346. layer: new Layer("tex_background_" + Date.now(), n, _this2.Scene, !0),
  14347. url: e
  14348. } : _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);
  14349. }).catch(function (n) {
  14350. logger$1.error("[Engine] set background image Error: ".concat(n)), r("[Engine] set background image Error: ".concat(n));
  14351. });
  14352. });
  14353. }
  14354. }, {
  14355. key: "cleanTheWholeScene",
  14356. value: function cleanTheWholeScene() {
  14357. var _this3 = this;
  14358. var e = this.scene.getFrameId();
  14359. this.scene.onBeforeRenderObservable.clear(), this.scene.onAfterRenderObservable.clear(), this.scene.clearCachedVertexData(), this.scene.cleanCachedTextureBuffer(), this.scene.registerBeforeRender(function () {
  14360. _this3.scene.getFrameId() - e > 5 && _this3.scene.dispose();
  14361. });
  14362. }
  14363. }, {
  14364. key: "getAreaAvatar",
  14365. value: function getAreaAvatar(e, t) {
  14366. var r = [];
  14367. return this._avatarManager.getAvatarList().forEach(function (n) {
  14368. var o = e,
  14369. a = n.position;
  14370. a && o && calcDistance3D(o, a) < t && r.push(n.id);
  14371. }), r;
  14372. }
  14373. }, {
  14374. key: "setEngineSize",
  14375. value: function setEngineSize(e) {
  14376. var t = e.width,
  14377. r = e.height,
  14378. n = this.canvas.width;
  14379. this.canvas.height, this.engine.setSize(Math.round(n), Math.round(n * (r / t)));
  14380. }
  14381. }, {
  14382. key: "getCurrentShaderMode",
  14383. value: function getCurrentShaderMode() {
  14384. return this._currentShader === this._materialManager.getDefaultShader() ? 0 : this._currentShader === this._materialManager.getPureVideoShader() ? 1 : 2;
  14385. }
  14386. }, {
  14387. key: "addSkyTV",
  14388. value: function addSkyTV(e, t) {
  14389. return this._skytv = new XTelevision(this.scene, e, this, t), this._skytv;
  14390. }
  14391. }, {
  14392. key: "addMv",
  14393. value: function addMv(e, t) {
  14394. this._mv.push(new XTelevision(this.scene, e, this, t));
  14395. }
  14396. }, {
  14397. key: "addMeshInfo",
  14398. value: function addMeshInfo(e) {
  14399. this._lowpolyManager.setMeshInfo(e);
  14400. }
  14401. }, {
  14402. key: "applyShader",
  14403. value: function applyShader() {
  14404. var _this4 = this;
  14405. return new Promise(function (e, t) {
  14406. _this4.shaderMode == EShaderMode.videoAndPano || _this4.shaderMode == EShaderMode.video ? _this4.changeVideoShaderForLowModel() : _this4.shaderMode == EShaderMode.default && _this4.changeDefaultShaderForLowModel(), e(!0);
  14407. });
  14408. }
  14409. }, {
  14410. key: "changeHardwareScaling",
  14411. value: function changeHardwareScaling(e) {
  14412. e < 1 ? e = 1 : e > 2.5 && (e = 2.5), this._bChangeEngineSize = !0, this.engine.setHardwareScalingLevel(this._initEngineScaleNumber * e);
  14413. }
  14414. }, {
  14415. key: "getCurrentUsedPanoId",
  14416. value: function getCurrentUsedPanoId() {
  14417. return this._currentPanoId;
  14418. }
  14419. }, {
  14420. key: "render",
  14421. value: function render() {
  14422. try {
  14423. this.scene.render();
  14424. } catch (e) {
  14425. throw logger$1.error("[Engine] Render Error: ".concat(e)), e;
  14426. }
  14427. }
  14428. }, {
  14429. key: "isReadyToRender",
  14430. value: function isReadyToRender(e) {
  14431. var _e$checkMesh = e.checkMesh,
  14432. t = _e$checkMesh === void 0 ? !0 : _e$checkMesh,
  14433. _e$checkEffect = e.checkEffect,
  14434. r = _e$checkEffect === void 0 ? !1 : _e$checkEffect,
  14435. _e$checkPostProgress = e.checkPostProgress,
  14436. n = _e$checkPostProgress === void 0 ? !1 : _e$checkPostProgress,
  14437. _e$checkParticle = e.checkParticle,
  14438. o = _e$checkParticle === void 0 ? !1 : _e$checkParticle,
  14439. _e$checkAnimation = e.checkAnimation,
  14440. a = _e$checkAnimation === void 0 ? !1 : _e$checkAnimation;
  14441. e.materialNameWhiteLists;
  14442. if (this.scene._isDisposed) return logger$1.error("[Engine] this.scene._isDisposed== false "), !1;
  14443. var l;
  14444. var u = this.scene.getEngine();
  14445. if (r && !u.areAllEffectsReady()) return logger$1.error("[Engine] engine.areAllEffectsReady == false"), !1;
  14446. if (a && this.scene._pendingData.length > 0) return logger$1.error("[Engine] scene._pendingData.length > 0 && animation error"), !1;
  14447. if (t) {
  14448. for (l = 0; l < this.scene.meshes.length; l++) {
  14449. var c = this.scene.meshes[l];
  14450. 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;
  14451. 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;
  14452. var h = c.hasThinInstances || c.getClassName() === "InstancedMesh" || c.getClassName() === "InstancedLinesMesh" || u.getCaps().instancedArrays && c.instances.length > 0;
  14453. var _iterator = _createForOfIteratorHelper(this.scene._isReadyForMeshStage),
  14454. _step;
  14455. try {
  14456. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  14457. var f = _step.value;
  14458. 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;
  14459. }
  14460. } catch (err) {
  14461. _iterator.e(err);
  14462. } finally {
  14463. _iterator.f();
  14464. }
  14465. }
  14466. for (l = 0; l < this.scene.geometries.length; l++) {
  14467. if (this.scene.geometries[l].delayLoadState === 2) return logger$1.error("[Engine] geometry.delayLoadState === 2"), !1;
  14468. }
  14469. }
  14470. if (n) {
  14471. if (this.scene.activeCameras && this.scene.activeCameras.length > 0) {
  14472. var _iterator2 = _createForOfIteratorHelper(this.scene.activeCameras),
  14473. _step2;
  14474. try {
  14475. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  14476. var _c = _step2.value;
  14477. if (!_c.isReady(!0)) return logger$1.error("[Engine] camera not ready === false, ", _c.name), !1;
  14478. }
  14479. } catch (err) {
  14480. _iterator2.e(err);
  14481. } finally {
  14482. _iterator2.f();
  14483. }
  14484. } else if (this.scene.activeCamera && !this.scene.activeCamera.isReady(!0)) return logger$1.error("[Engine] activeCamera ready === false, ", this.scene.activeCamera.name), !1;
  14485. }
  14486. if (o) {
  14487. var _iterator3 = _createForOfIteratorHelper(this.scene.particleSystems),
  14488. _step3;
  14489. try {
  14490. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  14491. var _c2 = _step3.value;
  14492. if (!_c2.isReady()) return logger$1.error("[Engine] particleSystem ready === false, ", _c2.name), !1;
  14493. }
  14494. } catch (err) {
  14495. _iterator3.e(err);
  14496. } finally {
  14497. _iterator3.f();
  14498. }
  14499. }
  14500. return !0;
  14501. }
  14502. }, {
  14503. key: "changePanoShaderForLowModel",
  14504. value: function changePanoShaderForLowModel(e) {
  14505. var _this5 = this;
  14506. return logger$1.info("[Engine] changePanoShaderForLowModel: ".concat(e)), this._materialManager.allowYUVUpdate(), new Promise(function (t, r) {
  14507. _this5._materialManager._isInDynamicRange(e) == !1 && r(!1), _this5._currentPanoId = e, _this5._currentShader = _this5._materialManager.getDynamicShader(e), _this5.changeShaderForLowModel().then(function () {
  14508. t(!0);
  14509. });
  14510. });
  14511. }
  14512. }, {
  14513. key: "changeVideoShaderForLowModel",
  14514. value: function changeVideoShaderForLowModel() {
  14515. return logger$1.info("[Engine] changeVideoShaderForLowModel"), this._currentShader = this._materialManager.getPureVideoShader(), this._materialManager.allowYUVUpdate(), this.changeShaderForLowModel();
  14516. }
  14517. }, {
  14518. key: "changeDefaultShaderForLowModel",
  14519. value: function changeDefaultShaderForLowModel() {
  14520. return logger$1.info("[Engine] changeDefaultShaderForLowModel"), this._currentShader = this._materialManager.getDefaultShader(), this._materialManager.stopYUVUpdate(), this.changeShaderForLowModel();
  14521. }
  14522. }, {
  14523. key: "changeShaderForLowModel",
  14524. value: function changeShaderForLowModel() {
  14525. var _this6 = this;
  14526. return new Promise(function (e, t) {
  14527. _this6._lowpolyManager.getMeshes().forEach(function (r) {
  14528. r.setMaterial(_this6._currentShader);
  14529. }), _this6._lowpolyManager.getCgMesh().mesh.material = _this6._currentShader, e(!0);
  14530. });
  14531. }
  14532. }, {
  14533. key: "setIBL",
  14534. value: function setIBL(e) {
  14535. this._lightManager.setIBL(e);
  14536. }
  14537. }, {
  14538. key: "postprocessing",
  14539. value: function postprocessing() {
  14540. var e = new BABYLON.DefaultRenderingPipeline("default", !0, this.scene);
  14541. e.imageProcessingEnabled = !1, e.bloomEnabled = !0, e.bloomThreshold = 1, e.bloomWeight = 1, e.bloomKernel = 64, e.bloomScale = .1;
  14542. }
  14543. }, {
  14544. key: "getGround",
  14545. value: function getGround(e) {
  14546. var t = this._lowpolyManager.getMeshes(),
  14547. r = [];
  14548. return t.forEach(function (n) {
  14549. n.mesh.name.indexOf("SM_Stage") >= 0 && r.push(n.mesh);
  14550. }), this.Scene.meshes.forEach(function (n) {
  14551. n.name.split("_")[0] === "ground" && r.push(n);
  14552. }), r;
  14553. }
  14554. }]);
  14555. return XSceneManager;
  14556. }();
  14557. 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); }; }
  14558. 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; } }
  14559. var InitEngineTimeoutError = /*#__PURE__*/function (_XverseError) {
  14560. _inherits(InitEngineTimeoutError, _XverseError);
  14561. var _super = _createSuper$3(InitEngineTimeoutError);
  14562. function InitEngineTimeoutError(e) {
  14563. _classCallCheck(this, InitEngineTimeoutError);
  14564. return _super.call(this, 1010, e || "\u5F15\u64CE\u521D\u59CB\u5316\u8D85\u65F6");
  14565. }
  14566. return _createClass(InitEngineTimeoutError);
  14567. }(XverseError);
  14568. var http = new Http();
  14569. var urlMap = new Map(),
  14570. urlTransformer = /*#__PURE__*/function () {
  14571. var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(i) {
  14572. var e,
  14573. _args2 = arguments;
  14574. return regenerator.wrap(function _callee2$(_context2) {
  14575. while (1) {
  14576. switch (_context2.prev = _context2.next) {
  14577. case 0:
  14578. e = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : !1;
  14579. return _context2.abrupt("return", typeof i != "string" ? (console.warn("url transformer error", i), i) : i.startsWith("blob:") ? i : e ? http.get({
  14580. url: i,
  14581. useIndexedDb: !0,
  14582. key: "url",
  14583. isOutPutObjectURL: !1
  14584. }) : urlMap.has(i) ? urlMap.get(i) : http.get({
  14585. url: i,
  14586. useIndexedDb: !0,
  14587. key: "url"
  14588. }).then(function (t) {
  14589. return urlMap.set(i, t), t;
  14590. }));
  14591. case 2:
  14592. case "end":
  14593. return _context2.stop();
  14594. }
  14595. }
  14596. }, _callee2);
  14597. }));
  14598. return function urlTransformer(_x2) {
  14599. return _ref2.apply(this, arguments);
  14600. };
  14601. }();
  14602. var sceneManager;
  14603. function getSceneManager(i, e) {
  14604. return sceneManager || (sceneManager = new XSceneManager(i, e)), sceneManager;
  14605. }
  14606. var EngineProxy = /*#__PURE__*/function () {
  14607. function EngineProxy(e) {
  14608. var _this = this;
  14609. _classCallCheck(this, EngineProxy);
  14610. E(this, "_tvs", []);
  14611. E(this, "isRenderFirstFrame", !1);
  14612. E(this, "_idleTime", 0);
  14613. E(this, "renderTimer");
  14614. E(this, "lightManager");
  14615. E(this, "_checkSceneNotReadyCount", 0);
  14616. E(this, "_checkSceneDurationFrameNum", 0);
  14617. E(this, "_checkSceneFrameCount", 0);
  14618. E(this, "timeoutCircularArray", new CircularArray(120, !1, []));
  14619. E(this, "frameCircularArray", new CircularArray(120, !1, []));
  14620. E(this, "interFrameCircularArray", new CircularArray(120, !1, []));
  14621. E(this, "drawCallCntCircularArray", new CircularArray(120, !1, []));
  14622. E(this, "activeFacesCircularArray", new CircularArray(120, !1, []));
  14623. E(this, "renderTimeCircularArray", new CircularArray(120, !1, []));
  14624. E(this, "drawCallTimeCircularArray", new CircularArray(120, !1, []));
  14625. E(this, "animationCircularArray", new CircularArray(120, !1, []));
  14626. E(this, "meshSelectCircularArray", new CircularArray(120, !1, []));
  14627. E(this, "renderTargetCircularArray", new CircularArray(120, !1, []));
  14628. E(this, "regBeforeRenderCircularArray", new CircularArray(120, !1, []));
  14629. E(this, "regAfterRenderCircularArray", new CircularArray(120, !1, []));
  14630. E(this, "renderCnt", 0);
  14631. E(this, "renderErrorCount", 0);
  14632. E(this, "engineSloppyCnt", 0);
  14633. E(this, "systemStuckCnt", 0);
  14634. E(this, "frameRenderNumber", 0);
  14635. E(this, "_setFPS", function (e) {
  14636. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 25;
  14637. logger$1.info("Set fps to", t);
  14638. var r = t > 60 ? 60 : t < 24 ? 24 : t;
  14639. e.Engine.stopRenderLoop();
  14640. var n = 1e3 / r;
  14641. var o = Date.now(),
  14642. a = Date.now(),
  14643. s = n,
  14644. l = 1;
  14645. var u = function u() {
  14646. var T;
  14647. var c = Date.now(),
  14648. h = c - o,
  14649. f = c - a;
  14650. a = c, _this.frameCircularArray.add(f), h - s > n && (_this.systemStuckCnt += 1);
  14651. var d = h / s;
  14652. l = .9 * l + .1 * d;
  14653. var _ = Date.now();
  14654. var g = 0,
  14655. m = 0;
  14656. if (_this.room.isUpdatedRawYUVData || _this.room.isPano) {
  14657. 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", {
  14658. error: new Error("[SDK] Scene not ready, skip render and reload.")
  14659. })), _this.room.stats.assign({
  14660. renderErrorCount: _this._checkSceneNotReadyCount
  14661. }), logger$1.infoAndReportMeasurement({
  14662. value: 0,
  14663. startTime: Date.now(),
  14664. metric: "renderError",
  14665. error: new Error("[SDK] Scene not ready, skip render and reload."),
  14666. reportOptions: {
  14667. sampleRate: .1
  14668. }
  14669. }));else try {
  14670. e.render();
  14671. } catch (C) {
  14672. _this.renderErrorCount++, _this.renderErrorCount > 10 && _this.room.proxyEvents("renderError", {
  14673. error: C
  14674. }), _this.room.stats.assign({
  14675. renderErrorCount: _this.renderErrorCount
  14676. }), logger$1.infoAndReportMeasurement({
  14677. value: 0,
  14678. startTime: Date.now(),
  14679. metric: "renderError",
  14680. error: C,
  14681. reportOptions: {
  14682. sampleRate: .1
  14683. }
  14684. });
  14685. }
  14686. g = Date.now() - _, _this.frameRenderNumber < 1e3 && _this.frameRenderNumber++, _this.room.networkController.rtcp.workers.UpdateYUV(), m = Date.now() - _ - g;
  14687. }
  14688. _this.isRenderFirstFrame || _this.room.networkController.rtcp.workers.UpdateYUV();
  14689. var y = Date.now() - _;
  14690. o = c + y, s = Math.min(Math.max((n - y) / l, 5), 200), y > n && (s = 10, _this.engineSloppyCnt += 1), _this._idleTime = s;
  14691. var b = s;
  14692. 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) {
  14693. var C = _this.frameCircularArray.getAvg(),
  14694. A = _this.timeoutCircularArray.getAvg(),
  14695. S = _this.frameCircularArray.getMax(),
  14696. P = _this.timeoutCircularArray.getMax();
  14697. (T = _this.room.stats) == null || T.assign({
  14698. avgFrameTime: C,
  14699. avgTimeoutTime: A,
  14700. maxFrameTime: S,
  14701. maxTimeoutTime: P,
  14702. systemStuckCnt: _this.systemStuckCnt
  14703. });
  14704. }
  14705. _this.renderTimer = window.setTimeout(u, s);
  14706. };
  14707. _this.renderTimer = window.setTimeout(u, n / l);
  14708. });
  14709. E(this, "updateStats", function () {
  14710. var e;
  14711. (e = _this.room.stats) == null || e.assign({
  14712. renderFrameTime: _this.renderTimeCircularArray.getAvg(),
  14713. maxRenderFrameTime: _this.renderTimeCircularArray.getMax(),
  14714. interFrameTime: _this.interFrameCircularArray.getAvg(),
  14715. animationTime: _this.animationCircularArray.getAvg(),
  14716. meshSelectTime: _this.meshSelectCircularArray.getAvg(),
  14717. drawcallTime: _this.drawCallTimeCircularArray.getAvg(),
  14718. idleTime: _this._idleTime,
  14719. registerBeforeRenderTime: _this.regBeforeRenderCircularArray.getAvg(),
  14720. registerAfterRenderTime: _this.regAfterRenderCircularArray.getAvg(),
  14721. renderTargetRenderTime: _this.renderTargetCircularArray.getAvg(),
  14722. fps: (1e3 / (_this.renderTimeCircularArray.getAvg() + _this.interFrameCircularArray.getAvg())).toFixed(2),
  14723. drawcall: _this.drawCallCntCircularArray.getAvg(),
  14724. engineSloppyCnt: _this.engineSloppyCnt,
  14725. maxInterFrameTime: _this.interFrameCircularArray.getMax(),
  14726. maxDrawcallTime: _this.drawCallTimeCircularArray.getMax(),
  14727. maxMeshSelectTime: _this.meshSelectCircularArray.getMax(),
  14728. maxAnimationTime: _this.animationCircularArray.getMax(),
  14729. maxRegisterBeforeRenderTime: _this.regBeforeRenderCircularArray.getMax(),
  14730. maxRegisterAfterRenderTime: _this.regAfterRenderCircularArray.getMax(),
  14731. maxRenderTargetRenderTime: _this.renderTargetCircularArray.getMax(),
  14732. avgFrameTime: _this.frameCircularArray.getAvg(),
  14733. avgTimeoutTime: _this.timeoutCircularArray.getAvg(),
  14734. maxFrameTime: _this.frameCircularArray.getMax(),
  14735. maxTimeoutTime: _this.timeoutCircularArray.getMax()
  14736. });
  14737. });
  14738. this.room = e;
  14739. }
  14740. _createClass(EngineProxy, [{
  14741. key: "initEngine",
  14742. value: function () {
  14743. var _initEngine = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  14744. var t, r, n, o, a;
  14745. return regenerator.wrap(function _callee3$(_context3) {
  14746. while (1) {
  14747. switch (_context3.prev = _context3.next) {
  14748. case 0:
  14749. _context3.next = 2;
  14750. return this.updateBillboard();
  14751. case 2:
  14752. logger$1.info("engine version:", VERSION$1);
  14753. t = logger$1;
  14754. t.setLevel(LoggerLevels$1.Warn);
  14755. r = {
  14756. videoResOriArray: [{
  14757. width: 720,
  14758. height: 1280
  14759. }, {
  14760. width: 1280,
  14761. height: 720
  14762. }, {
  14763. width: 480,
  14764. height: 654
  14765. }, {
  14766. width: 654,
  14767. height: 480
  14768. }, {
  14769. width: 1920,
  14770. height: 1080
  14771. }, {
  14772. width: 1080,
  14773. height: 1920
  14774. }, {
  14775. width: 414,
  14776. height: 896
  14777. }],
  14778. forceKeepVertical: this.room.options.objectFit !== "cover",
  14779. panoInfo: {
  14780. dynamicRange: 1,
  14781. width: 4096,
  14782. height: 2048
  14783. },
  14784. shaderMode: EShaderMode.videoAndPano,
  14785. yuvInfo: {
  14786. width: 1280,
  14787. height: 720,
  14788. fov: e.fov || DEFAULT_MAIN_CAMERA_FOV
  14789. },
  14790. cameraParam: {
  14791. maxZ: 1e4
  14792. },
  14793. urlTransformer,
  14794. logger: t,
  14795. disableWebGL2: this.room.options.disableWebGL2 || !1
  14796. }, n = this.room.options.resolution;
  14797. n && (r.videoResOriArray.some(function (l) {
  14798. return l.width === n.width && l.height === n.height;
  14799. }) || r.videoResOriArray.push(n));
  14800. o = this.room.sceneManager = getSceneManager(this.room.canvas, r);
  14801. this.room.setPictureQualityLevel(this.room.options.pictureQualityLevel || "high");
  14802. this.room.sceneManager.staticmeshComponent.setRegionLodRule([2, 2, -1, -1, -1]);
  14803. this.room.scene = o.Scene;
  14804. this.room.breathPointManager = o.breathPointComponent;
  14805. this.lightManager = o.lightComponent;
  14806. this.registerStats();
  14807. this.setEnv(e);
  14808. _context3.next = 17;
  14809. return this.room.avatarManager.init();
  14810. case 17:
  14811. a = this._createAssetList(e);
  14812. _context3.next = 20;
  14813. return this.loadAssets(a, "");
  14814. case 20:
  14815. this._setFPS(o);
  14816. case 21:
  14817. case "end":
  14818. return _context3.stop();
  14819. }
  14820. }
  14821. }, _callee3, this);
  14822. }));
  14823. function initEngine(_x3) {
  14824. return _initEngine.apply(this, arguments);
  14825. }
  14826. return initEngine;
  14827. }()
  14828. }, {
  14829. key: "pause",
  14830. value: function pause() {
  14831. clearTimeout(this.renderTimer), logger$1.info("Invoke room.pause to pause render");
  14832. var e = {
  14833. roomId: this.room.id,
  14834. effects: [],
  14835. lowPolyModels: [],
  14836. breathPointsConfig: [],
  14837. skinId: this.room.skinId
  14838. };
  14839. return this.loadAssets(e, this.room.skinId);
  14840. }
  14841. }, {
  14842. key: "resume",
  14843. value: function () {
  14844. var _resume = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4() {
  14845. var e;
  14846. return regenerator.wrap(function _callee4$(_context4) {
  14847. while (1) {
  14848. switch (_context4.prev = _context4.next) {
  14849. case 0:
  14850. this._setFPS(this.room.sceneManager), this.room.sceneManager.cameraComponent.cameraFovChange(this.room.sceneManager.yuvInfo), logger$1.info("Invoke room.resume to render");
  14851. e = this._createAssetList(this.room.skin);
  14852. _context4.next = 4;
  14853. return this.loadAssets(e, "");
  14854. case 4:
  14855. case "end":
  14856. return _context4.stop();
  14857. }
  14858. }
  14859. }, _callee4, this);
  14860. }));
  14861. function resume() {
  14862. return _resume.apply(this, arguments);
  14863. }
  14864. return resume;
  14865. }()
  14866. }, {
  14867. key: "setEnv",
  14868. value: function setEnv(e) {
  14869. var r;
  14870. this.lightManager || (this.lightManager = this.room.sceneManager.lightComponent), e = e || this.room.skin;
  14871. var t = ModelManager.findModel(e.models, AssetTypeName.Config, AssetClassName.Env);
  14872. return t ? (r = this.lightManager) == null ? void 0 : r.setIBL(t.modelUrl) : (logger$1.error("env file not found"), Promise.resolve());
  14873. }
  14874. }, {
  14875. key: "_parseModelsAndLoad",
  14876. value: function () {
  14877. var _parseModelsAndLoad2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(e, t, r) {
  14878. var n, o, a, u, c, h, _c, s, l, _u, _c2, _h;
  14879. return regenerator.wrap(function _callee5$(_context5) {
  14880. while (1) {
  14881. switch (_context5.prev = _context5.next) {
  14882. case 0:
  14883. logger$1.info("Invoke _parseModelsAndLoad start", t);
  14884. n = ["airship", "balloon", "default", "ground_feiting", "ground_reqiqiu"], o = new Map();
  14885. r == null && (r = "xxxx");
  14886. a = !0;
  14887. u = 0;
  14888. case 5:
  14889. if (!(u < e.length)) {
  14890. _context5.next = 20;
  14891. break;
  14892. }
  14893. a = !0;
  14894. c = 0;
  14895. case 8:
  14896. if (!(c < n.length)) {
  14897. _context5.next = 16;
  14898. break;
  14899. }
  14900. if (!(e[u].modelUrl.toLowerCase().indexOf(n[c]) >= 0)) {
  14901. _context5.next = 13;
  14902. break;
  14903. }
  14904. h = o.get(n[c]);
  14905. h ? (h.push(e[u]), o.set(n[c], h)) : o.set(n[c], [e[u]]), a = !1;
  14906. return _context5.abrupt("break", 16);
  14907. case 13:
  14908. ++c;
  14909. _context5.next = 8;
  14910. break;
  14911. case 16:
  14912. if (a) {
  14913. _c = o.get("default");
  14914. _c ? (_c.push(e[u]), o.set("default", _c)) : o.set("default", [e[u]]);
  14915. }
  14916. case 17:
  14917. ++u;
  14918. _context5.next = 5;
  14919. break;
  14920. case 20:
  14921. s = o.get(t) || [];
  14922. if (!(this.room.viewMode === "simple" && (s = s.filter(function (u) {
  14923. return !u.modelUrl.endsWith("zip");
  14924. })), !s)) {
  14925. _context5.next = 23;
  14926. break;
  14927. }
  14928. return _context5.abrupt("return", Promise.reject("no invalid scene model with group name: ".concat(t)));
  14929. case 23:
  14930. l = [];
  14931. for (_u = 0; _u < s.length; ++_u) {
  14932. _c2 = s[_u];
  14933. if (_c2.modelUrl.toLowerCase().endsWith("zip")) _c2.modelUrl.toLowerCase().endsWith("zip") && l.push(this.room.sceneManager.addNewLowPolyMesh({
  14934. url: _c2.modelUrl,
  14935. skinInfo: r
  14936. }));else {
  14937. _h = t;
  14938. l.push(this.room.sceneManager.addNewLowPolyMesh({
  14939. url: _c2.modelUrl,
  14940. group: _h,
  14941. pick: !0,
  14942. skinInfo: r
  14943. }));
  14944. }
  14945. }
  14946. return _context5.abrupt("return", Promise.all(l));
  14947. case 26:
  14948. case "end":
  14949. return _context5.stop();
  14950. }
  14951. }
  14952. }, _callee5, this);
  14953. }));
  14954. function _parseModelsAndLoad(_x4, _x5, _x6) {
  14955. return _parseModelsAndLoad2.apply(this, arguments);
  14956. }
  14957. return _parseModelsAndLoad;
  14958. }()
  14959. }, {
  14960. key: "_deleteAssetsLowpolyModel",
  14961. value: function () {
  14962. var _deleteAssetsLowpolyModel2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e) {
  14963. var t;
  14964. return regenerator.wrap(function _callee6$(_context6) {
  14965. while (1) {
  14966. switch (_context6.prev = _context6.next) {
  14967. case 0:
  14968. this.room.sceneManager.staticmeshComponent.deleteMeshesBySkinInfo(e), this.room.sceneManager.breathPointComponent.clearBreathPointsBySkinInfo(e), this.room.sceneManager.decalComponent.deleteDecalBySkinInfo(e);
  14969. t = [];
  14970. this.room.sceneManager.Scene.meshes.forEach(function (r) {
  14971. r.xskinInfo == e && t.push(r);
  14972. }), t.forEach(function (r) {
  14973. r.dispose(!1, !1);
  14974. });
  14975. case 3:
  14976. case "end":
  14977. return _context6.stop();
  14978. }
  14979. }
  14980. }, _callee6, this);
  14981. }));
  14982. function _deleteAssetsLowpolyModel(_x7) {
  14983. return _deleteAssetsLowpolyModel2.apply(this, arguments);
  14984. }
  14985. return _deleteAssetsLowpolyModel;
  14986. }()
  14987. }, {
  14988. key: "loadLandAssets",
  14989. value: function () {
  14990. var _loadLandAssets = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7() {
  14991. var _this2 = this;
  14992. var e;
  14993. return regenerator.wrap(function _callee7$(_context7) {
  14994. while (1) {
  14995. switch (_context7.prev = _context7.next) {
  14996. case 0:
  14997. e = this._createAssetList(this.room.skin);
  14998. return _context7.abrupt("return", this.loadAssets(e, this.room.skinId).catch(function () {
  14999. return _this2.loadAssets(e, _this2.room.skinId);
  15000. }));
  15001. case 2:
  15002. case "end":
  15003. return _context7.stop();
  15004. }
  15005. }
  15006. }, _callee7, this);
  15007. }));
  15008. function loadLandAssets() {
  15009. return _loadLandAssets.apply(this, arguments);
  15010. }
  15011. return loadLandAssets;
  15012. }()
  15013. }, {
  15014. key: "loadAssets",
  15015. value: function () {
  15016. var _loadAssets2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8(e) {
  15017. var t,
  15018. r,
  15019. n,
  15020. _args8 = arguments;
  15021. return regenerator.wrap(function _callee8$(_context8) {
  15022. while (1) {
  15023. switch (_context8.prev = _context8.next) {
  15024. case 0:
  15025. t = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : "";
  15026. r = _args8.length > 2 && _args8[2] !== undefined ? _args8[2] : 8e3;
  15027. n = Date.now();
  15028. return _context8.abrupt("return", this._loadAssets(e, t)._timeout(r, new InitEngineTimeoutError("loadAssets timeout(".concat(r, "ms)"))).then(function (o) {
  15029. return logger$1.infoAndReportMeasurement({
  15030. tag: "loadAssets",
  15031. startTime: n,
  15032. metric: "loadAssets"
  15033. }), o;
  15034. }).catch(function (o) {
  15035. return logger$1.infoAndReportMeasurement({
  15036. tag: "loadAssets",
  15037. startTime: n,
  15038. metric: "loadAssets",
  15039. error: o
  15040. }), Promise.reject(o);
  15041. }));
  15042. case 4:
  15043. case "end":
  15044. return _context8.stop();
  15045. }
  15046. }
  15047. }, _callee8, this);
  15048. }));
  15049. function loadAssets(_x8) {
  15050. return _loadAssets2.apply(this, arguments);
  15051. }
  15052. return loadAssets;
  15053. }()
  15054. }, {
  15055. key: "_loadAssets",
  15056. value: function () {
  15057. var _loadAssets3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9(e) {
  15058. var t,
  15059. r,
  15060. _args9 = arguments;
  15061. return regenerator.wrap(function _callee9$(_context9) {
  15062. while (1) {
  15063. switch (_context9.prev = _context9.next) {
  15064. case 0:
  15065. t = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : "";
  15066. _context9.prev = 1;
  15067. r = [];
  15068. r.push(this._loadAssetsLowpolyModel(e, t));
  15069. _context9.next = 6;
  15070. return Promise.all(r);
  15071. case 6:
  15072. _context9.next = 8;
  15073. return this.setEnv();
  15074. case 8:
  15075. this._checkSceneDurationFrameNum = EngineProxy._CHECK_DURATION;
  15076. this._checkSceneNotReadyCount = 0;
  15077. this._checkSceneFrameCount = 0;
  15078. this.updateAnimationList();
  15079. this.room.loadAssetsHook();
  15080. _context9.next = 18;
  15081. break;
  15082. case 15:
  15083. _context9.prev = 15;
  15084. _context9.t0 = _context9["catch"](1);
  15085. return _context9.abrupt("return", Promise.reject(_context9.t0));
  15086. case 18:
  15087. case "end":
  15088. return _context9.stop();
  15089. }
  15090. }
  15091. }, _callee9, this, [[1, 15]]);
  15092. }));
  15093. function _loadAssets(_x9) {
  15094. return _loadAssets3.apply(this, arguments);
  15095. }
  15096. return _loadAssets;
  15097. }()
  15098. }, {
  15099. key: "updateAnimationList",
  15100. value: function updateAnimationList() {
  15101. var _this3 = this;
  15102. if (this.room.avatarManager && this.room.avatarManager.xAvatarManager) {
  15103. var e = this.room.skin.animationList;
  15104. if (!e) return;
  15105. e.forEach(function (t) {
  15106. _this3.room.avatarManager.xAvatarManager.updateAnimationLists(t.animations, t.avatarId);
  15107. });
  15108. }
  15109. }
  15110. }, {
  15111. key: "_loadAssetsLowpolyModel",
  15112. value: function () {
  15113. var _loadAssetsLowpolyModel2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee11(e) {
  15114. var _this4 = this;
  15115. var t,
  15116. r,
  15117. n,
  15118. o,
  15119. a,
  15120. s,
  15121. u,
  15122. c,
  15123. h,
  15124. _args11 = arguments;
  15125. return regenerator.wrap(function _callee11$(_context11) {
  15126. while (1) {
  15127. switch (_context11.prev = _context11.next) {
  15128. case 0:
  15129. t = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : "";
  15130. r = [], n = [], o = [];
  15131. e.lowPolyModels.forEach(function (f) {
  15132. f.group === "TV" ? n.push({
  15133. id: "",
  15134. name: "",
  15135. thumbnailUrl: "",
  15136. typeName: AssetTypeName.Model,
  15137. className: AssetClassName.Tv,
  15138. modelUrl: f.url
  15139. }) : f.group === "\u544A\u767D\u5899" ? o.push({
  15140. id: "",
  15141. name: "",
  15142. thumbnailUrl: "",
  15143. typeName: AssetTypeName.Model,
  15144. className: AssetClassName.Lpm,
  15145. modelUrl: f.url
  15146. }) : r.push({
  15147. id: "",
  15148. name: "",
  15149. thumbnailUrl: "",
  15150. typeName: AssetTypeName.Model,
  15151. className: AssetClassName.Lpm,
  15152. modelUrl: f.url
  15153. });
  15154. }), t != "" && t != null && this._deleteAssetsLowpolyModel(t);
  15155. a = e.skinId;
  15156. logger$1.info("====> from ", t, " to ", a), this._tvs.forEach(function (f) {
  15157. return f.clean();
  15158. }), this._tvs = [];
  15159. s = EFitMode.cover;
  15160. a == "10048" && (s = EFitMode.contain), Array.isArray(n) && n.forEach(function (f, d) {
  15161. _this4._tvs.push(new TV("squareTv" + d, f.modelUrl, _this4.room, {
  15162. fitMode: s
  15163. }));
  15164. }), e.breathPointsConfig.forEach( /*#__PURE__*/function () {
  15165. var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10(f) {
  15166. var d;
  15167. return regenerator.wrap(function _callee10$(_context10) {
  15168. while (1) {
  15169. switch (_context10.prev = _context10.next) {
  15170. case 0:
  15171. _context10.prev = 0;
  15172. _context10.next = 3;
  15173. return urlTransformer(f.imageUrl);
  15174. case 3:
  15175. d = _context10.sent;
  15176. _context10.next = 9;
  15177. break;
  15178. case 6:
  15179. _context10.prev = 6;
  15180. _context10.t0 = _context10["catch"](0);
  15181. d = f.imageUrl, logger$1.error("urlTransformer error", _context10.t0);
  15182. case 9:
  15183. _this4.room.breathPointManager.addBreathPoint({
  15184. id: f.id,
  15185. position: f.position,
  15186. spriteSheet: d,
  15187. rotation: f.rotation || {
  15188. pitch: 0,
  15189. yaw: 270,
  15190. roll: 0
  15191. },
  15192. billboardMode: !0,
  15193. type: f.type || "no_type",
  15194. spriteWidthNumber: f.spriteWidthNum || 1,
  15195. spriteHeightNumber: f.spriteHeightNum || 1,
  15196. maxVisibleRegion: f.maxVisibleRegion || 150,
  15197. width: f.width,
  15198. height: f.height,
  15199. skinInfo: f.skinId
  15200. });
  15201. case 10:
  15202. case "end":
  15203. return _context10.stop();
  15204. }
  15205. }
  15206. }, _callee10, null, [[0, 6]]);
  15207. }));
  15208. return function (_x11) {
  15209. return _ref3.apply(this, arguments);
  15210. };
  15211. }()), o.forEach(function (f) {
  15212. _this4.room.sceneManager.decalComponent.addDecal({
  15213. id: f.id || "gbq",
  15214. meshPath: f.modelUrl,
  15215. skinInfo: a
  15216. });
  15217. });
  15218. u = this.room.sceneManager.staticmeshComponent.lowModel_group, c = Array.from(u.keys()).filter(function (f) {
  15219. return !f.startsWith("region_");
  15220. }), h = ["airship", "balloon", "ground_feiting", "ground_reqiqiu", "default"];
  15221. return _context11.abrupt("return", new Promise(function (f, d) {
  15222. Promise.all(h.map(function (_) {
  15223. return _this4._parseModelsAndLoad(r, _, a);
  15224. })).then(function () {
  15225. var _ = !1;
  15226. r.forEach(function (v) {
  15227. v.modelUrl.endsWith("zip") && (_ = !0);
  15228. }), _ == !1 && _this4.room.sceneManager.staticmeshComponent.deleteLastRegionMesh(), _this4.room.sceneManager.staticmeshComponent.lowModel_group;
  15229. var g = Array.from(u.keys()).filter(function (v) {
  15230. return !v.startsWith("region_");
  15231. }),
  15232. m = c.filter(function (v) {
  15233. return g.indexOf(v) < 0;
  15234. });
  15235. m.length > 0 && m.forEach(function (v) {
  15236. _this4.room.sceneManager.staticmeshComponent.deleteMeshesByGroup(v);
  15237. }), f(!0);
  15238. }).catch(function (_) {
  15239. d(_);
  15240. });
  15241. }));
  15242. case 9:
  15243. case "end":
  15244. return _context11.stop();
  15245. }
  15246. }
  15247. }, _callee11, this);
  15248. }));
  15249. function _loadAssetsLowpolyModel(_x10) {
  15250. return _loadAssetsLowpolyModel2.apply(this, arguments);
  15251. }
  15252. return _loadAssetsLowpolyModel;
  15253. }()
  15254. }, {
  15255. key: "_updateSkinAssets",
  15256. value: function () {
  15257. var _updateSkinAssets2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee12(e) {
  15258. var t, r, n;
  15259. return regenerator.wrap(function _callee12$(_context12) {
  15260. while (1) {
  15261. switch (_context12.prev = _context12.next) {
  15262. case 0:
  15263. t = this.room.lastSkinId;
  15264. _context12.next = 3;
  15265. return this.room.getSkin(e);
  15266. case 3:
  15267. r = _context12.sent;
  15268. n = this._createAssetList(r);
  15269. _context12.prev = 5;
  15270. _context12.next = 8;
  15271. return this.loadAssets(n, t);
  15272. case 8:
  15273. this.room.updateCurrentState({
  15274. versionId: r.versionId,
  15275. skinId: r.id,
  15276. skin: r
  15277. });
  15278. _context12.next = 16;
  15279. break;
  15280. case 11:
  15281. _context12.prev = 11;
  15282. _context12.t0 = _context12["catch"](5);
  15283. _context12.next = 15;
  15284. return this.loadAssets(n, t);
  15285. case 15:
  15286. this.room.updateCurrentState({
  15287. versionId: r.versionId,
  15288. skinId: r.id,
  15289. skin: r
  15290. });
  15291. case 16:
  15292. this.setEnv(r);
  15293. case 17:
  15294. case "end":
  15295. return _context12.stop();
  15296. }
  15297. }
  15298. }, _callee12, this, [[5, 11]]);
  15299. }));
  15300. function _updateSkinAssets(_x12) {
  15301. return _updateSkinAssets2.apply(this, arguments);
  15302. }
  15303. return _updateSkinAssets;
  15304. }()
  15305. }, {
  15306. key: "_createAssetList",
  15307. value: function _createAssetList(e) {
  15308. var t = [],
  15309. r = [],
  15310. n = [];
  15311. var o = e.models;
  15312. var a = this.room.modelManager.config.preload;
  15313. return this.room.viewMode === "simple" ? a && (o = a.baseUrls.map(function (l) {
  15314. return l.modelUrl = l.url, l;
  15315. })) : this.room.viewMode, ModelManager.findModels(o, AssetTypeName.Effects, AssetClassName.Effects).forEach(function (l) {
  15316. t.push({
  15317. url: l.modelUrl,
  15318. group: l.className,
  15319. name: l.name
  15320. });
  15321. }), ModelManager.findModels(o, AssetTypeName.Model, AssetClassName.Lpm).forEach(function (l) {
  15322. r.push({
  15323. url: l.modelUrl,
  15324. group: l.className
  15325. });
  15326. }), ModelManager.findModels(o, AssetTypeName.Model, AssetClassName.Gbq).forEach(function (l) {
  15327. r.push({
  15328. url: l.modelUrl,
  15329. group: l.className
  15330. });
  15331. }), ModelManager.findModels(o, AssetTypeName.Model, AssetClassName.Tv).forEach(function (l) {
  15332. r.push({
  15333. url: l.modelUrl,
  15334. group: l.className
  15335. });
  15336. }), [].forEach(function (l) {
  15337. l.skinId == e.id && n.push(l);
  15338. }), {
  15339. roomId: this.room.id,
  15340. effects: t,
  15341. lowPolyModels: r,
  15342. breathPointsConfig: n,
  15343. skinId: e.id
  15344. };
  15345. }
  15346. }, {
  15347. key: "registerStats",
  15348. value: function registerStats() {
  15349. var _this5 = this;
  15350. var e = this.room.sceneManager;
  15351. this.room.scene.registerAfterRender(function () {
  15352. var I;
  15353. var t = e.statisticComponent.getInterFrameTimeCounter(),
  15354. r = e.statisticComponent.getDrawCall(),
  15355. n = e.statisticComponent.getActiveFaces(),
  15356. o = e.statisticComponent.getFrameTimeCounter(),
  15357. a = e.statisticComponent.getDrawCallTime(),
  15358. s = e.statisticComponent.getAnimationTime(),
  15359. l = e.statisticComponent.getActiveMeshEvaluationTime(),
  15360. u = e.statisticComponent.getRenderTargetRenderTime(),
  15361. c = e.statisticComponent.getRegisterBeforeRenderTime(),
  15362. h = e.statisticComponent.getRegisterAfterRenderTime(),
  15363. f = e.statisticComponent.getActiveParticles(),
  15364. d = e.statisticComponent.getActiveBones(),
  15365. _ = e.Scene._activeAnimatables.length,
  15366. g = e.statisticComponent.getTotalRootNodes(),
  15367. m = e.Scene.geometries.length,
  15368. v = e.Scene.onBeforeRenderObservable.observers.length,
  15369. y = e.Scene.onAfterRenderObservable.observers.length,
  15370. b = e.statisticComponent.getTotalMeshes(),
  15371. T = e.statisticComponent.getTotalTextures(),
  15372. C = e.statisticComponent.getTotalMaterials(),
  15373. A = e.statisticComponent.getSystemInfo(),
  15374. S = A.resolution,
  15375. P = A.driver;
  15376. A.vender;
  15377. var R = A.version,
  15378. M = A.hardwareScalingLevel,
  15379. x = S + "_" + P + "_" + R + "_" + M;
  15380. _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({
  15381. renderFrameTime: _this5.renderTimeCircularArray.getAvg(),
  15382. maxRenderFrameTime: _this5.renderTimeCircularArray.getMax(),
  15383. interFrameTime: _this5.interFrameCircularArray.getAvg(),
  15384. animationTime: _this5.animationCircularArray.getAvg(),
  15385. meshSelectTime: _this5.meshSelectCircularArray.getAvg(),
  15386. drawcallTime: _this5.drawCallTimeCircularArray.getAvg(),
  15387. idleTime: _this5._idleTime,
  15388. registerBeforeRenderTime: _this5.regBeforeRenderCircularArray.getAvg(),
  15389. registerAfterRenderTime: _this5.regAfterRenderCircularArray.getAvg(),
  15390. renderTargetRenderTime: _this5.renderTargetCircularArray.getAvg(),
  15391. fps: (1e3 / (_this5.renderTimeCircularArray.getAvg() + _this5.interFrameCircularArray.getAvg())).toFixed(2),
  15392. drawcall: _this5.drawCallCntCircularArray.getAvg(),
  15393. triangle: n.toString(),
  15394. engineSloppyCnt: _this5.engineSloppyCnt,
  15395. maxInterFrameTime: _this5.interFrameCircularArray.getMax(),
  15396. maxDrawcallTime: _this5.drawCallTimeCircularArray.getMax(),
  15397. maxMeshSelectTime: _this5.meshSelectCircularArray.getMax(),
  15398. maxAnimationTime: _this5.animationCircularArray.getMax(),
  15399. maxRegisterBeforeRenderTime: _this5.regBeforeRenderCircularArray.getMax(),
  15400. maxRegisterAfterRenderTime: _this5.regAfterRenderCircularArray.getMax(),
  15401. maxRenderTargetRenderTime: _this5.renderTargetCircularArray.getMax(),
  15402. activeParticles: f,
  15403. activeBones: d,
  15404. activeAnimation: _,
  15405. totalMeshes: b,
  15406. totalRootNodes: g,
  15407. totalGeometries: m,
  15408. totalTextures: T,
  15409. totalMaterials: C,
  15410. registerBeforeCount: v,
  15411. registerAfterCount: y,
  15412. hardwareInfo: x
  15413. }));
  15414. });
  15415. }
  15416. }, {
  15417. key: "updateBillboard",
  15418. value: function () {
  15419. var _updateBillboard = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee13() {
  15420. var e, r, n, o, a, s;
  15421. return regenerator.wrap(function _callee13$(_context13) {
  15422. while (1) {
  15423. switch (_context13.prev = _context13.next) {
  15424. case 0:
  15425. e = this.room.options.skinId;
  15426. _context13.next = 3;
  15427. return this.room.modelManager.findAssetList(e);
  15428. case 3:
  15429. r = _context13.sent.filter(function (a) {
  15430. return a.typeName === AssetTypeName.Textures && a.className === AssetClassName.SayBubble;
  15431. });
  15432. n = ["bubble01", "bubble02", "bubble03"];
  15433. o = ["bubble01_npc", "bubble02_npc", "bubble03_npc"];
  15434. if (r.length) {
  15435. a = r.filter(function (l) {
  15436. return n.includes(l.name);
  15437. }).map(function (l) {
  15438. return l.url;
  15439. }), s = r.filter(function (l) {
  15440. return o.includes(l.name);
  15441. }).map(function (l) {
  15442. return l.url;
  15443. });
  15444. a.length && (XBillboardManager$1.userBubbleUrls = a), s.length && (XBillboardManager$1.npcBubbleUrls = s);
  15445. }
  15446. case 7:
  15447. case "end":
  15448. return _context13.stop();
  15449. }
  15450. }
  15451. }, _callee13, this);
  15452. }));
  15453. function updateBillboard() {
  15454. return _updateBillboard.apply(this, arguments);
  15455. }
  15456. return updateBillboard;
  15457. }()
  15458. }]);
  15459. return EngineProxy;
  15460. }();
  15461. 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); }; }
  15462. 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; } }
  15463. var LongPressMesh = [EMeshType.XAvatar];
  15464. var StaticMeshEvent = /*#__PURE__*/function (_EventEmitter) {
  15465. _inherits(StaticMeshEvent, _EventEmitter);
  15466. var _super = _createSuper$2(StaticMeshEvent);
  15467. function StaticMeshEvent(e) {
  15468. var _this;
  15469. _classCallCheck(this, StaticMeshEvent);
  15470. _this = _super.call(this);
  15471. E(_assertThisInitialized(_this), "scene");
  15472. E(_assertThisInitialized(_this), "_staringPointerTime", -1);
  15473. E(_assertThisInitialized(_this), "_pickedMeshID", "0");
  15474. E(_assertThisInitialized(_this), "_pointerDownTime", -1);
  15475. E(_assertThisInitialized(_this), "_currentPickPoint");
  15476. E(_assertThisInitialized(_this), "_longPressDelay", 500);
  15477. E(_assertThisInitialized(_this), "_pointerTapDelay", 200);
  15478. E(_assertThisInitialized(_this), "_pickedMeshType");
  15479. E(_assertThisInitialized(_this), "registerEvent", function () {
  15480. _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 () {
  15481. _this.scene.onPrePointerObservable.removeCallback(_this.onUp), _this.scene.onPrePointerObservable.removeCallback(_this.onDown), _this.scene.onPrePointerObservable.removeCallback(_this.onDoubleTap);
  15482. };
  15483. });
  15484. E(_assertThisInitialized(_this), "onUp", function () {
  15485. if (Date.now() - _this._pointerDownTime < _this._pointerTapDelay && !_this.scene._inputManager._isPointerSwiping()) {
  15486. _this.scene._inputManager._totalPointersPressed = 0;
  15487. var _e = _this._currentPickPoint;
  15488. _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) {
  15489. return t.isPickable && LongPressMesh.indexOf(t.xtype) == -1;
  15490. }), _e != null && _this.emit("pointTap", _e));
  15491. }
  15492. });
  15493. E(_assertThisInitialized(_this), "onDown", function () {
  15494. var e = _this.onPointerTap(function (t) {
  15495. return t.isPickable;
  15496. });
  15497. _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 () {
  15498. e = _this.onPointerTap(function (t) {
  15499. return t.isPickable && t.xtype == _this._pickedMeshType && t.xid == _this._pickedMeshID;
  15500. }), e !== null && Date.now() - _this._staringPointerTime > _this._longPressDelay && !_this.scene._inputManager._isPointerSwiping() && _this.scene._inputManager._totalPointersPressed !== 0 && (_this._staringPointerTime = 0, _this.emit("longPress", e));
  15501. }, _this._longPressDelay));
  15502. });
  15503. E(_assertThisInitialized(_this), "onDoubleTap", function () {
  15504. var e = _this.onPointerTap(void 0);
  15505. e != null && _this.emit("pointDoubleTap", e);
  15506. });
  15507. _this.manager = e, _this.scene = e.Scene, _this.registerEvent(), _this._currentPickPoint = null, _this._pickedMeshType = null;
  15508. return _this;
  15509. }
  15510. _createClass(StaticMeshEvent, [{
  15511. key: "onPointerTap",
  15512. value: function onPointerTap(e) {
  15513. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
  15514. var n, o;
  15515. var r = new BABYLON.PickingInfo();
  15516. if (t) {
  15517. var a = this.scene.multiPick(this.scene.pointerX, this.scene.pointerY, e, void 0, void 0);
  15518. a && a.length > 1 ? r = a[1] : a && (r = a[0]);
  15519. } else r = this.scene.pick(this.scene.pointerX, this.scene.pointerY, e, !1, null);
  15520. if (r.hit) {
  15521. var _a = (n = r == null ? void 0 : r.pickedPoint) == null ? void 0 : n.asArray();
  15522. if (_a) {
  15523. var _a2 = _slicedToArray(_a, 3),
  15524. s = _a2[0],
  15525. l = _a2[1],
  15526. u = _a2[2],
  15527. c = xversePosition2Ue4({
  15528. x: s,
  15529. y: l,
  15530. z: u
  15531. });
  15532. return {
  15533. name: (o = r.pickedMesh) == null ? void 0 : o.name,
  15534. type: r.pickedMesh.xtype,
  15535. id: r.pickedMesh.xid,
  15536. point: c
  15537. };
  15538. }
  15539. }
  15540. return null;
  15541. }
  15542. }]);
  15543. return StaticMeshEvent;
  15544. }(EventEmitter);
  15545. var RotationEvent = /*#__PURE__*/function () {
  15546. function RotationEvent(e) {
  15547. var _this = this;
  15548. _classCallCheck(this, RotationEvent);
  15549. E(this, "touchStartX");
  15550. E(this, "touchStartY");
  15551. E(this, "handelResize");
  15552. E(this, "_room");
  15553. E(this, "_canvas");
  15554. E(this, "handleTouchStart", function (e) {
  15555. var t = e.touches[0];
  15556. _this.touchStartX = t.pageX, _this.touchStartY = t.pageY, _this._room.emit("touchStart", {
  15557. event: e
  15558. });
  15559. });
  15560. E(this, "handleMouseDown", function (e) {
  15561. _this.touchStartX = e.pageX, _this.touchStartY = e.pageY;
  15562. });
  15563. E(this, "handleMouseMove", function (e) {
  15564. if (!_this.touchStartX || !_this.touchStartY) return;
  15565. var t = e.pageX,
  15566. r = e.pageY,
  15567. n = t - _this.touchStartX,
  15568. o = r - _this.touchStartY,
  15569. a = _this._room.options.canvas.offsetHeight,
  15570. s = _this._room.options.canvas.offsetWidth;
  15571. var l = 2 * o / a,
  15572. u = 2 * n / s;
  15573. l > 1 && (l = 1), u > 1 && (u = 1), _this._room.actionsHandler.rotate({
  15574. pitch: l,
  15575. yaw: u
  15576. }), _this.touchStartX = t, _this.touchStartY = r;
  15577. });
  15578. E(this, "handleMouseUp", function () {
  15579. _this.touchStartX = void 0, _this.touchStartY = void 0;
  15580. });
  15581. E(this, "handleTouchMove", function (e) {
  15582. if (!_this.touchStartX || !_this.touchStartY) return;
  15583. var t = e.touches[0],
  15584. r = t.pageX,
  15585. n = t.pageY,
  15586. o = r - _this.touchStartX,
  15587. a = n - _this.touchStartY,
  15588. s = _this._room.options.canvas.offsetHeight,
  15589. l = _this._room.options.canvas.offsetWidth;
  15590. var u = 2 * a / s,
  15591. c = 2 * o / l;
  15592. u > 1 && (u = 1), c > 1 && (c = 1), _this._room.actionsHandler.rotate({
  15593. pitch: u,
  15594. yaw: c
  15595. }), _this.touchStartX = r, _this.touchStartY = n, _this._room.emit("touchMove", {
  15596. pitch: u,
  15597. yaw: c,
  15598. event: e
  15599. });
  15600. });
  15601. E(this, "handleTouchEnd", function (e) {
  15602. _this._room.emit("touchEnd", {
  15603. event: e
  15604. });
  15605. });
  15606. this._room = e, this._canvas = e.canvas, this.handelResize = this.reiszeChange();
  15607. }
  15608. _createClass(RotationEvent, [{
  15609. key: "init",
  15610. value: function init() {
  15611. 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);
  15612. }
  15613. }, {
  15614. key: "clear",
  15615. value: function clear() {
  15616. 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);
  15617. }
  15618. }, {
  15619. key: "reiszeChange",
  15620. value: function reiszeChange() {
  15621. window.addEventListener("resize", function () {});
  15622. }
  15623. }]);
  15624. return RotationEvent;
  15625. }();
  15626. var EventsController = /*#__PURE__*/function () {
  15627. function EventsController(e) {
  15628. var _this = this;
  15629. _classCallCheck(this, EventsController);
  15630. E(this, "staticmeshEvent");
  15631. E(this, "rotationEvent");
  15632. E(this, "resize", function () {
  15633. _this.room.sceneManager.cameraComponent.cameraFovChange(_this.room.sceneManager.yuvInfo);
  15634. });
  15635. E(this, "clickEvent", function (e) {
  15636. var t = e.point,
  15637. r = e.name,
  15638. n = e.type,
  15639. o = e.id;
  15640. logger$1.debug("pointEvent", e), _this.room.proxyEvents("pointTap", {
  15641. point: t,
  15642. meshName: r,
  15643. type: n,
  15644. id: o
  15645. }), _this.room.proxyEvents("_coreClick", e);
  15646. });
  15647. E(this, "longPressEvent", function (e) {
  15648. _this.room.proxyEvents("_corePress", e);
  15649. });
  15650. E(this, "handleActionResponseTimeout", function (_ref) {
  15651. var e = _ref.error,
  15652. t = _ref.event;
  15653. _this.room.proxyEvents("actionResponseTimeout", {
  15654. error: e,
  15655. event: t
  15656. });
  15657. });
  15658. E(this, "handleNetworkStateChange", function (e) {
  15659. var t = e.state,
  15660. r = e.count;
  15661. t == "reconnecting" ? _this.room.proxyEvents("reconnecting", {
  15662. count: r || 1
  15663. }) : t === "reconnected" ? (_this.room.networkController.rtcp.workers.reset(), _this.room.proxyEvents("reconnected"), _this.room.afterReconnected()) : t === "disconnected" && _this.room.proxyEvents("disconnected");
  15664. });
  15665. this.room = e, this.staticmeshEvent = new StaticMeshEvent(this.room.sceneManager), this.rotationEvent = new RotationEvent(e);
  15666. }
  15667. _createClass(EventsController, [{
  15668. key: "bindEvents",
  15669. value: function bindEvents() {
  15670. 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);
  15671. }
  15672. }, {
  15673. key: "clearEvents",
  15674. value: function clearEvents() {
  15675. 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();
  15676. }
  15677. }]);
  15678. return EventsController;
  15679. }();
  15680. var Panorama = /*#__PURE__*/function () {
  15681. function Panorama(e) {
  15682. var _this = this;
  15683. _classCallCheck(this, Panorama);
  15684. E(this, "_actived", !1);
  15685. E(this, "handleReceivePanorama", /*#__PURE__*/function () {
  15686. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e, t) {
  15687. var r, n, _this$room$currentSta, o, a, s, _ref2, l;
  15688. return regenerator.wrap(function _callee$(_context) {
  15689. while (1) {
  15690. switch (_context.prev = _context.next) {
  15691. case 0:
  15692. logger$1.warn("handle panorama", e.uuid, e.pos, e.finished);
  15693. r = {
  15694. data: e.data,
  15695. pose: {
  15696. position: e.pos
  15697. }
  15698. }, n = _this.room.sceneManager;
  15699. _this.room.networkController.rtcp.workers.changePanoMode(!0);
  15700. _context.next = 5;
  15701. return n.materialComponent.changePanoImg(0, r);
  15702. case 5:
  15703. if (!e.finished) {
  15704. _context.next = 23;
  15705. break;
  15706. }
  15707. _context.next = 8;
  15708. return n.changePanoShaderForLowModel(0);
  15709. case 8:
  15710. _this.room.isPano = !0;
  15711. _this._actived = !0;
  15712. if (!t) {
  15713. _context.next = 14;
  15714. break;
  15715. }
  15716. _this.room.sceneManager.cameraComponent.changeToFirstPersonView({
  15717. position: t.position,
  15718. rotation: t.angle
  15719. });
  15720. _context.next = 23;
  15721. break;
  15722. case 14:
  15723. _this$room$currentSta = _this.room.currentState, o = _this$room$currentSta.skinId, a = _this$room$currentSta.pathName;
  15724. if (!(!o || !a)) {
  15725. _context.next = 17;
  15726. break;
  15727. }
  15728. return _context.abrupt("return");
  15729. case 17:
  15730. _context.next = 19;
  15731. return _this.room.modelManager.findRoute(o, a);
  15732. case 19:
  15733. s = _context.sent;
  15734. _ref2 = util.getRandomItem(s.birthPointList) || {};
  15735. l = _ref2.camera;
  15736. l && _this.room.sceneManager.cameraComponent.changeToFirstPersonView(le(oe({}, l), {
  15737. rotation: l.angle
  15738. }));
  15739. case 23:
  15740. case "end":
  15741. return _context.stop();
  15742. }
  15743. }
  15744. }, _callee);
  15745. }));
  15746. return function (_x, _x2) {
  15747. return _ref.apply(this, arguments);
  15748. };
  15749. }());
  15750. this.room = e;
  15751. }
  15752. _createClass(Panorama, [{
  15753. key: "actived",
  15754. get: function get() {
  15755. return this._actived;
  15756. }
  15757. }, {
  15758. key: "bindListener",
  15759. value: function bindListener(e) {
  15760. var _this2 = this;
  15761. this.room.networkController.rtcp.workers.registerFunction("panorama", function (r) {
  15762. 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));
  15763. });
  15764. }
  15765. }, {
  15766. key: "access",
  15767. value: function access(e, t, r) {
  15768. var _this3 = this;
  15769. var n = e.camera,
  15770. o = e.player,
  15771. a = e.attitude,
  15772. s = e.areaName,
  15773. l = e.pathName,
  15774. u = e.tag;
  15775. return this.room.actionsHandler.requestPanorama({
  15776. camera: n,
  15777. player: o,
  15778. attitude: a,
  15779. areaName: s,
  15780. pathName: l,
  15781. tag: u
  15782. }, t, r).then(function (c) {
  15783. return _this3.handleReceivePanorama(c, o);
  15784. });
  15785. }
  15786. }, {
  15787. key: "exit",
  15788. value: function exit(e) {
  15789. var _this4 = this;
  15790. var t = e.camera,
  15791. r = e.player,
  15792. n = e.attitude,
  15793. o = e.areaName,
  15794. a = e.pathName;
  15795. return this.room.networkController.rtcp.workers.changePanoMode(!1), this.room.actionsHandler.changeRotationRenderType({
  15796. renderType: RenderType.RotationVideo,
  15797. player: r,
  15798. camera: t,
  15799. attitude: n,
  15800. areaName: o,
  15801. pathName: a
  15802. }).then(function () {
  15803. return _this4.handleExitPanorama();
  15804. }).catch(function (s) {
  15805. return _this4.room.networkController.rtcp.workers.changePanoMode(!0), Promise.reject(s);
  15806. });
  15807. }
  15808. }, {
  15809. key: "handleExitPanorama",
  15810. value: function handleExitPanorama() {
  15811. var e, t, r, n, o, a;
  15812. this.room.isPano = !1, this._actived = !1, (n = (e = this.room.sceneManager) == null ? void 0 : e.cameraComponent) == null || n.forceChangeSavedCameraPose({
  15813. position: (t = this.room._currentClickingState) == null ? void 0 : t.camera.position,
  15814. rotation: (r = this.room._currentClickingState) == null ? void 0 : r.camera.angle
  15815. }), this.room.sceneManager.changeVideoShaderForLowModel(), (a = (o = this.room.sceneManager) == null ? void 0 : o.cameraComponent) == null || a.changeToThirdPersonView();
  15816. }
  15817. }]);
  15818. return Panorama;
  15819. }();
  15820. var BREATH_POINT_TYPE = "debugBreathPoint",
  15821. TAP_BREATH_POINT_TYPE = "debugTapBreathPoint",
  15822. DEFAULT_SEARCH_RANGE = 1e3;
  15823. var Debug = /*#__PURE__*/function () {
  15824. function Debug(e) {
  15825. _classCallCheck(this, Debug);
  15826. E(this, "isShowNearbyBreathPoints", !1);
  15827. E(this, "isShowTapBreathPoints", !1);
  15828. E(this, "isSceneShading", !0);
  15829. E(this, "searchRange", DEFAULT_SEARCH_RANGE);
  15830. E(this, "nearbyBreathPointListening", !1);
  15831. E(this, "tapBreathPointListening", !1);
  15832. E(this, "dumpStreamTimer", 0);
  15833. this.room = e;
  15834. }
  15835. _createClass(Debug, [{
  15836. key: "toggleStats",
  15837. value: function toggleStats() {
  15838. return this.room.stats.isShow ? this.room.stats.hide() : this.room.stats.show();
  15839. }
  15840. }, {
  15841. key: "toggleNearbyBreathPoint",
  15842. value: function toggleNearbyBreathPoint() {
  15843. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_SEARCH_RANGE;
  15844. this.searchRange = e, this.isShowNearbyBreathPoints = !this.isShowNearbyBreathPoints, this.isShowNearbyBreathPoints ? (this.getPointsAndRender(), this.setupNearbyBreathPointListener()) : this.room.breathPointManager.clearBreathPoints(BREATH_POINT_TYPE);
  15845. }
  15846. }, {
  15847. key: "toggleTapBreathPoint",
  15848. value: function toggleTapBreathPoint() {
  15849. this.isShowTapBreathPoints = !this.isShowTapBreathPoints, this.isShowTapBreathPoints ? this.setupTapPointListener() : this.room.breathPointManager.clearBreathPoints(TAP_BREATH_POINT_TYPE);
  15850. }
  15851. }, {
  15852. key: "dumpStream",
  15853. value: function dumpStream(e) {
  15854. var _this = this;
  15855. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10 * 1e3;
  15856. if (this.dumpStreamTimer) throw new Error("dumpStream running");
  15857. this.room.networkController.rtcp.workers.saveframe = !0, this.dumpStreamTimer = window.setTimeout(function () {
  15858. _this.room.networkController.rtcp.workers.SaveMediaStream = !0, _this.dumpStreamTimer = 0, e && e();
  15859. }, t);
  15860. }
  15861. }, {
  15862. key: "toggleSceneshading",
  15863. value: function toggleSceneshading() {
  15864. this.isSceneShading = !this.isSceneShading, this.isSceneShading ? this.room.sceneManager.changeVideoShaderForLowModel() : this.room.sceneManager.changeDefaultShaderForLowModel();
  15865. }
  15866. }, {
  15867. key: "setupTapPointListener",
  15868. value: function setupTapPointListener() {
  15869. var _this2 = this;
  15870. this.tapBreathPointListening || (this.tapBreathPointListening = !0, this.room.on("_coreClick", function (_ref) {
  15871. var e = _ref.point;
  15872. _this2.isShowTapBreathPoints && _this2.renderTapBreathPoint({
  15873. id: "tapToint",
  15874. position: e
  15875. });
  15876. }));
  15877. }
  15878. }, {
  15879. key: "renderTapBreathPoint",
  15880. value: function renderTapBreathPoint(_ref2) {
  15881. var e = _ref2.position,
  15882. t = _ref2.id;
  15883. var r;
  15884. if (r = this.room.breathPointManager.breathPoints.get(t)) {
  15885. r.position = e;
  15886. return;
  15887. }
  15888. this.room.breathPointManager.addBreathPoint({
  15889. id: t,
  15890. position: e,
  15891. type: TAP_BREATH_POINT_TYPE,
  15892. size: .8,
  15893. forceLeaveGround: !0,
  15894. billboardMode: !0,
  15895. rotation: Math.abs(e.z) < 20 ? {
  15896. pitch: 90,
  15897. yaw: 0,
  15898. roll: 0
  15899. } : {
  15900. pitch: 0,
  15901. yaw: 270,
  15902. roll: 0
  15903. }
  15904. });
  15905. }
  15906. }, {
  15907. key: "setupNearbyBreathPointListener",
  15908. value: function setupNearbyBreathPointListener() {
  15909. var _this3 = this;
  15910. var e;
  15911. this.nearbyBreathPointListening || (this.nearbyBreathPointListening = !0, (e = this.room._userAvatar) == null || e.on("stopMoving", function () {
  15912. _this3.isShowNearbyBreathPoints && _this3.getPointsAndRender();
  15913. }));
  15914. }
  15915. }, {
  15916. key: "getPointsAndRender",
  15917. value: function () {
  15918. var _getPointsAndRender = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  15919. var _this4 = this;
  15920. var r, n, e, t;
  15921. return regenerator.wrap(function _callee$(_context) {
  15922. while (1) {
  15923. switch (_context.prev = _context.next) {
  15924. case 0:
  15925. e = this.searchRange;
  15926. _context.t1 = (r = this.room._userAvatar) == null ? void 0 : r.position;
  15927. if (!_context.t1) {
  15928. _context.next = 6;
  15929. break;
  15930. }
  15931. _context.next = 5;
  15932. return this.getNeighborPoints({
  15933. point: (n = this.room._userAvatar) == null ? void 0 : n.position,
  15934. containSelf: !0,
  15935. searchRange: e
  15936. });
  15937. case 5:
  15938. _context.t1 = _context.sent;
  15939. case 6:
  15940. _context.t0 = _context.t1;
  15941. if (_context.t0) {
  15942. _context.next = 9;
  15943. break;
  15944. }
  15945. _context.t0 = [];
  15946. case 9:
  15947. t = _context.t0;
  15948. this.room.breathPointManager.breathPoints.forEach(function (o) {
  15949. !!t.find(function (s) {
  15950. return JSON.stringify(s) === o._id;
  15951. }) || _this4.room.breathPointManager.clearBreathPoints(o._id);
  15952. }), t.forEach(function (o) {
  15953. var a = JSON.stringify(o);
  15954. _this4.room.breathPointManager.breathPoints.get(a) || _this4.room.breathPointManager.addBreathPoint({
  15955. id: a,
  15956. position: o,
  15957. type: BREATH_POINT_TYPE,
  15958. rotation: {
  15959. pitch: 90,
  15960. yaw: 0,
  15961. roll: 0
  15962. },
  15963. forceLeaveGround: !0
  15964. });
  15965. });
  15966. case 11:
  15967. case "end":
  15968. return _context.stop();
  15969. }
  15970. }
  15971. }, _callee, this);
  15972. }));
  15973. function getPointsAndRender() {
  15974. return _getPointsAndRender.apply(this, arguments);
  15975. }
  15976. return getPointsAndRender;
  15977. }()
  15978. }, {
  15979. key: "getNeighborPoints",
  15980. value: function getNeighborPoints(e) {
  15981. var t = e.point,
  15982. _e$containSelf = e.containSelf,
  15983. r = _e$containSelf === void 0 ? !1 : _e$containSelf,
  15984. _e$searchRange = e.searchRange,
  15985. n = _e$searchRange === void 0 ? 500 : _e$searchRange;
  15986. return this.room.actionsHandler.getNeighborPoints({
  15987. point: t,
  15988. containSelf: r,
  15989. searchRange: n
  15990. });
  15991. }
  15992. }]);
  15993. return Debug;
  15994. }();
  15995. 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); }; }
  15996. 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; } }
  15997. var Xverse_Room = /*#__PURE__*/function (_EventEmitter) {
  15998. _inherits(Xverse_Room, _EventEmitter);
  15999. var _super = _createSuper$1(Xverse_Room);
  16000. function Xverse_Room(e) {
  16001. var _this;
  16002. _classCallCheck(this, Xverse_Room);
  16003. _this = _super.call(this);
  16004. E(_assertThisInitialized(_this), "disableAutoTurn", !1);
  16005. E(_assertThisInitialized(_this), "options");
  16006. E(_assertThisInitialized(_this), "_currentNetworkOptions");
  16007. E(_assertThisInitialized(_this), "lastSkinId");
  16008. E(_assertThisInitialized(_this), "debug");
  16009. E(_assertThisInitialized(_this), "isFirstDataUsed", !1);
  16010. E(_assertThisInitialized(_this), "userId", null);
  16011. E(_assertThisInitialized(_this), "pathManager", new PathManager());
  16012. E(_assertThisInitialized(_this), "networkController");
  16013. E(_assertThisInitialized(_this), "_startTime", Date.now());
  16014. E(_assertThisInitialized(_this), "canvas");
  16015. E(_assertThisInitialized(_this), "modelManager");
  16016. E(_assertThisInitialized(_this), "eventsController");
  16017. E(_assertThisInitialized(_this), "panorama");
  16018. E(_assertThisInitialized(_this), "engineProxy");
  16019. E(_assertThisInitialized(_this), "_id");
  16020. E(_assertThisInitialized(_this), "skinList", []);
  16021. E(_assertThisInitialized(_this), "isHost", !1);
  16022. E(_assertThisInitialized(_this), "avatarManager", new XverseAvatarManager(_assertThisInitialized(_this)));
  16023. E(_assertThisInitialized(_this), "effectManager", new XverseEffectManager(_assertThisInitialized(_this)));
  16024. E(_assertThisInitialized(_this), "sceneManager");
  16025. E(_assertThisInitialized(_this), "scene");
  16026. E(_assertThisInitialized(_this), "breathPointManager");
  16027. E(_assertThisInitialized(_this), "_currentState");
  16028. E(_assertThisInitialized(_this), "joined", !1);
  16029. E(_assertThisInitialized(_this), "disableRotate", !1);
  16030. E(_assertThisInitialized(_this), "isPano", !1);
  16031. E(_assertThisInitialized(_this), "movingByClick", !0);
  16032. E(_assertThisInitialized(_this), "camera", new Camera(_assertThisInitialized(_this)));
  16033. E(_assertThisInitialized(_this), "stats", new Stats(_assertThisInitialized(_this)));
  16034. E(_assertThisInitialized(_this), "isUpdatedRawYUVData", !1);
  16035. E(_assertThisInitialized(_this), "actionsHandler", new ActionsHandler(_assertThisInitialized(_this)));
  16036. E(_assertThisInitialized(_this), "_currentClickingState", null);
  16037. E(_assertThisInitialized(_this), "signal", new Signal(_assertThisInitialized(_this)));
  16038. E(_assertThisInitialized(_this), "firstFrameTimestamp");
  16039. E(_assertThisInitialized(_this), "receiveRtcData", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  16040. var e, t, r, n;
  16041. return regenerator.wrap(function _callee$(_context) {
  16042. while (1) {
  16043. switch (_context.prev = _context.next) {
  16044. case 0:
  16045. logger$1.info("Invoke receiveRtcData");
  16046. e = !1, t = !1, r = !1, n = !1;
  16047. return _context.abrupt("return", _this.viewMode === "serverless" ? (logger$1.warn("set view mode to serverless"), _this.setViewMode("observer").then(function () {
  16048. return _assertThisInitialized(_this);
  16049. }, function () {
  16050. return _assertThisInitialized(_this);
  16051. })) : new Promise(function (o) {
  16052. var a = _this.networkController.rtcp.workers;
  16053. a.registerFunction("signal", function (s) {
  16054. _this.signal.handleSignal(s);
  16055. }), a.registerFunction("stream", function (s) {
  16056. var l;
  16057. if (_this.emit("streamTimestamp", {
  16058. timestamp: Date.now()
  16059. }), t || (t = !0, logger$1.info("Invoke stream event")), s.stream) {
  16060. r || (r = !0, logger$1.info("Invoke updateRawYUVData")), _this.isUpdatedRawYUVData = !1;
  16061. var u = (l = _this._currentState.skin) == null ? void 0 : l.fov;
  16062. _this.sceneManager.materialComponent.updateRawYUVData(s.stream, s.width, s.height, u), _this.isUpdatedRawYUVData = !0;
  16063. }
  16064. e || (logger$1.info("Invoke isAfterRenderRegistered"), e = !0, _this.scene.registerAfterRender(function () {
  16065. _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()));
  16066. }));
  16067. }), _this.panorama.bindListener(function () {
  16068. o(_assertThisInitialized(_this)), _this.afterJoinRoom();
  16069. }), a.registerFunction("reconnectedFrame", function () {}), logger$1.info("Invoke decoderWorker.postMessage"), a.decoderWorker.postMessage({
  16070. t: 5
  16071. });
  16072. }));
  16073. case 3:
  16074. case "end":
  16075. return _context.stop();
  16076. }
  16077. }
  16078. }, _callee);
  16079. })));
  16080. E(_assertThisInitialized(_this), "moveToExtra", "");
  16081. _this.options = e, _this.options.wsServerUrl || (_this.options.wsServerUrl = SERVER_URLS.DEV), _this.modelManager = ModelManager.getInstance(e.appId, e.releaseId), _this.updateReporter();
  16082. var n = e;
  16083. n.canvas;
  16084. var r = Oe(n, ["canvas"]);
  16085. logger$1.infoAndReportMeasurement({
  16086. metric: "startJoinRoomAt",
  16087. startTime: Date.now(),
  16088. group: "joinRoom",
  16089. extra: r,
  16090. value: 0
  16091. });
  16092. return _this;
  16093. }
  16094. _createClass(Xverse_Room, [{
  16095. key: "currentNetworkOptions",
  16096. get: function get() {
  16097. return this._currentNetworkOptions;
  16098. }
  16099. }, {
  16100. key: "viewMode",
  16101. get: function get() {
  16102. var e;
  16103. return ((e = this._currentState) == null ? void 0 : e.viewMode) || "full";
  16104. }
  16105. }, {
  16106. key: "id",
  16107. get: function get() {
  16108. return this._id;
  16109. }
  16110. }, {
  16111. key: "skinId",
  16112. get: function get() {
  16113. return this._currentState.skinId;
  16114. }
  16115. }, {
  16116. key: "skin",
  16117. get: function get() {
  16118. return this._currentState.skin;
  16119. }
  16120. }, {
  16121. key: "sessionId",
  16122. get: function get() {
  16123. return this.currentNetworkOptions.sessionId;
  16124. }
  16125. }, {
  16126. key: "pictureQualityLevel",
  16127. get: function get() {
  16128. return this.currentState.pictureQualityLevel;
  16129. }
  16130. }, {
  16131. key: "avatars",
  16132. get: function get() {
  16133. return Array.from(this.avatarManager.avatars.values());
  16134. }
  16135. }, {
  16136. key: "currentState",
  16137. get: function get() {
  16138. var e;
  16139. return le(oe({}, this._currentState), {
  16140. state: (e = this.networkController) == null ? void 0 : e._state
  16141. });
  16142. }
  16143. }, {
  16144. key: "_userAvatar",
  16145. get: function get() {
  16146. var _this2 = this;
  16147. return this.avatars.find(function (e) {
  16148. return e.userId === _this2.userId;
  16149. });
  16150. }
  16151. }, {
  16152. key: "tvs",
  16153. get: function get() {
  16154. return this.engineProxy._tvs;
  16155. }
  16156. }, {
  16157. key: "tv",
  16158. get: function get() {
  16159. return this.tvs[0];
  16160. }
  16161. }, {
  16162. key: "currentClickingState",
  16163. get: function get() {
  16164. return this._currentClickingState;
  16165. }
  16166. }, {
  16167. key: "afterJoinRoomHook",
  16168. value: function afterJoinRoomHook() {}
  16169. }, {
  16170. key: "beforeJoinRoomResolveHook",
  16171. value: function beforeJoinRoomResolveHook() {}
  16172. }, {
  16173. key: "afterReconnectedHook",
  16174. value: function afterReconnectedHook() {}
  16175. }, {
  16176. key: "handleSignalHook",
  16177. value: function handleSignalHook(e) {}
  16178. }, {
  16179. key: "skinChangedHook",
  16180. value: function skinChangedHook() {}
  16181. }, {
  16182. key: "beforeStartGameHook",
  16183. value: function () {
  16184. var _beforeStartGameHook = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e) {
  16185. return regenerator.wrap(function _callee2$(_context2) {
  16186. while (1) {
  16187. switch (_context2.prev = _context2.next) {
  16188. case 0:
  16189. case "end":
  16190. return _context2.stop();
  16191. }
  16192. }
  16193. }, _callee2);
  16194. }));
  16195. function beforeStartGameHook(_x) {
  16196. return _beforeStartGameHook.apply(this, arguments);
  16197. }
  16198. return beforeStartGameHook;
  16199. }()
  16200. }, {
  16201. key: "loadAssetsHook",
  16202. value: function loadAssetsHook() {}
  16203. }, {
  16204. key: "afterUserAvatarLoadedHook",
  16205. value: function afterUserAvatarLoadedHook() {}
  16206. }, {
  16207. key: "audienceViewModeHook",
  16208. value: function audienceViewModeHook() {}
  16209. }, {
  16210. key: "setViewModeToObserver",
  16211. value: function setViewModeToObserver() {}
  16212. }, {
  16213. key: "handleVehicleHook",
  16214. value: function handleVehicleHook(e) {}
  16215. }, {
  16216. key: "updateReporter",
  16217. value: function updateReporter() {
  16218. var _this$options = this.options,
  16219. e = _this$options.avatarId,
  16220. t = _this$options.skinId,
  16221. r = _this$options.userId,
  16222. n = _this$options.roomId,
  16223. o = _this$options.role,
  16224. a = _this$options.appId,
  16225. s = _this$options.wsServerUrl;
  16226. reporter$1.updateHeader({
  16227. userId: r
  16228. }), reporter$1.updateBody({
  16229. roomId: n,
  16230. role: o,
  16231. skinId: t,
  16232. avatarId: e,
  16233. appId: a,
  16234. wsServerUrl: s
  16235. });
  16236. }
  16237. }, {
  16238. key: "initRoom",
  16239. value: function () {
  16240. var _initRoom2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
  16241. var _this$options$timeout, e;
  16242. return regenerator.wrap(function _callee3$(_context3) {
  16243. while (1) {
  16244. switch (_context3.prev = _context3.next) {
  16245. case 0:
  16246. _this$options$timeout = this.options.timeout, e = _this$options$timeout === void 0 ? DEFAULT_JOINROOM_TIMEOUT : _this$options$timeout;
  16247. if (!util.isSupported()) {
  16248. _context3.next = 5;
  16249. break;
  16250. }
  16251. return _context3.abrupt("return", this._initRoom()._timeout(e, new TimeoutError("initRoom timeout")));
  16252. case 5:
  16253. return _context3.abrupt("return", Promise.reject(new UnsupportedError()));
  16254. case 6:
  16255. case "end":
  16256. return _context3.stop();
  16257. }
  16258. }
  16259. }, _callee3, this);
  16260. }));
  16261. function initRoom() {
  16262. return _initRoom2.apply(this, arguments);
  16263. }
  16264. return initRoom;
  16265. }()
  16266. }, {
  16267. key: "_initRoom",
  16268. value: function () {
  16269. var _initRoom3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4() {
  16270. 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;
  16271. return regenerator.wrap(function _callee4$(_context4) {
  16272. while (1) {
  16273. switch (_context4.prev = _context4.next) {
  16274. case 0:
  16275. e = this.validateOptions(this.options);
  16276. if (!e) {
  16277. _context4.next = 3;
  16278. break;
  16279. }
  16280. return _context4.abrupt("return", (logger$1.error("initRoom param error", e), Promise.reject(e)));
  16281. case 3:
  16282. _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.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;
  16283. this.setCurrentNetworkOptions({
  16284. avatarId: r,
  16285. skinId: n,
  16286. roomId: R,
  16287. userId: o,
  16288. wsServerUrl: a,
  16289. role: s,
  16290. token: l,
  16291. pageSession: u,
  16292. rotationRenderType: c,
  16293. isAllSync: h,
  16294. appId: f,
  16295. camera: d,
  16296. player: _,
  16297. avatarComponents: g,
  16298. nickname: m,
  16299. avatarScale: v,
  16300. firends: y,
  16301. syncByEvent: b,
  16302. areaName: T,
  16303. attitude: C,
  16304. pathName: A,
  16305. person: P,
  16306. roomTypeId: M,
  16307. hasAvatar: x,
  16308. syncToOthers: I,
  16309. prioritySync: w,
  16310. extra: D,
  16311. removeWhenDisconnected: O
  16312. });
  16313. this.userId = o;
  16314. this.canvas = t;
  16315. T && (this.pathManager.currentArea = T);
  16316. this.networkController = new NetworkController(this);
  16317. this.setCurrentState({
  16318. areaName: T,
  16319. pathName: A,
  16320. attitude: C,
  16321. speed: 0,
  16322. viewMode: S,
  16323. state: this.networkController._state,
  16324. skinId: n
  16325. });
  16326. _context4.prev = 10;
  16327. _context4.next = 13;
  16328. return Promise.all([this.initNetwork(), this.initConfig(), this.initWasm()]);
  16329. case 13:
  16330. logger$1.info("network config wasm all ready, start to create game");
  16331. _context4.next = 16;
  16332. return this.requestCreateRoom({
  16333. skinId: n
  16334. });
  16335. case 16:
  16336. F = _context4.sent;
  16337. V = F.routeList.find(function (L) {
  16338. return L.areaName === T;
  16339. });
  16340. N = ((V == null ? void 0 : V.step) || 7.5) * 30;
  16341. this.updateCurrentState({
  16342. skin: F,
  16343. skinId: F.id,
  16344. versionId: F.versionId,
  16345. speed: N
  16346. });
  16347. _context4.next = 22;
  16348. return this.initEngine(F);
  16349. case 22:
  16350. _context4.next = 27;
  16351. break;
  16352. case 24:
  16353. _context4.prev = 24;
  16354. _context4.t0 = _context4["catch"](10);
  16355. return _context4.abrupt("return", Promise.reject(_context4.t0));
  16356. case 27:
  16357. this.beforeJoinRoomResolve();
  16358. return _context4.abrupt("return", this.receiveRtcData());
  16359. case 29:
  16360. case "end":
  16361. return _context4.stop();
  16362. }
  16363. }
  16364. }, _callee4, this, [[10, 24]]);
  16365. }));
  16366. function _initRoom() {
  16367. return _initRoom3.apply(this, arguments);
  16368. }
  16369. return _initRoom;
  16370. }()
  16371. }, {
  16372. key: "beforeJoinRoomResolve",
  16373. value: function beforeJoinRoomResolve() {
  16374. this.setupStats(), this.eventsController = new EventsController(this), this.eventsController.bindEvents(), this.panorama = new Panorama(this), this.beforeJoinRoomResolveHook();
  16375. }
  16376. }, {
  16377. key: "afterJoinRoom",
  16378. value: function afterJoinRoom() {
  16379. this.joined = !0, this.viewMode === "observer" && this.setViewModeToObserver(), logger$1.infoAndReportMeasurement({
  16380. tag: this.viewMode,
  16381. value: this.firstFrameTimestamp - this._startTime,
  16382. startTime: Date.now(),
  16383. metric: "joinRoom"
  16384. }), this.camera.initialFov = this.sceneManager.cameraComponent.getCameraFov(), this.stats.on("stats", function (_ref2) {
  16385. var e = _ref2.stats;
  16386. reporter$1.report("stats", oe({}, e));
  16387. }), this.debug = new Debug(this), this.afterJoinRoomHook();
  16388. }
  16389. }, {
  16390. key: "afterReconnected",
  16391. value: function afterReconnected() {
  16392. this.avatarManager.clearOtherUsers(), this.afterReconnectedHook();
  16393. }
  16394. }, {
  16395. key: "leave",
  16396. value: function leave() {
  16397. var e, t;
  16398. return logger$1.info("Invoke room.leave"), (e = this.eventsController) == null || e.clearEvents(), (t = this.networkController) == null || t.quit(), this;
  16399. }
  16400. }, {
  16401. key: "validateOptions",
  16402. value: function validateOptions(e) {
  16403. var _ref3 = e || {},
  16404. t = _ref3.canvas,
  16405. r = _ref3.avatarId,
  16406. n = _ref3.skinId,
  16407. o = _ref3.userId,
  16408. a = _ref3.role;
  16409. _ref3.roomId;
  16410. var l = _ref3.token,
  16411. u = _ref3.appId;
  16412. _ref3.avatarComponents;
  16413. var h = [];
  16414. t instanceof HTMLCanvasElement || h.push(new ParamError$1("`canvas` must be instanceof of HTMLCanvasElement"));
  16415. (!o || typeof o != "string") && h.push(new ParamError$1("`userId` must be string"));
  16416. (!l || typeof l != "string") && h.push(new ParamError$1("`token` must be string"));
  16417. (!u || typeof u != "string") && h.push(new ParamError$1("`appId` must be string"));
  16418. a == "audience" || (!r || !n) && h.push(new ParamError$1("`avatarId` and `skinId` is required when create room"));
  16419. return h[0];
  16420. }
  16421. }, {
  16422. key: "initNetwork",
  16423. value: function () {
  16424. var _initNetwork = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5() {
  16425. var e;
  16426. return regenerator.wrap(function _callee5$(_context5) {
  16427. while (1) {
  16428. switch (_context5.prev = _context5.next) {
  16429. case 0:
  16430. if (!(this.viewMode === "serverless")) {
  16431. _context5.next = 2;
  16432. break;
  16433. }
  16434. return _context5.abrupt("return", Promise.resolve());
  16435. case 2:
  16436. e = Date.now();
  16437. _context5.prev = 3;
  16438. _context5.next = 6;
  16439. return this.networkController.connect()._timeout(8e3, new InitNetworkTimeoutError());
  16440. case 6:
  16441. logger$1.infoAndReportMeasurement({
  16442. metric: "networkInitAt",
  16443. startTime: this._startTime,
  16444. group: "joinRoom"
  16445. });
  16446. logger$1.infoAndReportMeasurement({
  16447. metric: "networkInitCost",
  16448. startTime: e,
  16449. group: "joinRoom"
  16450. });
  16451. _context5.next = 13;
  16452. break;
  16453. case 10:
  16454. _context5.prev = 10;
  16455. _context5.t0 = _context5["catch"](3);
  16456. throw logger$1.infoAndReportMeasurement({
  16457. metric: "networkInitAt",
  16458. startTime: e,
  16459. group: "joinRoom",
  16460. error: _context5.t0
  16461. }), _context5.t0;
  16462. case 13:
  16463. case "end":
  16464. return _context5.stop();
  16465. }
  16466. }
  16467. }, _callee5, this, [[3, 10]]);
  16468. }));
  16469. function initNetwork() {
  16470. return _initNetwork.apply(this, arguments);
  16471. }
  16472. return initNetwork;
  16473. }()
  16474. }, {
  16475. key: "initConfig",
  16476. value: function () {
  16477. var _initConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6() {
  16478. var e;
  16479. return regenerator.wrap(function _callee6$(_context6) {
  16480. while (1) {
  16481. switch (_context6.prev = _context6.next) {
  16482. case 0:
  16483. e = Date.now();
  16484. _context6.prev = 1;
  16485. _context6.next = 4;
  16486. return this.modelManager.getApplicationConfig()._timeout(8e3, new InitConfigTimeoutError());
  16487. case 4:
  16488. logger$1.infoAndReportMeasurement({
  16489. metric: "configInitAt",
  16490. startTime: this._startTime,
  16491. group: "joinRoom"
  16492. });
  16493. logger$1.infoAndReportMeasurement({
  16494. metric: "configInitCost",
  16495. startTime: e,
  16496. group: "joinRoom"
  16497. });
  16498. _context6.next = 11;
  16499. break;
  16500. case 8:
  16501. _context6.prev = 8;
  16502. _context6.t0 = _context6["catch"](1);
  16503. throw logger$1.infoAndReportMeasurement({
  16504. metric: "configInitAt",
  16505. startTime: e,
  16506. group: "joinRoom",
  16507. error: _context6.t0
  16508. }), _context6.t0;
  16509. case 11:
  16510. case "end":
  16511. return _context6.stop();
  16512. }
  16513. }
  16514. }, _callee6, this, [[1, 8]]);
  16515. }));
  16516. function initConfig() {
  16517. return _initConfig.apply(this, arguments);
  16518. }
  16519. return initConfig;
  16520. }()
  16521. }, {
  16522. key: "initEngine",
  16523. value: function () {
  16524. var _initEngine = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7(e) {
  16525. var t, n;
  16526. return regenerator.wrap(function _callee7$(_context7) {
  16527. while (1) {
  16528. switch (_context7.prev = _context7.next) {
  16529. case 0:
  16530. t = Date.now();
  16531. _context7.prev = 1;
  16532. this.engineProxy = new EngineProxy(this);
  16533. _context7.next = 5;
  16534. return this.engineProxy.initEngine(e);
  16535. case 5:
  16536. logger$1.infoAndReportMeasurement({
  16537. metric: "webglInitAt",
  16538. startTime: this._startTime,
  16539. group: "joinRoom"
  16540. });
  16541. logger$1.infoAndReportMeasurement({
  16542. metric: "webglInitCost",
  16543. startTime: t,
  16544. group: "joinRoom"
  16545. });
  16546. return _context7.abrupt("return");
  16547. case 10:
  16548. _context7.prev = 10;
  16549. _context7.t0 = _context7["catch"](1);
  16550. n = _context7.t0;
  16551. return _context7.abrupt("return", (_context7.t0.code !== Codes.InitEngineTimeout && (n = new InitEngineError()), logger$1.error(_context7.t0), logger$1.infoAndReportMeasurement({
  16552. metric: "webglInitAt",
  16553. startTime: t,
  16554. group: "joinRoom",
  16555. error: n
  16556. }), Promise.reject(n)));
  16557. case 14:
  16558. case "end":
  16559. return _context7.stop();
  16560. }
  16561. }
  16562. }, _callee7, this, [[1, 10]]);
  16563. }));
  16564. function initEngine(_x2) {
  16565. return _initEngine.apply(this, arguments);
  16566. }
  16567. return initEngine;
  16568. }()
  16569. }, {
  16570. key: "initWasm",
  16571. value: function () {
  16572. var _initWasm = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8() {
  16573. var _this3 = this;
  16574. var e;
  16575. return regenerator.wrap(function _callee8$(_context8) {
  16576. while (1) {
  16577. switch (_context8.prev = _context8.next) {
  16578. case 0:
  16579. if (!(this.viewMode === "serverless")) {
  16580. _context8.next = 2;
  16581. break;
  16582. }
  16583. return _context8.abrupt("return", Promise.resolve());
  16584. case 2:
  16585. e = Date.now();
  16586. _context8.prev = 3;
  16587. _context8.next = 6;
  16588. return this.networkController.rtcp.workers.init(this.options.resolution)._timeout(8e3, new InitDecoderTimeoutError());
  16589. case 6:
  16590. this.networkController.rtcp.workers.registerFunction("error", function (t) {
  16591. logger$1.error("decode error", t);
  16592. var r = t.code,
  16593. n = t.message;
  16594. _this3.emit("error", {
  16595. code: r,
  16596. msg: n
  16597. });
  16598. });
  16599. logger$1.infoAndReportMeasurement({
  16600. metric: "wasmInitAt",
  16601. group: "joinRoom",
  16602. startTime: this._startTime
  16603. });
  16604. logger$1.infoAndReportMeasurement({
  16605. metric: "wasmInitCost",
  16606. group: "joinRoom",
  16607. startTime: e
  16608. });
  16609. eventsManager.on("traceId", function (t) {
  16610. _this3.networkController.rtcp.workers.onTraceId(t);
  16611. });
  16612. _context8.next = 15;
  16613. break;
  16614. case 12:
  16615. _context8.prev = 12;
  16616. _context8.t0 = _context8["catch"](3);
  16617. throw logger$1.infoAndReportMeasurement({
  16618. metric: "wasmInitAt",
  16619. group: "joinRoom",
  16620. startTime: e,
  16621. error: _context8.t0
  16622. }), _context8.t0;
  16623. case 15:
  16624. case "end":
  16625. return _context8.stop();
  16626. }
  16627. }
  16628. }, _callee8, this, [[3, 12]]);
  16629. }));
  16630. function initWasm() {
  16631. return _initWasm.apply(this, arguments);
  16632. }
  16633. return initWasm;
  16634. }()
  16635. }, {
  16636. key: "requestCreateRoom",
  16637. value: function () {
  16638. var _requestCreateRoom = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9(_ref4) {
  16639. var e, t, r, _ref5, n, o, _yield$this$networkCo, _r, _n, _o, a, s;
  16640. return regenerator.wrap(function _callee9$(_context9) {
  16641. while (1) {
  16642. switch (_context9.prev = _context9.next) {
  16643. case 0:
  16644. e = _ref4.skinId;
  16645. if (!e) {
  16646. _context9.next = 11;
  16647. break;
  16648. }
  16649. _context9.next = 4;
  16650. return this.getSkin(e);
  16651. case 4:
  16652. t = _context9.sent;
  16653. _context9.next = 7;
  16654. return this.modelManager.findRoute(e, this.options.pathName);
  16655. case 7:
  16656. r = _context9.sent;
  16657. this.updateCurrentNetworkOptions({
  16658. areaName: r.areaName,
  16659. attitude: r.attitude,
  16660. versionId: t.versionId
  16661. });
  16662. _ref5 = util.getRandomItem(r.birthPointList) || this.options, n = _ref5.camera, o = _ref5.player;
  16663. this.options.camera || this.updateCurrentNetworkOptions({
  16664. camera: n
  16665. }), this.options.player || this.updateCurrentNetworkOptions({
  16666. player: o
  16667. });
  16668. case 11:
  16669. if (!(this.viewMode === "serverless")) {
  16670. _context9.next = 13;
  16671. break;
  16672. }
  16673. return _context9.abrupt("return", t);
  16674. case 13:
  16675. _context9.prev = 13;
  16676. _context9.next = 16;
  16677. return this.beforeStartGameHook(this.options);
  16678. case 16:
  16679. _context9.next = 18;
  16680. return this.networkController.startGame();
  16681. case 18:
  16682. _yield$this$networkCo = _context9.sent;
  16683. _r = _yield$this$networkCo.room_id;
  16684. _n = _yield$this$networkCo.data;
  16685. _o = _yield$this$networkCo.session_id;
  16686. this._id = _r;
  16687. a = JSON.parse(_n);
  16688. this.isHost = a.IsHost, e = a.SkinID || e;
  16689. _context9.next = 27;
  16690. return this.getSkin(e);
  16691. case 27:
  16692. s = _context9.sent;
  16693. return _context9.abrupt("return", (this.updateCurrentNetworkOptions({
  16694. roomId: _r,
  16695. sessionId: _o
  16696. }), reporter$1.updateBody({
  16697. roomId: _r,
  16698. skinId: e,
  16699. serverSession: _o
  16700. }), s));
  16701. case 31:
  16702. _context9.prev = 31;
  16703. _context9.t0 = _context9["catch"](13);
  16704. throw logger$1.error("Request create room error", _context9.t0), _context9.t0;
  16705. case 34:
  16706. case "end":
  16707. return _context9.stop();
  16708. }
  16709. }
  16710. }, _callee9, this, [[13, 31]]);
  16711. }));
  16712. function requestCreateRoom(_x3) {
  16713. return _requestCreateRoom.apply(this, arguments);
  16714. }
  16715. return requestCreateRoom;
  16716. }()
  16717. }, {
  16718. key: "pause",
  16719. value: function pause() {
  16720. return this.engineProxy.pause();
  16721. }
  16722. }, {
  16723. key: "resume",
  16724. value: function resume() {
  16725. return this.engineProxy.resume();
  16726. }
  16727. }, {
  16728. key: "reconnect",
  16729. value: function reconnect() {
  16730. this.networkController.reconnect();
  16731. }
  16732. }, {
  16733. key: "setViewMode",
  16734. value: function () {
  16735. var _setViewMode = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10(e) {
  16736. return regenerator.wrap(function _callee10$(_context10) {
  16737. while (1) {
  16738. switch (_context10.prev = _context10.next) {
  16739. case 0:
  16740. case "end":
  16741. return _context10.stop();
  16742. }
  16743. }
  16744. }, _callee10);
  16745. }));
  16746. function setViewMode(_x4) {
  16747. return _setViewMode.apply(this, arguments);
  16748. }
  16749. return setViewMode;
  16750. }()
  16751. }, {
  16752. key: "handleRepetLogin",
  16753. value: function handleRepetLogin() {
  16754. logger$1.warn("receive " + Codes.RepeatLogin + " for repeat login"), this.emit("repeatLogin"), reporter$1.disable(), this.networkController.quit();
  16755. }
  16756. }, {
  16757. key: "setPictureQualityLevel",
  16758. value: function setPictureQualityLevel(e) {
  16759. var t = {
  16760. high: EImageQuality.high,
  16761. low: EImageQuality.low,
  16762. average: EImageQuality.mid
  16763. };
  16764. return this.updateCurrentState({
  16765. pictureQualityLevel: e
  16766. }), this.sceneManager.setImageQuality(t[e]);
  16767. }
  16768. }, {
  16769. key: "getSkin",
  16770. value: function () {
  16771. var _getSkin = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee11(e) {
  16772. var t, n;
  16773. return regenerator.wrap(function _callee11$(_context11) {
  16774. while (1) {
  16775. switch (_context11.prev = _context11.next) {
  16776. case 0:
  16777. t = null;
  16778. _context11.next = 3;
  16779. return this.modelManager.getSkinsList();
  16780. case 3:
  16781. t = (this.skinList = _context11.sent).find(function (n) {
  16782. return n.id === e || n.id === e;
  16783. });
  16784. if (!t) {
  16785. _context11.next = 6;
  16786. break;
  16787. }
  16788. return _context11.abrupt("return", t);
  16789. case 6:
  16790. n = "skin is invalid: skinId: ".concat(e);
  16791. return _context11.abrupt("return", Promise.reject(new ParamError$1(n)));
  16792. case 8:
  16793. case "end":
  16794. return _context11.stop();
  16795. }
  16796. }
  16797. }, _callee11, this);
  16798. }));
  16799. function getSkin(_x5) {
  16800. return _getSkin.apply(this, arguments);
  16801. }
  16802. return getSkin;
  16803. }()
  16804. }, {
  16805. key: "setupStats",
  16806. value: function setupStats() {
  16807. this.stats.assign({
  16808. roomId: this.id,
  16809. userId: this.userId
  16810. }), setInterval(this.engineProxy.updateStats, 1e3);
  16811. }
  16812. }, {
  16813. key: "proxyEvents",
  16814. value: function proxyEvents(e, t) {
  16815. this.emit(e, t);
  16816. }
  16817. }, {
  16818. key: "setCurrentNetworkOptions",
  16819. value: function setCurrentNetworkOptions(e) {
  16820. this._currentNetworkOptions = e;
  16821. }
  16822. }, {
  16823. key: "updateCurrentNetworkOptions",
  16824. value: function updateCurrentNetworkOptions(e) {
  16825. Object.assign(this._currentNetworkOptions, e), Object.assign(this.options, e);
  16826. }
  16827. }, {
  16828. key: "setCurrentState",
  16829. value: function setCurrentState(e) {
  16830. this._currentState = e;
  16831. }
  16832. }, {
  16833. key: "updateCurrentState",
  16834. value: function updateCurrentState(e) {
  16835. e.skinId && (this.lastSkinId = this.currentState.skinId, this.updateCurrentNetworkOptions({
  16836. skinId: e.skinId
  16837. })), e.versionId && this.updateCurrentNetworkOptions({
  16838. versionId: e.versionId
  16839. }), Object.assign(this._currentState, e);
  16840. }
  16841. }]);
  16842. return Xverse_Room;
  16843. }(EventEmitter);
  16844. 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); }; }
  16845. 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; } }
  16846. var XverseRoom = /*#__PURE__*/function (_Xverse_Room) {
  16847. _inherits(XverseRoom, _Xverse_Room);
  16848. var _super = _createSuper(XverseRoom);
  16849. function XverseRoom(e) {
  16850. var _this;
  16851. _classCallCheck(this, XverseRoom);
  16852. _this = _super.call(this, e);
  16853. _this.joyStick = new JoyStick(_assertThisInitialized(_this));
  16854. return _this;
  16855. }
  16856. _createClass(XverseRoom, [{
  16857. key: "afterJoinRoomHook",
  16858. value: function afterJoinRoomHook() {
  16859. this.joyStick.init({});
  16860. }
  16861. }]);
  16862. return XverseRoom;
  16863. }(Xverse_Room);
  16864. var Preload = /*#__PURE__*/function () {
  16865. function Preload(e) {
  16866. _classCallCheck(this, Preload);
  16867. this.config = null;
  16868. this.allKeys = [];
  16869. this.oldResourcesDeleted = !1;
  16870. this.requests = {
  16871. simple: {
  16872. stopped: !0,
  16873. requests: {}
  16874. },
  16875. observer: {
  16876. stopped: !0,
  16877. requests: {}
  16878. },
  16879. full: {
  16880. stopped: !0,
  16881. requests: {}
  16882. }
  16883. };
  16884. this.modelManager = e, this.init(e.appId);
  16885. }
  16886. _createClass(Preload, [{
  16887. key: "init",
  16888. value: function init(e) {
  16889. reporter$1.updateBody({
  16890. appId: e
  16891. });
  16892. }
  16893. }, {
  16894. key: "getConfig",
  16895. value: function () {
  16896. var _getConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  16897. var _yield$this$modelMana, t;
  16898. return regenerator.wrap(function _callee$(_context) {
  16899. while (1) {
  16900. switch (_context.prev = _context.next) {
  16901. case 0:
  16902. if (!this.config) {
  16903. _context.next = 2;
  16904. break;
  16905. }
  16906. return _context.abrupt("return", this.config);
  16907. case 2:
  16908. _context.next = 4;
  16909. return this.modelManager.requestConfig();
  16910. case 4:
  16911. _yield$this$modelMana = _context.sent;
  16912. t = _yield$this$modelMana.preload;
  16913. return _context.abrupt("return", t ? (this.config = t, Promise.resolve(t)) : Promise.reject("no preload config"));
  16914. case 7:
  16915. case "end":
  16916. return _context.stop();
  16917. }
  16918. }
  16919. }, _callee, this);
  16920. }));
  16921. function getConfig(_x) {
  16922. return _getConfig.apply(this, arguments);
  16923. }
  16924. return getConfig;
  16925. }()
  16926. }, {
  16927. key: "getAllKeys",
  16928. value: function () {
  16929. var _getAllKeys = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  16930. var e, t;
  16931. return regenerator.wrap(function _callee2$(_context2) {
  16932. while (1) {
  16933. switch (_context2.prev = _context2.next) {
  16934. case 0:
  16935. if (!this.allKeys.length) {
  16936. _context2.next = 2;
  16937. break;
  16938. }
  16939. return _context2.abrupt("return", this.allKeys);
  16940. case 2:
  16941. _context2.prev = 2;
  16942. _context2.next = 5;
  16943. return modelTable.getAllKeys();
  16944. case 5:
  16945. e = _context2.sent;
  16946. this.allKeys = e;
  16947. return _context2.abrupt("return", e);
  16948. case 10:
  16949. _context2.prev = 10;
  16950. _context2.t0 = _context2["catch"](2);
  16951. t = "preload getAllKeys error";
  16952. return _context2.abrupt("return", (logger$1.error(t), Promise.reject(t)));
  16953. case 14:
  16954. case "end":
  16955. return _context2.stop();
  16956. }
  16957. }
  16958. }, _callee2, this, [[2, 10]]);
  16959. }));
  16960. function getAllKeys() {
  16961. return _getAllKeys.apply(this, arguments);
  16962. }
  16963. return getAllKeys;
  16964. }()
  16965. }, {
  16966. key: "stop",
  16967. value: function stop(e) {
  16968. e === "serverless" && (e = "observer"), this.requests[e].stopped = !0;
  16969. var t = this.requests[e].requests;
  16970. Object.keys(t).forEach(function (r) {
  16971. http1.canceler.removePending(r), delete t[r];
  16972. });
  16973. }
  16974. }, {
  16975. key: "clearPreload",
  16976. value: function clearPreload(e) {
  16977. this.requests[e].stopped = !1, this.allKeys = [];
  16978. }
  16979. }, {
  16980. key: "start",
  16981. value: function () {
  16982. var _start = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e, t, r) {
  16983. var n, o, a, s, l, u, h, f, _s;
  16984. return regenerator.wrap(function _callee3$(_context3) {
  16985. while (1) {
  16986. switch (_context3.prev = _context3.next) {
  16987. case 0:
  16988. n = Date.now(), o = 0;
  16989. _context3.prev = 1;
  16990. if (!(e === "serverless" && (e = "observer"), !this.requests[e])) {
  16991. _context3.next = 4;
  16992. break;
  16993. }
  16994. return _context3.abrupt("return", Promise.reject(new ParamError("invalid stage name: " + e)));
  16995. case 4:
  16996. this.clearPreload(e);
  16997. _context3.next = 7;
  16998. return this.getConfig(e);
  16999. case 7:
  17000. a = _context3.sent;
  17001. _context3.next = 10;
  17002. return this.getAllKeys();
  17003. case 10:
  17004. s = _context3.sent;
  17005. _context3.prev = 11;
  17006. _context3.next = 14;
  17007. return this.deleteOldResources(a.assetUrls.map(function (d) {
  17008. return d.url;
  17009. }), s);
  17010. case 14:
  17011. _context3.next = 19;
  17012. break;
  17013. case 16:
  17014. _context3.prev = 16;
  17015. _context3.t0 = _context3["catch"](11);
  17016. logger$1.error(_context3.t0);
  17017. case 19:
  17018. l = a.baseUrls, u = a.assetUrls;
  17019. _context3.t1 = e;
  17020. _context3.next = _context3.t1 === "simple" ? 23 : _context3.t1 === "observer" ? 25 : _context3.t1 === "full" ? 27 : 29;
  17021. break;
  17022. case 23:
  17023. h = l;
  17024. return _context3.abrupt("break", 30);
  17025. case 25:
  17026. h = u;
  17027. return _context3.abrupt("break", 30);
  17028. case 27:
  17029. h = u;
  17030. return _context3.abrupt("break", 30);
  17031. case 29:
  17032. h = u;
  17033. case 30:
  17034. f = h.filter(function (d) {
  17035. return !s.includes(d.url);
  17036. });
  17037. r && isFunction(r) && (f = f.filter(r));
  17038. o = f.length;
  17039. logger$1.debug("keysNeedToPreload", f);
  17040. f.length || t && t(h.length, h.length);
  17041. n = Date.now();
  17042. _context3.next = 38;
  17043. return this._preload(e, f, t);
  17044. case 38:
  17045. logger$1.infoAndReportMeasurement({
  17046. tag: e,
  17047. startTime: n,
  17048. metric: "assetsPreload",
  17049. extra: {
  17050. total: o
  17051. }
  17052. });
  17053. return _context3.abrupt("return");
  17054. case 42:
  17055. _context3.prev = 42;
  17056. _context3.t2 = _context3["catch"](1);
  17057. _s = _context3.t2;
  17058. return _context3.abrupt("return", ((this.requests[e].stopped || axios.isCancel(_context3.t2)) && (_s = new PreloadCanceledError()), logger$1.infoAndReportMeasurement({
  17059. tag: e,
  17060. startTime: n,
  17061. metric: "assetsPreload",
  17062. extra: {
  17063. total: o
  17064. },
  17065. error: _s,
  17066. reportOptions: {
  17067. immediate: !0
  17068. }
  17069. }), Promise.reject(_s)));
  17070. case 46:
  17071. case "end":
  17072. return _context3.stop();
  17073. }
  17074. }
  17075. }, _callee3, this, [[1, 42], [11, 16]]);
  17076. }));
  17077. function start(_x2, _x3, _x4) {
  17078. return _start.apply(this, arguments);
  17079. }
  17080. return start;
  17081. }()
  17082. }, {
  17083. key: "deleteOldResources",
  17084. value: function deleteOldResources(e, t) {
  17085. if (!this.oldResourcesDeleted) this.oldResourcesDeleted = !0;else return Promise.resolve();
  17086. var r = t.filter(function (n) {
  17087. return !e.includes(n);
  17088. });
  17089. return logger$1.debug("keysNeedToDelete", r), logger$1.warn("keysNeedToDelete", r.length), Promise.all(r.map(function (n) {
  17090. return modelTable.delete(n);
  17091. }));
  17092. }
  17093. }, {
  17094. key: "_preload",
  17095. value: function () {
  17096. var _preload2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e, t, r) {
  17097. var _this = this;
  17098. var n, o, a;
  17099. return regenerator.wrap(function _callee6$(_context6) {
  17100. while (1) {
  17101. switch (_context6.prev = _context6.next) {
  17102. case 0:
  17103. n = t.length;
  17104. if (n) {
  17105. _context6.next = 3;
  17106. break;
  17107. }
  17108. return _context6.abrupt("return", Promise.resolve());
  17109. case 3:
  17110. o = 0;
  17111. a = window.setInterval(function () {
  17112. r && r(o, n), o >= n && window.clearInterval(a);
  17113. }, 1e3);
  17114. return _context6.abrupt("return", util.mapLimit(t, 10, /*#__PURE__*/function () {
  17115. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(s) {
  17116. var l, u;
  17117. return regenerator.wrap(function _callee5$(_context5) {
  17118. while (1) {
  17119. switch (_context5.prev = _context5.next) {
  17120. case 0:
  17121. l = s.size, u = s.url;
  17122. return _context5.abrupt("return", _this.requests[e].stopped ? Promise.reject(new PreloadCanceledError()) : http1.get({
  17123. url: u,
  17124. timeout: Preload.getTimeoutBySize(l),
  17125. responseType: "blob",
  17126. retry: 2,
  17127. beforeRequest: function beforeRequest() {
  17128. _this.requests[e].requests[u] = !0;
  17129. }
  17130. }).then( /*#__PURE__*/function () {
  17131. var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(c) {
  17132. var h, f;
  17133. return regenerator.wrap(function _callee4$(_context4) {
  17134. while (1) {
  17135. switch (_context4.prev = _context4.next) {
  17136. case 0:
  17137. h = c.data;
  17138. if (h instanceof Blob) {
  17139. _context4.next = 3;
  17140. break;
  17141. }
  17142. return _context4.abrupt("return", (logger$1.error("request blob failed, type:", typeof h, u), Promise.reject("request blob failed " + u)));
  17143. case 3:
  17144. _context4.next = 5;
  17145. return blobToDataURI(h);
  17146. case 5:
  17147. f = _context4.sent;
  17148. _context4.prev = 6;
  17149. _context4.next = 9;
  17150. return modelTable.put({
  17151. url: u,
  17152. model: f
  17153. });
  17154. case 9:
  17155. return _context4.abrupt("return");
  17156. case 12:
  17157. _context4.prev = 12;
  17158. _context4.t0 = _context4["catch"](6);
  17159. return _context4.abrupt("return", (logger$1.error("unable to add data to indexedDB", _context4.t0), Promise.reject(new InternalError("preload db error"))));
  17160. case 15:
  17161. case "end":
  17162. return _context4.stop();
  17163. }
  17164. }
  17165. }, _callee4, null, [[6, 12]]);
  17166. }));
  17167. return function (_x9) {
  17168. return _ref2.apply(this, arguments);
  17169. };
  17170. }()).then(function () {
  17171. o++, delete _this.requests[e].requests[u];
  17172. }, function (c) {
  17173. return delete _this.requests[e].requests[u], window.clearInterval(a), Promise.reject(c);
  17174. }));
  17175. case 2:
  17176. case "end":
  17177. return _context5.stop();
  17178. }
  17179. }
  17180. }, _callee5);
  17181. }));
  17182. return function (_x8) {
  17183. return _ref.apply(this, arguments);
  17184. };
  17185. }()));
  17186. case 6:
  17187. case "end":
  17188. return _context6.stop();
  17189. }
  17190. }
  17191. }, _callee6);
  17192. }));
  17193. function _preload(_x5, _x6, _x7) {
  17194. return _preload2.apply(this, arguments);
  17195. }
  17196. return _preload;
  17197. }()
  17198. }], [{
  17199. key: "getTimeoutBySize",
  17200. value: function getTimeoutBySize(e) {
  17201. return e ? e < 500 * 1e3 ? 30 * 1e3 : e < 1e3 * 1e3 ? 60 * 1e3 : 100 * 1e3 : 100 * 1e3;
  17202. }
  17203. }]);
  17204. return Preload;
  17205. }();
  17206. var RenderType$1 = {
  17207. PathVideo: 0,
  17208. RotationVideo: 1,
  17209. RotationImage: 2,
  17210. PanoramaImage: 3,
  17211. CGVideo: 4,
  17212. ClientRotationPano: 5,
  17213. CloudRotationPano: 6
  17214. };
  17215. var Xverse = /*#__PURE__*/function () {
  17216. function Xverse(e) {
  17217. _classCallCheck(this, Xverse);
  17218. e || (e = {});
  17219. var _e = e,
  17220. t = _e.onLog,
  17221. r = _e.env,
  17222. n = _e.appId,
  17223. o = _e.releaseId,
  17224. a = _e.subPackageVersion;
  17225. this.NO_CACHE = !1, this.env = r || "PROD", this.SUB_PACKAGE_VERSION = a, this.debug && logger$1.setLevel(LoggerLevels.Debug);
  17226. var s = this.pageSession = util.uuid();
  17227. reporter$1.updateHeader({
  17228. pageSession: s
  17229. });
  17230. reporter$1.updateReportUrl(REPORT_URL[this.env]);
  17231. a && reporter$1.updateBody({
  17232. sdkVersion: a
  17233. });
  17234. logger$1.infoAndReportMeasurement({
  17235. metric: "sdkInit",
  17236. startTime: Date.now(),
  17237. extra: {
  17238. version: a,
  17239. enviroment: r,
  17240. pageSession: s
  17241. }
  17242. });
  17243. logger$1.debug("debug mode:", this.debug);
  17244. reporter$1.on("report", function (l) {
  17245. t && t(l);
  17246. });
  17247. if (n) {
  17248. this.appId = n, this.releaseId = o;
  17249. var l = ModelManager.getInstance(n, o);
  17250. this.preload = new Preload(l);
  17251. }
  17252. }
  17253. _createClass(Xverse, [{
  17254. key: "isSupported",
  17255. get: function get() {
  17256. return isSupported();
  17257. }
  17258. }, {
  17259. key: "disableLogUpload",
  17260. value: function disableLogUpload() {
  17261. reporter$1.disable(), logger$1.debug("logger upload has been disabled");
  17262. }
  17263. }, {
  17264. key: "getSkinList",
  17265. value: function () {
  17266. var _getSkinList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  17267. return regenerator.wrap(function _callee$(_context) {
  17268. while (1) {
  17269. switch (_context.prev = _context.next) {
  17270. case 0:
  17271. return _context.abrupt("return", []);
  17272. case 1:
  17273. case "end":
  17274. return _context.stop();
  17275. }
  17276. }
  17277. }, _callee);
  17278. }));
  17279. function getSkinList() {
  17280. return _getSkinList.apply(this, arguments);
  17281. }
  17282. return getSkinList;
  17283. }()
  17284. }, {
  17285. key: "getAvatarList",
  17286. value: function () {
  17287. var _getAvatarList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  17288. return regenerator.wrap(function _callee2$(_context2) {
  17289. while (1) {
  17290. switch (_context2.prev = _context2.next) {
  17291. case 0:
  17292. return _context2.abrupt("return", []);
  17293. case 1:
  17294. case "end":
  17295. return _context2.stop();
  17296. }
  17297. }
  17298. }, _callee2);
  17299. }));
  17300. function getAvatarList() {
  17301. return _getAvatarList.apply(this, arguments);
  17302. }
  17303. return getAvatarList;
  17304. }()
  17305. }, {
  17306. key: "getGiftList",
  17307. value: function () {
  17308. var _getGiftList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
  17309. return regenerator.wrap(function _callee3$(_context3) {
  17310. while (1) {
  17311. switch (_context3.prev = _context3.next) {
  17312. case 0:
  17313. return _context3.abrupt("return", [{
  17314. id: "hack "
  17315. }]);
  17316. case 1:
  17317. case "end":
  17318. return _context3.stop();
  17319. }
  17320. }
  17321. }, _callee3);
  17322. }));
  17323. function getGiftList() {
  17324. return _getGiftList.apply(this, arguments);
  17325. }
  17326. return getGiftList;
  17327. }()
  17328. }, {
  17329. key: "joinRoom",
  17330. value: function () {
  17331. var _joinRoom = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  17332. var t, r, n, o;
  17333. return regenerator.wrap(function _callee4$(_context4) {
  17334. while (1) {
  17335. switch (_context4.prev = _context4.next) {
  17336. case 0:
  17337. t = e.pathName || "thirdwalk", r = e.rotationRenderType || RenderType$1.RotationVideo, n = e.person || Person.Third, o = new XverseRoom(le(oe({}, e), {
  17338. appId: e.appId || this.appId,
  17339. releaseId: e.releaseId || this.releaseId,
  17340. pageSession: this.pageSession,
  17341. isAllSync: !0,
  17342. rotationRenderType: r,
  17343. syncByEvent: !0,
  17344. pathName: t,
  17345. person: n,
  17346. role: e.role || "audience"
  17347. }));
  17348. return _context4.abrupt("return", o.initRoom().then(function () {
  17349. return o;
  17350. }));
  17351. case 2:
  17352. case "end":
  17353. return _context4.stop();
  17354. }
  17355. }
  17356. }, _callee4, this);
  17357. }));
  17358. function joinRoom(_x) {
  17359. return _joinRoom.apply(this, arguments);
  17360. }
  17361. return joinRoom;
  17362. }()
  17363. }]);
  17364. return Xverse;
  17365. }();
  17366. var xverse = new Xverse({
  17367. env: "DEV",
  17368. appId: "10016",
  17369. releaseId: '2203120033_29769e'
  17370. });
  17371. var l = /*#__PURE__*/function () {
  17372. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  17373. var R, room;
  17374. return regenerator.wrap(function _callee$(_context) {
  17375. while (1) {
  17376. switch (_context.prev = _context.next) {
  17377. case 0:
  17378. _context.prev = 0;
  17379. _context.next = 3;
  17380. return (R = xverse.preload) == null ? void 0 : R.start('full', function (M, x) {
  17381. });
  17382. case 3:
  17383. _context.next = 12;
  17384. break;
  17385. case 5:
  17386. _context.prev = 5;
  17387. _context.t0 = _context["catch"](0);
  17388. if (!(console.error(_context.t0), _context.t0.code === Codes.PreloadCanceled)) {
  17389. _context.next = 10;
  17390. break;
  17391. }
  17392. toast("\u9884\u52A0\u8F7D\u88AB\u53D6\u6D88");
  17393. return _context.abrupt("return");
  17394. case 10:
  17395. toast("\u8FDB\u5165\u5931\u8D25, \u8BF7\u91CD\u8BD5");
  17396. return _context.abrupt("return");
  17397. case 12:
  17398. _context.prev = 12;
  17399. _context.next = 15;
  17400. return xverse.joinRoom({
  17401. canvas: document.getElementById('canvas'),
  17402. skinId: '10092',
  17403. avatarId: 'KGe_Boy',
  17404. roomId: 'e629ef3e-022d-4e64-8654-703bb96410eb',
  17405. userId: '1f7acca1db9d5',
  17406. wsServerUrl: 'wss://uat-eks.xverse.cn/ws',
  17407. appId: "10016",
  17408. token: " ",
  17409. nickname: '1f7acca1db9d5',
  17410. firends: ["user1"],
  17411. viewMode: "full",
  17412. resolution: {
  17413. width: 1728,
  17414. height: 720
  17415. },
  17416. pathName: 'thirdwalk',
  17417. objectFit: null,
  17418. hasAvatar: !0,
  17419. syncToOthers: !0
  17420. });
  17421. case 15:
  17422. room = _context.sent;
  17423. window.room = room;
  17424. u();
  17425. c(); //e(!1);
  17426. _context.next = 26;
  17427. break;
  17428. case 21:
  17429. _context.prev = 21;
  17430. _context.t1 = _context["catch"](12);
  17431. console.error(_context.t1);
  17432. alert(_context.t1);
  17433. return _context.abrupt("return");
  17434. case 26:
  17435. case "end":
  17436. return _context.stop();
  17437. }
  17438. }
  17439. }, _callee, null, [[0, 5], [12, 21]]);
  17440. }));
  17441. return function l() {
  17442. return _ref.apply(this, arguments);
  17443. };
  17444. }();
  17445. var u = function u() {
  17446. window.room.on("_coreClick", function (_ref2) {
  17447. var f = _ref2.point;
  17448. window.room._userAvatar.moveTo({
  17449. point: f
  17450. });
  17451. });
  17452. };
  17453. var c = function c() {
  17454. window.room.on("repeatLogin", function () {
  17455. toast("\u8BE5\u7528\u6237\u5DF2\u7ECF\u5728\u5176\u4ED6\u5730\u70B9\u767B\u5F55", {
  17456. duration: 1e4
  17457. });
  17458. }), window.room.on("reconnecting", function (_ref3) {
  17459. var f = _ref3.count;
  17460. toast("\u5C1D\u8BD5\u7B2C".concat(f, "\u6B21\u91CD\u8FDE"));
  17461. }), window.room.on("reconnected", function () {
  17462. toast("\u91CD\u8FDE\u6210\u529F");
  17463. }), window.room.on("disconnected", function () {
  17464. var f = toast("\u8FDE\u63A5\u5931\u8D25\uFF0C\u624B\u52A8\u70B9\u51FB\u91CD\u8BD5", {
  17465. duration: 1e5,
  17466. onClick() {
  17467. f.hideToast(), window.room.reconnect();
  17468. }
  17469. });
  17470. });
  17471. };
  17472. l();
  17473. }));
  17474. //# sourceMappingURL=index.js.map