index.js 759 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655
  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$R() {
  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$R()) {
  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$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); }; }
  855. 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; } }
  856. var XverseError = /*#__PURE__*/function (_Error) {
  857. _inherits(XverseError, _Error);
  858. var _super = _createSuper$Q(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$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); }; }
  889. 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; } }
  890. var ParamError$1 = /*#__PURE__*/function (_XverseError) {
  891. _inherits(ParamError, _XverseError);
  892. var _super = _createSuper$P(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$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); }; }
  900. 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; } }
  901. var InternalError = /*#__PURE__*/function (_XverseError) {
  902. _inherits(InternalError, _XverseError);
  903. var _super = _createSuper$O(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$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); }; }
  911. 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; } }
  912. var TimeoutError = /*#__PURE__*/function (_XverseError) {
  913. _inherits(TimeoutError, _XverseError);
  914. var _super = _createSuper$N(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$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); }; }
  922. 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; } }
  923. var AuthenticationError$1 = /*#__PURE__*/function (_XverseError) {
  924. _inherits(AuthenticationError, _XverseError);
  925. var _super = _createSuper$M(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$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); }; }
  933. 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; } }
  934. var TokenExpiredError$1 = /*#__PURE__*/function (_XverseError) {
  935. _inherits(TokenExpiredError, _XverseError);
  936. var _super = _createSuper$L(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$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); }; }
  944. 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; } }
  945. var UnsupportedError$1 = /*#__PURE__*/function (_XverseError) {
  946. _inherits(UnsupportedError, _XverseError);
  947. var _super = _createSuper$K(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$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); }; }
  955. 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; } }
  956. var InitNetworkTimeoutError = /*#__PURE__*/function (_XverseError) {
  957. _inherits(InitNetworkTimeoutError, _XverseError);
  958. var _super = _createSuper$J(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$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); }; }
  966. 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; } }
  967. var InitDecoderTimeoutError = /*#__PURE__*/function (_XverseError) {
  968. _inherits(InitDecoderTimeoutError, _XverseError);
  969. var _super = _createSuper$I(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$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); }; }
  977. 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; } }
  978. var InitConfigTimeoutError = /*#__PURE__*/function (_XverseError) {
  979. _inherits(InitConfigTimeoutError, _XverseError);
  980. var _super = _createSuper$H(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$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); }; }
  988. 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; } }
  989. var InitEngineTimeoutError = /*#__PURE__*/function (_XverseError) {
  990. _inherits(InitEngineTimeoutError, _XverseError);
  991. var _super = _createSuper$G(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$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); }; }
  999. 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; } }
  1000. var InitEngineError = /*#__PURE__*/function (_XverseError) {
  1001. _inherits(InitEngineError, _XverseError);
  1002. var _super = _createSuper$F(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$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); }; }
  1010. 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; } }
  1011. var ActionBlockedError = /*#__PURE__*/function (_XverseError) {
  1012. _inherits(ActionBlockedError, _XverseError);
  1013. var _super = _createSuper$E(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$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); }; }
  1021. 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; } }
  1022. var PreloadCanceledError$1 = /*#__PURE__*/function (_XverseError) {
  1023. _inherits(PreloadCanceledError, _XverseError);
  1024. var _super = _createSuper$D(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$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); }; }
  1032. 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; } }
  1033. var FrequencyLimitError$1 = /*#__PURE__*/function (_XverseError) {
  1034. _inherits(FrequencyLimitError, _XverseError);
  1035. var _super = _createSuper$C(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$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); }; }
  1043. 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; } }
  1044. var UsersUpperLimitError = /*#__PURE__*/function (_XverseError) {
  1045. _inherits(UsersUpperLimitError, _XverseError);
  1046. var _super = _createSuper$B(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$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); }; }
  1054. 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; } }
  1055. var RoomsUpperLimitError = /*#__PURE__*/function (_XverseError) {
  1056. _inherits(RoomsUpperLimitError, _XverseError);
  1057. var _super = _createSuper$A(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$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); }; }
  1065. 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; } }
  1066. var ServerParamError = /*#__PURE__*/function (_XverseError) {
  1067. _inherits(ServerParamError, _XverseError);
  1068. var _super = _createSuper$z(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$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); }; }
  1076. 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; } }
  1077. var LackOfTokenError = /*#__PURE__*/function (_XverseError) {
  1078. _inherits(LackOfTokenError, _XverseError);
  1079. var _super = _createSuper$y(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$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); }; }
  1087. 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; } }
  1088. var LoginFailedError = /*#__PURE__*/function (_XverseError) {
  1089. _inherits(LoginFailedError, _XverseError);
  1090. var _super = _createSuper$x(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$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); }; }
  1098. 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; } }
  1099. var VerifyServiceDownError = /*#__PURE__*/function (_XverseError) {
  1100. _inherits(VerifyServiceDownError, _XverseError);
  1101. var _super = _createSuper$w(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$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); }; }
  1109. 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; } }
  1110. var CreateSessionFailedError = /*#__PURE__*/function (_XverseError) {
  1111. _inherits(CreateSessionFailedError, _XverseError);
  1112. var _super = _createSuper$v(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$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); }; }
  1120. 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; } }
  1121. var RtcConnectionError = /*#__PURE__*/function (_XverseError) {
  1122. _inherits(RtcConnectionError, _XverseError);
  1123. var _super = _createSuper$u(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$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); }; }
  1131. 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; } }
  1132. var DoActionFailedError = /*#__PURE__*/function (_XverseError) {
  1133. _inherits(DoActionFailedError, _XverseError);
  1134. var _super = _createSuper$t(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$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); }; }
  1142. 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; } }
  1143. var StateSyncFailedError = /*#__PURE__*/function (_XverseError) {
  1144. _inherits(StateSyncFailedError, _XverseError);
  1145. var _super = _createSuper$s(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$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); }; }
  1153. 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; } }
  1154. var BroadcastFailedError = /*#__PURE__*/function (_XverseError) {
  1155. _inherits(BroadcastFailedError, _XverseError);
  1156. var _super = _createSuper$r(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$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); }; }
  1164. 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; } }
  1165. var DataAbnormalError = /*#__PURE__*/function (_XverseError) {
  1166. _inherits(DataAbnormalError, _XverseError);
  1167. var _super = _createSuper$q(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$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); }; }
  1175. 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; } }
  1176. var GetOnVehicleError = /*#__PURE__*/function (_XverseError) {
  1177. _inherits(GetOnVehicleError, _XverseError);
  1178. var _super = _createSuper$p(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$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); }; }
  1186. 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; } }
  1187. var RepeatLoginError = /*#__PURE__*/function (_XverseError) {
  1188. _inherits(RepeatLoginError, _XverseError);
  1189. var _super = _createSuper$o(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$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); }; }
  1197. 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; } }
  1198. var RoomDoseNotExistError = /*#__PURE__*/function (_XverseError) {
  1199. _inherits(RoomDoseNotExistError, _XverseError);
  1200. var _super = _createSuper$n(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$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); }; }
  1208. 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; } }
  1209. var TicketExpireError = /*#__PURE__*/function (_XverseError) {
  1210. _inherits(TicketExpireError, _XverseError);
  1211. var _super = _createSuper$m(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$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); }; }
  1219. 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; } }
  1220. var ServerRateLimitError = /*#__PURE__*/function (_XverseError) {
  1221. _inherits(ServerRateLimitError, _XverseError);
  1222. var _super = _createSuper$l(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$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); }; }
  1230. 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; } }
  1231. var DoActionBlockedError = /*#__PURE__*/function (_XverseError) {
  1232. _inherits(DoActionBlockedError, _XverseError);
  1233. var _super = _createSuper$k(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$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); }; }
  1241. 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; } }
  1242. var ActionMaybeDelayError = /*#__PURE__*/function (_XverseError) {
  1243. _inherits(ActionMaybeDelayError, _XverseError);
  1244. var _super = _createSuper$j(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$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); }; }
  1252. 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; } }
  1253. var ActionResponseTimeoutError$1 = /*#__PURE__*/function (_XverseError) {
  1254. _inherits(ActionResponseTimeoutError, _XverseError);
  1255. var _super = _createSuper$i(ActionResponseTimeoutError);
  1256. function ActionResponseTimeoutError(e) {
  1257. _classCallCheck(this, ActionResponseTimeoutError);
  1258. return _super.call(this, 2999, e || "action\u56DE\u5305\u8D85\u65F6");
  1259. }
  1260. return _createClass(ActionResponseTimeoutError);
  1261. }(XverseError);
  1262. var CodeErrorMap = {
  1263. 1001: ParamError$1,
  1264. 1002: InternalError,
  1265. 1003: TimeoutError,
  1266. 1004: AuthenticationError$1,
  1267. 1005: TokenExpiredError$1,
  1268. 1006: UnsupportedError$1,
  1269. 1007: InitNetworkTimeoutError,
  1270. 1008: InitDecoderTimeoutError,
  1271. 1009: InitConfigTimeoutError,
  1272. 1010: InitEngineTimeoutError,
  1273. 1011: InitEngineError,
  1274. 1012: ActionBlockedError,
  1275. 1013: PreloadCanceledError$1,
  1276. 1014: FrequencyLimitError$1,
  1277. 2e3: UsersUpperLimitError,
  1278. 2001: RoomsUpperLimitError,
  1279. 2002: ServerParamError,
  1280. 2003: LackOfTokenError,
  1281. 2004: LoginFailedError,
  1282. 2005: VerifyServiceDownError,
  1283. 2006: CreateSessionFailedError,
  1284. 2008: RtcConnectionError,
  1285. 2009: DoActionFailedError,
  1286. 2010: StateSyncFailedError,
  1287. 2011: BroadcastFailedError,
  1288. 2012: DataAbnormalError,
  1289. 2015: GetOnVehicleError,
  1290. 2017: RepeatLoginError,
  1291. 2018: RoomDoseNotExistError,
  1292. 2019: TicketExpireError,
  1293. 2020: ServerRateLimitError,
  1294. 2333: DoActionBlockedError,
  1295. 2334: ActionMaybeDelayError,
  1296. 2999: ActionResponseTimeoutError$1
  1297. };
  1298. var util = {
  1299. uuid() {
  1300. return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (i) {
  1301. var e = Math.random() * 16 | 0;
  1302. return (i === "x" ? e : e & 3 | 8).toString(16);
  1303. });
  1304. },
  1305. getFormattedDate(i) {
  1306. var e = i.getMonth() + 1,
  1307. t = i.getDate(),
  1308. r = i.getHours(),
  1309. n = i.getMinutes(),
  1310. o = i.getSeconds(),
  1311. a = i.getMilliseconds(),
  1312. s = (e < 10 ? "0" : "") + e,
  1313. l = (t < 10 ? "0" : "") + t,
  1314. u = (r < 10 ? "0" : "") + r,
  1315. c = (n < 10 ? "0" : "") + n,
  1316. h = (o < 10 ? "0" : "") + o;
  1317. return i.getFullYear() + "-" + s + "-" + l + " " + u + ":" + c + ":" + h + "." + a;
  1318. },
  1319. createInstance(i) {
  1320. var e = new Axios(i),
  1321. t = bind(Axios.prototype.request, e);
  1322. return utils.extend(t, Axios.prototype, e), utils.extend(t, e), t.create = function (n) {
  1323. return createInstance(mergeConfig(i, n));
  1324. }, t;
  1325. },
  1326. mapLimit(i, e, t) {
  1327. return new Promise(function (r, n) {
  1328. var o = i.length;
  1329. var a = e - 1,
  1330. s = 0;
  1331. var l = function l(u) {
  1332. u.forEach(function (c) {
  1333. t(c).then(function () {
  1334. if (s++, s === o) {
  1335. r();
  1336. return;
  1337. }
  1338. a++;
  1339. var h = i[a];
  1340. h && l([h]);
  1341. }, function (h) {
  1342. n(h);
  1343. });
  1344. });
  1345. };
  1346. l(i.slice(0, e));
  1347. });
  1348. },
  1349. isWebAssemblySupported() {
  1350. try {
  1351. if (typeof WebAssembly == "object" && typeof WebAssembly.instantiate == "function") {
  1352. var i = new WebAssembly.Module(Uint8Array.of(0, 97, 115, 109, 1, 0, 0, 0));
  1353. if (i instanceof WebAssembly.Module) return new WebAssembly.Instance(i) instanceof WebAssembly.Instance;
  1354. }
  1355. } catch (_unused) {}
  1356. return console.log("wasm is not supported"), !1;
  1357. },
  1358. isSupported() {
  1359. return typeof RTCPeerConnection == "function" && this.isWebAssemblySupported();
  1360. },
  1361. objectParseFloat(i) {
  1362. var e = {};
  1363. return i && Object.keys(i).forEach(function (t) {
  1364. e[t] = parseFloat(i[t]);
  1365. }), e;
  1366. },
  1367. getRandomItem(i) {
  1368. i.length === 0 ? null : i[Math.floor(Math.random() * i.length)];
  1369. },
  1370. getErrorByCode(i) {
  1371. if (i === Codes.Success) return InternalError;
  1372. var e = CodeErrorMap[i];
  1373. return e || console.warn("unkown code", i), e || InternalError;
  1374. },
  1375. getDistance(i, e) {
  1376. var t = i.x,
  1377. r = i.y,
  1378. n = i.z,
  1379. o = e.x,
  1380. a = e.y,
  1381. s = e.z;
  1382. return Math.sqrt(Math.pow(Math.abs(t - o), 2) + Math.pow(Math.abs(r - a), 2) + Math.pow(Math.abs(n - s), 2));
  1383. }
  1384. };
  1385. 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); }; }
  1386. 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; } }
  1387. var Reporter = /*#__PURE__*/function (_EventEmitter) {
  1388. _inherits(Reporter, _EventEmitter);
  1389. var _super = _createSuper$h(Reporter);
  1390. function Reporter() {
  1391. var _this;
  1392. _classCallCheck(this, Reporter);
  1393. _this = _super.call(this);
  1394. _this._header = {};
  1395. _this._body = {};
  1396. _this._queue = [];
  1397. _this._disabled = !1;
  1398. _this._interval = null;
  1399. _this._reportUrl = null;
  1400. _this.isDocumentLoaded = function () {
  1401. return document.readyState === "complete";
  1402. };
  1403. _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 () {
  1404. _this._flushReport();
  1405. }, 10 * 1e3);
  1406. return _this;
  1407. }
  1408. _createClass(Reporter, [{
  1409. key: "disable",
  1410. value: function disable() {
  1411. this._disabled = !0, this._interval && window.clearInterval(this._interval);
  1412. }
  1413. }, {
  1414. key: "updateHeader",
  1415. value: function updateHeader(e) {
  1416. Object.assign(this._header, e);
  1417. }
  1418. }, {
  1419. key: "updateBody",
  1420. value: function updateBody(e) {
  1421. Object.assign(this._body, e);
  1422. }
  1423. }, {
  1424. key: "updateReportUrl",
  1425. value: function updateReportUrl(e) {
  1426. this._reportUrl = e;
  1427. }
  1428. }, {
  1429. key: "report",
  1430. value: function report(e, t, r) {
  1431. var _this2 = this;
  1432. if (this._disabled) return;
  1433. r || (r = {});
  1434. var _r = r,
  1435. n = _r.immediate,
  1436. o = _r.sampleRate;
  1437. if (o && o > Math.random()) return;
  1438. this.updateBody({
  1439. logTime: util.getFormattedDate(new Date()),
  1440. logTimestamp: Date.now()
  1441. });
  1442. var a = function a(s) {
  1443. var l = oe(le(oe({}, _this2._body), {
  1444. type: e
  1445. }), s);
  1446. _this2._queue.push(l), e === "measurement" && _this2.emit("report", s);
  1447. };
  1448. Array.isArray(t) ? t.forEach(function (s) {
  1449. return a(s);
  1450. }) : a(t), (n || this._queue.length >= REPORT_NUM_PER_REQUEST) && this._flushReport();
  1451. }
  1452. }, {
  1453. key: "_flushReport",
  1454. value: function _flushReport() {
  1455. if (this._disabled || !this._queue.length || !this.isDocumentLoaded()) return;
  1456. var e = {
  1457. header: this._header,
  1458. body: this._queue.splice(0, REPORT_NUM_PER_REQUEST)
  1459. };
  1460. this._post(e);
  1461. }
  1462. }, {
  1463. key: "_post",
  1464. value: function _post(e) {
  1465. var t = this._reportUrl || REPORT_URL.DEV;
  1466. return new Promise(function (r, n) {
  1467. var o = new XMLHttpRequest();
  1468. o.open("POST", t), o.setRequestHeader("Content-Type", "application/json");
  1469. try {
  1470. o.send(JSON.stringify(e));
  1471. } catch (a) {
  1472. console.error(a);
  1473. }
  1474. o.addEventListener("readystatechange", function () {
  1475. if (o.readyState == 4) return o.status == 200 ? r(o) : n("Unable to send log");
  1476. });
  1477. });
  1478. }
  1479. }]);
  1480. return Reporter;
  1481. }(EventEmitter);
  1482. var reporter$1 = new Reporter();
  1483. function _arrayLikeToArray$7(arr, len) {
  1484. if (len == null || len > arr.length) len = arr.length;
  1485. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  1486. arr2[i] = arr[i];
  1487. }
  1488. return arr2;
  1489. }
  1490. function _arrayWithoutHoles(arr) {
  1491. if (Array.isArray(arr)) return _arrayLikeToArray$7(arr);
  1492. }
  1493. function _iterableToArray(iter) {
  1494. if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
  1495. }
  1496. function _unsupportedIterableToArray$7(o, minLen) {
  1497. if (!o) return;
  1498. if (typeof o === "string") return _arrayLikeToArray$7(o, minLen);
  1499. var n = Object.prototype.toString.call(o).slice(8, -1);
  1500. if (n === "Object" && o.constructor) n = o.constructor.name;
  1501. if (n === "Map" || n === "Set") return Array.from(o);
  1502. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$7(o, minLen);
  1503. }
  1504. function _nonIterableSpread() {
  1505. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  1506. }
  1507. function _toConsumableArray(arr) {
  1508. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray$7(arr) || _nonIterableSpread();
  1509. }
  1510. var Logger = /*#__PURE__*/function () {
  1511. function Logger(e) {
  1512. _classCallCheck(this, Logger);
  1513. this.level = 3;
  1514. this.module = e;
  1515. }
  1516. _createClass(Logger, [{
  1517. key: "setLevel",
  1518. value: function setLevel(e) {
  1519. this.level = e;
  1520. }
  1521. }, {
  1522. key: "atleast",
  1523. value: function atleast(e) {
  1524. return e >= this.level && e >= this.level;
  1525. }
  1526. }, {
  1527. key: "print",
  1528. value: function print(e, t) {
  1529. for (var _len = arguments.length, r = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  1530. r[_key - 2] = arguments[_key];
  1531. }
  1532. if (this.atleast(t)) {
  1533. var _console$n;
  1534. var n = e == "debug" ? "info" : e,
  1535. o = this.prefix(e);
  1536. (_console$n = console[n]).call.apply(_console$n, [null, o].concat(r));
  1537. }
  1538. if (e !== "debug" && e !== "info") {
  1539. var _n = r.map(function (o) {
  1540. if (o instanceof Object) try {
  1541. return JSON.stringify(o);
  1542. } catch (_unused) {
  1543. return o;
  1544. } else return o;
  1545. }).join(",");
  1546. reporter$1.report("log", {
  1547. message: _n,
  1548. level: e,
  1549. module: this.module
  1550. });
  1551. }
  1552. }
  1553. }, {
  1554. key: "debug",
  1555. value: function debug() {
  1556. for (var _len2 = arguments.length, e = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  1557. e[_key2] = arguments[_key2];
  1558. }
  1559. return this.print.apply(this, ["debug", 1].concat(e));
  1560. }
  1561. }, {
  1562. key: "info",
  1563. value: function info() {
  1564. for (var _len3 = arguments.length, e = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  1565. e[_key3] = arguments[_key3];
  1566. }
  1567. return this.print.apply(this, ["info", 2].concat(e));
  1568. }
  1569. }, {
  1570. key: "infoAndReportLog",
  1571. value: function infoAndReportLog(e) {
  1572. for (var _len4 = arguments.length, t = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
  1573. t[_key4 - 1] = arguments[_key4];
  1574. }
  1575. var r = e.reportOptions;
  1576. delete e.reportOptions, reporter$1.report("log", e, r), t.length || (t = [e.message]), this.debug.apply(this, _toConsumableArray(t));
  1577. }
  1578. }, {
  1579. key: "infoAndReportMeasurement",
  1580. value: function infoAndReportMeasurement(e) {
  1581. for (var _len5 = arguments.length, t = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
  1582. t[_key5 - 1] = arguments[_key5];
  1583. }
  1584. var n;
  1585. var r = e.reportOptions;
  1586. if (e.startTime) {
  1587. var o = Date.now();
  1588. e.value === void 0 && (e.endTime = o), e.value === void 0 && (e.value = o - e.startTime);
  1589. }
  1590. 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) {
  1591. this.error.apply(this, _toConsumableArray(t));
  1592. return;
  1593. }
  1594. this.warn.apply(this, _toConsumableArray(t));
  1595. }
  1596. }, {
  1597. key: "warn",
  1598. value: function warn() {
  1599. for (var _len6 = arguments.length, e = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
  1600. e[_key6] = arguments[_key6];
  1601. }
  1602. return this.print.apply(this, ["warn", 3].concat(e));
  1603. }
  1604. }, {
  1605. key: "error",
  1606. value: function error() {
  1607. for (var _len7 = arguments.length, e = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
  1608. e[_key7] = arguments[_key7];
  1609. }
  1610. return this.print.apply(this, ["error", 4].concat(e));
  1611. }
  1612. }, {
  1613. key: "prefix",
  1614. value: function prefix(e) {
  1615. return "[".concat(this.module, "][").concat(e, "] ").concat(util.getFormattedDate(new Date()), ":");
  1616. }
  1617. }], [{
  1618. key: "setLevel",
  1619. value: function setLevel(e) {
  1620. this.level = e;
  1621. }
  1622. }]);
  1623. return Logger;
  1624. }();
  1625. var logger$1 = new Logger();
  1626. var AxiosCanceler = /*#__PURE__*/function () {
  1627. function AxiosCanceler() {
  1628. _classCallCheck(this, AxiosCanceler);
  1629. this.pendingMap = new Map();
  1630. }
  1631. _createClass(AxiosCanceler, [{
  1632. key: "addPending",
  1633. value: function addPending(e) {
  1634. var _this = this;
  1635. return new axios.CancelToken(function (t) {
  1636. _this.pendingMap.has(e) || _this.pendingMap.set(e, t);
  1637. });
  1638. }
  1639. }, {
  1640. key: "removeAllPending",
  1641. value: function removeAllPending() {
  1642. this.pendingMap.forEach(function (e) {
  1643. e && isFunction(e) && e();
  1644. }), this.pendingMap.clear();
  1645. }
  1646. }, {
  1647. key: "removePending",
  1648. value: function removePending(e) {
  1649. if (this.pendingMap.has(e)) {
  1650. var t = this.pendingMap.get(e);
  1651. t && t(e), this.pendingMap.delete(e);
  1652. }
  1653. }
  1654. }, {
  1655. key: "removeCancelToken",
  1656. value: function removeCancelToken(e) {
  1657. this.pendingMap.has(e) && this.pendingMap.delete(e);
  1658. }
  1659. }, {
  1660. key: "reset",
  1661. value: function reset() {
  1662. this.pendingMap = new Map();
  1663. }
  1664. }]);
  1665. return AxiosCanceler;
  1666. }();
  1667. 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); }; }
  1668. 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; } }
  1669. var Http1 = /*#__PURE__*/function (_EventEmitter) {
  1670. _inherits(Http1, _EventEmitter);
  1671. var _super = _createSuper$g(Http1);
  1672. function Http1() {
  1673. var _this;
  1674. _classCallCheck(this, Http1);
  1675. _this = _super.call(this);
  1676. _this.instatnce = axios.create(), _this.canceler = new AxiosCanceler();
  1677. return _this;
  1678. }
  1679. _createClass(Http1, [{
  1680. key: "requestConstant",
  1681. value: function requestConstant() {
  1682. return {
  1683. x_nounce: this.randomString(),
  1684. x_timestamp: new Date().getTime(),
  1685. x_os: "web"
  1686. };
  1687. }
  1688. }, {
  1689. key: "requestParams",
  1690. value: function requestParams(e) {
  1691. return oe({}, e.params);
  1692. }
  1693. }, {
  1694. key: "get",
  1695. value: function get(e) {
  1696. return this.request(le(oe({}, e), {
  1697. method: "GET"
  1698. }));
  1699. }
  1700. }, {
  1701. key: "post",
  1702. value: function post(e) {
  1703. return this.request(le(oe({}, e), {
  1704. method: "POST"
  1705. }));
  1706. }
  1707. }, {
  1708. key: "request",
  1709. value: function request(e) {
  1710. var _this2 = this;
  1711. var t = e.url,
  1712. _e$timeout = e.timeout,
  1713. r = _e$timeout === void 0 ? 1e4 : _e$timeout,
  1714. n = e.method,
  1715. o = e.key,
  1716. a = e.beforeRequest,
  1717. s = e.responseType,
  1718. l = e.data;
  1719. var _e$retry = e.retry,
  1720. u = _e$retry === void 0 ? 0 : _e$retry;
  1721. var c = this.patchUrl(t),
  1722. h = this.canceler.addPending(t);
  1723. a && isFunction(a) && a(e);
  1724. var f = this.requestParams(e);
  1725. var d = {
  1726. url: c,
  1727. method: n,
  1728. timeout: r,
  1729. cancelToken: h,
  1730. responseType: s,
  1731. params: f
  1732. };
  1733. n === "POST" && (d = oe({
  1734. data: l
  1735. }, d));
  1736. var _ = Date.now(),
  1737. g = function g() {
  1738. return _this2.instatnce.request(d).then(function (m) {
  1739. return o && logger$1.infoAndReportMeasurement({
  1740. metric: "http",
  1741. startTime: _,
  1742. extra: t,
  1743. group: "http",
  1744. tag: o
  1745. }), _this2.canceler.removeCancelToken(t), m;
  1746. }).catch(function (m) {
  1747. var v = axios.isCancel(m);
  1748. return u > 0 && !v ? (u--, logger$1.warn("request ".concat(t, " retry, left retry count"), u), g()) : (logger$1.infoAndReportMeasurement({
  1749. metric: "http",
  1750. startTime: _,
  1751. error: m,
  1752. extra: {
  1753. url: t,
  1754. isCanceled: v
  1755. },
  1756. tag: o,
  1757. group: "http"
  1758. }), _this2.canceler.removeCancelToken(t), Promise.reject(m));
  1759. });
  1760. };
  1761. return g();
  1762. }
  1763. }, {
  1764. key: "patchUrl",
  1765. value: function patchUrl(e) {
  1766. return e;
  1767. }
  1768. }, {
  1769. key: "randomString",
  1770. value: function randomString() {
  1771. var e = "";
  1772. var t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
  1773. r = t.length;
  1774. for (var n = 0; n < 8; n++) {
  1775. e += t.charAt(Math.floor(Math.random() * r));
  1776. }
  1777. return e;
  1778. }
  1779. }]);
  1780. return Http1;
  1781. }(EventEmitter);
  1782. var http1 = new Http1();
  1783. var ModelManager = /*#__PURE__*/function () {
  1784. function ModelManager(e, t) {
  1785. _classCallCheck(this, ModelManager);
  1786. this.avatarModelList = [];
  1787. this.skinList = [];
  1788. this.applicationConfig = null;
  1789. this.config = null;
  1790. this.appId = e, this.releaseId = t;
  1791. }
  1792. _createClass(ModelManager, [{
  1793. key: "findSkinConfig",
  1794. value: function () {
  1795. var _findSkinConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  1796. var t, n;
  1797. return regenerator.wrap(function _callee$(_context) {
  1798. while (1) {
  1799. switch (_context.prev = _context.next) {
  1800. case 0:
  1801. t = null;
  1802. _context.next = 3;
  1803. return this.getSkinsList();
  1804. case 3:
  1805. t = (this.skinList = _context.sent).find(function (n) {
  1806. return n.id === e;
  1807. });
  1808. if (!t) {
  1809. _context.next = 6;
  1810. break;
  1811. }
  1812. return _context.abrupt("return", t);
  1813. case 6:
  1814. n = "skin is invalid: skinId: ".concat(e);
  1815. return _context.abrupt("return", Promise.reject(new ParamError(n)));
  1816. case 8:
  1817. case "end":
  1818. return _context.stop();
  1819. }
  1820. }
  1821. }, _callee, this);
  1822. }));
  1823. function findSkinConfig(_x) {
  1824. return _findSkinConfig.apply(this, arguments);
  1825. }
  1826. return findSkinConfig;
  1827. }()
  1828. }, {
  1829. key: "findRoute",
  1830. value: function () {
  1831. var _findRoute = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e, t) {
  1832. var n, o;
  1833. return regenerator.wrap(function _callee2$(_context2) {
  1834. while (1) {
  1835. switch (_context2.prev = _context2.next) {
  1836. case 0:
  1837. _context2.next = 2;
  1838. return this.findSkinConfig(e);
  1839. case 2:
  1840. n = _context2.sent.routeList.find(function (o) {
  1841. return o.pathName === t;
  1842. });
  1843. if (n) {
  1844. _context2.next = 6;
  1845. break;
  1846. }
  1847. o = "find path failed: skinId: ".concat(e, ", pathName: ").concat(t);
  1848. return _context2.abrupt("return", Promise.reject(new ParamError(o)));
  1849. case 6:
  1850. return _context2.abrupt("return", (logger$1.debug("find route success", n), n));
  1851. case 7:
  1852. case "end":
  1853. return _context2.stop();
  1854. }
  1855. }
  1856. }, _callee2, this);
  1857. }));
  1858. function findRoute(_x2, _x3) {
  1859. return _findRoute.apply(this, arguments);
  1860. }
  1861. return findRoute;
  1862. }()
  1863. }, {
  1864. key: "findAssetList",
  1865. value: function () {
  1866. var _findAssetList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  1867. var r, n;
  1868. return regenerator.wrap(function _callee3$(_context3) {
  1869. while (1) {
  1870. switch (_context3.prev = _context3.next) {
  1871. case 0:
  1872. _context3.next = 2;
  1873. return this.findSkinConfig(e);
  1874. case 2:
  1875. r = _context3.sent.assetList;
  1876. if (r) {
  1877. _context3.next = 6;
  1878. break;
  1879. }
  1880. n = "find path failed: skinId: ".concat(e);
  1881. return _context3.abrupt("return", Promise.reject(new ParamError(n)));
  1882. case 6:
  1883. return _context3.abrupt("return", (logger$1.debug("find route success", r), r));
  1884. case 7:
  1885. case "end":
  1886. return _context3.stop();
  1887. }
  1888. }
  1889. }, _callee3, this);
  1890. }));
  1891. function findAssetList(_x4) {
  1892. return _findAssetList.apply(this, arguments);
  1893. }
  1894. return findAssetList;
  1895. }()
  1896. }, {
  1897. key: "findAsset",
  1898. value: function () {
  1899. var _findAsset = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e, t) {
  1900. var r,
  1901. n,
  1902. o,
  1903. a,
  1904. _args4 = arguments;
  1905. return regenerator.wrap(function _callee4$(_context4) {
  1906. while (1) {
  1907. switch (_context4.prev = _context4.next) {
  1908. case 0:
  1909. r = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : "id";
  1910. _context4.next = 3;
  1911. return this.findSkinConfig(e);
  1912. case 3:
  1913. n = _context4.sent;
  1914. if (!Array.isArray(t)) {
  1915. _context4.next = 6;
  1916. break;
  1917. }
  1918. return _context4.abrupt("return", t.map(function (a) {
  1919. return n.models.find(function (s) {
  1920. return s[r] === a;
  1921. });
  1922. }).filter(Boolean));
  1923. case 6:
  1924. o = n.models.find(function (a) {
  1925. return a[r] === t;
  1926. });
  1927. if (o) {
  1928. _context4.next = 10;
  1929. break;
  1930. }
  1931. a = "find asset failed: skinId: ".concat(e, ", keyValue: ").concat(t);
  1932. return _context4.abrupt("return", Promise.reject(new ParamError(a)));
  1933. case 10:
  1934. return _context4.abrupt("return", (logger$1.debug("find asset success", o), o));
  1935. case 11:
  1936. case "end":
  1937. return _context4.stop();
  1938. }
  1939. }
  1940. }, _callee4, this);
  1941. }));
  1942. function findAsset(_x5, _x6) {
  1943. return _findAsset.apply(this, arguments);
  1944. }
  1945. return findAsset;
  1946. }()
  1947. }, {
  1948. key: "findPoint",
  1949. value: function () {
  1950. var _findPoint = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(e, t) {
  1951. var n, o;
  1952. return regenerator.wrap(function _callee5$(_context5) {
  1953. while (1) {
  1954. switch (_context5.prev = _context5.next) {
  1955. case 0:
  1956. _context5.next = 2;
  1957. return this.findSkinConfig(e);
  1958. case 2:
  1959. n = _context5.sent.pointList.find(function (o) {
  1960. return o.id === t;
  1961. });
  1962. if (n) {
  1963. _context5.next = 6;
  1964. break;
  1965. }
  1966. o = "find point failed: skinId: ".concat(e, ", id: ").concat(t);
  1967. return _context5.abrupt("return", Promise.reject(new ParamError(o)));
  1968. case 6:
  1969. return _context5.abrupt("return", (logger$1.debug("find point success", n), n));
  1970. case 7:
  1971. case "end":
  1972. return _context5.stop();
  1973. }
  1974. }
  1975. }, _callee5, this);
  1976. }));
  1977. function findPoint(_x7, _x8) {
  1978. return _findPoint.apply(this, arguments);
  1979. }
  1980. return findPoint;
  1981. }()
  1982. }, {
  1983. key: "requestConfig",
  1984. value: function () {
  1985. var _requestConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6() {
  1986. var t, r, _ref, n, o;
  1987. return regenerator.wrap(function _callee6$(_context6) {
  1988. while (1) {
  1989. switch (_context6.prev = _context6.next) {
  1990. case 0:
  1991. if (!this.config) {
  1992. _context6.next = 2;
  1993. break;
  1994. }
  1995. return _context6.abrupt("return", this.config);
  1996. case 2:
  1997. // let e = `https://static.xverse.cn/console/config/${this.appId}/config.json`;
  1998. // this.releaseId && (e = `https://static.xverse.cn/console/config/${this.appId}/${this.releaseId}/config.json`);
  1999. // const t = Xverse.USE_TME_CDN ? "https://static.xverse.cn/tmeland/config/tme_config.json" : e;
  2000. t = './assets/config.json';
  2001. _context6.prev = 3;
  2002. _context6.next = 6;
  2003. return http1.get({
  2004. url: "".concat(t, "?t=").concat(Date.now()),
  2005. key: "config",
  2006. timeout: 6e3,
  2007. retry: 2
  2008. });
  2009. case 6:
  2010. r = _context6.sent;
  2011. _ref = r.data.data || {}, n = _ref.config, o = _ref.preload;
  2012. if (n) {
  2013. _context6.next = 10;
  2014. break;
  2015. }
  2016. throw new Error("config data parse error" + r.data);
  2017. case 10:
  2018. return _context6.abrupt("return", (this.config = {
  2019. config: n,
  2020. preload: o
  2021. }, logger$1.debug("get config success", this.config), this.config));
  2022. case 13:
  2023. _context6.prev = 13;
  2024. _context6.t0 = _context6["catch"](3);
  2025. return _context6.abrupt("return", Promise.reject(_context6.t0));
  2026. case 16:
  2027. case "end":
  2028. return _context6.stop();
  2029. }
  2030. }
  2031. }, _callee6, this, [[3, 13]]);
  2032. }));
  2033. function requestConfig() {
  2034. return _requestConfig.apply(this, arguments);
  2035. }
  2036. return requestConfig;
  2037. }()
  2038. }, {
  2039. key: "getApplicationConfig",
  2040. value: function () {
  2041. var _getApplicationConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7() {
  2042. var e;
  2043. return regenerator.wrap(function _callee7$(_context7) {
  2044. while (1) {
  2045. switch (_context7.prev = _context7.next) {
  2046. case 0:
  2047. if (!this.applicationConfig) {
  2048. _context7.next = 2;
  2049. break;
  2050. }
  2051. return _context7.abrupt("return", this.applicationConfig);
  2052. case 2:
  2053. _context7.prev = 2;
  2054. _context7.next = 5;
  2055. return this.requestConfig();
  2056. case 5:
  2057. e = _context7.sent;
  2058. return _context7.abrupt("return", (this.applicationConfig = e.config, this.applicationConfig));
  2059. case 9:
  2060. _context7.prev = 9;
  2061. _context7.t0 = _context7["catch"](2);
  2062. return _context7.abrupt("return", Promise.reject(_context7.t0));
  2063. case 12:
  2064. case "end":
  2065. return _context7.stop();
  2066. }
  2067. }
  2068. }, _callee7, this, [[2, 9]]);
  2069. }));
  2070. function getApplicationConfig() {
  2071. return _getApplicationConfig.apply(this, arguments);
  2072. }
  2073. return getApplicationConfig;
  2074. }()
  2075. }, {
  2076. key: "getAvatarModelList",
  2077. value: function () {
  2078. var _getAvatarModelList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8() {
  2079. var _yield$this$getApplic, e;
  2080. return regenerator.wrap(function _callee8$(_context8) {
  2081. while (1) {
  2082. switch (_context8.prev = _context8.next) {
  2083. case 0:
  2084. if (!this.avatarModelList.length) {
  2085. _context8.next = 2;
  2086. break;
  2087. }
  2088. return _context8.abrupt("return", this.avatarModelList);
  2089. case 2:
  2090. _context8.prev = 2;
  2091. _context8.next = 5;
  2092. return this.getApplicationConfig();
  2093. case 5:
  2094. _yield$this$getApplic = _context8.sent;
  2095. e = _yield$this$getApplic.avatars;
  2096. return _context8.abrupt("return", (this.avatarModelList = e.map(function (t) {
  2097. return {
  2098. name: t.name,
  2099. id: t.id,
  2100. modelUrl: t.url,
  2101. gender: t.gender,
  2102. components: t.components
  2103. };
  2104. }), this.avatarModelList));
  2105. case 10:
  2106. _context8.prev = 10;
  2107. _context8.t0 = _context8["catch"](2);
  2108. return _context8.abrupt("return", (logger$1.error(_context8.t0), []));
  2109. case 13:
  2110. case "end":
  2111. return _context8.stop();
  2112. }
  2113. }
  2114. }, _callee8, this, [[2, 10]]);
  2115. }));
  2116. function getAvatarModelList() {
  2117. return _getAvatarModelList.apply(this, arguments);
  2118. }
  2119. return getAvatarModelList;
  2120. }()
  2121. }, {
  2122. key: "getSkinsList",
  2123. value: function () {
  2124. var _getSkinsList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9() {
  2125. var _yield$this$getApplic2, e;
  2126. return regenerator.wrap(function _callee9$(_context9) {
  2127. while (1) {
  2128. switch (_context9.prev = _context9.next) {
  2129. case 0:
  2130. if (!this.skinList.length) {
  2131. _context9.next = 2;
  2132. break;
  2133. }
  2134. return _context9.abrupt("return", this.skinList);
  2135. case 2:
  2136. _context9.prev = 2;
  2137. _context9.next = 5;
  2138. return this.getApplicationConfig();
  2139. case 5:
  2140. _yield$this$getApplic2 = _context9.sent;
  2141. e = _yield$this$getApplic2.skins;
  2142. return _context9.abrupt("return", (this.skinList = e.map(function (t) {
  2143. var r;
  2144. return {
  2145. name: t.name,
  2146. dataVersion: t.id + t.versionId,
  2147. id: t.id,
  2148. fov: parseInt(t.fov || 90),
  2149. models: t.assetList.map(function (n) {
  2150. var o = n.assetId,
  2151. a = n.url,
  2152. s = n.thumbnailUrl,
  2153. l = n.typeName,
  2154. u = n.className;
  2155. return {
  2156. id: o,
  2157. modelUrl: a,
  2158. name: n.name,
  2159. thumbnailUrl: s,
  2160. typeName: l,
  2161. className: u === "\u4F4E\u6A21" ? "\u7C97\u6A21" : u
  2162. };
  2163. }),
  2164. routeList: (r = t.routeList) == null ? void 0 : r.map(function (n) {
  2165. var o = n.areaName,
  2166. a = n.attitude,
  2167. s = n.id,
  2168. l = n.pathName,
  2169. u = n.step,
  2170. c = n.birthPointList;
  2171. return {
  2172. areaName: o,
  2173. attitude: a,
  2174. id: s,
  2175. pathName: l,
  2176. step: u,
  2177. birthPointList: c.map(function (h) {
  2178. return {
  2179. camera: h.camera && {
  2180. position: util.objectParseFloat(h.camera.position),
  2181. angle: util.objectParseFloat(h.camera.rotation)
  2182. },
  2183. player: h.player && {
  2184. position: util.objectParseFloat(h.player.position),
  2185. angle: util.objectParseFloat(h.player.rotation)
  2186. }
  2187. };
  2188. })
  2189. };
  2190. }),
  2191. pointList: t.pointList.map(function (n) {
  2192. return le(oe({}, n), {
  2193. position: util.objectParseFloat(n.position),
  2194. rotation: util.objectParseFloat(n.rotation)
  2195. });
  2196. }),
  2197. versionId: t.versionId,
  2198. isEnable: t.isEnable,
  2199. assetList: t.assetList,
  2200. visibleRules: t.visibleRules,
  2201. animationList: t.animationList
  2202. };
  2203. }), this.skinList));
  2204. case 10:
  2205. _context9.prev = 10;
  2206. _context9.t0 = _context9["catch"](2);
  2207. return _context9.abrupt("return", (logger$1.error(_context9.t0), []));
  2208. case 13:
  2209. case "end":
  2210. return _context9.stop();
  2211. }
  2212. }
  2213. }, _callee9, this, [[2, 10]]);
  2214. }));
  2215. function getSkinsList() {
  2216. return _getSkinsList.apply(this, arguments);
  2217. }
  2218. return getSkinsList;
  2219. }()
  2220. }, {
  2221. key: "getBreathPointTextrueList",
  2222. value: function () {
  2223. var _getBreathPointTextrueList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10() {
  2224. return regenerator.wrap(function _callee10$(_context10) {
  2225. while (1) {
  2226. switch (_context10.prev = _context10.next) {
  2227. case 0:
  2228. return _context10.abrupt("return", [{
  2229. url: TEXTURE_URL
  2230. }]);
  2231. case 1:
  2232. case "end":
  2233. return _context10.stop();
  2234. }
  2235. }
  2236. }, _callee10);
  2237. }));
  2238. function getBreathPointTextrueList() {
  2239. return _getBreathPointTextrueList.apply(this, arguments);
  2240. }
  2241. return getBreathPointTextrueList;
  2242. }()
  2243. }], [{
  2244. key: "getInstance",
  2245. value: function getInstance(e, t) {
  2246. //getInstance(e, t) {
  2247. return this.instance || (this.instance = new ModelManager(e, t)), this.instance;
  2248. }
  2249. }, {
  2250. key: "findModels",
  2251. value: function findModels(e, t, r) {
  2252. //findModels(e, t, r) {
  2253. return e.filter(function (o) {
  2254. return o.typeName === t && o.className === r;
  2255. });
  2256. }
  2257. }, {
  2258. key: "findModel",
  2259. value: function findModel(e, t, r) {
  2260. //findModel(e, t, r) {
  2261. var n = e.filter(function (o) {
  2262. return o.typeName === t && o.className === r;
  2263. })[0];
  2264. return n || null;
  2265. }
  2266. }]);
  2267. return ModelManager;
  2268. }();
  2269. // export { modelManager };
  2270. var JoyStick = /*#__PURE__*/function () {
  2271. function JoyStick(e) {
  2272. _classCallCheck(this, JoyStick);
  2273. this._zone = document.createElement("div");
  2274. this._joystick = null;
  2275. this._room = e;
  2276. }
  2277. _createClass(JoyStick, [{
  2278. key: "init",
  2279. value: function init(e) {
  2280. var _this = this;
  2281. var _e$interval = e.interval,
  2282. t = _e$interval === void 0 ? 33 : _e$interval,
  2283. _e$triggerDistance = e.triggerDistance,
  2284. r = _e$triggerDistance === void 0 ? 25 : _e$triggerDistance,
  2285. _e$style = e.style,
  2286. n = _e$style === void 0 ? {
  2287. left: 0,
  2288. bottom: 0
  2289. } : _e$style,
  2290. o = function o(u, c) {
  2291. _this._room.actionsHandler.joystick({
  2292. degree: Math.floor(u),
  2293. level: Math.floor(c / 5)
  2294. });
  2295. },
  2296. a = this._zone;
  2297. 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({
  2298. zone: a,
  2299. mode: "static",
  2300. position: {
  2301. left: "50%",
  2302. top: "50%"
  2303. },
  2304. color: "white"
  2305. });
  2306. var s, l;
  2307. return this._joystick.on("move", function (u, c) {
  2308. s = c;
  2309. }), this._joystick.on("start", function () {
  2310. l = window.setInterval(function () {
  2311. s && s.distance > r && o && o(s.angle.degree, s.distance);
  2312. }, t);
  2313. }), this._joystick.on("end", function () {
  2314. l && window.clearInterval(l), l = void 0;
  2315. }), this._joystick;
  2316. }
  2317. }, {
  2318. key: "show",
  2319. value: function show() {
  2320. if (!this._joystick) throw new Error("joystick is not created");
  2321. this._zone.style.display = "block";
  2322. }
  2323. }, {
  2324. key: "hide",
  2325. value: function hide() {
  2326. if (!this._joystick) throw new Error("joystick is not created");
  2327. this._zone.style.display = "none";
  2328. }
  2329. }]);
  2330. return JoyStick;
  2331. }();
  2332. var CoreBroadcastType$1 = {
  2333. PlayAnimation: 'PlayAnimation'
  2334. };
  2335. var AvatarGroup = {
  2336. Npc: 'npc',
  2337. User: 'user'
  2338. };
  2339. var MessageHandleType$1 = {
  2340. MHT_Undefined: 0,
  2341. MHT_RoomMulticast: 1,
  2342. MHT_FollowListMulticast: 2,
  2343. MHT_CustomTargetSync: 3
  2344. };
  2345. var Broadcast$1 = /*#__PURE__*/function () {
  2346. function Broadcast(e, t) {
  2347. _classCallCheck(this, Broadcast);
  2348. this.room = e;
  2349. this.handlers = [];
  2350. this.init(t);
  2351. }
  2352. _createClass(Broadcast, [{
  2353. key: "init",
  2354. value: function init(t) {
  2355. this.handlers.push(t);
  2356. }
  2357. }, {
  2358. key: "handleBroadcast",
  2359. value: function () {
  2360. var _handleBroadcast = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  2361. return regenerator.wrap(function _callee$(_context) {
  2362. while (1) {
  2363. switch (_context.prev = _context.next) {
  2364. case 0:
  2365. _context.prev = 1;
  2366. JSON.parse(e.broadcastAction.data);
  2367. _context.next = 9;
  2368. break;
  2369. case 5:
  2370. _context.prev = 5;
  2371. _context.t0 = _context["catch"](1);
  2372. logger$1.error(_context.t0);
  2373. return _context.abrupt("return");
  2374. case 9:
  2375. case "end":
  2376. return _context.stop();
  2377. }
  2378. }
  2379. }, _callee, null, [[1, 5]]);
  2380. }));
  2381. function handleBroadcast(_x) {
  2382. return _handleBroadcast.apply(this, arguments);
  2383. }
  2384. return handleBroadcast;
  2385. }()
  2386. }, {
  2387. key: "broadcast",
  2388. value: function broadcast(e) {
  2389. var t = e.data,
  2390. _e$msgType = e.msgType,
  2391. r = _e$msgType === void 0 ? MessageHandleType$1.MHT_FollowListMulticast : _e$msgType,
  2392. n = e.targetUserIds;
  2393. return this.room.actionsHandler.broadcast({
  2394. data: t,
  2395. msgType: r,
  2396. targetUserIds: n
  2397. });
  2398. }
  2399. }]);
  2400. return Broadcast;
  2401. }();
  2402. var XAvatarLoader = /*#__PURE__*/function () {
  2403. function XAvatarLoader() {
  2404. _classCallCheck(this, XAvatarLoader);
  2405. E(this, "containers", new Map());
  2406. E(this, "meshes", new Map());
  2407. E(this, "animations", new Map());
  2408. E(this, "aniPath", new Map());
  2409. E(this, "binPath", new Map());
  2410. E(this, "texPath", new Map());
  2411. E(this, "matPath", new Map());
  2412. E(this, "mshPath", new Map());
  2413. E(this, "rootPath", new Map());
  2414. E(this, "meshTexList", new Map());
  2415. E(this, "_enableIdb", !0);
  2416. E(this, "_mappings", new Map());
  2417. E(this, "_sharedTex", new Map());
  2418. E(this, "avaliableAnimation", new Map());
  2419. E(this, "enableShareTexture", !0);
  2420. E(this, "enableShareAnimation", !0);
  2421. E(this, "fillEmptyLod", !0);
  2422. var e = new BABYLON.GLTFFileLoader();
  2423. BABYLON.SceneLoader.RegisterPlugin(e), e.preprocessUrlAsync = function (t) {
  2424. var r = avatarLoader._mappings.get(t);
  2425. return r ? Promise.resolve(r) : Promise.resolve(t);
  2426. };
  2427. }
  2428. _createClass(XAvatarLoader, [{
  2429. key: "getParsedUrl",
  2430. value: function getParsedUrl(e, t, r) {
  2431. var _this = this;
  2432. return new Promise(function (o, a) {
  2433. if (!r || r.indexOf(".zip") === -1) return o(r);
  2434. var s = _this.rootPath.get(r);
  2435. if (s) return o(s);
  2436. {
  2437. var l = ".zip",
  2438. u = r.replace(l, "") + COMPONENT_LIST_PREFIX;
  2439. e.urlTransformer(u, !0).then(function (c) {
  2440. if (!c) return a("Loading Failed");
  2441. new Response(c).json().then(function (h) {
  2442. var _, g, m, v, y, b, T;
  2443. var f = r.replace(l, ""),
  2444. d = f + ((_ = h == null ? void 0 : h.components) == null ? void 0 : _.url.replace("./", ""));
  2445. 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) {
  2446. var A = f + "/" + C.url;
  2447. _this.matPath.set(C.name, A);
  2448. }), h.bin) {
  2449. var C = f + "/" + h.bin.url;
  2450. _this.binPath.set(t, C);
  2451. var A = f + "/" + h.bin.url_lod2;
  2452. _this.binPath.set(t + "_" + avatarSetting.lod[1].level, A);
  2453. var S = f + "/" + h.bin.url_lod4;
  2454. _this.binPath.set(t + "_" + avatarSetting.lod[2].level, S);
  2455. }
  2456. return h.textures && h.textures.forEach(function (C) {
  2457. var A = f + "/" + C.url;
  2458. _this.texPath.set(C.url, A);
  2459. var S = _this.meshTexList.get(h.components.url);
  2460. C.type === "png" && (S ? S.find(function (P) {
  2461. return P === C.name;
  2462. }) || S.push(C.url) : _this.meshTexList.set(t, [C.name]));
  2463. }), o(d);
  2464. }).catch(function (h) {
  2465. logger$1.error("[Engine] parse json file error,".concat(h));
  2466. });
  2467. }).catch(function (c) {
  2468. logger$1.error("[Engine] ulrtransform error, cannot find resource in db,".concat(c));
  2469. });
  2470. }
  2471. });
  2472. }
  2473. }, {
  2474. key: "parse",
  2475. value: function () {
  2476. var _parse = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e, t) {
  2477. var _this2 = this;
  2478. var r;
  2479. return regenerator.wrap(function _callee$(_context) {
  2480. while (1) {
  2481. switch (_context.prev = _context.next) {
  2482. case 0:
  2483. r = [];
  2484. t.forEach(function (n) {
  2485. _this2._setAnimationList(n.id, n.animations), r.push(_this2.getParsedUrl(e, n.id, n.url)), n.components.forEach(function (o) {
  2486. o.units.forEach(function (a) {
  2487. r.push(_this2.getParsedUrl(e, a.name, a.url));
  2488. });
  2489. });
  2490. });
  2491. _context.next = 4;
  2492. return Promise.all(r);
  2493. case 4:
  2494. case "end":
  2495. return _context.stop();
  2496. }
  2497. }
  2498. }, _callee);
  2499. }));
  2500. function parse(_x, _x2) {
  2501. return _parse.apply(this, arguments);
  2502. }
  2503. return parse;
  2504. }()
  2505. }, {
  2506. key: "_setAnimationList",
  2507. value: function _setAnimationList(e, t) {
  2508. var _this3 = this;
  2509. t ? t.forEach(function (r) {
  2510. _this3.aniPath.set(e + "_" + r.name, r.url);
  2511. }) : logger$1.error("[Engine] no animation list exist, please check config for details");
  2512. }
  2513. }, {
  2514. key: "disposeContainer",
  2515. value: function disposeContainer() {
  2516. var _this4 = this;
  2517. this.containers.forEach(function (e, t) {
  2518. 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));
  2519. }), this._sharedTex.forEach(function (e, t) {
  2520. e.xReferenceCount == 0 && (e.dispose(), _this4._sharedTex.delete(t));
  2521. });
  2522. }
  2523. }, {
  2524. key: "enableIdb",
  2525. set: function set(e) {
  2526. this._enableIdb = e;
  2527. }
  2528. }, {
  2529. key: "getGlbPath",
  2530. value: function getGlbPath(e) {
  2531. return this.aniPath.get(e + ".glb");
  2532. }
  2533. }, {
  2534. key: "getGltfPath",
  2535. value: function getGltfPath(e) {
  2536. return this.mshPath.get(e + ".gltf");
  2537. }
  2538. }, {
  2539. key: "getPngUrl",
  2540. value: function getPngUrl(e) {
  2541. return this.texPath.get(e + ".png");
  2542. }
  2543. }, {
  2544. key: "getMeshUrl",
  2545. value: function getMeshUrl(e) {
  2546. return this.mshPath.get(e);
  2547. }
  2548. }, {
  2549. key: "_getSourceKey",
  2550. value: function _getSourceKey(e, t) {
  2551. return t && avatarSetting.lod[t] ? e + avatarSetting.lod[t].fileName.split(".")[0] : e;
  2552. }
  2553. }, {
  2554. key: "_getAnimPath",
  2555. value: function _getAnimPath(e, t) {
  2556. var r = this.aniPath.get(t + "_animations_" + t.split("_")[1]);
  2557. return r || (r = this.aniPath.get(t + "_" + e)), r;
  2558. }
  2559. }, {
  2560. key: "load",
  2561. value: function load(e, t, r, n) {
  2562. var _this5 = this;
  2563. return new Promise(function (o, a) {
  2564. _this5.loadGlb(e, t, r).then(function (s) {
  2565. return s ? o(s) : a("[Engine] container load failed");
  2566. }).catch(function () {
  2567. return a("[Engine] container load failed");
  2568. });
  2569. });
  2570. }
  2571. }, {
  2572. key: "_searchAnimation",
  2573. value: function _searchAnimation(e, t) {
  2574. var r;
  2575. return this.containers.forEach(function (n, o) {
  2576. var a = t.split("_")[0];
  2577. o.indexOf(a) != -1 && o.indexOf(e) != -1 && (r = n);
  2578. }), r;
  2579. }
  2580. }, {
  2581. key: "loadAnimRes",
  2582. value: function loadAnimRes(e, t, r) {
  2583. var _this6 = this;
  2584. return new Promise(function (n, o) {
  2585. var a = _this6._getAnimPath(t, r),
  2586. s = getAnimationKey(t, r);
  2587. if (a && _this6.containers.get(a)) return n(_this6.containers.get(a));
  2588. if (a) _this6._loadGlbFromBlob(e, s, a).then(function (l) {
  2589. return l.animationGroups.length == 0 ? (_this6.containers.delete(s), l.dispose(), Promise.reject("container does not contains animation data")) : n(l);
  2590. });else return o("no such url");
  2591. });
  2592. }
  2593. }, {
  2594. key: "loadGlb",
  2595. value: function loadGlb(e, t, r) {
  2596. var n = this.getMeshUrl(this._getSourceKey(t, r));
  2597. 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");
  2598. }
  2599. }, {
  2600. key: "loadGltf",
  2601. value: function loadGltf(e, t, r, n) {
  2602. var o = this._getSourceKey(t, r || 0);
  2603. var a = this.getGltfPath(o);
  2604. 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();
  2605. }
  2606. }, {
  2607. key: "loadSubsequence",
  2608. value: function loadSubsequence() {}
  2609. }, {
  2610. key: "loadVAT",
  2611. value: function loadVAT() {}
  2612. }, {
  2613. key: "getResourceName",
  2614. value: function getResourceName(e) {
  2615. return this.meshTexList.get(e);
  2616. }
  2617. }, {
  2618. key: "_loadGltfFromUrl",
  2619. value: function _loadGltfFromUrl(e, t, r) {
  2620. return BABYLON.SceneLoader.LoadAssetContainerAsync(r, t + ".gltf", e.Scene, null, ".gltf");
  2621. }
  2622. }, {
  2623. key: "_loadGlbFromBlob",
  2624. value: function _loadGlbFromBlob(e, t, r) {
  2625. var _this7 = this;
  2626. return new Promise(function (n, o) {
  2627. e.urlTransformer(r).then(function (a) {
  2628. BABYLON.SceneLoader.LoadAssetContainerAsync("", a, e.Scene, null, ".glb").then(function (s) {
  2629. if (s) {
  2630. if (_this7.enableShareTexture && s.textures.length > 0) {
  2631. var l = t.indexOf("_lod") != -1 ? t.slice(0, -5) : t,
  2632. u = _this7._sharedTex.get(l);
  2633. u ? (s.meshes[1].material._albedoTexture = u, s.textures.forEach(function (c) {
  2634. c.dispose();
  2635. }), s.textures = [u], u.xReferenceCount++) : (_this7._sharedTex.set(l, s.textures[0]), s.textures[0].xReferenceCount = 1);
  2636. }
  2637. return s.addAllToScene(), s.xReferenceCount = 0, s.meshes.forEach(function (l) {
  2638. l.setEnabled(!1);
  2639. }), _this7.containers.set(r, s), n(s);
  2640. } else o("glb file load failed");
  2641. });
  2642. });
  2643. });
  2644. }
  2645. }, {
  2646. key: "_loadGlbFromUrl",
  2647. value: function _loadGlbFromUrl(e, t, r) {
  2648. var _this8 = this;
  2649. return new Promise(function (n, o) {
  2650. BABYLON.SceneLoader.LoadAssetContainerAsync("", r, e.Scene, null, ".glb").then(function (a) {
  2651. if (a) {
  2652. if (a.addAllToScene(), a.meshes.forEach(function (s) {
  2653. s.setEnabled(!1);
  2654. }), _this8.enableShareTexture && a.textures.length > 0) {
  2655. var s = t.indexOf("_lod") != -1 ? t.slice(0, -5) : t,
  2656. l = _this8._sharedTex.get(s);
  2657. l ? (a.meshes[1].material._albedoTexture = l, a.textures.forEach(function (u) {
  2658. u.dispose();
  2659. }), a.textures = [l], l.xReferenceCount++) : (_this8._sharedTex.set(s, a.textures[0]), a.textures[0].xReferenceCount = 1);
  2660. }
  2661. return a.xReferenceCount = 0, _this8.containers.set(r, a), n(a);
  2662. } else o("glb file load failed");
  2663. });
  2664. });
  2665. }
  2666. }, {
  2667. key: "_loadGltfFromBlob",
  2668. value: function _loadGltfFromBlob(e, t, r, n) {
  2669. var _this9 = this;
  2670. return new Promise(function (o, a) {
  2671. var s = [];
  2672. var l = _this9._getSourceKey(t, r),
  2673. u = _this9.getGltfPath(l);
  2674. 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."));
  2675. var c = _this9.mshPath.get(l + ".gltf");
  2676. if (!c) return a("cannot find asset mshPath");
  2677. var h = _this9.binPath.get(l + ".bin");
  2678. if (!h) return a("cannot find asset binPath");
  2679. if (!n) {
  2680. var _ = _this9.meshTexList.get(t);
  2681. if (!_ || _.length == 0) return a("cannot find texture");
  2682. n = _[0];
  2683. }
  2684. var f = _this9.texPath.get(n + ".png");
  2685. if (!f) return a();
  2686. var d = _this9.texPath.get(n + "-astc.ktx");
  2687. if (!d) return a();
  2688. 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 () {
  2689. var _ = u.replace(l + ".gltf", "");
  2690. BABYLON.SceneLoader.LoadAssetContainerAsync(_, l + ".gltf", e.Scene, null, ".gltf").then(function (g) {
  2691. var v;
  2692. _this9.containers.set(u, g), g.addAllToScene(), g.meshes.forEach(function (y) {
  2693. y.setEnabled(!1);
  2694. });
  2695. var m = _this9._sharedTex.get(t);
  2696. 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);
  2697. });
  2698. });
  2699. });
  2700. }
  2701. }, {
  2702. key: "_blobMapping",
  2703. value: function _blobMapping(e, t) {
  2704. var _this10 = this;
  2705. return new Promise(function (r, n) {
  2706. e.urlTransformer(t).then(function (o) {
  2707. return o ? (_this10._mappings.set(t, o), r(t)) : n("[Engine] url urlTransformer parse error ".concat(t));
  2708. });
  2709. });
  2710. }
  2711. }]);
  2712. return XAvatarLoader;
  2713. }();
  2714. var avatarLoader = new XAvatarLoader();
  2715. var SyncEventType = {
  2716. Reset: 0,
  2717. Appear: 1,
  2718. Disappear: 2,
  2719. Move: 3,
  2720. ChangeRenderInfo: 4,
  2721. KeepAlive: 5,
  2722. Rotate: 6,
  2723. ET_RemoveVisitor: 7
  2724. };
  2725. var GetStateTypes = {
  2726. Default: 0,
  2727. Event: 1
  2728. };
  2729. var EAvatarRelationRank = {
  2730. Self: 0,
  2731. Npc: 1,
  2732. Friend: 2,
  2733. Stranger: 3,
  2734. Robot: 4,
  2735. Unknown: 5
  2736. };
  2737. var Person = {
  2738. Third: 0,
  2739. First: 1
  2740. };
  2741. var MotionType = {
  2742. Walk: 'walk',
  2743. Run: 'run',
  2744. Fly: 'fly'
  2745. };
  2746. var Queue = /*#__PURE__*/function () {
  2747. function Queue() {
  2748. _classCallCheck(this, Queue);
  2749. E(this, "queue", []);
  2750. E(this, "currentAction");
  2751. }
  2752. _createClass(Queue, [{
  2753. key: "append",
  2754. value: function () {
  2755. var _append = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  2756. var t, r;
  2757. return regenerator.wrap(function _callee$(_context) {
  2758. while (1) {
  2759. switch (_context.prev = _context.next) {
  2760. case 0:
  2761. if (!(this.queue.length === 0 || ((t = this.currentAction) == null ? void 0 : t.type) === e.type && this.queue.length === 1)) {
  2762. _context.next = 7;
  2763. break;
  2764. }
  2765. this.queue = [];
  2766. this.queue.push(e);
  2767. _context.next = 5;
  2768. return this.go();
  2769. case 5:
  2770. _context.next = 8;
  2771. break;
  2772. case 7:
  2773. ((r = this.queue[this.queue.length - 1]) == null ? void 0 : r.type) === e.type && this.queue.pop(), this.queue.push(e);
  2774. case 8:
  2775. case "end":
  2776. return _context.stop();
  2777. }
  2778. }
  2779. }, _callee, this);
  2780. }));
  2781. function append(_x) {
  2782. return _append.apply(this, arguments);
  2783. }
  2784. return append;
  2785. }()
  2786. }, {
  2787. key: "go",
  2788. value: function () {
  2789. var _go = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  2790. var e;
  2791. return regenerator.wrap(function _callee2$(_context2) {
  2792. while (1) {
  2793. switch (_context2.prev = _context2.next) {
  2794. case 0:
  2795. if (!(this.queue.length !== 0)) {
  2796. _context2.next = 9;
  2797. break;
  2798. }
  2799. e = this.queue[0];
  2800. this.currentAction = e;
  2801. _context2.next = 5;
  2802. return e.action();
  2803. case 5:
  2804. this.currentAction = void 0;
  2805. this.queue.splice(0, 1);
  2806. _context2.next = 9;
  2807. return this.go();
  2808. case 9:
  2809. case "end":
  2810. return _context2.stop();
  2811. }
  2812. }
  2813. }, _callee2, this);
  2814. }));
  2815. function go() {
  2816. return _go.apply(this, arguments);
  2817. }
  2818. return go;
  2819. }()
  2820. }, {
  2821. key: "reject",
  2822. value: function () {
  2823. var _reject = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
  2824. return regenerator.wrap(function _callee3$(_context3) {
  2825. while (1) {
  2826. switch (_context3.prev = _context3.next) {
  2827. case 0:
  2828. this.queue = [];
  2829. case 1:
  2830. case "end":
  2831. return _context3.stop();
  2832. }
  2833. }
  2834. }, _callee3, this);
  2835. }));
  2836. function reject() {
  2837. return _reject.apply(this, arguments);
  2838. }
  2839. return reject;
  2840. }()
  2841. }]);
  2842. return Queue;
  2843. }();
  2844. 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; } } }; }
  2845. 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); }
  2846. 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; }
  2847. 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); }; }
  2848. 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; } }
  2849. var XverseAvatar = /*#__PURE__*/function (_EventEmitter) {
  2850. _inherits(XverseAvatar, _EventEmitter);
  2851. var _super = _createSuper$f(XverseAvatar);
  2852. function XverseAvatar(_ref) {
  2853. var _this;
  2854. var e = _ref.userId,
  2855. t = _ref.isHost,
  2856. r = _ref.room,
  2857. n = _ref.avatarId,
  2858. o = _ref.isSelf,
  2859. _ref$group = _ref.group,
  2860. a = _ref$group === void 0 ? AvatarGroup.Npc : _ref$group;
  2861. _classCallCheck(this, XverseAvatar);
  2862. _this = _super.call(this);
  2863. E(_assertThisInitialized(_this), "xAvatar");
  2864. E(_assertThisInitialized(_this), "_isHost", !1);
  2865. E(_assertThisInitialized(_this), "_room");
  2866. E(_assertThisInitialized(_this), "_withModel", !1);
  2867. E(_assertThisInitialized(_this), "_userId");
  2868. E(_assertThisInitialized(_this), "group", AvatarGroup.User);
  2869. E(_assertThisInitialized(_this), "state", "idle");
  2870. E(_assertThisInitialized(_this), "isLoading", !0);
  2871. E(_assertThisInitialized(_this), "_isMoving", !1);
  2872. E(_assertThisInitialized(_this), "_isRotating", !1);
  2873. E(_assertThisInitialized(_this), "_failed", !1);
  2874. E(_assertThisInitialized(_this), "disconnected", !1);
  2875. E(_assertThisInitialized(_this), "_avatarId");
  2876. E(_assertThisInitialized(_this), "prioritySync", !1);
  2877. E(_assertThisInitialized(_this), "priority", EAvatarRelationRank.Stranger);
  2878. E(_assertThisInitialized(_this), "_avatarModel");
  2879. E(_assertThisInitialized(_this), "_motionType", MotionType.Walk);
  2880. E(_assertThisInitialized(_this), "isSelf", !1);
  2881. E(_assertThisInitialized(_this), "_lastAnimTraceId", "");
  2882. E(_assertThisInitialized(_this), "statusSyncQueue", new Queue());
  2883. E(_assertThisInitialized(_this), "extraInfo", {});
  2884. E(_assertThisInitialized(_this), "setPosition", function (e) {
  2885. var t;
  2886. !_this._room.signal.isUpdatedYUV || (t = _this.xAvatar) == null || t.setPosition(positionPrecisionProtect(e));
  2887. });
  2888. E(_assertThisInitialized(_this), "setRotation", function (e) {
  2889. var t;
  2890. !_this._room.signal.isUpdatedYUV || (t = _this.xAvatar) == null || t.setRotation(rotationPrecisionProtect(e));
  2891. });
  2892. E(_assertThisInitialized(_this), "stopAnimation", function () {
  2893. var e, t;
  2894. (t = (e = _this.xAvatar) == null ? void 0 : e.controller) == null || t.stopAnimation();
  2895. });
  2896. E(_assertThisInitialized(_this), "_playAnimation", /*#__PURE__*/function () {
  2897. var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  2898. var t,
  2899. r,
  2900. o,
  2901. n,
  2902. _a,
  2903. _args = arguments;
  2904. return regenerator.wrap(function _callee$(_context) {
  2905. while (1) {
  2906. switch (_context.prev = _context.next) {
  2907. case 0:
  2908. t = _args.length > 1 && _args[1] !== undefined ? _args[1] : !0;
  2909. r = _args.length > 2 && _args[2] !== undefined ? _args[2] : !1;
  2910. if (_this._room.signal.isUpdatedYUV) {
  2911. _context.next = 4;
  2912. break;
  2913. }
  2914. return _context.abrupt("return");
  2915. case 4:
  2916. if (!(_this.state !== "idle" && !r)) {
  2917. _context.next = 6;
  2918. break;
  2919. }
  2920. return _context.abrupt("return", (logger$1.debug("_playAnimation", "state is not idle"), Promise.resolve("_playAnimation, state is not idle")));
  2921. case 6:
  2922. n = Date.now();
  2923. _context.prev = 7;
  2924. if ((o = _this.xAvatar) != null && o.controller) {
  2925. _context.next = 10;
  2926. break;
  2927. }
  2928. return _context.abrupt("return", Promise.reject(new InternalError("[avatar: ".concat(_this.userId, "] Play animation failed: ").concat(e, ", no controller"))));
  2929. case 10:
  2930. _this.isSelf && setTimeout(function () {
  2931. logger$1.infoAndReportMeasurement({
  2932. tag: e,
  2933. startTime: n,
  2934. value: 0,
  2935. metric: "playAnimationStart"
  2936. });
  2937. });
  2938. _a = util.uuid();
  2939. _this._lastAnimTraceId = _a;
  2940. _context.next = 15;
  2941. return _this.xAvatar.controller.playAnimation(e, t);
  2942. case 15:
  2943. _a === _this._lastAnimTraceId && !_this.isMoving && !t && e !== "Idle" && _this.xAvatar.controller.playAnimation("Idle", t).catch(function (s) {
  2944. logger$1.error("[avatar: ".concat(_this.userId, "] Play animation failed [force idle]"), s);
  2945. });
  2946. _this.isSelf && logger$1.infoAndReportMeasurement({
  2947. tag: e,
  2948. startTime: n,
  2949. extra: {
  2950. loop: t
  2951. },
  2952. metric: "playAnimationEnd"
  2953. });
  2954. _context.next = 22;
  2955. break;
  2956. case 19:
  2957. _context.prev = 19;
  2958. _context.t0 = _context["catch"](7);
  2959. return _context.abrupt("return", (logger$1.error("[avatar: ".concat(_this.userId, "] Play animation failed: ").concat(e), _context.t0), _this.isSelf && logger$1.infoAndReportMeasurement({
  2960. tag: e,
  2961. startTime: n,
  2962. metric: "playAnimationEnd",
  2963. error: _context.t0,
  2964. extra: {
  2965. loop: t
  2966. }
  2967. }), Promise.reject(_context.t0)));
  2968. case 22:
  2969. case "end":
  2970. return _context.stop();
  2971. }
  2972. }
  2973. }, _callee, null, [[7, 19]]);
  2974. }));
  2975. return function (_x) {
  2976. return _ref2.apply(this, arguments);
  2977. };
  2978. }());
  2979. E(_assertThisInitialized(_this), "changeComponents", /*#__PURE__*/function () {
  2980. var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e) {
  2981. var _ref4, t, _ref4$endAnimation, r, n, o;
  2982. return regenerator.wrap(function _callee2$(_context2) {
  2983. while (1) {
  2984. switch (_context2.prev = _context2.next) {
  2985. case 0:
  2986. _ref4 = e || {}, t = _ref4.mode, _ref4$endAnimation = _ref4.endAnimation, r = _ref4$endAnimation === void 0 ? "" : _ref4$endAnimation, n = JSON.parse(JSON.stringify(e.avatarComponents));
  2987. o = avatarComponentsValidate(n, _this._avatarModel);
  2988. 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({
  2989. avatarComponents: n,
  2990. mode: t,
  2991. endAnimation: r
  2992. }).then(function () {
  2993. _this.isSelf && t !== ChangeComponentsMode.Preview && _this.avatarComponentsSync(_this.avatarComponents);
  2994. })));
  2995. case 3:
  2996. case "end":
  2997. return _context2.stop();
  2998. }
  2999. }
  3000. }, _callee2);
  3001. }));
  3002. return function (_x2) {
  3003. return _ref3.apply(this, arguments);
  3004. };
  3005. }());
  3006. E(_assertThisInitialized(_this), "_changeComponents", /*#__PURE__*/function () {
  3007. var _ref5 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  3008. var o, _ref6, _ref6$avatarComponent, t, r, n, _a2, s, l, _iterator, _step, u, c, h, f, d;
  3009. return regenerator.wrap(function _callee3$(_context3) {
  3010. while (1) {
  3011. switch (_context3.prev = _context3.next) {
  3012. case 0:
  3013. _ref6 = e || {}, _ref6$avatarComponent = _ref6.avatarComponents, t = _ref6$avatarComponent === void 0 ? [] : _ref6$avatarComponent, r = _ref6.mode, n = Date.now();
  3014. _context3.prev = 1;
  3015. if (_this.xAvatar) {
  3016. _context3.next = 4;
  3017. break;
  3018. }
  3019. return _context3.abrupt("return", Promise.reject(new InternalError("changeComponents failed, without instance: xAvatar")));
  3020. case 4:
  3021. _context3.next = 6;
  3022. return avatarComponentsModify(_this._avatarModel, t);
  3023. case 6:
  3024. _a2 = _context3.sent;
  3025. s = [];
  3026. _context3.next = 10;
  3027. return avatarComponentsParser(_this._avatarModel, _a2, _this.avatarComponents);
  3028. case 10:
  3029. l = _context3.sent;
  3030. if (!(l.length === 0)) {
  3031. _context3.next = 13;
  3032. break;
  3033. }
  3034. return _context3.abrupt("return", _this.avatarComponents);
  3035. case 13:
  3036. _context3.next = 15;
  3037. return _this.beforeChangeComponentsHook(e);
  3038. case 15:
  3039. _iterator = _createForOfIteratorHelper$6(l);
  3040. try {
  3041. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  3042. u = _step.value;
  3043. c = u.id, h = u.type, f = u.url, d = u.suitComb;
  3044. s.push((o = _this.xAvatar) == null ? void 0 : o.addComponent(c, h, f, d));
  3045. }
  3046. } catch (err) {
  3047. _iterator.e(err);
  3048. } finally {
  3049. _iterator.f();
  3050. }
  3051. _context3.next = 19;
  3052. return Promise.all(s);
  3053. case 19:
  3054. _this.emit("componentsChanged", {
  3055. components: _this.avatarComponents,
  3056. mode: r
  3057. });
  3058. _this.isSelf && logger$1.infoAndReportMeasurement({
  3059. tag: "changeComponents",
  3060. startTime: n,
  3061. metric: "changeComponents",
  3062. extra: {
  3063. inputComponents: t,
  3064. finalComponents: _this.avatarComponents,
  3065. mode: ChangeComponentsMode[r]
  3066. }
  3067. });
  3068. return _context3.abrupt("return", _this.avatarComponents);
  3069. case 24:
  3070. _context3.prev = 24;
  3071. _context3.t0 = _context3["catch"](1);
  3072. return _context3.abrupt("return", (_this.isSelf && logger$1.infoAndReportMeasurement({
  3073. tag: "changeComponents",
  3074. startTime: n,
  3075. metric: "changeComponents",
  3076. error: _context3.t0,
  3077. extra: {
  3078. inputComponents: t,
  3079. finalComponents: _this.avatarComponents,
  3080. mode: ChangeComponentsMode[r]
  3081. }
  3082. }), Promise.reject(_context3.t0)));
  3083. case 27:
  3084. case "end":
  3085. return _context3.stop();
  3086. }
  3087. }
  3088. }, _callee3, null, [[1, 24]]);
  3089. }));
  3090. return function (_x3) {
  3091. return _ref5.apply(this, arguments);
  3092. };
  3093. }());
  3094. E(_assertThisInitialized(_this), "avatarComponentsSync", function (e) {
  3095. e = e.map(function (t) {
  3096. return {
  3097. type: t.type,
  3098. id: t.id
  3099. };
  3100. }), _this._room.actionsHandler.avatarComponentsSync(e);
  3101. });
  3102. E(_assertThisInitialized(_this), "hide", function () {
  3103. var e;
  3104. if ((e = _this.xAvatar) != null && e.hide()) return Promise.resolve("avatar: ".concat(_this.userId, " hide success"));
  3105. {
  3106. var _t = "avatar: ".concat(_this.userId, " hide failed ").concat(!_this.xAvatar && "without instance: xAvatar");
  3107. return logger$1.warn(_t), Promise.reject(_t);
  3108. }
  3109. });
  3110. E(_assertThisInitialized(_this), "show", function () {
  3111. var e;
  3112. if ((e = _this.xAvatar) != null && e.show()) return Promise.resolve("avatar: ".concat(_this.userId, " show success"));
  3113. {
  3114. var _t2 = "avatar: ".concat(_this.userId, " show failed ").concat(!_this.xAvatar && "without instance: xAvatar");
  3115. return logger$1.warn(_t2), Promise.reject(_t2);
  3116. }
  3117. });
  3118. E(_assertThisInitialized(_this), "sayTimer");
  3119. _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) {
  3120. var l = s.find(function (u) {
  3121. return u.id === n;
  3122. });
  3123. l && (_this._avatarModel = l);
  3124. });
  3125. return _this;
  3126. }
  3127. _createClass(XverseAvatar, [{
  3128. key: "avatarId",
  3129. get: function get() {
  3130. return this._avatarId;
  3131. }
  3132. }, {
  3133. key: "isRender",
  3134. get: function get() {
  3135. var e;
  3136. return !!((e = this.xAvatar) != null && e.isRender);
  3137. }
  3138. }, {
  3139. key: "isHidden",
  3140. get: function get() {
  3141. var e;
  3142. return !!((e = this.xAvatar) != null && e.isHide);
  3143. }
  3144. }, {
  3145. key: "motionType",
  3146. get: function get() {
  3147. return this._motionType;
  3148. },
  3149. set: function set(e) {
  3150. this._motionType = e;
  3151. }
  3152. }, {
  3153. key: "nickname",
  3154. get: function get() {
  3155. var e;
  3156. return (e = this.xAvatar) == null ? void 0 : e.nickName;
  3157. }
  3158. }, {
  3159. key: "words",
  3160. get: function get() {
  3161. var e;
  3162. return (e = this.xAvatar) == null ? void 0 : e.words;
  3163. }
  3164. }, {
  3165. key: "isHost",
  3166. get: function get() {
  3167. return this._isHost;
  3168. }
  3169. }, {
  3170. key: "failed",
  3171. get: function get() {
  3172. return this._failed;
  3173. }
  3174. }, {
  3175. key: "scale",
  3176. get: function get() {
  3177. var e;
  3178. return (e = this.xAvatar) == null ? void 0 : e.scale;
  3179. }
  3180. }, {
  3181. key: "animations",
  3182. get: function get() {
  3183. var e;
  3184. return !this.xAvatar || !this.xAvatar.controller ? [] : ((e = this.xAvatar) == null ? void 0 : e.getAvaliableAnimations()) || [];
  3185. }
  3186. }, {
  3187. key: "position",
  3188. get: function get() {
  3189. var e;
  3190. return (e = this.xAvatar) == null ? void 0 : e.position;
  3191. }
  3192. }, {
  3193. key: "rotation",
  3194. get: function get() {
  3195. var e;
  3196. return (e = this.xAvatar) == null ? void 0 : e.rotation;
  3197. }
  3198. }, {
  3199. key: "pose",
  3200. get: function get() {
  3201. return {
  3202. position: this.position,
  3203. angle: this.rotation
  3204. };
  3205. }
  3206. }, {
  3207. key: "id",
  3208. get: function get() {
  3209. return this.userId;
  3210. }
  3211. }, {
  3212. key: "isMoving",
  3213. get: function get() {
  3214. return this._isMoving;
  3215. },
  3216. set: function set(e) {
  3217. this._isMoving = e, this.state = e ? "moving" : "idle";
  3218. }
  3219. }, {
  3220. key: "isRotating",
  3221. get: function get() {
  3222. return this._isRotating;
  3223. },
  3224. set: function set(e) {
  3225. this._isRotating = e, this.state = e ? "rotating" : "idle";
  3226. }
  3227. }, {
  3228. key: "withModel",
  3229. get: function get() {
  3230. return this._withModel;
  3231. }
  3232. }, {
  3233. key: "avatarComponents",
  3234. get: function get() {
  3235. var e;
  3236. return JSON.parse(JSON.stringify(((e = this.xAvatar) == null ? void 0 : e.clothesList) || []));
  3237. }
  3238. }, {
  3239. key: "userId",
  3240. get: function get() {
  3241. return this._userId;
  3242. }
  3243. }, {
  3244. key: "removeWhenDisconnected",
  3245. get: function get() {
  3246. return this.extraInfo && this.extraInfo.removeWhenDisconnected !== void 0 ? this.extraInfo.removeWhenDisconnected : !0;
  3247. }
  3248. }, {
  3249. key: "setConnectionStatus",
  3250. value: function setConnectionStatus(e) {
  3251. this.disconnected !== e && (this.disconnected = e, e ? this.emit("disconnected") : this.emit("reconnected"), logger$1.warn("avatar ".concat(this.userId, " status changed, disconnected:"), e));
  3252. }
  3253. }, {
  3254. key: "setScale",
  3255. value: function setScale(e) {
  3256. var t;
  3257. (t = this.xAvatar) == null || t.setScale(e > 0 ? e : 1);
  3258. }
  3259. }, {
  3260. key: "playAnimation",
  3261. value: function () {
  3262. var _playAnimation = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  3263. var _this2 = this;
  3264. var _ref7, t, r, n, o;
  3265. return regenerator.wrap(function _callee4$(_context4) {
  3266. while (1) {
  3267. switch (_context4.prev = _context4.next) {
  3268. case 0:
  3269. _ref7 = e || {}, t = _ref7.animationName, r = _ref7.loop, n = _ref7.extra;
  3270. if (!this.isSelf) {
  3271. _context4.next = 13;
  3272. break;
  3273. }
  3274. if (!this.isMoving) {
  3275. _context4.next = 11;
  3276. break;
  3277. }
  3278. _context4.prev = 3;
  3279. _context4.next = 6;
  3280. return this.stopMoving();
  3281. case 6:
  3282. _context4.next = 11;
  3283. break;
  3284. case 8:
  3285. _context4.prev = 8;
  3286. _context4.t0 = _context4["catch"](3);
  3287. return _context4.abrupt("return", (logger$1.error("stopMoving error before playAnimation ".concat(t), _context4.t0), Promise.reject("stopMoving error before playAnimation ".concat(t))));
  3288. case 11:
  3289. o = {
  3290. info: {
  3291. userId: this.userId,
  3292. animation: t,
  3293. loop: r,
  3294. extra: encodeURIComponent(n || "")
  3295. },
  3296. broadcastType: CoreBroadcastType.PlayAnimation
  3297. };
  3298. this._room.avatarManager.broadcast.broadcast({
  3299. data: o
  3300. });
  3301. case 13:
  3302. return _context4.abrupt("return", (this.emit("animationStart", {
  3303. animationName: t,
  3304. extra: safeDecodeURIComponent(n || "")
  3305. }), this._playAnimation(t, r).then(function () {
  3306. _this2.emit("animationEnd", {
  3307. animationName: t,
  3308. extra: safeDecodeURIComponent(n || "")
  3309. });
  3310. })));
  3311. case 14:
  3312. case "end":
  3313. return _context4.stop();
  3314. }
  3315. }
  3316. }, _callee4, this, [[3, 8]]);
  3317. }));
  3318. function playAnimation(_x4) {
  3319. return _playAnimation.apply(this, arguments);
  3320. }
  3321. return playAnimation;
  3322. }()
  3323. }, {
  3324. key: "beforeChangeComponentsHook",
  3325. value: function () {
  3326. var _beforeChangeComponentsHook = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(e) {
  3327. return regenerator.wrap(function _callee5$(_context5) {
  3328. while (1) {
  3329. switch (_context5.prev = _context5.next) {
  3330. case 0:
  3331. case "end":
  3332. return _context5.stop();
  3333. }
  3334. }
  3335. }, _callee5);
  3336. }));
  3337. function beforeChangeComponentsHook(_x5) {
  3338. return _beforeChangeComponentsHook.apply(this, arguments);
  3339. }
  3340. return beforeChangeComponentsHook;
  3341. }()
  3342. }, {
  3343. key: "turnTo",
  3344. value: function turnTo(e) {
  3345. var _this3 = this;
  3346. if (this._room.viewMode === "observer") {
  3347. this._room.sceneManager.cameraComponent.MainCamera.setTarget(ue4Position2Xverse(e.point));
  3348. return;
  3349. }
  3350. return this._room.actionsHandler.turnTo(e).then(function () {
  3351. _this3.emit("viewChanged", {
  3352. extra: (e == null ? void 0 : e.extra) || ""
  3353. });
  3354. });
  3355. }
  3356. }, {
  3357. key: "moveTo",
  3358. value: function () {
  3359. var _moveTo = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e) {
  3360. var _ref8, t, _ref8$extra, r, a, o;
  3361. return regenerator.wrap(function _callee6$(_context6) {
  3362. while (1) {
  3363. switch (_context6.prev = _context6.next) {
  3364. case 0:
  3365. _ref8 = e || {}, t = _ref8.point, _ref8$extra = _ref8.extra, r = _ref8$extra === void 0 ? "" : _ref8$extra;
  3366. if (this.position) {
  3367. _context6.next = 3;
  3368. break;
  3369. }
  3370. return _context6.abrupt("return", Promise.reject(new ParamError("avatar position is empty")));
  3371. case 3:
  3372. if (!(typeof r != "string" || typeof r == "string" && r.length > 64)) {
  3373. _context6.next = 6;
  3374. break;
  3375. }
  3376. a = "extra shoud be string which length less than 64";
  3377. return _context6.abrupt("return", (logger$1.warn(a), Promise.reject(new ParamError(a))));
  3378. case 6:
  3379. o = util.getDistance(this.position, t) / 100 > 100 ? MotionType.Run : MotionType.Walk;
  3380. return _context6.abrupt("return", this._room.actionsHandler.moveTo({
  3381. point: t,
  3382. motionType: o,
  3383. extra: r
  3384. }));
  3385. case 8:
  3386. case "end":
  3387. return _context6.stop();
  3388. }
  3389. }
  3390. }, _callee6, this);
  3391. }));
  3392. function moveTo(_x6) {
  3393. return _moveTo.apply(this, arguments);
  3394. }
  3395. return moveTo;
  3396. }()
  3397. }, {
  3398. key: "stopMoving",
  3399. value: function () {
  3400. var _stopMoving = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7() {
  3401. return regenerator.wrap(function _callee7$(_context7) {
  3402. while (1) {
  3403. switch (_context7.prev = _context7.next) {
  3404. case 0:
  3405. return _context7.abrupt("return", this._room.actionsHandler.stopMoving());
  3406. case 1:
  3407. case "end":
  3408. return _context7.stop();
  3409. }
  3410. }
  3411. }, _callee7, this);
  3412. }));
  3413. function stopMoving() {
  3414. return _stopMoving.apply(this, arguments);
  3415. }
  3416. return stopMoving;
  3417. }()
  3418. }, {
  3419. key: "rotateTo",
  3420. value: function rotateTo(e) {
  3421. return this._room.actionsHandler.rotateTo(e);
  3422. }
  3423. }, {
  3424. key: "setRayCast",
  3425. value: function setRayCast(e) {
  3426. this.xAvatar && (this.xAvatar.isRayCastEnable = e);
  3427. }
  3428. }, {
  3429. key: "say",
  3430. value: function say(e, t) {
  3431. var _this4 = this;
  3432. if (this.sayTimer && window.clearTimeout(this.sayTimer), !this.xAvatar) {
  3433. logger$1.error("say failed, without instance: xAvatar");
  3434. return;
  3435. }
  3436. this.xAvatar.say(e, {
  3437. scale: this.xAvatar.scale,
  3438. isUser: this.group === AvatarGroup.User
  3439. }), !(t === void 0 || t <= 0) && (this.sayTimer = window.setTimeout(function () {
  3440. _this4.silent();
  3441. }, t));
  3442. }
  3443. }, {
  3444. key: "silent",
  3445. value: function silent() {
  3446. var e;
  3447. if (!this.xAvatar) {
  3448. logger$1.error("silent failed, without instance: xAvatar");
  3449. return;
  3450. }
  3451. (e = this.xAvatar) == null || e.silent();
  3452. }
  3453. }, {
  3454. key: "setMotionType",
  3455. value: function setMotionType(_ref9) {
  3456. var _this5 = this;
  3457. var _ref9$type = _ref9.type,
  3458. e = _ref9$type === void 0 ? MotionType.Walk : _ref9$type;
  3459. return this.motionType === e ? Promise.resolve() : this._room.actionsHandler.setMotionType(e).then(function () {
  3460. _this5._motionType = e;
  3461. });
  3462. }
  3463. }, {
  3464. key: "setNickname",
  3465. value: function setNickname(e) {
  3466. return this._room.actionsHandler.setNickName(encodeURIComponent(e));
  3467. }
  3468. }, {
  3469. key: "_setNickname",
  3470. value: function _setNickname(e) {
  3471. var r, n;
  3472. if (!e) return;
  3473. var t = safeDecodeURIComponent(e);
  3474. ((r = this.xAvatar) == null ? void 0 : r.nickName) !== t && (this.isSelf && (this._room.updateCurrentNetworkOptions({
  3475. nickname: t
  3476. }), this._room.options.nickname = t), (n = this.xAvatar) == null || n.setNickName(t, {
  3477. scale: this.xAvatar.scale
  3478. }));
  3479. }
  3480. }, {
  3481. key: "_move",
  3482. value: function _move(e) {
  3483. var s;
  3484. var _ref10 = e || {},
  3485. t = _ref10.start,
  3486. r = _ref10.end,
  3487. n = _ref10.walkSpeed,
  3488. _ref10$moveAnimation = _ref10.moveAnimation,
  3489. o = _ref10$moveAnimation === void 0 ? "Walking" : _ref10$moveAnimation,
  3490. _ref10$inter = _ref10.inter,
  3491. a = _ref10$inter === void 0 ? [] : _ref10$inter;
  3492. return (s = this.xAvatar) == null ? void 0 : s.move(t, r, n, o, a);
  3493. }
  3494. }, {
  3495. key: "setPickBoxScale",
  3496. value: function setPickBoxScale() {
  3497. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
  3498. return this.xAvatar ? (this.xAvatar.setPickBoxScale(e), !0) : (logger$1.error("setPickBoxScale failed, without instance: xAvatar"), !1);
  3499. }
  3500. }, {
  3501. key: "transfer",
  3502. value: function transfer(e) {
  3503. var t = e.player,
  3504. r = e.camera,
  3505. n = e.areaName,
  3506. o = e.attitude,
  3507. a = e.pathName;
  3508. return this._room.actionsHandler.transfer({
  3509. renderType: RenderType.RotationVideo,
  3510. player: t,
  3511. camera: r,
  3512. areaName: n,
  3513. attitude: o,
  3514. pathName: a,
  3515. tag: "transfer"
  3516. });
  3517. }
  3518. }, {
  3519. key: "avatarLoadedHook",
  3520. value: function avatarLoadedHook() {}
  3521. }, {
  3522. key: "avatarStartMovingHook",
  3523. value: function avatarStartMovingHook() {}
  3524. }, {
  3525. key: "avatarStopMovingHook",
  3526. value: function avatarStopMovingHook() {}
  3527. }, {
  3528. key: "statusSync",
  3529. value: function () {
  3530. var _statusSync = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8(e) {
  3531. var _this6 = this;
  3532. var t, r, n, _e$event$rotateEvent, o, s, _o, _a3, _s;
  3533. return regenerator.wrap(function _callee8$(_context8) {
  3534. while (1) {
  3535. switch (_context8.prev = _context8.next) {
  3536. case 0:
  3537. _context8.prev = 0;
  3538. if (!((t = e.event) != null && t.rotateEvent)) {
  3539. _context8.next = 10;
  3540. break;
  3541. }
  3542. _e$event$rotateEvent = e.event.rotateEvent, o = _e$event$rotateEvent.angle, s = this.motionType === MotionType.Run ? "Running" : "Walking";
  3543. _context8.t0 = this.rotation;
  3544. if (!_context8.t0) {
  3545. _context8.next = 10;
  3546. break;
  3547. }
  3548. this.rotation.yaw = this.rotation.yaw % 360;
  3549. o.yaw - this.rotation.yaw > 180 && (o.yaw = 180 - o.yaw);
  3550. this.isRotating = !0;
  3551. _context8.next = 10;
  3552. return this.xAvatar.rotateTo(o, this.rotation, s).then(function () {
  3553. _this6._playAnimation("Idle", !0), _this6.isRotating = !1;
  3554. });
  3555. case 10:
  3556. if (!(e.event && (((r = e.event) == null ? void 0 : r.points.length) || 0) > 1 && !this.isSelf)) {
  3557. _context8.next = 17;
  3558. break;
  3559. }
  3560. this.isMoving = !0, e.playerState.attitude && (this._motionType = e.playerState.attitude);
  3561. _o = this.motionType === MotionType.Run ? "Running" : "Walking", _a3 = this._room.skin.routeList.find(function (l) {
  3562. return l.areaName === _this6._room.currentState.areaName;
  3563. }), _s = ((_a3 == null ? void 0 : _a3.step) || 7.5) * 30 * (25 / 30);
  3564. _context8.t1 = this.position;
  3565. if (!_context8.t1) {
  3566. _context8.next = 17;
  3567. break;
  3568. }
  3569. _context8.next = 17;
  3570. return this._move({
  3571. start: this.position,
  3572. end: e.event.points[e.event.points.length - 1],
  3573. walkSpeed: _s,
  3574. moveAnimation: _o,
  3575. inter: (n = e.event) == null ? void 0 : n.points.slice(0, -1)
  3576. }).then(function () {
  3577. _this6.isMoving = !1;
  3578. });
  3579. case 17:
  3580. _context8.next = 22;
  3581. break;
  3582. case 19:
  3583. _context8.prev = 19;
  3584. _context8.t2 = _context8["catch"](0);
  3585. return _context8.abrupt("return");
  3586. case 22:
  3587. case "end":
  3588. return _context8.stop();
  3589. }
  3590. }
  3591. }, _callee8, this, [[0, 19]]);
  3592. }));
  3593. function statusSync(_x7) {
  3594. return _statusSync.apply(this, arguments);
  3595. }
  3596. return statusSync;
  3597. }()
  3598. }]);
  3599. return XverseAvatar;
  3600. }(EventEmitter);
  3601. 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); }; }
  3602. 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; } }
  3603. var XverseAvatarManager = /*#__PURE__*/function (_EventEmitter) {
  3604. _inherits(XverseAvatarManager, _EventEmitter);
  3605. var _super = _createSuper$e(XverseAvatarManager);
  3606. function XverseAvatarManager(e) {
  3607. var _this;
  3608. _classCallCheck(this, XverseAvatarManager);
  3609. _this = _super.call(this);
  3610. _this.xAvatarManager = null;
  3611. _this.avatars = new Map();
  3612. _this.syncAvatarsLength = 0;
  3613. _this._room = e;
  3614. _this._usersStatistics();
  3615. _this.broadcast = _this.setupBroadcast();
  3616. e.on("skinChanged", function () {
  3617. _this.avatars.forEach(function (t) {
  3618. t.disconnected && _this.removeAvatar(t.userId, !0);
  3619. });
  3620. });
  3621. return _this;
  3622. }
  3623. _createClass(XverseAvatarManager, [{
  3624. key: "setupBroadcast",
  3625. value: function setupBroadcast() {
  3626. var _this2 = this;
  3627. return new Broadcast$1(this._room, /*#__PURE__*/function () {
  3628. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  3629. var t, r, n, o, a, _r$loop, s, l;
  3630. return regenerator.wrap(function _callee$(_context) {
  3631. while (1) {
  3632. switch (_context.prev = _context.next) {
  3633. case 0:
  3634. t = e.broadcastType, r = e.info;
  3635. if (!(t !== CoreBroadcastType$1.PlayAnimation)) {
  3636. _context.next = 3;
  3637. break;
  3638. }
  3639. return _context.abrupt("return");
  3640. case 3:
  3641. 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);
  3642. _context.t0 = l && !l.isSelf;
  3643. if (!_context.t0) {
  3644. _context.next = 10;
  3645. break;
  3646. }
  3647. l.emit("animationStart", {
  3648. animationName: o,
  3649. extra: decodeURIComponent(a)
  3650. });
  3651. _context.next = 9;
  3652. return l == null ? void 0 : l._playAnimation(o, s);
  3653. case 9:
  3654. l.emit("animationEnd", {
  3655. animationName: o,
  3656. extra: decodeURIComponent(a)
  3657. });
  3658. case 10:
  3659. case "end":
  3660. return _context.stop();
  3661. }
  3662. }
  3663. }, _callee);
  3664. }));
  3665. return function (_x) {
  3666. return _ref.apply(this, arguments);
  3667. };
  3668. }());
  3669. }
  3670. }, {
  3671. key: "hideAll",
  3672. value: function hideAll() {
  3673. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !0;
  3674. this.xAvatarManager.hideAll(e);
  3675. }
  3676. }, {
  3677. key: "showAll",
  3678. value: function showAll() {
  3679. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !0;
  3680. this.xAvatarManager.showAll(e);
  3681. }
  3682. }, {
  3683. key: "init",
  3684. value: function () {
  3685. var _init = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  3686. var e, t;
  3687. return regenerator.wrap(function _callee2$(_context2) {
  3688. while (1) {
  3689. switch (_context2.prev = _context2.next) {
  3690. case 0:
  3691. this.xAvatarManager = this._room.sceneManager.avatarComponent;
  3692. _context2.prev = 1;
  3693. _context2.next = 4;
  3694. return this._room.modelManager.getApplicationConfig();
  3695. case 4:
  3696. e = _context2.sent;
  3697. t = e.avatars;
  3698. if (!t) {
  3699. _context2.next = 10;
  3700. break;
  3701. }
  3702. _context2.next = 9;
  3703. return avatarLoader.parse(this._room.sceneManager, t);
  3704. case 9:
  3705. return _context2.abrupt("return");
  3706. case 10:
  3707. return _context2.abrupt("return", Promise.reject("cannot find avatar config list"));
  3708. case 13:
  3709. _context2.prev = 13;
  3710. _context2.t0 = _context2["catch"](1);
  3711. return _context2.abrupt("return", (logger$1.error(_context2.t0), Promise.reject("avatar mananger init error!")));
  3712. case 16:
  3713. case "end":
  3714. return _context2.stop();
  3715. }
  3716. }
  3717. }, _callee2, this, [[1, 13]]);
  3718. }));
  3719. function init() {
  3720. return _init.apply(this, arguments);
  3721. }
  3722. return init;
  3723. }()
  3724. }, {
  3725. key: "handleAvatar",
  3726. value: function () {
  3727. var _handleAvatar2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  3728. var _this3 = this;
  3729. var r, t, n, o, _n, a;
  3730. return regenerator.wrap(function _callee3$(_context3) {
  3731. while (1) {
  3732. switch (_context3.prev = _context3.next) {
  3733. case 0:
  3734. if (!(this._room.viewMode === "simple" || !this._room.joined || !e.newUserStates)) {
  3735. _context3.next = 2;
  3736. break;
  3737. }
  3738. return _context3.abrupt("return");
  3739. case 2:
  3740. t = e.newUserStates;
  3741. if (((r = this._room._userAvatar) == null ? void 0 : r.isMoving) && this._room._userAvatar.motionType === MotionType.Run) {
  3742. n = t.filter(function (a) {
  3743. return a.userId === _this3._room.userId;
  3744. }), o = t.filter(function (a) {
  3745. return a.userId !== _this3._room.userId;
  3746. }).slice(0, 2);
  3747. t = n.concat(o);
  3748. }
  3749. if (e.getStateType === GetStateTypes.Event) {
  3750. this.syncAvatarsLength = (t || []).length;
  3751. _n = this._room.avatars.filter(function (s) {
  3752. return s.group == AvatarGroup.User;
  3753. });
  3754. _n.filter(function (s) {
  3755. return !(t != null && t.find(function (l) {
  3756. return l.userId == s.userId;
  3757. }));
  3758. }).forEach(function (s) {
  3759. _this3.removeAvatar(s.userId);
  3760. });
  3761. a = t.filter(function (s) {
  3762. return !_n.find(function (l) {
  3763. return l.userId == s.userId;
  3764. });
  3765. });
  3766. this._handleAvatar(a);
  3767. }
  3768. this._handleAvatar(t);
  3769. case 6:
  3770. case "end":
  3771. return _context3.stop();
  3772. }
  3773. }
  3774. }, _callee3, this);
  3775. }));
  3776. function handleAvatar(_x2) {
  3777. return _handleAvatar2.apply(this, arguments);
  3778. }
  3779. return handleAvatar;
  3780. }()
  3781. }, {
  3782. key: "_handleAvatar",
  3783. value: function () {
  3784. var _handleAvatar3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  3785. var _this4 = this;
  3786. return regenerator.wrap(function _callee4$(_context4) {
  3787. while (1) {
  3788. switch (_context4.prev = _context4.next) {
  3789. case 0:
  3790. e == null || e.forEach(function (t) {
  3791. var n, o, a, s, l, u, c, h, f;
  3792. var r = _this4._room.userId === t.userId;
  3793. if (((n = t.event) == null ? void 0 : n.type) === SyncEventType.ET_RemoveVisitor) {
  3794. var d = (a = (o = t.event) == null ? void 0 : o.removeVisitorEvent) == null ? void 0 : a.removeVisitorEvent,
  3795. _ = JSON.parse(safeDecodeURIComponent(((l = (s = t.event) == null ? void 0 : s.removeVisitorEvent) == null ? void 0 : l.extraInfo) || "")),
  3796. g = _.code,
  3797. m = _.msg;
  3798. d === RemoveVisitorType.RVT_ChangeToObserver ? _this4._room.audienceViewModeHook() : d === RemoveVisitorType.RVT_MoveOutOfTheRoom && _this4._room.leave(), _this4._room.emit("visitorStatusChanged", {
  3799. code: g,
  3800. msg: m
  3801. });
  3802. }
  3803. if (t.event && [SyncEventType.Appear, SyncEventType.Reset].includes(t.event.type) || !t.event) {
  3804. var _d = _this4.avatars.get(t.userId);
  3805. if (t.playerState.avatarId && (_d == null ? void 0 : _d.avatarId) !== t.playerState.avatarId && (_d = void 0, _this4.removeAvatar(t.userId)), _d) {
  3806. 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) {
  3807. var _2 = safeParseComponents(t.playerState.avatarComponents);
  3808. _d._changeComponents({
  3809. avatarComponents: _2,
  3810. mode: ChangeComponentsMode.Preview
  3811. });
  3812. }
  3813. } else {
  3814. var _t$playerState$player = t.playerState.player,
  3815. _3 = _t$playerState$player.position,
  3816. _g = _t$playerState$player.angle,
  3817. _m = t.playerState.avatarId,
  3818. v = t.playerState.prioritySync,
  3819. y = safelyJsonParse(t.playerState.extra);
  3820. if (!_m) return;
  3821. var b = safeParseComponents(t.playerState.avatarComponents),
  3822. T = safeDecodeURIComponent(t.playerState.nickName),
  3823. C = _this4.calculatePriority(t.userId, y);
  3824. _this4.addAvatar({
  3825. userId: t.userId,
  3826. isHost: t.playerState.isHost,
  3827. nickname: T,
  3828. avatarPosition: _3,
  3829. avatarRotation: _g,
  3830. avatarScale: t.playerState.avatarSize,
  3831. avatarId: _m,
  3832. avatarComponents: t.playerState.person === Person.First ? [] : b,
  3833. priority: C,
  3834. group: AvatarGroup.User,
  3835. prioritySync: v,
  3836. extraInfo: y
  3837. }).then(function () {
  3838. var A;
  3839. (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"));
  3840. }).catch(function (A) {
  3841. r && (_this4.xAvatarManager.setMainAvatar(t.userId), _this4._room.emit("userAvatarFailed", {
  3842. error: A
  3843. }), logger$1.error("userAvatarFailed", A));
  3844. });
  3845. }
  3846. }
  3847. 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) {
  3848. (h = t == null ? void 0 : t.event) != null && h.id && _this4._room.actionsHandler.confirmEvent(t.event.id);
  3849. var _d2 = _this4.avatars.get(t.userId);
  3850. _d2 && _d2.withModel && !_d2.isLoading && _this4.updateAvatarPositionAndRotation(t);
  3851. }
  3852. if (!r && ((f = t.event) == null ? void 0 : f.type) === SyncEventType.Rotate) {
  3853. var _d3 = _this4.avatars.get(t.userId);
  3854. _d3.statusSyncQueue.append({
  3855. type: QueueType.Rotate,
  3856. action: function action() {
  3857. return _d3.statusSync(t);
  3858. }
  3859. });
  3860. }
  3861. });
  3862. case 1:
  3863. case "end":
  3864. return _context4.stop();
  3865. }
  3866. }
  3867. }, _callee4);
  3868. }));
  3869. function _handleAvatar(_x3) {
  3870. return _handleAvatar3.apply(this, arguments);
  3871. }
  3872. return _handleAvatar;
  3873. }()
  3874. }, {
  3875. key: "calculatePriority",
  3876. value: function calculatePriority(e, t) {
  3877. var n;
  3878. return e === this._room.userId ? EAvatarRelationRank.Self : (n = this._room.options.firends) != null && n.includes(e) ? EAvatarRelationRank.Friend : EAvatarRelationRank.Stranger;
  3879. }
  3880. }, {
  3881. key: "updateAvatarPositionAndRotation",
  3882. value: function updateAvatarPositionAndRotation(e) {
  3883. var t, r;
  3884. if ((t = e == null ? void 0 : e.playerState) != null && t.player) {
  3885. var _e$playerState$player = e.playerState.player,
  3886. n = _e$playerState$player.position,
  3887. o = _e$playerState$player.angle;
  3888. var a = this.avatars.get(e.userId);
  3889. if (!a) return;
  3890. 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({
  3891. type: QueueType.Move,
  3892. action: function action() {
  3893. return a.statusSync(e);
  3894. }
  3895. }), e.renderInfo && a.isSelf) {
  3896. var _e$renderInfo = e.renderInfo,
  3897. s = _e$renderInfo.isMoving,
  3898. l = _e$renderInfo.isRotating;
  3899. this._updateAvatarMovingStatus({
  3900. id: e.userId,
  3901. isMoving: !!s,
  3902. isRotating: !!l
  3903. });
  3904. }
  3905. }
  3906. }
  3907. }, {
  3908. key: "addAvatar",
  3909. value: function () {
  3910. var _addAvatar = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(e) {
  3911. 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;
  3912. return regenerator.wrap(function _callee5$(_context5) {
  3913. while (1) {
  3914. switch (_context5.prev = _context5.next) {
  3915. case 0:
  3916. 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;
  3917. g = this.avatars.get(t);
  3918. if (!g) {
  3919. _context5.next = 4;
  3920. break;
  3921. }
  3922. return _context5.abrupt("return", Promise.resolve(g));
  3923. case 4:
  3924. if (!(g = new XverseAvatarManager.subAvatar({
  3925. userId: t,
  3926. isHost: r,
  3927. isSelf: _,
  3928. room: this._room,
  3929. avatarComponents: l,
  3930. avatarId: o,
  3931. nickname: s,
  3932. group: c
  3933. }), this.avatars.set(t, g), !g.withModel)) {
  3934. _context5.next = 6;
  3935. break;
  3936. }
  3937. return _context5.abrupt("return", (g.isLoading = !1, g.avatarLoadedHook(), this._room.emit("avatarChanged", {
  3938. avatars: this._room.avatars
  3939. }), g));
  3940. case 6:
  3941. _context5.next = 8;
  3942. return this._room.modelManager.getAvatarModelList();
  3943. case 8:
  3944. v = _context5.sent.find(function (b) {
  3945. return b.id === o;
  3946. });
  3947. y = Date.now();
  3948. if (v) {
  3949. _context5.next = 12;
  3950. break;
  3951. }
  3952. return _context5.abrupt("return", (this._room.emit("avatarChanged", {
  3953. avatars: this._room.avatars
  3954. }), this.avatars.delete(t), Promise.reject("no such avatar model with id: ".concat(o))));
  3955. case 12:
  3956. _context5.prev = 12;
  3957. _context5.next = 15;
  3958. return avatarComponentsModify(v, l);
  3959. case 15:
  3960. b = _context5.sent;
  3961. b = b.filter(function (A) {
  3962. return A.type != "pendant";
  3963. });
  3964. _context5.next = 19;
  3965. return avatarComponentsParser(v, b);
  3966. case 19:
  3967. T = _context5.sent;
  3968. _context5.next = 22;
  3969. return this.xAvatarManager.loadAvatar({
  3970. id: t,
  3971. avatarType: o,
  3972. priority: u,
  3973. avatarManager: this.xAvatarManager,
  3974. assets: T,
  3975. status: {
  3976. avatarPosition: n,
  3977. avatarRotation: a,
  3978. avatarScale: h
  3979. }
  3980. })._timeout(8e3, new TimeoutError("loadAvatar timeout(8s)"));
  3981. case 22:
  3982. C = _context5.sent;
  3983. 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", {
  3984. avatars: this._room.avatars
  3985. }), s && g._setNickname(s), t === this._room.userId && (logger$1.infoAndReportMeasurement({
  3986. metric: "avatarLoadDuration",
  3987. startTime: y,
  3988. group: "costs"
  3989. }), logger$1.infoAndReportMeasurement({
  3990. metric: "avatarLoadAt",
  3991. startTime: this._room._startTime,
  3992. group: "costs"
  3993. })), g));
  3994. case 26:
  3995. _context5.prev = 26;
  3996. _context5.t0 = _context5["catch"](12);
  3997. return _context5.abrupt("return", (g.isLoading = !1, this._room.emit("avatarChanged", {
  3998. avatars: this._room.avatars
  3999. }), logger$1.error(_context5.t0), Promise.reject(_context5.t0)));
  4000. case 29:
  4001. case "end":
  4002. return _context5.stop();
  4003. }
  4004. }
  4005. }, _callee5, this, [[12, 26]]);
  4006. }));
  4007. function addAvatar(_x4) {
  4008. return _addAvatar.apply(this, arguments);
  4009. }
  4010. return addAvatar;
  4011. }()
  4012. }, {
  4013. key: "removeAvatar",
  4014. value: function removeAvatar(e) {
  4015. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
  4016. var r = this.avatars.get(e);
  4017. if (!!r) {
  4018. if (r.removeWhenDisconnected || t) {
  4019. r.xAvatar && this.xAvatarManager.deleteAvatar(r.xAvatar), this.avatars.delete(e), this._room.emit("avatarChanged", {
  4020. avatars: this._room.avatars
  4021. });
  4022. return;
  4023. }
  4024. r.setConnectionStatus(!0);
  4025. }
  4026. }
  4027. }, {
  4028. key: "clearOtherUsers",
  4029. value: function clearOtherUsers() {
  4030. var _this5 = this;
  4031. this.avatars.forEach(function (e) {
  4032. !e.isSelf && e.group === AvatarGroup.User && _this5.removeAvatar(e.userId);
  4033. });
  4034. }
  4035. }, {
  4036. key: "_updateAvatarMovingStatus",
  4037. value: function () {
  4038. var _updateAvatarMovingStatus2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e) {
  4039. var t, r, n, o, a, _a;
  4040. return regenerator.wrap(function _callee6$(_context6) {
  4041. while (1) {
  4042. switch (_context6.prev = _context6.next) {
  4043. case 0:
  4044. t = e.id, r = e.isMoving, n = e.isRotating, o = this.avatars.get(t);
  4045. if (!!o) {
  4046. if (o.isRotating !== n) {
  4047. o.isRotating = n;
  4048. a = "Idle";
  4049. n && (a = "Walking", o.motionType === MotionType.Run && (a = "Running")), o._playAnimation(a, !0, !0), logger$1.infoAndReportMeasurement({
  4050. startTime: Date.now(),
  4051. value: 0,
  4052. metric: n ? "userAvatarStartRotating" : "userAvatarStopRotating",
  4053. extra: {
  4054. motionType: o.motionType,
  4055. moveToExtra: this._room.moveToExtra
  4056. }
  4057. });
  4058. }
  4059. if (o.isMoving !== r) {
  4060. o.isMoving = r;
  4061. _a = "Idle";
  4062. r && (_a = "Walking", o.motionType === MotionType.Run && (_a = "Running")), r ? (o.avatarStartMovingHook(), o.emit("startMoving", {
  4063. target: o,
  4064. extra: this._room.moveToExtra
  4065. })) : (o.avatarStopMovingHook(), o.emit("stopMoving", {
  4066. target: o,
  4067. extra: this._room.moveToExtra
  4068. })), o._playAnimation(_a, !0, !0), logger$1.infoAndReportMeasurement({
  4069. startTime: Date.now(),
  4070. value: 0,
  4071. metric: r ? "userAvatarStartMoving" : "userAvatarStopMoving",
  4072. extra: {
  4073. motionType: o.motionType,
  4074. moveToExtra: this._room.moveToExtra
  4075. }
  4076. });
  4077. }
  4078. }
  4079. case 2:
  4080. case "end":
  4081. return _context6.stop();
  4082. }
  4083. }
  4084. }, _callee6, this);
  4085. }));
  4086. function _updateAvatarMovingStatus(_x5) {
  4087. return _updateAvatarMovingStatus2.apply(this, arguments);
  4088. }
  4089. return _updateAvatarMovingStatus;
  4090. }()
  4091. }, {
  4092. key: "_usersStatistics",
  4093. value: function _usersStatistics() {
  4094. var _this6 = this;
  4095. this.on("userAvatarLoaded", function () {
  4096. window.setInterval(function () {
  4097. var e = _this6._room.avatars.filter(function (r) {
  4098. return r.group === AvatarGroup.User;
  4099. }).length || 0,
  4100. t = _this6._room.avatars.filter(function (r) {
  4101. return r.group === AvatarGroup.User && r.isRender;
  4102. }).length || 0;
  4103. _this6._room.stats.assign({
  4104. userNum: e,
  4105. syncUserNum: _this6.syncAvatarsLength,
  4106. renderedUserNum: t
  4107. });
  4108. }, 3e3);
  4109. });
  4110. }
  4111. }]);
  4112. return XverseAvatarManager;
  4113. }(EventEmitter);
  4114. E(XverseAvatarManager, "subAvatar", XverseAvatar);
  4115. var PathManager = /*#__PURE__*/function () {
  4116. function PathManager() {
  4117. _classCallCheck(this, PathManager);
  4118. this.currentArea = '';
  4119. this.currentPathName = '';
  4120. this.currentAttitude = '';
  4121. this.speed = 0;
  4122. }
  4123. _createClass(PathManager, [{
  4124. key: "getSpeed",
  4125. value: function getSpeed(e) {
  4126. var t = {
  4127. guangchang: {
  4128. [MotionType.Walk]: 17,
  4129. [MotionType.Run]: 51
  4130. },
  4131. tower: {
  4132. [MotionType.Walk]: 12.5,
  4133. [MotionType.Run]: 25
  4134. },
  4135. zhiboting: {
  4136. [MotionType.Walk]: 12.5,
  4137. [MotionType.Run]: 25
  4138. },
  4139. youxiting: {
  4140. [MotionType.Walk]: 12.5,
  4141. [MotionType.Run]: 25
  4142. },
  4143. diqing: {
  4144. [MotionType.Walk]: 12.5,
  4145. [MotionType.Run]: 25
  4146. }
  4147. },
  4148. r = t[this.currentArea] || t.guangchang;
  4149. return this.speed = r[e] * 30, this.speed;
  4150. }
  4151. }]);
  4152. return PathManager;
  4153. }();
  4154. var CameraStates = {
  4155. Normal: 0,
  4156. ItemView: 1,
  4157. CGView: 2,
  4158. PathView: 3
  4159. };
  4160. var EImageQuality = {
  4161. low: 0,
  4162. mid: 1,
  4163. high: 2
  4164. };
  4165. var Actions = {
  4166. Clicking: 1,
  4167. PlayCG: 6,
  4168. Back: 7,
  4169. ChangeRoom: 8,
  4170. ChangeSkin: 13,
  4171. Joystick: 15,
  4172. Transfer: 18,
  4173. GetOnVehicle: 22,
  4174. GetOffVehicle: 23,
  4175. StopMoving: 34,
  4176. UnaryActionLine: 1e3,
  4177. Init: 1001,
  4178. Exit: 1002,
  4179. SetIFrameInfo: 1003,
  4180. GetNeighborPoints: 1004,
  4181. ReserveSeat: 1005,
  4182. GetReserveStatus: 1006,
  4183. ChangeNickname: 1007,
  4184. ChangeBitRateInfo: 1008,
  4185. Echo: 1009,
  4186. SetPlayerState: 1010,
  4187. TurnTo: 1011,
  4188. TurnToFace: 1012,
  4189. RotateTo: 1013,
  4190. Rotation: 1014,
  4191. CameraTurnTo: 1015,
  4192. ConfirmEvent: 1016,
  4193. Broadcast: 1017,
  4194. NotifyActionLine: 2e4,
  4195. AudienceChangeToVisitor: 1020,
  4196. VisitorChangeToAudience: 1021,
  4197. RemoveVisitor: 1022,
  4198. GetUserWithAvatar: 1023
  4199. };
  4200. 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); }; }
  4201. 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; } }
  4202. var Camera = /*#__PURE__*/function (_EventEmitter) {
  4203. _inherits(Camera, _EventEmitter);
  4204. var _super = _createSuper$d(Camera);
  4205. function Camera(e) {
  4206. var _this;
  4207. _classCallCheck(this, Camera);
  4208. _this = _super.call(this);
  4209. _this.initialFov = 0;
  4210. _this._state = CameraStates.Normal;
  4211. _this._person = Person.Third;
  4212. _this._cameraFollowing = !0;
  4213. _this._room = e;
  4214. return _this;
  4215. }
  4216. _createClass(Camera, [{
  4217. key: "checkPointOnLeftOrRight",
  4218. value: function checkPointOnLeftOrRight(e) {
  4219. var t = ue4Position2Xverse(e);
  4220. if (!t || this.checkPointInView(e)) return;
  4221. var o = this._room.scene.activeCamera;
  4222. if (!o) return;
  4223. var a = [o.target.x, o.target.y, o.target.z],
  4224. s = [o.position.x, o.position.y, o.position.z],
  4225. l = t.x,
  4226. u = t.y,
  4227. c = t.z,
  4228. h = calNormVector(s, a),
  4229. f = calNormVector(s, [l, u, c]);
  4230. return vectorCrossMulti(h, f) < 0 ? Direction.Right : Direction.Left;
  4231. }
  4232. }, {
  4233. key: "checkPointInView",
  4234. value: function checkPointInView(e, t, r) {
  4235. var n = ue4Position2Xverse({
  4236. x: e,
  4237. y: t,
  4238. z: r
  4239. });
  4240. if (!n) return !1;
  4241. for (var o = 0; o < 6; o++) {
  4242. if (this._room.scene.frustumPlanes[o].dotCoordinate(n) < 0) return !1;
  4243. }
  4244. return !0;
  4245. }
  4246. }, {
  4247. key: "person",
  4248. get: function get() {
  4249. return this._person;
  4250. }
  4251. }, {
  4252. key: "state",
  4253. get: function get() {
  4254. return this._state;
  4255. }
  4256. }, {
  4257. key: "pose",
  4258. get: function get() {
  4259. return this._room.currentClickingState.camera;
  4260. }
  4261. }, {
  4262. key: "cameraFollowing",
  4263. get: function get() {
  4264. return this._cameraFollowing;
  4265. },
  4266. set: function set(e) {
  4267. logger$1.info("cameraFollowing setter", e), this.setCameraFollowing({
  4268. isFollowHost: e
  4269. });
  4270. }
  4271. }, {
  4272. key: "setCameraFollowing",
  4273. value: function setCameraFollowing(_ref) {
  4274. _ref.isFollowHost;
  4275. }
  4276. }, {
  4277. key: "handleRenderInfo",
  4278. value: function handleRenderInfo(e) {
  4279. var t = e.renderInfo.cameraStateType,
  4280. r = this._room.sceneManager;
  4281. 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", {
  4282. state: t
  4283. })), this._room.isHost) return;
  4284. var n = e.playerState.isFollowHost;
  4285. !!n !== this._cameraFollowing && (this._cameraFollowing = !!n, this.emit("cameraFollowingChanged", {
  4286. cameraFollowing: !!n
  4287. }));
  4288. }
  4289. }, {
  4290. key: "setCameraState",
  4291. value: function setCameraState(_ref2) {
  4292. var e = _ref2.state;
  4293. if (this._state === e) {
  4294. logger$1.warn("You are already in ".concat(CameraStates[e], " camera state"));
  4295. return;
  4296. }
  4297. e === CameraStates.Normal || this._state === CameraStates.ItemView && logger$1.warn("CloseUp camera state can only be triggerd by room internally");
  4298. }
  4299. }, {
  4300. key: "turnToFace",
  4301. value: function turnToFace(_ref3) {
  4302. var _ref3$extra = _ref3.extra,
  4303. e = _ref3$extra === void 0 ? "" : _ref3$extra,
  4304. _ref3$offset = _ref3.offset,
  4305. t = _ref3$offset === void 0 ? 0 : _ref3$offset;
  4306. var r = {
  4307. action_type: Actions.TurnToFace,
  4308. turn_to_face_action: {
  4309. offset: t
  4310. }
  4311. };
  4312. return this.emit("viewChanged", {
  4313. extra: e
  4314. }), this._room.actionsHandler.sendData({
  4315. data: r
  4316. });
  4317. }
  4318. }, {
  4319. key: "isInDefaultView",
  4320. value: function isInDefaultView() {
  4321. if (!this._room.isHost) {
  4322. logger$1.warn("It is recommended to call the function on the host side");
  4323. return;
  4324. }
  4325. if (!this._room._currentClickingState) return logger$1.error("CurrentState should not be empty"), !1;
  4326. var _this$_room$_currentC = this._room._currentClickingState,
  4327. e = _this$_room$_currentC.camera,
  4328. t = _this$_room$_currentC.player;
  4329. return Math.abs(t.angle.yaw - 180 - e.angle.yaw) % 360 <= 4;
  4330. }
  4331. }, {
  4332. key: "screenShot",
  4333. value: function () {
  4334. var _screenShot = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(_ref4) {
  4335. var e, _ref4$autoSave, t, r, n, o;
  4336. return regenerator.wrap(function _callee$(_context) {
  4337. while (1) {
  4338. switch (_context.prev = _context.next) {
  4339. case 0:
  4340. e = _ref4.name, _ref4$autoSave = _ref4.autoSave, t = _ref4$autoSave === void 0 ? !1 : _ref4$autoSave;
  4341. r = this._room.scene.getEngine(), n = this._room.scene.activeCamera;
  4342. _context.prev = 2;
  4343. this._room.sceneManager.setImageQuality(EImageQuality.high);
  4344. _context.next = 6;
  4345. return CreateScreenshotAsync(r, n, {
  4346. precision: 1
  4347. });
  4348. case 6:
  4349. o = _context.sent;
  4350. return _context.abrupt("return", (this._room.sceneManager.setImageQuality(EImageQuality.low), t === !0 && downloadFileByBase64(o, e), Promise.resolve(o)));
  4351. case 10:
  4352. _context.prev = 10;
  4353. _context.t0 = _context["catch"](2);
  4354. return _context.abrupt("return", (this._room.sceneManager.setImageQuality(EImageQuality.low), Promise.reject(_context.t0)));
  4355. case 13:
  4356. case "end":
  4357. return _context.stop();
  4358. }
  4359. }
  4360. }, _callee, this, [[2, 10]]);
  4361. }));
  4362. function screenShot(_x) {
  4363. return _screenShot.apply(this, arguments);
  4364. }
  4365. return screenShot;
  4366. }()
  4367. }, {
  4368. key: "changeToFirstPerson",
  4369. value: function changeToFirstPerson(e, t, r) {
  4370. var _this2 = this;
  4371. var n = e.camera,
  4372. o = e.player,
  4373. a = e.attitude,
  4374. s = e.areaName,
  4375. l = e.pathName;
  4376. return this._room.actionsHandler.requestPanorama({
  4377. camera: n,
  4378. player: o,
  4379. attitude: a,
  4380. areaName: s,
  4381. pathName: l
  4382. }, t, r).then(function () {
  4383. _this2._room.networkController.rtcp.workers.changePanoMode(!0);
  4384. var _ref5 = o || {},
  4385. u = _ref5.position,
  4386. c = _ref5.angle;
  4387. _this2._room.sceneManager.cameraComponent.changeToFirstPersonView({
  4388. position: u,
  4389. rotation: c
  4390. });
  4391. });
  4392. }
  4393. }, {
  4394. key: "setPerson",
  4395. value: function setPerson(e) {
  4396. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
  4397. camera: this._room._currentClickingState.camera,
  4398. player: this._room._currentClickingState.player
  4399. };
  4400. var r = Date.now();
  4401. return this._setPerson(e, t).then(function (n) {
  4402. return logger$1.infoAndReportMeasurement({
  4403. tag: Person[e],
  4404. startTime: r,
  4405. metric: "setPerson"
  4406. }), n;
  4407. }).catch(function (n) {
  4408. return logger$1.infoAndReportMeasurement({
  4409. tag: Person[e],
  4410. startTime: r,
  4411. metric: "setPerson",
  4412. error: n
  4413. }), Promise.reject(n);
  4414. });
  4415. }
  4416. }, {
  4417. key: "_setPerson",
  4418. value: function _setPerson(e) {
  4419. var _this3 = this;
  4420. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
  4421. camera: this._room._currentClickingState.camera,
  4422. player: this._room._currentClickingState.player
  4423. };
  4424. 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({
  4425. camera: t.camera,
  4426. player: t.player,
  4427. tag: "setPerson"
  4428. }).then(function () {
  4429. var o, a;
  4430. _this3._person = e, (o = _this3._room._userAvatar) == null || o.hide();
  4431. var _ref6 = ((a = _this3._room.currentClickingState) == null ? void 0 : a.camera) || {},
  4432. r = _ref6.position,
  4433. n = _ref6.angle;
  4434. !r || !n || _this3._room.sceneManager.cameraComponent.changeToFirstPersonView({
  4435. position: r,
  4436. rotation: n
  4437. });
  4438. }) : this._room.panorama.exit({
  4439. camera: t.camera,
  4440. player: t.player
  4441. }).then(function () {
  4442. var r, n;
  4443. _this3._person = e, (r = _this3._room._userAvatar) != null && r.xAvatar && ((n = _this3._room._userAvatar) == null || n.xAvatar.show());
  4444. });
  4445. }
  4446. }, {
  4447. key: "setCameraPose",
  4448. value: function setCameraPose(e) {
  4449. this._room.sceneManager.cameraComponent.setCameraPose({
  4450. position: e.position,
  4451. rotation: e.angle
  4452. });
  4453. }
  4454. }, {
  4455. key: "setMainCameraRotationLimit",
  4456. value: function setMainCameraRotationLimit(e) {
  4457. var t = e.limitAxis,
  4458. r = e.limitRotation;
  4459. this._room.sceneManager.cameraComponent.setMainCameraRotationLimit(t, r);
  4460. }
  4461. }]);
  4462. return Camera;
  4463. }(EventEmitter);
  4464. 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); }; }
  4465. 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; } }
  4466. var numberFormat = new Intl.NumberFormat(window.navigator.language, {
  4467. maximumFractionDigits: 0
  4468. });
  4469. var Stats = /*#__PURE__*/function (_EventEmitter) {
  4470. _inherits(Stats, _EventEmitter);
  4471. var _super = _createSuper$c(Stats);
  4472. function Stats(e) {
  4473. var _this;
  4474. _classCallCheck(this, Stats);
  4475. _this = _super.call(this);
  4476. _this._netInterval = null;
  4477. _this._disabled = !1;
  4478. _this._show = !1;
  4479. _this._aggregatedStats = {};
  4480. _this._displayElement = null;
  4481. _this._extraStats = {};
  4482. _this._networkSamples = [];
  4483. _this.externalStats = null;
  4484. _this.constructedTime = null;
  4485. _this.room = e, _this.constructedTime = Date.now(), _this._interval = window.setInterval(function () {
  4486. var t, r, n;
  4487. _this._disabled || _this.onStats((n = (r = (t = e.networkController) == null ? void 0 : t.rtcp) == null ? void 0 : r.workers) == null ? void 0 : n.uploadDataToServer());
  4488. }, 1e3), _this._netInterval = window.setInterval(function () {
  4489. _this.getIsWeakNet();
  4490. }, NET_INTERVAL * 1e3);
  4491. return _this;
  4492. }
  4493. _createClass(Stats, [{
  4494. key: "isShow",
  4495. get: function get() {
  4496. return this._show;
  4497. }
  4498. }, {
  4499. key: "assign",
  4500. value: function assign(e) {
  4501. Object.assign(this._extraStats, e), ((e == null ? void 0 : e.hb) || (e == null ? void 0 : e.rtt)) && this.startStatsNetSamples();
  4502. }
  4503. }, {
  4504. key: "appendExternalStats",
  4505. value: function appendExternalStats(e) {
  4506. var _this2 = this;
  4507. var t = {};
  4508. if (!e || typeof e != "object") {
  4509. console.warn("appendExternalStats should be plain object");
  4510. return;
  4511. }
  4512. Object.keys(e).forEach(function (r) {
  4513. Object.prototype.hasOwnProperty.call(_this2._aggregatedStats, r) ? console.warn("".concat(r, " is duplicate with internal stats")) : t[r] = e[r];
  4514. }), !(Object.keys(t).length > 10) && (this.externalStats = t);
  4515. }
  4516. }, {
  4517. key: "getRtt",
  4518. value: function getRtt() {
  4519. var e = this._extraStats.rtt;
  4520. return typeof e != "number" ? 0 : e > 999 ? 999 : e;
  4521. }
  4522. }, {
  4523. key: "enable",
  4524. value: function enable() {
  4525. this._disabled = !1;
  4526. }
  4527. }, {
  4528. key: "disable",
  4529. value: function disable() {
  4530. this._disabled = !0;
  4531. }
  4532. }, {
  4533. key: "disableNet",
  4534. value: function disableNet() {
  4535. this._netInterval && window.clearInterval(this._netInterval);
  4536. }
  4537. }, {
  4538. key: "show",
  4539. value: function show() {
  4540. this._show = !0, this._render();
  4541. }
  4542. }, {
  4543. key: "hide",
  4544. value: function hide() {
  4545. this._show = !1, this._displayElement && document.body.removeChild(this._displayElement), this._displayElement = null;
  4546. }
  4547. }, {
  4548. key: "getIsWeakNet",
  4549. value: function getIsWeakNet() {
  4550. var _this3 = this;
  4551. var e = !1;
  4552. var t = this._networkSamples.length - 1;
  4553. if (t < 0) return;
  4554. var r = this._networkSamples[t].time,
  4555. n = this._networkSamples[0].time,
  4556. o = r - n,
  4557. a = 1e3 * (DURATION - 2);
  4558. if (o < a) return;
  4559. var s = this._networkSamples.map(function (g) {
  4560. return _this3.isNetDelay(g, "rtt");
  4561. }),
  4562. l = this._networkSamples.map(function (g) {
  4563. return _this3.isNetDelay(g, "hb");
  4564. }),
  4565. u = s.reduce(function (g, m) {
  4566. return g + m;
  4567. }, 0),
  4568. c = l.reduce(function (g, m) {
  4569. return g + m;
  4570. }, 0),
  4571. h = Math.floor(u / this._networkSamples.length) * 100,
  4572. f = Math.floor(c / this._networkSamples.length) * 100,
  4573. d = 70;
  4574. (h >= d || f >= d) && (e = !0);
  4575. var _ = this.room.viewMode === "observer" || this.room.viewMode === "serverless";
  4576. e && !_ && (logger$1.infoAndReportMeasurement({
  4577. metric: "weakNetwork",
  4578. startTime: Date.now(),
  4579. extra: {
  4580. msg: this._networkSamples.slice(20),
  4581. netDelayRTTValues: u,
  4582. netDelayHBValues: c
  4583. }
  4584. }), this.emit("weakNetwork"));
  4585. }
  4586. }, {
  4587. key: "startStatsNetSamples",
  4588. value: function startStatsNetSamples() {
  4589. var _this$_extraStats = this._extraStats,
  4590. e = _this$_extraStats.rtt,
  4591. t = _this$_extraStats.hb;
  4592. if (e || t) {
  4593. var r = {
  4594. rtt: e,
  4595. hb: t,
  4596. time: new Date().getTime()
  4597. };
  4598. this._networkSamples.push(r);
  4599. var n = this._networkSamples.length - 1;
  4600. if (n < 0) return;
  4601. var o = this._networkSamples[n].time,
  4602. a = 1e3 * DURATION;
  4603. this._networkSamples = this._networkSamples.filter(function (s) {
  4604. return s.time > o - a;
  4605. });
  4606. }
  4607. }
  4608. }, {
  4609. key: "isNetDelay",
  4610. value: function isNetDelay(e, t) {
  4611. return t === "rtt" ? e.rtt > RTT_MAX_VALUE ? 1 : 0 : t === "hb" && e.hb > HB_MAX_VALUE ? 1 : 0;
  4612. }
  4613. }, {
  4614. key: "getPreciesTimer",
  4615. value: function getPreciesTimer(e, t) {
  4616. var r = t * 1e3,
  4617. n = new Date().getTime();
  4618. var o = 0;
  4619. o++;
  4620. var a = new Date().getTime() - (n + o * 1e3),
  4621. s = r - a,
  4622. l = setTimeout(function () {
  4623. clearTimeout(l), e();
  4624. }, s);
  4625. }
  4626. }, {
  4627. key: "_render",
  4628. value: function _render() {
  4629. var c, h, f, d, _, g, m, v, y, b, T, C, A, S, P, R, M, x, I, w;
  4630. if (!this._aggregatedStats) return;
  4631. 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));
  4632. var e = [],
  4633. t = Date.now() - this.constructedTime,
  4634. r = Math.floor(t / 1e3 % 60),
  4635. n = Math.floor(t / (1e3 * 60) % 60),
  4636. o = Math.floor(t / (1e3 * 60 * 60) % 24),
  4637. a = o < 10 ? "0" + o.toString() : o.toString(),
  4638. s = n < 10 ? "0" + n : n,
  4639. l = r < 10 ? "0" + r : r;
  4640. e.push({
  4641. key: new Date(Math.floor(this._aggregatedStats.timestamp || 0)).toLocaleString("en-GB"),
  4642. value: a + ":" + s + ":" + l
  4643. }), e.push({
  4644. key: "rtt: " + this._extraStats.rtt + " hb: " + this._extraStats.hb,
  4645. value: "FPS: " + this._extraStats.fps + " avatar: " + ((c = this.room._userAvatar) == null ? void 0 : c.state)
  4646. }), e.push({
  4647. key: "SDK: " + Xverse$1.SUB_PACKAGE_VERSION,
  4648. value: "ENGINE:" + VERSION$1 + " uid:" + this._extraStats.userId
  4649. }), e.push({
  4650. key: "\u540C\u6B65/\u6709\u6548/\u663E\u793A\u73A9\u5BB6",
  4651. value: "".concat(this._extraStats.syncUserNum || 0, "/").concat(this._extraStats.userNum || 0, "/").concat(this._extraStats.renderedUserNum || 0)
  4652. }), e.push({
  4653. key: "media/meta bitrate(kbps)",
  4654. value: numberFormat.format(this._aggregatedStats.mediaBitrate || 0) + "/" + numberFormat.format(this._aggregatedStats.metaBitrate || 0)
  4655. }), e.push({
  4656. key: ":----------------Decoding---------------",
  4657. value: ""
  4658. }), e.push({
  4659. key: "-max/avg decodeTime(ms)",
  4660. value: numberFormat.format(this._aggregatedStats.decodeTimeMaxFrame || 0) + "/" + numberFormat.format(this._aggregatedStats.decodeTimePerFrame || 0)
  4661. }), e.push({
  4662. key: "-frmAwait/Lost/Drop",
  4663. 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
  4664. }), e.push({
  4665. key: ":----------------FrameLoop-------------",
  4666. value: ""
  4667. }), e.push({
  4668. key: "interval(max/avg/>40)",
  4669. 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
  4670. }), e.push({
  4671. key: "systemStuck",
  4672. value: this._extraStats.systemStuckCnt
  4673. }), e.push({
  4674. key: "--update",
  4675. value: (this._aggregatedStats.maxGraphicTime.toFixed(1) || 0) + "/" + (((d = this._aggregatedStats.averageGraphicTime) == null ? void 0 : d.toFixed(0)) || 0)
  4676. }), e.push({
  4677. key: "--timeout",
  4678. value: (((_ = this._extraStats.maxTimeoutTime) == null ? void 0 : _.toFixed(1)) || 0) + "/" + ((g = this._extraStats.avgTimeoutTime) == null ? void 0 : g.toFixed(0)) || 0
  4679. }), e.push({
  4680. key: "--render",
  4681. value: (((m = this._extraStats.maxRenderFrameTime) == null ? void 0 : m.toFixed(1)) || 0) + "/" + (((v = this._extraStats.renderFrameTime) == null ? void 0 : v.toFixed(0)) || 0)
  4682. }), e.push({
  4683. key: "---anim/regBR/clip(avg ms)",
  4684. value: (this._extraStats.animationTime.toFixed(2) || 0) + " / " + (this._extraStats.registerBeforeRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.meshSelectTime.toFixed(2) || 0)
  4685. }), e.push({
  4686. key: "---anim/regBR/clip(max ms)",
  4687. value: (this._extraStats.maxAnimationTime.toFixed(2) || 0) + " / " + (this._extraStats.maxRegisterBeforeRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.maxMeshSelectTime.toFixed(2) || 0)
  4688. }), e.push({
  4689. key: "---rTR/drC/regAF(avg ms)",
  4690. value: (this._extraStats.renderTargetRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.drawcallTime.toFixed(2) || 0) + " / " + (this._extraStats.registerAfterRenderTime.toFixed(2) || 0)
  4691. }), e.push({
  4692. key: "---rTR/drC/regAF(max ms)",
  4693. value: (this._extraStats.maxRenderTargetRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.maxDrawcallTime.toFixed(2) || 0) + " / " + (this._extraStats.maxRegisterAfterRenderTime.toFixed(2) || 0)
  4694. }), e.push({
  4695. key: "--tri/drC/pati/bones/anim(Num)",
  4696. 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)
  4697. }), e.push({
  4698. key: "--rootN/mesh/geo/tex/mat(Num)",
  4699. 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)
  4700. }), e.push({
  4701. key: "--registerBF/AF(Num)",
  4702. value: (this._extraStats.registerBeforeCount.toFixed(0) || 0) + " / " + (this._extraStats.registerAfterCount.toFixed(0) || 0)
  4703. }), e.push({
  4704. key: ":----------------Rotation-------------------",
  4705. value: ""
  4706. }), e.push({
  4707. key: "Total(ms/miss)",
  4708. value: (((y = this._aggregatedStats.avgOverallTime) == null ? void 0 : y.toFixed(2)) || 0) + "/" + (this._aggregatedStats.responseMissPs + this._aggregatedStats.processMissPs + this._aggregatedStats.displayMissPs)
  4709. }), e.push({
  4710. key: "--rotateRsp",
  4711. value: (((b = this._aggregatedStats.avgResponseTime) == null ? void 0 : b.toFixed(1)) || 0) + "/" + this._aggregatedStats.responseMissPs
  4712. }), e.push({
  4713. key: "--rotateProc",
  4714. value: (((T = this._aggregatedStats.avgProcessTime) == null ? void 0 : T.toFixed(1)) || 0) + "/" + this._aggregatedStats.processMissPs
  4715. }), e.push({
  4716. key: "--rotateShow",
  4717. value: (((C = this._aggregatedStats.avgDisplayTime) == null ? void 0 : C.toFixed(1)) || 0) + "/" + this._aggregatedStats.displayMissPs
  4718. }), ((A = this.room._userAvatar) == null ? void 0 : A.state) == "moving", e.push({
  4719. key: ":----------------Move----------------------",
  4720. value: ""
  4721. }), e.push({
  4722. key: "-startDelay",
  4723. 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)
  4724. }), (((S = this.room._userAvatar) == null ? void 0 : S.state) == "moving" || this._aggregatedStats.moveEvent == "GetOnAirship" || this._aggregatedStats.moveEvent == "GetOnVehicle") && e.push({
  4725. key: "-srvInterFrm(max/avg)",
  4726. value: (this._aggregatedStats.maxServerDiff || 0) + "/" + (this._aggregatedStats.avgServerDiff.toFixed(1) || 0)
  4727. }), e.push({
  4728. key: "-interFrameDelay",
  4729. value: "(max/avg/jank)"
  4730. }), e.push({
  4731. key: "--toDisplay",
  4732. 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)
  4733. }), e.push({
  4734. key: "--received",
  4735. 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)
  4736. }), e.push({
  4737. key: "--decoded",
  4738. 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)
  4739. }), e.push({
  4740. key: ":----------------DevInfo-----------------",
  4741. value: ""
  4742. }), e.push({
  4743. key: "sd",
  4744. value: (this._aggregatedStats.sdMoveResponseLongTime.toFixed(1) || 0) + "/" + (this._aggregatedStats.sdMoveProcessLongTime.toFixed(1) || 0) + "/" + (this._aggregatedStats.sdMoveDisplayLongTime.toFixed(1) || 0)
  4745. }), e.push({
  4746. key: "----hardwareInfo",
  4747. value: this._extraStats.hardwareInfo
  4748. });
  4749. var u = "";
  4750. for (var _i = 0, _e = e; _i < _e.length; _i++) {
  4751. var O = _e[_i];
  4752. u += "<div><span>".concat(O.key, "</span>: <span>").concat(O.value, "</span> </div>");
  4753. }
  4754. this._displayElement.innerHTML = u;
  4755. }
  4756. }, {
  4757. key: "onStats",
  4758. value: function onStats(e) {
  4759. var _this4 = this;
  4760. var n;
  4761. if (!e) return;
  4762. var t = {},
  4763. r = this;
  4764. 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) {
  4765. t[o] = _this4.externalStats[o];
  4766. }), r._aggregatedStats = t, this.emit("stats", {
  4767. stats: t
  4768. });
  4769. }
  4770. }]);
  4771. return Stats;
  4772. }(EventEmitter);
  4773. 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); }; }
  4774. 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; } }
  4775. var EventsManager = /*#__PURE__*/function (_EventEmitter) {
  4776. _inherits(EventsManager, _EventEmitter);
  4777. var _super = _createSuper$b(EventsManager);
  4778. function EventsManager() {
  4779. var _this;
  4780. _classCallCheck(this, EventsManager);
  4781. _this = _super.apply(this, arguments);
  4782. E(_assertThisInitialized(_this), "events", new Map());
  4783. E(_assertThisInitialized(_this), "specialEvents", new Map());
  4784. return _this;
  4785. }
  4786. _createClass(EventsManager, [{
  4787. key: "remove",
  4788. value: function remove(e, t, r, n) {
  4789. if (this.specialEvents.has(e) && !n && t === Codes.Success) return;
  4790. this.events.get(e) && (this.emit(e, {
  4791. code: t,
  4792. data: r
  4793. }), this.events.delete(e), this.specialEvents.delete(e));
  4794. }
  4795. }, {
  4796. key: "track",
  4797. value: function () {
  4798. var _track = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e, t) {
  4799. var _this2 = this;
  4800. var r, _ref, n, _ref$noReport, o, a, s, l, u, c;
  4801. return regenerator.wrap(function _callee$(_context) {
  4802. while (1) {
  4803. switch (_context.prev = _context.next) {
  4804. case 0:
  4805. r = e.traceId;
  4806. this.emitTraceIdToDecoder(e);
  4807. _ref = t || {}, n = _ref.sampleRate, _ref$noReport = _ref.noReport, o = _ref$noReport === void 0 ? !1 : _ref$noReport, a = _ref.special;
  4808. if (!(n && Math.random() > n)) {
  4809. _context.next = 5;
  4810. break;
  4811. }
  4812. return _context.abrupt("return", Promise.resolve());
  4813. case 5:
  4814. s = Actions[e.event] + "Action", l = e.tag;
  4815. this.events.set(r, !0), a && this.specialEvents.set(r, !0);
  4816. u = Date.now();
  4817. c = null;
  4818. return _context.abrupt("return", new Promise(function (h, f) {
  4819. if (o) return _this2.off(r), _this2.events.delete(r), h(void 0);
  4820. _this2.on(r, function (_ref2) {
  4821. var _ = _ref2.code,
  4822. g = _ref2.data,
  4823. m = _ref2.msg;
  4824. if (_ === Codes.Success) h(g), _this2.off(r), logger$1.infoAndReportMeasurement({
  4825. metric: s,
  4826. tag: l,
  4827. extra: e.extra,
  4828. startTime: u,
  4829. traceId: r
  4830. });else {
  4831. if (_ === Codes.ActionMaybeDelay) return;
  4832. if (_ === Codes.DoActionBlocked && e.event === Actions.Rotation) {
  4833. logger$1.debug(s + " response code: " + _);
  4834. return;
  4835. }
  4836. var v = util.getErrorByCode(_),
  4837. y = new v(m);
  4838. _this2.off(r), f(y), _this2.emit("actionResponseError", {
  4839. error: y,
  4840. event: e,
  4841. tag: l
  4842. }), logger$1.infoAndReportMeasurement({
  4843. metric: s,
  4844. tag: l,
  4845. extra: e.extra,
  4846. error: y,
  4847. startTime: u,
  4848. traceId: r
  4849. });
  4850. }
  4851. });
  4852. var d = e.timeout || 2e3;
  4853. c = window.setTimeout(function () {
  4854. if (c && clearTimeout(c), !_this2.events.get(r)) return;
  4855. var _ = new ActionResponseTimeoutError("".concat(s, " timeout in ").concat(d, "ms"));
  4856. _this2.emit("actionResponseTimeout", {
  4857. error: _,
  4858. event: e,
  4859. tag: l
  4860. }), f(_), _this2.events.delete(r), _this2.off(r), logger$1.infoAndReportMeasurement({
  4861. metric: s,
  4862. tag: l,
  4863. extra: e.extra,
  4864. error: _,
  4865. startTime: u,
  4866. traceId: r
  4867. });
  4868. }, d);
  4869. }));
  4870. case 10:
  4871. case "end":
  4872. return _context.stop();
  4873. }
  4874. }
  4875. }, _callee, this);
  4876. }));
  4877. function track(_x, _x2) {
  4878. return _track.apply(this, arguments);
  4879. }
  4880. return track;
  4881. }()
  4882. }, {
  4883. key: "emitTraceIdToDecoder",
  4884. value: function emitTraceIdToDecoder(e) {
  4885. if (e.event === Actions.Rotation || e.event === Actions.Clicking || e.event === Actions.GetOnVehicle || e.event === Actions.GetOffVehicle) {
  4886. var t = {
  4887. [Actions.Rotation]: "Rotation",
  4888. [Actions.GetOnVehicle]: "GetOnVehicle",
  4889. [Actions.GetOffVehicle]: "GetOffVehicle",
  4890. [Actions.Clicking]: "MoveTo"
  4891. };
  4892. this.emit("traceId", {
  4893. traceId: e.traceId,
  4894. timestamp: Date.now(),
  4895. event: t[e.event]
  4896. });
  4897. }
  4898. }
  4899. }]);
  4900. return EventsManager;
  4901. }(EventEmitter);
  4902. var eventsManager = new EventsManager();
  4903. var ClickType = {
  4904. Screen: 0,
  4905. ThreeDimension: 1,
  4906. ThreeDimensionQuick: 2,
  4907. IgnoreView: 3
  4908. };
  4909. var QueueActions = [Actions.Transfer, Actions.ChangeSkin, Actions.GetOnVehicle, Actions.GetOffVehicle];
  4910. var ActionsHandler = /*#__PURE__*/function () {
  4911. function ActionsHandler(e) {
  4912. _classCallCheck(this, ActionsHandler);
  4913. this.currentActiveAction = null;
  4914. this.room = e;
  4915. }
  4916. _createClass(ActionsHandler, [{
  4917. key: "avatarComponentsSync",
  4918. value: function () {
  4919. var _avatarComponentsSync = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  4920. var t;
  4921. return regenerator.wrap(function _callee$(_context) {
  4922. while (1) {
  4923. switch (_context.prev = _context.next) {
  4924. case 0:
  4925. t = {
  4926. action_type: Actions.SetPlayerState,
  4927. set_player_state_action: {
  4928. player_state: {
  4929. avatar_components: JSON.stringify(e)
  4930. }
  4931. }
  4932. };
  4933. this.sendData({
  4934. data: t
  4935. });
  4936. case 2:
  4937. case "end":
  4938. return _context.stop();
  4939. }
  4940. }
  4941. }, _callee, this);
  4942. }));
  4943. function avatarComponentsSync(_x) {
  4944. return _avatarComponentsSync.apply(this, arguments);
  4945. }
  4946. return avatarComponentsSync;
  4947. }()
  4948. }, {
  4949. key: "sendData",
  4950. value: function () {
  4951. var _sendData = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e) {
  4952. var _this = this;
  4953. var t, _e$sampleRate, r, _e$timeout, n, o, a, s;
  4954. return regenerator.wrap(function _callee2$(_context2) {
  4955. while (1) {
  4956. switch (_context2.prev = _context2.next) {
  4957. case 0:
  4958. _context2.next = 2;
  4959. return this.beforeSend(e);
  4960. case 2:
  4961. t = util.uuid();
  4962. if (!(this.room.networkController.sendRtcData(le(oe({}, e.data), {
  4963. trace_id: t,
  4964. user_id: this.room.options.userId
  4965. })), e.track === !1)) {
  4966. _context2.next = 5;
  4967. break;
  4968. }
  4969. return _context2.abrupt("return", Promise.resolve(null));
  4970. case 5:
  4971. _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;
  4972. return _context2.abrupt("return", eventsManager.track({
  4973. timeout: n,
  4974. traceId: t,
  4975. event: a.action_type,
  4976. tag: o,
  4977. extra: a
  4978. }, {
  4979. special: s,
  4980. sampleRate: r,
  4981. noReport: this.room.viewMode === "serverless" || this.room.options.viewMode === "serverless"
  4982. }).finally(function () {
  4983. QueueActions.includes(e.data.action_type) && (_this.currentActiveAction = void 0);
  4984. }));
  4985. case 7:
  4986. case "end":
  4987. return _context2.stop();
  4988. }
  4989. }
  4990. }, _callee2, this);
  4991. }));
  4992. function sendData(_x2) {
  4993. return _sendData.apply(this, arguments);
  4994. }
  4995. return sendData;
  4996. }()
  4997. }, {
  4998. key: "beforeSend",
  4999. value: function () {
  5000. var _beforeSend = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  5001. var o, t, r;
  5002. return regenerator.wrap(function _callee3$(_context3) {
  5003. while (1) {
  5004. switch (_context3.prev = _context3.next) {
  5005. case 0:
  5006. t = (o = this.room._userAvatar) == null ? void 0 : o.isMoving, r = e.data.action_type;
  5007. if (!QueueActions.includes(r)) {
  5008. _context3.next = 5;
  5009. break;
  5010. }
  5011. if (!this.currentActiveAction) {
  5012. _context3.next = 4;
  5013. break;
  5014. }
  5015. 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")))));
  5016. case 4:
  5017. this.currentActiveAction = r;
  5018. case 5:
  5019. if (!(t && QueueActions.includes(e.data.action_type))) {
  5020. _context3.next = 14;
  5021. break;
  5022. }
  5023. _context3.prev = 6;
  5024. _context3.next = 9;
  5025. return this.stopMoving();
  5026. case 9:
  5027. _context3.next = 14;
  5028. break;
  5029. case 11:
  5030. _context3.prev = 11;
  5031. _context3.t0 = _context3["catch"](6);
  5032. this.currentActiveAction = void 0, logger$1.error("before action stopMoving failed", _context3.t0);
  5033. case 14:
  5034. case "end":
  5035. return _context3.stop();
  5036. }
  5037. }
  5038. }, _callee3, this, [[6, 11]]);
  5039. }));
  5040. function beforeSend(_x3) {
  5041. return _beforeSend.apply(this, arguments);
  5042. }
  5043. return beforeSend;
  5044. }()
  5045. }, {
  5046. key: "moveTo",
  5047. value: function () {
  5048. var _moveTo = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  5049. var t, _e$extra, r, n, o;
  5050. return regenerator.wrap(function _callee4$(_context4) {
  5051. while (1) {
  5052. switch (_context4.prev = _context4.next) {
  5053. case 0:
  5054. t = e.point, _e$extra = e.extra, r = _e$extra === void 0 ? "" : _e$extra, n = e.motionType, o = {
  5055. action_type: Actions.Clicking,
  5056. clicking_action: {
  5057. clicking_point: t,
  5058. clicking_type: ClickType.IgnoreView,
  5059. extra: encodeURIComponent(r),
  5060. attitude: n
  5061. },
  5062. clicking_state: this.room._currentClickingState
  5063. };
  5064. return _context4.abrupt("return", this.sendData({
  5065. data: o
  5066. }));
  5067. case 2:
  5068. case "end":
  5069. return _context4.stop();
  5070. }
  5071. }
  5072. }, _callee4, this);
  5073. }));
  5074. function moveTo(_x4) {
  5075. return _moveTo.apply(this, arguments);
  5076. }
  5077. return moveTo;
  5078. }()
  5079. }, {
  5080. key: "transfer",
  5081. value: function transfer(e) {
  5082. var _this2 = this;
  5083. var t = e.renderType,
  5084. r = e.player,
  5085. n = e.camera,
  5086. o = e.areaName,
  5087. a = e.attitude,
  5088. s = e.pathName,
  5089. l = e.person,
  5090. u = e.noMedia,
  5091. c = e.timeout,
  5092. h = e.tag,
  5093. f = e.special,
  5094. d = {
  5095. data: {
  5096. action_type: Actions.Transfer,
  5097. transfer_action: {
  5098. render_type: t,
  5099. player: r,
  5100. camera: n,
  5101. areaName: o,
  5102. attitude: a,
  5103. pathName: s,
  5104. person: {
  5105. type: l
  5106. },
  5107. noMedia: u,
  5108. tiles: [0, 1, 2, 4]
  5109. }
  5110. },
  5111. special: f,
  5112. timeout: c || 4e3,
  5113. tag: h
  5114. };
  5115. return this.sendData(d).then(function (_) {
  5116. return typeof l != "undefined" && _this2.room.updateCurrentNetworkOptions({
  5117. person: l,
  5118. rotationRenderType: t
  5119. }), _;
  5120. });
  5121. }
  5122. }, {
  5123. key: "changeRotationRenderType",
  5124. value: function changeRotationRenderType(e) {
  5125. var t = e.renderType,
  5126. r = e.player,
  5127. n = e.camera,
  5128. o = e.areaName,
  5129. a = e.attitude,
  5130. s = e.pathName;
  5131. return this.transfer({
  5132. renderType: t,
  5133. player: r,
  5134. camera: n,
  5135. areaName: o,
  5136. attitude: a,
  5137. pathName: s,
  5138. tag: "changeToRotationVideo"
  5139. });
  5140. }
  5141. }, {
  5142. key: "requestPanorama",
  5143. value: function requestPanorama(e, t, r) {
  5144. var n = e.camera,
  5145. o = e.player,
  5146. a = e.areaName,
  5147. s = e.attitude,
  5148. l = e.pathName,
  5149. u = e.tag;
  5150. return this.transfer({
  5151. renderType: RenderType.ClientRotationPano,
  5152. player: o,
  5153. camera: n,
  5154. person: Person.First,
  5155. areaName: a,
  5156. attitude: s,
  5157. pathName: l,
  5158. noMedia: t,
  5159. timeout: r,
  5160. tag: u || "requestPanorama",
  5161. special: !t
  5162. });
  5163. }
  5164. }, {
  5165. key: "setMotionType",
  5166. value: function setMotionType(e) {
  5167. return this.transfer({
  5168. attitude: e,
  5169. tag: "setMotionType"
  5170. });
  5171. }
  5172. }, {
  5173. key: "setNickName",
  5174. value: function setNickName(e) {
  5175. var t = {
  5176. action_type: Actions.ChangeNickname,
  5177. change_nickname_action: {
  5178. nickname: e
  5179. }
  5180. };
  5181. return this.sendData({
  5182. data: t
  5183. });
  5184. }
  5185. }, {
  5186. key: "getReserveSeat",
  5187. value: function getReserveSeat(_ref) {
  5188. var e = _ref.routeId,
  5189. t = _ref.name;
  5190. var r = {
  5191. action_type: Actions.ReserveSeat,
  5192. reserve_seat_action: {
  5193. route_id: e,
  5194. name: t
  5195. }
  5196. };
  5197. return this.sendData({
  5198. data: r
  5199. });
  5200. }
  5201. }, {
  5202. key: "getReserveStatus",
  5203. value: function getReserveStatus(_ref2) {
  5204. var e = _ref2.routeId,
  5205. t = _ref2.name,
  5206. r = _ref2.need_detail;
  5207. var n = {
  5208. action_type: Actions.GetReserveStatus,
  5209. get_reserve_status_action: {
  5210. route_id: e,
  5211. name: t,
  5212. need_detail: r
  5213. }
  5214. };
  5215. return this.sendData({
  5216. data: n,
  5217. timeout: 2e3
  5218. }).then(function (o) {
  5219. return o.reserveDetail;
  5220. });
  5221. }
  5222. }, {
  5223. key: "stopMoving",
  5224. value: function stopMoving() {
  5225. var e = {
  5226. action_type: Actions.StopMoving,
  5227. stop_move_action: {}
  5228. };
  5229. return this.sendData({
  5230. data: e
  5231. });
  5232. }
  5233. }, {
  5234. key: "getOnVehicle",
  5235. value: function getOnVehicle(_ref3) {
  5236. var e = _ref3.routeId,
  5237. t = _ref3.name,
  5238. r = _ref3.camera;
  5239. var n = {
  5240. action_type: Actions.GetOnVehicle,
  5241. get_on_vehicle_action: {
  5242. route_id: e,
  5243. name: t,
  5244. camera: r
  5245. }
  5246. };
  5247. return this.sendData({
  5248. data: n
  5249. });
  5250. }
  5251. }, {
  5252. key: "getOffVehicle",
  5253. value: function getOffVehicle(_ref4) {
  5254. var e = _ref4.renderType,
  5255. t = _ref4.player,
  5256. r = _ref4.camera;
  5257. var n = {
  5258. action_type: Actions.GetOffVehicle,
  5259. get_off_vehicle_action: {
  5260. render_type: e,
  5261. player: t,
  5262. camera: r
  5263. }
  5264. };
  5265. return this.sendData({
  5266. data: n
  5267. });
  5268. }
  5269. }, {
  5270. key: "confirmEvent",
  5271. value: function confirmEvent(e) {
  5272. var t = {
  5273. action_type: Actions.ConfirmEvent,
  5274. confirm_event_action: {
  5275. id: e
  5276. }
  5277. };
  5278. return this.sendData({
  5279. data: t,
  5280. track: !1
  5281. });
  5282. }
  5283. }, {
  5284. key: "echo",
  5285. value: function echo(e) {
  5286. var t = {
  5287. action_type: Actions.Echo,
  5288. echo_msg: {
  5289. echoMsg: e
  5290. }
  5291. };
  5292. return this.sendData({
  5293. data: t,
  5294. track: !1
  5295. });
  5296. }
  5297. }, {
  5298. key: "changeSkin",
  5299. value: function () {
  5300. var _changeSkin = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e) {
  5301. var _this3 = this;
  5302. var t, r, n, _e$landingType, o, a, s, l, u, c, h, f, d, _, _e$roomTypeId, g, m, y, v;
  5303. return regenerator.wrap(function _callee6$(_context6) {
  5304. while (1) {
  5305. switch (_context6.prev = _context6.next) {
  5306. case 0:
  5307. 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) {
  5308. return y.id === r;
  5309. })[0];
  5310. if (m) {
  5311. _context6.next = 4;
  5312. break;
  5313. }
  5314. y = "skin ".concat(r, " is invalid");
  5315. return _context6.abrupt("return", (logger$1.error(y), Promise.reject(new ParamError(y))));
  5316. case 4:
  5317. v = {
  5318. action_type: Actions.ChangeSkin,
  5319. change_skin_action: {
  5320. skinID: r,
  5321. mode: n === ChangeMode.Preview ? ChangeMode.Preview : ChangeMode.Confirm,
  5322. skin_data_version: r + m.versionId,
  5323. landing_type: o,
  5324. landing_point: a,
  5325. landing_camera: s,
  5326. render_wrapper: {
  5327. render_type: l
  5328. },
  5329. areaName: u,
  5330. attitude: c,
  5331. noMedia: d,
  5332. person: f,
  5333. pathName: h,
  5334. roomTypeId: g
  5335. }
  5336. };
  5337. return _context6.abrupt("return", this.sendData({
  5338. data: v,
  5339. timeout: _ || 6e3,
  5340. special: t
  5341. }).then( /*#__PURE__*/function () {
  5342. var _ref5 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(y) {
  5343. var b, _ref6, T;
  5344. return regenerator.wrap(function _callee5$(_context5) {
  5345. while (1) {
  5346. switch (_context5.prev = _context5.next) {
  5347. case 0:
  5348. if (!(l === RenderType.ClientRotationPano && y)) {
  5349. _context5.next = 8;
  5350. break;
  5351. }
  5352. _context5.next = 3;
  5353. return _this3.room.modelManager.findRoute(r, h);
  5354. case 3:
  5355. b = _context5.sent;
  5356. _ref6 = util.getRandomItem(b.birthPointList) || {};
  5357. T = _ref6.camera;
  5358. _context5.next = 8;
  5359. return _this3.room.panorama.handleReceivePanorama(y, T);
  5360. case 8:
  5361. return _context5.abrupt("return", _this3.handleChangeSkin(e));
  5362. case 9:
  5363. case "end":
  5364. return _context5.stop();
  5365. }
  5366. }
  5367. }, _callee5);
  5368. }));
  5369. return function (_x6) {
  5370. return _ref5.apply(this, arguments);
  5371. };
  5372. }()).catch(function (y) {
  5373. return d ? _this3.handleChangeSkin(e) : Promise.reject(y);
  5374. }));
  5375. case 6:
  5376. case "end":
  5377. return _context6.stop();
  5378. }
  5379. }
  5380. }, _callee6, this);
  5381. }));
  5382. function changeSkin(_x5) {
  5383. return _changeSkin.apply(this, arguments);
  5384. }
  5385. return changeSkin;
  5386. }()
  5387. }, {
  5388. key: "handleChangeSkin",
  5389. value: function handleChangeSkin(e) {
  5390. var _this4 = this;
  5391. var t = e.skinId,
  5392. r = e.mode,
  5393. n = e.renderType,
  5394. o = e.areaName,
  5395. a = e.attitude,
  5396. s = e.pathName;
  5397. return this.room.sceneManager.staticmeshComponent.getCgMesh().show(), this.room.sceneManager.cameraComponent.switchToCgCamera(), this.room.engineProxy._updateSkinAssets(t).then(function () {
  5398. _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({
  5399. pathName: s,
  5400. attitude: a,
  5401. areaName: o
  5402. }), _this4.room.skinChangedHook(), _this4.room.emit("skinChanged", {
  5403. skin: {
  5404. id: t
  5405. },
  5406. mode: r
  5407. }), n === RenderType.ClientRotationPano && _this4.room.sceneManager.cameraComponent.allowMainCameraController();
  5408. });
  5409. }
  5410. }, {
  5411. key: "rotate",
  5412. value: function rotate(_ref7) {
  5413. var e = _ref7.pitch,
  5414. t = _ref7.yaw;
  5415. var n;
  5416. if (this.room.disableRotate || this.room.isPano || ((n = this.room._userAvatar) == null ? void 0 : n._isChangingComponentsMode)) return;
  5417. var r = {
  5418. action_type: Actions.Rotation,
  5419. rotation_action: {
  5420. vertical_move: e,
  5421. horizontal_move: -t
  5422. }
  5423. };
  5424. this.sendData({
  5425. data: r,
  5426. sampleRate: .02
  5427. });
  5428. }
  5429. }, {
  5430. key: "turnTo",
  5431. value: function turnTo(e) {
  5432. var _ref8 = e || {},
  5433. t = _ref8.point,
  5434. _ref8$timeout = _ref8.timeout,
  5435. r = _ref8$timeout === void 0 ? 2e3 : _ref8$timeout,
  5436. _ref8$offset = _ref8.offset,
  5437. n = _ref8$offset === void 0 ? 8 : _ref8$offset,
  5438. o = {
  5439. action_type: Actions.TurnTo,
  5440. turn_to_action: {
  5441. turn_to_point: t,
  5442. offset: n
  5443. }
  5444. };
  5445. return this.sendData({
  5446. data: o,
  5447. timeout: r
  5448. });
  5449. }
  5450. }, {
  5451. key: "rotateTo",
  5452. value: function rotateTo(e) {
  5453. var _ref9 = e || {},
  5454. t = _ref9.point,
  5455. _ref9$offset = _ref9.offset,
  5456. r = _ref9$offset === void 0 ? 0 : _ref9$offset,
  5457. _ref9$speed = _ref9.speed,
  5458. n = _ref9$speed === void 0 ? 3 : _ref9$speed,
  5459. o = {
  5460. action_type: Actions.RotateTo,
  5461. rotate_to_action: {
  5462. rotate_to_point: t,
  5463. offset: r,
  5464. speed: n
  5465. }
  5466. };
  5467. return this.sendData({
  5468. data: o
  5469. });
  5470. }
  5471. }, {
  5472. key: "broadcast",
  5473. value: function broadcast(e) {
  5474. var t = e.data,
  5475. _e$msgType = e.msgType,
  5476. r = _e$msgType === void 0 ? MessageHandleType.MHT_FollowListMulticast : _e$msgType,
  5477. n = e.targetUserIds;
  5478. if (r === MessageHandleType.MHT_CustomTargetSync && !Array.isArray(n)) return Promise.reject(new ParamError("param targetUserIds is required when msgType is ".concat(MessageHandleType[r])));
  5479. var o = {
  5480. action_type: Actions.Broadcast,
  5481. broadcast_action: {
  5482. data: JSON.stringify(t),
  5483. user_id: this.room.options.userId,
  5484. msgType: r
  5485. }
  5486. };
  5487. return Array.isArray(n) && r === MessageHandleType.MHT_CustomTargetSync && (o.broadcast_action.target_user_ids = n), this.room.actionsHandler.sendData({
  5488. data: o,
  5489. tag: t.broadcastType
  5490. });
  5491. }
  5492. }, {
  5493. key: "getNeighborPoints",
  5494. value: function getNeighborPoints(e) {
  5495. var t = e.point,
  5496. _e$containSelf = e.containSelf,
  5497. r = _e$containSelf === void 0 ? !1 : _e$containSelf,
  5498. _e$searchRange = e.searchRange,
  5499. n = _e$searchRange === void 0 ? 500 : _e$searchRange,
  5500. o = {
  5501. action_type: Actions.GetNeighborPoints,
  5502. get_neighbor_points_action: {
  5503. point: t,
  5504. level: 1,
  5505. containSelf: r,
  5506. searchRange: n
  5507. }
  5508. };
  5509. return this.sendData({
  5510. data: o
  5511. }).then(function (a) {
  5512. return a.nps;
  5513. });
  5514. }
  5515. }, {
  5516. key: "playCG",
  5517. value: function playCG(e) {
  5518. var t = {
  5519. action_type: Actions.PlayCG,
  5520. play_cg_action: {
  5521. cg_name: e
  5522. }
  5523. };
  5524. return this.sendData({
  5525. data: t
  5526. });
  5527. }
  5528. }, {
  5529. key: "audienceToVisitor",
  5530. value: function audienceToVisitor(e) {
  5531. var t = e.avatarId,
  5532. r = e.avatarComponents,
  5533. n = e.player,
  5534. o = e.camera,
  5535. a = {
  5536. action_type: Actions.AudienceChangeToVisitor,
  5537. audienceChangeToVisitorAction: {
  5538. avatarID: t,
  5539. avatarComponents: r,
  5540. player: n,
  5541. camera: o
  5542. }
  5543. };
  5544. return logger$1.debug("send data: audience to visitor"), this.sendData({
  5545. data: a
  5546. });
  5547. }
  5548. }, {
  5549. key: "visitorToAudience",
  5550. value: function visitorToAudience(e) {
  5551. var t = e.renderType,
  5552. r = e.player,
  5553. n = e.camera,
  5554. o = e.areaName,
  5555. a = e.attitude,
  5556. s = e.pathName,
  5557. l = e.person,
  5558. u = e.noMedia,
  5559. c = {
  5560. action_type: Actions.VisitorChangeToAudience,
  5561. visitorChangeToAudienceAction: {
  5562. transferAction: {
  5563. render_type: t,
  5564. player: r,
  5565. camera: n,
  5566. areaName: o,
  5567. attitude: a,
  5568. pathName: s,
  5569. person: {
  5570. type: l
  5571. },
  5572. noMedia: u,
  5573. tiles: [0, 1, 2, 4]
  5574. }
  5575. }
  5576. };
  5577. return logger$1.debug("send data: visitor to audience"), this.sendData({
  5578. data: c
  5579. });
  5580. }
  5581. }, {
  5582. key: "removeVisitor",
  5583. value: function removeVisitor(e) {
  5584. var t = e.removeType,
  5585. r = e.userIDList,
  5586. _e$extraInfo = e.extraInfo,
  5587. n = _e$extraInfo === void 0 ? "" : _e$extraInfo,
  5588. o = {
  5589. action_type: Actions.RemoveVisitor,
  5590. removeVisitorAction: {
  5591. removeVisitorEvent: t,
  5592. userIDList: r,
  5593. extraInfo: encodeURIComponent(n)
  5594. }
  5595. };
  5596. return logger$1.debug("send data: remove visitor"), this.sendData({
  5597. data: o
  5598. });
  5599. }
  5600. }, {
  5601. key: "getUserWithAvatar",
  5602. value: function getUserWithAvatar(e, t) {
  5603. var r = {
  5604. action_type: Actions.GetUserWithAvatar,
  5605. getUserWithAvatarAction: {
  5606. userType: e,
  5607. roomID: t
  5608. }
  5609. };
  5610. return logger$1.debug("send data: get user with avatar"), this.sendData({
  5611. data: r
  5612. }).then(function (n) {
  5613. return n.userWithAvatarList;
  5614. });
  5615. }
  5616. }, {
  5617. key: "joystick",
  5618. value: function joystick(e) {
  5619. var t = e.degree,
  5620. _e$level = e.level,
  5621. r = _e$level === void 0 ? 1 : _e$level,
  5622. n = util.uuid();
  5623. var o = -t + 90 + 360;
  5624. o >= 360 && (o -= 360);
  5625. var a = {
  5626. action_type: Actions.Joystick,
  5627. dir_action: {
  5628. move_angle: o,
  5629. speed_level: r
  5630. },
  5631. trace_id: n,
  5632. user_id: this.room.options.userId,
  5633. packet_id: n
  5634. };
  5635. return this.sendData({
  5636. data: a,
  5637. track: !1
  5638. });
  5639. }
  5640. }]);
  5641. return ActionsHandler;
  5642. }();
  5643. var ECurrentShaderMode = {
  5644. default: 0,
  5645. video: 1,
  5646. pano: 2
  5647. };
  5648. var PointType = {
  5649. Path: 0,
  5650. Item: 1,
  5651. Closeup: 2,
  5652. NoValidMatched: 3
  5653. };
  5654. var Signal = /*#__PURE__*/function () {
  5655. function Signal(e) {
  5656. _classCallCheck(this, Signal);
  5657. this.signalHandleActived = !0;
  5658. this.isUpdatedYUV = !0;
  5659. this._room = e;
  5660. }
  5661. _createClass(Signal, [{
  5662. key: "handleSignal",
  5663. value: function handleSignal(e) {
  5664. var _this = this;
  5665. var a, s, l;
  5666. if (!this.signalHandleActived) return;
  5667. var t = e.signal,
  5668. r = e.alreadyUpdateYUV;
  5669. if (this.handleActionResponses(t), this._room.handleSignalHook(t), !r) {
  5670. var u = (a = t.newUserStates) == null ? void 0 : a.find(function (c) {
  5671. return c.userId === _this._room.userId;
  5672. });
  5673. if ((u == null ? void 0 : u.renderInfo) && ((s = this._room._userAvatar) == null ? void 0 : s.isMoving)) {
  5674. logger$1.debug("stream stoped, make avatar to stop");
  5675. var _u$renderInfo = u.renderInfo,
  5676. c = _u$renderInfo.isMoving,
  5677. h = _u$renderInfo.isRotating;
  5678. this._room.avatarManager._updateAvatarMovingStatus({
  5679. id: u.userId,
  5680. isMoving: !!c,
  5681. isRotating: !!h
  5682. });
  5683. }
  5684. return;
  5685. }
  5686. this.isUpdatedYUV = r;
  5687. var n = t;
  5688. if (!t) {
  5689. logger$1.warn("metadata signal is empty");
  5690. return;
  5691. }
  5692. if (n.code === Codes.RepeatLogin) {
  5693. this._room.handleRepetLogin();
  5694. return;
  5695. }
  5696. 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));
  5697. var o = (l = n.newUserStates) == null ? void 0 : l.find(function (u) {
  5698. return u.userId === _this._room.userId;
  5699. });
  5700. if (n.broadcastAction) try {
  5701. var _u = JSON.parse(n.broadcastAction.data);
  5702. Broadcast.handlers.forEach(function (c) {
  5703. return c(_u);
  5704. });
  5705. } catch (u) {
  5706. logger$1.error(u);
  5707. }
  5708. if (n.newUserStates && n.newUserStates.length > 0 && this._room.avatarManager.handleAvatar(n), o != null && o.playerState) {
  5709. this._room._currentClickingState = o.playerState;
  5710. var _o$playerState = o.playerState,
  5711. _u2 = _o$playerState.pathName,
  5712. _c = _o$playerState.attitude,
  5713. _h = _o$playerState.areaName,
  5714. f = _o$playerState.skinId;
  5715. if (_u2 && (this._room.pathManager.currentPathName = _u2, this._room.updateCurrentState({
  5716. pathName: _u2
  5717. })), f && this.udpateSkinInfo(f), _h && this._room.updateCurrentState({
  5718. areaName: _h
  5719. }), _c) {
  5720. var d = this._room.skin.routeList.find(function (g) {
  5721. return g.areaName === _this._room.currentState.areaName;
  5722. }),
  5723. _ = ((d == null ? void 0 : d.step) || 7.5) * 30;
  5724. this._room.updateCurrentState({
  5725. speed: _,
  5726. attitude: _c
  5727. }), this._room.pathManager.currentAttitude = _c, this._room._userAvatar && (this._room._userAvatar.motionType = _c);
  5728. }
  5729. this._room.sceneManager.getCurrentShaderMode() !== ECurrentShaderMode.pano && !this._room.isPano && o.playerState.camera && this._room.camera.setCameraPose(o.playerState.camera);
  5730. }
  5731. if (o != null && o.renderInfo && this._room.camera.handleRenderInfo(o), n.actionType !== void 0) {
  5732. var _u3 = n.actionType,
  5733. _c2 = n.code,
  5734. _h2 = n.echoMsg,
  5735. _f = n.traceId;
  5736. _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);
  5737. }
  5738. }
  5739. }, {
  5740. key: "handleActionResponses",
  5741. value: function handleActionResponses(e) {
  5742. var _this2 = this;
  5743. !(e != null && e.actionResponses) || e.actionResponses.length === 0 || e.actionResponses.forEach(function (t) {
  5744. if (t.actionType == null) return;
  5745. var r = t.pointType,
  5746. n = t.extra,
  5747. o = t.actionType,
  5748. a = t.traceId,
  5749. s = t.code,
  5750. l = t.msg;
  5751. 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));
  5752. });
  5753. }
  5754. }, {
  5755. key: "udpateSkinInfo",
  5756. value: function () {
  5757. var _udpateSkinInfo = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  5758. var t;
  5759. return regenerator.wrap(function _callee$(_context) {
  5760. while (1) {
  5761. switch (_context.prev = _context.next) {
  5762. case 0:
  5763. this._room.updateCurrentState({
  5764. skinId: e
  5765. });
  5766. _context.next = 3;
  5767. return this._room.skinList.find(function (r) {
  5768. return r.id === e;
  5769. });
  5770. case 3:
  5771. t = _context.sent;
  5772. t && this._room.updateCurrentState({
  5773. skin: t
  5774. });
  5775. case 5:
  5776. case "end":
  5777. return _context.stop();
  5778. }
  5779. }
  5780. }, _callee, this);
  5781. }));
  5782. function udpateSkinInfo(_x) {
  5783. return _udpateSkinInfo.apply(this, arguments);
  5784. }
  5785. return udpateSkinInfo;
  5786. }()
  5787. }]);
  5788. return Signal;
  5789. }();
  5790. 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); }; }
  5791. 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; } }
  5792. var XverseEffectManager = /*#__PURE__*/function (_EventEmitter) {
  5793. _inherits(XverseEffectManager, _EventEmitter);
  5794. var _super = _createSuper$a(XverseEffectManager);
  5795. function XverseEffectManager(e) {
  5796. var _this;
  5797. _classCallCheck(this, XverseEffectManager);
  5798. _this = _super.call(this);
  5799. E(_assertThisInitialized(_this), "effects", new Map());
  5800. E(_assertThisInitialized(_this), "room");
  5801. _this.room = e;
  5802. return _this;
  5803. }
  5804. _createClass(XverseEffectManager, [{
  5805. key: "addEffect",
  5806. value: function () {
  5807. var _addEffect = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  5808. var o, t, r, _e$type, n, a;
  5809. return regenerator.wrap(function _callee$(_context) {
  5810. while (1) {
  5811. switch (_context.prev = _context.next) {
  5812. case 0:
  5813. t = e.jsonPath, r = e.id, _e$type = e.type, n = _e$type === void 0 ? IEffectType.SubSequence : _e$type;
  5814. _context.prev = 1;
  5815. this.effects.get(r) && ((o = this.effects.get(r)) == null || o.dispose());
  5816. a = new Ae.subEffect({
  5817. id: r,
  5818. jsonPath: t,
  5819. type: n,
  5820. room: this.room
  5821. });
  5822. this.effects.set(r, a);
  5823. _context.next = 7;
  5824. return a.init();
  5825. case 7:
  5826. return _context.abrupt("return", a);
  5827. case 10:
  5828. _context.prev = 10;
  5829. _context.t0 = _context["catch"](1);
  5830. return _context.abrupt("return", (this.effects.delete(r), logger$1.error(_context.t0), Promise.reject(_context.t0)));
  5831. case 13:
  5832. case "end":
  5833. return _context.stop();
  5834. }
  5835. }
  5836. }, _callee, this, [[1, 10]]);
  5837. }));
  5838. function addEffect(_x) {
  5839. return _addEffect.apply(this, arguments);
  5840. }
  5841. return addEffect;
  5842. }()
  5843. }, {
  5844. key: "clearEffects",
  5845. value: function clearEffects() {
  5846. var _this2 = this;
  5847. this.effects.forEach(function (e) {
  5848. e.dispose(), _this2.effects.delete(e.id);
  5849. });
  5850. }
  5851. }, {
  5852. key: "removeEffect",
  5853. value: function removeEffect(e) {
  5854. var t = this.effects.get(e);
  5855. t == null || t.dispose(), t && this.effects.delete(t.id);
  5856. }
  5857. }]);
  5858. return XverseEffectManager;
  5859. }(EventEmitter);
  5860. var Heartbeat = /*#__PURE__*/function () {
  5861. function Heartbeat(e) {
  5862. var _this = this;
  5863. _classCallCheck(this, Heartbeat);
  5864. E(this, "_interval", null);
  5865. E(this, "ping", function () {
  5866. var e = Date.now().toString();
  5867. _this.handler.ping(e);
  5868. });
  5869. this.handler = e;
  5870. }
  5871. _createClass(Heartbeat, [{
  5872. key: "ping",
  5873. value: function ping() {
  5874. var e = Date.now().toString();
  5875. this.handler.ping(e);
  5876. }
  5877. }, {
  5878. key: "start",
  5879. value: function start() {
  5880. this.stop(), logger$1.debug("Setting ping interval to ".concat(PING_INTERVAL_MS, "ms")), this._interval = window.setInterval(this.ping, PING_INTERVAL_MS);
  5881. }
  5882. }, {
  5883. key: "stop",
  5884. value: function stop() {
  5885. logger$1.debug("stop heartbeat"), this._interval && window.clearInterval(this._interval);
  5886. }
  5887. }, {
  5888. key: "pong",
  5889. value: function pong(e, t) {
  5890. !e || typeof e == "string" && this.handler.pong(Date.now() - Number(e), t);
  5891. }
  5892. }]);
  5893. return Heartbeat;
  5894. }();
  5895. var Timeout$1 = /*#__PURE__*/function () {
  5896. function Timeout(e, t) {
  5897. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !0;
  5898. _classCallCheck(this, Timeout);
  5899. this._timeout = null;
  5900. this._fn = e, this._delay = t, r && this.start();
  5901. }
  5902. _createClass(Timeout, [{
  5903. key: "delay",
  5904. get: function get() {
  5905. return this._delay;
  5906. }
  5907. }, {
  5908. key: "isSet",
  5909. get: function get() {
  5910. return !!this._timeout;
  5911. }
  5912. }, {
  5913. key: "setDelay",
  5914. value: function setDelay(e) {
  5915. this._delay = e;
  5916. }
  5917. }, {
  5918. key: "start",
  5919. value: function start() {
  5920. var _this = this;
  5921. this.isSet || (this._timeout = window.setTimeout(function () {
  5922. var e = _this._fn;
  5923. _this.clear(), e();
  5924. }, this._delay));
  5925. }
  5926. }, {
  5927. key: "clear",
  5928. value: function clear() {
  5929. window.clearTimeout(this._timeout), this._timeout = void 0;
  5930. }
  5931. }, {
  5932. key: "reset",
  5933. value: function reset() {
  5934. this.clear(), this.start();
  5935. }
  5936. }]);
  5937. return Timeout;
  5938. }();
  5939. 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); }; }
  5940. 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; } }
  5941. var Socket = /*#__PURE__*/function (_EventEmitter) {
  5942. _inherits(Socket, _EventEmitter);
  5943. var _super = _createSuper$9(Socket);
  5944. function Socket(e) {
  5945. var _this;
  5946. _classCallCheck(this, Socket);
  5947. _this = _super.call(this);
  5948. E(_assertThisInitialized(_this), "_ws");
  5949. E(_assertThisInitialized(_this), "_openTimer");
  5950. E(_assertThisInitialized(_this), "connected", !1);
  5951. E(_assertThisInitialized(_this), "_hasTimeout", !1);
  5952. E(_assertThisInitialized(_this), "heartbeat");
  5953. E(_assertThisInitialized(_this), "latency", function (e, t) {
  5954. return _this.send({
  5955. id: "checkLatency",
  5956. data: JSON.stringify(e),
  5957. packet_id: t
  5958. });
  5959. });
  5960. E(_assertThisInitialized(_this), "send", function (e) {
  5961. if (_this.wsNoReady()) return;
  5962. var t = JSON.stringify(e);
  5963. e.id !== "heartbeat" && logger$1.info("send ws frame", t), _this._ws.send(t);
  5964. });
  5965. E(_assertThisInitialized(_this), "startGame", function () {
  5966. var _this$network$room$cu = _this.network.room.currentNetworkOptions,
  5967. e = _this$network$room$cu.roomId,
  5968. t = _this$network$room$cu.userId,
  5969. r = _this$network$room$cu.avatarId,
  5970. n = _this$network$room$cu.skinId,
  5971. o = _this$network$room$cu.role,
  5972. a = _this$network$room$cu.avatarComponents,
  5973. s = _this$network$room$cu.versionId,
  5974. l = _this$network$room$cu.rotationRenderType,
  5975. u = _this$network$room$cu.isAllSync,
  5976. c = _this$network$room$cu.nickname,
  5977. h = _this$network$room$cu.avatarScale,
  5978. f = _this$network$room$cu.appId,
  5979. d = _this$network$room$cu.camera,
  5980. _ = _this$network$room$cu.player,
  5981. g = _this$network$room$cu.firends,
  5982. m = _this$network$room$cu.syncByEvent,
  5983. v = _this$network$room$cu.areaName,
  5984. y = _this$network$room$cu.attitude,
  5985. b = _this$network$room$cu.pathName,
  5986. T = _this$network$room$cu.person,
  5987. _this$network$room$cu2 = _this$network$room$cu.roomTypeId,
  5988. C = _this$network$room$cu2 === void 0 ? "" : _this$network$room$cu2,
  5989. A = _this$network$room$cu.syncToOthers,
  5990. S = _this$network$room$cu.hasAvatar,
  5991. P = _this$network$room$cu.prioritySync,
  5992. _this$network$room$cu3 = _this$network$room$cu.extra,
  5993. R = _this$network$room$cu3 === void 0 ? {} : _this$network$room$cu3,
  5994. M = _this$network$room$cu.removeWhenDisconnected;
  5995. R.removeWhenDisconnected = M;
  5996. var x = {
  5997. id: "start",
  5998. room_id: e,
  5999. user_id: t,
  6000. trace_id: util.uuid(),
  6001. data: JSON.stringify({
  6002. avatar_components: JSON.stringify(a),
  6003. avatar_id: r,
  6004. skin_id: n,
  6005. is_host: o ? o == "host" : !0,
  6006. skin_data_version: n !== void 0 && s !== void 0 ? n + s : void 0,
  6007. rotation_render_type: l,
  6008. is_all_sync: u,
  6009. nick_name: encodeURIComponent(c || ""),
  6010. app_id: f,
  6011. camera: d,
  6012. player: _,
  6013. person: T,
  6014. firends: JSON.stringify(g),
  6015. sync_by_event: m,
  6016. area_name: v,
  6017. path_name: b,
  6018. attitude: y,
  6019. room_type_id: C,
  6020. syncToOthers: A,
  6021. hasAvatar: S,
  6022. avatarSize: h,
  6023. prioritySync: P,
  6024. extra: JSON.stringify(R)
  6025. })
  6026. };
  6027. _this.send(x), logger$1.warn("startGame", le(oe({}, x), {
  6028. data: JSON.parse(x.data)
  6029. }));
  6030. });
  6031. _this.network = e, _this.heartbeat = new Heartbeat({
  6032. ping: function ping(t) {
  6033. var r;
  6034. if (!_this.connected) {
  6035. _this.heartbeat.stop(), (r = e.room.stats) == null || r.assign({
  6036. rtt: 0
  6037. });
  6038. return;
  6039. }
  6040. _this.send({
  6041. id: "heartbeat",
  6042. data: t
  6043. });
  6044. },
  6045. pong(t) {
  6046. var r;
  6047. (r = e.room.stats) == null || r.assign({
  6048. rtt: t
  6049. });
  6050. }
  6051. });
  6052. return _this;
  6053. }
  6054. _createClass(Socket, [{
  6055. key: "connection",
  6056. get: function get() {
  6057. return this._ws;
  6058. }
  6059. }, {
  6060. key: "start",
  6061. value: function start() {
  6062. var _this2 = this;
  6063. this._hasTimeout = !1;
  6064. var e = this.getAddress();
  6065. logger$1.info("connecting to ".concat(e));
  6066. var t = Date.now();
  6067. this._ws = new WebSocket(e), this._openTimer = new Timeout$1(function () {
  6068. var r = "Failed to open websocket in ".concat(DEFAULT_OPEN_TIMEOUT_MS, " ms");
  6069. _this2._hasTimeout = !0, _this2.emit("socketClosed", new InitNetworkTimeoutError(r));
  6070. }, DEFAULT_OPEN_TIMEOUT_MS), this._ws.onopen = function () {
  6071. var r;
  6072. (r = _this2._openTimer) == null || r.clear(), _this2.connected = !0, _this2.heartbeat.start(), _this2.network.room.currentNetworkOptions.reconnect || (logger$1.infoAndReportMeasurement({
  6073. metric: "wsOpenedAt",
  6074. group: "joinRoom",
  6075. startTime: _this2.network.room._startTime
  6076. }), logger$1.infoAndReportMeasurement({
  6077. metric: "wsOpenedCost",
  6078. group: "joinRoom",
  6079. startTime: t
  6080. }));
  6081. }, this.handleWSEvent();
  6082. }
  6083. }, {
  6084. key: "getAddress",
  6085. value: function getAddress() {
  6086. var _this$network$room$cu4 = this.network.room.currentNetworkOptions,
  6087. e = _this$network$room$cu4.wsServerUrl,
  6088. t = _this$network$room$cu4.reconnect,
  6089. r = _this$network$room$cu4.sessionId,
  6090. n = _this$network$room$cu4.token,
  6091. o = _this$network$room$cu4.roomId,
  6092. a = _this$network$room$cu4.userId,
  6093. s = _this$network$room$cu4.pageSession,
  6094. l = this.network.room.skinId;
  6095. var u = e;
  6096. t && (u = u + "?reconnect=true&lastSessionID=".concat(r));
  6097. var c = "userId=".concat(a, "&roomId=").concat(o, "&pageSession=").concat(s) + (this.network.room.isHost ? "&skinId=".concat(l) : "") + (n ? "&token=".concat(n) : "");
  6098. return u = u.indexOf("?") > -1 ? u + "&" + c : u + "?" + c, u;
  6099. }
  6100. }, {
  6101. key: "handleWSEvent",
  6102. value: function handleWSEvent() {
  6103. var _this3 = this;
  6104. var e = this._ws;
  6105. e.addEventListener("error", function (t) {
  6106. _this3.connected = !1, logger$1.error("webscoket error", t), _this3.emit("socketClosed", new InternalError("connect to address error: " + _this3.network.room.currentNetworkOptions.wsServerUrl));
  6107. }), e.addEventListener("close", function (t) {
  6108. _this3.connected = !1, _this3._onClose(t);
  6109. }), e.addEventListener("message", function (t) {
  6110. if (!t || _this3._hasTimeout || !_this3.connected) return;
  6111. var r = null;
  6112. try {
  6113. r = JSON.parse(t.data);
  6114. } catch (o) {
  6115. logger$1.error(o);
  6116. return;
  6117. }
  6118. if (!r) return;
  6119. var n = r.id;
  6120. if (!!n) switch (n !== "heartbeat" && logger$1.info("receive ws frame: ".concat(t.data)), n) {
  6121. case "fail":
  6122. break;
  6123. case "init":
  6124. try {
  6125. var o = r.data.slice(-37, -1);
  6126. reporter$1.updateBody({
  6127. serverSession: o
  6128. });
  6129. } catch (o) {
  6130. console.error(o);
  6131. }
  6132. _this3.network.rtcp.start();
  6133. break;
  6134. case "heartbeat":
  6135. _this3.heartbeat.pong(r.data);
  6136. break;
  6137. case "offer":
  6138. _this3.network.rtcp.setRemoteDescription(r.data, _this3.network.stream.el);
  6139. break;
  6140. case "ice_candidate":
  6141. _this3.network.rtcp.addCandidate(r.data);
  6142. break;
  6143. case "start":
  6144. _this3.emit("gameRoomAvailable", r);
  6145. break;
  6146. case "error":
  6147. try {
  6148. var _JSON$parse = JSON.parse(r.data),
  6149. _o = _JSON$parse.Code,
  6150. a = _JSON$parse.Msg;
  6151. if (_o) {
  6152. if (_o == 3003) return _this3.emit("socketClosed", new TokenExpiredError());
  6153. if (authenticationErrorCodes.indexOf(_o) > -1) return _this3.emit("socketClosed", new AuthenticationError("\u9274\u6743\u9519\u8BEF:" + a));
  6154. {
  6155. var s = util.getErrorByCode(_o);
  6156. _this3.emit("socketClosed", new s(a));
  6157. }
  6158. }
  6159. } catch (o) {
  6160. logger$1.error(o), _this3.emit("socketClosed", new InternalError(r.data));
  6161. }
  6162. break;
  6163. case "checkLatency":
  6164. {
  6165. var _o2 = r.packet_id,
  6166. _a = r.data.split(",");
  6167. _this3.onLatencyCheck({
  6168. packetId: _o2,
  6169. addresses: _a
  6170. });
  6171. break;
  6172. }
  6173. default:
  6174. logger$1.warn("unkown ws message type", n, r);
  6175. }
  6176. });
  6177. }
  6178. }, {
  6179. key: "onLatencyCheck",
  6180. value: function onLatencyCheck(e) {
  6181. var _this4 = this;
  6182. var t = _toConsumableArray(new Set(e.addresses || []));
  6183. Promise.all(t.map(function (r) {
  6184. return {
  6185. [r]: 9999
  6186. };
  6187. })).then(function (r) {
  6188. var n = Object.assign.apply(Object, [{}].concat(_toConsumableArray(r)));
  6189. _this4.latency(n, e.packetId);
  6190. });
  6191. }
  6192. }, {
  6193. key: "wsNoReady",
  6194. value: function wsNoReady() {
  6195. return this._ws.readyState == WebSocket.CLOSED || this._ws.readyState == WebSocket.CLOSING || this._ws.readyState == WebSocket.CONNECTING;
  6196. }
  6197. }, {
  6198. key: "prepareReconnect",
  6199. value: function prepareReconnect() {
  6200. this._close({
  6201. code: WS_CLOSE_RECONNECT,
  6202. reason: "reconnect"
  6203. });
  6204. }
  6205. }, {
  6206. key: "_onClose",
  6207. value: function _onClose(_ref) {
  6208. var e = _ref.code,
  6209. t = _ref.reason;
  6210. 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"));
  6211. }
  6212. }, {
  6213. key: "_close",
  6214. value: function _close(_ref2) {
  6215. var e = _ref2.code,
  6216. t = _ref2.reason;
  6217. var r;
  6218. (r = this._ws) == null || r.close(e, t);
  6219. }
  6220. }, {
  6221. key: "quit",
  6222. value: function quit() {
  6223. this._close({
  6224. code: WS_CLOSE_NORMAL,
  6225. reason: "quit"
  6226. });
  6227. }
  6228. }]);
  6229. return Socket;
  6230. }(EventEmitter);
  6231. function add(i, e) {
  6232. return e == -1 && (e = 0), i + e;
  6233. }
  6234. function max(i, e) {
  6235. return Math.max(i, e);
  6236. }
  6237. function count_sd(i, e) {
  6238. function t(r, n) {
  6239. var o = 0;
  6240. return n == -1 ? o = 0 : o = (n - e) * (n - e), r + o;
  6241. }
  6242. return Math.sqrt(i.reduce(t, 0) / i.reduce(count_valid, 0)) || 0;
  6243. }
  6244. function count_valid(i, e) {
  6245. var t = 0;
  6246. return e != -1 && (t = 1), i + t;
  6247. }
  6248. function count_less(i, e) {
  6249. function t(r, n) {
  6250. var o = 0;
  6251. return n != -1 && n < e && (o = 1), r + o;
  6252. }
  6253. return i.reduce(t, 0);
  6254. }
  6255. var CircularArray = /*#__PURE__*/function () {
  6256. function CircularArray(e, t, r) {
  6257. _classCallCheck(this, CircularArray);
  6258. 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);
  6259. }
  6260. _createClass(CircularArray, [{
  6261. key: "add",
  6262. value: function add(e) {
  6263. 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);
  6264. }
  6265. }, {
  6266. key: "computeAvg",
  6267. value: function computeAvg(e) {
  6268. return e.reduce(add, 0) / e.reduce(count_valid, 0) || 0;
  6269. }
  6270. }, {
  6271. key: "computeMax",
  6272. value: function computeMax(e) {
  6273. return e.reduce(max, 0) || 0;
  6274. }
  6275. }, {
  6276. key: "computeThreshPercent",
  6277. value: function computeThreshPercent(e) {
  6278. if (this.countLess) {
  6279. var t = count_less(e, this.lessThreshes[0]) || 0,
  6280. r = count_less(e, this.lessThreshes[1]) || 0,
  6281. n = count_less(e, this.lessThreshes[2]) || 0,
  6282. o = count_less(e, this.lessThreshes[3]) || 0,
  6283. a = e.reduce(count_valid, 0);
  6284. return [t, r, n, o, a];
  6285. } else return [0, 0, 0, 0, 0];
  6286. }
  6287. }, {
  6288. key: "getAvg",
  6289. value: function getAvg() {
  6290. var e = this.sum / this.count || 0,
  6291. t = this.computeAvg(this.circularData) || 0;
  6292. return Math.abs(e - t) > .01 && console.error("avg value mismatch: ", e, t), this.computeAvg(this.circularData) || 0;
  6293. }
  6294. }, {
  6295. key: "getMax",
  6296. value: function getMax() {
  6297. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !0;
  6298. var t = this.computeMax(this.circularData) || 0;
  6299. return e && Math.abs(t - this.max) > .01 && console.error("max value mismatch: ", this.max, t), this.computeMax(this.circularData) || 0;
  6300. }
  6301. }, {
  6302. key: "getStandardDeviation",
  6303. value: function getStandardDeviation() {
  6304. return count_sd(this.circularData, this.getAvg());
  6305. }
  6306. }, {
  6307. key: "getThreshPercent",
  6308. value: function getThreshPercent() {
  6309. return this.computeThreshPercent(this.circularData);
  6310. }
  6311. }, {
  6312. key: "getIncomingMax",
  6313. value: function getIncomingMax() {
  6314. return this.computeMax(this.incomingData) || 0;
  6315. }
  6316. }, {
  6317. key: "getIncomingAvg",
  6318. value: function getIncomingAvg() {
  6319. return this.computeAvg(this.incomingData) || 0;
  6320. }
  6321. }, {
  6322. key: "getIncomingStandardDeviation",
  6323. value: function getIncomingStandardDeviation() {
  6324. return count_sd(this.incomingData, this.getIncomingAvg());
  6325. }
  6326. }, {
  6327. key: "getIncomingThreshPercent",
  6328. value: function getIncomingThreshPercent() {
  6329. return this.computeThreshPercent(this.incomingData);
  6330. }
  6331. }, {
  6332. key: "clearFastComputeItem",
  6333. value: function clearFastComputeItem() {
  6334. 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;
  6335. }
  6336. }, {
  6337. key: "clearIncoming",
  6338. value: function clearIncoming() {
  6339. for (; this.incomingData.length > 0;) {
  6340. this.incomingData.pop();
  6341. }
  6342. }
  6343. }, {
  6344. key: "clear",
  6345. value: function clear() {
  6346. this.circularData.fill(-1), this.circularPtr = 0, this.clearFastComputeItem(), this.clearIncoming();
  6347. }
  6348. }]);
  6349. return CircularArray;
  6350. }();
  6351. 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; } } }; }
  6352. 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); }
  6353. 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; }
  6354. var defaultLogger = {
  6355. info: console.log,
  6356. debug: console.log,
  6357. error: console.error,
  6358. infoAndReportMeasurement: function infoAndReportMeasurement() {}
  6359. };
  6360. var USER_ID = "987412365",
  6361. PAGE_SESSION = "aaabbbccc",
  6362. SERVER_SESSION = "cccbbbaaa",
  6363. COS_PREFIX = "error-bitstreams-auto-uploaded-from-application/",
  6364. FRAME_COMPOSE_LENGTH = 5;
  6365. var Workers = /*#__PURE__*/function () {
  6366. function Workers(e, t) {
  6367. var _this = this;
  6368. _classCallCheck(this, Workers);
  6369. 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 = {
  6370. x: 0,
  6371. y: 0,
  6372. z: 0,
  6373. tiles: []
  6374. }, 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 () {
  6375. return DECODER_VERSION;
  6376. }, this.downloadBlob = function (r, n, o) {
  6377. var a = new Blob([r], {
  6378. type: o
  6379. }),
  6380. s = window.URL.createObjectURL(a);
  6381. _this.downloadURL(s, n), setTimeout(function () {
  6382. return window.URL.revokeObjectURL(s);
  6383. }, 1e3);
  6384. }, this.downloadURL = function (r, n) {
  6385. var o = document.createElement("a");
  6386. o.href = r, o.download = n, document.body.appendChild(o), o.style.display = "none", o.click(), o.remove();
  6387. }, this.Stringify = function (r) {
  6388. var n = "";
  6389. for (var a = 0; a < r.length / 8192; a++) {
  6390. n += String.fromCharCode.apply(null, r.slice(a * 8192, (a + 1) * 8192));
  6391. }
  6392. return n;
  6393. }, this._rtcp = e;
  6394. }
  6395. _createClass(Workers, [{
  6396. key: "registerLogger",
  6397. value: function registerLogger(e) {//defaultLogger = e
  6398. }
  6399. }, {
  6400. key: "registerFunction",
  6401. value: function registerFunction(e, t) {
  6402. this.functionMap.set(e, t);
  6403. }
  6404. }, {
  6405. key: "hasFrmCntInCache",
  6406. value: function hasFrmCntInCache(e) {
  6407. var t = -1;
  6408. for (var r = 0; r < this.cacheFrameComposes.length; r++) {
  6409. this.cacheFrameComposes[r].frameCnt == e && (t = r);
  6410. }
  6411. return t;
  6412. }
  6413. }, {
  6414. key: "requestPanoramaTest",
  6415. value: function requestPanoramaTest(e, t, r, n, o) {
  6416. var a = o,
  6417. s = {
  6418. action_type: 16,
  6419. change_rotation_render_type_action: {
  6420. render_type: 5,
  6421. player: {
  6422. position: {
  6423. x: 0,
  6424. y: 0,
  6425. z: 0
  6426. },
  6427. angle: {
  6428. yaw: 0,
  6429. pitch: 0,
  6430. roll: 0
  6431. }
  6432. },
  6433. camera: {
  6434. position: {
  6435. x: e,
  6436. y: t,
  6437. z: r
  6438. },
  6439. angle: {
  6440. yaw: 0,
  6441. pitch: 0,
  6442. roll: 0
  6443. }
  6444. },
  6445. client_pano_titles_bitmap: n
  6446. },
  6447. trace_id: a,
  6448. user_id: this.userId_test,
  6449. packet_id: a
  6450. };
  6451. defaultLogger.debug("send data: ", s), this._rtcp.sendData(s);
  6452. }
  6453. }, {
  6454. key: "onRotateInPanoMode",
  6455. value: function onRotateInPanoMode(e) {
  6456. var t = e.traceId,
  6457. r = {};
  6458. r.width = 1280, r.height = 720, r.horz_fov = 92, r.angle = {
  6459. yaw: 100,
  6460. pitch: 30
  6461. };
  6462. var n = new ArrayBuffer(8),
  6463. o = new DataView(n);
  6464. getTilesInView(r, n);
  6465. var a = n.slice(0);
  6466. this.PendingMasks.unshift({
  6467. buffer: a,
  6468. angle: r.angle
  6469. }), MaskSetToOne(18, this.PanoView), operateForDataView(o, this.PanoView, o, function (s, l) {
  6470. return s ^ s & l;
  6471. }), 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);
  6472. }
  6473. }, {
  6474. key: "processMetaWithTraceId",
  6475. value: function processMetaWithTraceId(e) {
  6476. var _iterator = _createForOfIteratorHelper$5(e.traceIds),
  6477. _step;
  6478. try {
  6479. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  6480. var t = _step.value;
  6481. if (this.traceIdMap.has(t)) {
  6482. var r = this.traceIdMap.get(t);
  6483. r != null && (r.receiveTime = Date.now(), r.status = 1);
  6484. }
  6485. if (t == this.PendingMovingTraceId) {
  6486. 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());
  6487. var _r = Date.now();
  6488. this.lastMoveResponseTime = _r, this.lastMoveProcessTime = _r, this.lastMoveDisplayTime = _r, this.frameServerCircular.clear(), this.frameClientCircular.clear();
  6489. }
  6490. }
  6491. } catch (err) {
  6492. _iterator.e(err);
  6493. } finally {
  6494. _iterator.f();
  6495. }
  6496. }
  6497. }, {
  6498. key: "onTraceId",
  6499. value: function onTraceId(e) {
  6500. var _this2 = this;
  6501. var r = e.traceId,
  6502. n = e.timestamp,
  6503. o = e.event;
  6504. if (o === "Rotation") {
  6505. var a = {
  6506. traceId: r,
  6507. pts: 0,
  6508. startTime: n,
  6509. receiveTime: 0,
  6510. readyTime: 0,
  6511. displayTime: 0,
  6512. status: 0
  6513. };
  6514. this.traceIdMap.set(r, a);
  6515. var s = setTimeout(function () {
  6516. if (s && clearTimeout(s), _this2.traceIdMap.has(r)) {
  6517. var l = _this2.traceIdMap.get(r);
  6518. switch (l == null ? void 0 : l.status) {
  6519. case 0:
  6520. {
  6521. _this2.responseMiss += 1;
  6522. break;
  6523. }
  6524. case 1:
  6525. {
  6526. _this2.processMiss += 1;
  6527. var u = l.receiveTime - l.startTime;
  6528. _this2.responseTimeArray.push(u);
  6529. break;
  6530. }
  6531. case 2:
  6532. {
  6533. _this2.displayMiss += 1;
  6534. var _u = l.receiveTime - l.startTime,
  6535. c = l.readyTime - l.receiveTime;
  6536. _this2.responseTimeArray.push(_u), _this2.processTimeArray.push(c);
  6537. break;
  6538. }
  6539. case 3:
  6540. defaultLogger.debug("status is 3");
  6541. }
  6542. }
  6543. }, 1e3);
  6544. } 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();
  6545. }
  6546. }, {
  6547. key: "executeFunction",
  6548. value: function executeFunction(e, t) {
  6549. if (this.functionMap.has(e)) {
  6550. var r = this.functionMap.get(e);
  6551. r != null && r(t);
  6552. }
  6553. }
  6554. }, {
  6555. key: "UpdateStats",
  6556. value: function UpdateStats(e) {
  6557. var _this3 = this;
  6558. var t;
  6559. (t = this._rtcp.connection) == null || t.getStats(null).then(function (r) {
  6560. r.forEach(function (n) {
  6561. n.type == "data-channel" && (_this3.rtcMessageReceived = n.messagesReceived - n.messagesSent, _this3.rtcBytesReceived = n.bytesReceived);
  6562. });
  6563. }), 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;
  6564. }
  6565. }, {
  6566. key: "ReceiveDecodeMessage",
  6567. value: function ReceiveDecodeMessage(e) {
  6568. var n;
  6569. if (!this.firstYUVReceived) {
  6570. this.firstYUVDecoded = e.data.yuv_ts;
  6571. var o = this.firstYUVDecoded - this.rtcp.network.room._startTime;
  6572. defaultLogger.infoAndReportMeasurement({
  6573. metric: "firstYUVDecodedAt",
  6574. value: o,
  6575. group: "joinRoom"
  6576. }), this.firstRender = Date.now();
  6577. var a = this.firstYUVDecoded - this.rtcp.network.room._startTime;
  6578. defaultLogger.infoAndReportMeasurement({
  6579. metric: "firstRenderAt",
  6580. value: a,
  6581. group: "joinRoom"
  6582. }), this.firstYUVReceived = !0, this.lastRenderTs = Date.now();
  6583. }
  6584. !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", {
  6585. stream: this.cachedStreams[this.setPtr],
  6586. width: this.cachedResolution[this.setPtr].width,
  6587. height: this.cachedResolution[this.setPtr].height,
  6588. pts: this.cachedPtss[this.setPtr]
  6589. }), this.executeFunction("signal", {
  6590. signal: this.cachedMetas[this.setPtr],
  6591. pts: this.cachedPtss[this.setPtr],
  6592. alreadyUpdateYUV: !0
  6593. })) : this.updateDropFrame += 1, this.decoderWorker.postMessage({
  6594. t: 2,
  6595. frameCnt: this.cachedPtss[this.setPtr],
  6596. buffer: this.cachedStreams[this.setPtr]
  6597. }, [this.cachedStreams[this.setPtr].buffer])), this.getPtr = (this.getPtr + 1) % this.cachedLength);
  6598. var t = e.data.metadata;
  6599. if ((n = t == null ? void 0 : t.traceIds) != null && n.length) {
  6600. var _iterator2 = _createForOfIteratorHelper$5(t.traceIds),
  6601. _step2;
  6602. try {
  6603. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  6604. var _o = _step2.value;
  6605. if (this.traceIdMap.has(_o)) {
  6606. var _a = this.traceIdMap.get(_o);
  6607. _a != null && (_a.readyTime = Date.now(), _a.status = 2);
  6608. }
  6609. }
  6610. } catch (err) {
  6611. _iterator2.e(err);
  6612. } finally {
  6613. _iterator2.f();
  6614. }
  6615. }
  6616. if (e.data.pts == this.moveStartPts && (this.MoveProcessDelay = Date.now() - this.StartMovingTs), this.userId_test = this.rtcp.network.room.userId, this.inMovingMode) {
  6617. var _o2 = Date.now(),
  6618. _a2 = _o2 - this.lastMoveProcessTime;
  6619. this.moveProcessCircular.add(_a2), this.lastMoveProcessTime = _o2;
  6620. }
  6621. var r = this.setPtr;
  6622. 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] = {
  6623. width: e.data.width,
  6624. height: e.data.height
  6625. }, this.setPtr = (this.setPtr + 1) % this.cachedLength;
  6626. }
  6627. }, {
  6628. key: "SendCacheFrameInfo",
  6629. value: function SendCacheFrameInfo(e) {
  6630. var _this4 = this;
  6631. var h, f, d, _, g, m, v;
  6632. var t = e.data.cachedKey,
  6633. r = e.data.metadata,
  6634. n = t,
  6635. o = r,
  6636. a = (d = (f = (h = o.newUserStates) == null ? void 0 : h.find(function (y) {
  6637. return y.userId === _this4.rtcp.network.room.userId;
  6638. })) == null ? void 0 : f.playerState) == null ? void 0 : d.roomTypeId,
  6639. s = this.rtcp.network.room.skinId,
  6640. l = (v = (m = (g = (_ = o.newUserStates) == null ? void 0 : _.find(function (y) {
  6641. return y.userId === _this4._rtcp.network.room.userId;
  6642. })) == null ? void 0 : g.playerState) == null ? void 0 : m.player) == null ? void 0 : v.position,
  6643. u = {
  6644. MsgType: 1,
  6645. FrameCacheMsg: {
  6646. FrameIndex: n,
  6647. RoomTypeId: a,
  6648. SkinID: s,
  6649. Position: l
  6650. }
  6651. };
  6652. var c = "";
  6653. try {
  6654. c = JSON.stringify(u);
  6655. } catch (y) {
  6656. defaultLogger.error(y);
  6657. return;
  6658. }
  6659. }
  6660. }, {
  6661. key: "ReceivePanoramaDecodeMessage",
  6662. value: function ReceivePanoramaDecodeMessage(e) {
  6663. defaultLogger.info("Receive Panorama Image in Workers.ts"), MaskSetToOne(e.data.tileId, this.PanoView);
  6664. var t = 0,
  6665. r;
  6666. var n = this.PendingMasks.length;
  6667. for (t = 0; t < n; t++) {
  6668. var o = this.PendingMasks[t].buffer,
  6669. a = new DataView(o),
  6670. s = new ArrayBuffer(8),
  6671. l = new DataView(s);
  6672. if (operateForDataView(this.PanoView, a, l, function (u, c) {
  6673. return c ^ u & c;
  6674. }), IsAll0(l)) {
  6675. r = this.PendingMasks[t].angle;
  6676. break;
  6677. }
  6678. }
  6679. for (var _o3 = t; _o3 < n; _o3++) {
  6680. this.PendingMasks.pop();
  6681. }
  6682. this.executeFunction("panorama", {
  6683. data: e.data.data,
  6684. tileId: e.data.tileId,
  6685. pos: {
  6686. x: e.data.x,
  6687. y: e.data.y,
  6688. z: e.data.z
  6689. },
  6690. uuid: e.data.uuid,
  6691. finished: !0,
  6692. matchAngle: r
  6693. });
  6694. }
  6695. }, {
  6696. key: "enable_decoder_queue_logging",
  6697. value: function enable_decoder_queue_logging() {
  6698. this.decoderWorker.postMessage({
  6699. t: 100,
  6700. status: !0
  6701. });
  6702. }
  6703. }, {
  6704. key: "disable_decoder_queue_logging",
  6705. value: function disable_decoder_queue_logging() {
  6706. this.decoderWorker.postMessage({
  6707. t: 100,
  6708. status: !1
  6709. });
  6710. }
  6711. }, {
  6712. key: "init",
  6713. value: function () {
  6714. var _init = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  6715. var _this5 = this;
  6716. var e,
  6717. r,
  6718. n,
  6719. t,
  6720. _args = arguments;
  6721. return regenerator.wrap(function _callee$(_context) {
  6722. while (1) {
  6723. switch (_context.prev = _context.next) {
  6724. case 0:
  6725. e = _args.length > 0 && _args[0] !== undefined ? _args[0] : {
  6726. width: 1280,
  6727. height: 720
  6728. };
  6729. for (r = 0; r < FRAME_COMPOSE_LENGTH; r++) {
  6730. n = {
  6731. buffer: new Uint8Array(2621440),
  6732. size: 0,
  6733. startReceiveTime: 0,
  6734. serverTime: 0,
  6735. frameCnt: -1
  6736. };
  6737. this.cacheFrameComposes.push(n);
  6738. }
  6739. t = new Blob([decoder], {
  6740. type: "application/javascript"
  6741. });
  6742. this.decoderWorker = new Worker(URL.createObjectURL(t));
  6743. this.decoderWorker.postMessage({
  6744. t: 9,
  6745. url: WASM_URLS[WASM_Version],
  6746. jitterLength: DECODER_PASSIVE_JITTER
  6747. });
  6748. this.decoderWorker.postMessage({
  6749. t: 1,
  6750. config: e
  6751. });
  6752. return _context.abrupt("return", new Promise(function (r) {
  6753. _this5.decoderWorker.onmessage = function (n) {
  6754. switch (n.data.t) {
  6755. case 0:
  6756. _this5.ReceiveDecodeMessage(n);
  6757. break;
  6758. case 1:
  6759. _this5.UpdateStats(n);
  6760. break;
  6761. case 2:
  6762. r();
  6763. break;
  6764. case 3:
  6765. _this5.SendCacheFrameInfo(n);
  6766. break;
  6767. case 4:
  6768. {
  6769. var o = new Date().toISOString(),
  6770. a = USER_ID + "-" + PAGE_SESSION + "-" + SERVER_SESSION + "-" + o + ".264";
  6771. uploadStream(COS_PREFIX + a, n.data.fileObj);
  6772. break;
  6773. }
  6774. case 5:
  6775. _this5.executeFunction("signal", {
  6776. signal: n.data.metadata,
  6777. pts: -1,
  6778. alreadyUpdateYUV: !1
  6779. });
  6780. break;
  6781. case 6:
  6782. defaultLogger.infoAndReportMeasurement(n.data), defaultLogger.debug("WASM Ready Cost");
  6783. break;
  6784. case 7:
  6785. _this5.ReceivePanoramaDecodeMessage(n);
  6786. break;
  6787. case 8:
  6788. {
  6789. var _o4 = {
  6790. MstType: 0
  6791. };
  6792. var _a3 = "";
  6793. try {
  6794. _a3 = JSON.stringify(_o4);
  6795. } catch (l) {
  6796. defaultLogger.error(l);
  6797. return;
  6798. }
  6799. var s = "wasm:" + _a3;
  6800. _this5._rtcp.sendStringData(s);
  6801. break;
  6802. }
  6803. case 9:
  6804. {
  6805. defaultLogger.info(n.data.printMsg);
  6806. break;
  6807. }
  6808. case 10:
  6809. {
  6810. defaultLogger.error(n.data.printMsg), _this5.executeFunction("error", {
  6811. code: n.data.code,
  6812. message: n.data.printMsg
  6813. });
  6814. break;
  6815. }
  6816. default:
  6817. defaultLogger.error("Receive unknown message event from decoder"), defaultLogger.debug(n.data);
  6818. break;
  6819. }
  6820. };
  6821. }));
  6822. case 7:
  6823. case "end":
  6824. return _context.stop();
  6825. }
  6826. }
  6827. }, _callee, this);
  6828. }));
  6829. function init() {
  6830. return _init.apply(this, arguments);
  6831. }
  6832. return init;
  6833. }()
  6834. }, {
  6835. key: "UpdateYUV",
  6836. value: function UpdateYUV() {
  6837. var t, r;
  6838. var e = this.getPtr;
  6839. if (this.cachedMetas[e] != null && !this.cachedRender[e]) {
  6840. var n = Date.now();
  6841. if (this.firstUpdateYUV) {
  6842. var h = ((t = this.cachedStreams[e]) == null ? void 0 : t.byteLength) || 0;
  6843. defaultLogger.infoAndReportMeasurement({
  6844. metric: "firstUpdateStreamLength",
  6845. value: h,
  6846. group: "joinRoom"
  6847. }), this.firstUpdateYUV = !1;
  6848. }
  6849. this.cachedStreams[e] != null && this.executeFunction("stream", {
  6850. stream: this.cachedStreams[e],
  6851. width: this.cachedResolution[e].width,
  6852. height: this.cachedResolution[e].height,
  6853. pts: this.cachedPtss[e]
  6854. });
  6855. var o = Date.now();
  6856. this.cachedStreams[e] != null && this.decoderWorker.postMessage({
  6857. t: 2,
  6858. frameCnt: this.cachedPtss[e],
  6859. buffer: this.cachedStreams[e]
  6860. }, [this.cachedStreams[e].buffer]);
  6861. var a = Date.now(),
  6862. s = o - n,
  6863. l = a - o;
  6864. (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;
  6865. var u = o - n;
  6866. this.updateYUVCircular.add(u);
  6867. var c = this.cachedMetas[e];
  6868. if ((r = c == null ? void 0 : c.traceIds) != null && r.length) {
  6869. var _iterator3 = _createForOfIteratorHelper$5(c.traceIds),
  6870. _step3;
  6871. try {
  6872. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  6873. var _h = _step3.value;
  6874. if (this.traceIdMap.has(_h)) {
  6875. var f = this.traceIdMap.get(_h);
  6876. if (f != null) {
  6877. f.displayTime = Date.now(), f.status = 3;
  6878. var d = f.receiveTime - f.startTime,
  6879. _ = f.readyTime - f.receiveTime,
  6880. g = f.displayTime - f.readyTime,
  6881. m = f.displayTime - f.startTime;
  6882. this.responseTimeArray.push(d), this.processTimeArray.push(_), this.displayTimeArray.push(g), this.overallTimeArray.push(m), this.traceIdMap.delete(_h);
  6883. }
  6884. }
  6885. }
  6886. } catch (err) {
  6887. _iterator3.e(err);
  6888. } finally {
  6889. _iterator3.f();
  6890. }
  6891. }
  6892. if (this.cachedPtss[e] == this.moveStartPts && (this.MoveDisplayDelay = Date.now() - this.StartMovingTs), this.inMovingMode) {
  6893. var _h2 = Date.now(),
  6894. _f = _h2 - this.lastMoveDisplayTime;
  6895. this.moveDisplayCircular.add(_f), this.lastMoveDisplayTime = _h2;
  6896. }
  6897. this.executeFunction("signal", {
  6898. signal: this.cachedMetas[e],
  6899. pts: this.cachedPtss[e],
  6900. alreadyUpdateYUV: !0
  6901. }), this.cachedRender[e] = !0, this.getPtr = (this.getPtr + 1) % this.cachedLength;
  6902. }
  6903. }
  6904. }, {
  6905. key: "unmarshalPano",
  6906. value: function unmarshalPano(e) {
  6907. var t = new DataView(e);
  6908. if (t.getUint32(0) != 1723558763) return !1;
  6909. console.log("Receive Pano Message"), t.getUint16(4);
  6910. var n = t.getUint16(6),
  6911. o = t.getUint32(8),
  6912. a = t.getUint32(12) - (1 << 30) * 2,
  6913. s = t.getUint32(16) - (1 << 30) * 2,
  6914. l = t.getUint32(20) - (1 << 30) * 2,
  6915. u = t.getUint32(24),
  6916. c = new Uint8Array(e).subarray(28, 64),
  6917. h = String.fromCharCode.apply(null, c),
  6918. f = t.getUint32(64),
  6919. d = e.byteLength - n;
  6920. if (d == u) {
  6921. var g = {
  6922. data: new Uint8Array(e).subarray(n),
  6923. mediaLen: u,
  6924. tileId: o,
  6925. uuid: h,
  6926. x: a,
  6927. y: s,
  6928. z: l
  6929. };
  6930. this.decoderWorker.postMessage({
  6931. t: 8,
  6932. data: g
  6933. });
  6934. } else {
  6935. var _ = new Uint8Array(e, n, d);
  6936. if (this.cachePanoTileID == o) {
  6937. if (this.panoCacheBuffer.set(_, f), this.panoCacheSize += d, this.panoCacheSize === u) {
  6938. var m = {
  6939. data: new Uint8Array(this.panoCacheBuffer).slice(0, u),
  6940. mediaLen: u,
  6941. tileId: o,
  6942. uuid: h,
  6943. x: a,
  6944. y: s,
  6945. z: l
  6946. };
  6947. this.decoderWorker.postMessage({
  6948. t: 8,
  6949. data: m
  6950. }), this.panoCacheSize = 0;
  6951. }
  6952. } else this.panoCacheBuffer.set(_, f), this.panoCacheSize = d, this.cachePanoTileID = o;
  6953. }
  6954. return !0;
  6955. }
  6956. }, {
  6957. key: "clearMoveArray",
  6958. value: function clearMoveArray() {
  6959. 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 = "";
  6960. }
  6961. }, {
  6962. key: "getIsMoving",
  6963. value: function getIsMoving(e) {
  6964. var t;
  6965. if (typeof e.newUserStates != "undefined") for (var r = 0; r < e.newUserStates.length; r++) {
  6966. var n = e.newUserStates[r];
  6967. if (n.userId == this.rtcp.network.room.userId) {
  6968. t = n.renderInfo.isMoving;
  6969. break;
  6970. }
  6971. }
  6972. return t;
  6973. }
  6974. }, {
  6975. key: "isHeartBeatPacket",
  6976. value: function isHeartBeatPacket(e, t) {
  6977. return new DataView(e).getUint32(0) == 2009889916;
  6978. }
  6979. }, {
  6980. key: "resetSendTimeDiff",
  6981. value: function resetSendTimeDiff() {
  6982. this.prevSenderTs = 0, this.serverSendTimeArray.clear();
  6983. }
  6984. }, {
  6985. key: "calcSendTimeDiff",
  6986. value: function calcSendTimeDiff(e) {
  6987. if (this.prevSenderTs == -1) {
  6988. this.prevSenderTs = e;
  6989. return;
  6990. }
  6991. var t = e - this.prevSenderTs;
  6992. this.serverSendTimeArray.add(t), this.prevSenderTs = e;
  6993. }
  6994. }, {
  6995. key: "unmarshalStream",
  6996. value: function unmarshalStream(e) {
  6997. var _this6 = this;
  6998. var T, C, A, S, P, R, M, x, I, w;
  6999. var t = new DataView(e);
  7000. if (t.getUint32(0) != 1437227610) return !1;
  7001. t.getUint16(4);
  7002. var n = t.getUint16(6),
  7003. o = t.getUint16(8),
  7004. a = o,
  7005. s = t.getUint16(10);
  7006. var l = !1;
  7007. s == 1 && (l = !0);
  7008. var u = t.getUint32(12),
  7009. c = t.getUint32(16),
  7010. h = t.getUint32(20),
  7011. f = t.getUint16(24),
  7012. d = t.getUint16(26),
  7013. _ = t.getUint32(28),
  7014. g = t.getUint32(n - 4),
  7015. m = u + c,
  7016. v = e.byteLength - n,
  7017. y = new Uint8Array(e, n, v);
  7018. this.calcSendTimeDiff(h);
  7019. var b;
  7020. if (this.inPanoMode && (c > 0 || f)) return defaultLogger.error("Stream Protocal Violation: receive illegal stream in Pano mode"), !0;
  7021. if (v === m) {
  7022. this.receivedMedia++;
  7023. var O = new Uint8Array(e).subarray(n);
  7024. h - this.lastServerTS > 60 ? this.serverFrameSlow++ : h - this.lastServerTS < 16 && this.serverFrameFast++;
  7025. var D = Date.now();
  7026. D - this.lastClientTS > 60 ? this.clientFrameSlow++ : D - this.lastClientTS < 16 && this.clientFrameFast++;
  7027. var F = c === 0,
  7028. V = h - this.lastServerTS;
  7029. 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;
  7030. var N = O.subarray(0, u),
  7031. L = Date.now(),
  7032. k = JSON.parse(this.Stringify(N)),
  7033. U = Date.now();
  7034. 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));
  7035. var z = this.getIsMoving(k);
  7036. if (this.inMovingMode && z == 0 && this.lastIsMoving == 1 && this.clearMoveArray(), typeof z != "undefined" && (this.lastIsMoving = z), this.inMovingMode) {
  7037. var G = Date.now(),
  7038. W = G - this.lastMoveResponseTime;
  7039. this.moveResponseCircular.add(W), this.lastMoveResponseTime = G;
  7040. }
  7041. (f || d) && (b = (P = (S = (A = (C = k.newUserStates) == null ? void 0 : C.find(function (G) {
  7042. return G.userId === _this6._rtcp.network.room.userId;
  7043. })) == null ? void 0 : A.playerState) == null ? void 0 : S.player) == null ? void 0 : P.position);
  7044. var H = {
  7045. t: 0,
  7046. data: O,
  7047. mediaLen: c,
  7048. metaLen: u,
  7049. metadata: k,
  7050. frameCnt: a,
  7051. server_ts: h,
  7052. isIDR: l,
  7053. cacheRequest: d,
  7054. cached: f,
  7055. cachedKey: _,
  7056. position: b
  7057. };
  7058. if (this.inPanoMode) return this.executeFunction("signal", {
  7059. signal: k,
  7060. pts: -1,
  7061. alreadyUpdateYUV: !0
  7062. }), !0;
  7063. if (this.decoderWorker.postMessage(H, [O.buffer]), !this.firstMediaReceived) {
  7064. this.firstMediaArraval = Date.now();
  7065. var _G = this.firstMediaArraval - this.rtcp.network.room._startTime;
  7066. defaultLogger.infoAndReportMeasurement({
  7067. metric: "firstMediaArravalAt",
  7068. value: _G,
  7069. group: "joinRoom"
  7070. }), this.firstMediaReceived = !0;
  7071. }
  7072. } else {
  7073. var _O = this.hasFrmCntInCache(a);
  7074. if (_O != -1) {
  7075. if (this.cacheFrameComposes[_O].buffer.set(y, g), this.cacheFrameComposes[_O].size += v, this.cacheFrameComposes[_O].size === m) {
  7076. var _D = new Uint8Array(this.cacheFrameComposes[_O].buffer).slice(0, m);
  7077. 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++;
  7078. var _F = Date.now();
  7079. _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;
  7080. var _V = _D.subarray(0, u),
  7081. _N = Date.now(),
  7082. _L = JSON.parse(this.Stringify(_V)),
  7083. _k = Date.now();
  7084. 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);
  7085. var _U = this.getIsMoving(_L);
  7086. if (this.inMovingMode && _U == 0 && this.lastIsMoving == 1 && this.clearMoveArray(), typeof _U != "undefined" && (this.lastIsMoving = _U), this.inMovingMode) {
  7087. var _H = Date.now(),
  7088. _G2 = _H - this.lastMoveResponseTime;
  7089. this.moveResponseCircular.add(_G2), this.lastMoveResponseTime = _H;
  7090. }
  7091. (f || d) && (b = (w = (I = (x = (M = _L.newUserStates) == null ? void 0 : M.find(function (H) {
  7092. return H.userId === _this6._rtcp.network.room.userId;
  7093. })) == null ? void 0 : x.playerState) == null ? void 0 : I.player) == null ? void 0 : w.position);
  7094. var _z = {
  7095. t: 0,
  7096. data: _D,
  7097. mediaLen: c,
  7098. metaLen: u,
  7099. metadata: _L,
  7100. frameCnt: a,
  7101. server_ts: h,
  7102. isIDR: l,
  7103. cacheRequest: d,
  7104. cached: f,
  7105. cachedKey: _,
  7106. position: b
  7107. };
  7108. if (this.inPanoMode) return this.executeFunction("signal", {
  7109. signal: _L,
  7110. pts: -1,
  7111. alreadyUpdateYUV: !0
  7112. }), !0;
  7113. if (this.decoderWorker.postMessage(_z, [_D.buffer]), !this.firstMediaReceived) {
  7114. this.firstMediaArraval = Date.now();
  7115. var _H2 = this.firstMediaArraval - this.rtcp.network.room._startTime;
  7116. defaultLogger.infoAndReportMeasurement({
  7117. metric: "firstMediaArravalAt",
  7118. value: _H2,
  7119. group: "joinRoom"
  7120. }), this.firstMediaReceived = !0;
  7121. }
  7122. } else this.cacheFrameComposes[_O].size > m && defaultLogger.debug("I frame exceed, cache size is ", this.cacheSize, ", total size is ", m);
  7123. } else if (_O == -1) {
  7124. var _D2 = this.hasFrmCntInCache(-1);
  7125. if (_D2 == -1) {
  7126. var _F2 = Date.now() + 1e18,
  7127. _V2 = -1;
  7128. for (var _N2 = 0; _N2 < this.cacheFrameComposes.length; _N2++) {
  7129. this.cacheFrameComposes[_N2].serverTime < _F2 && (_F2 = this.cacheFrameComposes[_N2].serverTime, _V2 = _N2);
  7130. }
  7131. _D2 = _V2;
  7132. }
  7133. 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;
  7134. }
  7135. }
  7136. return !0;
  7137. }
  7138. }, {
  7139. key: "reset",
  7140. value: function reset() {
  7141. defaultLogger.debug("Worker reset is called"), this.cacheFrameCnt = 0, this.receivedMedia = 0, this.reconnectSignal = !0, this.decoderWorker.postMessage({
  7142. t: 4
  7143. });
  7144. }
  7145. }, {
  7146. key: "dataHandleOff",
  7147. value: function dataHandleOff(e) {
  7148. defaultLogger.debug("hhh");
  7149. }
  7150. }, {
  7151. key: "dataHandle",
  7152. value: function dataHandle(e) {
  7153. this.saveframe && (this.decoderWorker.postMessage({
  7154. t: 6
  7155. }), this.saveframe = !1), this.SaveMediaStream && (this.decoderWorker.postMessage({
  7156. t: 7
  7157. }), this.SaveMediaStream = !1);
  7158. var t = new Uint8Array(e);
  7159. if (t.length >= 4 && this.isHeartBeatPacket(t.buffer, t.length) == !0) return;
  7160. if (t.length > 36 && this.unmarshalStream(t.buffer) == !0) {
  7161. this.reconnectSignal && (this.executeFunction("reconnectedFrame", {}), this.reconnectSignal = !1);
  7162. return;
  7163. }
  7164. if (t.length > 20 && this.unmarshalPano(t.buffer) == !0) return;
  7165. this.noWasmBytesReceived += e.byteLength;
  7166. var r = JSON.parse(this.Stringify(t));
  7167. this.executeFunction("signal", {
  7168. signal: r,
  7169. pts: -1,
  7170. alreadyUpdateYUV: !0
  7171. });
  7172. }
  7173. }, {
  7174. key: "changePanoMode",
  7175. value: function changePanoMode(e) {
  7176. this.inPanoMode = e;
  7177. }
  7178. }, {
  7179. key: "uploadDataToServer",
  7180. value: function uploadDataToServer() {
  7181. this.DynamicPanoTest == !0 && (this.onRotateInPanoMode({
  7182. traceId: "b2e1a296-6438-4371-8a31-687beb724ebe"
  7183. }), this.DynamicPanoTest = !1);
  7184. function e(ie, ee) {
  7185. return ee == -1 && (ee = 0), ie + ee;
  7186. }
  7187. function t(ie, ee) {
  7188. return Math.max(ie, ee);
  7189. }
  7190. var r = this.responseTimeArray.reduce(e, 0) / this.responseTimeArray.length || 0,
  7191. n = this.processTimeArray.reduce(e, 0) / this.processTimeArray.length || 0,
  7192. o = this.displayTimeArray.reduce(e, 0) / this.displayTimeArray.length || 0,
  7193. a = this.overallTimeArray.reduce(e, 0) / this.overallTimeArray.length || 0,
  7194. s = this.overallTimeArray.length;
  7195. this.responseTimeArray = [], this.processTimeArray = [], this.displayTimeArray = [], this.overallTimeArray = [];
  7196. var l = this.moveResponseCircular.getThreshPercent(),
  7197. u = l[0],
  7198. c = l[1],
  7199. h = l[2],
  7200. f = l[3],
  7201. d = l[4],
  7202. _ = d - f,
  7203. g = 1 - c / d || 0,
  7204. m = [u, c - u, h - c, f - h, _],
  7205. v = this.moveProcessCircular.getThreshPercent(),
  7206. y = v[0],
  7207. b = v[1],
  7208. T = v[2],
  7209. C = v[3],
  7210. A = v[4],
  7211. S = A - C,
  7212. P = 1 - b / A || 0,
  7213. R = [y, b - y, T - b, C - T, S],
  7214. M = this.moveDisplayCircular.getThreshPercent(),
  7215. x = M[0],
  7216. I = M[1],
  7217. w = M[2],
  7218. O = M[3],
  7219. D = M[4],
  7220. F = D - O,
  7221. V = 1 - I / D || 0,
  7222. N = [x, I - x, w - I, O - w, F],
  7223. L = x,
  7224. k = I - x,
  7225. U = w - I,
  7226. z = O - w,
  7227. H = F,
  7228. G = this.moveResponseCircular.getAvg(),
  7229. W = this.moveProcessCircular.getAvg(),
  7230. j = this.moveDisplayCircular.getAvg(),
  7231. B = this.moveResponseCircular.getMax(),
  7232. X = this.moveProcessCircular.getMax(),
  7233. $ = this.moveDisplayCircular.getMax(),
  7234. Y = this.moveResponseCircular.getStandardDeviation(),
  7235. K = this.moveProcessCircular.getStandardDeviation(),
  7236. Z = this.moveDisplayCircular.getStandardDeviation();
  7237. 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();
  7238. var q = this.frameServerCircular.getAvg(),
  7239. J = this.frameServerCircular.getMax();
  7240. this.frameClientCircular.getAvg(), this.frameClientCircular.getMax();
  7241. var Q = this.metaParseAraay.reduce(e, 0) / this.metaParseAraay.length || 0,
  7242. te = this.metaParseAraay.reduce(t, 0);
  7243. this.metaParseAraay = [];
  7244. var re = {
  7245. mediaBytesReceived: this.mediaBytesReceived,
  7246. metaBytesReceived: this.metaBytesReceived,
  7247. packetsLost: this.packetsLost,
  7248. timestamp: Date.now(),
  7249. frameHeight: 1280,
  7250. frameWidth: 720,
  7251. framesReceived: this.receivedMedia,
  7252. framesReceivedWorker: this.receivedMedia_worker,
  7253. framesDecoded: this.receivedYUV,
  7254. framesEmited: this.receivedEmit,
  7255. decodeTimePerFrame: this.decodeTimePerFrame,
  7256. decodeTimeMaxFrame: this.decodeTimeMaxFrame,
  7257. packetsDrop: this.packetsDrop,
  7258. framesAwait: this.framesAwait,
  7259. firstMediaArraval: this.firstMediaArraval,
  7260. firstYUVDecoded: this.firstYUVDecoded,
  7261. firstRender: this.firstRender,
  7262. returnFrames: this.returnFrames,
  7263. sendOutBuffer: this.sendOutBuffer,
  7264. maxGraphicTime: this.updateYUVCircular.getMax(),
  7265. averageGraphicTime: this.updateYUVCircular.getAvg(),
  7266. jankTimes: this.JankTimes,
  7267. bigJankTimes: this.bigJankTimes,
  7268. decodeJankTimes: this.DecodeJankTimes,
  7269. bigDecodeJankTimes: this.bigDecodeJankTimes,
  7270. serverFrameSlow: this.serverFrameSlow,
  7271. serverFrameFast: this.serverFrameFast,
  7272. clientFrameSlow: this.clientFrameSlow,
  7273. clientFrameFast: this.clientFrameFast,
  7274. rtcMessageReceived: this.rtcMessageReceived,
  7275. rtcBytesReceived: this.rtcBytesReceived - this.noWasmBytesReceived,
  7276. receiveIframes: this.receiveIframes,
  7277. decodeIframes: this.decodeIframes,
  7278. avgResponseTime: r,
  7279. avgProcessTime: n,
  7280. avgDisplayTime: o,
  7281. avgOverallTime: a,
  7282. overallTimeCount: s,
  7283. responseMiss: this.responseMiss,
  7284. processMiss: this.processMiss,
  7285. displayMiss: this.displayMiss,
  7286. updateDropFrame: this.updateDropFrame,
  7287. moveEvent: this.moveEvent,
  7288. avgResponseMoveDiff: this.moveEvent == "MoveTo" ? G : 0,
  7289. avgProcessMoveDiff: this.moveEvent == "MoveTo" ? W : 0,
  7290. avgDisplayMoveDiff: this.moveEvent == "MoveTo" ? j : 0,
  7291. maxResponseMoveDiff: this.moveEvent == "MoveTo" ? B : 0,
  7292. maxProcessMoveDiff: this.moveEvent == "MoveTo" ? X : 0,
  7293. maxDisplayMoveDiff: this.moveEvent == "MoveTo" ? $ : 0,
  7294. moveResponseJank: this.moveEvent == "MoveTo" ? g : 0,
  7295. moveProcessJank: this.moveEvent == "MoveTo" ? P : 0,
  7296. moveDisplayJank: this.moveEvent == "MoveTo" ? V : 0,
  7297. moveResponseCounts: this.moveEvent == "MoveTo" ? m.toString() : "0,0,0,0,0",
  7298. moveProcessCounts: this.moveEvent == "MoveTo" ? R.toString() : "0,0,0,0,0",
  7299. moveDisplayCounts: this.moveEvent == "MoveTo" ? N.toString() : "0,0,0,0,0",
  7300. MoveDisplayCountGood: this.moveEvent == "MoveTo" ? L.toString() : "0",
  7301. MoveDisplayCountWell: this.moveEvent == "MoveTo" ? k.toString() : "0",
  7302. MoveDisplayCountFair: this.moveEvent == "MoveTo" ? U.toString() : "0",
  7303. MoveDisplayCountBad: this.moveEvent == "MoveTo" ? z.toString() : "0",
  7304. MoveDisplayCountRest: this.moveEvent == "MoveTo" ? H.toString() : "0",
  7305. moveResponseDelay: this.moveEvent == "MoveTo" ? this.MoveResponseDelay : 0,
  7306. moveProcessDelay: this.moveEvent == "MoveTo" ? this.MoveProcessDelay : 0,
  7307. moveDisplayDelay: this.moveEvent == "MoveTo" ? this.MoveDisplayDelay : 0,
  7308. sdMoveResponseLongTime: Y,
  7309. sdMoveProcessLongTime: K,
  7310. sdMoveDisplayLongTime: Z,
  7311. avgResponseFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? G : 0,
  7312. avgProcessFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? W : 0,
  7313. avgDisplayFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? j : 0,
  7314. maxResponseFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? B : 0,
  7315. maxProcessFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? X : 0,
  7316. maxDisplayFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? $ : 0,
  7317. flyResponseJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? g : 0,
  7318. flyProcessJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? P : 0,
  7319. flyDisplayJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? V : 0,
  7320. flyResponseCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? m.toString() : "0,0,0,0,0",
  7321. flyProcessCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? R.toString() : "0,0,0,0,0",
  7322. flyDisplayCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? N.toString() : "0,0,0,0,0",
  7323. flyResponseDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveResponseDelay : 0,
  7324. flyProcessDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveProcessDelay : 0,
  7325. flyDisplayDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveDisplayDelay : 0,
  7326. avgMetaParseTime: Q,
  7327. maxMetaParseTime: te,
  7328. avgServerDiff: q,
  7329. maxServerDiff: J,
  7330. streamType: WASM_Version
  7331. };
  7332. return this.lastReturnFrames = this.returnFrames, this.lastReceivedEmit = this.receivedEmit, re;
  7333. }
  7334. }]);
  7335. return Workers;
  7336. }();
  7337. 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); }; }
  7338. 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; } }
  7339. var Rtcp = /*#__PURE__*/function (_EventEmitter) {
  7340. _inherits(Rtcp, _EventEmitter);
  7341. var _super = _createSuper$8(Rtcp);
  7342. function Rtcp(e) {
  7343. var _this;
  7344. _classCallCheck(this, Rtcp);
  7345. _this = _super.call(this);
  7346. E(_assertThisInitialized(_this), "connection", null);
  7347. E(_assertThisInitialized(_this), "inputChannel", null);
  7348. E(_assertThisInitialized(_this), "mediaStream");
  7349. E(_assertThisInitialized(_this), "socket");
  7350. E(_assertThisInitialized(_this), "connected", !1);
  7351. E(_assertThisInitialized(_this), "candidates", []);
  7352. E(_assertThisInitialized(_this), "isAnswered", !1);
  7353. E(_assertThisInitialized(_this), "isFlushing", !1);
  7354. E(_assertThisInitialized(_this), "inputReady", !1);
  7355. E(_assertThisInitialized(_this), "workers");
  7356. E(_assertThisInitialized(_this), "actived", !0);
  7357. E(_assertThisInitialized(_this), "heartbeat");
  7358. E(_assertThisInitialized(_this), "onIcecandidate", function (e) {
  7359. if (e.candidate != null) {
  7360. var t = JSON.stringify(e.candidate);
  7361. logger$1.debug("Got ice candidate: ".concat(t)), _this.network.socket.send({
  7362. id: "ice_candidate",
  7363. data: btoa(t)
  7364. });
  7365. }
  7366. });
  7367. E(_assertThisInitialized(_this), "onIcecandidateerror", function (e) {
  7368. logger$1.error("onicecandidateerror", e.errorCode, e.errorText, e);
  7369. });
  7370. E(_assertThisInitialized(_this), "onIceStateChange", function (e) {
  7371. switch (e.target.iceGatheringState) {
  7372. case "gathering":
  7373. logger$1.info("ice gathering");
  7374. break;
  7375. case "complete":
  7376. logger$1.info("Ice gathering completed");
  7377. }
  7378. });
  7379. E(_assertThisInitialized(_this), "onIceConnectionStateChange", function () {
  7380. if (!!_this.connection) switch (logger$1.info("iceConnectionState: ".concat(_this.connection.iceConnectionState)), _this.connection.iceConnectionState) {
  7381. case "connected":
  7382. {
  7383. _this.connected = !0;
  7384. break;
  7385. }
  7386. case "disconnected":
  7387. {
  7388. _this.connected = !1, _this.emit("rtcDisconnected");
  7389. break;
  7390. }
  7391. case "failed":
  7392. {
  7393. _this.emit("rtcDisconnected"), _this.connected = !1;
  7394. break;
  7395. }
  7396. }
  7397. });
  7398. E(_assertThisInitialized(_this), "setRemoteDescription", /*#__PURE__*/function () {
  7399. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e, t) {
  7400. var a, s, l, r, n, o, u;
  7401. return regenerator.wrap(function _callee$(_context) {
  7402. while (1) {
  7403. switch (_context.prev = _context.next) {
  7404. case 0:
  7405. if (_this.connection) {
  7406. _context.next = 2;
  7407. break;
  7408. }
  7409. return _context.abrupt("return");
  7410. case 2:
  7411. r = JSON.parse(atob(e)), n = new RTCSessionDescription(r);
  7412. _context.next = 5;
  7413. return _this.connection.setRemoteDescription(n);
  7414. case 5:
  7415. _context.next = 7;
  7416. return _this.connection.createAnswer();
  7417. case 7:
  7418. o = _context.sent;
  7419. 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) {
  7420. u = o.sdp.lastIndexOf("a=mid:1");
  7421. o.sdp = o.sdp.slice(0, u) + "a=mid:2" + o.sdp.slice(u + 7);
  7422. }
  7423. _context.prev = 9;
  7424. _context.next = 12;
  7425. return _this.connection.setLocalDescription(o);
  7426. case 12:
  7427. _context.next = 17;
  7428. break;
  7429. case 14:
  7430. _context.prev = 14;
  7431. _context.t0 = _context["catch"](9);
  7432. logger$1.error("error", _context.t0);
  7433. case 17:
  7434. _this.isAnswered = !0, _this.network.rtcp.flushCandidate(), _this.network.socket.send({
  7435. id: "answer",
  7436. data: btoa(JSON.stringify(o))
  7437. }), t.srcObject = _this.mediaStream;
  7438. case 18:
  7439. case "end":
  7440. return _context.stop();
  7441. }
  7442. }
  7443. }, _callee, null, [[9, 14]]);
  7444. }));
  7445. return function (_x, _x2) {
  7446. return _ref.apply(this, arguments);
  7447. };
  7448. }());
  7449. E(_assertThisInitialized(_this), "flushCandidate", function () {
  7450. _this.isFlushing || !_this.isAnswered || (_this.isFlushing = !0, _this.candidates.forEach(function (e) {
  7451. var t = atob(e),
  7452. r = JSON.parse(t);
  7453. if (/172\./.test(r.candidate)) return;
  7454. var n = new RTCIceCandidate(r);
  7455. _this.connection && _this.connection.addIceCandidate(n).then(function () {}, function (o) {
  7456. logger$1.info("add candidate failed", o);
  7457. });
  7458. }), _this.isFlushing = !1);
  7459. });
  7460. E(_assertThisInitialized(_this), "input", function (e) {
  7461. var t;
  7462. !_this.actived || !_this.inputChannel || _this.inputChannel.readyState === "open" && ((t = _this.inputChannel) == null || t.send(e));
  7463. });
  7464. _this.network = e, _this.workers = new Workers(_assertThisInitialized(_this), logger$1), _this.workers.registerLogger(logger$1), _this.workers.registerFunction("data", function (t) {
  7465. _this.emit("data", t);
  7466. }), _this.heartbeat = new Heartbeat({
  7467. ping: function ping(t) {
  7468. e.room.actionsHandler.echo(t);
  7469. },
  7470. pong(t, r) {
  7471. var n;
  7472. r && t > 500 && logger$1.warn("high hb value ".concat(t, ", traceId:") + r), (n = e.room.stats) == null || n.assign({
  7473. hb: t
  7474. });
  7475. }
  7476. });
  7477. return _this;
  7478. }
  7479. _createClass(Rtcp, [{
  7480. key: "start",
  7481. value: function start() {
  7482. var _this2 = this;
  7483. this.connection = new RTCPeerConnection();
  7484. var e = Date.now();
  7485. this.connection.ondatachannel = function (t) {
  7486. logger$1.info("ondatachannel: ".concat(t.channel.label));
  7487. _this2.inputChannel = t.channel;
  7488. _this2.inputChannel.onopen = function () {
  7489. var r;
  7490. 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({
  7491. metric: "datachannelOpenedAt",
  7492. startTime: _this2.network.room._startTime,
  7493. group: "joinRoom"
  7494. }), logger$1.infoAndReportMeasurement({
  7495. metric: "datachannelOpenedCost",
  7496. startTime: e,
  7497. group: "joinRoom"
  7498. }));
  7499. console.log('this.inputChannel', _this2.inputChannel);
  7500. }, _this2.inputChannel.onclose = function () {
  7501. var r;
  7502. return logger$1.info("The input channel has closed, id:", (r = _this2.inputChannel) == null ? void 0 : r.id);
  7503. }, _this2.inputChannel.onmessage = function (r) {
  7504. // console.log('this.workers',this.workers)
  7505. //console.log('inputChannel',r.data)
  7506. _this2.workers.dataHandle(r.data);
  7507. };
  7508. }, this.connection.oniceconnectionstatechange = this.onIceConnectionStateChange, this.connection.onicegatheringstatechange = this.onIceStateChange, this.connection.onicecandidate = this.onIcecandidate, this.connection.onicecandidateerror = this.onIcecandidateerror, this.network.socket.send({
  7509. id: "init_webrtc",
  7510. data: JSON.stringify({
  7511. is_mobile: !0
  7512. })
  7513. });
  7514. }
  7515. }, {
  7516. key: "addCandidate",
  7517. value: function addCandidate(e) {
  7518. e === "" ? this.network.rtcp.flushCandidate() : this.candidates.push(e);
  7519. }
  7520. }, {
  7521. key: "disconnect",
  7522. value: function disconnect() {
  7523. var e, t, r;
  7524. 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;
  7525. }
  7526. }, {
  7527. key: "sendStringData",
  7528. value: function sendStringData(e) {
  7529. console.log('e', e);
  7530. this.input(e);
  7531. }
  7532. }, {
  7533. key: "sendData",
  7534. value: function sendData(e) {
  7535. var t = "";
  7536. try {
  7537. t = JSON.stringify(e);
  7538. } catch (r) {
  7539. logger$1.error(r);
  7540. return;
  7541. }
  7542. this.input(t);
  7543. }
  7544. }]);
  7545. return Rtcp;
  7546. }(EventEmitter);
  7547. var NetworkMonitor = /*#__PURE__*/function () {
  7548. function NetworkMonitor(e) {
  7549. _classCallCheck(this, NetworkMonitor);
  7550. this._listener = e;
  7551. }
  7552. _createClass(NetworkMonitor, [{
  7553. key: "isOnline",
  7554. get: function get() {
  7555. var e = window.navigator;
  7556. return typeof e.onLine == "boolean" ? e.onLine : !0;
  7557. }
  7558. }, {
  7559. key: "start",
  7560. value: function start() {
  7561. window.addEventListener("online", this._listener), window.addEventListener("offline", this._listener);
  7562. }
  7563. }, {
  7564. key: "stop",
  7565. value: function stop() {
  7566. window.removeEventListener("online", this._listener), window.removeEventListener("offline", this._listener);
  7567. }
  7568. }]);
  7569. return NetworkMonitor;
  7570. }();
  7571. var Stream = /*#__PURE__*/function () {
  7572. function Stream(e) {
  7573. _classCallCheck(this, Stream);
  7574. this.el = null;
  7575. this._streamPlayTimer = null;
  7576. if (!e) {
  7577. this.el = this.createVideoElement();
  7578. return;
  7579. }
  7580. this.el = e;
  7581. }
  7582. _createClass(Stream, [{
  7583. key: "play",
  7584. value: function play() {
  7585. var _this = this;
  7586. return new Promise(function (e, t) {
  7587. _this._streamPlayTimer = new Timeout(function () {
  7588. t(new InternalError("Stream play timeout"));
  7589. }, 5e3), _this.el && _this.el.play().then(function () {
  7590. var r;
  7591. e(), logger$1.info("Media can autoplay"), (r = _this._streamPlayTimer) == null || r.clear();
  7592. }).catch(function (r) {
  7593. var n;
  7594. logger$1.error("Media Failed to autoplay"), logger$1.error(r), t(new InternalError("Media Failed to autoplay")), (n = _this._streamPlayTimer) == null || n.clear();
  7595. });
  7596. });
  7597. }
  7598. }, {
  7599. key: "createVideoElement",
  7600. value: function createVideoElement() {
  7601. var e = document.createElement("video");
  7602. 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;
  7603. }
  7604. }]);
  7605. return Stream;
  7606. }();
  7607. 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); }; }
  7608. 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; } }
  7609. 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 ";
  7610. var NetworkController = /*#__PURE__*/function (_EventEmitter) {
  7611. _inherits(NetworkController, _EventEmitter);
  7612. var _super = _createSuper$7(NetworkController);
  7613. function NetworkController(e) {
  7614. var _this;
  7615. _classCallCheck(this, NetworkController);
  7616. _this = _super.call(this);
  7617. _this.socket = null;
  7618. _this.rtcp = null;
  7619. _this.stream = null;
  7620. _this._state = 'connecting';
  7621. _this._networkMonitor = null;
  7622. _this.blockedActions = [];
  7623. _this.reconnectCount = 0;
  7624. _this.room = e, _this.socket = new Socket(_assertThisInitialized(_this));
  7625. _this.rtcp = new Rtcp(_assertThisInitialized(_this));
  7626. _this.stream = new Stream();
  7627. _this._networkMonitor = new NetworkMonitor(function () {
  7628. 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());
  7629. });
  7630. _this.checkNetworkQuality(_this.room.currentNetworkOptions.wsServerUrl);
  7631. _this._networkMonitor.start();
  7632. new VisibilityChangeHandler().subscribe(function (r) {
  7633. var n, o;
  7634. r ? ((o = _this.room.stats) == null || o.disable(), logger$1.infoAndReportMeasurement({
  7635. metric: "pageHide",
  7636. startTime: Date.now()
  7637. })) : ((n = _this.room.stats) == null || n.enable(), logger$1.infoAndReportMeasurement({
  7638. metric: "pageShow",
  7639. startTime: Date.now(),
  7640. extra: {
  7641. state: _this._state
  7642. }
  7643. }), _this._state === "disconnected" && _this.reconnect());
  7644. });
  7645. return _this;
  7646. }
  7647. _createClass(NetworkController, [{
  7648. key: "startGame",
  7649. value: function startGame() {
  7650. var _this2 = this;
  7651. return new Promise(function (e, t) {
  7652. if (!_this2.rtcp.connected) return t(new InternalError("Game cannot load. Please refresh"));
  7653. if (!_this2.rtcp.inputReady) return t(new InternalError("Game is not ready yet. Please wait"));
  7654. _this2.socket.on("gameRoomAvailable", function (r) {
  7655. _this2.setState("connected"), e(r), _this2.rtcp.heartbeat.start();
  7656. }), _this2.socket.on("socketClosed", function (r) {
  7657. t(r);
  7658. }), _this2.socket.startGame();
  7659. });
  7660. }
  7661. }, {
  7662. key: "addBlockedActions",
  7663. value: function addBlockedActions(e) {
  7664. var _this$blockedActions;
  7665. (_this$blockedActions = this.blockedActions).push.apply(_this$blockedActions, _toConsumableArray(e));
  7666. }
  7667. }, {
  7668. key: "removeBlockedActions",
  7669. value: function removeBlockedActions(e) {
  7670. if (!e) {
  7671. this.blockedActions = [];
  7672. return;
  7673. }
  7674. var t = this.blockedActions.indexOf(e);
  7675. this.blockedActions.splice(t, 1);
  7676. }
  7677. }, {
  7678. key: "setState",
  7679. value: function setState(e) {
  7680. this._state !== e && (logger$1.info("Set network state to ", e), this._state = e);
  7681. }
  7682. }, {
  7683. key: "connectAndStart",
  7684. value: function () {
  7685. var _connectAndStart = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  7686. return regenerator.wrap(function _callee$(_context) {
  7687. while (1) {
  7688. switch (_context.prev = _context.next) {
  7689. case 0:
  7690. return _context.abrupt("return", this.connect(e).then(this.startGame));
  7691. case 1:
  7692. case "end":
  7693. return _context.stop();
  7694. }
  7695. }
  7696. }, _callee, this);
  7697. }));
  7698. function connectAndStart(_x) {
  7699. return _connectAndStart.apply(this, arguments);
  7700. }
  7701. return connectAndStart;
  7702. }()
  7703. }, {
  7704. key: "connect",
  7705. value: function () {
  7706. var _connect = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  7707. var _this3 = this;
  7708. var e,
  7709. _args2 = arguments;
  7710. return regenerator.wrap(function _callee2$(_context2) {
  7711. while (1) {
  7712. switch (_context2.prev = _context2.next) {
  7713. case 0:
  7714. e = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : !1;
  7715. this.room.updateCurrentNetworkOptions({
  7716. reconnect: e
  7717. });
  7718. return _context2.abrupt("return", new Promise(function (t, r) {
  7719. _this3.rtcp.on("rtcConnected", function () {
  7720. _this3.setState("connected"), t();
  7721. }), _this3.rtcp.on("rtcDisconnected", function () {
  7722. 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());
  7723. }), _this3.socket.on("socketQuit", function () {
  7724. logger$1.info("socket quit success"), _this3.setState("closed");
  7725. }), _this3.socket.on("socketClosed", function (n) {
  7726. _this3._state === "connecting" && (_this3.setState("disconnected"), r(n)), r(n);
  7727. }), _this3.socket.start();
  7728. }));
  7729. case 3:
  7730. case "end":
  7731. return _context2.stop();
  7732. }
  7733. }
  7734. }, _callee2, this);
  7735. }));
  7736. function connect() {
  7737. return _connect.apply(this, arguments);
  7738. }
  7739. return connect;
  7740. }()
  7741. }, {
  7742. key: "reconnect",
  7743. value: function reconnect() {
  7744. var _this4 = this;
  7745. if (this.room.viewMode === "observer") return;
  7746. var e = Date.now();
  7747. if (this.reconnectCount++, this.reconnectCount > MAX_RECONNECT_COUNT) {
  7748. logger$1.error("reconnect failed, reached max reconnect count", MAX_RECONNECT_COUNT), this.reconnectCount = 0, this.emit("stateChanged", {
  7749. state: "disconnected"
  7750. });
  7751. return;
  7752. }
  7753. return logger$1.info("start reconnect, count:", this.reconnectCount), this._reconnect().then(function () {
  7754. logger$1.infoAndReportMeasurement({
  7755. startTime: e,
  7756. metric: "reconnect"
  7757. });
  7758. }).catch(function (t) {
  7759. if (logger$1.infoAndReportMeasurement({
  7760. startTime: e,
  7761. metric: "reconnect",
  7762. error: t
  7763. }), t.code === Codes.RepeatLogin) {
  7764. _this4.room.handleRepetLogin();
  7765. return;
  7766. }
  7767. var r = 1e3;
  7768. logger$1.info("reconnect failed, wait " + r + " ms for next reconnect"), setTimeout(function () {
  7769. _this4.reconnect();
  7770. }, r);
  7771. });
  7772. }
  7773. }, {
  7774. key: "_reconnect",
  7775. value: function _reconnect() {
  7776. var _this5 = this;
  7777. 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", {
  7778. state: "reconnecting",
  7779. count: this.reconnectCount
  7780. }), this.socket.off("gameRoomAvailable"), this.socket.off("socketClosed"), this.rtcp.off("rtcDisconnected"), this.rtcp.off("rtcConnected"), this.connectAndStart(!0).then(function (_ref) {
  7781. var e = _ref.session_id;
  7782. _this5.room.updateCurrentNetworkOptions({
  7783. sessionId: e
  7784. }), reporter.updateBody({
  7785. serverSession: e
  7786. }), logger$1.info("reconnect success"), _this5.setState("connected"), _this5.reconnectCount = 0, _this5.emit("stateChanged", {
  7787. state: "reconnected"
  7788. });
  7789. }));
  7790. }
  7791. }, {
  7792. key: "prepareReconnect",
  7793. value: function prepareReconnect() {
  7794. this.rtcp.disconnect(), this.socket.prepareReconnect(), this.prepareReconnectOptions();
  7795. }
  7796. }, {
  7797. key: "prepareReconnectOptions",
  7798. value: function prepareReconnectOptions() {
  7799. var _ref2 = this.room.currentClickingState || {},
  7800. e = _ref2.camera,
  7801. t = _ref2.player;
  7802. e && t && this.room.updateCurrentNetworkOptions({
  7803. camera: e,
  7804. player: t
  7805. });
  7806. }
  7807. }, {
  7808. key: "sendRtcData",
  7809. value: function sendRtcData(e) {
  7810. if (this.blockedActions.includes(e.action_type)) {
  7811. logger$1.info("action: ".concat(Actions[e.action_type], " was blocked"));
  7812. return;
  7813. }
  7814. this.rtcp.sendData(e);
  7815. }
  7816. }, {
  7817. key: "sendSocketData",
  7818. value: function sendSocketData(e) {
  7819. logger$1.debug("ws send ->", e), this.socket.send(e);
  7820. }
  7821. }, {
  7822. key: "quit",
  7823. value: function quit() {
  7824. var e = util.uuid(),
  7825. t = {
  7826. action_type: Actions.Exit,
  7827. trace_id: e,
  7828. exit_action: {},
  7829. user_id: this.room.options.userId,
  7830. packet_id: e
  7831. };
  7832. this.setState("closed"), this.socket.quit(), this.sendRtcData(t);
  7833. }
  7834. }, {
  7835. key: "checkNetworkQuality",
  7836. value: function checkNetworkQuality(i) {
  7837. var worker = null;
  7838. if (!i) return;
  7839. var e = Date.now();
  7840. if (this.pingOthers("https://www.baidu.com", function (t, r) {
  7841. logger$1.infoAndReportMeasurement({
  7842. metric: "baiduRtt",
  7843. group: "http",
  7844. value: r,
  7845. startTime: e
  7846. });
  7847. }), !worker) {
  7848. var t = new Blob([workerSourceCode], {
  7849. type: "application/javascript"
  7850. });
  7851. worker = new Worker(URL.createObjectURL(t)), worker.onmessage = function (r) {
  7852. logger$1.infoAndReportMeasurement({
  7853. metric: "workerRtt",
  7854. group: "http",
  7855. startTime: e,
  7856. value: r.data
  7857. });
  7858. };
  7859. }
  7860. }
  7861. }, {
  7862. key: "pingOthers",
  7863. value: function pingOthers(i, e) {
  7864. var t = !1;
  7865. var r = new Image();
  7866. r.onload = o, r.onerror = a;
  7867. var n = Date.now();
  7868. function o(l) {
  7869. t = !0, s();
  7870. }
  7871. function a(l) {}
  7872. function s() {
  7873. var l = Date.now() - n;
  7874. if (typeof e == "function") return t ? e(null, l) : (console.error("error loading resource"), e("error", l));
  7875. }
  7876. r.src = i + "/favicon.ico?" + +new Date();
  7877. }
  7878. }]);
  7879. return NetworkController;
  7880. }(EventEmitter);
  7881. var AssetTypeName = {
  7882. Config: 'CONFIG',
  7883. Model: 'MODEL',
  7884. Vedio: 'VEDIO',
  7885. Media: 'MEDIA',
  7886. Effects: 'EFFECTS',
  7887. Gift: 'GIFT',
  7888. Textures: 'TEXTURES'
  7889. };
  7890. var AssetClassName = {
  7891. Effects: '\u7279\u6548',
  7892. Tv: 'TV',
  7893. Lpm: '\u7C97\u6A21',
  7894. Reward: '\u571F\u8C6A\u699C',
  7895. Env: '\u73AF\u5883\u5149',
  7896. Gbq: '\u544A\u767D\u5899',
  7897. BreathPoint: '\u547C\u5438\u70B9',
  7898. Gifts: '\u9001\u793C',
  7899. Panorama: '\u5168\u666F\u56FE',
  7900. GiftBubble: '\u9001\u793C\u6C14\u6CE1',
  7901. SayBubble: '\u804A\u5929\u6C14\u6CE1'
  7902. };
  7903. var LoggerLevels$1 = {
  7904. Debug: 1,
  7905. Info: 2,
  7906. Warn: 3,
  7907. Error: 4,
  7908. Off: 5
  7909. };
  7910. var EShaderMode = {
  7911. default: 0,
  7912. video: 1,
  7913. videoAndPano: 2
  7914. };
  7915. var EFitMode = {
  7916. fill: 'fill',
  7917. contain: 'contain',
  7918. cover: 'cover'
  7919. };
  7920. var BaseTable = /*#__PURE__*/function () {
  7921. function BaseTable(e, t) {
  7922. _classCallCheck(this, BaseTable);
  7923. this.db = null;
  7924. this.isCreatingTable = !1;
  7925. this.hasCleared = !1;
  7926. this.dbName = e, this.dbVersion = t;
  7927. }
  7928. _createClass(BaseTable, [{
  7929. key: "clearDataBase",
  7930. value: function () {
  7931. var _clearDataBase = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  7932. var _this = this;
  7933. return regenerator.wrap(function _callee$(_context) {
  7934. while (1) {
  7935. switch (_context.prev = _context.next) {
  7936. case 0:
  7937. return _context.abrupt("return", this.hasCleared || (e && (this.hasCleared = !0), !window.indexedDB.databases) ? Promise.resolve() : new Promise(function (t, r) {
  7938. var n = window.indexedDB.deleteDatabase(_this.dbName);
  7939. n.onsuccess = function () {
  7940. t();
  7941. }, n.onerror = r;
  7942. }));
  7943. case 1:
  7944. case "end":
  7945. return _context.stop();
  7946. }
  7947. }
  7948. }, _callee, this);
  7949. }));
  7950. function clearDataBase(_x) {
  7951. return _clearDataBase.apply(this, arguments);
  7952. }
  7953. return clearDataBase;
  7954. }()
  7955. }, {
  7956. key: "tableName",
  7957. value: function tableName() {
  7958. throw new Error("Derived class have to override 'tableName', and set a proper table name!");
  7959. }
  7960. }, {
  7961. key: "keyPath",
  7962. value: function keyPath() {
  7963. throw new Error("Derived class have to override 'keyPath', and set a proper index name!");
  7964. }
  7965. }, {
  7966. key: "index",
  7967. value: function index() {
  7968. throw new Error("Derived class have to override 'index', and set a proper index name!");
  7969. }
  7970. }, {
  7971. key: "checkAndOpenDatabase",
  7972. value: function () {
  7973. var _checkAndOpenDatabase = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  7974. var _this2 = this;
  7975. return regenerator.wrap(function _callee2$(_context2) {
  7976. while (1) {
  7977. switch (_context2.prev = _context2.next) {
  7978. case 0:
  7979. return _context2.abrupt("return", this.db ? Promise.resolve(this.db) : new Promise(function (e, t) {
  7980. var n = setTimeout(function () {
  7981. logger$1.info("wait db to open for", 200), _this2.db ? e(_this2.db) : e(_this2.checkAndOpenDatabase()), clearTimeout(n);
  7982. }, 200);
  7983. _this2.openDatabase(_this2.dbName, _this2.dbVersion || 1, function () {
  7984. _this2.db && !_this2.isCreatingTable && e(_this2.db), logger$1.info("successCallback called, this.db: ".concat(!!_this2.db, ", this.isCreatingStore: ").concat(_this2.isCreatingTable)), clearTimeout(n);
  7985. }, function () {
  7986. t(new Error("Failed to open database!")), clearTimeout(n);
  7987. }, function () {
  7988. _this2.db && e(_this2.db), clearTimeout(n), logger$1.info("successCallback called, this.db: ".concat(!!_this2.db, ", this.isCreatingStore: ").concat(_this2.isCreatingTable));
  7989. });
  7990. }));
  7991. case 1:
  7992. case "end":
  7993. return _context2.stop();
  7994. }
  7995. }
  7996. }, _callee2, this);
  7997. }));
  7998. function checkAndOpenDatabase() {
  7999. return _checkAndOpenDatabase.apply(this, arguments);
  8000. }
  8001. return checkAndOpenDatabase;
  8002. }()
  8003. }, {
  8004. key: "openDatabase",
  8005. value: function openDatabase(e, t, r, n, o) {
  8006. var _this3 = this;
  8007. if (this.isCreatingTable) return;
  8008. this.isCreatingTable = !0, logger$1.info(e, t);
  8009. var a = window.indexedDB.open(e, t),
  8010. s = this.tableName();
  8011. a.onsuccess = function (l) {
  8012. _this3.db = a.result, logger$1.info("IndexedDb ".concat(e, " is opened.")), _this3.db.objectStoreNames.contains(s) && (_this3.isCreatingTable = !1), r && r(l);
  8013. }, a.onerror = function (l) {
  8014. var u;
  8015. 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);
  8016. }, a.onupgradeneeded = function (l) {
  8017. var u = l.target.result,
  8018. c = _this3.index();
  8019. logger$1.info("Creating table ".concat(s, "."));
  8020. var h = u.objectStoreNames.contains(s);
  8021. if (h) h = u.transaction([s], "readwrite").objectStore(s);else {
  8022. var f = _this3.keyPath();
  8023. h = u.createObjectStore(s, {
  8024. keyPath: f
  8025. });
  8026. }
  8027. c.map(function (f) {
  8028. h.createIndex(f, f, {
  8029. unique: !1
  8030. });
  8031. }), _this3.isCreatingTable = !1, logger$1.info("Table ".concat(s, " opened")), o && o(l);
  8032. };
  8033. }
  8034. }, {
  8035. key: "add",
  8036. value: function () {
  8037. var _add = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  8038. var t, o;
  8039. return regenerator.wrap(function _callee3$(_context3) {
  8040. while (1) {
  8041. switch (_context3.prev = _context3.next) {
  8042. case 0:
  8043. t = this.tableName();
  8044. _context3.next = 3;
  8045. return this.checkAndOpenDatabase();
  8046. case 3:
  8047. o = _context3.sent.transaction([t], "readwrite").objectStore(t).add(e);
  8048. return _context3.abrupt("return", new Promise(function (a, s) {
  8049. o.onsuccess = function (l) {
  8050. a(l);
  8051. }, o.onerror = function (l) {
  8052. var u;
  8053. logger$1.error((u = l.srcElement) == null ? void 0 : u.error), s(l);
  8054. };
  8055. }));
  8056. case 5:
  8057. case "end":
  8058. return _context3.stop();
  8059. }
  8060. }
  8061. }, _callee3, this);
  8062. }));
  8063. function add(_x2) {
  8064. return _add.apply(this, arguments);
  8065. }
  8066. return add;
  8067. }()
  8068. }, {
  8069. key: "put",
  8070. value: function () {
  8071. var _put = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  8072. var t, o;
  8073. return regenerator.wrap(function _callee4$(_context4) {
  8074. while (1) {
  8075. switch (_context4.prev = _context4.next) {
  8076. case 0:
  8077. t = this.tableName();
  8078. _context4.next = 3;
  8079. return this.checkAndOpenDatabase();
  8080. case 3:
  8081. o = _context4.sent.transaction([t], "readwrite").objectStore(t).put(e);
  8082. return _context4.abrupt("return", new Promise(function (a, s) {
  8083. o.onsuccess = function (l) {
  8084. a(l);
  8085. }, o.onerror = function (l) {
  8086. var u;
  8087. logger$1.error("db put error", (u = l.srcElement) == null ? void 0 : u.error), s(l);
  8088. };
  8089. }));
  8090. case 5:
  8091. case "end":
  8092. return _context4.stop();
  8093. }
  8094. }
  8095. }, _callee4, this);
  8096. }));
  8097. function put(_x3) {
  8098. return _put.apply(this, arguments);
  8099. }
  8100. return put;
  8101. }()
  8102. }, {
  8103. key: "delete",
  8104. value: function _delete(e, t, r) {
  8105. var n = this.tableName();
  8106. this.checkAndOpenDatabase().then(function (o) {
  8107. var s = o.transaction([n], "readwrite").objectStore(n).delete(e);
  8108. s.onsuccess = t, s.onerror = r;
  8109. });
  8110. }
  8111. }, {
  8112. key: "update",
  8113. value: function update() {
  8114. this.checkAndOpenDatabase().then(function (e) {});
  8115. }
  8116. }, {
  8117. key: "getAllKeys",
  8118. value: function () {
  8119. var _getAllKeys = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5() {
  8120. var e, t;
  8121. return regenerator.wrap(function _callee5$(_context5) {
  8122. while (1) {
  8123. switch (_context5.prev = _context5.next) {
  8124. case 0:
  8125. e = this.tableName();
  8126. _context5.next = 3;
  8127. return this.checkAndOpenDatabase();
  8128. case 3:
  8129. t = _context5.sent;
  8130. return _context5.abrupt("return", new Promise(function (r, n) {
  8131. var a = t.transaction([e], "readonly").objectStore(e).getAllKeys();
  8132. a.onsuccess = function (s) {
  8133. r(s.target.result);
  8134. }, a.onerror = function (s) {
  8135. logger$1.error("db getAllKeys error", s), n(s);
  8136. };
  8137. }));
  8138. case 5:
  8139. case "end":
  8140. return _context5.stop();
  8141. }
  8142. }
  8143. }, _callee5, this);
  8144. }));
  8145. function getAllKeys() {
  8146. return _getAllKeys.apply(this, arguments);
  8147. }
  8148. return getAllKeys;
  8149. }()
  8150. }, {
  8151. key: "query",
  8152. value: function () {
  8153. var _query = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e, t) {
  8154. var r, n;
  8155. return regenerator.wrap(function _callee6$(_context6) {
  8156. while (1) {
  8157. switch (_context6.prev = _context6.next) {
  8158. case 0:
  8159. r = this.tableName();
  8160. _context6.next = 3;
  8161. return this.checkAndOpenDatabase();
  8162. case 3:
  8163. n = _context6.sent;
  8164. return _context6.abrupt("return", new Promise(function (o, a) {
  8165. var u = n.transaction([r], "readonly").objectStore(r).index(e).get(t);
  8166. u.onsuccess = function (c) {
  8167. var f;
  8168. var h = (f = c == null ? void 0 : c.target) == null ? void 0 : f.result;
  8169. o && o(h);
  8170. }, u.onerror = function (c) {
  8171. logger$1.error("db query error", c), a(c);
  8172. };
  8173. }));
  8174. case 5:
  8175. case "end":
  8176. return _context6.stop();
  8177. }
  8178. }
  8179. }, _callee6, this);
  8180. }));
  8181. function query(_x4, _x5) {
  8182. return _query.apply(this, arguments);
  8183. }
  8184. return query;
  8185. }()
  8186. }, {
  8187. key: "sleep",
  8188. value: function () {
  8189. var _sleep = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7(e) {
  8190. return regenerator.wrap(function _callee7$(_context7) {
  8191. while (1) {
  8192. switch (_context7.prev = _context7.next) {
  8193. case 0:
  8194. return _context7.abrupt("return", new Promise(function (t) {
  8195. setTimeout(function () {
  8196. t("");
  8197. }, e);
  8198. }));
  8199. case 1:
  8200. case "end":
  8201. return _context7.stop();
  8202. }
  8203. }
  8204. }, _callee7);
  8205. }));
  8206. function sleep(_x6) {
  8207. return _sleep.apply(this, arguments);
  8208. }
  8209. return sleep;
  8210. }()
  8211. }]);
  8212. return BaseTable;
  8213. }();
  8214. 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); }; }
  8215. 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; } }
  8216. var ModelTable = /*#__PURE__*/function (_BaseTable) {
  8217. _inherits(ModelTable, _BaseTable);
  8218. var _super = _createSuper$6(ModelTable);
  8219. function ModelTable() {
  8220. _classCallCheck(this, ModelTable);
  8221. return _super.call(this, "XverseDatabase", 1);
  8222. }
  8223. _createClass(ModelTable, [{
  8224. key: "tableName",
  8225. value: function tableName() {
  8226. return "models";
  8227. }
  8228. }, {
  8229. key: "index",
  8230. value: function index() {
  8231. return ["url"];
  8232. }
  8233. }, {
  8234. key: "keyPath",
  8235. value: function keyPath() {
  8236. return "url";
  8237. }
  8238. }]);
  8239. return ModelTable;
  8240. }(BaseTable);
  8241. var modelTable = new ModelTable();
  8242. 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); }; }
  8243. 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; } }
  8244. var isIndexedDbSupported = function isIndexedDbSupported() {
  8245. return (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB) !== void 0;
  8246. };
  8247. var dataURItoBlob = function dataURItoBlob(i) {
  8248. var e;
  8249. i.split(",")[0].indexOf("base64") >= 0 ? e = atob(i.split(",")[1]) : e = unescape(i.split(",")[1]);
  8250. var t = i.split(",")[0].split(":")[1].split(";")[0],
  8251. r = new Uint8Array(e.length);
  8252. for (var o = 0; o < e.length; o++) {
  8253. r[o] = e.charCodeAt(o);
  8254. }
  8255. return new Blob([r], {
  8256. type: t
  8257. });
  8258. };
  8259. var Http = /*#__PURE__*/function (_EventEmitter) {
  8260. _inherits(Http, _EventEmitter);
  8261. var _super = _createSuper$5(Http);
  8262. function Http() {
  8263. _classCallCheck(this, Http);
  8264. return _super.apply(this, arguments);
  8265. }
  8266. _createClass(Http, [{
  8267. key: "get",
  8268. value: function () {
  8269. var _get = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref) {
  8270. var e, _ref$useIndexedDb, t, _ref$timeout, r, n, _ref$isOutPutObjectUR, o, a, s, l;
  8271. return regenerator.wrap(function _callee2$(_context2) {
  8272. while (1) {
  8273. switch (_context2.prev = _context2.next) {
  8274. case 0:
  8275. 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;
  8276. if (!(Xverse.NO_CACHE !== void 0 && (t = !Xverse.NO_CACHE), t)) {
  8277. _context2.next = 25;
  8278. break;
  8279. }
  8280. if (!isIndexedDbSupported()) {
  8281. _context2.next = 22;
  8282. break;
  8283. }
  8284. window.performance.now();
  8285. a = null;
  8286. _context2.prev = 5;
  8287. _context2.next = 8;
  8288. return modelTable.query("url", e);
  8289. case 8:
  8290. a = _context2.sent;
  8291. _context2.next = 14;
  8292. break;
  8293. case 11:
  8294. _context2.prev = 11;
  8295. _context2.t0 = _context2["catch"](5);
  8296. return _context2.abrupt("return", (logger$1.debug(_context2.t0), logger$1.warn("cache query error", e), Promise.resolve(e)));
  8297. case 14:
  8298. if (!(a && a.model)) {
  8299. _context2.next = 19;
  8300. break;
  8301. }
  8302. s = dataURItoBlob(a.model), l = Promise.resolve(o ? URL.createObjectURL(s) : s);
  8303. return _context2.abrupt("return", (window.performance.now(), l));
  8304. case 19:
  8305. return _context2.abrupt("return", this.request({
  8306. url: e,
  8307. timeout: r,
  8308. contentType: "blob",
  8309. key: n
  8310. }).then( /*#__PURE__*/function () {
  8311. var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(s) {
  8312. var l;
  8313. return regenerator.wrap(function _callee$(_context) {
  8314. while (1) {
  8315. switch (_context.prev = _context.next) {
  8316. case 0:
  8317. _context.next = 2;
  8318. return blobToDataURI(s.response);
  8319. case 2:
  8320. l = _context.sent;
  8321. _context.prev = 3;
  8322. _context.next = 6;
  8323. return modelTable.put({
  8324. url: e,
  8325. model: l
  8326. });
  8327. case 6:
  8328. _context.next = 11;
  8329. break;
  8330. case 8:
  8331. _context.prev = 8;
  8332. _context.t0 = _context["catch"](3);
  8333. logger$1.warn("unable to add data to indexedDB", _context.t0);
  8334. case 11:
  8335. return _context.abrupt("return", Promise.resolve(o ? URL.createObjectURL(s.response) : s.response));
  8336. case 12:
  8337. case "end":
  8338. return _context.stop();
  8339. }
  8340. }
  8341. }, _callee, null, [[3, 8]]);
  8342. }));
  8343. return function (_x2) {
  8344. return _ref2.apply(this, arguments);
  8345. };
  8346. }()));
  8347. case 20:
  8348. _context2.next = 23;
  8349. break;
  8350. case 22:
  8351. return _context2.abrupt("return", this.request({
  8352. url: e,
  8353. timeout: r,
  8354. contentType: "blob",
  8355. key: n
  8356. }).then(function (a) {
  8357. var s = a.response;
  8358. return Promise.resolve(o ? URL.createObjectURL(s) : s);
  8359. }).catch(function (a) {
  8360. return Promise.reject(a);
  8361. }));
  8362. case 23:
  8363. _context2.next = 26;
  8364. break;
  8365. case 25:
  8366. return _context2.abrupt("return", this.request({
  8367. url: e,
  8368. timeout: r,
  8369. key: n
  8370. }).then(function (a) {
  8371. return a.getResponseHeader("content-type") === "application/json" ? Promise.resolve(JSON.parse(a.responseText)) : Promise.resolve(a.responseText);
  8372. }));
  8373. case 26:
  8374. case "end":
  8375. return _context2.stop();
  8376. }
  8377. }
  8378. }, _callee2, this, [[5, 11]]);
  8379. }));
  8380. function get(_x) {
  8381. return _get.apply(this, arguments);
  8382. }
  8383. return get;
  8384. }()
  8385. }, {
  8386. key: "request",
  8387. value: function request(e) {
  8388. var _this = this;
  8389. var _e$timeout = e.timeout,
  8390. t = _e$timeout === void 0 ? 3e4 : _e$timeout,
  8391. r = e.contentType;
  8392. e.key;
  8393. var o = e.onRequestStart,
  8394. a = e.url;
  8395. return new Promise(function (s, l) {
  8396. window.performance.now();
  8397. var u = new XMLHttpRequest();
  8398. r && (u.responseType = r), u.timeout = t, u.addEventListener("readystatechange", function () {
  8399. if (u.readyState == 4) {
  8400. if (u.status == 200) return window.performance.now(), _this.emit("loadend", {
  8401. message: "request ".concat(a, " load success")
  8402. }), s(u);
  8403. {
  8404. var c = "Unable to load the request ".concat(a);
  8405. return _this.emit("error", {
  8406. message: c
  8407. }), logger$1.error(c), l(c);
  8408. }
  8409. }
  8410. }), o && o(u), u.open("GET", a), u.send();
  8411. });
  8412. }
  8413. }]);
  8414. return Http;
  8415. }(EventEmitter); // const http = new Http();
  8416. var Logger1 = /*#__PURE__*/function () {
  8417. function Logger1(e) {
  8418. _classCallCheck(this, Logger1);
  8419. E(this, "module");
  8420. this.module = e;
  8421. }
  8422. _createClass(Logger1, [{
  8423. key: "debug",
  8424. value: function debug() {
  8425. var _Logger1$instance;
  8426. return (_Logger1$instance = Logger1.instance).debug.apply(_Logger1$instance, arguments);
  8427. }
  8428. }, {
  8429. key: "info",
  8430. value: function info() {
  8431. var _Logger1$instance2;
  8432. return (_Logger1$instance2 = Logger1.instance).info.apply(_Logger1$instance2, arguments);
  8433. }
  8434. }, {
  8435. key: "warn",
  8436. value: function warn() {
  8437. var _Logger1$instance3;
  8438. return (_Logger1$instance3 = Logger1.instance).warn.apply(_Logger1$instance3, arguments);
  8439. }
  8440. }, {
  8441. key: "error",
  8442. value: function error() {
  8443. var _Logger1$instance4;
  8444. return (_Logger1$instance4 = Logger1.instance).error.apply(_Logger1$instance4, arguments);
  8445. }
  8446. }], [{
  8447. key: "setLogger",
  8448. value: function setLogger(e) {
  8449. Logger1.instance = e;
  8450. }
  8451. }]);
  8452. return Logger1;
  8453. }();
  8454. var XCameraComponent = /*#__PURE__*/function () {
  8455. function XCameraComponent(e, t, r) {
  8456. var _this = this;
  8457. _classCallCheck(this, XCameraComponent);
  8458. E(this, "maincameraRotLimitObserver", null);
  8459. E(this, "mainCamera");
  8460. E(this, "cgCamera");
  8461. E(this, "saveCameraPose");
  8462. E(this, "_cameraPose");
  8463. E(this, "scene");
  8464. E(this, "canvas");
  8465. E(this, "yuvInfo");
  8466. E(this, "forceKeepVertical", !1);
  8467. E(this, "initCamera", function (e) {
  8468. var _e$maxZ = e.maxZ,
  8469. t = _e$maxZ === void 0 ? 1e4 : _e$maxZ,
  8470. _e$minZ = e.minZ,
  8471. r = _e$minZ === void 0 ? .1 : _e$minZ,
  8472. _e$angularSensibility = e.angularSensibility,
  8473. n = _e$angularSensibility === void 0 ? 2e3 : _e$angularSensibility;
  8474. _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);
  8475. });
  8476. E(this, "cameraFovChange", function (e) {
  8477. _this.yuvInfo = e;
  8478. var t = e.width,
  8479. r = e.height,
  8480. n = _this.canvas.width,
  8481. o = _this.canvas.height,
  8482. a = e.fov;
  8483. if (_this.forceKeepVertical == !0) {
  8484. var s = t / (2 * Math.tan(Math.PI * a / 360)),
  8485. l = 2 * Math.atan(r / (2 * s));
  8486. _this.mainCamera.fov = l, _this.cgCamera.fov = l, _this.mainCamera.fovMode = BABYLON.Camera.FOVMODE_VERTICAL_FIXED, _this.cgCamera.fovMode = BABYLON.Camera.FOVMODE_VERTICAL_FIXED;
  8487. } 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) {
  8488. var _s = o,
  8489. _l = n,
  8490. u = _s * t / r / (2 * Math.tan(a * Math.PI / 360)),
  8491. c = 2 * Math.atan(_l / (2 * u));
  8492. _this.mainCamera.fov = c, _this.cgCamera.fov = c;
  8493. } else _this.mainCamera.fov = Math.PI * a / 180, _this.cgCamera.fov = Math.PI * a / 180;
  8494. });
  8495. E(this, "setCameraPose", function (e) {
  8496. var n;
  8497. var t = ue4Position2Xverse(e.position);
  8498. var r = null;
  8499. e.rotation != null && (r = ue4Rotation2Xverse(e.rotation)), _this._cameraPose = {
  8500. position: t
  8501. }, r != null && (_this._cameraPose.rotation = r), _this.scene.activeCamera === _this.mainCamera && !((n = _this.mainCamera) != null && n.isDisposed()) && _this._setCamPositionRotation(_this.mainCamera, _this._cameraPose);
  8502. });
  8503. E(this, "_setCamPositionRotation", function (e, t) {
  8504. var r, n;
  8505. t.position && (e.position = (r = t.position) == null ? void 0 : r.clone()), t.rotation && (e.rotation = (n = t.rotation) == null ? void 0 : n.clone());
  8506. });
  8507. E(this, "switchCamera", function (e) {
  8508. var t;
  8509. (t = _this.scene.activeCamera) == null || t.detachControl(_this.canvas), _this.scene.activeCamera = e;
  8510. });
  8511. E(this, "reCalXYZRot", function (e, t) {
  8512. return e = e % (2 * Math.PI), Math.abs(t - e) >= Math.PI && (e = e - 2 * Math.PI), e;
  8513. });
  8514. E(this, "_moveCam", function (e, t, r, n, o, a, s, l) {
  8515. var u = function u(v, y, b) {
  8516. 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);
  8517. },
  8518. c = function c(v, y, b) {
  8519. 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);
  8520. },
  8521. h = new Animation("myAnimation1", "position", s, Animation.ANIMATIONTYPE_VECTOR3, Animation.ANIMATIONLOOPMODE_CONSTANT);
  8522. var f = [],
  8523. d = t,
  8524. _ = r;
  8525. for (var v = 0; v < a; ++v) {
  8526. f.push({
  8527. frame: v,
  8528. value: c(d, _, v / a)
  8529. });
  8530. }
  8531. f.push({
  8532. frame: f.length,
  8533. value: c(d, _, 1)
  8534. }), h.setKeys(f);
  8535. var g = new Animation("myAnimation2", "rotation", s, Animation.ANIMATIONTYPE_VECTOR3, Animation.ANIMATIONLOOPMODE_CONSTANT);
  8536. f = [], d = n, _ = o;
  8537. for (var _v = 0; _v < a; ++_v) {
  8538. f.push({
  8539. frame: _v,
  8540. value: u(d, _, _v / a)
  8541. });
  8542. }
  8543. f.push({
  8544. frame: f.length,
  8545. value: u(d, _, 1)
  8546. }), g.setKeys(f), e.animations.push(g), e.animations.push(h);
  8547. var m = _this.scene.beginAnimation(e, 0, a, !1);
  8548. m.onAnimationEnd = function () {
  8549. l(), m.stop(), m.animationStarted = !1;
  8550. };
  8551. });
  8552. this.scene = t, this.canvas = e, this.yuvInfo = r.yuvInfo, r.forceKeepVertical != null && (this.forceKeepVertical = r.forceKeepVertical), this.initCamera(r.cameraParam);
  8553. }
  8554. _createClass(XCameraComponent, [{
  8555. key: "MainCamera",
  8556. get: function get() {
  8557. return this.mainCamera;
  8558. }
  8559. }, {
  8560. key: "CgCamera",
  8561. get: function get() {
  8562. return this.cgCamera;
  8563. }
  8564. }, {
  8565. key: "getCameraHorizonFov",
  8566. value: function getCameraHorizonFov() {
  8567. return this.mainCamera.fovMode == BABYLON.Camera.FOVMODE_HORIZONTAL_FIXED ? this.mainCamera.fov : Math.PI * this.yuvInfo.fov / 180;
  8568. }
  8569. }, {
  8570. key: "changeMainCameraRotationDamping",
  8571. value: function changeMainCameraRotationDamping() {
  8572. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2e3;
  8573. this.mainCamera.angularSensibility = e;
  8574. }
  8575. }, {
  8576. key: "removeMainCameraRotationLimit",
  8577. value: function removeMainCameraRotationLimit() {
  8578. this.maincameraRotLimitObserver != null && this.mainCamera.onAfterCheckInputsObservable.remove(this.maincameraRotLimitObserver);
  8579. }
  8580. }, {
  8581. key: "setMainCameraInfo",
  8582. value: function setMainCameraInfo(e) {
  8583. var _e$maxZ2 = e.maxZ,
  8584. t = _e$maxZ2 === void 0 ? 1e4 : _e$maxZ2,
  8585. _e$minZ2 = e.minZ,
  8586. r = _e$minZ2 === void 0 ? .1 : _e$minZ2,
  8587. _e$angularSensibility2 = e.angularSensibility,
  8588. n = _e$angularSensibility2 === void 0 ? 2e3 : _e$angularSensibility2;
  8589. this.mainCamera.maxZ = t, this.mainCamera.minZ = r, this.mainCamera.angularSensibility = n;
  8590. }
  8591. }, {
  8592. key: "getMainCameraInfo",
  8593. value: function getMainCameraInfo() {
  8594. return {
  8595. maxZ: this.mainCamera.maxZ,
  8596. minZ: this.mainCamera.minZ,
  8597. angularSensibility: this.mainCamera.angularSensibility
  8598. };
  8599. }
  8600. }, {
  8601. key: "_limitAngle",
  8602. value: function _limitAngle(e, t) {
  8603. 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;
  8604. }
  8605. }, {
  8606. key: "setMainCameraRotationLimit",
  8607. value: function setMainCameraRotationLimit(e, t) {
  8608. var _this2 = this;
  8609. this.maincameraRotLimitObserver != null && this.removeMainCameraRotationLimit();
  8610. var r = this.mainCamera,
  8611. n = e.yaw,
  8612. o = e.pitch,
  8613. a = e.roll,
  8614. s = t.yaw,
  8615. l = t.pitch,
  8616. u = t.roll;
  8617. if (s < 0 || l < 0 || u < 0) throw new Error("\u76F8\u673A\u65CB\u8F6C\u9650\u5236\u53EA\u80FD\u8BBE\u7F6E\u4E3A\u5927\u4E8E0");
  8618. var c = [o - l, o + l],
  8619. h = [n - s, n + s],
  8620. f = [a - u, a + u];
  8621. this.maincameraRotLimitObserver = r.onAfterCheckInputsObservable.add(function () {
  8622. var _xverseRotation2Ue = xverseRotation2Ue4(r.rotation),
  8623. d = _xverseRotation2Ue.pitch,
  8624. _ = _xverseRotation2Ue.yaw,
  8625. g = _xverseRotation2Ue.roll;
  8626. d = _this2._limitAngle(d, c), _ = _this2._limitAngle(_, h), g = _this2._limitAngle(g, f), r.rotation = ue4Rotation2Xverse({
  8627. pitch: d,
  8628. yaw: _,
  8629. roll: g
  8630. });
  8631. });
  8632. }
  8633. }, {
  8634. key: "setMainCameraRotationLimitByAnchor",
  8635. value: function setMainCameraRotationLimitByAnchor(e, t, r) {
  8636. this.maincameraRotLimitObserver != null && this.removeMainCameraRotationLimit();
  8637. var n = this.mainCamera,
  8638. o = ue4Rotation2Xverse_mesh(t),
  8639. a = ue4Rotation2Xverse_mesh(r);
  8640. a != null && o != null && e.mesh != null && (this.maincameraRotLimitObserver = n.onAfterCheckInputsObservable.add(function () {
  8641. var s = e.mesh.rotation;
  8642. 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));
  8643. }));
  8644. }
  8645. }, {
  8646. key: "getCameraPose",
  8647. value: function getCameraPose() {
  8648. var e = xversePosition2Ue4({
  8649. x: this.mainCamera.position.x,
  8650. y: this.mainCamera.position.y,
  8651. z: this.mainCamera.position.z
  8652. }),
  8653. t = xverseRotation2Ue4({
  8654. x: this.mainCamera.rotation.x,
  8655. y: this.mainCamera.rotation.y,
  8656. z: this.mainCamera.rotation.z
  8657. });
  8658. return {
  8659. position: e,
  8660. rotation: t
  8661. };
  8662. }
  8663. }, {
  8664. key: "changeCameraFov",
  8665. value: function changeCameraFov(e, t) {
  8666. this.mainCamera.fov = e, t != null && (this.mainCamera.fovMode = t == 0 ? BABYLON.Camera.FOVMODE_HORIZONTAL_FIXED : BABYLON.Camera.FOVMODE_VERTICAL_FIXED);
  8667. }
  8668. }, {
  8669. key: "controlCameraRotation",
  8670. value: function controlCameraRotation(e, t) {
  8671. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : .5;
  8672. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : .5;
  8673. var o = {
  8674. pitch: n * t * 180,
  8675. yaw: r * e * 180,
  8676. roll: 0
  8677. };
  8678. this.addRot(o);
  8679. }
  8680. }, {
  8681. key: "addRot",
  8682. value: function addRot(e) {
  8683. var t = this.mainCamera,
  8684. r = ue4Rotation2Xverse_mesh(e);
  8685. r != null && t.rotation.addInPlace(r);
  8686. }
  8687. }, {
  8688. key: "getCameraFov",
  8689. value: function getCameraFov() {
  8690. return this.mainCamera.fov;
  8691. }
  8692. }, {
  8693. key: "allowMainCameraController",
  8694. value: function allowMainCameraController() {
  8695. this.mainCamera.attachControl(this.canvas, !0);
  8696. }
  8697. }, {
  8698. key: "detachMainCameraController",
  8699. value: function detachMainCameraController() {
  8700. this.mainCamera.detachControl(this.canvas);
  8701. }
  8702. }, {
  8703. key: "forceChangeSavedCameraPose",
  8704. value: function forceChangeSavedCameraPose(e) {
  8705. this.saveCameraPose != null && (e.position != null && (this.saveCameraPose.position = ue4Position2Xverse(e.position)), e.rotation != null && (this.saveCameraPose.rotation = ue4Rotation2Xverse(e.rotation)));
  8706. }
  8707. }, {
  8708. key: "changeToFirstPersonView",
  8709. value: function changeToFirstPersonView(e) {
  8710. this.saveCameraPose = {
  8711. position: this.mainCamera.position.clone(),
  8712. rotation: this.mainCamera.rotation.clone()
  8713. }, this.mainCamera.attachControl(this.canvas, !0), e.position != null && (this.mainCamera.position = ue4Position2Xverse(e.position)), e.rotation != null && (this.mainCamera.rotation = ue4Rotation2Xverse(e.rotation));
  8714. }
  8715. }, {
  8716. key: "changeToThirdPersonView",
  8717. value: function changeToThirdPersonView() {
  8718. 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));
  8719. }
  8720. }, {
  8721. key: "switchToMainCamera",
  8722. value: function switchToMainCamera() {
  8723. this.switchCamera(this.mainCamera);
  8724. }
  8725. }, {
  8726. key: "switchToCgCamera",
  8727. value: function switchToCgCamera() {
  8728. this.switchCamera(this.cgCamera);
  8729. }
  8730. }, {
  8731. key: "moveMainCamera",
  8732. value: function moveMainCamera(e, t, r, n, o) {
  8733. this._moveCam(this.mainCamera, this.mainCamera.position, e, this.mainCamera.rotation, t, r, n, o);
  8734. }
  8735. }]);
  8736. return XCameraComponent;
  8737. }();
  8738. var EMeshType = {
  8739. XAvatar: 'XAvatar',
  8740. XStaticMesh: 'XStaticMesh',
  8741. XBreathPoint: 'breathpoint',
  8742. Decal: 'decal',
  8743. Cgplane: 'cgplane',
  8744. Tv: 'tv',
  8745. XSubSequence: 'XSubSequence',
  8746. XBillboard: 'XBillboard'
  8747. };
  8748. var XStaticMesh = /*#__PURE__*/function () {
  8749. function XStaticMesh(_ref) {
  8750. var _this = this;
  8751. var e = _ref.id,
  8752. t = _ref.mesh,
  8753. _ref$group = _ref.group,
  8754. r = _ref$group === void 0 ? "default" : _ref$group,
  8755. _ref$lod = _ref.lod,
  8756. n = _ref$lod === void 0 ? 0 : _ref$lod,
  8757. _ref$xtype = _ref.xtype,
  8758. o = _ref$xtype === void 0 ? EMeshType.XStaticMesh : _ref$xtype,
  8759. _ref$skinInfo = _ref.skinInfo,
  8760. a = _ref$skinInfo === void 0 ? "default" : _ref$skinInfo,
  8761. _ref$url = _ref.url,
  8762. s = _ref$url === void 0 ? "" : _ref$url;
  8763. _classCallCheck(this, XStaticMesh);
  8764. E(this, "_mesh");
  8765. E(this, "_id", "-1");
  8766. E(this, "_group");
  8767. E(this, "_lod");
  8768. E(this, "_isMoving", !1);
  8769. E(this, "_isRotating", !1);
  8770. E(this, "_isVisible", !0);
  8771. E(this, "_skinInfo");
  8772. E(this, "setVisibility", function (e, t) {
  8773. Array.isArray(e) ? e.forEach(function (r) {
  8774. _this.setVisibility(r, t);
  8775. }) : e.isAnInstance || (e.visibility = t);
  8776. });
  8777. E(this, "setPickable", function (e, t) {
  8778. Array.isArray(e) ? e.forEach(function (r) {
  8779. _this.setPickable(r, t);
  8780. }) : ("isPickable" in e && (e.isPickable = t), e.setEnabled(t));
  8781. });
  8782. E(this, "hide", function () {
  8783. var e;
  8784. _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) {
  8785. _this.setVisibility(t, 0), _this.setPickable(t, !1);
  8786. });
  8787. });
  8788. E(this, "show", function () {
  8789. var e;
  8790. _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) {
  8791. _this.setVisibility(t, 1), _this.setPickable(t, !0);
  8792. });
  8793. });
  8794. E(this, "attachToAvatar", function (e) {
  8795. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
  8796. x: 0,
  8797. y: .5,
  8798. z: 0
  8799. };
  8800. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
  8801. yaw: 0,
  8802. pitch: 0,
  8803. roll: 0
  8804. };
  8805. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
  8806. x: .35,
  8807. y: .35,
  8808. z: .35
  8809. };
  8810. var o = ue4Scaling2Xverse(n),
  8811. a = ue4Rotation2Xverse(r),
  8812. s = ue4Position2Xverse(t),
  8813. l = _this._mesh;
  8814. e && l ? (e.setParent(l), e.position = s, e.rotation = a, e.scaling = o) : logger$1.error("[Engine] avatar or attachment not found!");
  8815. });
  8816. E(this, "detachFromAvatar", function (e) {
  8817. _this._mesh && e ? _this._mesh.removeChild(e) : logger$1.error("[Engine] avatar not found!");
  8818. });
  8819. 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;
  8820. }
  8821. _createClass(XStaticMesh, [{
  8822. key: "mesh",
  8823. get: function get() {
  8824. return this._mesh;
  8825. }
  8826. }, {
  8827. key: "position",
  8828. get: function get() {
  8829. var o;
  8830. if (!this._mesh) return null;
  8831. var _ref2 = (o = this._mesh) == null ? void 0 : o.position,
  8832. e = _ref2.x,
  8833. t = _ref2.y,
  8834. r = _ref2.z;
  8835. return xversePosition2Ue4({
  8836. x: e,
  8837. y: t,
  8838. z: r
  8839. });
  8840. }
  8841. }, {
  8842. key: "id",
  8843. get: function get() {
  8844. return this._id;
  8845. }
  8846. }, {
  8847. key: "group",
  8848. get: function get() {
  8849. return this._group;
  8850. }
  8851. }, {
  8852. key: "isMoving",
  8853. get: function get() {
  8854. return this._isMoving;
  8855. }
  8856. }, {
  8857. key: "isVisible",
  8858. get: function get() {
  8859. return this._isVisible;
  8860. }
  8861. }, {
  8862. key: "isRotating",
  8863. get: function get() {
  8864. return this._isRotating;
  8865. }
  8866. }, {
  8867. key: "skinInfo",
  8868. get: function get() {
  8869. return this._skinInfo;
  8870. }
  8871. }, {
  8872. key: "allowMove",
  8873. value: function allowMove() {
  8874. this._mesh != null && (this._mesh.getChildMeshes().forEach(function (e) {
  8875. e.unfreezeWorldMatrix();
  8876. }), this._mesh.unfreezeWorldMatrix());
  8877. }
  8878. }, {
  8879. key: "unallowMove",
  8880. value: function unallowMove() {
  8881. this._mesh != null && (this._mesh.getChildMeshes().forEach(function (e) {
  8882. e.freezeWorldMatrix();
  8883. }), this._mesh.freezeWorldMatrix());
  8884. }
  8885. }, {
  8886. key: "getID",
  8887. value: function getID() {
  8888. return this._id;
  8889. }
  8890. }, {
  8891. key: "setPosition",
  8892. value: function setPosition(e) {
  8893. if (this._mesh) {
  8894. var t = ue4Position2Xverse(e);
  8895. this._mesh.position = t;
  8896. } else logger$1.error("[Engine] no root for positioning");
  8897. }
  8898. }, {
  8899. key: "setRotation",
  8900. value: function setRotation(e) {
  8901. var t = ue4Rotation2Xverse_mesh(e);
  8902. this._mesh ? this._mesh.rotation = t : logger$1.error("[Engine] no root for rotating");
  8903. }
  8904. }, {
  8905. key: "setScale",
  8906. value: function setScale(e) {
  8907. this._mesh ? this._mesh.scaling = new BABYLON.Vector3(e, e, -e) : logger$1.error("[Engine] no root for scaling");
  8908. }
  8909. }, {
  8910. key: "disableAvatar",
  8911. value: function disableAvatar() {
  8912. var e;
  8913. (e = this._mesh) == null || e.setEnabled(!1);
  8914. }
  8915. }, {
  8916. key: "enableAvatar",
  8917. value: function enableAvatar() {
  8918. var e;
  8919. (e = this._mesh) == null || e.setEnabled(!0);
  8920. }
  8921. }, {
  8922. key: "togglePickable",
  8923. value: function togglePickable(e) {
  8924. var t;
  8925. (t = this.mesh) == null || t.getChildMeshes().forEach(function (r) {
  8926. "instances" in r && "isPickable" in r && (r.isPickable = e);
  8927. }), this.mesh != null && "isPickable" in this.mesh && (this.mesh.isPickable = e);
  8928. }
  8929. }, {
  8930. key: "setMaterial",
  8931. value: function setMaterial(e) {
  8932. var t;
  8933. (t = this.mesh) == null || t.getChildMeshes().forEach(function (r) {
  8934. "instances" in r && "material" in r && (r.material = e);
  8935. }), this.mesh != null && "material" in this.mesh && (this.mesh.material = e);
  8936. }
  8937. }, {
  8938. key: "dispose",
  8939. value: function dispose() {
  8940. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !1;
  8941. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
  8942. !this.mesh.isDisposed() && this.mesh.dispose(e, t);
  8943. }
  8944. }]);
  8945. return XStaticMesh;
  8946. }();
  8947. 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); }; }
  8948. 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; } }
  8949. var XLowpolyModelError = /*#__PURE__*/function (_XverseError) {
  8950. _inherits(XLowpolyModelError, _XverseError);
  8951. var _super = _createSuper$4(XLowpolyModelError);
  8952. function XLowpolyModelError(e) {
  8953. _classCallCheck(this, XLowpolyModelError);
  8954. return _super.call(this, 5204, e || "[Engine] \u4F20\u5165\u6A21\u578Burl\u9519\u8BEF");
  8955. }
  8956. return _createClass(XLowpolyModelError);
  8957. }(XverseError);
  8958. var XStaticMeshFromOneGltf = /*#__PURE__*/function () {
  8959. function XStaticMeshFromOneGltf(e, t) {
  8960. var _this = this;
  8961. _classCallCheck(this, XStaticMeshFromOneGltf);
  8962. E(this, "_scene");
  8963. E(this, "_url");
  8964. E(this, "_group");
  8965. E(this, "_pickable");
  8966. E(this, "_meshes");
  8967. E(this, "_id");
  8968. E(this, "_lod");
  8969. E(this, "_groupUuid");
  8970. E(this, "_isInScene");
  8971. E(this, "_skinInfo");
  8972. E(this, "loadMesh", function (e, t) {
  8973. var r = _this._meshes.length,
  8974. n = t ? 1 : 0,
  8975. o = _this._url;
  8976. return BABYLON.SceneLoader.LoadAssetContainerAsync("", o, _this._scene, function () {
  8977. _this._scene.blockMaterialDirtyMechanism = !0;
  8978. }, ".glb").then(function (a) {
  8979. for (var s = a.materials.length - 1; s >= 0; --s) {
  8980. a.materials[s].dispose();
  8981. }
  8982. _this._scene.blockMaterialDirtyMechanism = !0;
  8983. for (var _s = 0; _s < a.meshes.length; ++_s) {
  8984. var l = a.meshes[_s];
  8985. if ("instances" in l) {
  8986. "visibility" in l && (l.visibility = 0), "isPickable" in l && (l.isPickable = _this._pickable), e != null && (l.material = e), "hasVertexAlpha" in l && (l.hasVertexAlpha = !1);
  8987. var u = new XStaticMesh({
  8988. id: _this._groupUuid + "-" + Math.random().toString(36).substr(2, 5),
  8989. mesh: l,
  8990. lod: _this._lod,
  8991. group: _this._group,
  8992. url: _this._url,
  8993. xtype: EMeshType.XStaticMesh,
  8994. skinInfo: _this._skinInfo
  8995. });
  8996. _this._meshes.push(u);
  8997. }
  8998. _this._scene.addMesh(l);
  8999. }
  9000. return !0;
  9001. }).then(function () {
  9002. _this._isInScene = !0;
  9003. for (var a = r; a < _this._meshes.length; ++a) {
  9004. _this._meshes[a].mesh.visibility = n;
  9005. }
  9006. return Promise.resolve(!0);
  9007. }).catch(function (a) {
  9008. logger$1.error("[Engine] input gltf mesh uri error! " + a), Promise.reject(new XLowpolyModelError("[Engine] input gltf mesh uri error! " + a));
  9009. });
  9010. });
  9011. 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;
  9012. }
  9013. _createClass(XStaticMeshFromOneGltf, [{
  9014. key: "isinscene",
  9015. get: function get() {
  9016. return this._isInScene;
  9017. }
  9018. }, {
  9019. key: "groupUuid",
  9020. get: function get() {
  9021. return this._groupUuid;
  9022. }
  9023. }, {
  9024. key: "skinInfo",
  9025. get: function get() {
  9026. return this._skinInfo;
  9027. }
  9028. }, {
  9029. key: "group",
  9030. get: function get() {
  9031. return this._group;
  9032. }
  9033. }, {
  9034. key: "meshes",
  9035. get: function get() {
  9036. return this._meshes;
  9037. }
  9038. }, {
  9039. key: "url",
  9040. get: function get() {
  9041. return this._url;
  9042. }
  9043. }, {
  9044. key: "id",
  9045. get: function get() {
  9046. return this._id;
  9047. }
  9048. }, {
  9049. key: "lod",
  9050. get: function get() {
  9051. return this._lod;
  9052. }
  9053. }, {
  9054. key: "removeFromScene",
  9055. value: function removeFromScene() {
  9056. if (this._isInScene) {
  9057. this._isInScene = !1;
  9058. for (var e = 0, t = this._meshes.length; e < t; ++e) {
  9059. this._meshes[e].mesh != null && this._scene.removeMesh(this._meshes[e].mesh);
  9060. }
  9061. }
  9062. }
  9063. }, {
  9064. key: "addToScene",
  9065. value: function addToScene() {
  9066. if (this._isInScene == !1) {
  9067. this._isInScene = !0;
  9068. for (var e = 0, t = this._meshes.length; e < t; ++e) {
  9069. this._meshes[e].mesh != null && this._scene.addMesh(this._meshes[e].mesh);
  9070. }
  9071. }
  9072. }
  9073. }, {
  9074. key: "toggleVisibility",
  9075. value: function toggleVisibility(e) {
  9076. var t = e ? 1 : 0;
  9077. for (var r = 0, n = this._meshes.length; r < n; ++r) {
  9078. "visibility" in this._meshes[r].mesh && (this._meshes[r].mesh.visibility = t);
  9079. }
  9080. }
  9081. }, {
  9082. key: "togglePickable",
  9083. value: function togglePickable(e) {
  9084. for (var t = 0, r = this._meshes.length; t < r; ++t) {
  9085. "isPickable" in this._meshes[t].mesh && (this._meshes[t].mesh.isPickable = e);
  9086. }
  9087. }
  9088. }, {
  9089. key: "setMaterial",
  9090. value: function setMaterial(e) {
  9091. for (var t = 0, r = this._meshes.length; t < r; ++t) {
  9092. "material" in this._meshes[t].mesh && (this._meshes[t].mesh.material = e);
  9093. }
  9094. }
  9095. }, {
  9096. key: "dispose",
  9097. value: function dispose() {
  9098. for (var e = 0, t = this._meshes.length; e < t; ++e) {
  9099. this._meshes[e].mesh.dispose(!1, !1);
  9100. }
  9101. }
  9102. }]);
  9103. return XStaticMeshFromOneGltf;
  9104. }();
  9105. var XStaticMeshComponent = /*#__PURE__*/function () {
  9106. function XStaticMeshComponent(e) {
  9107. var _this = this;
  9108. _classCallCheck(this, XStaticMeshComponent);
  9109. E(this, "scene");
  9110. E(this, "_staticmeshes");
  9111. E(this, "_lowModel_group");
  9112. E(this, "_CgPlane");
  9113. E(this, "_rootDir");
  9114. E(this, "_abosoluteUrl");
  9115. E(this, "_partMeshSkinInfo");
  9116. E(this, "_meshInfoJson");
  9117. E(this, "_orijson");
  9118. E(this, "_notUsedRegionLists");
  9119. E(this, "_meshInfoKeys");
  9120. E(this, "_currentUpdateRegionCount");
  9121. E(this, "_currentMeshUsedLod");
  9122. E(this, "_currentPartGroup");
  9123. E(this, "_allowRegionUpdate");
  9124. E(this, "_allowRegionForceLod");
  9125. E(this, "_forceLod");
  9126. E(this, "_scenemanager");
  9127. E(this, "regionIdInCamera");
  9128. E(this, "regionIdInCameraConst");
  9129. E(this, "_cameraInRegionId");
  9130. E(this, "_meshVis");
  9131. E(this, "_doMeshVisChangeNumber");
  9132. E(this, "_meshVisTypeName");
  9133. E(this, "_visCheckDurationFrameNumber");
  9134. E(this, "_regionLodRule");
  9135. E(this, "reg_staticmesh_partupdate", function () {
  9136. if (_this._allowRegionUpdate && (_this.scene.getFrameId(), _this._meshUpdateFrame()), _this._allowRegionForceLod) {
  9137. _this.scene.getFrameId() % 2 == 0 && _this.setOneRegionLod(_this._meshInfoKeys[_this._currentUpdateRegionCount % _this._meshInfoKeys.length].toString(), _this._forceLod);
  9138. var t = !0;
  9139. var r = Array.from(_this._currentMeshUsedLod.keys());
  9140. if (r.length > 0) {
  9141. for (var n = 0; n < r.length; ++n) {
  9142. _this._currentMeshUsedLod.get(r[n]) != _this._forceLod && (t = !1);
  9143. }
  9144. t && (_this._allowRegionForceLod = !1);
  9145. }
  9146. }
  9147. });
  9148. E(this, "setMeshInfo", function (e) {
  9149. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
  9150. _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 () {
  9151. _this.startMeshUpdate();
  9152. }));
  9153. });
  9154. E(this, "_meshUpdateFrame", function () {
  9155. {
  9156. var _e = _this._meshInfoKeys[_this._currentUpdateRegionCount % _this._meshInfoKeys.length];
  9157. var t = !0;
  9158. var r = 3;
  9159. if (_this._scenemanager != null && _this._scenemanager.cameraComponent != null) {
  9160. var n = _this._getMainPlayerPosition();
  9161. if (n != null) {
  9162. if (_this._cameraInRegionId >= 0) {
  9163. var a = _this.getRegionIdWhichIncludeCamera(n);
  9164. (_this._cameraInRegionId != a || _this.regionIdInCamera.length == 0) && (_this._cameraInRegionId = a, _this.regionIdInCamera = _this._getNeighborId(_this._cameraInRegionId.toString()), _this.regionIdInCameraConst = _this.regionIdInCamera.slice());
  9165. var s = _this.regionIdInCamera.pop();
  9166. for (; s != null;) {
  9167. if (_this._notUsedRegionLists.indexOf(s) >= 0) s = _this.regionIdInCamera.pop();else break;
  9168. }
  9169. s != null && (_e = s.toString());
  9170. } else _this._cameraInRegionId = _this.getRegionIdWhichIncludeCamera(n);
  9171. if (_this._currentMeshUsedLod.size == 0 || _this._notUsedRegionLists.indexOf(parseInt(_e)) >= 0) {
  9172. _e = _this._cameraInRegionId.toString();
  9173. var _a = _this._getNeighborId(_e);
  9174. for (; _a.length == 0 && (_e = _this.getNearestRegionIdWithCamera(n).toString()), _this._notUsedRegionLists.indexOf(parseInt(_e)) >= 0;) {
  9175. _e = _a.pop().toString();
  9176. }
  9177. }
  9178. var o = _this._meshInfoJson[_this._cameraInRegionId.toString()].lod;
  9179. 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];
  9180. }
  9181. }
  9182. _this.setOneRegionLod(_e, r, t), _this.updateRegionNotInLocalNeighbor(), _this.cleanRootNodes();
  9183. }
  9184. });
  9185. E(this, "updateRegionNotInLocalNeighbor", function () {
  9186. Array.from(_this._currentMeshUsedLod.keys()).forEach(function (t) {
  9187. _this.regionIdInCameraConst.indexOf(parseInt(t)) < 0 && _this.setOneRegionLod(t, -1);
  9188. });
  9189. });
  9190. E(this, "cleanRootNodes", function () {
  9191. if (_this.scene.getFrameId() % 3 == 0) {
  9192. var _e2 = [];
  9193. _this.scene.rootNodes.forEach(function (t) {
  9194. (t.getClassName() == "TransformNode" && t.getChildren().length == 0 || t.getClassName() == "Mesh" && t.name == "__root__" && t.getChildren().length == 0) && _e2.push(t);
  9195. }), _e2.forEach(function (t) {
  9196. t.dispose();
  9197. });
  9198. }
  9199. });
  9200. E(this, "setOneRegionLod", function (e, t) {
  9201. _this._currentUpdateRegionCount++;
  9202. var n = _this._calHashCode(_this._rootDir),
  9203. o = "region_" + n + "_" + e;
  9204. if (t < 0) {
  9205. _this._currentMeshUsedLod.has(e) && (_this._currentMeshUsedLod.delete(e), _this._currentPartGroup.delete(o), _this.deleteMeshesByCustomProperty("group", "region_" + n + "_" + e));
  9206. return;
  9207. }
  9208. var a = _this._rootDir + e + "_lod" + t + "_xverse.glb",
  9209. s = _this._currentMeshUsedLod.get(e);
  9210. _this._currentPartGroup.add(o), s != null ? s != t && (_this._currentMeshUsedLod.set(e, t), _this._scenemanager.addNewLowPolyMesh({
  9211. url: a,
  9212. group: "region_" + n + "_" + e,
  9213. pick: !0,
  9214. lod: t,
  9215. skinInfo: _this._partMeshSkinInfo
  9216. }, [{
  9217. group: "region_" + n + "_" + e,
  9218. mode: 0
  9219. }])) : (_this._currentMeshUsedLod.set(e, t), _this._scenemanager.addNewLowPolyMesh({
  9220. url: a,
  9221. group: "region_" + n + "_" + e,
  9222. pick: !0,
  9223. lod: t,
  9224. skinInfo: _this._partMeshSkinInfo
  9225. }));
  9226. });
  9227. E(this, "checkPointInView", function (_ref) {
  9228. var e = _ref.x,
  9229. t = _ref.y,
  9230. r = _ref.z;
  9231. var n = ue4Position2Xverse({
  9232. x: e,
  9233. y: t,
  9234. z: r
  9235. });
  9236. if (!n) return !1;
  9237. for (var o = 0; o < 6; o++) {
  9238. if (_this.scene.frustumPlanes[o].dotCoordinate(n) < 0) return !1;
  9239. }
  9240. return !0;
  9241. });
  9242. E(this, "addNewLowPolyMesh", function (e, t, r) {
  9243. 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)));
  9244. {
  9245. var n = e.url;
  9246. return new Promise(function (o, a) {
  9247. return _this._scenemanager.urlTransformer(e.url).then(function (s) {
  9248. e.url = s;
  9249. var l = new XStaticMeshFromOneGltf(_this.scene, e),
  9250. u = Date.now();
  9251. return new Promise(function (c, h) {
  9252. l.loadMesh(r, !0).then(function (f) {
  9253. var d = Date.now();
  9254. if (_this._scenemanager.engineRunTimeStats.timeArray_loadStaticMesh.add(d - u), f == !0) {
  9255. var _ = _this.getLowModelType(e);
  9256. var g = 0;
  9257. 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) {
  9258. var m = [];
  9259. for (var v = 0; v < t.length; ++v) {
  9260. m.push(t[v].group), _this.updateLowModelGroup(t[v], _, g);
  9261. }
  9262. }
  9263. _this._scenemanager.engineRunTimeStats.timeArray_updateStaticMesh.add(Date.now() - d), c(!0);
  9264. } else h(new XLowpolyModelError("[Engine] after lowmodel error!"));
  9265. }).catch(function (f) {
  9266. logger$1.error("[Engine] load Mesh [" + n + "] error! " + f), h(new XLowpolyModelError("[Engine] load Mesh [".concat(n, "] error! ").concat(f)));
  9267. });
  9268. });
  9269. }).then(function (s) {
  9270. s == !0 ? (logger$1.info("[Engine] load Mesh [".concat(n, "] successfully.")), o(!0)) : a(!1);
  9271. }).catch(function (s) {
  9272. logger$1.error("[Engine] addNewLowPolyMesh [" + n + "] error! " + s), a(new XLowpolyModelError("[Engine] addNewLowPolyMesh [".concat(n, "] error! ").concat(s)));
  9273. });
  9274. });
  9275. }
  9276. });
  9277. E(this, "toggleLowModelVisibility", function (e) {
  9278. var t = e.vis,
  9279. _e$groupName = e.groupName,
  9280. r = _e$groupName === void 0 ? "" : _e$groupName,
  9281. _e$skinInfo = e.skinInfo,
  9282. n = _e$skinInfo === void 0 ? "" : _e$skinInfo;
  9283. _this._meshVis = t, _this._meshVisTypeName = {
  9284. groupName: r,
  9285. skinInfo: n
  9286. }, _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;
  9287. });
  9288. E(this, "reg_staticmesh_visibility", function () {
  9289. if (_this._doMeshVisChangeNumber >= 0) if (_this._doMeshVisChangeNumber < _this._visCheckDurationFrameNumber) {
  9290. if (_this._doMeshVisChangeNumber = _this._doMeshVisChangeNumber + 1, _this._meshVisTypeName.groupName == Te.ALL_MESHES) _this._lowModel_group.forEach(function (e, t) {
  9291. for (var r = 0, n = e.length; r < n; ++r) {
  9292. e[r].toggleVisibility(_this._meshVis);
  9293. }
  9294. });else {
  9295. if (_this._lowModel_group.has(_this._meshVisTypeName.groupName)) for (var _e3 = 0; _e3 < _this._lowModel_group.get(_this._meshVisTypeName.groupName).length; ++_e3) {
  9296. _this._lowModel_group.get(_this._meshVisTypeName.groupName)[_e3].toggleVisibility(_this._meshVis);
  9297. }
  9298. if (_this._meshVisTypeName.skinInfo != "") for (var _e4 = 0; _e4 < _this._staticmeshes.length; ++_e4) {
  9299. _this._staticmeshes[_e4].skinInfo == _this._meshVisTypeName.skinInfo && _this._staticmeshes[_e4].toggleVisibility(_this._meshVis);
  9300. }
  9301. }
  9302. } else _this._meshVis = !0, _this._meshVisTypeName = {
  9303. groupName: "",
  9304. skinInfo: ""
  9305. }, _this._doMeshVisChangeNumber = -1;
  9306. });
  9307. E(this, "_getMeshesByCustomProperty", function (e, t) {
  9308. var r = [];
  9309. return _this._staticmeshes.forEach(function (n) {
  9310. n[e] != null && n[e] == t && (r = r.concat(n.meshes));
  9311. }), r;
  9312. });
  9313. 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 = {
  9314. groupName: "",
  9315. skinInfo: ""
  9316. }, this._doMeshVisChangeNumber = -1, this._visCheckDurationFrameNumber = -1, this._regionLodRule = [0, 1, 3, 3, -1], this.initCgLowModel(), this._regionPartLoop();
  9317. }
  9318. _createClass(XStaticMeshComponent, [{
  9319. key: "cameraInRegionId",
  9320. get: function get() {
  9321. return this._cameraInRegionId;
  9322. }
  9323. }, {
  9324. key: "setRegionLodRule",
  9325. value: function setRegionLodRule(e) {
  9326. return e.length != 5 ? !1 : (e.forEach(function (t) {}), this._regionLodRule = e, !0);
  9327. }
  9328. }, {
  9329. key: "lowModel_group",
  9330. get: function get() {
  9331. return this._lowModel_group;
  9332. }
  9333. }, {
  9334. key: "_regionPartLoop",
  9335. value: function _regionPartLoop() {
  9336. this.scene.registerBeforeRender(this.reg_staticmesh_partupdate), this.scene.registerAfterRender(this.reg_staticmesh_visibility);
  9337. }
  9338. }, {
  9339. key: "_globalSearchCameraInWhichRegion",
  9340. value: function _globalSearchCameraInWhichRegion(e, t) {
  9341. var r = -1;
  9342. for (var n = 0; n < t.length; ++n) {
  9343. var o = this._meshInfoJson[t[n].toString()].boundingbox,
  9344. a = o[0],
  9345. s = o[1];
  9346. 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]) {
  9347. r = parseInt(t[n].toString());
  9348. break;
  9349. }
  9350. }
  9351. return r;
  9352. }
  9353. }, {
  9354. key: "getRegionIdByPosition",
  9355. value: function getRegionIdByPosition(e) {
  9356. return this.getRegionIdWhichIncludeCamera(e);
  9357. }
  9358. }, {
  9359. key: "getRegionIdWhichIncludeCamera",
  9360. value: function getRegionIdWhichIncludeCamera(e) {
  9361. var t = -1;
  9362. if (this._allowRegionUpdate == !1) return t;
  9363. 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) {
  9364. var r = 1e7;
  9365. for (var n = 0; n < this._meshInfoKeys.length; ++n) {
  9366. var o = this._meshInfoJson[this._meshInfoKeys[n]].center,
  9367. a = Math.abs(e.x - o[0]) + Math.abs(e.y - o[1]);
  9368. r > a && (r = a, t = parseInt(this._meshInfoKeys[n]));
  9369. }
  9370. }
  9371. return t;
  9372. }
  9373. }, {
  9374. key: "getNearestRegionIdWithCamera",
  9375. value: function getNearestRegionIdWithCamera(e) {
  9376. var t = 1,
  9377. r = 1e7;
  9378. for (var n = 0; n < this._meshInfoKeys.length; ++n) {
  9379. if (this._notUsedRegionLists.indexOf(parseInt(this._meshInfoKeys[n])) >= 0) continue;
  9380. var o = this._meshInfoJson[this._meshInfoKeys[n]].center,
  9381. a = Math.abs(e.x - o[0]) + Math.abs(e.y - o[1]);
  9382. r > a && (r = a, t = parseInt(this._meshInfoKeys[n]));
  9383. }
  9384. return t;
  9385. }
  9386. }, {
  9387. key: "_getNeighborId",
  9388. value: function _getNeighborId(e) {
  9389. var t = this._meshInfoJson[e].lod;
  9390. var r = [];
  9391. var n = Object.keys(t);
  9392. for (var o = n.length - 1; o >= 0; --o) {
  9393. r = r.concat(t[n[o]]);
  9394. }
  9395. return r.push(parseInt(e)), r;
  9396. }
  9397. }, {
  9398. key: "_getMainPlayerPosition",
  9399. value: function _getMainPlayerPosition() {
  9400. var e = this._scenemanager.cameraComponent.getCameraPose().position,
  9401. t = this._scenemanager.avatarComponent.getMainAvatar();
  9402. if (t != null && t != null) {
  9403. var r = t.position;
  9404. if (r != null) return r;
  9405. }
  9406. return e;
  9407. }
  9408. }, {
  9409. key: "_calHashCode",
  9410. value: function _calHashCode(e) {
  9411. return hashCode(e) + "_" + this._partMeshSkinInfo;
  9412. }
  9413. }, {
  9414. key: "forceAllRegionLod",
  9415. value: function forceAllRegionLod() {
  9416. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 3;
  9417. e < 0 && (e = 0), e > 3 && (e = 3), this.stopMeshUpdate(), this._allowRegionForceLod = !0, this._forceLod = e;
  9418. }
  9419. }, {
  9420. key: "deleteLastRegionMesh",
  9421. value: function deleteLastRegionMesh() {
  9422. if (this._rootDir != "") {
  9423. var e = this._calHashCode(this._rootDir);
  9424. 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);
  9425. }
  9426. }
  9427. }, {
  9428. key: "startMeshUpdate",
  9429. value: function startMeshUpdate() {
  9430. this._allowRegionUpdate == !1 && this._meshInfoJson != null && this._abosoluteUrl != "" && this._meshInfoKeys.length > 0 && (this._allowRegionUpdate = !0);
  9431. }
  9432. }, {
  9433. key: "stopMeshUpdate",
  9434. value: function stopMeshUpdate() {
  9435. this._allowRegionUpdate = !1;
  9436. }
  9437. }, {
  9438. key: "parseJson",
  9439. value: function parseJson(e) {
  9440. var _this2 = this;
  9441. return new Promise(function (t, r) {
  9442. return _this2._scenemanager.urlTransformer(e).then(function (n) {
  9443. var o = new XMLHttpRequest();
  9444. o.open("get", n), o.send(null), o.onload = function () {
  9445. if (o.status == 200) {
  9446. var a = JSON.parse(o.responseText);
  9447. _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();
  9448. }
  9449. }, o.onerror = function () {
  9450. 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)));
  9451. };
  9452. }).catch(function (n) {
  9453. 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)));
  9454. });
  9455. });
  9456. }
  9457. }, {
  9458. key: "initCgLowModel",
  9459. value: function initCgLowModel() {
  9460. var e = BABYLON.MeshBuilder.CreatePlane("CgPlane", {
  9461. size: 400
  9462. });
  9463. e.position = new BABYLON.Vector3(0, 1010, 0), e.rotation = new BABYLON.Vector3(3 * Math.PI / 2, 0, 0), this._CgPlane = new XStaticMesh({
  9464. id: "CgPlane",
  9465. mesh: e,
  9466. xtype: EMeshType.Cgplane
  9467. }), this._CgPlane.hide();
  9468. }
  9469. }, {
  9470. key: "getLowModelType",
  9471. value: function getLowModelType(e) {
  9472. var t = "";
  9473. return e.group != null ? t = e.group : t = "default", t;
  9474. }
  9475. }, {
  9476. key: "lowmodelGroupMapAddValue",
  9477. value: function lowmodelGroupMapAddValue(e, t) {
  9478. var r = this._lowModel_group.get(e);
  9479. r != null ? (r.push(t), this._lowModel_group.set(e, r)) : this._lowModel_group.set(e, [t]);
  9480. }
  9481. }, {
  9482. key: "updateLowModelGroup",
  9483. value: function updateLowModelGroup(e, t, r) {
  9484. var n = r;
  9485. 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);
  9486. }
  9487. }, {
  9488. key: "toggleVisibleLowModelGroup",
  9489. value: function toggleVisibleLowModelGroup(e, t) {
  9490. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : -1;
  9491. if (this._lowModel_group.has(t)) {
  9492. var n = this._lowModel_group.get(t);
  9493. var o = n.length;
  9494. r >= 0 && o >= r && (o = r);
  9495. for (var a = 0; a < o; ++a) {
  9496. n[a].toggleVisibility(e);
  9497. }
  9498. }
  9499. }
  9500. }, {
  9501. key: "deleteLowModelGroup",
  9502. value: function deleteLowModelGroup(e) {
  9503. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
  9504. if (this._lowModel_group.has(e)) {
  9505. var o = this._lowModel_group.get(e);
  9506. var a = o.length;
  9507. t >= 0 && a >= t && (a = t);
  9508. for (var s = 0; s < a; ++s) {
  9509. o[s].dispose();
  9510. }
  9511. t >= 0 ? this._lowModel_group.set(e, this._lowModel_group.get(e).slice(a)) : this._lowModel_group.delete(e);
  9512. }
  9513. var r = this._lowModel_group.get(e),
  9514. n = [];
  9515. r != null && r.length > 0 ? this._staticmeshes.forEach(function (o) {
  9516. if (o.group != e) n.push(o);else for (var _a2 = 0; _a2 < r.length; ++_a2) {
  9517. o.groupUuid == r[_a2].groupUuid && n.push(o);
  9518. }
  9519. }) : this._staticmeshes.forEach(function (o) {
  9520. o.group != e && n.push(o);
  9521. }), this._staticmeshes = n;
  9522. }
  9523. }, {
  9524. key: "deleteMeshesByGroup",
  9525. value: function deleteMeshesByGroup(e) {
  9526. this.deleteLowModelGroup(e);
  9527. }
  9528. }, {
  9529. key: "deleteMeshesById",
  9530. value: function deleteMeshesById(e) {
  9531. this.deleteMeshesByCustomProperty("id", e);
  9532. }
  9533. }, {
  9534. key: "deleteMeshesByLoD",
  9535. value: function deleteMeshesByLoD(e) {
  9536. this.deleteMeshesByCustomProperty("lod", e);
  9537. }
  9538. }, {
  9539. key: "deleteMeshesBySkinInfo",
  9540. value: function deleteMeshesBySkinInfo(e) {
  9541. this.deleteMeshesByCustomProperty("skinInfo", e);
  9542. }
  9543. }, {
  9544. key: "removeMeshesFromSceneByGroup",
  9545. value: function removeMeshesFromSceneByGroup(e) {
  9546. this.removeMeshesFromSceneByCustomProperty("group", e);
  9547. }
  9548. }, {
  9549. key: "removeMeshesFromSceneById",
  9550. value: function removeMeshesFromSceneById(e) {
  9551. this.removeMeshesFromSceneByCustomProperty("id", e);
  9552. }
  9553. }, {
  9554. key: "addMeshesToSceneByGroup",
  9555. value: function addMeshesToSceneByGroup(e) {
  9556. this.addMeshesToSceneByCustomProperty("group", e);
  9557. }
  9558. }, {
  9559. key: "addMeshesToSceneById",
  9560. value: function addMeshesToSceneById(e) {
  9561. this.addMeshesToSceneByCustomProperty("id", e);
  9562. }
  9563. }, {
  9564. key: "removeMeshesFromSceneByCustomProperty",
  9565. value: function removeMeshesFromSceneByCustomProperty(e, t) {
  9566. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
  9567. this._staticmeshes.forEach(function (n) {
  9568. n.isinscene && n[e] != null && (r ? n[e].indexOf(t) < 0 || n.removeFromScene() : n[e] != t || n.removeFromScene());
  9569. });
  9570. }
  9571. }, {
  9572. key: "addMeshesToSceneByCustomProperty",
  9573. value: function addMeshesToSceneByCustomProperty(e, t) {
  9574. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
  9575. this._staticmeshes.forEach(function (n) {
  9576. n.isinscene == !1 && n[e] != null && (r ? n[e].indexOf(t) < 0 || n.addToScene() : n[e] != t || n.addToScene());
  9577. });
  9578. }
  9579. }, {
  9580. key: "deleteMeshesByCustomProperty",
  9581. value: function deleteMeshesByCustomProperty(e, t) {
  9582. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
  9583. var n = [];
  9584. this._staticmeshes.forEach(function (a) {
  9585. a[e] != null && (r ? a[e].indexOf(t) < 0 ? n.push(a) : a.dispose() : a[e] != t ? n.push(a) : a.dispose());
  9586. }), this._staticmeshes = n;
  9587. var o = Array.from(this._lowModel_group.keys());
  9588. for (var a = 0; a < o.length; ++a) {
  9589. var s = o[a],
  9590. l = this._lowModel_group.get(s);
  9591. if (l != null) {
  9592. var u = [];
  9593. for (var c = 0; c < l.length; ++c) {
  9594. l[c][e] != null && (r ? l[c][e].indexOf(t) < 0 && u.push(l[c]) : l[c][e] != t && u.push(l[c]));
  9595. }
  9596. u.length > 0 ? this._lowModel_group.set(s, u) : this._lowModel_group.delete(s);
  9597. }
  9598. }
  9599. }
  9600. }, {
  9601. key: "getMeshes",
  9602. value: function getMeshes() {
  9603. var e = [];
  9604. for (var t = 0; t < this._staticmeshes.length; ++t) {
  9605. e = e.concat(this._staticmeshes[t].meshes);
  9606. }
  9607. return e;
  9608. }
  9609. }, {
  9610. key: "getCgMesh",
  9611. value: function getCgMesh() {
  9612. return this._CgPlane;
  9613. }
  9614. }, {
  9615. key: "getMeshesByGroup",
  9616. value: function getMeshesByGroup() {
  9617. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "default";
  9618. var t = this._lowModel_group.get(e);
  9619. if (t != null) {
  9620. var r = [];
  9621. for (var n = 0; n < t.length; ++n) {
  9622. r = r.concat(t[n].meshes);
  9623. }
  9624. return r;
  9625. } else return null;
  9626. }
  9627. }, {
  9628. key: "getMeshesByGroup2",
  9629. value: function getMeshesByGroup2() {
  9630. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "default";
  9631. return this._getMeshesByCustomProperty("group", e);
  9632. }
  9633. }]);
  9634. return XStaticMeshComponent;
  9635. }();
  9636. var XVideoRawYUV = /*#__PURE__*/function () {
  9637. function XVideoRawYUV(e, t) {
  9638. var _this = this;
  9639. _classCallCheck(this, XVideoRawYUV);
  9640. E(this, "scene");
  9641. E(this, "_videoRawYUVTexture");
  9642. E(this, "videosResOriArray");
  9643. E(this, "_currentVideoId");
  9644. this.scene = e, this._videoRawYUVTexture = [], this.videosResOriArray = t, this._currentVideoId = -1;
  9645. for (var r = 0; r < t.length; ++r) {
  9646. (function (n) {
  9647. var o = BABYLON.RawTexture.CreateLuminanceTexture(null, t[n].width, t[n].height * 1.5, _this.scene, !1, !0);
  9648. o.name = "videoTex_" + t[n].width + "_" + t[n].height, _this._videoRawYUVTexture.push(o);
  9649. })(r);
  9650. }
  9651. }
  9652. _createClass(XVideoRawYUV, [{
  9653. key: "inRange",
  9654. value: function inRange(e) {
  9655. return e >= 0 && e < this._videoRawYUVTexture.length;
  9656. }
  9657. }, {
  9658. key: "getVideoYUVTex",
  9659. value: function getVideoYUVTex(e) {
  9660. return this.inRange(e) ? this._videoRawYUVTexture[e] : null;
  9661. }
  9662. }, {
  9663. key: "findId",
  9664. value: function findId(e, t) {
  9665. var r = 0;
  9666. for (var n = 0; n < this.videosResOriArray.length; ++n) {
  9667. if (this.videosResOriArray[n].width == e && this.videosResOriArray[n].height == t) {
  9668. r = n;
  9669. break;
  9670. }
  9671. }
  9672. return r;
  9673. }
  9674. }, {
  9675. key: "getCurrentVideoTexId",
  9676. value: function getCurrentVideoTexId() {
  9677. return this._currentVideoId;
  9678. }
  9679. }, {
  9680. key: "setCurrentVideoTexId",
  9681. value: function setCurrentVideoTexId(e) {
  9682. this._currentVideoId = e;
  9683. }
  9684. }]);
  9685. return XVideoRawYUV;
  9686. }();
  9687. var XMaterialComponent = /*#__PURE__*/function () {
  9688. function XMaterialComponent(e, t) {
  9689. var _this = this;
  9690. _classCallCheck(this, XMaterialComponent);
  9691. E(this, "scene");
  9692. E(this, "engine");
  9693. E(this, "yuvInfo");
  9694. E(this, "shaderMode");
  9695. E(this, "_panoInfo");
  9696. E(this, "_dynamic_size");
  9697. E(this, "_dynamic_babylonpose");
  9698. E(this, "_dynamic_textures");
  9699. E(this, "_dynamic_shaders");
  9700. E(this, "_scenemanager");
  9701. E(this, "_videoTexture");
  9702. E(this, "_videoElement");
  9703. E(this, "_lowModelShader");
  9704. E(this, "_defaultShader");
  9705. E(this, "_inputYUV420", !0);
  9706. E(this, "_inputPanoYUV420", !0);
  9707. E(this, "_videoRawYUVTexArray");
  9708. E(this, "_isUpdateYUV", !0);
  9709. E(this, "initMaterial", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  9710. return regenerator.wrap(function _callee$(_context) {
  9711. while (1) {
  9712. switch (_context.prev = _context.next) {
  9713. case 0:
  9714. return _context.abrupt("return", new Promise(function (e, t) {
  9715. _this._initDefaultShader(), _this.shaderMode == 2 ? _this.initDynamicData(_this._panoInfo.dynamicRange, _this._panoInfo.width, _this._panoInfo.height).then(function () {
  9716. _this._initPureVideoShader(), _this._prepareRender(_this.yuvInfo);
  9717. }) : _this.shaderMode == 1 ? (_this._initPureVideoShader(), _this._prepareRender(_this.yuvInfo)) : _this.shaderMode == 0, e(!0);
  9718. }));
  9719. case 1:
  9720. case "end":
  9721. return _context.stop();
  9722. }
  9723. }
  9724. }, _callee);
  9725. })));
  9726. E(this, "_initPureVideoContent", function (e) {
  9727. _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 () {
  9728. _this._changePureVideoLowModelShaderCanvasSize(e);
  9729. })) : (_this._videoElement = e.videoElement, _this._videoTexture || (_this._videoTexture = new VideoTexture("InterVideoTexture", _this._videoElement, _this.scene, !0, !1)), BABYLON.Texture.WhenAllReady([_this._videoTexture], function () {
  9730. _this._changePureVideoLowModelShaderCanvasSize({
  9731. width: _this._videoElement.height,
  9732. height: _this._videoElement.width,
  9733. fov: e.fov
  9734. });
  9735. }), _this._lowModelShader.setTexture("texture_video", _this._videoTexture), _this._lowModelShader.setFloat("isYUV", 0));
  9736. });
  9737. E(this, "_changePureVideoLowModelShaderCanvasSize", function (e) {
  9738. var a;
  9739. var t = e.fov || 50,
  9740. r = e.width || 720,
  9741. n = e.height || 1280,
  9742. o = r / (2 * Math.tan(Math.PI * t / 360));
  9743. (a = _this._lowModelShader) == null || a.setVector3("focal_width_height", new BABYLON.Vector3(o, r, n));
  9744. });
  9745. E(this, "updateRawYUVData", function (e, t, r) {
  9746. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : -1;
  9747. var o, a;
  9748. if (n == -1 && (n = _this.yuvInfo.fov), _this._isUpdateYUV == !0) {
  9749. var s = {
  9750. width: t,
  9751. height: r,
  9752. fov: n
  9753. },
  9754. l = _this._videoRawYUVTexArray.findId(t, r),
  9755. u = _this._videoRawYUVTexArray.getCurrentVideoTexId();
  9756. (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);
  9757. }
  9758. });
  9759. E(this, "_changeVideoRes", function (e) {
  9760. _this._lowModelShader.setTexture("texture_video", _this._videoRawYUVTexArray.getVideoYUVTex(e));
  9761. });
  9762. E(this, "initDynamicData", function (e, t, r) {
  9763. return new Promise(function (n, o) {
  9764. _this.setDynamicSize(e).then(function (a) {
  9765. if (a) {
  9766. for (var s = 0; s < e; ++s) {
  9767. (function (l) {
  9768. _this.initDynamicTexture(l, t, r), _this.initDynamicShaders(l).then(function () {
  9769. _this._updatePanoShaderInput(l);
  9770. });
  9771. })(s);
  9772. }
  9773. n(!0);
  9774. } else o(new XMaterialError("[Engine] DynamicRoomSize (".concat(e, ") is too small")));
  9775. });
  9776. }).catch(function (n) {
  9777. return logger$1.error("[Engine] ".concat(n));
  9778. });
  9779. });
  9780. E(this, "_initDefaultShader", function () {
  9781. _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);
  9782. });
  9783. E(this, "_initPureVideoShader", function () {
  9784. if (_this._lowModelShader == null) {
  9785. var _e = new BABYLON.ShaderMaterial("PureVideoShader", _this.scene, {
  9786. vertexSource: pureVideoVertex,
  9787. fragmentSource: pureVideoFragment
  9788. }, {
  9789. attributes: ["uv", "position", "world0", "world1", "world2", "world3"],
  9790. uniforms: ["view", "projection", "worldViewProjection", "world"],
  9791. defines: ["#define SHADOWFULLFLOAT"]
  9792. });
  9793. _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;
  9794. }
  9795. });
  9796. E(this, "setDynamicSize", function (e) {
  9797. return new Promise(function (t, r) {
  9798. e >= 1 && e <= 100 ? (_this._dynamic_size = e, t(!0)) : (_this._dynamic_size = 1, t(!1));
  9799. });
  9800. });
  9801. E(this, "_isInDynamicRange", function (e) {
  9802. return e < _this._dynamic_size && e >= 0;
  9803. });
  9804. E(this, "initDynamicTexture", function (e, t, r) {
  9805. _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());
  9806. });
  9807. E(this, "initDynamicShaders", function (e) {
  9808. return logger$1.info("[Engine] Material init dynamic shader."), new Promise(function (t, r) {
  9809. _this._dynamic_shaders[e] != null && _this._dynamic_shaders[e].dispose();
  9810. var n = new BABYLON.ShaderMaterial("Pano_Shader_" + e, _this.scene, {
  9811. vertexSource: panoVertex,
  9812. fragmentSource: panoFragment
  9813. }, {
  9814. attributes: ["uv", "position", "world0", "world1", "world2", "world3"],
  9815. uniforms: ["view", "projection", "worldViewProjection", "world"],
  9816. defines: ["#define SHADOWFULLFLOAT"]
  9817. });
  9818. 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);
  9819. });
  9820. });
  9821. 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);
  9822. }
  9823. _createClass(XMaterialComponent, [{
  9824. key: "stopYUVUpdate",
  9825. value: function stopYUVUpdate() {
  9826. this._isUpdateYUV = !1;
  9827. }
  9828. }, {
  9829. key: "allowYUVUpdate",
  9830. value: function allowYUVUpdate() {
  9831. this._isUpdateYUV = !0;
  9832. }
  9833. }, {
  9834. key: "setPanoInfo",
  9835. value: function setPanoInfo(e) {
  9836. this._panoInfo = e;
  9837. }
  9838. }, {
  9839. key: "_prepareRender",
  9840. value: function _prepareRender(e) {
  9841. e && (this._initPureVideoContent(e), this._updatePureVideoShaderInput());
  9842. }
  9843. }, {
  9844. key: "getPureVideoShader",
  9845. value: function getPureVideoShader() {
  9846. return this._lowModelShader;
  9847. }
  9848. }, {
  9849. key: "getDefaultShader",
  9850. value: function getDefaultShader() {
  9851. return this._defaultShader;
  9852. }
  9853. }, {
  9854. key: "updatePanoPartYUV",
  9855. value: function updatePanoPartYUV(e, t, r) {
  9856. var n = t.subarray(0, r.width * r.height),
  9857. o = t.subarray(r.width * r.height, r.width * r.height * 1.25),
  9858. a = t.subarray(r.width * r.height * 1.25),
  9859. s = this._panoInfo.width,
  9860. l = this._panoInfo.height;
  9861. if (this._dynamic_textures[e] != null) {
  9862. var u = this._dynamic_textures[e].getInternalTexture();
  9863. if (u != null && u != null) {
  9864. var c = this.engine._getTextureTarget(u);
  9865. 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);
  9866. }
  9867. }
  9868. }
  9869. }, {
  9870. key: "changePanoImg",
  9871. value: function changePanoImg(e, t) {
  9872. var _this2 = this;
  9873. 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")));
  9874. var r = ue4Position2Xverse(t.pose.position);
  9875. return r && (this._dynamic_babylonpose[e] = {
  9876. position: r
  9877. }), new Promise(function (n, o) {
  9878. try {
  9879. typeof t.data == "string" ? (_this2.setPanoYUV420(!1), _this2._dynamic_textures[e].updateURL(t.data, null, function () {
  9880. _this2._dynamic_textures[e].updateSamplingMode(BABYLON.Texture.NEAREST_SAMPLINGMODE);
  9881. })) : (_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);
  9882. } catch (a) {
  9883. o(new XMaterialError("[Engine] ChangePanoImg Error! ".concat(a)));
  9884. }
  9885. }).then(function (n) {
  9886. 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;
  9887. });
  9888. }
  9889. }, {
  9890. key: "setYUV420",
  9891. value: function setYUV420(e) {
  9892. this._inputYUV420 = e;
  9893. }
  9894. }, {
  9895. key: "isYUV420",
  9896. value: function isYUV420() {
  9897. return this._inputYUV420;
  9898. }
  9899. }, {
  9900. key: "setPanoYUV420",
  9901. value: function setPanoYUV420(e) {
  9902. this._inputPanoYUV420 = e;
  9903. }
  9904. }, {
  9905. key: "isPanoYUV420",
  9906. value: function isPanoYUV420() {
  9907. return this._inputPanoYUV420;
  9908. }
  9909. }, {
  9910. key: "getDynamicShader",
  9911. value: function getDynamicShader(e) {
  9912. return this._dynamic_shaders[e];
  9913. }
  9914. }, {
  9915. key: "_updatePureVideoShaderInput",
  9916. value: function _updatePureVideoShaderInput() {
  9917. var _this3 = this;
  9918. var e, t, r, n, o, a, s, l, u, c;
  9919. 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 () {
  9920. var h;
  9921. _this3._lowModelShader.setFloat("fireworkLight", _this3.scene.getLightByName("fireworkLight").getScaledIntensity()), _this3._lowModelShader.setVector3("fireworkLightPosition", (h = _this3.scene.getLightByName("fireworkLight")) == null ? void 0 : h.position);
  9922. });else {
  9923. var h = new BABYLON.PointLight("fireworkLight", new BABYLON.Vector3(0, 0, 0), this.scene);
  9924. h.intensity = 0;
  9925. }
  9926. }
  9927. }, {
  9928. key: "_updatePanoShaderInput",
  9929. value: function _updatePanoShaderInput(e) {
  9930. var _this4 = this;
  9931. var t, r, n, o, a, s, l, u, c, h;
  9932. 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 () {
  9933. var f;
  9934. _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);
  9935. });else {
  9936. var f = new BABYLON.PointLight("fireworkLight", new BABYLON.Vector3(0, 0, 0), this.scene);
  9937. f.intensity = 0;
  9938. }
  9939. }
  9940. }]);
  9941. return XMaterialComponent;
  9942. }();
  9943. var XStats = /*#__PURE__*/function () {
  9944. function XStats(e) {
  9945. _classCallCheck(this, XStats);
  9946. E(this, "scene");
  9947. E(this, "sceneInstrumentation");
  9948. E(this, "engineInstrumentation");
  9949. E(this, "caps");
  9950. E(this, "engine");
  9951. E(this, "_canvas");
  9952. E(this, "_osversion");
  9953. E(this, "_scenemanager");
  9954. this._scenemanager = e, this.scene = e.Scene, this._canvas = e.canvas, this.initSceneInstrument();
  9955. }
  9956. _createClass(XStats, [{
  9957. key: "initSceneInstrument",
  9958. value: function initSceneInstrument() {
  9959. 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();
  9960. }
  9961. }, {
  9962. key: "getFrameTimeCounter",
  9963. value: function getFrameTimeCounter() {
  9964. return this.sceneInstrumentation.frameTimeCounter.current;
  9965. }
  9966. }, {
  9967. key: "getInterFrameTimeCounter",
  9968. value: function getInterFrameTimeCounter() {
  9969. return this.sceneInstrumentation.interFrameTimeCounter.current;
  9970. }
  9971. }, {
  9972. key: "getActiveMeshEvaluationTime",
  9973. value: function getActiveMeshEvaluationTime() {
  9974. return this.sceneInstrumentation.activeMeshesEvaluationTimeCounter.current;
  9975. }
  9976. }, {
  9977. key: "getDrawCall",
  9978. value: function getDrawCall() {
  9979. return this.sceneInstrumentation.drawCallsCounter.current;
  9980. }
  9981. }, {
  9982. key: "getDrawCallTime",
  9983. value: function getDrawCallTime() {
  9984. return this.sceneInstrumentation.renderTimeCounter.current;
  9985. }
  9986. }, {
  9987. key: "getAnimationTime",
  9988. value: function getAnimationTime() {
  9989. return this.sceneInstrumentation.animationsTimeCounter.current;
  9990. }
  9991. }, {
  9992. key: "getActiveMesh",
  9993. value: function getActiveMesh() {
  9994. return this.scene.getActiveMeshes().length;
  9995. }
  9996. }, {
  9997. key: "getActiveFaces",
  9998. value: function getActiveFaces() {
  9999. return Math.round(this.scene.getActiveIndices() / 3);
  10000. }
  10001. }, {
  10002. key: "getActiveBones",
  10003. value: function getActiveBones() {
  10004. return this.scene.getActiveBones();
  10005. }
  10006. }, {
  10007. key: "getActiveAnimation",
  10008. value: function getActiveAnimation() {
  10009. return this.scene._activeAnimatables.length;
  10010. }
  10011. }, {
  10012. key: "getActiveParticles",
  10013. value: function getActiveParticles() {
  10014. return this.scene.getActiveParticles();
  10015. }
  10016. }, {
  10017. key: "getTotalMaterials",
  10018. value: function getTotalMaterials() {
  10019. return this.scene.materials.length;
  10020. }
  10021. }, {
  10022. key: "getTotalTextures",
  10023. value: function getTotalTextures() {
  10024. return this.scene.textures.length;
  10025. }
  10026. }, {
  10027. key: "getTotalGeometries",
  10028. value: function getTotalGeometries() {
  10029. return this.scene.geometries.length;
  10030. }
  10031. }, {
  10032. key: "getTotalMeshes",
  10033. value: function getTotalMeshes() {
  10034. return this.scene.meshes.length;
  10035. }
  10036. }, {
  10037. key: "getCameraRenderTime",
  10038. value: function getCameraRenderTime() {
  10039. return this.sceneInstrumentation.cameraRenderTimeCounter.current;
  10040. }
  10041. }, {
  10042. key: "getTotalRootNodes",
  10043. value: function getTotalRootNodes() {
  10044. return this.scene.rootNodes.length;
  10045. }
  10046. }, {
  10047. key: "getRenderTargetRenderTime",
  10048. value: function getRenderTargetRenderTime() {
  10049. var e = this.getDrawCallTime(),
  10050. t = this.getActiveMeshEvaluationTime(),
  10051. r = this.getCameraRenderTime() - (t + e);
  10052. return this.getRTT1Time() + r;
  10053. }
  10054. }, {
  10055. key: "getRegisterBeforeRenderTime",
  10056. value: function getRegisterBeforeRenderTime() {
  10057. return this.sceneInstrumentation.registerBeforeTimeCounter.current;
  10058. }
  10059. }, {
  10060. key: "getRegisterAfterRenderTime",
  10061. value: function getRegisterAfterRenderTime() {
  10062. return this.sceneInstrumentation.registerAfterTimeCounter.current;
  10063. }
  10064. }, {
  10065. key: "getRTT1Time",
  10066. value: function getRTT1Time() {
  10067. return this.sceneInstrumentation.getRTT1TimeCounter.current;
  10068. }
  10069. }, {
  10070. key: "getRegisterBeforeRenderObserverLength",
  10071. value: function getRegisterBeforeRenderObserverLength() {
  10072. return this.scene.onBeforeRenderObservable.observers.length;
  10073. }
  10074. }, {
  10075. key: "getRegisterAfterRenderObserverLength",
  10076. value: function getRegisterAfterRenderObserverLength() {
  10077. return this.scene.onAfterRenderObservable.observers.length;
  10078. }
  10079. }, {
  10080. key: "getTotalMeshByType",
  10081. value: function getTotalMeshByType() {
  10082. var e = new Map();
  10083. return this.scene.meshes.forEach(function (t) {
  10084. e.has(t.xtype) ? e.set(t.xtype, e.get(t.xtype) + 1) : e.set(t.xtype, 1);
  10085. }), e;
  10086. }
  10087. }, {
  10088. key: "getHardwareRenderInfo",
  10089. value: function getHardwareRenderInfo() {
  10090. return {
  10091. maxTexturesUnits: this.caps.maxTexturesImageUnits,
  10092. maxVertexTextureImageUnits: this.caps.maxVertexTextureImageUnits,
  10093. maxCombinedTexturesImageUnits: this.caps.maxCombinedTexturesImageUnits,
  10094. maxTextureSize: this.caps.maxTextureSize,
  10095. maxSamples: this.caps.maxSamples,
  10096. maxCubemapTextureSize: this.caps.maxCubemapTextureSize,
  10097. maxRenderTextureSize: this.caps.maxRenderTextureSize,
  10098. maxVertexAttribs: this.caps.maxVertexAttribs,
  10099. maxVaryingVectors: this.caps.maxVaryingVectors,
  10100. maxVertexUniformVectors: this.caps.maxVertexUniformVectors,
  10101. maxFragmentUniformVectors: this.caps.maxFragmentUniformVectors,
  10102. standardDerivatives: this.caps.standardDerivatives,
  10103. supportTextureCompress: {
  10104. s3tc: this.caps.s3tc !== void 0,
  10105. s3tc_srgb: this.caps.s3tc_srgb !== void 0,
  10106. pvrtc: this.caps.pvrtc !== void 0,
  10107. etc1: this.caps.etc1 !== void 0,
  10108. etc2: this.caps.etc2 !== void 0,
  10109. astc: this.caps.astc !== void 0,
  10110. bptc: this.caps.bptc !== void 0
  10111. },
  10112. textureFloat: this.caps.textureFloat,
  10113. vertexArrayObject: this.caps.vertexArrayObject,
  10114. textureAnisotropicFilterExtension: this.caps.textureAnisotropicFilterExtension !== void 0,
  10115. maxAnisotropy: this.caps.maxAnisotropy,
  10116. instancedArrays: this.caps.instancedArrays,
  10117. uintIndices: this.caps.uintIndices,
  10118. highPrecisionShaders: this.caps.highPrecisionShaderSupported,
  10119. fragmentDepth: this.caps.fragmentDepthSupported,
  10120. textureFloatLinearFiltering: this.caps.textureFloatLinearFiltering,
  10121. renderToTextureFloat: this.caps.textureFloatRender,
  10122. textureHalfFloat: this.caps.textureHalfFloat,
  10123. textureHalfFloatLinearFiltering: this.caps.textureHalfFloatLinearFiltering,
  10124. textureHalfFloatRender: this.caps.textureHalfFloatRender,
  10125. textureLOD: this.caps.textureLOD,
  10126. drawBuffersExtension: this.caps.drawBuffersExtension,
  10127. depthTextureExtension: this.caps.depthTextureExtension,
  10128. colorBufferFloat: this.caps.colorBufferFloat,
  10129. supportTimerQuery: this.caps.timerQuery !== void 0,
  10130. canUseTimestampForTimerQuery: this.caps.canUseTimestampForTimerQuery,
  10131. supportOcclusionQuery: this.caps.supportOcclusionQuery,
  10132. multiview: this.caps.multiview,
  10133. oculusMultiview: this.caps.oculusMultiview,
  10134. maxMSAASamples: this.caps.maxMSAASamples,
  10135. blendMinMax: this.caps.blendMinMax,
  10136. canUseGLInstanceID: this.caps.canUseGLInstanceID,
  10137. canUseGLVertexID: this.caps.canUseGLVertexID,
  10138. supportComputeShaders: this.caps.supportComputeShaders,
  10139. supportSRGBBuffers: this.caps.supportSRGBBuffers,
  10140. supportStencil: this.engine.isStencilEnable
  10141. };
  10142. }
  10143. }, {
  10144. key: "getSystemInfo",
  10145. value: function getSystemInfo() {
  10146. return {
  10147. resolution: "real: " + this.engine.getRenderWidth() + "x" + this.engine.getRenderHeight() + " cavs: " + this._canvas.clientWidth + "x" + this._canvas.clientHeight,
  10148. hardwareScalingLevel: this.engine.getHardwareScalingLevel().toFixed(2).toString() + "_" + this._scenemanager.initEngineScaleNumber.toFixed(2).toString(),
  10149. driver: this.engine.getGlInfo().renderer,
  10150. vender: this.engine.getGlInfo().vendor,
  10151. version: this.engine.getGlInfo().version,
  10152. os: this._osversion
  10153. };
  10154. }
  10155. }, {
  10156. key: "getFps",
  10157. value: function getFps() {
  10158. var e = this.sceneInstrumentation.frameTimeCounter.lastSecAverage,
  10159. t = this.sceneInstrumentation.interFrameTimeCounter.lastSecAverage;
  10160. return 1e3 / (e + t);
  10161. }
  10162. }, {
  10163. key: "osVersion",
  10164. value: function osVersion() {
  10165. var e = window.navigator.userAgent;
  10166. var t;
  10167. 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;
  10168. }
  10169. }]);
  10170. return XStats;
  10171. }();
  10172. function _arrayWithHoles(arr) {
  10173. if (Array.isArray(arr)) return arr;
  10174. }
  10175. function _iterableToArrayLimit(arr, i) {
  10176. var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
  10177. if (_i == null) return;
  10178. var _arr = [];
  10179. var _n = true;
  10180. var _d = false;
  10181. var _s, _e;
  10182. try {
  10183. for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
  10184. _arr.push(_s.value);
  10185. if (i && _arr.length === i) break;
  10186. }
  10187. } catch (err) {
  10188. _d = true;
  10189. _e = err;
  10190. } finally {
  10191. try {
  10192. if (!_n && _i["return"] != null) _i["return"]();
  10193. } finally {
  10194. if (_d) throw _e;
  10195. }
  10196. }
  10197. return _arr;
  10198. }
  10199. function _nonIterableRest() {
  10200. throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  10201. }
  10202. function _slicedToArray(arr, i) {
  10203. return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray$7(arr, i) || _nonIterableRest();
  10204. }
  10205. var BreathPoint = /*#__PURE__*/function () {
  10206. function BreathPoint(e) {
  10207. _classCallCheck(this, BreathPoint);
  10208. E(this, "_staticmesh");
  10209. E(this, "_id");
  10210. E(this, "_mat");
  10211. E(this, "_type");
  10212. E(this, "_maxVisibleRegion");
  10213. E(this, "_skinInfo");
  10214. E(this, "_scene");
  10215. E(this, "_isInScene");
  10216. var t = e.mesh,
  10217. r = e.id,
  10218. n = e.position,
  10219. o = e.rotation,
  10220. a = e.mat,
  10221. _e$type = e.type,
  10222. s = _e$type === void 0 ? "default" : _e$type,
  10223. _e$maxVisibleRegion = e.maxVisibleRegion,
  10224. l = _e$maxVisibleRegion === void 0 ? -1 : _e$maxVisibleRegion,
  10225. u = e.scene,
  10226. _e$skinInfo = e.skinInfo,
  10227. c = _e$skinInfo === void 0 ? "default" : _e$skinInfo;
  10228. 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;
  10229. }
  10230. _createClass(BreathPoint, [{
  10231. key: "isInScene",
  10232. get: function get() {
  10233. return this._isInScene;
  10234. }
  10235. }, {
  10236. key: "skinInfo",
  10237. get: function get() {
  10238. return this._skinInfo;
  10239. }
  10240. }, {
  10241. key: "maxvisibleregion",
  10242. get: function get() {
  10243. return this._maxVisibleRegion;
  10244. }
  10245. }, {
  10246. key: "getMesh",
  10247. value: function getMesh() {
  10248. return this._staticmesh;
  10249. }
  10250. }, {
  10251. key: "mesh",
  10252. get: function get() {
  10253. return this._staticmesh.mesh;
  10254. }
  10255. }, {
  10256. key: "toggleVisibility",
  10257. value: function toggleVisibility(e) {
  10258. e == !0 ? this._staticmesh.show() : this._staticmesh.hide();
  10259. }
  10260. }, {
  10261. key: "changePickable",
  10262. value: function changePickable(e) {
  10263. this._staticmesh.mesh.isPickable = e;
  10264. }
  10265. }, {
  10266. key: "removeFromScene",
  10267. value: function removeFromScene() {
  10268. this._isInScene && (this._staticmesh.mesh != null && this._scene.removeMesh(this._staticmesh.mesh), this._isInScene = !1);
  10269. }
  10270. }, {
  10271. key: "addToScene",
  10272. value: function addToScene() {
  10273. this._isInScene == !1 && (this._staticmesh.mesh != null && this._scene.addMesh(this._staticmesh.mesh), this._isInScene = !0);
  10274. }
  10275. }, {
  10276. key: "dispose",
  10277. value: function dispose() {
  10278. var e;
  10279. (e = this._staticmesh.mesh) == null || e.dispose(!1, !1);
  10280. }
  10281. }, {
  10282. key: "position",
  10283. get: function get() {
  10284. return xversePosition2Ue4(this._staticmesh.mesh.position);
  10285. },
  10286. set: function set(e) {
  10287. this._staticmesh.mesh.position = ue4Position2Xverse(e);
  10288. }
  10289. }, {
  10290. key: "rotation",
  10291. get: function get() {
  10292. return xverseRotation2Ue4(this._staticmesh.mesh.rotation);
  10293. },
  10294. set: function set(e) {
  10295. this._staticmesh.mesh.rotation = ue4Rotation2Xverse(e);
  10296. }
  10297. }]);
  10298. return BreathPoint;
  10299. }();
  10300. 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; } } }; }
  10301. 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); }
  10302. 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; }
  10303. var XBreathPointManager = /*#__PURE__*/function () {
  10304. function XBreathPointManager(e) {
  10305. var _this = this;
  10306. _classCallCheck(this, XBreathPointManager);
  10307. E(this, "_scene");
  10308. E(this, "materialMap", new Map());
  10309. E(this, "breathPoints", new Map());
  10310. E(this, "_sceneManager");
  10311. E(this, "_allIds", new Set());
  10312. E(this, "_loopBPKeys", []);
  10313. E(this, "addBreathPoint", /*#__PURE__*/function () {
  10314. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  10315. 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;
  10316. return regenerator.wrap(function _callee$(_context) {
  10317. while (1) {
  10318. switch (_context.prev = _context.next) {
  10319. case 0:
  10320. t = [{
  10321. url: "https://static.xverse.cn/qqktv/texture.png"
  10322. }];
  10323. if (!(t.length <= 0)) {
  10324. _context.next = 4;
  10325. break;
  10326. }
  10327. logger$1.warn("[Engine] BreathPoint get texture list error: textureList.length <= 0"), new XBreathPointError("[Engine] BreathPoint get texture list error!");
  10328. return _context.abrupt("return");
  10329. case 4:
  10330. 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 ? {
  10331. pitch: -90,
  10332. yaw: 270,
  10333. roll: 0
  10334. } : _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;
  10335. if (!_this.breathPoints.get(n)) {
  10336. _context.next = 8;
  10337. break;
  10338. }
  10339. logger$1.warn("[Engine] Cannot add breathPoint with an existing id: [" + n + "]"), new XBreathPointError("[Engine] Cannot add breathPoint with an existing id: [" + n + "]");
  10340. return _context.abrupt("return");
  10341. case 8:
  10342. if (g) {
  10343. I = _this.castRay(new BABYLON.Vector3(l.x, l.y, l.z)) * scaleFromUE4toXverse;
  10344. I != 0 ? l.z = l.z - I + 1 : l.z = l.z + 1;
  10345. }
  10346. if (_this.materialMap.get(m)) {
  10347. _I = _this.materialMap.get(m);
  10348. _I.count = _I.count + 1, C = _I.mat;
  10349. } else {
  10350. _I2 = new BABYLON.Texture(o, _this._scene, !0, !0, BABYLON.Texture.BILINEAR_SAMPLINGMODE, null, function () {
  10351. logger$1.error("[Engine] Breathpoint create texture error."), new XBreathPointError("[Engine] Breathpoint create texture error.");
  10352. }, null, !0);
  10353. _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, {
  10354. mat: C,
  10355. count: 1,
  10356. lastRenderTime: Date.now(),
  10357. fps: d,
  10358. spriteWidthNumber: a,
  10359. spriteHeightNumber: s,
  10360. spriteSheet: o,
  10361. texture: _I2
  10362. });
  10363. }
  10364. A = new Array(6);
  10365. for (_I3 = 0; _I3 < 6; _I3++) {
  10366. A[_I3] = new BABYLON.Vector4(0, 0, 0, 0);
  10367. }
  10368. A[0] = new BABYLON.Vector4(0, 0, 1 / a, 1 / s), A[1] = new BABYLON.Vector4(0, 0, 1 / a, 1 / s);
  10369. S = {};
  10370. h > 0 && f > 0 ? S = {
  10371. width: h,
  10372. height: f,
  10373. depth: .01,
  10374. faceUV: A
  10375. } : S = {
  10376. size: c,
  10377. depth: .01,
  10378. faceUV: A
  10379. };
  10380. P = BABYLON.MeshBuilder.CreateBox(n, S, _this._scene);
  10381. P.material = C;
  10382. R = new XStaticMesh({
  10383. id: n,
  10384. mesh: P,
  10385. xtype: EMeshType.XBreathPoint,
  10386. skinInfo: T
  10387. });
  10388. M = u;
  10389. _ && (P.billboardMode = BABYLON.Mesh.BILLBOARDMODE_ALL, R.allowMove(), M = {
  10390. pitch: 0,
  10391. yaw: 270,
  10392. roll: 0
  10393. });
  10394. x = new BreathPoint({
  10395. type: m,
  10396. mesh: R,
  10397. id: n,
  10398. position: l,
  10399. rotation: M,
  10400. mat: C,
  10401. maxVisibleRegion: b,
  10402. scene: _this._scene,
  10403. skinInfo: T
  10404. });
  10405. _this.breathPoints.set(n, x), _this._allIds.add(n), v > 0 && setTimeout(function () {
  10406. _this.clearBreathPoints(n);
  10407. }, v * 1e3);
  10408. case 22:
  10409. case "end":
  10410. return _context.stop();
  10411. }
  10412. }
  10413. }, _callee);
  10414. }));
  10415. return function (_x) {
  10416. return _ref.apply(this, arguments);
  10417. };
  10418. }());
  10419. E(this, "reg_breathpoint_update", function () {
  10420. var e = new Date().getTime();
  10421. if (_this.materialMap != null) {
  10422. var _iterator = _createForOfIteratorHelper$4(_this.materialMap),
  10423. _step;
  10424. try {
  10425. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  10426. var _step$value = _slicedToArray(_step.value, 2),
  10427. t = _step$value[0],
  10428. r = _step$value[1];
  10429. 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);
  10430. }
  10431. } catch (err) {
  10432. _iterator.e(err);
  10433. } finally {
  10434. _iterator.f();
  10435. }
  10436. }
  10437. });
  10438. E(this, "reg_breathpoint_autovisible", function () {
  10439. if (_this._scene.getFrameId() % 2 == 0) if (_this._loopBPKeys.length == 0) _this._loopBPKeys = Array.from(_this._allIds);else {
  10440. var _e = _this._getMainPlayerPosition();
  10441. for (var t = 0; t < 5 && _this._loopBPKeys.length > 0; ++t) {
  10442. var r = _this._loopBPKeys.pop();
  10443. if (r != null) {
  10444. var n = _this.getBreathPoint(r);
  10445. if (n != null && n.maxvisibleregion >= 0 && n.mesh.visibility == 1) {
  10446. var o = n.mesh.position;
  10447. calcDistance3DVector(_e, o) >= n.maxvisibleregion ? n == null || n.removeFromScene() : n == null || n.addToScene();
  10448. }
  10449. }
  10450. }
  10451. }
  10452. });
  10453. this._sceneManager = e, this._scene = e.Scene, this._scene.registerBeforeRender(this.reg_breathpoint_update), this._scene.registerBeforeRender(this.reg_breathpoint_autovisible);
  10454. }
  10455. _createClass(XBreathPointManager, [{
  10456. key: "setAllBreathPointVisibility",
  10457. value: function setAllBreathPointVisibility(e) {
  10458. var _iterator2 = _createForOfIteratorHelper$4(this.breathPoints.entries()),
  10459. _step2;
  10460. try {
  10461. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  10462. var _step2$value = _slicedToArray(_step2.value, 2),
  10463. t = _step2$value[0],
  10464. r = _step2$value[1];
  10465. r.toggleVisibility(e);
  10466. }
  10467. } catch (err) {
  10468. _iterator2.e(err);
  10469. } finally {
  10470. _iterator2.f();
  10471. }
  10472. }
  10473. }, {
  10474. key: "toggleBPVisibilityBySkinInfo",
  10475. value: function toggleBPVisibilityBySkinInfo(e, t) {
  10476. var _iterator3 = _createForOfIteratorHelper$4(this.breathPoints.entries()),
  10477. _step3;
  10478. try {
  10479. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  10480. var _step3$value = _slicedToArray(_step3.value, 2),
  10481. r = _step3$value[0],
  10482. n = _step3$value[1];
  10483. n.skinInfo == e && n.toggleVisibility(t);
  10484. }
  10485. } catch (err) {
  10486. _iterator3.e(err);
  10487. } finally {
  10488. _iterator3.f();
  10489. }
  10490. }
  10491. }, {
  10492. key: "toggleBPVisibilityById",
  10493. value: function toggleBPVisibilityById(e, t) {
  10494. var r = this.getBreathPoint(e);
  10495. r != null && r.toggleVisibility(t);
  10496. }
  10497. }, {
  10498. key: "getBreathPointBySkinInfo",
  10499. value: function getBreathPointBySkinInfo(e) {
  10500. var t = [];
  10501. var _iterator4 = _createForOfIteratorHelper$4(this.breathPoints.entries()),
  10502. _step4;
  10503. try {
  10504. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  10505. var _step4$value = _slicedToArray(_step4.value, 2),
  10506. r = _step4$value[0],
  10507. n = _step4$value[1];
  10508. n.skinInfo == e && t.push(n);
  10509. }
  10510. } catch (err) {
  10511. _iterator4.e(err);
  10512. } finally {
  10513. _iterator4.f();
  10514. }
  10515. return t;
  10516. }
  10517. }, {
  10518. key: "getAllBreathPoint",
  10519. value: function getAllBreathPoint() {
  10520. return this.breathPoints;
  10521. }
  10522. }, {
  10523. key: "getBreathPoint",
  10524. value: function getBreathPoint(e) {
  10525. return this.breathPoints.get(e);
  10526. }
  10527. }, {
  10528. key: "delete",
  10529. value: function _delete(e) {
  10530. var t = this.breathPoints.get(e);
  10531. if (t != null) {
  10532. t.dispose(), this._allIds.delete(e);
  10533. var r = this.materialMap.get(t._type);
  10534. 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);
  10535. }
  10536. }
  10537. }, {
  10538. key: "castRay",
  10539. value: function castRay(e) {
  10540. var s;
  10541. e = ue4Position2Xverse({
  10542. x: e.x,
  10543. y: e.y,
  10544. z: e.z
  10545. });
  10546. var t = new BABYLON.Vector3(0, -1, 0),
  10547. r = new BABYLON.Ray(e, t, length),
  10548. n = [],
  10549. o = (s = this._sceneManager) == null ? void 0 : s.getGround({
  10550. x: e.x,
  10551. y: e.y,
  10552. z: e.z
  10553. });
  10554. var a = r.intersectsMeshes(o);
  10555. if (a.length > 0) {
  10556. var l = a[0];
  10557. if (l && l.pickedMesh) {
  10558. var u = l.distance;
  10559. t.y = 1;
  10560. var c = r.intersectsMeshes(n);
  10561. var h = 1e8;
  10562. if (c.length > 0) {
  10563. var f = c[0];
  10564. return f && f.pickedMesh && (h = -f.distance), h == 1e8 ? u : Math.abs(h) < Math.abs(u) ? h : u;
  10565. }
  10566. }
  10567. } else if (t.y = 1, a = r.intersectsMeshes(n), a.length > 0) {
  10568. var _l = a[0];
  10569. if (_l && _l.pickedMesh) return _l.distance;
  10570. }
  10571. return 0;
  10572. }
  10573. }, {
  10574. key: "changePickable",
  10575. value: function changePickable(e) {
  10576. var _iterator5 = _createForOfIteratorHelper$4(this.breathPoints.entries()),
  10577. _step5;
  10578. try {
  10579. for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
  10580. var _step5$value = _slicedToArray(_step5.value, 2),
  10581. t = _step5$value[0],
  10582. r = _step5$value[1];
  10583. r.changePickable(e);
  10584. }
  10585. } catch (err) {
  10586. _iterator5.e(err);
  10587. } finally {
  10588. _iterator5.f();
  10589. }
  10590. }
  10591. }, {
  10592. key: "clearBreathPoints",
  10593. value: function clearBreathPoints(e) {
  10594. logger$1.info("[Engine] clearBreathPoints: ".concat(e));
  10595. var _iterator6 = _createForOfIteratorHelper$4(this.breathPoints.entries()),
  10596. _step6;
  10597. try {
  10598. for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
  10599. var _step6$value = _slicedToArray(_step6.value, 2),
  10600. t = _step6$value[0],
  10601. r = _step6$value[1];
  10602. (r._type == e || r._id == e) && this.delete(r._id);
  10603. }
  10604. } catch (err) {
  10605. _iterator6.e(err);
  10606. } finally {
  10607. _iterator6.f();
  10608. }
  10609. }
  10610. }, {
  10611. key: "clearBreathPointsBySkinInfo",
  10612. value: function clearBreathPointsBySkinInfo(e) {
  10613. logger$1.info("[Engine] clearBreathPointsBySkinInfo: ".concat(e));
  10614. var _iterator7 = _createForOfIteratorHelper$4(this.breathPoints.entries()),
  10615. _step7;
  10616. try {
  10617. for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
  10618. var _step7$value = _slicedToArray(_step7.value, 2),
  10619. t = _step7$value[0],
  10620. r = _step7$value[1];
  10621. r.skinInfo == e && this.delete(r._id);
  10622. }
  10623. } catch (err) {
  10624. _iterator7.e(err);
  10625. } finally {
  10626. _iterator7.f();
  10627. }
  10628. }
  10629. }, {
  10630. key: "clearAllBreathPoints",
  10631. value: function clearAllBreathPoints() {
  10632. logger$1.info("[Engine] ClearAllBreathPoints");
  10633. var _iterator8 = _createForOfIteratorHelper$4(this.breathPoints.entries()),
  10634. _step8;
  10635. try {
  10636. for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
  10637. var _step8$value = _slicedToArray(_step8.value, 2),
  10638. e = _step8$value[0],
  10639. t = _step8$value[1];
  10640. this.delete(t._id);
  10641. }
  10642. } catch (err) {
  10643. _iterator8.e(err);
  10644. } finally {
  10645. _iterator8.f();
  10646. }
  10647. }
  10648. }, {
  10649. key: "_getMainPlayerPosition",
  10650. value: function _getMainPlayerPosition() {
  10651. var r;
  10652. var e = this._sceneManager.cameraComponent.MainCamera.position,
  10653. t = this._sceneManager.avatarComponent.getMainAvatar();
  10654. if (t != null && t != null) {
  10655. var n = (r = t == null ? void 0 : t.rootNode) == null ? void 0 : r.position;
  10656. if (n != null) return n;
  10657. }
  10658. return e;
  10659. }
  10660. }, {
  10661. key: "changeBreathPointPose",
  10662. value: function changeBreathPointPose(e, t, r) {
  10663. var n = new BABYLON.Vector3(e.position.x, e.position.y, e.position.z);
  10664. if (this.breathPoints.get(r) != null) {
  10665. logger$1.info("[Engine] changeBreathPointPose, id:".concat(r));
  10666. var o = this.breathPoints.get(r),
  10667. a = o.mesh.position;
  10668. var s = a.subtract(n);
  10669. s = BABYLON.Vector3.Normalize(s);
  10670. var l = BABYLON.Vector3.Distance(a, n),
  10671. u = new Ray(n, s, l),
  10672. c = this._scene.multiPickWithRay(u);
  10673. if (c) {
  10674. for (var h = 0; h < c.length; h++) {
  10675. if (c[h].pickedMesh != null && t.mesh.name.indexOf(c[h].pickedMesh.name) >= 0) {
  10676. var f = c[h].pickedPoint;
  10677. o.mesh.position = n.add(f.subtract(n).scale(.99)), this.breathPoints.set(r, o);
  10678. }
  10679. }
  10680. }
  10681. } else logger$1.warn("[Engine] changeBreathPointPose, id:".concat(r, " is not existing!"));
  10682. }
  10683. }]);
  10684. return XBreathPointManager;
  10685. }();
  10686. 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; } } }; }
  10687. 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); }
  10688. 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; }
  10689. var XDecalManager = /*#__PURE__*/function () {
  10690. function XDecalManager(e) {
  10691. _classCallCheck(this, XDecalManager);
  10692. E(this, "scene");
  10693. E(this, "_decal");
  10694. E(this, "_mat");
  10695. E(this, "_sharedMat");
  10696. E(this, "_scenemanager");
  10697. this._decal = new Map(), this._mat = new Map(), this._sharedMat = new Map(), this._scenemanager = e, this.scene = e.Scene;
  10698. }
  10699. _createClass(XDecalManager, [{
  10700. key: "decals",
  10701. get: function get() {
  10702. return Array.from(this._decal.values());
  10703. }
  10704. }, {
  10705. key: "getMesh",
  10706. value: function getMesh() {
  10707. return this._decal;
  10708. }
  10709. }, {
  10710. key: "addDecal",
  10711. value: function () {
  10712. var _addDecal = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  10713. var _this = this;
  10714. var t, r, _e$skinInfo, n;
  10715. return regenerator.wrap(function _callee$(_context) {
  10716. while (1) {
  10717. switch (_context.prev = _context.next) {
  10718. case 0:
  10719. t = e.id, r = e.meshPath, _e$skinInfo = e.skinInfo, n = _e$skinInfo === void 0 ? "default" : _e$skinInfo;
  10720. 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) {
  10721. return _this._scenemanager.urlTransformer(r).then(function (s) {
  10722. return new Promise(function (l, u) {
  10723. if (_this._decal.get(t)) l(!0);else {
  10724. var c = new XDecal({
  10725. id: t,
  10726. scene: _this.scene,
  10727. meshPath: s,
  10728. skinInfo: n
  10729. });
  10730. _this._decal.set(t, c), c.loadModel().then(function () {
  10731. l(!0);
  10732. }).catch(function (h) {
  10733. 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)));
  10734. });
  10735. }
  10736. });
  10737. }).then(function (s) {
  10738. s == !0 ? o(!0) : a(!1);
  10739. }).catch(function (s) {
  10740. 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)));
  10741. });
  10742. })));
  10743. case 2:
  10744. case "end":
  10745. return _context.stop();
  10746. }
  10747. }
  10748. }, _callee, this);
  10749. }));
  10750. function addDecal(_x) {
  10751. return _addDecal.apply(this, arguments);
  10752. }
  10753. return addDecal;
  10754. }()
  10755. }, {
  10756. key: "setDecalTexture",
  10757. value: function setDecalTexture(e) {
  10758. var _this2 = this;
  10759. var t = e.id,
  10760. r = e.buffer,
  10761. _e$isDynamic = e.isDynamic,
  10762. n = _e$isDynamic === void 0 ? !1 : _e$isDynamic,
  10763. _e$width = e.width,
  10764. o = _e$width === void 0 ? 1100 : _e$width,
  10765. _e$height = e.height,
  10766. a = _e$height === void 0 ? 25 : _e$height,
  10767. _e$slots = e.slots,
  10768. s = _e$slots === void 0 ? 1 : _e$slots,
  10769. _e$visibleSlots = e.visibleSlots,
  10770. l = _e$visibleSlots === void 0 ? 1 : _e$visibleSlots,
  10771. u = !0;
  10772. return logger.info("[Engine] setDecalTexture wiht id:[".concat(t, "]")), new Promise(function (c, h) {
  10773. var f = _this2._decal.get(t);
  10774. if (f != null) {
  10775. if (_this2._mat.get(t) != null) _this2.changeDecalTexture({
  10776. id: t,
  10777. buffer: r,
  10778. isUrl: u,
  10779. isDynamic: n,
  10780. width: o,
  10781. height: a,
  10782. slots: s,
  10783. visibleSlots: l
  10784. }), c(!0);else {
  10785. var d = new XDecalMaterial(t, _this2.scene);
  10786. d.setTexture(r, u, n, o, a, s, l).then(function () {
  10787. f.setMat(d.getMat()), _this2._decal.set(t, f), _this2._mat.set(t, d), c(!0);
  10788. }).catch(function (_) {
  10789. logger.error("[Engine] setDecalTexture Error! " + _), h(new XDecalTextureError("[Engine] decal set texture error! ".concat(_)));
  10790. });
  10791. }
  10792. } else logger.error("[Engine] Error! decal id: [" + t + "] is not find!"), h(new XDecalTextureError("[Engine] decal id: [".concat(t, "] is not find!")));
  10793. });
  10794. }
  10795. }, {
  10796. key: "shareDecal",
  10797. value: function () {
  10798. var _shareDecal = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e) {
  10799. var _this3 = this;
  10800. var t, r, n, _e$skinInfo2, o;
  10801. return regenerator.wrap(function _callee2$(_context2) {
  10802. while (1) {
  10803. switch (_context2.prev = _context2.next) {
  10804. case 0:
  10805. t = e.idTar, r = e.meshPath, n = e.idSrc, _e$skinInfo2 = e.skinInfo, o = _e$skinInfo2 === void 0 ? "default" : _e$skinInfo2;
  10806. 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) {
  10807. return _this3._scenemanager.urlTransformer(r).then(function (l) {
  10808. var u = new XDecal({
  10809. id: t,
  10810. scene: _this3.scene,
  10811. meshPath: l,
  10812. skinInfo: o
  10813. }),
  10814. c = _this3._mat.get(n);
  10815. c != null && (u.setMat(c.getMat()), u.sourceMatId = n, _this3._decal.set(t, u), _this3.addSharedMatCount(n)), a(!0);
  10816. }).catch(function (l) {
  10817. s(new XDecalError("[Engine] decal shareDecal error! ".concat(l)));
  10818. });
  10819. })) : (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!"))));
  10820. case 2:
  10821. case "end":
  10822. return _context2.stop();
  10823. }
  10824. }
  10825. }, _callee2, this);
  10826. }));
  10827. function shareDecal(_x2) {
  10828. return _shareDecal.apply(this, arguments);
  10829. }
  10830. return shareDecal;
  10831. }()
  10832. }, {
  10833. key: "changeDecalModel",
  10834. value: function () {
  10835. var _changeDecalModel = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  10836. var _this4 = this;
  10837. var t, r, n;
  10838. return regenerator.wrap(function _callee3$(_context3) {
  10839. while (1) {
  10840. switch (_context3.prev = _context3.next) {
  10841. case 0:
  10842. t = e.id, r = e.meshPath, n = this._decal.get(t);
  10843. return _context3.abrupt("return", new Promise(function (o, a) {
  10844. return n != null ? (logger.info("[Engine] changeDecalModel id:".concat(t)), n.changeModel(r).then(function () {
  10845. _this4._decal.set(t, n), o(!0);
  10846. })) : (logger.warn("[Engine] changeDecalModel id:".concat(t, " is not exist")), a("[Engine] changeDecalModel id:".concat(t, " is not exist")));
  10847. }));
  10848. case 2:
  10849. case "end":
  10850. return _context3.stop();
  10851. }
  10852. }
  10853. }, _callee3, this);
  10854. }));
  10855. function changeDecalModel(_x3) {
  10856. return _changeDecalModel.apply(this, arguments);
  10857. }
  10858. return changeDecalModel;
  10859. }()
  10860. }, {
  10861. key: "changeDecalTexture",
  10862. value: function changeDecalTexture(e) {
  10863. var t = e.id,
  10864. r = e.buffer,
  10865. _e$isUrl = e.isUrl,
  10866. n = _e$isUrl === void 0 ? !1 : _e$isUrl,
  10867. _e$isDynamic2 = e.isDynamic,
  10868. o = _e$isDynamic2 === void 0 ? !1 : _e$isDynamic2,
  10869. _e$width2 = e.width,
  10870. a = _e$width2 === void 0 ? 1110 : _e$width2,
  10871. _e$height2 = e.height,
  10872. s = _e$height2 === void 0 ? 25 : _e$height2,
  10873. _e$slots2 = e.slots,
  10874. l = _e$slots2 === void 0 ? 1 : _e$slots2,
  10875. _e$visibleSlots2 = e.visibleSlots,
  10876. u = _e$visibleSlots2 === void 0 ? 1 : _e$visibleSlots2,
  10877. c = this._mat.get(t);
  10878. 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"));
  10879. }
  10880. }, {
  10881. key: "deleteDecal",
  10882. value: function deleteDecal(e) {
  10883. var t, r;
  10884. if (this._decal.has(e)) {
  10885. var n = this._decal.get(e);
  10886. 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);
  10887. }
  10888. }
  10889. }, {
  10890. key: "deleteDecalBySkinInfo",
  10891. value: function deleteDecalBySkinInfo(e) {
  10892. var _iterator = _createForOfIteratorHelper$3(this._decal.entries()),
  10893. _step;
  10894. try {
  10895. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  10896. var _step$value = _slicedToArray(_step.value, 2),
  10897. t = _step$value[0],
  10898. r = _step$value[1];
  10899. r.skinInfo == e && this.deleteDecal(t);
  10900. }
  10901. } catch (err) {
  10902. _iterator.e(err);
  10903. } finally {
  10904. _iterator.f();
  10905. }
  10906. }
  10907. }, {
  10908. key: "addSharedMatCount",
  10909. value: function addSharedMatCount(e) {
  10910. var t = this._sharedMat.get(e);
  10911. t != null ? this._sharedMat.set(e, t + 1) : this._sharedMat.set(e, 1);
  10912. }
  10913. }, {
  10914. key: "minusSharedMatCount",
  10915. value: function minusSharedMatCount(e) {
  10916. var r;
  10917. var t = this._sharedMat.get(e);
  10918. 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)));
  10919. }
  10920. }, {
  10921. key: "toggle",
  10922. value: function toggle(e, t) {
  10923. var r = this._decal.get(e);
  10924. r == null || r.toggle(t);
  10925. }
  10926. }, {
  10927. key: "toggleDecalBySkinInfo",
  10928. value: function toggleDecalBySkinInfo(e, t) {
  10929. var _iterator2 = _createForOfIteratorHelper$3(this._decal.entries()),
  10930. _step2;
  10931. try {
  10932. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  10933. var _step2$value = _slicedToArray(_step2.value, 2),
  10934. r = _step2$value[0],
  10935. n = _step2$value[1];
  10936. n.skinInfo == e && n.toggle(t);
  10937. }
  10938. } catch (err) {
  10939. _iterator2.e(err);
  10940. } finally {
  10941. _iterator2.f();
  10942. }
  10943. }
  10944. }, {
  10945. key: "updateTexAsWords",
  10946. value: function updateTexAsWords(e, t) {
  10947. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  10948. var _r$clearArea = r.clearArea,
  10949. n = _r$clearArea === void 0 ? !0 : _r$clearArea,
  10950. _r$w = r.w,
  10951. o = _r$w === void 0 ? 480 : _r$w,
  10952. _r$h = r.h,
  10953. a = _r$h === void 0 ? 480 : _r$h,
  10954. _r$y = r.y,
  10955. s = _r$y === void 0 ? a / 2 : _r$y,
  10956. _r$fontsize = r.fontsize,
  10957. l = _r$fontsize === void 0 ? 70 : _r$fontsize,
  10958. _r$slots = r.slots,
  10959. u = _r$slots === void 0 ? 1 : _r$slots,
  10960. _r$visibleSlots = r.visibleSlots,
  10961. c = _r$visibleSlots === void 0 ? 1 : _r$visibleSlots,
  10962. _r$font = r.font,
  10963. h = _r$font === void 0 ? "black-body" : _r$font,
  10964. _r$color = r.color,
  10965. f = _r$color === void 0 ? "white" : _r$color,
  10966. _r$fontweight = r.fontweight,
  10967. d = _r$fontweight === void 0 ? 100 : _r$fontweight;
  10968. var _r$x = r.x,
  10969. _ = _r$x === void 0 ? o / 2 : _r$x;
  10970. var g = this._mat.get(e);
  10971. if (g) {
  10972. _ == -1 && (_ = (g.getUOffset() + c / u) % 1 * o * u);
  10973. var v = g.getMat().diffuseTexture,
  10974. y = v.getContext();
  10975. 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();
  10976. }
  10977. }
  10978. }, {
  10979. key: "updateTexAsImg",
  10980. value: function () {
  10981. var _updateTexAsImg = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e, t) {
  10982. var _this5 = this;
  10983. var r,
  10984. _r$clearArea2,
  10985. n,
  10986. _r$w2,
  10987. o,
  10988. _r$h2,
  10989. a,
  10990. _r$x2,
  10991. s,
  10992. _r$y2,
  10993. l,
  10994. _r$clearW,
  10995. u,
  10996. _r$clearH,
  10997. c,
  10998. _args4 = arguments;
  10999. return regenerator.wrap(function _callee4$(_context4) {
  11000. while (1) {
  11001. switch (_context4.prev = _context4.next) {
  11002. case 0:
  11003. r = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
  11004. _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;
  11005. 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) {
  11006. return _this5._scenemanager.urlTransformer(t).then(function (d) {
  11007. return new Promise(function (_, g) {
  11008. var m = _this5._mat.get(e);
  11009. if (m) {
  11010. var y = m.getMat().diffuseTexture;
  11011. if (typeof t == "string") {
  11012. var b = new Image();
  11013. b.crossOrigin = "anonymous", b.src = d, b.onload = function () {
  11014. var T = y.getContext();
  11015. 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);
  11016. }, b.onerror = function () {
  11017. 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!")));
  11018. };
  11019. } 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!")));
  11020. } 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!")));
  11021. }).then(function (_) {
  11022. _ == !0 ? h(!0) : (logger.error("[Engine] updateTexAsImg Error. id: [".concat(e, "] !")), f(new XDecalError("[Engine] updateTexAsImg error! id: [".concat(e, "]"))));
  11023. }).catch(function (_) {
  11024. logger.error("[Engine] updateTexAsImg Error. id: [".concat(e, "]. ").concat(_));
  11025. });
  11026. });
  11027. }));
  11028. case 3:
  11029. case "end":
  11030. return _context4.stop();
  11031. }
  11032. }
  11033. }, _callee4);
  11034. }));
  11035. function updateTexAsImg(_x4, _x5) {
  11036. return _updateTexAsImg.apply(this, arguments);
  11037. }
  11038. return updateTexAsImg;
  11039. }()
  11040. }, {
  11041. key: "startAnime",
  11042. value: function startAnime(e, t) {
  11043. logger.info("[Engine] Decal Start Anime. [".concat(e, "]"));
  11044. var _t$speed = t.speed,
  11045. r = _t$speed === void 0 ? .001 : _t$speed,
  11046. n = t.callback,
  11047. o = this._mat.get(e);
  11048. 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!")));
  11049. }
  11050. }]);
  11051. return XDecalManager;
  11052. }();
  11053. var PoolObject = /*#__PURE__*/function () {
  11054. function PoolObject(e, t, r) {
  11055. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !0;
  11056. _classCallCheck(this, PoolObject);
  11057. E(this, "data");
  11058. E(this, "nextFree");
  11059. E(this, "previousFree");
  11060. E(this, "free");
  11061. this.data = e, this.nextFree = t, this.previousFree = r, this.free = n;
  11062. }
  11063. _createClass(PoolObject, [{
  11064. key: "dispose",
  11065. value: function dispose() {
  11066. this.data && this.data instanceof BABYLON.Mesh && this.data.dispose(!0, !0), this.previousFree = null, this.nextFree = null, this.data = null;
  11067. }
  11068. }]);
  11069. return PoolObject;
  11070. }();
  11071. var Pool = /*#__PURE__*/function () {
  11072. function Pool(e, t, r, n) {
  11073. _classCallCheck(this, Pool);
  11074. this.lastFree = null;
  11075. this.nextFree = null;
  11076. this._pool = [], this.objCreator = e, this.objReseter = t;
  11077. for (var _len = arguments.length, o = new Array(_len > 4 ? _len - 4 : 0), _key = 4; _key < _len; _key++) {
  11078. o[_key - 4] = arguments[_key];
  11079. }
  11080. for (var a = 0; a < n; a++) {
  11081. this.addNewObject(this.newPoolObject.apply(this, o));
  11082. }
  11083. this.capacity = r;
  11084. }
  11085. _createClass(Pool, [{
  11086. key: "addNewObject",
  11087. value: function addNewObject(e) {
  11088. return this._pool.push(e), this.release(e), e;
  11089. }
  11090. }, {
  11091. key: "release",
  11092. value: function release(e) {
  11093. 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);
  11094. }
  11095. }, {
  11096. key: "getFree",
  11097. value: function getFree() {
  11098. var t = this.nextFree ? this.nextFree : this.addNewObject(this.newPoolObject.apply(this, arguments));
  11099. return t.free = !1, this.nextFree = t.nextFree, this.nextFree || (this.lastFree = null), t;
  11100. }
  11101. }, {
  11102. key: "newPoolObject",
  11103. value: function newPoolObject() {
  11104. var t = this.objCreator.apply(this, arguments);
  11105. return new PoolObject(t, this.nextFree, this.lastFree);
  11106. }
  11107. }, {
  11108. key: "releaseAll",
  11109. value: function releaseAll() {
  11110. var _this = this;
  11111. this._pool.forEach(function (e) {
  11112. return _this.release(e);
  11113. });
  11114. }
  11115. }, {
  11116. key: "clean",
  11117. value: function clean() {
  11118. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  11119. var r = this.nextFree;
  11120. if (!r) return;
  11121. var n = 0;
  11122. for (; r;) {
  11123. n += 1, r = r.nextFree;
  11124. }
  11125. var o = !1;
  11126. if (n > e && this._pool.length > this.capacity && (o = !0), o) for (r = this.nextFree; r;) {
  11127. r.free = !1, this.nextFree = r.nextFree;
  11128. var a = this._pool.indexOf(r);
  11129. this._pool.splice(a, 1), this.nextFree || (this.lastFree = null), r == null || r.dispose(), r = this.nextFree;
  11130. }
  11131. }
  11132. }]);
  11133. return Pool;
  11134. }();
  11135. var BillboardStatus = {
  11136. SHOW: 1,
  11137. HIDE: 0,
  11138. DISPOSE: -1
  11139. };
  11140. 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); }; }
  11141. 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; } }
  11142. var AvatarAnimationError$1 = /*#__PURE__*/function (_XverseError) {
  11143. _inherits(AvatarAnimationError, _XverseError);
  11144. var _super = _createSuper$3(AvatarAnimationError);
  11145. function AvatarAnimationError(e) {
  11146. _classCallCheck(this, AvatarAnimationError);
  11147. return _super.call(this, 5101, e || "[Engine] \u89D2\u8272\u52A8\u753B\u64AD\u653E\u5931\u8D25");
  11148. }
  11149. return _createClass(AvatarAnimationError);
  11150. }(XverseError);
  11151. 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; } } }; }
  11152. 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); }
  11153. 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; }
  11154. var XAnimationController = /*#__PURE__*/function () {
  11155. function XAnimationController(e) {
  11156. var _this = this;
  11157. _classCallCheck(this, XAnimationController);
  11158. E(this, "iBodyAnim");
  11159. E(this, "animations", []);
  11160. E(this, "defaultAnimation", "Idle");
  11161. E(this, "onPlay", "Idle");
  11162. E(this, "loop", !0);
  11163. E(this, "animationExtras", []);
  11164. E(this, "enableBlend", !1);
  11165. E(this, "enableSkLod", !1);
  11166. E(this, "_boneMap", new Map());
  11167. E(this, "_lodMask", new Map());
  11168. E(this, "activeFaceAnimation");
  11169. E(this, "iFaceAnim");
  11170. E(this, "_scene");
  11171. E(this, "_avatar");
  11172. E(this, "onPlayObservable", new Observable());
  11173. E(this, "postObserver");
  11174. E(this, "playAnimation", function (e, t) {
  11175. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  11176. var n = arguments.length > 3 ? arguments[3] : undefined;
  11177. var o = arguments.length > 4 ? arguments[4] : undefined;
  11178. var a = arguments.length > 5 ? arguments[5] : undefined;
  11179. return new Promise(function (s, l) {
  11180. if (_this._isPlaying(e, r) || (_this._registerAnimInfo(e, t, r, n, o, a), !_this._isAnimate())) return s(null);
  11181. _this._prerocess(e, t), _this._avatar.avatarManager.loadAnimation(_this._avatar.avatarType, e).then(function (u) {
  11182. if (!u) return l(new AvatarAnimationError$1("animation group does not exist"));
  11183. var c = _this._mappingSkeleton(u);
  11184. if (!c) return l(new AvatarAnimationError$1("mapping animation failed"));
  11185. if (c && _this._isAnimationValid(c)) return c.dispose(), l(new AvatarAnimationError$1("mapping animation failed"));
  11186. 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"));
  11187. _this._playEffect(), _this.postObserver = c.onAnimationEndObservable.addOnce(function () {
  11188. return _this._postprocess(r), s(null);
  11189. });
  11190. });
  11191. });
  11192. });
  11193. E(this, "stopAnimation", function () {
  11194. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  11195. var t, r, n, o;
  11196. switch (e) {
  11197. case 0:
  11198. _this.iBodyAnim && _this.iBodyAnim.animGroup && ((t = _this.iBodyAnim) == null || t.animGroup.stop());
  11199. break;
  11200. case 1:
  11201. _this.iFaceAnim && _this.iFaceAnim.animGroup && ((r = _this.iFaceAnim) == null || r.animGroup.stop());
  11202. break;
  11203. case 2:
  11204. _this.iBodyAnim && _this.iBodyAnim.animGroup && ((n = _this.iBodyAnim) == null || n.animGroup.stop()), _this.iFaceAnim && _this.iFaceAnim.animGroup && ((o = _this.iFaceAnim) == null || o.animGroup.stop());
  11205. break;
  11206. }
  11207. });
  11208. E(this, "pauseAnimation", function () {
  11209. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  11210. var t, r, n, o;
  11211. switch (e) {
  11212. case 0:
  11213. _this.iBodyAnim && _this.iBodyAnim.animGroup && ((t = _this.iBodyAnim) == null || t.animGroup.pause());
  11214. break;
  11215. case 1:
  11216. _this.iFaceAnim && _this.iFaceAnim.animGroup && ((r = _this.iFaceAnim) == null || r.animGroup.pause());
  11217. break;
  11218. case 2:
  11219. _this.iBodyAnim && _this.iBodyAnim.animGroup && ((n = _this.iBodyAnim) == null || n.animGroup.pause()), _this.iFaceAnim && _this.iFaceAnim.animGroup && ((o = _this.iFaceAnim) == null || o.animGroup.pause());
  11220. break;
  11221. }
  11222. });
  11223. E(this, "resetAnimation", function () {
  11224. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  11225. var t, r, n, o;
  11226. switch (e) {
  11227. case 0:
  11228. _this.iBodyAnim && _this.iBodyAnim.animGroup && ((t = _this.iBodyAnim) == null || t.animGroup.reset());
  11229. break;
  11230. case 1:
  11231. _this.iFaceAnim && _this.iFaceAnim.animGroup && ((r = _this.iFaceAnim) == null || r.animGroup.reset());
  11232. break;
  11233. case 2:
  11234. _this.iBodyAnim && _this.iBodyAnim.animGroup && ((n = _this.iBodyAnim) == null || n.animGroup.reset()), _this.iFaceAnim && _this.iFaceAnim.animGroup && ((o = _this.iFaceAnim) == null || o.animGroup.reset());
  11235. break;
  11236. }
  11237. });
  11238. this._avatar = e, this._scene = e.avatarManager.scene, this.animationExtras.push(action.Cheering.animName), this._boneMap = new Map();
  11239. }
  11240. _createClass(XAnimationController, [{
  11241. key: "_isPlaying",
  11242. value: function _isPlaying(e, t) {
  11243. 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);
  11244. }
  11245. }, {
  11246. key: "activeAnimation",
  11247. value: function activeAnimation() {
  11248. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  11249. var t, r;
  11250. switch (e) {
  11251. case 0:
  11252. return (t = this.iBodyAnim) == null ? void 0 : t.animGroup;
  11253. case 1:
  11254. return (r = this.iFaceAnim) == null ? void 0 : r.animGroup;
  11255. default:
  11256. return;
  11257. }
  11258. }
  11259. }, {
  11260. key: "enableAnimationBlend",
  11261. value: function enableAnimationBlend() {
  11262. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : .1;
  11263. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  11264. var r, n, o, a;
  11265. if (t == 0 && ((r = this.iBodyAnim) == null ? void 0 : r.animGroup)) {
  11266. var _iterator = _createForOfIteratorHelper$2((n = this.iBodyAnim) == null ? void 0 : n.animGroup.targetedAnimations),
  11267. _step;
  11268. try {
  11269. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  11270. var s = _step.value;
  11271. s.animation.enableBlending = !0, s.animation.blendingSpeed = e;
  11272. }
  11273. } catch (err) {
  11274. _iterator.e(err);
  11275. } finally {
  11276. _iterator.f();
  11277. }
  11278. } else if (t == 0 && ((o = this.iFaceAnim) == null ? void 0 : o.animGroup)) {
  11279. var _iterator2 = _createForOfIteratorHelper$2((a = this.iFaceAnim) == null ? void 0 : a.animGroup.targetedAnimations),
  11280. _step2;
  11281. try {
  11282. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  11283. var _s = _step2.value;
  11284. _s.animation.enableBlending = !0, _s.animation.blendingSpeed = e;
  11285. }
  11286. } catch (err) {
  11287. _iterator2.e(err);
  11288. } finally {
  11289. _iterator2.f();
  11290. }
  11291. }
  11292. }
  11293. }, {
  11294. key: "disableAnimationBlend",
  11295. value: function disableAnimationBlend() {
  11296. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  11297. var t, r, n, o;
  11298. if (e == 0 && ((t = this.iBodyAnim) == null ? void 0 : t.animGroup)) {
  11299. var _iterator3 = _createForOfIteratorHelper$2((r = this.iBodyAnim) == null ? void 0 : r.animGroup.targetedAnimations),
  11300. _step3;
  11301. try {
  11302. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  11303. var a = _step3.value;
  11304. a.animation.enableBlending = !1;
  11305. }
  11306. } catch (err) {
  11307. _iterator3.e(err);
  11308. } finally {
  11309. _iterator3.f();
  11310. }
  11311. } else if (e == 0 && ((n = this.iFaceAnim) == null ? void 0 : n.animGroup)) {
  11312. var _iterator4 = _createForOfIteratorHelper$2((o = this.iFaceAnim) == null ? void 0 : o.animGroup.targetedAnimations),
  11313. _step4;
  11314. try {
  11315. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  11316. var _a = _step4.value;
  11317. _a.animation.enableBlending = !1;
  11318. }
  11319. } catch (err) {
  11320. _iterator4.e(err);
  11321. } finally {
  11322. _iterator4.f();
  11323. }
  11324. }
  11325. }
  11326. }, {
  11327. key: "skeletonMask",
  11328. value: function skeletonMask(e) {
  11329. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  11330. if (t == 0) {
  11331. var r = this._lodMask.get(this._avatar.distLevel);
  11332. if (r) for (var n = 0; n < e.targetedAnimations.length; ++n) {
  11333. r.includes(e.targetedAnimations[n].target.name) || (e.targetedAnimations.splice(n, 1), n--);
  11334. }
  11335. return !0;
  11336. }
  11337. return !1;
  11338. }
  11339. }, {
  11340. key: "detachAnimation",
  11341. value: function detachAnimation() {
  11342. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2;
  11343. var t, r;
  11344. switch (e) {
  11345. case 0:
  11346. 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);
  11347. break;
  11348. case 1:
  11349. 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);
  11350. break;
  11351. case 2:
  11352. 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);
  11353. break;
  11354. }
  11355. }
  11356. }, {
  11357. key: "blendAnimation",
  11358. value: function blendAnimation() {}
  11359. }, {
  11360. key: "getAnimation",
  11361. value: function getAnimation(e, t) {
  11362. return avatarLoader.animations.get(getAnimationKey(t, e));
  11363. }
  11364. }, {
  11365. key: "_mappingSkeleton",
  11366. value: function _mappingSkeleton(e) {
  11367. var _this2 = this;
  11368. if (e) {
  11369. var t = e.clone(e.name, function (r) {
  11370. var o, a, s;
  11371. var n = r.name.split(" ").length > 2 ? r.name.split(" ")[2] : r.name;
  11372. if (_this2._boneMap.size === ((o = _this2._avatar.skeleton) == null ? void 0 : o.bones.length)) return _this2._boneMap.get(n);
  11373. {
  11374. var l = (s = (a = _this2._avatar.skeleton) == null ? void 0 : a.bones.find(function (u) {
  11375. return u.name === r.name || u.name === r.name.split(" ")[2];
  11376. })) == null ? void 0 : s.getTransformNode();
  11377. return l && (l.name = n, _this2._boneMap.set(n, l)), l;
  11378. }
  11379. });
  11380. return t._parentContainer = e._parentContainer, t;
  11381. } else return;
  11382. }
  11383. }, {
  11384. key: "removeAnimation",
  11385. value: function removeAnimation(e) {
  11386. var t = avatarLoader.containers.get(e.name);
  11387. t && (t.dispose(), avatarLoader.containers.delete(e.name), avatarLoader.animations.delete(getAnimationKey(e.name, e.skType)));
  11388. }
  11389. }, {
  11390. key: "_setPosition",
  11391. value: function _setPosition(e, t) {
  11392. this._avatar.priority === 0 && this._avatar.isRender && e === this.defaultAnimation && e != this.onPlay && !this._avatar.isSelected && this._avatar.setPosition(this._avatar.position, !0);
  11393. }
  11394. }, {
  11395. key: "_registerAnimInfo",
  11396. value: function _registerAnimInfo(e, t) {
  11397. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  11398. var n = arguments.length > 3 ? arguments[3] : undefined;
  11399. var o = arguments.length > 4 ? arguments[4] : undefined;
  11400. var a = arguments.length > 5 ? arguments[5] : undefined;
  11401. var s = {
  11402. name: e,
  11403. skType: this._avatar.avatarType,
  11404. loop: t,
  11405. playSpeed: n,
  11406. currentFrame: 0,
  11407. startFrame: o,
  11408. endFrame: a
  11409. };
  11410. 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;
  11411. }
  11412. }, {
  11413. key: "_isAnimate",
  11414. value: function _isAnimate() {
  11415. var e;
  11416. return !(!this._avatar.isRender || !this._avatar.skeleton || ((e = this._avatar.rootNode) == null ? void 0 : e.getChildMeshes().length) == 0);
  11417. }
  11418. }, {
  11419. key: "_prerocess",
  11420. value: function _prerocess(e, t) {
  11421. 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));
  11422. }
  11423. }, {
  11424. key: "_playEffect",
  11425. value: function _playEffect() {
  11426. var _this3 = this;
  11427. this.animationExtras.indexOf(this.iBodyAnim.name) != -1 && action.Cheering.attachPair.forEach(function (t) {
  11428. _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);
  11429. });
  11430. }
  11431. }, {
  11432. key: "_playAnimation",
  11433. value: function _playAnimation() {
  11434. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  11435. var t, r;
  11436. 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;
  11437. }
  11438. }, {
  11439. key: "_postprocess",
  11440. value: function _postprocess(e) {
  11441. var r, n;
  11442. var t;
  11443. 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();
  11444. }
  11445. }, {
  11446. key: "_isAnimationValid",
  11447. value: function _isAnimationValid(e) {
  11448. for (var t = 0; t < e.targetedAnimations.length; ++t) {
  11449. if (e.targetedAnimations[t].target) return !1;
  11450. }
  11451. return !0;
  11452. }
  11453. }]);
  11454. return XAnimationController;
  11455. }();
  11456. var XAvatarComopnent = /*#__PURE__*/function () {
  11457. function XAvatarComopnent() {
  11458. _classCallCheck(this, XAvatarComopnent);
  11459. E(this, "resourceIdList", []);
  11460. E(this, "skeleton");
  11461. E(this, "extraProp");
  11462. E(this, "extras", []);
  11463. E(this, "body");
  11464. }
  11465. _createClass(XAvatarComopnent, [{
  11466. key: "addBodyComp",
  11467. value: function addBodyComp(e, t) {
  11468. 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);
  11469. }
  11470. }, {
  11471. key: "addClothesComp",
  11472. value: function addClothesComp(e, t) {
  11473. var _this = this;
  11474. 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) {
  11475. r.skeleton = _this.skeleton;
  11476. }), !0);
  11477. }
  11478. }, {
  11479. key: "clearClothesComp",
  11480. value: function clearClothesComp(e) {
  11481. e.root.getChildMeshes().forEach(function (t) {
  11482. t.skeleton = null, t.dispose(), t.xid = void 0;
  11483. }), e.root.dispose(), this.resourceIdList = this.resourceIdList.filter(function (t) {
  11484. return t.uId != e.uId;
  11485. });
  11486. }
  11487. }, {
  11488. key: "clearAllClothesComps",
  11489. value: function clearAllClothesComps() {
  11490. this.resourceIdList.forEach(function (e) {
  11491. var t;
  11492. 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) {
  11493. r.skeleton = null, r.dispose();
  11494. }), (t = e.root.skeleton) == null || t.dispose(), e.root.dispose();
  11495. }), this.resourceIdList = [];
  11496. }
  11497. }, {
  11498. key: "dispose",
  11499. value: function dispose(e) {
  11500. 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");
  11501. }
  11502. }, {
  11503. key: "changeClothesComp",
  11504. value: function changeClothesComp(e, t, r, n, o) {
  11505. var _this2 = this;
  11506. return new Promise(function (a) {
  11507. if (r === "pendant" || _this2.resourceIdList.some(function (s) {
  11508. return s.name === t;
  11509. })) return a();
  11510. if (e.isHide || !e.isRender) o.concat(r).forEach(function (l) {
  11511. e.clothesList = e.clothesList.filter(function (c) {
  11512. return c.type != l;
  11513. });
  11514. var u = {
  11515. type: r,
  11516. id: t,
  11517. url: n,
  11518. lod: 0
  11519. };
  11520. e.clothesList.push(u);
  11521. }), a();else {
  11522. var s = o.concat(r);
  11523. e.avatarManager.loadDecoration(r, t, 0).then(function (l) {
  11524. if (l) {
  11525. e.attachDecoration(l);
  11526. var u = {
  11527. type: r,
  11528. id: t,
  11529. url: n
  11530. };
  11531. e.clothesList.push(u), l.root.setEnabled(!0), s.forEach(function (c) {
  11532. var h = _this2.resourceIdList.filter(function (f) {
  11533. return f.type === c;
  11534. });
  11535. if (h.length > 1) {
  11536. (function () {
  11537. var f = h.filter(function (d) {
  11538. return d.name === t;
  11539. });
  11540. if (f.length > 1) {
  11541. var _loop = function _loop(d) {
  11542. e.detachDecoration(f[d]), e.clothesList = e.clothesList.filter(function (g) {
  11543. return g.id != f[d].name;
  11544. });
  11545. var _ = {
  11546. type: r,
  11547. id: t,
  11548. url: n
  11549. };
  11550. e.clothesList.push(_);
  11551. };
  11552. for (var d = 1; d < f.length; ++d) {
  11553. _loop(d);
  11554. }
  11555. }
  11556. })();
  11557. }
  11558. h[0] && h[0].name != t && _this2._readyToDetach(e, r) && (e.detachDecoration(h[0]), e.clothesList = e.clothesList.filter(function (f) {
  11559. return f.id != h[0].name;
  11560. }));
  11561. });
  11562. }
  11563. return a();
  11564. });
  11565. }
  11566. });
  11567. }
  11568. }, {
  11569. key: "_readyToDetach",
  11570. value: function _readyToDetach(e, t) {
  11571. return !((t == "clothes" || t == "pants") && e.clothesList.filter(function (n) {
  11572. return n.type === "suit";
  11573. }).length == 1 && (!e.clothesList.some(function (n) {
  11574. return n.type === "pants";
  11575. }) || !e.clothesList.some(function (n) {
  11576. return n.type === "clothes";
  11577. })));
  11578. }
  11579. }, {
  11580. key: "addDecoComp",
  11581. value: function addDecoComp(e, t, r, n, o) {
  11582. if (e.isRender) {
  11583. var a = e.avatarManager.extraComps.get(t),
  11584. s = a == null ? void 0 : a.clone(t, void 0);
  11585. if (!a) {
  11586. logger$1.error("\u6CA1\u6709\u5BF9\u5E94\u7684\u7EC4\u4EF6");
  11587. return;
  11588. }
  11589. this.extras.push(s);
  11590. var l = this.skeleton.bones.find(function (u) {
  11591. return u.name === r;
  11592. });
  11593. s.position = n, s.rotation = o, s.attachToBone(l, e.rootNode.getChildMeshes()[0]);
  11594. }
  11595. }
  11596. }, {
  11597. key: "showExtra",
  11598. value: function showExtra(e) {
  11599. this.extras.forEach(function (t) {
  11600. t.name.indexOf(e) > 0 && t.setEnabled(!0);
  11601. });
  11602. }
  11603. }, {
  11604. key: "hideExtra",
  11605. value: function hideExtra(e) {
  11606. this.extras.forEach(function (t) {
  11607. t.name.indexOf(e) > 0 && t.setEnabled(!1);
  11608. });
  11609. }
  11610. }, {
  11611. key: "disposeExtra",
  11612. value: function disposeExtra() {
  11613. this.extras.forEach(function (e) {
  11614. e.dispose();
  11615. }), this.extras = [];
  11616. }
  11617. }]);
  11618. return XAvatarComopnent;
  11619. }();
  11620. var XStateMachine = /*#__PURE__*/function () {
  11621. function XStateMachine(e) {
  11622. _classCallCheck(this, XStateMachine);
  11623. E(this, "state");
  11624. E(this, "isMoving");
  11625. E(this, "isRotating");
  11626. E(this, "_observer");
  11627. E(this, "_movingObserver");
  11628. E(this, "_scene");
  11629. this._scene = e;
  11630. }
  11631. _createClass(XStateMachine, [{
  11632. key: "rotateTo",
  11633. value: function rotateTo(e, t, r, n) {
  11634. var _this = this;
  11635. return new Promise(function (o, a) {
  11636. var h;
  11637. var s = e.avatarManager.scene;
  11638. if (r && e.setRotation(r), t == r) return o();
  11639. e.priority === 0 && logger$1.info("avatar ".concat(e.id, " starts to rotate from ").concat(r, " to ").concat(t));
  11640. var l = 0;
  11641. var u = 1e3 / 25,
  11642. c = calcDistance3DAngle(t, e.rotation) / u;
  11643. _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 () {
  11644. var f;
  11645. if (l < 1) {
  11646. if (!e.rootNode) return e.setRotation(t), o();
  11647. var d = BABYLON.Vector3.Lerp(e.rootNode.rotation, ue4Rotation2Xverse(t), l);
  11648. e.setRotation(xverseRotation2Ue4(d)), l += u / (c * 1e3);
  11649. } else return s.onBeforeRenderObservable.remove(_this._movingObserver), (f = e.controller) == null || f.playAnimation("Idle", !0), o();
  11650. });
  11651. });
  11652. }
  11653. }, {
  11654. key: "_filterPathPoint",
  11655. value: function _filterPathPoint(e) {
  11656. var t = 0;
  11657. var r = 1e-4;
  11658. if (e.length <= 1) return [];
  11659. for (; t < e.length - 1;) {
  11660. calcDistance3D(e[t], e[t + 1]) < r ? e.splice(t, 1) : t++;
  11661. }
  11662. return e;
  11663. }
  11664. }, {
  11665. key: "moveTo",
  11666. value: function moveTo(e, t, r, n, o, a) {
  11667. var _this2 = this;
  11668. return new Promise(function (s, l) {
  11669. var m;
  11670. var u = e.avatarManager.scene;
  11671. e.priority === 0 && logger$1.info("avatar ".concat(e.id, " starts to move from ").concat(t, " to ").concat(r));
  11672. var c = 0;
  11673. a ? a = a.concat(r) : a = [r], a = _this2._filterPathPoint(a);
  11674. var h = t,
  11675. f = a.shift();
  11676. if (!f) return l("[Engine input path error]");
  11677. var d = calcDistance3D(h, f) / n;
  11678. var _ = 1e3 / 25;
  11679. e.rootNode.lookAt(ue4Position2Xverse(f));
  11680. var g = xverseRotation2Ue4({
  11681. x: e.rootNode.rotation.x,
  11682. y: e.rootNode.rotation.y,
  11683. z: e.rootNode.rotation.z
  11684. });
  11685. 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 () {
  11686. var v;
  11687. if (c < 1) {
  11688. var y = BABYLON.Vector3.Lerp(ue4Position2Xverse(h), ue4Position2Xverse(f), c);
  11689. if (e.setPosition(xversePosition2Ue4(y)), !e.rootNode) return e.setPosition(r), s();
  11690. c += _ / (d * 1e3);
  11691. } else if (h = f, f = a.shift(), f) {
  11692. d = calcDistance3D(h, f) / n, e.rootNode.lookAt(ue4Position2Xverse(f));
  11693. var _y = xverseRotation2Ue4({
  11694. x: e.rootNode.rotation.x,
  11695. y: e.rootNode.rotation.y,
  11696. z: e.rootNode.rotation.z
  11697. });
  11698. _y && (_y.roll = 0, _y.pitch = 0, e.setRotation(_y)), c = 0;
  11699. } else return u.onBeforeRenderObservable.remove(_this2._movingObserver), (v = e.controller) == null || v.playAnimation("Idle", !0), s();
  11700. });
  11701. });
  11702. }
  11703. }, {
  11704. key: "lookAt",
  11705. value: function lookAt(e, t, r) {
  11706. return new Promise(function (n) {
  11707. var _, g;
  11708. var o = ue4Position2Xverse(t),
  11709. s = e.rootNode.position.subtract(o).length(),
  11710. l = new BABYLON.Vector3(s * Math.sin(e.rootNode.rotation.y), 0, s * Math.cos(e.rootNode.rotation.y)),
  11711. u = (_ = e.rootNode) == null ? void 0 : _.position.add(l);
  11712. var c = 0;
  11713. var h = r || 1 / 100,
  11714. f = (g = e.rootNode) == null ? void 0 : g.getScene(),
  11715. d = f == null ? void 0 : f.onBeforeRenderObservable.add(function () {
  11716. var y, b;
  11717. var m = (y = e.controller) == null ? void 0 : y.animations.find(function (T) {
  11718. return T.name == "Idle";
  11719. });
  11720. (m == null ? void 0 : m.isPlaying) != !0 && (m == null || m.play());
  11721. var v = BABYLON.Vector3.Lerp(u, o, c);
  11722. c < 1 ? ((b = e.rootNode) == null || b.lookAt(v), c += h) : (d && f.onBeforeRenderObservable.remove(d), n());
  11723. });
  11724. });
  11725. }
  11726. }, {
  11727. key: "sendObjectTo",
  11728. value: function sendObjectTo(e, t, r) {
  11729. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 2;
  11730. var o = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 10;
  11731. var a = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
  11732. x: 0,
  11733. y: 0,
  11734. z: 150
  11735. };
  11736. return new Promise(function (s, l) {
  11737. var u;
  11738. if (!r.loaded) l("Gift has not inited!");else {
  11739. var c = (u = e.rootNode) == null ? void 0 : u.getScene();
  11740. var h = 0;
  11741. var f = 1 / (n * 25),
  11742. d = f,
  11743. _ = o / 100,
  11744. g = 8 * _ * f * f;
  11745. var m = .5 * g / f,
  11746. v = ue4Position2Xverse(e.position);
  11747. var y = ue4Position2Xverse(a),
  11748. b = ue4Position2Xverse(e.position),
  11749. T = c == null ? void 0 : c.onBeforeRenderObservable.add(function () {
  11750. (!t || !e.position || !t.position) && (T && c.onBeforeRenderObservable.remove(T), l("Invalid receiver when shoot gift!")), r.loaded || (T && c.onBeforeRenderObservable.remove(T), s());
  11751. var C = ue4Position2Xverse(t.position),
  11752. A = new BABYLON.Vector3((C.x - b.x) * f, m, (C.z - b.z) * f);
  11753. m = m - g, h < 1 ? (v = v.add(A), r.setPositionVector(v.add(y)), h += d) : (s(), T && c.onBeforeRenderObservable.remove(T));
  11754. });
  11755. }
  11756. });
  11757. }
  11758. }, {
  11759. key: "roll",
  11760. value: function roll(e, t, r, n) {
  11761. var o, a;
  11762. 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 () {
  11763. e.rootNode.rotation.y += r * .1 * n, e.rootNode.rotation.y %= Math.PI * 2;
  11764. }));
  11765. }
  11766. }, {
  11767. key: "disposeObsever",
  11768. value: function disposeObsever() {
  11769. this._movingObserver && this._scene.onBeforeRenderObservable.remove(this._movingObserver);
  11770. }
  11771. }]);
  11772. return XStateMachine;
  11773. }();
  11774. var XAvatarBillboardComponent = /*#__PURE__*/function () {
  11775. function XAvatarBillboardComponent(e) {
  11776. var _this = this;
  11777. _classCallCheck(this, XAvatarBillboardComponent);
  11778. E(this, "_nickName", "");
  11779. E(this, "_words", "");
  11780. E(this, "_isNameVisible", !0);
  11781. E(this, "_isBubbleVisible", !0);
  11782. E(this, "_isGiftButtonsVisible", !1);
  11783. E(this, "withinVisualRange", !1);
  11784. E(this, "_bubble");
  11785. E(this, "_nameBoard");
  11786. E(this, "_giftButtons", new Map());
  11787. E(this, "_buttonTex", new Map());
  11788. E(this, "_nameLinesLimit", 2);
  11789. E(this, "_nameLengthPerLine", 16);
  11790. E(this, "_scene");
  11791. E(this, "_pickBbox", null);
  11792. E(this, "bbox");
  11793. E(this, "_height", .26);
  11794. E(this, "_attachmentObservers", new Map());
  11795. E(this, "attachToAvatar", function (e, t) {
  11796. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
  11797. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
  11798. x: 0,
  11799. y: 0,
  11800. z: 0
  11801. };
  11802. var o = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : !1;
  11803. var a = arguments.length > 5 ? arguments[5] : undefined;
  11804. var s = arguments.length > 6 ? arguments[6] : undefined;
  11805. var l = e.rootNode;
  11806. if (_this.bbox || e.getBbox(), t && l) {
  11807. var u = a || t.uniqueId;
  11808. var c = _this._attachmentObservers.get(u);
  11809. if (c) if (o) _this._scene.onBeforeRenderObservable.remove(c), _this._attachmentObservers.delete(u);else return;
  11810. var h = ue4Position2Xverse(n);
  11811. r ? (t.setParent(l), t.position = h) : (c = _this._scene.onBeforeRenderObservable.add(function () {
  11812. var f = 0;
  11813. 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);
  11814. var d = new BABYLON.Vector3(0, _this._height, 0);
  11815. 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;
  11816. }), _this._attachmentObservers.set(u, c));
  11817. } else logger$1.error("avatar or attachment not found!");
  11818. });
  11819. E(this, "detachFromAvatar", function (e, t) {
  11820. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
  11821. var n = _this._attachmentObservers.get(t.uniqueId);
  11822. n && _this._scene.onBeforeRenderObservable.remove(n), e.rootNode ? (t.setEnabled(!1), t.parent = null, r && t.dispose()) : logger$1.error("avatar not found!");
  11823. });
  11824. E(this, "getBbox", function (e) {
  11825. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  11826. var _t$isConst = t.isConst,
  11827. r = _t$isConst === void 0 ? !1 : _t$isConst,
  11828. _t$changeWithAvatar = t.changeWithAvatar,
  11829. n = _t$changeWithAvatar === void 0 ? !1 : _t$changeWithAvatar;
  11830. var _t$localCenter = t.localCenter,
  11831. o = _t$localCenter === void 0 ? {
  11832. x: 0,
  11833. y: 0,
  11834. z: 75
  11835. } : _t$localCenter,
  11836. _t$width = t.width,
  11837. a = _t$width === void 0 ? 1.32 : _t$width,
  11838. _t$height = t.height,
  11839. s = _t$height === void 0 ? 1.5 : _t$height,
  11840. _t$depth = t.depth,
  11841. l = _t$depth === void 0 ? .44 : _t$depth;
  11842. if (n) {
  11843. var u = e.scale;
  11844. o = {
  11845. x: o.x * u,
  11846. y: o.y * u,
  11847. z: o.z * u
  11848. }, a *= u, s *= u, l *= u;
  11849. }
  11850. if (e.rootNode) {
  11851. var _u = new BABYLON.Vector3(0, 0, 0),
  11852. c = new BABYLON.Vector3(0, 0, 0);
  11853. if (r) {
  11854. var f = ue4Position2Xverse(o);
  11855. _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)));
  11856. } 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) {
  11857. e.rootNode.getChildMeshes().forEach(function (_) {
  11858. var g = _.getBoundingInfo().boundingBox.minimum,
  11859. m = _.getBoundingInfo().boundingBox.maximum;
  11860. _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);
  11861. });
  11862. var _f = c.x - _u.x,
  11863. d = c.z - _u.z;
  11864. _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;
  11865. } else {
  11866. var _f2 = e.avatarManager.getMainAvatar();
  11867. _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);
  11868. }
  11869. var h = e.rootNode.computeWorldMatrix(!0);
  11870. if (_this.bbox ? _this.bbox.reConstruct(_u, c, h) : _this.bbox = new BABYLON.BoundingBox(_u, c, h), _this._pickBbox == null) {
  11871. var _f3 = _this.createPickBoundingbox(e, _this.bbox);
  11872. _this.attachToAvatar(e, _f3.data, !1, {
  11873. x: 0,
  11874. y: 0,
  11875. z: 0
  11876. }, !1, "pickbox"), _this._pickBbox = _f3;
  11877. }
  11878. } else logger$1.error("avatar not found!");
  11879. });
  11880. this._scene = e;
  11881. }
  11882. _createClass(XAvatarBillboardComponent, [{
  11883. key: "isNameVisible",
  11884. get: function get() {
  11885. return this._isNameVisible;
  11886. }
  11887. }, {
  11888. key: "isBubbleVisible",
  11889. get: function get() {
  11890. return this._isBubbleVisible;
  11891. }
  11892. }, {
  11893. key: "isGiftButtonsVisible",
  11894. get: function get() {
  11895. return this._isGiftButtonsVisible;
  11896. }
  11897. }, {
  11898. key: "words",
  11899. get: function get() {
  11900. return this._words;
  11901. }
  11902. }, {
  11903. key: "nickName",
  11904. get: function get() {
  11905. return this._nickName;
  11906. }
  11907. }, {
  11908. key: "giftButtons",
  11909. get: function get() {
  11910. return this._giftButtons;
  11911. }
  11912. }, {
  11913. key: "bubble",
  11914. get: function get() {
  11915. return this._bubble;
  11916. }
  11917. }, {
  11918. key: "nameBoard",
  11919. get: function get() {
  11920. return this._nameBoard;
  11921. }
  11922. }, {
  11923. key: "setNicknameStatus",
  11924. value: function setNicknameStatus(e) {
  11925. if (this.nameBoard && this.nameBoard.setStatus(e), e == BillboardStatus.DISPOSE) {
  11926. var t = this._attachmentObservers.get("nickname");
  11927. t && (this._scene.onBeforeRenderObservable.remove(t), this._attachmentObservers.delete("nickname"));
  11928. }
  11929. }
  11930. }, {
  11931. key: "setBubbleStatus",
  11932. value: function setBubbleStatus(e) {
  11933. if (this.bubble && this.bubble.setStatus(e), e == BillboardStatus.DISPOSE) {
  11934. var t = this._attachmentObservers.get("bubble");
  11935. t && (this._scene.onBeforeRenderObservable.remove(t), this._attachmentObservers.delete("bubble"));
  11936. }
  11937. }
  11938. }, {
  11939. key: "setButtonsStatus",
  11940. value: function setButtonsStatus(e) {
  11941. var _this2 = this;
  11942. this.giftButtons && this.giftButtons.size != 0 && this.giftButtons.forEach(function (t) {
  11943. if (t.setStatus(e), e == BillboardStatus.DISPOSE && t.getMesh()) {
  11944. var r = "button_" + t.getMesh().xid,
  11945. n = _this2._attachmentObservers.get(r);
  11946. n && (_this2._scene.onBeforeRenderObservable.remove(n), _this2._attachmentObservers.delete(r));
  11947. }
  11948. });
  11949. }
  11950. }, {
  11951. key: "setGiftButtonsVisible",
  11952. value: function setGiftButtonsVisible(e) {
  11953. this.setButtonsStatus(e ? BillboardStatus.SHOW : BillboardStatus.DISPOSE);
  11954. }
  11955. }, {
  11956. key: "dispose",
  11957. value: function dispose(e) {
  11958. var _this3 = this;
  11959. this._attachmentObservers.forEach(function (t) {
  11960. _this3._scene.onBeforeRenderObservable.remove(t);
  11961. }), this._attachmentObservers.clear(), this.updateBillboardStatus(e, BillboardStatus.DISPOSE), this._buttonTex.clear(), this._pickBbox && (e.avatarManager.bboxMeshPool.release(this._pickBbox), this._pickBbox = null);
  11962. }
  11963. }, {
  11964. key: "updateBillboardStatus",
  11965. value: function updateBillboardStatus(e, t) {
  11966. 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));
  11967. }
  11968. }, {
  11969. key: "disposeBillBoard",
  11970. value: function disposeBillBoard(e) {
  11971. var _this4 = this;
  11972. this._attachmentObservers.forEach(function (t) {
  11973. _this4._scene.onBeforeRenderObservable.remove(t);
  11974. }), this._attachmentObservers.clear(), this.updateBillboardStatus(e, BillboardStatus.DISPOSE), this._buttonTex.clear(), this._pickBbox && (e.avatarManager.bboxMeshPool.release(this._pickBbox), this._pickBbox = null);
  11975. }
  11976. }, {
  11977. key: "setPickBoxScale",
  11978. value: function setPickBoxScale(e) {
  11979. this._pickBbox && this._pickBbox.data && (this._pickBbox.data.scaling = new BABYLON.Vector3(e, e, e));
  11980. }
  11981. }, {
  11982. key: "setIsPickable",
  11983. value: function setIsPickable(e, t) {
  11984. e.rootNode && e.rootNode.getChildMeshes().forEach(function (r) {
  11985. r.isPickable = t;
  11986. }), this._pickBbox && this._pickBbox.data && (this._pickBbox.data.isPickable = t);
  11987. }
  11988. }, {
  11989. key: "initNameboard",
  11990. value: function initNameboard(e) {
  11991. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  11992. this._nameBoard == null && (this._nameBoard = e.avatarManager.sceneManager.billboardComponent.addBillboard("name-" + e.id, !1, !0)), this._nameBoard.init("nickname", t / 300, t / 300);
  11993. }
  11994. }, {
  11995. key: "initBubble",
  11996. value: function initBubble(e) {
  11997. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  11998. 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);
  11999. }
  12000. }, {
  12001. key: "say",
  12002. value: function say(e) {
  12003. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this._words;
  12004. var _ref = arguments.length > 2 ? arguments[2] : undefined,
  12005. r = _ref.id,
  12006. n = _ref.isUser,
  12007. o = _ref.background,
  12008. _ref$font = _ref.font,
  12009. a = _ref$font === void 0 ? "Arial" : _ref$font,
  12010. _ref$fontsize = _ref.fontsize,
  12011. s = _ref$fontsize === void 0 ? 38 : _ref$fontsize,
  12012. _ref$fontcolor = _ref.fontcolor,
  12013. l = _ref$fontcolor === void 0 ? "#ffffff" : _ref$fontcolor,
  12014. _ref$fontstyle = _ref.fontstyle,
  12015. u = _ref$fontstyle === void 0 ? "bold" : _ref$fontstyle,
  12016. _ref$linesize = _ref.linesize,
  12017. c = _ref$linesize === void 0 ? 22 : _ref$linesize,
  12018. h = _ref.linelimit,
  12019. _ref$offsets = _ref.offsets,
  12020. f = _ref$offsets === void 0 ? {
  12021. x: 0,
  12022. y: 0,
  12023. z: 40
  12024. } : _ref$offsets,
  12025. d = _ref.scale,
  12026. _ref$compensationZ = _ref.compensationZ,
  12027. _ = _ref$compensationZ === void 0 ? 11.2 : _ref$compensationZ,
  12028. _ref$reregistAnyway = _ref.reregistAnyway,
  12029. g = _ref$reregistAnyway === void 0 ? !0 : _ref$reregistAnyway;
  12030. (!this.bubble || this.bubble.getMesh() == null) && e.initBubble(), this._words = t;
  12031. var m;
  12032. n != null && (m = n ? XBillboardManager.userBubbleUrls : XBillboardManager.npcBubbleUrls), this._bubble && (this._bubble.DEFAULT_CONFIGS = {
  12033. id: r,
  12034. isUser: n,
  12035. background: o || m,
  12036. font: a,
  12037. fontsize: s,
  12038. fontcolor: l,
  12039. fontstyle: u,
  12040. linesize: c,
  12041. linelimit: h,
  12042. offsets: f,
  12043. scale: d,
  12044. compensationZ: _,
  12045. reregistAnyway: g
  12046. }, this._bubble.getMesh() && (this._bubble.drawBillboard({
  12047. imageList: o || m
  12048. }, {
  12049. texts: this._words,
  12050. font: a,
  12051. fontsize: s,
  12052. fontcolor: l,
  12053. fontstyle: u,
  12054. linesize: c
  12055. }, {
  12056. offsets: f,
  12057. scale: d,
  12058. compensationZ: _
  12059. }), this.attachToAvatar(e, this._bubble.getMesh(), !1, this._bubble.offsets, g, "bubble"), r && this._bubble.setId(r))), this.setButtonsStatus(BillboardStatus.DISPOSE);
  12060. }
  12061. }, {
  12062. key: "silent",
  12063. value: function silent() {
  12064. this.setBubbleStatus(BillboardStatus.DISPOSE), this._words = "";
  12065. }
  12066. }, {
  12067. key: "setNickName",
  12068. value: function setNickName(e, t, _ref2) {
  12069. var r = _ref2.id,
  12070. n = _ref2.isUser,
  12071. o = _ref2.background,
  12072. _ref2$font = _ref2.font,
  12073. a = _ref2$font === void 0 ? "Arial" : _ref2$font,
  12074. _ref2$fontsize = _ref2.fontsize,
  12075. s = _ref2$fontsize === void 0 ? 40 : _ref2$fontsize,
  12076. _ref2$fontcolor = _ref2.fontcolor,
  12077. l = _ref2$fontcolor === void 0 ? "#ffffff" : _ref2$fontcolor,
  12078. _ref2$fontstyle = _ref2.fontstyle,
  12079. u = _ref2$fontstyle === void 0 ? "bold" : _ref2$fontstyle,
  12080. _ref2$linesize = _ref2.linesize,
  12081. c = _ref2$linesize === void 0 ? 22 : _ref2$linesize,
  12082. h = _ref2.linelimit,
  12083. _ref2$offsets = _ref2.offsets,
  12084. f = _ref2$offsets === void 0 ? {
  12085. x: 0,
  12086. y: 0,
  12087. z: 15
  12088. } : _ref2$offsets,
  12089. d = _ref2.scale,
  12090. _ref2$compensationZ = _ref2.compensationZ,
  12091. _ = _ref2$compensationZ === void 0 ? 0 : _ref2$compensationZ,
  12092. _ref2$reregistAnyway = _ref2.reregistAnyway,
  12093. g = _ref2$reregistAnyway === void 0 ? !1 : _ref2$reregistAnyway;
  12094. this._nickName = t, (!this.nameBoard || this.nameBoard.getMesh() == null) && this.initNameboard(e), this._nameBoard && this._nameBoard.getMesh() && (this._nameBoard.DEFAULT_CONFIGS = {
  12095. id: r,
  12096. isUser: n,
  12097. background: o,
  12098. font: a,
  12099. fontsize: s,
  12100. fontcolor: l,
  12101. fontstyle: u,
  12102. linesize: c,
  12103. linelimit: h,
  12104. offsets: f,
  12105. scale: d,
  12106. compensationZ: _,
  12107. reregistAnyway: g
  12108. }, this._nameBoard.drawBillboard({}, {
  12109. texts: this._nickName,
  12110. font: a,
  12111. fontsize: s,
  12112. fontcolor: l,
  12113. fontstyle: u,
  12114. linesize: c,
  12115. linelimit: h
  12116. }, {
  12117. offsets: f,
  12118. scale: d,
  12119. compensationZ: 0
  12120. }), this.attachToAvatar(e, this._nameBoard.getMesh(), !1, this._nameBoard.offsets, g, "nickname"), r && this._nameBoard.setId(r));
  12121. }
  12122. }, {
  12123. key: "generateButtons",
  12124. value: function generateButtons(e) {
  12125. var _this5 = this;
  12126. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  12127. var r = arguments.length > 2 ? arguments[2] : undefined;
  12128. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 85;
  12129. if (t && (this._buttonTex = t, this.clearButtons()), this._buttonTex.size == 0) return;
  12130. var o = (this._buttonTex.size - 1) / 2;
  12131. this._buttonTex.forEach(function (a, s) {
  12132. var l = _this5._giftButtons.get(s);
  12133. l || (l = e.avatarManager.sceneManager.billboardComponent.addBillboard("button-" + s + e.id, !0, !1), l.init(s, r / 240, r / 240));
  12134. var u = {
  12135. x: r * o * 70,
  12136. y: 0,
  12137. z: r * (n - 20 * (o * o))
  12138. };
  12139. l.drawBillboard({
  12140. imageList: [a]
  12141. }, {}, {
  12142. offsets: u,
  12143. scale: r
  12144. }), _this5.attachToAvatar(e, l.getMesh(), !1, l.offsets, !0, "button_" + s), _this5._giftButtons.set(s, l), o -= 1;
  12145. }), this.setBubbleStatus(BillboardStatus.DISPOSE);
  12146. }
  12147. }, {
  12148. key: "clearButtons",
  12149. value: function clearButtons() {
  12150. this._giftButtons.forEach(function (e) {
  12151. e.dispose();
  12152. }), this._giftButtons.clear();
  12153. }
  12154. }, {
  12155. key: "createPickBoundingbox",
  12156. value: function createPickBoundingbox(e, t) {
  12157. var r = t.extendSize.x * 2,
  12158. n = t.extendSize.y * 2,
  12159. o = t.extendSize.z * 2,
  12160. a = this._scene,
  12161. s = Math.max(r, o),
  12162. l = e.avatarManager.bboxMeshPool.getFree(a, s, n, s),
  12163. u = l.data;
  12164. return u && (u.position = t.centerWorld, u.setEnabled(!1), u.isPickable = !0, u.xtype = EMeshType.XAvatar, u.xid = e.id), l;
  12165. }
  12166. }]);
  12167. return XAvatarBillboardComponent;
  12168. }();
  12169. var castRayOffsetY = .01;
  12170. var castRayTeleportationOffset = 10;
  12171. var XAvatar = /*#__PURE__*/function () {
  12172. function XAvatar(_ref) {
  12173. var _this = this;
  12174. var e = _ref.id,
  12175. t = _ref.avatarType,
  12176. r = _ref.priority,
  12177. n = _ref.avatarManager,
  12178. o = _ref.assets,
  12179. a = _ref.status;
  12180. _classCallCheck(this, XAvatar);
  12181. E(this, "id", "-1");
  12182. E(this, "priority", 0);
  12183. E(this, "isRender", !1);
  12184. E(this, "distLevel", 0);
  12185. E(this, "isInLoadingList", !1);
  12186. E(this, "isHide", !1);
  12187. E(this, "component");
  12188. E(this, "controller");
  12189. E(this, "stateMachine");
  12190. E(this, "bbComponent");
  12191. E(this, "_avatarType");
  12192. E(this, "clothesList", []);
  12193. E(this, "isSelected", !1);
  12194. E(this, "pendingLod", !1);
  12195. E(this, "_previousReceivedPosition", new BABYLON.Vector3(0, 1e4, 0));
  12196. E(this, "_avatarPosition");
  12197. E(this, "_avatarRotation");
  12198. E(this, "_avatarScale");
  12199. E(this, "rootNode");
  12200. E(this, "distToCam", 1e11);
  12201. E(this, "enableNickname", !0);
  12202. E(this, "distance", 1e11);
  12203. E(this, "isCulling", !1);
  12204. E(this, "reslevel", 0);
  12205. E(this, "isInLoadingQueue", !1);
  12206. E(this, "_isRayCastEnable");
  12207. E(this, "_scene");
  12208. E(this, "_avatarManager");
  12209. E(this, "_transparent", 0);
  12210. E(this, "hide", function () {
  12211. return _this.isHide = !0, _this._hide(), !_this.isRender;
  12212. });
  12213. E(this, "_show", function () {
  12214. var e;
  12215. _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)));
  12216. });
  12217. E(this, "show", function () {
  12218. return _this.isHide = !1, _this._show(), !!_this.isRender;
  12219. });
  12220. E(this, "setAnimations", function (e) {
  12221. _this.controller.animations = e;
  12222. });
  12223. E(this, "attachToAvatar", function (e) {
  12224. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
  12225. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
  12226. x: 0,
  12227. y: 0,
  12228. z: 0
  12229. };
  12230. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !1;
  12231. var o = arguments.length > 4 ? arguments[4] : undefined;
  12232. var a = arguments.length > 5 ? arguments[5] : undefined;
  12233. return _this.bbComponent.attachToAvatar(_this, e, t, r, n, o, a);
  12234. });
  12235. E(this, "detachFromAvatar", function (e) {
  12236. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
  12237. return _this.bbComponent.detachFromAvatar(_this, e, t);
  12238. });
  12239. E(this, "getBbox", function () {
  12240. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  12241. return _this.bbComponent.getBbox(_this, e);
  12242. });
  12243. 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 ? {
  12244. pitch: 0,
  12245. yaw: 0,
  12246. roll: 0
  12247. } : a.avatarRotation, this._avatarPosition = a.avatarPosition == null ? {
  12248. x: 0,
  12249. y: 0,
  12250. z: 0
  12251. } : a.avatarPosition, this.setPosition(this._avatarPosition), this.setRotation(this._avatarRotation), this.setScale(this.scale), this._isRayCastEnable = avatarSetting.isRayCastEnable, this._scene.registerBeforeRender(function () {
  12252. _this.tick();
  12253. });
  12254. }
  12255. _createClass(XAvatar, [{
  12256. key: "tick",
  12257. value: function tick() {
  12258. this.cullingTick();
  12259. }
  12260. }, {
  12261. key: "cullingTick",
  12262. value: function cullingTick() {
  12263. var _this2 = this;
  12264. var e;
  12265. this.isCulling && ((e = this.rootNode) == null || e.getChildMeshes().forEach(function (t) {
  12266. _this2.distToCam < 50 ? t.visibility = 0 : t.visibility = _this2._transparent;
  12267. }));
  12268. }
  12269. }, {
  12270. key: "setTransParentThresh",
  12271. value: function setTransParentThresh(e) {
  12272. this._transparent = e;
  12273. }
  12274. }, {
  12275. key: "isNameVisible",
  12276. get: function get() {
  12277. return this.bbComponent.isNameVisible;
  12278. }
  12279. }, {
  12280. key: "isBubbleVisible",
  12281. get: function get() {
  12282. return this.bbComponent.isBubbleVisible;
  12283. }
  12284. }, {
  12285. key: "isGiftButtonsVisible",
  12286. get: function get() {
  12287. return this.bbComponent.isGiftButtonsVisible;
  12288. }
  12289. }, {
  12290. key: "words",
  12291. get: function get() {
  12292. return this.bbComponent.words;
  12293. }
  12294. }, {
  12295. key: "nickName",
  12296. get: function get() {
  12297. return this.bbComponent.nickName;
  12298. }
  12299. }, {
  12300. key: "giftButtons",
  12301. get: function get() {
  12302. return this.bbComponent.giftButtons;
  12303. }
  12304. }, {
  12305. key: "bubble",
  12306. get: function get() {
  12307. return this.bbComponent.bubble;
  12308. }
  12309. }, {
  12310. key: "nameBoard",
  12311. get: function get() {
  12312. return this.bbComponent.nameBoard;
  12313. }
  12314. }, {
  12315. key: "avatarManager",
  12316. get: function get() {
  12317. return this._avatarManager;
  12318. }
  12319. }, {
  12320. key: "withinVisibleRange",
  12321. set: function set(e) {
  12322. this.bbComponent.withinVisualRange = e;
  12323. }
  12324. }, {
  12325. key: "setNicknameStatus",
  12326. value: function setNicknameStatus(e) {
  12327. return this.bbComponent.setNicknameStatus(e);
  12328. }
  12329. }, {
  12330. key: "setBubbleStatus",
  12331. value: function setBubbleStatus(e) {
  12332. return this.bbComponent.setBubbleStatus(e);
  12333. }
  12334. }, {
  12335. key: "setButtonsStatus",
  12336. value: function setButtonsStatus(e) {
  12337. return this.bbComponent.setBubbleStatus(e);
  12338. }
  12339. }, {
  12340. key: "setGiftButtonsVisible",
  12341. value: function setGiftButtonsVisible(e) {
  12342. return this.bbComponent.setGiftButtonsVisible(e);
  12343. }
  12344. }, {
  12345. key: "avatarType",
  12346. get: function get() {
  12347. return this._avatarType;
  12348. }
  12349. }, {
  12350. key: "attachBody",
  12351. value: function attachBody(e) {
  12352. return this.component.addBodyComp(this, e);
  12353. }
  12354. }, {
  12355. key: "attachDecoration",
  12356. value: function attachDecoration(e) {
  12357. return this.component.addClothesComp(this, e);
  12358. }
  12359. }, {
  12360. key: "detachDecoration",
  12361. value: function detachDecoration(e) {
  12362. return this.component.clearClothesComp(e);
  12363. }
  12364. }, {
  12365. key: "detachDecorationAll",
  12366. value: function detachDecorationAll() {
  12367. return this.component.clearAllClothesComps();
  12368. }
  12369. }, {
  12370. key: "skeleton",
  12371. get: function get() {
  12372. return this.component.skeleton;
  12373. }
  12374. }, {
  12375. key: "position",
  12376. get: function get() {
  12377. return this._avatarPosition;
  12378. }
  12379. }, {
  12380. key: "rotation",
  12381. get: function get() {
  12382. return this._avatarRotation;
  12383. }
  12384. }, {
  12385. key: "scale",
  12386. get: function get() {
  12387. return this._avatarScale;
  12388. }
  12389. }, {
  12390. key: "_hide_culling",
  12391. value: function _hide_culling() {
  12392. this.bbComponent.updateBillboardStatus(this, BillboardStatus.HIDE), this.isCulling = !0;
  12393. }
  12394. }, {
  12395. key: "_show_culling",
  12396. value: function _show_culling() {
  12397. this.isCulling && (this.rootNode && this.rootNode.getChildMeshes().forEach(function (e) {
  12398. e.visibility = 1;
  12399. }), this.bbComponent.updateBillboardStatus(this, BillboardStatus.SHOW), this.isCulling = !1);
  12400. }
  12401. }, {
  12402. key: "_hide",
  12403. value: function _hide() {
  12404. !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()));
  12405. }
  12406. }, {
  12407. key: "rotate",
  12408. value: function rotate(e, t, r) {
  12409. return this.stateMachine.roll(this, e, t, r);
  12410. }
  12411. }, {
  12412. key: "isRayCastEnable",
  12413. get: function get() {
  12414. return this._isRayCastEnable;
  12415. },
  12416. set: function set(e) {
  12417. this._isRayCastEnable = e;
  12418. }
  12419. }, {
  12420. key: "getAvatarId",
  12421. value: function getAvatarId() {
  12422. return this.id;
  12423. }
  12424. }, {
  12425. key: "getAvaliableAnimations",
  12426. value: function getAvaliableAnimations() {
  12427. var e = avatarLoader.avaliableAnimation.get(this.avatarType);
  12428. return e || [];
  12429. }
  12430. }, {
  12431. key: "setPosition",
  12432. value: function setPosition(e) {
  12433. var _this3 = this;
  12434. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
  12435. if (this._avatarPosition = e, this.rootNode) {
  12436. var r = ue4Position2Xverse(this._avatarPosition);
  12437. var n = !1;
  12438. 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) {
  12439. _this3.rootNode.position = r, _this3.rootNode.position.y -= o;
  12440. }).catch(function (o) {
  12441. Promise.reject(o);
  12442. }) : (this.rootNode.position.x = r.x, this.rootNode.position.z = r.z) : this.rootNode.position = r, this._previousReceivedPosition = r.clone();
  12443. }
  12444. return Promise.resolve(e);
  12445. }
  12446. }, {
  12447. key: "setRotation",
  12448. value: function setRotation(e) {
  12449. if (this._avatarRotation = e, this.rootNode) {
  12450. var t = {
  12451. pitch: e.pitch,
  12452. yaw: e.yaw + 180,
  12453. roll: e.roll
  12454. },
  12455. r = ue4Rotation2Xverse(t);
  12456. this.rootNode.rotation = r;
  12457. }
  12458. }
  12459. }, {
  12460. key: "setAvatarVisible",
  12461. value: function setAvatarVisible(e) {
  12462. this.rootNode && (this.rootNode.setEnabled(e), this.rootNode.getChildMeshes().forEach(function (t) {
  12463. t.setEnabled(e);
  12464. }));
  12465. }
  12466. }, {
  12467. key: "setScale",
  12468. value: function setScale(e) {
  12469. this._avatarScale = e, this.rootNode && (this.rootNode.scaling = new BABYLON.Vector3(e, e, e)), this.bbComponent.bbox && this.getBbox();
  12470. }
  12471. }, {
  12472. key: "_removeAvatarFromScene",
  12473. value: function _removeAvatarFromScene() {
  12474. var e, t;
  12475. this.isRender = !1, (e = this.controller) == null || e.detachAnimation(), this.component.dispose(this), (t = this.avatarManager.sceneManager) == null || t.lightComponent.removeShadow(this);
  12476. }
  12477. }, {
  12478. key: "removeAvatarFromScene",
  12479. value: function removeAvatarFromScene() {
  12480. this._removeAvatarFromScene(), this._disposeBillBoard();
  12481. }
  12482. }, {
  12483. key: "_disposeBillBoard",
  12484. value: function _disposeBillBoard() {
  12485. this.bbComponent.disposeBillBoard(this);
  12486. }
  12487. }, {
  12488. key: "addComponent",
  12489. value: function addComponent(e, t, r, n) {
  12490. return this.component.changeClothesComp(this, e, t, r, n);
  12491. }
  12492. }, {
  12493. key: "_castRay",
  12494. value: function _castRay(e) {
  12495. var _this4 = this;
  12496. return new Promise(function (t, r) {
  12497. var d;
  12498. var n = ue4Position2Xverse(e),
  12499. o = new BABYLON.Vector3(0, -1, 0),
  12500. a = 1.5 * _this4.scale,
  12501. s = 100 * a,
  12502. l = a,
  12503. u = new BABYLON.Vector3(n.x, n.y + l, +n.z),
  12504. c = new BABYLON.Ray(u, o, s),
  12505. h = (d = _this4.avatarManager.sceneManager) == null ? void 0 : d.getGround(e);
  12506. 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);
  12507. var f = c.intersectsMeshes(h);
  12508. if (f.length > 0) return t(f[0].distance - l);
  12509. if (o.y = 1, f = c.intersectsMeshes(h), f.length > 0) return t(-(f[0].distance - l));
  12510. });
  12511. }
  12512. }, {
  12513. key: "setPickBoxScale",
  12514. value: function setPickBoxScale(e) {
  12515. return this.bbComponent.setPickBoxScale(e);
  12516. }
  12517. }, {
  12518. key: "setIsPickable",
  12519. value: function setIsPickable(e) {
  12520. return this.bbComponent.setIsPickable(this, e);
  12521. }
  12522. }, {
  12523. key: "createPickBoundingbox",
  12524. value: function createPickBoundingbox(e) {
  12525. return this.bbComponent.createPickBoundingbox(this, e);
  12526. }
  12527. }, {
  12528. key: "scaleBbox",
  12529. value: function scaleBbox(e) {
  12530. this.bbComponent.bbox && this.bbComponent.bbox.scale(e);
  12531. }
  12532. }, {
  12533. key: "rotateTo",
  12534. value: function rotateTo(e, t, r) {
  12535. return this.stateMachine.rotateTo(this, e, t, r);
  12536. }
  12537. }, {
  12538. key: "faceTo",
  12539. value: function faceTo(e, t) {
  12540. return this.stateMachine.lookAt(this, e, t);
  12541. }
  12542. }, {
  12543. key: "removeObserver",
  12544. value: function removeObserver() {
  12545. this.stateMachine.disposeObsever();
  12546. }
  12547. }, {
  12548. key: "move",
  12549. value: function move(e, t, r, n, o) {
  12550. return this.stateMachine.moveTo(this, e, t, r, n, o);
  12551. }
  12552. }, {
  12553. key: "initNameboard",
  12554. value: function initNameboard() {
  12555. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
  12556. return this.bbComponent.initNameboard(this, e);
  12557. }
  12558. }, {
  12559. key: "initBubble",
  12560. value: function initBubble() {
  12561. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
  12562. return this.bbComponent.initBubble(this, e);
  12563. }
  12564. }, {
  12565. key: "say",
  12566. value: function say(e, _ref2) {
  12567. var t = _ref2.id,
  12568. r = _ref2.isUser,
  12569. n = _ref2.background,
  12570. _ref2$font = _ref2.font,
  12571. o = _ref2$font === void 0 ? "Arial" : _ref2$font,
  12572. _ref2$fontsize = _ref2.fontsize,
  12573. a = _ref2$fontsize === void 0 ? 38 : _ref2$fontsize,
  12574. _ref2$fontcolor = _ref2.fontcolor,
  12575. s = _ref2$fontcolor === void 0 ? "#ffffff" : _ref2$fontcolor,
  12576. _ref2$fontstyle = _ref2.fontstyle,
  12577. l = _ref2$fontstyle === void 0 ? "bold" : _ref2$fontstyle,
  12578. _ref2$linesize = _ref2.linesize,
  12579. u = _ref2$linesize === void 0 ? 22 : _ref2$linesize,
  12580. c = _ref2.linelimit,
  12581. _ref2$offsets = _ref2.offsets,
  12582. h = _ref2$offsets === void 0 ? {
  12583. x: 0,
  12584. y: 0,
  12585. z: 40
  12586. } : _ref2$offsets,
  12587. _ref2$scale = _ref2.scale,
  12588. f = _ref2$scale === void 0 ? this._avatarScale : _ref2$scale,
  12589. _ref2$compensationZ = _ref2.compensationZ,
  12590. d = _ref2$compensationZ === void 0 ? 11.2 : _ref2$compensationZ,
  12591. _ref2$reregistAnyway = _ref2.reregistAnyway,
  12592. _ = _ref2$reregistAnyway === void 0 ? !0 : _ref2$reregistAnyway;
  12593. return this.bbComponent.say(this, e, {
  12594. id: t,
  12595. isUser: r,
  12596. background: n,
  12597. font: o,
  12598. fontsize: a,
  12599. fontcolor: s,
  12600. fontstyle: l,
  12601. linesize: u,
  12602. linelimit: c,
  12603. offsets: h,
  12604. scale: f,
  12605. compensationZ: d,
  12606. reregistAnyway: _
  12607. });
  12608. }
  12609. }, {
  12610. key: "silent",
  12611. value: function silent() {
  12612. return this.bbComponent.silent();
  12613. }
  12614. }, {
  12615. key: "setNickName",
  12616. value: function setNickName(e, _ref3) {
  12617. var t = _ref3.id,
  12618. r = _ref3.isUser,
  12619. n = _ref3.background,
  12620. _ref3$font = _ref3.font,
  12621. o = _ref3$font === void 0 ? "Arial" : _ref3$font,
  12622. _ref3$fontsize = _ref3.fontsize,
  12623. a = _ref3$fontsize === void 0 ? 40 : _ref3$fontsize,
  12624. _ref3$fontcolor = _ref3.fontcolor,
  12625. s = _ref3$fontcolor === void 0 ? "#ffffff" : _ref3$fontcolor,
  12626. _ref3$fontstyle = _ref3.fontstyle,
  12627. l = _ref3$fontstyle === void 0 ? "bold" : _ref3$fontstyle,
  12628. _ref3$linesize = _ref3.linesize,
  12629. u = _ref3$linesize === void 0 ? 22 : _ref3$linesize,
  12630. c = _ref3.linelimit,
  12631. _ref3$offsets = _ref3.offsets,
  12632. h = _ref3$offsets === void 0 ? {
  12633. x: 0,
  12634. y: 0,
  12635. z: 15
  12636. } : _ref3$offsets,
  12637. _ref3$scale = _ref3.scale,
  12638. f = _ref3$scale === void 0 ? this._avatarScale : _ref3$scale,
  12639. _ref3$compensationZ = _ref3.compensationZ,
  12640. d = _ref3$compensationZ === void 0 ? 0 : _ref3$compensationZ,
  12641. _ref3$reregistAnyway = _ref3.reregistAnyway,
  12642. _ = _ref3$reregistAnyway === void 0 ? !1 : _ref3$reregistAnyway;
  12643. return this.bbComponent.setNickName(this, e, {
  12644. id: t,
  12645. isUser: r,
  12646. background: n,
  12647. font: o,
  12648. fontsize: a,
  12649. fontcolor: s,
  12650. fontstyle: l,
  12651. linesize: u,
  12652. linelimit: c,
  12653. offsets: h,
  12654. scale: f,
  12655. compensationZ: d,
  12656. reregistAnyway: _
  12657. });
  12658. }
  12659. }, {
  12660. key: "generateButtons",
  12661. value: function generateButtons() {
  12662. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  12663. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this._avatarScale;
  12664. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 85;
  12665. return this.bbComponent.generateButtons(this, e, t, r);
  12666. }
  12667. }, {
  12668. key: "clearButtons",
  12669. value: function clearButtons() {
  12670. return this.bbComponent.clearButtons();
  12671. }
  12672. }, {
  12673. key: "attachExtraProp",
  12674. value: function attachExtraProp(e, t, r, n) {
  12675. return this.component.addDecoComp(this, e, t, r, n);
  12676. }
  12677. }, {
  12678. key: "showExtra",
  12679. value: function showExtra(e) {
  12680. return this.component.showExtra(e);
  12681. }
  12682. }, {
  12683. key: "hideExtra",
  12684. value: function hideExtra(e) {
  12685. return this.component.hideExtra(e);
  12686. }
  12687. }, {
  12688. key: "disposeExtra",
  12689. value: function disposeExtra() {
  12690. return this.component.disposeExtra();
  12691. }
  12692. }, {
  12693. key: "getSkeletonPositionByName",
  12694. value: function getSkeletonPositionByName(e) {
  12695. var t;
  12696. if (this.skeleton) {
  12697. var r = this.skeleton.bones.find(function (n) {
  12698. return n.name.replace("Clone of ", "") == e;
  12699. });
  12700. if (r && r.getTransformNode() && ((t = r.getTransformNode()) == null ? void 0 : t.position)) {
  12701. var n = r.getTransformNode().position;
  12702. return xversePosition2Ue4({
  12703. x: n.x,
  12704. y: n.y,
  12705. z: n.z
  12706. });
  12707. }
  12708. }
  12709. }
  12710. }, {
  12711. key: "shootTo",
  12712. value: function shootTo(e, t) {
  12713. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2;
  12714. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 10;
  12715. var o = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
  12716. x: 0,
  12717. y: 0,
  12718. z: 150
  12719. };
  12720. return this.stateMachine.sendObjectTo(this, e, t, r, n, o);
  12721. }
  12722. }]);
  12723. return XAvatar;
  12724. }();
  12725. 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; } } }; }
  12726. 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); }
  12727. 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; }
  12728. var XAvatarManager = /*#__PURE__*/function () {
  12729. function XAvatarManager(e) {
  12730. var _this = this;
  12731. _classCallCheck(this, XAvatarManager);
  12732. this.characterMap = new Map();
  12733. this.curAnimList = [];
  12734. this.extraComps = new Map();
  12735. this._mainUser = null;
  12736. this._lodSettings = null;
  12737. this.maxBillBoardDist = 0;
  12738. this.maxAvatarNum = 0;
  12739. this.currentLODUsers = [];
  12740. this.bboxMeshPool = null;
  12741. this._distLevels = [];
  12742. this._maxLODUsers = [];
  12743. this._cullingDistance = 0;
  12744. this._maxDistRange = null;
  12745. this._delayTime = 100;
  12746. this._queueLength = -1;
  12747. this._queue = [];
  12748. this._processList = [];
  12749. this._process = null;
  12750. this._updateLoopObserver = null;
  12751. this._avatarInDistance = [];
  12752. this._renderedAvatar = [];
  12753. this._enableNickname = !0;
  12754. this._tickObserver = null;
  12755. this._tickInterval = null;
  12756. this._defaultAnims = null;
  12757. this._tickDispose = 0;
  12758. this._disposeTime = 100;
  12759. this.avatarLoader = avatarLoader;
  12760. this._scene = e.mainScene;
  12761. this._sceneManager = e;
  12762. this.initAvatarMap();
  12763. this._initSettings();
  12764. 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;
  12765. var t = 0;
  12766. this._tickObserver = this._scene.onAfterRenderObservable.add(function () {
  12767. t += 1, t == _this._tickInterval && (_this.tick(), t = 0);
  12768. });
  12769. }
  12770. _createClass(XAvatarManager, [{
  12771. key: "tick",
  12772. value: function tick() {
  12773. this.bboxMeshPool.clean(0);
  12774. }
  12775. }, {
  12776. key: "createBboxAsset",
  12777. value: function createBboxAsset(e, t, r, n) {
  12778. return BABYLON.MeshBuilder.CreateBox("avatarBbox", {
  12779. width: t,
  12780. height: r,
  12781. depth: n
  12782. }, e);
  12783. }
  12784. }, {
  12785. key: "resetBboxAsset",
  12786. value: function resetBboxAsset(e) {
  12787. var t = e.data;
  12788. return t.setEnabled(!1), t.isPickable = !1, e;
  12789. }
  12790. }, {
  12791. key: "_initSettings",
  12792. value: function _initSettings() {
  12793. this._defaultAnims = avatarSetting.defaultIdle, this._lodSettings = avatarSetting.lod, this._distLevels = avatarSetting.lod.map(function (e) {
  12794. return e.dist;
  12795. }), this._maxLODUsers = avatarSetting.lod.map(function (e) {
  12796. return e.quota;
  12797. }), this.currentLODUsers = new Array(this._distLevels.length).fill(0), this.maxAvatarNum = avatarSetting.maxAvatarNum, this.maxBillBoardDist = avatarSetting.maxBillBoardDist, this._cullingDistance = avatarSetting.cullingDistance;
  12798. }
  12799. }, {
  12800. key: "maxRenderNum",
  12801. value: function maxRenderNum() {
  12802. var e = 0;
  12803. return this._maxLODUsers.forEach(function (t) {
  12804. e += t;
  12805. }), e;
  12806. }
  12807. }, {
  12808. key: "curRenderNum",
  12809. value: function curRenderNum() {
  12810. var e = 0;
  12811. return this.currentLODUsers.forEach(function (t) {
  12812. e += t;
  12813. }), e;
  12814. }
  12815. }, {
  12816. key: "setLoDLevels",
  12817. value: function setLoDLevels(e) {
  12818. this._distLevels = e;
  12819. }
  12820. }, {
  12821. key: "cullingDistance",
  12822. get: function get() {
  12823. return this._cullingDistance;
  12824. },
  12825. set: function set(e) {
  12826. this._cullingDistance = e;
  12827. }
  12828. }, {
  12829. key: "getLoDLevels",
  12830. value: function getLoDLevels() {
  12831. return this._distLevels;
  12832. }
  12833. }, {
  12834. key: "setLodUserLimits",
  12835. value: function setLodUserLimits(e, t) {
  12836. this._maxLODUsers.length > e && (this._maxLODUsers[e] = t);
  12837. }
  12838. }, {
  12839. key: "setLodDist",
  12840. value: function setLodDist(e, t) {
  12841. this._distLevels[e] = t;
  12842. }
  12843. }, {
  12844. key: "setMaxDistRange",
  12845. value: function setMaxDistRange(e) {
  12846. this._maxDistRange = e, this._distLevels[this._distLevels.length - 1] = e;
  12847. }
  12848. }, {
  12849. key: "scene",
  12850. get: function get() {
  12851. return this._scene;
  12852. }
  12853. }, {
  12854. key: "setMainAvatar",
  12855. value: function setMainAvatar(e) {
  12856. var t;
  12857. this._mainUser = (t = this.characterMap.get(0)) == null ? void 0 : t.get(e);
  12858. }
  12859. }, {
  12860. key: "getMainAvatar",
  12861. value: function getMainAvatar() {
  12862. return this._mainUser;
  12863. }
  12864. }, {
  12865. key: "enableAllNickname",
  12866. value: function enableAllNickname(e) {
  12867. var _this2 = this;
  12868. return this.characterMap.forEach(function (t, r) {
  12869. r != 0 && t.forEach(function (n, o) {
  12870. _this2._updateBillboardStatus(n, e ? BillboardStatus.SHOW : BillboardStatus.HIDE);
  12871. });
  12872. }), this._enableNickname = e;
  12873. }
  12874. }, {
  12875. key: "getAvatarById",
  12876. value: function getAvatarById(e) {
  12877. var t;
  12878. return this.characterMap.forEach(function (r, n) {
  12879. r.get(e) && (t = r.get(e));
  12880. }), t;
  12881. }
  12882. }, {
  12883. key: "getAvatarNums",
  12884. value: function getAvatarNums() {
  12885. var e = 0;
  12886. return this.characterMap.forEach(function (t, r) {
  12887. e += t.size;
  12888. }), e;
  12889. }
  12890. }, {
  12891. key: "registerAvatar",
  12892. value: function registerAvatar(e) {
  12893. this.characterMap.get(e.priority).set(e.id, e);
  12894. }
  12895. }, {
  12896. key: "unregisterAvatar",
  12897. value: function unregisterAvatar(e) {
  12898. this.characterMap.get(e.priority).delete(e.id);
  12899. }
  12900. }, {
  12901. key: "initAvatarMap",
  12902. value: function initAvatarMap() {
  12903. 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());
  12904. }
  12905. }, {
  12906. key: "loadAvatar",
  12907. value: function loadAvatar(_ref) {
  12908. var _this3 = this;
  12909. var e = _ref.id,
  12910. t = _ref.avatarType,
  12911. r = _ref.priority,
  12912. n = _ref.avatarManager,
  12913. o = _ref.assets,
  12914. a = _ref.status;
  12915. return new Promise(function (s, l) {
  12916. if (_this3.getAvatarById(e)) return l(new DuplicateAvatarIDError("[Engine] cannot init avatar with the same id = ".concat(e)));
  12917. if (_this3.getAvatarNums() > _this3.maxAvatarNum) return l(new ExceedMaxAvatarNumError("[Engine] \u8D85\u51FA\u6700\u5927\u89D2\u8272\u9650\u5236 ".concat(_this3.maxAvatarNum)));
  12918. var u = new XAvatar({
  12919. id: e,
  12920. avatarType: t,
  12921. priority: r,
  12922. avatarManager: n,
  12923. assets: o,
  12924. status: a
  12925. });
  12926. if (_this3.registerAvatar(u), r == 0) _this3.setMainAvatar(u.id), _this3.addAvatarToScene(u, 0).then(function (c) {
  12927. return logger$1.debug("[Engine] avatar ".concat(u.id, " has been added to scene")), c ? (_this3._updateBillboardStatus(c, BillboardStatus.SHOW), setTimeout(function () {
  12928. _this3.launchProcessLoadingLoop();
  12929. }, _this3._delayTime), s(c)) : (u.removeAvatarFromScene(), l(new AvatarAssetLoadingError()));
  12930. }).catch(function (c) {
  12931. return u.removeAvatarFromScene(), l(new AvatarAssetLoadingError(c));
  12932. });else return s(u);
  12933. });
  12934. }
  12935. }, {
  12936. key: "deleteAvatar",
  12937. value: function deleteAvatar(e) {
  12938. return e.isRender ? (e.removeAvatarFromScene(), this.currentLODUsers[e.distLevel]--) : e.bbComponent.disposeBillBoard(e), this._processList = this._processList.filter(function (t) {
  12939. return t.id !== e.id;
  12940. }), this.unregisterAvatar(e), e.rootNode && (e.rootNode.dispose(), e.rootNode = void 0), e.bbComponent.bbox && e.bbComponent.bbox.dispose(), e.removeObserver(), e;
  12941. }
  12942. }, {
  12943. key: "_checkLODLevel",
  12944. value: function _checkLODLevel(e) {
  12945. if (e < this._distLevels[0]) return 0;
  12946. for (var t = 1; t < this._distLevels.length; ++t) {
  12947. if (e >= this._distLevels[t - 1] && e < this._distLevels[t]) return t;
  12948. }
  12949. return this._distLevels.length - 1;
  12950. }
  12951. }, {
  12952. key: "sceneManager",
  12953. get: function get() {
  12954. return this._sceneManager;
  12955. }
  12956. }, {
  12957. key: "launchProcessLoadingLoop",
  12958. value: function launchProcessLoadingLoop() {
  12959. this._updateAvatarStatus();
  12960. }
  12961. }, {
  12962. key: "stopProcessLoadingLoop",
  12963. value: function stopProcessLoadingLoop() {
  12964. var e;
  12965. this._updateLoopObserver && ((e = this._scene) == null || e.onBeforeRenderObservable.remove(this._updateLoopObserver));
  12966. }
  12967. }, {
  12968. key: "_distToMain",
  12969. value: function _distToMain(e) {
  12970. var n;
  12971. var t = (n = this._mainUser) == null ? void 0 : n.position,
  12972. r = e.position;
  12973. if (r && t) {
  12974. var o = this.sceneManager.cameraComponent.MainCamera.getFrontPosition(1).subtract(this.sceneManager.cameraComponent.MainCamera.position).normalize(),
  12975. a = e.rootNode.position.subtract(this.sceneManager.cameraComponent.MainCamera.position).normalize();
  12976. var s = 1;
  12977. if (o && a) {
  12978. var l = a.multiply(o);
  12979. s = Math.acos(l.x + l.y + l.z) < this.sceneManager.cameraComponent.MainCamera.fov / 2 ? 1 : 1e11;
  12980. }
  12981. return calcDistance3D(t, r) * s;
  12982. } else return logger$1.warn("user position or camera position is not correct!"), 1e11;
  12983. }
  12984. }, {
  12985. key: "_distToCamera",
  12986. value: function _distToCamera(e) {
  12987. var n;
  12988. var t = (n = this._sceneManager) == null ? void 0 : n.cameraComponent.getCameraPose().position,
  12989. r = e.position;
  12990. return r && t ? calcDistance3D(t, r) : (logger$1.warn("user position or camera position is not correct!"), 1e11);
  12991. }
  12992. }, {
  12993. key: "showAll",
  12994. value: function showAll(e) {
  12995. this.characterMap.forEach(function (t, r) {
  12996. e && r == 0 && t.forEach(function (n, o) {
  12997. n.show();
  12998. }), r != 0 && t.forEach(function (n, o) {
  12999. n.show();
  13000. });
  13001. });
  13002. }
  13003. }, {
  13004. key: "hideAll",
  13005. value: function hideAll(e) {
  13006. this.characterMap.forEach(function (t, r) {
  13007. e && r == 0 && t.forEach(function (n, o) {
  13008. n.hide();
  13009. }), r != 0 && t.forEach(function (n, o) {
  13010. n.hide();
  13011. });
  13012. });
  13013. }
  13014. }, {
  13015. key: "_assemblyAvatar",
  13016. value: function _assemblyAvatar(e, t) {
  13017. var _this4 = this;
  13018. var n, o;
  13019. var r = e.get(avatarSetting.body);
  13020. if (r && !t.attachBody(r)) {
  13021. t.isInLoadingList = !1, e.clear();
  13022. return;
  13023. }
  13024. var _iterator = _createForOfIteratorHelper$1(e),
  13025. _step;
  13026. try {
  13027. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  13028. var a = _step.value;
  13029. if (a[0] != avatarSetting.body && a[0] != avatarSetting.animations && !t.attachDecoration(a[1])) {
  13030. t.isInLoadingList = !1, t.removeAvatarFromScene(), e.clear();
  13031. return;
  13032. }
  13033. }
  13034. } catch (err) {
  13035. _iterator.e(err);
  13036. } finally {
  13037. _iterator.f();
  13038. }
  13039. t.isRender = !0, (n = t.controller) == null || n.playAnimation(t.controller.onPlay, t.controller.loop), (o = t.controller) == null || o.onPlayObservable.addOnce(function () {
  13040. var a, s;
  13041. if (!_this4.getAvatarById(t.id)) {
  13042. t.isInLoadingList = !1, t.removeAvatarFromScene(), _this4.currentLODUsers[t.distLevel]--;
  13043. return;
  13044. }
  13045. if (_this4.getAvatarById(t.id).rootNode.getChildMeshes().length < e.size) {
  13046. 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]--;
  13047. return;
  13048. }
  13049. 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));
  13050. });
  13051. }
  13052. }, {
  13053. key: "_disposeUnusedAssets",
  13054. value: function _disposeUnusedAssets() {
  13055. this._tickDispose++, this._tickDispose > this._disposeTime && (avatarLoader.disposeContainer(), this._tickDispose = 0);
  13056. }
  13057. }, {
  13058. key: "_addResourcesToList",
  13059. value: function _addResourcesToList(e, t) {
  13060. var _this5 = this;
  13061. return e.clothesList.forEach(function (r) {
  13062. r.lod = t, _this5._queue.push(r);
  13063. }), this._queue.push({
  13064. type: avatarSetting.animations,
  13065. id: this._defaultAnims
  13066. }), this._queue.push({
  13067. type: avatarSetting.body,
  13068. id: e.avatarType,
  13069. lod: t
  13070. }), !0;
  13071. }
  13072. }, {
  13073. key: "_updateBillboardStatus",
  13074. value: function _updateBillboardStatus(e, t) {
  13075. e.bbComponent.updateBillboardStatus(e, t);
  13076. }
  13077. }, {
  13078. key: "_processLayer",
  13079. value: function _processLayer(e) {
  13080. var _this6 = this;
  13081. var t = this.characterMap.get(e),
  13082. r = [];
  13083. for (t == null || t.forEach(function (n) {
  13084. n.distToCam = _this6._distToCamera(n);
  13085. var o = n.distToCam < _this6._cullingDistance;
  13086. if (n.isRender && (!n.isHide && o ? n._hide_culling() : n._show_culling()), n.priority != 0) {
  13087. n.distance = _this6._distToMain(n);
  13088. var _a = BillboardStatus.SHOW;
  13089. 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));
  13090. }
  13091. }), r.sort(function (n, o) {
  13092. return o.distance - n.distance;
  13093. }); r.length > 0 && this.curRenderNum() < this.maxRenderNum();) {
  13094. var n = r.pop();
  13095. var o = this._checkLODLevel(n.distance),
  13096. a = !1;
  13097. for (var s = 0; s < this._maxLODUsers.length; ++s) {
  13098. if (this.currentLODUsers[s] < this._maxLODUsers[s]) {
  13099. o = s, a = !0;
  13100. break;
  13101. }
  13102. }
  13103. if (!a || n.distance > this._maxDistRange) {
  13104. if (n.isRender) {
  13105. n._removeAvatarFromScene();
  13106. var _s = BillboardStatus.HIDE;
  13107. n.distance < this._maxDistRange && (_s = BillboardStatus.SHOW), this._updateBillboardStatus(n, _s);
  13108. }
  13109. break;
  13110. }
  13111. 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]++;
  13112. }
  13113. return this.curRenderNum() >= this.maxRenderNum() && r.forEach(function (n) {
  13114. if (n.isRender) {
  13115. n._removeAvatarFromScene();
  13116. var _o = BillboardStatus.HIDE;
  13117. n.distance < _this6._maxDistRange && (_o = BillboardStatus.SHOW), _this6._updateBillboardStatus(n, _o);
  13118. }
  13119. }), this.curRenderNum() < this.maxRenderNum();
  13120. }
  13121. }, {
  13122. key: "_updateAvatar",
  13123. value: function _updateAvatar() {
  13124. var _this7 = this;
  13125. this.currentLODUsers = [0, 0, 0];
  13126. var e = [5, 4, 3, 2, 1, 0];
  13127. for (; e.length > 0;) {
  13128. var t = e.pop();
  13129. if (!this._processLayer(t)) {
  13130. e.forEach(function (n) {
  13131. var o;
  13132. (o = _this7.characterMap.get(n)) == null || o.forEach(function (a) {
  13133. a.distance = _this7._distToMain(a);
  13134. var s = BillboardStatus.HIDE;
  13135. a.distToCam < _this7._maxDistRange && (s = BillboardStatus.SHOW, a.isRender && a._removeAvatarFromScene()), _this7._updateBillboardStatus(a, s);
  13136. });
  13137. });
  13138. break;
  13139. }
  13140. }
  13141. }
  13142. }, {
  13143. key: "_updateAvatarStatus",
  13144. value: function _updateAvatarStatus() {
  13145. var _this8 = this;
  13146. var e = new Map();
  13147. this._updateLoopObserver = this.scene.onBeforeRenderObservable.add(function () {
  13148. var t;
  13149. if (_this8._disposeUnusedAssets(), !(_this8.getAvatarNums() <= 0)) {
  13150. if (!_this8._process && _this8._processList.length == 0 && _this8._updateAvatar(), !_this8._process && _this8._processList.length > 0) {
  13151. var r = _this8._processList.shift();
  13152. 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;
  13153. }
  13154. if (e.size === _this8._queueLength && _this8._process) {
  13155. _this8._process.pendingLod && (_this8._process.pendingLod = !1, _this8._process._removeAvatarFromScene());
  13156. var _r = Date.now();
  13157. _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();
  13158. }
  13159. _this8._loadResByList(e);
  13160. }
  13161. });
  13162. }
  13163. }, {
  13164. key: "_loadResByList",
  13165. value: function _loadResByList(e) {
  13166. var _this9 = this;
  13167. var t = 0;
  13168. var r = 5;
  13169. if (!this._process) {
  13170. e.clear();
  13171. return;
  13172. }
  13173. var _loop = function _loop() {
  13174. var n = Date.now(),
  13175. o = _this9._queue.pop();
  13176. setTimeout(function () {
  13177. o ? o.type === avatarSetting.body ? _this9.loadBody(o.type, o.id, o.lod).then(function (a) {
  13178. a && e.set(avatarSetting.body, a), t += Date.now() - n;
  13179. }).catch(function (a) {
  13180. _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);
  13181. }) : o.type === avatarSetting.animations ? _this9.loadAnimation(_this9._process.avatarType, o.id).then(function (a) {
  13182. a && e.set(avatarSetting.animations, a), t += Date.now() - n;
  13183. }).catch(function (a) {
  13184. _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);
  13185. }) : _this9.loadDecoration(o.type, o.id, o.lod).then(function (a) {
  13186. a && e.set(a.type, a), t += Date.now() - n;
  13187. }).catch(function (a) {
  13188. _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);
  13189. }) : t += 100;
  13190. }, 0);
  13191. };
  13192. for (; t < r && this._queue.length > 0;) {
  13193. _loop();
  13194. }
  13195. }
  13196. }, {
  13197. key: "_validateContainer",
  13198. value: function _validateContainer(e) {
  13199. 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;
  13200. }
  13201. }, {
  13202. key: "_getAssetContainer",
  13203. value: function _getAssetContainer(e, t) {
  13204. var _this10 = this;
  13205. return new Promise(function (r, n) {
  13206. var o = _this10._getSourceKey(e, t || 0),
  13207. a = avatarLoader.containers.get(o);
  13208. if (a) return r(a);
  13209. avatarLoader.load(_this10.sceneManager, e, t).then(function (s) {
  13210. 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, ".")));
  13211. }).catch(function (s) {
  13212. return n(new ContainerLoadingFailedError("[Engine] ".concat(s, " :: cannot load body type ").concat(e, ".")));
  13213. });
  13214. });
  13215. }
  13216. }, {
  13217. key: "_clipContainerRes",
  13218. value: function _clipContainerRes(e) {
  13219. e.transformNodes.forEach(function (t) {
  13220. t.dispose();
  13221. }), e.transformNodes = [], e.skeletons.forEach(function (t) {
  13222. t.dispose();
  13223. }), e.skeletons = [];
  13224. }
  13225. }, {
  13226. key: "loadBody",
  13227. value: function loadBody(e, t, r) {
  13228. var _this11 = this;
  13229. return new Promise(function (n, o) {
  13230. return avatarLoader.load(_this11.sceneManager, t, r).then(function (a) {
  13231. if (a) {
  13232. var s = a.instantiateModelsToScene();
  13233. a.xReferenceCount++;
  13234. var l = {
  13235. isRender: !1,
  13236. uId: Math.random(),
  13237. root: s.rootNodes[0],
  13238. skeletonType: e,
  13239. name: t,
  13240. animations: s.animationGroups,
  13241. skeleton: s.skeletons[0],
  13242. lod: r
  13243. };
  13244. return s.rootNodes[0]._parentContainer = a, s.rootNodes[0].setEnabled(!1), n(l);
  13245. } else return o(new ContainerLoadingFailedError("[Engine] container failed instanciates failed"));
  13246. }).catch(function () {
  13247. return o(new ContainerLoadingFailedError("[Engine] body type ".concat(e, " instanciates failed")));
  13248. });
  13249. });
  13250. }
  13251. }, {
  13252. key: "updateAnimationLists",
  13253. value: function updateAnimationLists(e, t) {
  13254. return new Promise(function (r, n) {
  13255. return avatarLoader.avaliableAnimation.set(t, e), r();
  13256. });
  13257. }
  13258. }, {
  13259. key: "loadAnimation",
  13260. value: function loadAnimation(e, t) {
  13261. var _this12 = this;
  13262. return new Promise(function (r, n) {
  13263. return avatarLoader.loadAnimRes(_this12.sceneManager, t, e).then(function (o) {
  13264. if (o) {
  13265. var a;
  13266. var s = _this12.avatarLoader.animations;
  13267. return o.animationGroups.forEach(function (l) {
  13268. l.stop(), l.name === t && (a = l, a.pContainer = o), s.set(getAnimationKey(l.name, e), l);
  13269. }), _this12._clipContainerRes(o), o.xReferenceCount++, r(a);
  13270. } else return n(new ContainerLoadingFailedError("[Engine] container failed instanciates failed"));
  13271. });
  13272. });
  13273. }
  13274. }, {
  13275. key: "loadDecoration",
  13276. value: function loadDecoration(e, t, r) {
  13277. var _this13 = this;
  13278. return new Promise(function (n, o) {
  13279. return avatarLoader.load(_this13.sceneManager, t, r).then(function (a) {
  13280. if (a) {
  13281. _this13._clipContainerRes(a);
  13282. var s = a.meshes[1].clone(a.meshes[1].name, null);
  13283. if (!s) {
  13284. logger$1.warn("[Engine] decoration does not exist!"), n(null);
  13285. return;
  13286. }
  13287. var l = {
  13288. isRender: !1,
  13289. uId: Math.random(),
  13290. root: s,
  13291. type: e,
  13292. name: t,
  13293. isSelected: !1,
  13294. lod: r
  13295. };
  13296. if (a.xReferenceCount++, s._parentContainer = a, a.meshes.length > 1) for (var u = 2; u < a.meshes.length; u++) {
  13297. s.addChild(a.meshes[u].clone(a.meshes[u].name, null));
  13298. }
  13299. s.setEnabled(!1), l.isSelected = !0, n(l);
  13300. } else return o(new ContainerLoadingFailedError("[Engine] container failed, instanciates failed."));
  13301. }).catch(function () {
  13302. return o(new ContainerLoadingFailedError("[Engine] body type ".concat(e, " instanciates failed.")));
  13303. });
  13304. });
  13305. }
  13306. }, {
  13307. key: "_getSourceKey",
  13308. value: function _getSourceKey(e, t) {
  13309. return t && avatarSetting.lod[t] ? e + avatarSetting.lod[t].fileName.split(".")[0] : e;
  13310. }
  13311. }, {
  13312. key: "addAvatarToScene",
  13313. value: function addAvatarToScene(e, t) {
  13314. var _this14 = this;
  13315. var r = Date.now();
  13316. return new Promise(function (n, o) {
  13317. _this14.loadBody(e.avatarType, e.avatarType, t).then(function (a) {
  13318. var s;
  13319. if (!a) return e.isInLoadingList = !1, o(new ContainerLoadingFailedError("[Engine] avatar ".concat(e.id, " instanciates failed")));
  13320. if (e.attachBody(a), a.animations.length > 0) return a.animations.forEach(function (l) {
  13321. l.stop();
  13322. }), 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);
  13323. _this14.loadAnimation(e.avatarType, _this14._defaultAnims).then(function (l) {
  13324. if (!l) return e.removeAvatarFromScene(), e.isInLoadingList = !1, o(new AvatarAnimationError());
  13325. var u = [];
  13326. e.clothesList.length > 0 && e.clothesList.forEach(function (c) {
  13327. u.push(_this14.loadDecoration(c.type, c.id, t));
  13328. }), Promise.all(u).then(function (c) {
  13329. var d, _, g, m;
  13330. c.forEach(function (v) {
  13331. if (v && !v.isRender) e.attachDecoration(v);else return e.isInLoadingList = !1, e.removeAvatarFromScene(), o(new AvatarAssetLoadingError());
  13332. }), e.isRender = !0, (d = e.controller) == null || d.playAnimation(e.controller.onPlay, e.controller.loop), e.setAvatarVisible(!0);
  13333. var h = avatarLoader.mshPath.get("meshes/ygb.glb"),
  13334. f = avatarLoader.matPath.get(avatarResources.ygb.mesh);
  13335. h && f ? _this14.loadExtra(f, h).then(function (v) {
  13336. var y;
  13337. e.isRender = !0, e.isInLoadingList = !1, e.distLevel = t, (y = _this14._sceneManager) == null || y.engineRunTimeStats.timeArray_addAvatarToScene.add(Date.now() - r), n(e);
  13338. }) : (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);
  13339. }).catch(function () {
  13340. return o(new AvatarAssetLoadingError("[Engine] avatar ".concat(e.id, " instanciates failed.")));
  13341. });
  13342. }).catch(function () {
  13343. return o(new AvatarAssetLoadingError("[Engine] avatar ".concat(e.id, " instanciates failed.")));
  13344. });
  13345. }).catch(function () {
  13346. return o(new AvatarAssetLoadingError("[Engine] avatar ".concat(e.id, " instanciates failed.")));
  13347. });
  13348. });
  13349. }
  13350. }, {
  13351. key: "loadExtra",
  13352. value: function loadExtra(e, t) {
  13353. var _this15 = this;
  13354. var r = avatarResources.ygb.name;
  13355. return new Promise(function (n, o) {
  13356. var a;
  13357. (a = _this15.sceneManager) == null || a.urlTransformer(e).then(function (s) {
  13358. BABYLON.SceneLoader.LoadAssetContainerAsync("", s, _this15.scene, null, avatarSetting.fileType).then(function (l) {
  13359. var c;
  13360. _this15.extraComps.set(r, l.meshes[0]);
  13361. var u = new NodeMaterial("material_".concat(r), _this15._scene, {
  13362. emitComments: !1
  13363. });
  13364. (c = _this15.sceneManager) == null || c.urlTransformer(t).then(function (h) {
  13365. u.loadAsync(h).then(function () {
  13366. l.meshes[2].material.dispose(!0, !0), u.build(!1), l.meshes[2].material = u, n(l.meshes[2]);
  13367. });
  13368. });
  13369. });
  13370. });
  13371. });
  13372. }
  13373. }, {
  13374. key: "getAvatarList",
  13375. value: function getAvatarList() {
  13376. var e = [];
  13377. return this.characterMap.forEach(function (t, r) {
  13378. t.forEach(function (n, o) {
  13379. e.push(n);
  13380. });
  13381. }), e;
  13382. }
  13383. }, {
  13384. key: "_debug_avatar",
  13385. value: function _debug_avatar() {
  13386. var t, r;
  13387. 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);
  13388. var e = 0;
  13389. this.getAvatarList().forEach(function (n) {
  13390. 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++);
  13391. }), console.error("========= avatar num", e), console.error("loop:", this._updateLoopObserver ? "on" : "false", "=> process", this._process, "===> comp", this._processList), console.error("===>maxLODUsers", this._maxLODUsers);
  13392. }
  13393. }]);
  13394. return XAvatarManager;
  13395. }();
  13396. var XBillboard = /*#__PURE__*/function () {
  13397. function XBillboard(e) {
  13398. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
  13399. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
  13400. _classCallCheck(this, XBillboard);
  13401. E(this, "_mesh", null);
  13402. E(this, "_texture", null);
  13403. E(this, "_scalingFactor", 1);
  13404. E(this, "offsets", null);
  13405. E(this, "_pickable");
  13406. E(this, "_background", null);
  13407. E(this, "_billboardManager");
  13408. E(this, "poolobj", null);
  13409. E(this, "_usePool");
  13410. E(this, "_initMeshScale", new BABYLON.Vector3(1, 1, 1));
  13411. E(this, "_status", -1);
  13412. E(this, "_stageChanged", !1);
  13413. E(this, "DEFAULT_CONFIGS", {});
  13414. this._billboardManager = e, this._pickable = t, this._usePool = r;
  13415. }
  13416. _createClass(XBillboard, [{
  13417. key: "scalingFactor",
  13418. set: function set(e) {
  13419. this._scalingFactor = e;
  13420. }
  13421. }, {
  13422. key: "background",
  13423. set: function set(e) {
  13424. this._background = e;
  13425. }
  13426. }, {
  13427. key: "size",
  13428. get: function get() {
  13429. return -1;
  13430. }
  13431. }, {
  13432. key: "setStatus",
  13433. value: function setStatus(e) {
  13434. e != this._status && (this._stageChanged = !0, this._status = e);
  13435. }
  13436. }, {
  13437. key: "status",
  13438. get: function get() {
  13439. return this._status;
  13440. }
  13441. }, {
  13442. key: "stageChanged",
  13443. get: function get() {
  13444. return this._stageChanged;
  13445. },
  13446. set: function set(e) {
  13447. this._stageChanged = e;
  13448. }
  13449. }, {
  13450. key: "init",
  13451. value: function init() {
  13452. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
  13453. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : .001;
  13454. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : .001;
  13455. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !1;
  13456. var o = this._billboardManager.sceneManager.Scene;
  13457. if (this._usePool) {
  13458. var a = this._billboardManager.billboardPool.getFree(o, t, r, n);
  13459. 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;
  13460. } else this._mesh = this._billboardManager.createBillboardAsset(o, n);
  13461. 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;
  13462. }
  13463. }, {
  13464. key: "dispose",
  13465. value: function dispose() {
  13466. 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;
  13467. }
  13468. }, {
  13469. key: "getMesh",
  13470. value: function getMesh() {
  13471. return this._mesh;
  13472. }
  13473. }, {
  13474. key: "updateImage",
  13475. value: function updateImage(e) {
  13476. var _this = this;
  13477. return new Promise(function (t) {
  13478. if (_this._texture == null) {
  13479. logger$1.error("[Engine]Billboard texture not found");
  13480. return;
  13481. }
  13482. var r = _this._mesh,
  13483. n = _this._texture,
  13484. o = _this._scalingFactor,
  13485. a = _this._initMeshScale.x,
  13486. s = _this._initMeshScale.y,
  13487. l = _this._texture.getContext(),
  13488. u = _this._texture.getSize();
  13489. l.clearRect(0, 0, u.width, u.height);
  13490. var c = new Image();
  13491. c.crossOrigin = "anonymous", c.src = e, c.onload = function () {
  13492. var h = c.width * o,
  13493. f = c.height * o;
  13494. 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();
  13495. };
  13496. });
  13497. }
  13498. }, {
  13499. key: "show",
  13500. value: function show() {
  13501. this._mesh && (this._mesh.setEnabled(!0), this._mesh.isPickable = this._pickable);
  13502. }
  13503. }, {
  13504. key: "hide",
  13505. value: function hide() {
  13506. this._mesh && (this._mesh.setEnabled(!1), this._mesh.isPickable = !1);
  13507. }
  13508. }, {
  13509. key: "setId",
  13510. value: function setId(e) {
  13511. this._mesh && (this._mesh.xid = e);
  13512. }
  13513. }, {
  13514. key: "setPosition",
  13515. value: function setPosition(e) {
  13516. if (e && this._mesh) {
  13517. var t = ue4Position2Xverse(e);
  13518. this._mesh.position = t;
  13519. }
  13520. }
  13521. }, {
  13522. key: "updateText",
  13523. value: function updateText(e, t) {
  13524. var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !0;
  13525. var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
  13526. var o = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 30;
  13527. var a = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : "monospace";
  13528. var s = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : "black";
  13529. var l = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : "bold";
  13530. var u = arguments.length > 8 ? arguments[8] : undefined;
  13531. if (this._texture == null) {
  13532. logger$1.error("[Engine]Billboard texture not found");
  13533. return;
  13534. }
  13535. var c = this._texture,
  13536. h = this._mesh,
  13537. f = this._scalingFactor,
  13538. d = this._initMeshScale.x,
  13539. _ = this._initMeshScale.y;
  13540. if (e != "") {
  13541. var g = this._texture.getContext(),
  13542. m = this._texture.getSize();
  13543. g.clearRect(0, 0, m.width, m.height);
  13544. var v = new Image();
  13545. if (r) {
  13546. t != null ? t ? this._background = this._billboardManager.userBackGroundBlob : this._background = this._billboardManager.npcBackGroundBlob : this._background || (this._background = this._billboardManager.userBackGroundBlob);
  13547. var y = e,
  13548. b = u && u < n.length - 1 ? u : n.length - 1;
  13549. if (this._background) {
  13550. if (b > this._background.length) {
  13551. for (var T = 0; T < b - this._background.length; T++) {
  13552. n.pop();
  13553. }
  13554. b = n.length - 1, y = e.slice(0, n[b] - 1) + String.fromCharCode(8230);
  13555. }
  13556. v.crossOrigin = "anonymous", v.src = this._background[b - 1], v.onload = function () {
  13557. var T = v.width * f,
  13558. C = v.height * f;
  13559. 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);
  13560. for (var A = 0; A < b; A++) {
  13561. 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);
  13562. }
  13563. c.hasAlpha = !0;
  13564. };
  13565. }
  13566. } else {
  13567. var _y = u && u < n.length - 1 ? u : n.length - 1,
  13568. _b = 480 * f,
  13569. _T = 60 * f * _y;
  13570. this._mesh.scaling = new BABYLON.Vector3(_b * d, _T * _, 1), c.scaleTo(_b, _T);
  13571. var C = c.getContext();
  13572. C.textAlign = "center", C.textBaseline = "middle";
  13573. for (var A = 0; A < _y; A++) {
  13574. 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);
  13575. }
  13576. c.hasAlpha = !0;
  13577. }
  13578. } else this.clearText();
  13579. }
  13580. }, {
  13581. key: "drawBillboard",
  13582. value: function drawBillboard(e, t, r) {
  13583. var _this2 = this;
  13584. var m;
  13585. var n = e.imageList,
  13586. o = t.texts,
  13587. _t$font = t.font,
  13588. a = _t$font === void 0 ? "monospace" : _t$font,
  13589. _t$fontsize = t.fontsize,
  13590. s = _t$fontsize === void 0 ? 40 : _t$fontsize,
  13591. _t$fontcolor = t.fontcolor,
  13592. l = _t$fontcolor === void 0 ? "#ffffff" : _t$fontcolor,
  13593. _t$fontstyle = t.fontstyle,
  13594. u = _t$fontstyle === void 0 ? "" : _t$fontstyle,
  13595. _t$linesize = t.linesize,
  13596. c = _t$linesize === void 0 ? 20 : _t$linesize,
  13597. h = t.linelimit,
  13598. f = r.position,
  13599. d = r.offsets,
  13600. _ = r.scale,
  13601. _r$compensationZ = r.compensationZ,
  13602. g = _r$compensationZ === void 0 ? 0 : _r$compensationZ;
  13603. if (this.scalingFactor = _ || 1, d && (this.offsets = {
  13604. x: d.x * this._scalingFactor,
  13605. y: d.y * this._scalingFactor,
  13606. z: d.z * this._scalingFactor
  13607. }), this.offsets || (this.offsets = {
  13608. x: 0,
  13609. y: 0,
  13610. z: 0
  13611. }), this.setPosition(f), n && !o) (m = this._billboardManager.sceneManager) == null || m.urlTransformer(n[0]).then(function (v) {
  13612. _this2.updateImage(v);
  13613. });else if (o && !n) {
  13614. var _getStringBoundaries = getStringBoundaries(o, c, XBillboardManager$1.alphaWidthMap),
  13615. _getStringBoundaries2 = _slicedToArray(_getStringBoundaries, 2),
  13616. v = _getStringBoundaries2[0],
  13617. y = _getStringBoundaries2[1];
  13618. this.offsets.z += this._scalingFactor * g * (y.length - 1), this.updateText(v, void 0, !1, y, s, a, l, u, h);
  13619. } else if (o && n) {
  13620. this.background = n;
  13621. var _getStringBoundaries3 = getStringBoundaries(o, c, XBillboardManager$1.alphaWidthMap),
  13622. _getStringBoundaries4 = _slicedToArray(_getStringBoundaries3, 2),
  13623. _v = _getStringBoundaries4[0],
  13624. _y2 = _getStringBoundaries4[1];
  13625. this.offsets.z += this._scalingFactor * g * (_y2.length - 1), this.updateText(_v, void 0, !0, _y2, s, a, l, u, h);
  13626. }
  13627. this.setStatus(1);
  13628. }
  13629. }, {
  13630. key: "clearText",
  13631. value: function clearText() {
  13632. if (this._texture != null) {
  13633. var e = this._texture.getContext(),
  13634. t = this._texture.getSize();
  13635. e.clearRect(0, 0, t.width, t.height), this._texture.update();
  13636. }
  13637. }
  13638. }]);
  13639. return XBillboard;
  13640. }();
  13641. var texRootDir = "https://app-asset-1258211750.file.myqcloud.com/1/textures/";
  13642. var XBillboardManager$1 = /*#__PURE__*/function () {
  13643. function XBillboardManager(e) {
  13644. var _this = this;
  13645. _classCallCheck(this, XBillboardManager);
  13646. E(this, "billboardMap", new Map());
  13647. E(this, "sceneManager");
  13648. E(this, "billboardPool");
  13649. E(this, "userBackGroundBlob", new Array());
  13650. E(this, "npcBackGroundBlob", new Array());
  13651. E(this, "tickObserver");
  13652. E(this, "tickInterval");
  13653. E(this, "_updateLoopObserver");
  13654. this.sceneManager = e, this.billboardPool = new Pool(this.createBillboardAsset, this.resetBillboardAsset, 0, 60, this.sceneManager.Scene, !1), this.tickInterval = 250;
  13655. var t = 0;
  13656. this.tickObserver = this.sceneManager.Scene.onAfterRenderObservable.add(function () {
  13657. t += 1, t == _this.tickInterval && (_this.tick(), t = 0);
  13658. }), this.launchBillboardStatusLoop();
  13659. }
  13660. _createClass(XBillboardManager, [{
  13661. key: "tick",
  13662. value: function tick() {
  13663. this.billboardPool.clean(0, this.sceneManager.Scene, !1);
  13664. }
  13665. }, {
  13666. key: "createBillboardAsset",
  13667. value: function createBillboardAsset(e) {
  13668. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
  13669. var r = BABYLON.MeshBuilder.CreatePlane("billboard-", {
  13670. height: .001,
  13671. width: .001,
  13672. sideOrientation: BABYLON.Mesh.DOUBLESIDE
  13673. }, e);
  13674. r.isPickable = !0, r.setEnabled(!1);
  13675. var n = new BABYLON.DynamicTexture("billboard-tex-", {
  13676. width: .001 + 1,
  13677. height: .001 + 1
  13678. }, e, t, BABYLON.Texture.BILINEAR_SAMPLINGMODE);
  13679. n.hasAlpha = !0;
  13680. var o = new BABYLON.StandardMaterial("billboard-mat-", e);
  13681. 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;
  13682. }
  13683. }, {
  13684. key: "resetBillboardAsset",
  13685. value: function resetBillboardAsset(e) {
  13686. var t = e.data;
  13687. return t.setEnabled(!1), t.isPickable = !1, e;
  13688. }
  13689. }, {
  13690. key: "loadBackGroundTexToIDB",
  13691. value: function () {
  13692. var _loadBackGroundTexToIDB = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  13693. var _this2 = this;
  13694. return regenerator.wrap(function _callee$(_context) {
  13695. while (1) {
  13696. switch (_context.prev = _context.next) {
  13697. case 0:
  13698. XBillboardManager.userBubbleUrls.forEach(function (r) {
  13699. _this2.sceneManager.urlTransformer(r).then(function (n) {
  13700. _this2.userBackGroundBlob.push(n);
  13701. });
  13702. }), XBillboardManager.npcBubbleUrls.forEach(function (r) {
  13703. _this2.sceneManager.urlTransformer(r).then(function (n) {
  13704. _this2.npcBackGroundBlob.push(n);
  13705. });
  13706. });
  13707. case 1:
  13708. case "end":
  13709. return _context.stop();
  13710. }
  13711. }
  13712. }, _callee);
  13713. }));
  13714. function loadBackGroundTexToIDB() {
  13715. return _loadBackGroundTexToIDB.apply(this, arguments);
  13716. }
  13717. return loadBackGroundTexToIDB;
  13718. }()
  13719. }, {
  13720. key: "addBillboardToMap",
  13721. value: function addBillboardToMap(e, t) {
  13722. this.billboardMap.set(e, t);
  13723. }
  13724. }, {
  13725. key: "addBillboard",
  13726. value: function addBillboard(e, t, r) {
  13727. var n = this.getBillboard(e);
  13728. return n || (n = new XBillboard(this, t, r), this.addBillboardToMap(e, n)), n;
  13729. }
  13730. }, {
  13731. key: "generateStaticBillboard",
  13732. value: function generateStaticBillboard(e, _ref) {
  13733. var _ref$id = _ref.id,
  13734. t = _ref$id === void 0 ? "billboard" : _ref$id,
  13735. r = _ref.isUser,
  13736. n = _ref.background,
  13737. _ref$font = _ref.font,
  13738. o = _ref$font === void 0 ? "Arial" : _ref$font,
  13739. _ref$fontsize = _ref.fontsize,
  13740. a = _ref$fontsize === void 0 ? 40 : _ref$fontsize,
  13741. _ref$fontcolor = _ref.fontcolor,
  13742. s = _ref$fontcolor === void 0 ? "#ffffff" : _ref$fontcolor,
  13743. _ref$fontstyle = _ref.fontstyle,
  13744. l = _ref$fontstyle === void 0 ? "600" : _ref$fontstyle,
  13745. _ref$linesize = _ref.linesize,
  13746. u = _ref$linesize === void 0 ? 16 : _ref$linesize,
  13747. c = _ref.linelimit,
  13748. _ref$scale = _ref.scale,
  13749. h = _ref$scale === void 0 ? 1 : _ref$scale,
  13750. _ref$width = _ref.width,
  13751. f = _ref$width === void 0 ? .01 : _ref$width,
  13752. _ref$height = _ref.height,
  13753. d = _ref$height === void 0 ? .01 : _ref$height,
  13754. _ref$position = _ref.position,
  13755. _ = _ref$position === void 0 ? {
  13756. x: 0,
  13757. y: 0,
  13758. z: 0
  13759. } : _ref$position;
  13760. var g = this.addBillboard(t, !1, !0);
  13761. g.getMesh() == null && g.init(t, f, d);
  13762. var m;
  13763. r != null && (m = r ? XBillboardManager.userBubbleUrls : XBillboardManager.npcBubbleUrls), g && g.getMesh() && (g.DEFAULT_CONFIGS = {
  13764. id: t,
  13765. isUser: r,
  13766. background: n,
  13767. font: o,
  13768. fontsize: a,
  13769. fontcolor: s,
  13770. fontstyle: l,
  13771. linesize: u,
  13772. linelimit: c,
  13773. scale: h,
  13774. width: f,
  13775. height: d,
  13776. position: _
  13777. }, g.drawBillboard({
  13778. imageList: n || m
  13779. }, {
  13780. texts: e,
  13781. font: o,
  13782. fontsize: a,
  13783. fontcolor: s,
  13784. fontstyle: l,
  13785. linesize: u,
  13786. linelimit: c
  13787. }, {
  13788. position: _,
  13789. scale: h
  13790. }), t && g.setId(t), g.setStatus(BillboardStatus.SHOW));
  13791. }
  13792. }, {
  13793. key: "getBillboard",
  13794. value: function getBillboard(e) {
  13795. return this.billboardMap.get(e);
  13796. }
  13797. }, {
  13798. key: "toggle",
  13799. value: function toggle(e, t) {
  13800. var r;
  13801. (r = this.getBillboard(e)) == null || r.setStatus(t ? BillboardStatus.SHOW : BillboardStatus.HIDE);
  13802. }
  13803. }, {
  13804. key: "removeBillboard",
  13805. value: function removeBillboard(e) {
  13806. var t = this.getBillboard(e);
  13807. t && (t.setStatus(BillboardStatus.DISPOSE), this.billboardMap.delete(e));
  13808. }
  13809. }, {
  13810. key: "launchBillboardStatusLoop",
  13811. value: function launchBillboardStatusLoop() {
  13812. var _this3 = this;
  13813. this._updateLoopObserver = this.sceneManager.Scene.onBeforeRenderObservable.add(function () {
  13814. _this3.billboardMap.size <= 0 || _this3.billboardMap.forEach(function (e) {
  13815. e.stageChanged && (e.status == BillboardStatus.SHOW ? e.show() : e.status == BillboardStatus.HIDE ? e.hide() : (e.hide(), e.dispose()), e.stageChanged = !1);
  13816. });
  13817. });
  13818. }
  13819. }]);
  13820. return XBillboardManager;
  13821. }();
  13822. 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"]);
  13823. var XLightManager = /*#__PURE__*/function () {
  13824. function XLightManager(e) {
  13825. _classCallCheck(this, XLightManager);
  13826. E(this, "_scene");
  13827. E(this, "_envTexture");
  13828. E(this, "_shadowLight");
  13829. E(this, "_shadowGenerator");
  13830. E(this, "_avatarShadowMeshMap");
  13831. E(this, "_cullingShadowObservers");
  13832. E(this, "sceneManager");
  13833. this.sceneManager = e, this._scene = this.sceneManager.Scene, this._envTexture = null, this.shadowLean = .1;
  13834. var t = new BABYLON.Vector3(this.shadowLean, -1, 0),
  13835. r = 1024;
  13836. 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();
  13837. }
  13838. _createClass(XLightManager, [{
  13839. key: "shadowLean",
  13840. set: function set(e) {
  13841. e = Math.min(e, 1), e = Math.max(e, -1), this._shadowLight && (this._shadowLight.direction = new BABYLON.Vector3(e, -1, 0));
  13842. }
  13843. }, {
  13844. key: "setIBL",
  13845. value: function setIBL(e) {
  13846. var _this = this;
  13847. return new Promise(function (t, r) {
  13848. _this.sceneManager.urlTransformer(e).then(function (n) {
  13849. var o;
  13850. if (n == ((o = _this._envTexture) == null ? void 0 : o.url)) return t("env set success");
  13851. _this._envTexture != null && _this.disposeIBL(), _this._envTexture = BABYLON.CubeTexture.CreateFromPrefilteredData(n, _this._scene, ".env"), _this._scene.environmentTexture = _this._envTexture, _this._envTexture.onLoadObservable.addOnce(function () {
  13852. t("env set success"), logger$1.info("env set success");
  13853. });
  13854. }).catch(function () {
  13855. r("env set fail");
  13856. });
  13857. });
  13858. }
  13859. }, {
  13860. key: "disposeIBL",
  13861. value: function disposeIBL() {
  13862. 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"));
  13863. }
  13864. }, {
  13865. key: "removeShadow",
  13866. value: function removeShadow(e) {
  13867. var t;
  13868. if (this._avatarShadowMeshMap.has(e)) {
  13869. this._avatarShadowMeshMap.delete(e), this._cullingShadowObservers.get(e) && (this._scene.onBeforeRenderObservable.remove(this._cullingShadowObservers.get(e)), this._cullingShadowObservers.delete(e));
  13870. var r = e.rootNode;
  13871. r && ((t = this._shadowGenerator) == null || t.removeShadowCaster(r));
  13872. } else return;
  13873. }
  13874. }, {
  13875. key: "setShadow",
  13876. value: function setShadow(e) {
  13877. if (this._avatarShadowMeshMap.has(e)) return;
  13878. e.rootNode && this._avatarShadowMeshMap.set(e, e.rootNode.getChildMeshes());
  13879. var t = 20,
  13880. r = 10,
  13881. n = this.cullingShadow(t, r, e);
  13882. this._cullingShadowObservers.set(e, n);
  13883. }
  13884. }, {
  13885. key: "cullingShadow",
  13886. value: function cullingShadow(e, t, r) {
  13887. var _this2 = this;
  13888. var n = 0;
  13889. var o = function o() {
  13890. var s, l;
  13891. if (n == t) {
  13892. var u = _this2._avatarShadowMeshMap.get(r),
  13893. c = (s = r.rootNode) == null ? void 0 : s.getChildMeshes(),
  13894. h = _this2._scene.activeCamera;
  13895. u == null || u.forEach(function (f) {
  13896. var d;
  13897. (d = _this2._shadowGenerator) == null || d.removeShadowCaster(f, !1);
  13898. }), c == null || c.forEach(function (f) {
  13899. var d;
  13900. (d = _this2._shadowGenerator) == null || d.addShadowCaster(f, !1);
  13901. }), h && r.rootNode && ((l = r.rootNode.position) == null ? void 0 : l.subtract(h.position).length()) > e && (c == null || c.forEach(function (f) {
  13902. var d;
  13903. (d = _this2._shadowGenerator) == null || d.removeShadowCaster(f, !1);
  13904. })), c && _this2._avatarShadowMeshMap.set(r, c), n = 0;
  13905. } else n += 1;
  13906. };
  13907. return this._scene.onBeforeRenderObservable.add(o);
  13908. }
  13909. }, {
  13910. key: "attachLightToCamera",
  13911. value: function attachLightToCamera(e) {
  13912. var _this3 = this;
  13913. var t = e,
  13914. r = 15,
  13915. n = function n() {
  13916. var o = _this3._scene.activeCamera;
  13917. if (o) {
  13918. var a = t.direction,
  13919. s = new BABYLON.Vector3(r * a.x, r * a.y, r * a.z),
  13920. l = o.position;
  13921. t.position = l.subtract(s);
  13922. }
  13923. };
  13924. return t && this._scene.registerBeforeRender(n), n;
  13925. }
  13926. }]);
  13927. return XLightManager;
  13928. }();
  13929. var RunTimeArray = /*#__PURE__*/function () {
  13930. function RunTimeArray() {
  13931. _classCallCheck(this, RunTimeArray);
  13932. E(this, "circularData");
  13933. this.circularData = [];
  13934. }
  13935. _createClass(RunTimeArray, [{
  13936. key: "add",
  13937. value: function add(e) {
  13938. this.circularData.length > 1e3 && this.circularData.shift(), this.circularData.push(e);
  13939. }
  13940. }, {
  13941. key: "getAvg",
  13942. value: function getAvg() {
  13943. var e = 0;
  13944. for (var t = 0; t < this.circularData.length; t++) {
  13945. e += this.circularData[t];
  13946. }
  13947. return {
  13948. sum: e,
  13949. avg: e / this.circularData.length || 0
  13950. };
  13951. }
  13952. }, {
  13953. key: "getMax",
  13954. value: function getMax() {
  13955. var e = 0;
  13956. for (var t = 0; t < this.circularData.length; t++) {
  13957. e < this.circularData[t] && (e = this.circularData[t]);
  13958. }
  13959. return e || 0;
  13960. }
  13961. }, {
  13962. key: "clear",
  13963. value: function clear() {
  13964. this.circularData = [];
  13965. }
  13966. }, {
  13967. key: "getStat",
  13968. value: function getStat() {
  13969. var e = this.getAvg(),
  13970. t = {
  13971. sum: e.sum,
  13972. avg: e.avg,
  13973. max: this.getMax()
  13974. };
  13975. return this.clear(), t;
  13976. }
  13977. }]);
  13978. return RunTimeArray;
  13979. }();
  13980. var XEngineRunTimeStats = /*#__PURE__*/_createClass(function XEngineRunTimeStats() {
  13981. _classCallCheck(this, XEngineRunTimeStats);
  13982. E(this, "timeArray_loadStaticMesh", new RunTimeArray());
  13983. E(this, "timeArray_updateStaticMesh", new RunTimeArray());
  13984. E(this, "timeArray_addAvatarToScene", new RunTimeArray());
  13985. });
  13986. 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; } } }; }
  13987. 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); }
  13988. 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; }
  13989. var getAlphaWidthMap = function getAlphaWidthMap(i, e) {
  13990. var t = new BABYLON.DynamicTexture("test", 3, e),
  13991. r = new Map();
  13992. for (var n = 32; n < 127; n++) {
  13993. var o = String.fromCodePoint(n),
  13994. a = 2 + "px " + i;
  13995. t.drawText(o, null, null, a, "#000000", "#ffffff", !0);
  13996. var s = t.getContext();
  13997. s.font = a;
  13998. var l = s.measureText(o).width;
  13999. r.set(n, l);
  14000. }
  14001. return t.dispose(), r;
  14002. };
  14003. var XSceneManager = /*#__PURE__*/function () {
  14004. function XSceneManager(e, t) {
  14005. var _this = this;
  14006. _classCallCheck(this, XSceneManager);
  14007. E(this, "scene");
  14008. E(this, "engine");
  14009. E(this, "canvas");
  14010. E(this, "gl");
  14011. E(this, "_yuvInfo");
  14012. E(this, "cameraParam");
  14013. E(this, "shaderMode");
  14014. E(this, "panoInfo");
  14015. E(this, "_initEngineScaleNumber");
  14016. E(this, "_forceKeepVertical", !1);
  14017. E(this, "_currentShader");
  14018. E(this, "_currentPanoId");
  14019. E(this, "_renderStatusCheckCount", 0);
  14020. E(this, "_renderStatusNotChecktCount", 0);
  14021. E(this, "_nonlinearCanvasResize", !1);
  14022. E(this, "_bChangeEngineSize", !0);
  14023. E(this, "_cameraManager");
  14024. E(this, "_lowpolyManager");
  14025. E(this, "_materialManager");
  14026. E(this, "_statisticManager");
  14027. E(this, "_breathPointManager");
  14028. E(this, "_skytv");
  14029. E(this, "_mv", []);
  14030. E(this, "_decalManager");
  14031. E(this, "_lightManager");
  14032. E(this, "_avatarManager");
  14033. E(this, "urlTransformer");
  14034. E(this, "_billboardManager");
  14035. E(this, "_backgroundImg");
  14036. E(this, "engineRunTimeStats");
  14037. E(this, "uploadHardwareSystemInfo", function () {
  14038. var e = _this.statisticComponent.getHardwareRenderInfo(),
  14039. t = _this.statisticComponent.getSystemInfo(),
  14040. r = {
  14041. driver: t.driver,
  14042. vender: t.vender,
  14043. webgl: t.version,
  14044. os: t.os
  14045. };
  14046. logger$1.warn(JSON.stringify(e)), logger$1.warn(JSON.stringify(r));
  14047. });
  14048. E(this, "addNewLowPolyMesh", /*#__PURE__*/function () {
  14049. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e, t) {
  14050. return regenerator.wrap(function _callee$(_context) {
  14051. while (1) {
  14052. switch (_context.prev = _context.next) {
  14053. case 0:
  14054. _context.t0 = _this._currentShader == null;
  14055. if (!_context.t0) {
  14056. _context.next = 4;
  14057. break;
  14058. }
  14059. _context.next = 4;
  14060. return _this.initSceneManager();
  14061. case 4:
  14062. return _context.abrupt("return", _this._lowpolyManager.addNewLowPolyMesh(e, t, _this._currentShader));
  14063. case 5:
  14064. case "end":
  14065. return _context.stop();
  14066. }
  14067. }
  14068. }, _callee);
  14069. }));
  14070. return function (_x, _x2) {
  14071. return _ref.apply(this, arguments);
  14072. };
  14073. }());
  14074. E(this, "initSceneManager", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  14075. return regenerator.wrap(function _callee2$(_context2) {
  14076. while (1) {
  14077. switch (_context2.prev = _context2.next) {
  14078. case 0:
  14079. _context2.next = 2;
  14080. return _this._materialManager.initMaterial();
  14081. case 2:
  14082. return _context2.abrupt("return", _this.applyShader());
  14083. case 3:
  14084. case "end":
  14085. return _context2.stop();
  14086. }
  14087. }
  14088. }, _callee2);
  14089. })));
  14090. E(this, "registerAfterRender", function () {
  14091. var e;
  14092. if (_this._forceKeepVertical) {
  14093. var _t = _this.canvas.width,
  14094. _r = _this.canvas.height;
  14095. var _n = 0,
  14096. _o = [[0, 0, 0, 0], [0, 0, 0, 0]];
  14097. 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) {
  14098. _this.gl.enable(_this.gl.SCISSOR_TEST);
  14099. for (var a = 0; a < _o.length; ++a) {
  14100. _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);
  14101. }
  14102. _this.gl.disable(_this.gl.SCISSOR_TEST);
  14103. }
  14104. }
  14105. });
  14106. E(this, "resetRender", function () {
  14107. _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));
  14108. });
  14109. var r = /iphone|ipad/gi.test(window.navigator.userAgent) || t.disableWebGL2,
  14110. n = new BABYLON.Engine(e, !0, {
  14111. preserveDrawingBuffer: !0,
  14112. stencil: !0,
  14113. disableWebGL2Support: r
  14114. }, !0),
  14115. o = new BABYLON.Scene(n);
  14116. this.scene = o, this.engine = n, this.canvas = e, this.scene.clearColor = new BABYLON.Color4(.7, .7, .7, 1), this.engine.getCaps().parallelShaderCompile = void 0, this._initEngineScaleNumber = this.engine.getHardwareScalingLevel(), this.engine.enableOfflineSupport = !1, this.engine.doNotHandleContextLost = !0, this.scene.clearCachedVertexData(), this.scene.cleanCachedTextureBuffer(), this.urlTransformer = t.urlTransformer || function (s) {
  14117. return Promise.resolve(s);
  14118. }, t.logger && Logger1.setLogger(t.logger), this.gl = e.getContext("webgl2", {
  14119. preserveDrawingBuffer: !0
  14120. }) || e.getContext("webgl", {
  14121. preserveDrawingBuffer: !0
  14122. }) || e.getContext("experimental-webgl", {
  14123. preserveDrawingBuffer: !0
  14124. }), 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 = {
  14125. width: t.videoResOriArray[0].width,
  14126. height: t.videoResOriArray[0].height,
  14127. fov: 50
  14128. }, t.cameraParam != null && (this.cameraParam = t.cameraParam), t.nonlinearCanvasResize != null && (this._nonlinearCanvasResize = t.nonlinearCanvasResize), this._cameraManager = new XCameraComponent(this.canvas, this.scene, {
  14129. cameraParam: this.cameraParam,
  14130. yuvInfo: this._yuvInfo,
  14131. forceKeepVertical: this._forceKeepVertical
  14132. }), this._lowpolyManager = new XStaticMeshComponent(this), this._materialManager = new XMaterialComponent(this, {
  14133. videoResOriArray: t.videoResOriArray,
  14134. yuvInfo: this._yuvInfo,
  14135. panoInfo: this.panoInfo,
  14136. shaderMode: this.shaderMode
  14137. }), 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 () {
  14138. _this._nonlinearCanvasResize && _this._bChangeEngineSize && (_this.setEngineSize(_this._yuvInfo), _this._bChangeEngineSize = !1);
  14139. }), this.scene.registerAfterRender(function () {
  14140. _this._nonlinearCanvasResize || _this.registerAfterRender();
  14141. }), window.addEventListener("resize", function () {
  14142. _this._nonlinearCanvasResize ? _this._bChangeEngineSize = !0 : _this.engine.resize();
  14143. }), XBillboardManager$1.alphaWidthMap = getAlphaWidthMap("Arial", this.scene), this.uploadHardwareSystemInfo();
  14144. }
  14145. _createClass(XSceneManager, [{
  14146. key: "yuvInfo",
  14147. get: function get() {
  14148. return this.getCurrentShaderMode() == 1 ? this._yuvInfo : {
  14149. width: -1,
  14150. height: -1,
  14151. fov: -1
  14152. };
  14153. },
  14154. set: function set(e) {
  14155. this.getCurrentShaderMode() == 1 && (this._yuvInfo = e, this._cameraManager.cameraFovChange(e));
  14156. }
  14157. }, {
  14158. key: "mainScene",
  14159. get: function get() {
  14160. return this.scene;
  14161. }
  14162. }, {
  14163. key: "cameraComponent",
  14164. get: function get() {
  14165. return this._cameraManager;
  14166. }
  14167. }, {
  14168. key: "staticmeshComponent",
  14169. get: function get() {
  14170. return this._lowpolyManager;
  14171. }
  14172. }, {
  14173. key: "materialComponent",
  14174. get: function get() {
  14175. return this._materialManager;
  14176. }
  14177. }, {
  14178. key: "statisticComponent",
  14179. get: function get() {
  14180. return this._statisticManager;
  14181. }
  14182. }, {
  14183. key: "avatarComponent",
  14184. get: function get() {
  14185. return this._avatarManager;
  14186. }
  14187. }, {
  14188. key: "lightComponent",
  14189. get: function get() {
  14190. return this._lightManager;
  14191. }
  14192. }, {
  14193. key: "Engine",
  14194. get: function get() {
  14195. return this.engine;
  14196. }
  14197. }, {
  14198. key: "Scene",
  14199. get: function get() {
  14200. return this.scene;
  14201. }
  14202. }, {
  14203. key: "billboardComponent",
  14204. get: function get() {
  14205. return this._billboardManager;
  14206. }
  14207. }, {
  14208. key: "breathPointComponent",
  14209. get: function get() {
  14210. return this._breathPointManager;
  14211. }
  14212. }, {
  14213. key: "skytvComponent",
  14214. get: function get() {
  14215. return this._skytv;
  14216. }
  14217. }, {
  14218. key: "mvComponent",
  14219. get: function get() {
  14220. return this._mv;
  14221. }
  14222. }, {
  14223. key: "decalComponent",
  14224. get: function get() {
  14225. return this._decalManager;
  14226. }
  14227. }, {
  14228. key: "currentShader",
  14229. get: function get() {
  14230. return this._currentShader;
  14231. }
  14232. }, {
  14233. key: "initEngineScaleNumber",
  14234. get: function get() {
  14235. return this._initEngineScaleNumber;
  14236. }
  14237. }, {
  14238. key: "setImageQuality",
  14239. value: function setImageQuality(e) {
  14240. 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 + "]"));
  14241. }
  14242. }, {
  14243. key: "setNonlinearCanvasResize",
  14244. value: function setNonlinearCanvasResize(e) {
  14245. this._nonlinearCanvasResize = e, this._bChangeEngineSize = e, e || this.engine.resize();
  14246. }
  14247. }, {
  14248. key: "setBackgroundColor",
  14249. value: function setBackgroundColor(e) {
  14250. this.scene.clearColor = new Color4(e.r, e.g, e.b, e.a);
  14251. }
  14252. }, {
  14253. key: "setBackgroundImg",
  14254. value: function setBackgroundImg(e) {
  14255. var _this2 = this;
  14256. return this._backgroundImg != null && this._backgroundImg.url == e ? Promise.resolve(!0) : new Promise(function (t, r) {
  14257. _this2.urlTransformer(e).then(function (n) {
  14258. _this2._backgroundImg == null ? _this2._backgroundImg = {
  14259. layer: new Layer("tex_background_" + Date.now(), n, _this2.Scene, !0),
  14260. url: e
  14261. } : _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);
  14262. }).catch(function (n) {
  14263. logger$1.error("[Engine] set background image Error: ".concat(n)), r("[Engine] set background image Error: ".concat(n));
  14264. });
  14265. });
  14266. }
  14267. }, {
  14268. key: "cleanTheWholeScene",
  14269. value: function cleanTheWholeScene() {
  14270. var _this3 = this;
  14271. var e = this.scene.getFrameId();
  14272. this.scene.onBeforeRenderObservable.clear(), this.scene.onAfterRenderObservable.clear(), this.scene.clearCachedVertexData(), this.scene.cleanCachedTextureBuffer(), this.scene.registerBeforeRender(function () {
  14273. _this3.scene.getFrameId() - e > 5 && _this3.scene.dispose();
  14274. });
  14275. }
  14276. }, {
  14277. key: "getAreaAvatar",
  14278. value: function getAreaAvatar(e, t) {
  14279. var r = [];
  14280. return this._avatarManager.getAvatarList().forEach(function (n) {
  14281. var o = e,
  14282. a = n.position;
  14283. a && o && calcDistance3D(o, a) < t && r.push(n.id);
  14284. }), r;
  14285. }
  14286. }, {
  14287. key: "setEngineSize",
  14288. value: function setEngineSize(e) {
  14289. var t = e.width,
  14290. r = e.height,
  14291. n = this.canvas.width;
  14292. this.canvas.height, this.engine.setSize(Math.round(n), Math.round(n * (r / t)));
  14293. }
  14294. }, {
  14295. key: "getCurrentShaderMode",
  14296. value: function getCurrentShaderMode() {
  14297. return this._currentShader === this._materialManager.getDefaultShader() ? 0 : this._currentShader === this._materialManager.getPureVideoShader() ? 1 : 2;
  14298. }
  14299. }, {
  14300. key: "addSkyTV",
  14301. value: function addSkyTV(e, t) {
  14302. return this._skytv = new XTelevision(this.scene, e, this, t), this._skytv;
  14303. }
  14304. }, {
  14305. key: "addMv",
  14306. value: function addMv(e, t) {
  14307. this._mv.push(new XTelevision(this.scene, e, this, t));
  14308. }
  14309. }, {
  14310. key: "addMeshInfo",
  14311. value: function addMeshInfo(e) {
  14312. this._lowpolyManager.setMeshInfo(e);
  14313. }
  14314. }, {
  14315. key: "applyShader",
  14316. value: function applyShader() {
  14317. var _this4 = this;
  14318. return new Promise(function (e, t) {
  14319. _this4.shaderMode == EShaderMode.videoAndPano || _this4.shaderMode == EShaderMode.video ? _this4.changeVideoShaderForLowModel() : _this4.shaderMode == EShaderMode.default && _this4.changeDefaultShaderForLowModel(), e(!0);
  14320. });
  14321. }
  14322. }, {
  14323. key: "changeHardwareScaling",
  14324. value: function changeHardwareScaling(e) {
  14325. e < 1 ? e = 1 : e > 2.5 && (e = 2.5), this._bChangeEngineSize = !0, this.engine.setHardwareScalingLevel(this._initEngineScaleNumber * e);
  14326. }
  14327. }, {
  14328. key: "getCurrentUsedPanoId",
  14329. value: function getCurrentUsedPanoId() {
  14330. return this._currentPanoId;
  14331. }
  14332. }, {
  14333. key: "render",
  14334. value: function render() {
  14335. try {
  14336. this.scene.render();
  14337. } catch (e) {
  14338. throw logger$1.error("[Engine] Render Error: ".concat(e)), e;
  14339. }
  14340. }
  14341. }, {
  14342. key: "isReadyToRender",
  14343. value: function isReadyToRender(e) {
  14344. var _e$checkMesh = e.checkMesh,
  14345. t = _e$checkMesh === void 0 ? !0 : _e$checkMesh,
  14346. _e$checkEffect = e.checkEffect,
  14347. r = _e$checkEffect === void 0 ? !1 : _e$checkEffect,
  14348. _e$checkPostProgress = e.checkPostProgress,
  14349. n = _e$checkPostProgress === void 0 ? !1 : _e$checkPostProgress,
  14350. _e$checkParticle = e.checkParticle,
  14351. o = _e$checkParticle === void 0 ? !1 : _e$checkParticle,
  14352. _e$checkAnimation = e.checkAnimation,
  14353. a = _e$checkAnimation === void 0 ? !1 : _e$checkAnimation;
  14354. e.materialNameWhiteLists;
  14355. if (this.scene._isDisposed) return logger$1.error("[Engine] this.scene._isDisposed== false "), !1;
  14356. var l;
  14357. var u = this.scene.getEngine();
  14358. if (r && !u.areAllEffectsReady()) return logger$1.error("[Engine] engine.areAllEffectsReady == false"), !1;
  14359. if (a && this.scene._pendingData.length > 0) return logger$1.error("[Engine] scene._pendingData.length > 0 && animation error"), !1;
  14360. if (t) {
  14361. for (l = 0; l < this.scene.meshes.length; l++) {
  14362. var c = this.scene.meshes[l];
  14363. 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;
  14364. 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;
  14365. var h = c.hasThinInstances || c.getClassName() === "InstancedMesh" || c.getClassName() === "InstancedLinesMesh" || u.getCaps().instancedArrays && c.instances.length > 0;
  14366. var _iterator = _createForOfIteratorHelper(this.scene._isReadyForMeshStage),
  14367. _step;
  14368. try {
  14369. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  14370. var f = _step.value;
  14371. 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;
  14372. }
  14373. } catch (err) {
  14374. _iterator.e(err);
  14375. } finally {
  14376. _iterator.f();
  14377. }
  14378. }
  14379. for (l = 0; l < this.scene.geometries.length; l++) {
  14380. if (this.scene.geometries[l].delayLoadState === 2) return logger$1.error("[Engine] geometry.delayLoadState === 2"), !1;
  14381. }
  14382. }
  14383. if (n) {
  14384. if (this.scene.activeCameras && this.scene.activeCameras.length > 0) {
  14385. var _iterator2 = _createForOfIteratorHelper(this.scene.activeCameras),
  14386. _step2;
  14387. try {
  14388. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  14389. var _c = _step2.value;
  14390. if (!_c.isReady(!0)) return logger$1.error("[Engine] camera not ready === false, ", _c.name), !1;
  14391. }
  14392. } catch (err) {
  14393. _iterator2.e(err);
  14394. } finally {
  14395. _iterator2.f();
  14396. }
  14397. } else if (this.scene.activeCamera && !this.scene.activeCamera.isReady(!0)) return logger$1.error("[Engine] activeCamera ready === false, ", this.scene.activeCamera.name), !1;
  14398. }
  14399. if (o) {
  14400. var _iterator3 = _createForOfIteratorHelper(this.scene.particleSystems),
  14401. _step3;
  14402. try {
  14403. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  14404. var _c2 = _step3.value;
  14405. if (!_c2.isReady()) return logger$1.error("[Engine] particleSystem ready === false, ", _c2.name), !1;
  14406. }
  14407. } catch (err) {
  14408. _iterator3.e(err);
  14409. } finally {
  14410. _iterator3.f();
  14411. }
  14412. }
  14413. return !0;
  14414. }
  14415. }, {
  14416. key: "changePanoShaderForLowModel",
  14417. value: function changePanoShaderForLowModel(e) {
  14418. var _this5 = this;
  14419. return logger$1.info("[Engine] changePanoShaderForLowModel: ".concat(e)), this._materialManager.allowYUVUpdate(), new Promise(function (t, r) {
  14420. _this5._materialManager._isInDynamicRange(e) == !1 && r(!1), _this5._currentPanoId = e, _this5._currentShader = _this5._materialManager.getDynamicShader(e), _this5.changeShaderForLowModel().then(function () {
  14421. t(!0);
  14422. });
  14423. });
  14424. }
  14425. }, {
  14426. key: "changeVideoShaderForLowModel",
  14427. value: function changeVideoShaderForLowModel() {
  14428. return logger$1.info("[Engine] changeVideoShaderForLowModel"), this._currentShader = this._materialManager.getPureVideoShader(), this._materialManager.allowYUVUpdate(), this.changeShaderForLowModel();
  14429. }
  14430. }, {
  14431. key: "changeDefaultShaderForLowModel",
  14432. value: function changeDefaultShaderForLowModel() {
  14433. return logger$1.info("[Engine] changeDefaultShaderForLowModel"), this._currentShader = this._materialManager.getDefaultShader(), this._materialManager.stopYUVUpdate(), this.changeShaderForLowModel();
  14434. }
  14435. }, {
  14436. key: "changeShaderForLowModel",
  14437. value: function changeShaderForLowModel() {
  14438. var _this6 = this;
  14439. return new Promise(function (e, t) {
  14440. _this6._lowpolyManager.getMeshes().forEach(function (r) {
  14441. r.setMaterial(_this6._currentShader);
  14442. }), _this6._lowpolyManager.getCgMesh().mesh.material = _this6._currentShader, e(!0);
  14443. });
  14444. }
  14445. }, {
  14446. key: "setIBL",
  14447. value: function setIBL(e) {
  14448. this._lightManager.setIBL(e);
  14449. }
  14450. }, {
  14451. key: "postprocessing",
  14452. value: function postprocessing() {
  14453. var e = new BABYLON.DefaultRenderingPipeline("default", !0, this.scene);
  14454. e.imageProcessingEnabled = !1, e.bloomEnabled = !0, e.bloomThreshold = 1, e.bloomWeight = 1, e.bloomKernel = 64, e.bloomScale = .1;
  14455. }
  14456. }, {
  14457. key: "getGround",
  14458. value: function getGround(e) {
  14459. var t = this._lowpolyManager.getMeshes(),
  14460. r = [];
  14461. return t.forEach(function (n) {
  14462. n.mesh.name.indexOf("SM_Stage") >= 0 && r.push(n.mesh);
  14463. }), this.Scene.meshes.forEach(function (n) {
  14464. n.name.split("_")[0] === "ground" && r.push(n);
  14465. }), r;
  14466. }
  14467. }]);
  14468. return XSceneManager;
  14469. }();
  14470. var http = new Http();
  14471. var urlMap = new Map(),
  14472. urlTransformer = /*#__PURE__*/function () {
  14473. var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(i) {
  14474. var e,
  14475. _args2 = arguments;
  14476. return regenerator.wrap(function _callee2$(_context2) {
  14477. while (1) {
  14478. switch (_context2.prev = _context2.next) {
  14479. case 0:
  14480. e = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : !1;
  14481. return _context2.abrupt("return", typeof i != "string" ? (console.warn("url transformer error", i), i) : i.startsWith("blob:") ? i : e ? http.get({
  14482. url: i,
  14483. useIndexedDb: !0,
  14484. key: "url",
  14485. isOutPutObjectURL: !1
  14486. }) : urlMap.has(i) ? urlMap.get(i) : http.get({
  14487. url: i,
  14488. useIndexedDb: !0,
  14489. key: "url"
  14490. }).then(function (t) {
  14491. return urlMap.set(i, t), t;
  14492. }));
  14493. case 2:
  14494. case "end":
  14495. return _context2.stop();
  14496. }
  14497. }
  14498. }, _callee2);
  14499. }));
  14500. return function urlTransformer(_x2) {
  14501. return _ref2.apply(this, arguments);
  14502. };
  14503. }();
  14504. var sceneManager;
  14505. function getSceneManager(i, e) {
  14506. return sceneManager || (sceneManager = new XSceneManager(i, e)), sceneManager;
  14507. }
  14508. var EngineProxy = /*#__PURE__*/function () {
  14509. function EngineProxy(e) {
  14510. var _this = this;
  14511. _classCallCheck(this, EngineProxy);
  14512. E(this, "_tvs", []);
  14513. E(this, "isRenderFirstFrame", !1);
  14514. E(this, "_idleTime", 0);
  14515. E(this, "renderTimer");
  14516. E(this, "lightManager");
  14517. E(this, "_checkSceneNotReadyCount", 0);
  14518. E(this, "_checkSceneDurationFrameNum", 0);
  14519. E(this, "_checkSceneFrameCount", 0);
  14520. E(this, "timeoutCircularArray", new CircularArray(120, !1, []));
  14521. E(this, "frameCircularArray", new CircularArray(120, !1, []));
  14522. E(this, "interFrameCircularArray", new CircularArray(120, !1, []));
  14523. E(this, "drawCallCntCircularArray", new CircularArray(120, !1, []));
  14524. E(this, "activeFacesCircularArray", new CircularArray(120, !1, []));
  14525. E(this, "renderTimeCircularArray", new CircularArray(120, !1, []));
  14526. E(this, "drawCallTimeCircularArray", new CircularArray(120, !1, []));
  14527. E(this, "animationCircularArray", new CircularArray(120, !1, []));
  14528. E(this, "meshSelectCircularArray", new CircularArray(120, !1, []));
  14529. E(this, "renderTargetCircularArray", new CircularArray(120, !1, []));
  14530. E(this, "regBeforeRenderCircularArray", new CircularArray(120, !1, []));
  14531. E(this, "regAfterRenderCircularArray", new CircularArray(120, !1, []));
  14532. E(this, "renderCnt", 0);
  14533. E(this, "renderErrorCount", 0);
  14534. E(this, "engineSloppyCnt", 0);
  14535. E(this, "systemStuckCnt", 0);
  14536. E(this, "frameRenderNumber", 0);
  14537. E(this, "_setFPS", function (e) {
  14538. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 25;
  14539. logger$1.info("Set fps to", t);
  14540. var r = t > 60 ? 60 : t < 24 ? 24 : t;
  14541. e.Engine.stopRenderLoop();
  14542. var n = 1e3 / r;
  14543. var o = Date.now(),
  14544. a = Date.now(),
  14545. s = n,
  14546. l = 1;
  14547. var u = function u() {
  14548. var T;
  14549. var c = Date.now(),
  14550. h = c - o,
  14551. f = c - a;
  14552. a = c, _this.frameCircularArray.add(f), h - s > n && (_this.systemStuckCnt += 1);
  14553. var d = h / s;
  14554. l = .9 * l + .1 * d;
  14555. var _ = Date.now();
  14556. var g = 0,
  14557. m = 0;
  14558. if (_this.room.isUpdatedRawYUVData || _this.room.isPano) {
  14559. 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", {
  14560. error: new Error("[SDK] Scene not ready, skip render and reload.")
  14561. })), _this.room.stats.assign({
  14562. renderErrorCount: _this._checkSceneNotReadyCount
  14563. }), logger$1.infoAndReportMeasurement({
  14564. value: 0,
  14565. startTime: Date.now(),
  14566. metric: "renderError",
  14567. error: new Error("[SDK] Scene not ready, skip render and reload."),
  14568. reportOptions: {
  14569. sampleRate: .1
  14570. }
  14571. }));else try {
  14572. e.render();
  14573. } catch (C) {
  14574. _this.renderErrorCount++, _this.renderErrorCount > 10 && _this.room.proxyEvents("renderError", {
  14575. error: C
  14576. }), _this.room.stats.assign({
  14577. renderErrorCount: _this.renderErrorCount
  14578. }), logger$1.infoAndReportMeasurement({
  14579. value: 0,
  14580. startTime: Date.now(),
  14581. metric: "renderError",
  14582. error: C,
  14583. reportOptions: {
  14584. sampleRate: .1
  14585. }
  14586. });
  14587. }
  14588. g = Date.now() - _, _this.frameRenderNumber < 1e3 && _this.frameRenderNumber++, _this.room.networkController.rtcp.workers.UpdateYUV(), m = Date.now() - _ - g;
  14589. }
  14590. _this.isRenderFirstFrame || _this.room.networkController.rtcp.workers.UpdateYUV();
  14591. var y = Date.now() - _;
  14592. o = c + y, s = Math.min(Math.max((n - y) / l, 5), 200), y > n && (s = 10, _this.engineSloppyCnt += 1), _this._idleTime = s;
  14593. var b = s;
  14594. 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) {
  14595. var C = _this.frameCircularArray.getAvg(),
  14596. A = _this.timeoutCircularArray.getAvg(),
  14597. S = _this.frameCircularArray.getMax(),
  14598. P = _this.timeoutCircularArray.getMax();
  14599. (T = _this.room.stats) == null || T.assign({
  14600. avgFrameTime: C,
  14601. avgTimeoutTime: A,
  14602. maxFrameTime: S,
  14603. maxTimeoutTime: P,
  14604. systemStuckCnt: _this.systemStuckCnt
  14605. });
  14606. }
  14607. _this.renderTimer = window.setTimeout(u, s);
  14608. };
  14609. _this.renderTimer = window.setTimeout(u, n / l);
  14610. });
  14611. E(this, "updateStats", function () {
  14612. var e;
  14613. (e = _this.room.stats) == null || e.assign({
  14614. renderFrameTime: _this.renderTimeCircularArray.getAvg(),
  14615. maxRenderFrameTime: _this.renderTimeCircularArray.getMax(),
  14616. interFrameTime: _this.interFrameCircularArray.getAvg(),
  14617. animationTime: _this.animationCircularArray.getAvg(),
  14618. meshSelectTime: _this.meshSelectCircularArray.getAvg(),
  14619. drawcallTime: _this.drawCallTimeCircularArray.getAvg(),
  14620. idleTime: _this._idleTime,
  14621. registerBeforeRenderTime: _this.regBeforeRenderCircularArray.getAvg(),
  14622. registerAfterRenderTime: _this.regAfterRenderCircularArray.getAvg(),
  14623. renderTargetRenderTime: _this.renderTargetCircularArray.getAvg(),
  14624. fps: (1e3 / (_this.renderTimeCircularArray.getAvg() + _this.interFrameCircularArray.getAvg())).toFixed(2),
  14625. drawcall: _this.drawCallCntCircularArray.getAvg(),
  14626. engineSloppyCnt: _this.engineSloppyCnt,
  14627. maxInterFrameTime: _this.interFrameCircularArray.getMax(),
  14628. maxDrawcallTime: _this.drawCallTimeCircularArray.getMax(),
  14629. maxMeshSelectTime: _this.meshSelectCircularArray.getMax(),
  14630. maxAnimationTime: _this.animationCircularArray.getMax(),
  14631. maxRegisterBeforeRenderTime: _this.regBeforeRenderCircularArray.getMax(),
  14632. maxRegisterAfterRenderTime: _this.regAfterRenderCircularArray.getMax(),
  14633. maxRenderTargetRenderTime: _this.renderTargetCircularArray.getMax(),
  14634. avgFrameTime: _this.frameCircularArray.getAvg(),
  14635. avgTimeoutTime: _this.timeoutCircularArray.getAvg(),
  14636. maxFrameTime: _this.frameCircularArray.getMax(),
  14637. maxTimeoutTime: _this.timeoutCircularArray.getMax()
  14638. });
  14639. });
  14640. this.room = e;
  14641. }
  14642. _createClass(EngineProxy, [{
  14643. key: "initEngine",
  14644. value: function () {
  14645. var _initEngine = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
  14646. var t, r, n, o, a;
  14647. return regenerator.wrap(function _callee3$(_context3) {
  14648. while (1) {
  14649. switch (_context3.prev = _context3.next) {
  14650. case 0:
  14651. _context3.next = 2;
  14652. return this.updateBillboard();
  14653. case 2:
  14654. logger$1.info("engine version:", VERSION$1);
  14655. t = logger$1;
  14656. t.setLevel(LoggerLevels$1.Warn);
  14657. r = {
  14658. videoResOriArray: [{
  14659. width: 720,
  14660. height: 1280
  14661. }, {
  14662. width: 1280,
  14663. height: 720
  14664. }, {
  14665. width: 480,
  14666. height: 654
  14667. }, {
  14668. width: 654,
  14669. height: 480
  14670. }, {
  14671. width: 1920,
  14672. height: 1080
  14673. }, {
  14674. width: 1080,
  14675. height: 1920
  14676. }, {
  14677. width: 414,
  14678. height: 896
  14679. }],
  14680. forceKeepVertical: this.room.options.objectFit !== "cover",
  14681. panoInfo: {
  14682. dynamicRange: 1,
  14683. width: 4096,
  14684. height: 2048
  14685. },
  14686. shaderMode: EShaderMode.videoAndPano,
  14687. yuvInfo: {
  14688. width: 1280,
  14689. height: 720,
  14690. fov: e.fov || DEFAULT_MAIN_CAMERA_FOV
  14691. },
  14692. cameraParam: {
  14693. maxZ: 1e4
  14694. },
  14695. urlTransformer,
  14696. logger: t,
  14697. disableWebGL2: this.room.options.disableWebGL2 || !1
  14698. }, n = this.room.options.resolution;
  14699. n && (r.videoResOriArray.some(function (l) {
  14700. return l.width === n.width && l.height === n.height;
  14701. }) || r.videoResOriArray.push(n));
  14702. o = this.room.sceneManager = getSceneManager(this.room.canvas, r);
  14703. this.room.setPictureQualityLevel(this.room.options.pictureQualityLevel || "high");
  14704. this.room.sceneManager.staticmeshComponent.setRegionLodRule([2, 2, -1, -1, -1]);
  14705. this.room.scene = o.Scene;
  14706. this.room.breathPointManager = o.breathPointComponent;
  14707. this.lightManager = o.lightComponent;
  14708. this.registerStats();
  14709. this.setEnv(e);
  14710. _context3.next = 17;
  14711. return this.room.avatarManager.init();
  14712. case 17:
  14713. a = this._createAssetList(e);
  14714. _context3.next = 20;
  14715. return this.loadAssets(a, "");
  14716. case 20:
  14717. this._setFPS(o);
  14718. case 21:
  14719. case "end":
  14720. return _context3.stop();
  14721. }
  14722. }
  14723. }, _callee3, this);
  14724. }));
  14725. function initEngine(_x3) {
  14726. return _initEngine.apply(this, arguments);
  14727. }
  14728. return initEngine;
  14729. }()
  14730. }, {
  14731. key: "pause",
  14732. value: function pause() {
  14733. clearTimeout(this.renderTimer), logger$1.info("Invoke room.pause to pause render");
  14734. var e = {
  14735. roomId: this.room.id,
  14736. effects: [],
  14737. lowPolyModels: [],
  14738. breathPointsConfig: [],
  14739. skinId: this.room.skinId
  14740. };
  14741. return this.loadAssets(e, this.room.skinId);
  14742. }
  14743. }, {
  14744. key: "resume",
  14745. value: function () {
  14746. var _resume = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4() {
  14747. var e;
  14748. return regenerator.wrap(function _callee4$(_context4) {
  14749. while (1) {
  14750. switch (_context4.prev = _context4.next) {
  14751. case 0:
  14752. this._setFPS(this.room.sceneManager), this.room.sceneManager.cameraComponent.cameraFovChange(this.room.sceneManager.yuvInfo), logger$1.info("Invoke room.resume to render");
  14753. e = this._createAssetList(this.room.skin);
  14754. _context4.next = 4;
  14755. return this.loadAssets(e, "");
  14756. case 4:
  14757. case "end":
  14758. return _context4.stop();
  14759. }
  14760. }
  14761. }, _callee4, this);
  14762. }));
  14763. function resume() {
  14764. return _resume.apply(this, arguments);
  14765. }
  14766. return resume;
  14767. }()
  14768. }, {
  14769. key: "setEnv",
  14770. value: function setEnv(e) {
  14771. var r;
  14772. this.lightManager || (this.lightManager = this.room.sceneManager.lightComponent), e = e || this.room.skin;
  14773. var t = ModelManager.findModel(e.models, AssetTypeName.Config, AssetClassName.Env);
  14774. return t ? (r = this.lightManager) == null ? void 0 : r.setIBL(t.modelUrl) : (logger$1.error("env file not found"), Promise.resolve());
  14775. }
  14776. }, {
  14777. key: "_parseModelsAndLoad",
  14778. value: function () {
  14779. var _parseModelsAndLoad2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(e, t, r) {
  14780. var n, o, a, u, c, h, _c, s, l, _u, _c2, _h;
  14781. return regenerator.wrap(function _callee5$(_context5) {
  14782. while (1) {
  14783. switch (_context5.prev = _context5.next) {
  14784. case 0:
  14785. logger$1.info("Invoke _parseModelsAndLoad start", t);
  14786. n = ["airship", "balloon", "default", "ground_feiting", "ground_reqiqiu"], o = new Map();
  14787. r == null && (r = "xxxx");
  14788. a = !0;
  14789. u = 0;
  14790. case 5:
  14791. if (!(u < e.length)) {
  14792. _context5.next = 20;
  14793. break;
  14794. }
  14795. a = !0;
  14796. c = 0;
  14797. case 8:
  14798. if (!(c < n.length)) {
  14799. _context5.next = 16;
  14800. break;
  14801. }
  14802. if (!(e[u].modelUrl.toLowerCase().indexOf(n[c]) >= 0)) {
  14803. _context5.next = 13;
  14804. break;
  14805. }
  14806. h = o.get(n[c]);
  14807. h ? (h.push(e[u]), o.set(n[c], h)) : o.set(n[c], [e[u]]), a = !1;
  14808. return _context5.abrupt("break", 16);
  14809. case 13:
  14810. ++c;
  14811. _context5.next = 8;
  14812. break;
  14813. case 16:
  14814. if (a) {
  14815. _c = o.get("default");
  14816. _c ? (_c.push(e[u]), o.set("default", _c)) : o.set("default", [e[u]]);
  14817. }
  14818. case 17:
  14819. ++u;
  14820. _context5.next = 5;
  14821. break;
  14822. case 20:
  14823. s = o.get(t) || [];
  14824. if (!(this.room.viewMode === "simple" && (s = s.filter(function (u) {
  14825. return !u.modelUrl.endsWith("zip");
  14826. })), !s)) {
  14827. _context5.next = 23;
  14828. break;
  14829. }
  14830. return _context5.abrupt("return", Promise.reject("no invalid scene model with group name: ".concat(t)));
  14831. case 23:
  14832. l = [];
  14833. for (_u = 0; _u < s.length; ++_u) {
  14834. _c2 = s[_u];
  14835. if (_c2.modelUrl.toLowerCase().endsWith("zip")) _c2.modelUrl.toLowerCase().endsWith("zip") && l.push(this.room.sceneManager.addNewLowPolyMesh({
  14836. url: _c2.modelUrl,
  14837. skinInfo: r
  14838. }));else {
  14839. _h = t;
  14840. l.push(this.room.sceneManager.addNewLowPolyMesh({
  14841. url: _c2.modelUrl,
  14842. group: _h,
  14843. pick: !0,
  14844. skinInfo: r
  14845. }));
  14846. }
  14847. }
  14848. return _context5.abrupt("return", Promise.all(l));
  14849. case 26:
  14850. case "end":
  14851. return _context5.stop();
  14852. }
  14853. }
  14854. }, _callee5, this);
  14855. }));
  14856. function _parseModelsAndLoad(_x4, _x5, _x6) {
  14857. return _parseModelsAndLoad2.apply(this, arguments);
  14858. }
  14859. return _parseModelsAndLoad;
  14860. }()
  14861. }, {
  14862. key: "_deleteAssetsLowpolyModel",
  14863. value: function () {
  14864. var _deleteAssetsLowpolyModel2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e) {
  14865. var t;
  14866. return regenerator.wrap(function _callee6$(_context6) {
  14867. while (1) {
  14868. switch (_context6.prev = _context6.next) {
  14869. case 0:
  14870. this.room.sceneManager.staticmeshComponent.deleteMeshesBySkinInfo(e), this.room.sceneManager.breathPointComponent.clearBreathPointsBySkinInfo(e), this.room.sceneManager.decalComponent.deleteDecalBySkinInfo(e);
  14871. t = [];
  14872. this.room.sceneManager.Scene.meshes.forEach(function (r) {
  14873. r.xskinInfo == e && t.push(r);
  14874. }), t.forEach(function (r) {
  14875. r.dispose(!1, !1);
  14876. });
  14877. case 3:
  14878. case "end":
  14879. return _context6.stop();
  14880. }
  14881. }
  14882. }, _callee6, this);
  14883. }));
  14884. function _deleteAssetsLowpolyModel(_x7) {
  14885. return _deleteAssetsLowpolyModel2.apply(this, arguments);
  14886. }
  14887. return _deleteAssetsLowpolyModel;
  14888. }()
  14889. }, {
  14890. key: "loadLandAssets",
  14891. value: function () {
  14892. var _loadLandAssets = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7() {
  14893. var _this2 = this;
  14894. var e;
  14895. return regenerator.wrap(function _callee7$(_context7) {
  14896. while (1) {
  14897. switch (_context7.prev = _context7.next) {
  14898. case 0:
  14899. e = this._createAssetList(this.room.skin);
  14900. return _context7.abrupt("return", this.loadAssets(e, this.room.skinId).catch(function () {
  14901. return _this2.loadAssets(e, _this2.room.skinId);
  14902. }));
  14903. case 2:
  14904. case "end":
  14905. return _context7.stop();
  14906. }
  14907. }
  14908. }, _callee7, this);
  14909. }));
  14910. function loadLandAssets() {
  14911. return _loadLandAssets.apply(this, arguments);
  14912. }
  14913. return loadLandAssets;
  14914. }()
  14915. }, {
  14916. key: "loadAssets",
  14917. value: function () {
  14918. var _loadAssets2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8(e) {
  14919. var t,
  14920. r,
  14921. n,
  14922. _args8 = arguments;
  14923. return regenerator.wrap(function _callee8$(_context8) {
  14924. while (1) {
  14925. switch (_context8.prev = _context8.next) {
  14926. case 0:
  14927. t = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : "";
  14928. r = _args8.length > 2 && _args8[2] !== undefined ? _args8[2] : 8e3;
  14929. n = Date.now();
  14930. return _context8.abrupt("return", this._loadAssets(e, t)._timeout(r, new InitEngineTimeoutError("loadAssets timeout(".concat(r, "ms)"))).then(function (o) {
  14931. return logger$1.infoAndReportMeasurement({
  14932. tag: "loadAssets",
  14933. startTime: n,
  14934. metric: "loadAssets"
  14935. }), o;
  14936. }).catch(function (o) {
  14937. return logger$1.infoAndReportMeasurement({
  14938. tag: "loadAssets",
  14939. startTime: n,
  14940. metric: "loadAssets",
  14941. error: o
  14942. }), Promise.reject(o);
  14943. }));
  14944. case 4:
  14945. case "end":
  14946. return _context8.stop();
  14947. }
  14948. }
  14949. }, _callee8, this);
  14950. }));
  14951. function loadAssets(_x8) {
  14952. return _loadAssets2.apply(this, arguments);
  14953. }
  14954. return loadAssets;
  14955. }()
  14956. }, {
  14957. key: "_loadAssets",
  14958. value: function () {
  14959. var _loadAssets3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9(e) {
  14960. var t,
  14961. r,
  14962. _args9 = arguments;
  14963. return regenerator.wrap(function _callee9$(_context9) {
  14964. while (1) {
  14965. switch (_context9.prev = _context9.next) {
  14966. case 0:
  14967. t = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : "";
  14968. _context9.prev = 1;
  14969. r = [];
  14970. r.push(this._loadAssetsLowpolyModel(e, t));
  14971. _context9.next = 6;
  14972. return Promise.all(r);
  14973. case 6:
  14974. _context9.next = 8;
  14975. return this.setEnv();
  14976. case 8:
  14977. this._checkSceneDurationFrameNum = EngineProxy._CHECK_DURATION;
  14978. this._checkSceneNotReadyCount = 0;
  14979. this._checkSceneFrameCount = 0;
  14980. this.updateAnimationList();
  14981. this.room.loadAssetsHook();
  14982. _context9.next = 18;
  14983. break;
  14984. case 15:
  14985. _context9.prev = 15;
  14986. _context9.t0 = _context9["catch"](1);
  14987. return _context9.abrupt("return", Promise.reject(_context9.t0));
  14988. case 18:
  14989. case "end":
  14990. return _context9.stop();
  14991. }
  14992. }
  14993. }, _callee9, this, [[1, 15]]);
  14994. }));
  14995. function _loadAssets(_x9) {
  14996. return _loadAssets3.apply(this, arguments);
  14997. }
  14998. return _loadAssets;
  14999. }()
  15000. }, {
  15001. key: "updateAnimationList",
  15002. value: function updateAnimationList() {
  15003. var _this3 = this;
  15004. if (this.room.avatarManager && this.room.avatarManager.xAvatarManager) {
  15005. var e = this.room.skin.animationList;
  15006. if (!e) return;
  15007. e.forEach(function (t) {
  15008. _this3.room.avatarManager.xAvatarManager.updateAnimationLists(t.animations, t.avatarId);
  15009. });
  15010. }
  15011. }
  15012. }, {
  15013. key: "_loadAssetsLowpolyModel",
  15014. value: function () {
  15015. var _loadAssetsLowpolyModel2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee11(e) {
  15016. var _this4 = this;
  15017. var t,
  15018. r,
  15019. n,
  15020. o,
  15021. a,
  15022. s,
  15023. u,
  15024. c,
  15025. h,
  15026. _args11 = arguments;
  15027. return regenerator.wrap(function _callee11$(_context11) {
  15028. while (1) {
  15029. switch (_context11.prev = _context11.next) {
  15030. case 0:
  15031. t = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : "";
  15032. r = [], n = [], o = [];
  15033. e.lowPolyModels.forEach(function (f) {
  15034. f.group === "TV" ? n.push({
  15035. id: "",
  15036. name: "",
  15037. thumbnailUrl: "",
  15038. typeName: AssetTypeName.Model,
  15039. className: AssetClassName.Tv,
  15040. modelUrl: f.url
  15041. }) : f.group === "\u544A\u767D\u5899" ? o.push({
  15042. id: "",
  15043. name: "",
  15044. thumbnailUrl: "",
  15045. typeName: AssetTypeName.Model,
  15046. className: AssetClassName.Lpm,
  15047. modelUrl: f.url
  15048. }) : r.push({
  15049. id: "",
  15050. name: "",
  15051. thumbnailUrl: "",
  15052. typeName: AssetTypeName.Model,
  15053. className: AssetClassName.Lpm,
  15054. modelUrl: f.url
  15055. });
  15056. }), t != "" && t != null && this._deleteAssetsLowpolyModel(t);
  15057. a = e.skinId;
  15058. logger$1.info("====> from ", t, " to ", a), this._tvs.forEach(function (f) {
  15059. return f.clean();
  15060. }), this._tvs = [];
  15061. s = EFitMode.cover;
  15062. a == "10048" && (s = EFitMode.contain), Array.isArray(n) && n.forEach(function (f, d) {
  15063. _this4._tvs.push(new TV("squareTv" + d, f.modelUrl, _this4.room, {
  15064. fitMode: s
  15065. }));
  15066. }), e.breathPointsConfig.forEach( /*#__PURE__*/function () {
  15067. var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10(f) {
  15068. var d;
  15069. return regenerator.wrap(function _callee10$(_context10) {
  15070. while (1) {
  15071. switch (_context10.prev = _context10.next) {
  15072. case 0:
  15073. _context10.prev = 0;
  15074. _context10.next = 3;
  15075. return urlTransformer(f.imageUrl);
  15076. case 3:
  15077. d = _context10.sent;
  15078. _context10.next = 9;
  15079. break;
  15080. case 6:
  15081. _context10.prev = 6;
  15082. _context10.t0 = _context10["catch"](0);
  15083. d = f.imageUrl, logger$1.error("urlTransformer error", _context10.t0);
  15084. case 9:
  15085. _this4.room.breathPointManager.addBreathPoint({
  15086. id: f.id,
  15087. position: f.position,
  15088. spriteSheet: d,
  15089. rotation: f.rotation || {
  15090. pitch: 0,
  15091. yaw: 270,
  15092. roll: 0
  15093. },
  15094. billboardMode: !0,
  15095. type: f.type || "no_type",
  15096. spriteWidthNumber: f.spriteWidthNum || 1,
  15097. spriteHeightNumber: f.spriteHeightNum || 1,
  15098. maxVisibleRegion: f.maxVisibleRegion || 150,
  15099. width: f.width,
  15100. height: f.height,
  15101. skinInfo: f.skinId
  15102. });
  15103. case 10:
  15104. case "end":
  15105. return _context10.stop();
  15106. }
  15107. }
  15108. }, _callee10, null, [[0, 6]]);
  15109. }));
  15110. return function (_x11) {
  15111. return _ref3.apply(this, arguments);
  15112. };
  15113. }()), o.forEach(function (f) {
  15114. _this4.room.sceneManager.decalComponent.addDecal({
  15115. id: f.id || "gbq",
  15116. meshPath: f.modelUrl,
  15117. skinInfo: a
  15118. });
  15119. });
  15120. u = this.room.sceneManager.staticmeshComponent.lowModel_group, c = Array.from(u.keys()).filter(function (f) {
  15121. return !f.startsWith("region_");
  15122. }), h = ["airship", "balloon", "ground_feiting", "ground_reqiqiu", "default"];
  15123. return _context11.abrupt("return", new Promise(function (f, d) {
  15124. Promise.all(h.map(function (_) {
  15125. return _this4._parseModelsAndLoad(r, _, a);
  15126. })).then(function () {
  15127. var _ = !1;
  15128. r.forEach(function (v) {
  15129. v.modelUrl.endsWith("zip") && (_ = !0);
  15130. }), _ == !1 && _this4.room.sceneManager.staticmeshComponent.deleteLastRegionMesh(), _this4.room.sceneManager.staticmeshComponent.lowModel_group;
  15131. var g = Array.from(u.keys()).filter(function (v) {
  15132. return !v.startsWith("region_");
  15133. }),
  15134. m = c.filter(function (v) {
  15135. return g.indexOf(v) < 0;
  15136. });
  15137. m.length > 0 && m.forEach(function (v) {
  15138. _this4.room.sceneManager.staticmeshComponent.deleteMeshesByGroup(v);
  15139. }), f(!0);
  15140. }).catch(function (_) {
  15141. d(_);
  15142. });
  15143. }));
  15144. case 9:
  15145. case "end":
  15146. return _context11.stop();
  15147. }
  15148. }
  15149. }, _callee11, this);
  15150. }));
  15151. function _loadAssetsLowpolyModel(_x10) {
  15152. return _loadAssetsLowpolyModel2.apply(this, arguments);
  15153. }
  15154. return _loadAssetsLowpolyModel;
  15155. }()
  15156. }, {
  15157. key: "_updateSkinAssets",
  15158. value: function () {
  15159. var _updateSkinAssets2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee12(e) {
  15160. var t, r, n;
  15161. return regenerator.wrap(function _callee12$(_context12) {
  15162. while (1) {
  15163. switch (_context12.prev = _context12.next) {
  15164. case 0:
  15165. t = this.room.lastSkinId;
  15166. _context12.next = 3;
  15167. return this.room.getSkin(e);
  15168. case 3:
  15169. r = _context12.sent;
  15170. n = this._createAssetList(r);
  15171. _context12.prev = 5;
  15172. _context12.next = 8;
  15173. return this.loadAssets(n, t);
  15174. case 8:
  15175. this.room.updateCurrentState({
  15176. versionId: r.versionId,
  15177. skinId: r.id,
  15178. skin: r
  15179. });
  15180. _context12.next = 16;
  15181. break;
  15182. case 11:
  15183. _context12.prev = 11;
  15184. _context12.t0 = _context12["catch"](5);
  15185. _context12.next = 15;
  15186. return this.loadAssets(n, t);
  15187. case 15:
  15188. this.room.updateCurrentState({
  15189. versionId: r.versionId,
  15190. skinId: r.id,
  15191. skin: r
  15192. });
  15193. case 16:
  15194. this.setEnv(r);
  15195. case 17:
  15196. case "end":
  15197. return _context12.stop();
  15198. }
  15199. }
  15200. }, _callee12, this, [[5, 11]]);
  15201. }));
  15202. function _updateSkinAssets(_x12) {
  15203. return _updateSkinAssets2.apply(this, arguments);
  15204. }
  15205. return _updateSkinAssets;
  15206. }()
  15207. }, {
  15208. key: "_createAssetList",
  15209. value: function _createAssetList(e) {
  15210. var t = [],
  15211. r = [],
  15212. n = [];
  15213. var o = e.models;
  15214. var a = this.room.modelManager.config.preload;
  15215. return this.room.viewMode === "simple" ? a && (o = a.baseUrls.map(function (l) {
  15216. return l.modelUrl = l.url, l;
  15217. })) : this.room.viewMode, ModelManager.findModels(o, AssetTypeName.Effects, AssetClassName.Effects).forEach(function (l) {
  15218. t.push({
  15219. url: l.modelUrl,
  15220. group: l.className,
  15221. name: l.name
  15222. });
  15223. }), ModelManager.findModels(o, AssetTypeName.Model, AssetClassName.Lpm).forEach(function (l) {
  15224. r.push({
  15225. url: l.modelUrl,
  15226. group: l.className
  15227. });
  15228. }), ModelManager.findModels(o, AssetTypeName.Model, AssetClassName.Gbq).forEach(function (l) {
  15229. r.push({
  15230. url: l.modelUrl,
  15231. group: l.className
  15232. });
  15233. }), ModelManager.findModels(o, AssetTypeName.Model, AssetClassName.Tv).forEach(function (l) {
  15234. r.push({
  15235. url: l.modelUrl,
  15236. group: l.className
  15237. });
  15238. }), [].forEach(function (l) {
  15239. l.skinId == e.id && n.push(l);
  15240. }), {
  15241. roomId: this.room.id,
  15242. effects: t,
  15243. lowPolyModels: r,
  15244. breathPointsConfig: n,
  15245. skinId: e.id
  15246. };
  15247. }
  15248. }, {
  15249. key: "registerStats",
  15250. value: function registerStats() {
  15251. var _this5 = this;
  15252. var e = this.room.sceneManager;
  15253. this.room.scene.registerAfterRender(function () {
  15254. var I;
  15255. var t = e.statisticComponent.getInterFrameTimeCounter(),
  15256. r = e.statisticComponent.getDrawCall(),
  15257. n = e.statisticComponent.getActiveFaces(),
  15258. o = e.statisticComponent.getFrameTimeCounter(),
  15259. a = e.statisticComponent.getDrawCallTime(),
  15260. s = e.statisticComponent.getAnimationTime(),
  15261. l = e.statisticComponent.getActiveMeshEvaluationTime(),
  15262. u = e.statisticComponent.getRenderTargetRenderTime(),
  15263. c = e.statisticComponent.getRegisterBeforeRenderTime(),
  15264. h = e.statisticComponent.getRegisterAfterRenderTime(),
  15265. f = e.statisticComponent.getActiveParticles(),
  15266. d = e.statisticComponent.getActiveBones(),
  15267. _ = e.Scene._activeAnimatables.length,
  15268. g = e.statisticComponent.getTotalRootNodes(),
  15269. m = e.Scene.geometries.length,
  15270. v = e.Scene.onBeforeRenderObservable.observers.length,
  15271. y = e.Scene.onAfterRenderObservable.observers.length,
  15272. b = e.statisticComponent.getTotalMeshes(),
  15273. T = e.statisticComponent.getTotalTextures(),
  15274. C = e.statisticComponent.getTotalMaterials(),
  15275. A = e.statisticComponent.getSystemInfo(),
  15276. S = A.resolution,
  15277. P = A.driver;
  15278. A.vender;
  15279. var R = A.version,
  15280. M = A.hardwareScalingLevel,
  15281. x = S + "_" + P + "_" + R + "_" + M;
  15282. _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({
  15283. renderFrameTime: _this5.renderTimeCircularArray.getAvg(),
  15284. maxRenderFrameTime: _this5.renderTimeCircularArray.getMax(),
  15285. interFrameTime: _this5.interFrameCircularArray.getAvg(),
  15286. animationTime: _this5.animationCircularArray.getAvg(),
  15287. meshSelectTime: _this5.meshSelectCircularArray.getAvg(),
  15288. drawcallTime: _this5.drawCallTimeCircularArray.getAvg(),
  15289. idleTime: _this5._idleTime,
  15290. registerBeforeRenderTime: _this5.regBeforeRenderCircularArray.getAvg(),
  15291. registerAfterRenderTime: _this5.regAfterRenderCircularArray.getAvg(),
  15292. renderTargetRenderTime: _this5.renderTargetCircularArray.getAvg(),
  15293. fps: (1e3 / (_this5.renderTimeCircularArray.getAvg() + _this5.interFrameCircularArray.getAvg())).toFixed(2),
  15294. drawcall: _this5.drawCallCntCircularArray.getAvg(),
  15295. triangle: n.toString(),
  15296. engineSloppyCnt: _this5.engineSloppyCnt,
  15297. maxInterFrameTime: _this5.interFrameCircularArray.getMax(),
  15298. maxDrawcallTime: _this5.drawCallTimeCircularArray.getMax(),
  15299. maxMeshSelectTime: _this5.meshSelectCircularArray.getMax(),
  15300. maxAnimationTime: _this5.animationCircularArray.getMax(),
  15301. maxRegisterBeforeRenderTime: _this5.regBeforeRenderCircularArray.getMax(),
  15302. maxRegisterAfterRenderTime: _this5.regAfterRenderCircularArray.getMax(),
  15303. maxRenderTargetRenderTime: _this5.renderTargetCircularArray.getMax(),
  15304. activeParticles: f,
  15305. activeBones: d,
  15306. activeAnimation: _,
  15307. totalMeshes: b,
  15308. totalRootNodes: g,
  15309. totalGeometries: m,
  15310. totalTextures: T,
  15311. totalMaterials: C,
  15312. registerBeforeCount: v,
  15313. registerAfterCount: y,
  15314. hardwareInfo: x
  15315. }));
  15316. });
  15317. }
  15318. }, {
  15319. key: "updateBillboard",
  15320. value: function () {
  15321. var _updateBillboard = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee13() {
  15322. var e, r, n, o, a, s;
  15323. return regenerator.wrap(function _callee13$(_context13) {
  15324. while (1) {
  15325. switch (_context13.prev = _context13.next) {
  15326. case 0:
  15327. e = this.room.options.skinId;
  15328. _context13.next = 3;
  15329. return this.room.modelManager.findAssetList(e);
  15330. case 3:
  15331. r = _context13.sent.filter(function (a) {
  15332. return a.typeName === AssetTypeName.Textures && a.className === AssetClassName.SayBubble;
  15333. });
  15334. n = ["bubble01", "bubble02", "bubble03"];
  15335. o = ["bubble01_npc", "bubble02_npc", "bubble03_npc"];
  15336. if (r.length) {
  15337. a = r.filter(function (l) {
  15338. return n.includes(l.name);
  15339. }).map(function (l) {
  15340. return l.url;
  15341. }), s = r.filter(function (l) {
  15342. return o.includes(l.name);
  15343. }).map(function (l) {
  15344. return l.url;
  15345. });
  15346. a.length && (XBillboardManager$1.userBubbleUrls = a), s.length && (XBillboardManager$1.npcBubbleUrls = s);
  15347. }
  15348. case 7:
  15349. case "end":
  15350. return _context13.stop();
  15351. }
  15352. }
  15353. }, _callee13, this);
  15354. }));
  15355. function updateBillboard() {
  15356. return _updateBillboard.apply(this, arguments);
  15357. }
  15358. return updateBillboard;
  15359. }()
  15360. }]);
  15361. return EngineProxy;
  15362. }();
  15363. 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); }; }
  15364. 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; } }
  15365. var LongPressMesh = [EMeshType.XAvatar];
  15366. var StaticMeshEvent = /*#__PURE__*/function (_EventEmitter) {
  15367. _inherits(StaticMeshEvent, _EventEmitter);
  15368. var _super = _createSuper$2(StaticMeshEvent);
  15369. function StaticMeshEvent(e) {
  15370. var _this;
  15371. _classCallCheck(this, StaticMeshEvent);
  15372. _this = _super.call(this);
  15373. E(_assertThisInitialized(_this), "scene");
  15374. E(_assertThisInitialized(_this), "_staringPointerTime", -1);
  15375. E(_assertThisInitialized(_this), "_pickedMeshID", "0");
  15376. E(_assertThisInitialized(_this), "_pointerDownTime", -1);
  15377. E(_assertThisInitialized(_this), "_currentPickPoint");
  15378. E(_assertThisInitialized(_this), "_longPressDelay", 500);
  15379. E(_assertThisInitialized(_this), "_pointerTapDelay", 200);
  15380. E(_assertThisInitialized(_this), "_pickedMeshType");
  15381. E(_assertThisInitialized(_this), "registerEvent", function () {
  15382. _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 () {
  15383. _this.scene.onPrePointerObservable.removeCallback(_this.onUp), _this.scene.onPrePointerObservable.removeCallback(_this.onDown), _this.scene.onPrePointerObservable.removeCallback(_this.onDoubleTap);
  15384. };
  15385. });
  15386. E(_assertThisInitialized(_this), "onUp", function () {
  15387. if (Date.now() - _this._pointerDownTime < _this._pointerTapDelay && !_this.scene._inputManager._isPointerSwiping()) {
  15388. _this.scene._inputManager._totalPointersPressed = 0;
  15389. var _e = _this._currentPickPoint;
  15390. _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) {
  15391. return t.isPickable && LongPressMesh.indexOf(t.xtype) == -1;
  15392. }), _e != null && _this.emit("pointTap", _e));
  15393. }
  15394. });
  15395. E(_assertThisInitialized(_this), "onDown", function () {
  15396. var e = _this.onPointerTap(function (t) {
  15397. return t.isPickable;
  15398. });
  15399. _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 () {
  15400. e = _this.onPointerTap(function (t) {
  15401. return t.isPickable && t.xtype == _this._pickedMeshType && t.xid == _this._pickedMeshID;
  15402. }), e !== null && Date.now() - _this._staringPointerTime > _this._longPressDelay && !_this.scene._inputManager._isPointerSwiping() && _this.scene._inputManager._totalPointersPressed !== 0 && (_this._staringPointerTime = 0, _this.emit("longPress", e));
  15403. }, _this._longPressDelay));
  15404. });
  15405. E(_assertThisInitialized(_this), "onDoubleTap", function () {
  15406. var e = _this.onPointerTap(void 0);
  15407. e != null && _this.emit("pointDoubleTap", e);
  15408. });
  15409. _this.manager = e, _this.scene = e.Scene, _this.registerEvent(), _this._currentPickPoint = null, _this._pickedMeshType = null;
  15410. return _this;
  15411. }
  15412. _createClass(StaticMeshEvent, [{
  15413. key: "onPointerTap",
  15414. value: function onPointerTap(e) {
  15415. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
  15416. var n, o;
  15417. var r = new BABYLON.PickingInfo();
  15418. if (t) {
  15419. var a = this.scene.multiPick(this.scene.pointerX, this.scene.pointerY, e, void 0, void 0);
  15420. a && a.length > 1 ? r = a[1] : a && (r = a[0]);
  15421. } else r = this.scene.pick(this.scene.pointerX, this.scene.pointerY, e, !1, null);
  15422. if (r.hit) {
  15423. var _a = (n = r == null ? void 0 : r.pickedPoint) == null ? void 0 : n.asArray();
  15424. if (_a) {
  15425. var _a2 = _slicedToArray(_a, 3),
  15426. s = _a2[0],
  15427. l = _a2[1],
  15428. u = _a2[2],
  15429. c = xversePosition2Ue4({
  15430. x: s,
  15431. y: l,
  15432. z: u
  15433. });
  15434. return {
  15435. name: (o = r.pickedMesh) == null ? void 0 : o.name,
  15436. type: r.pickedMesh.xtype,
  15437. id: r.pickedMesh.xid,
  15438. point: c
  15439. };
  15440. }
  15441. }
  15442. return null;
  15443. }
  15444. }]);
  15445. return StaticMeshEvent;
  15446. }(EventEmitter);
  15447. var RotationEvent = /*#__PURE__*/function () {
  15448. function RotationEvent(e) {
  15449. var _this = this;
  15450. _classCallCheck(this, RotationEvent);
  15451. E(this, "touchStartX");
  15452. E(this, "touchStartY");
  15453. E(this, "handelResize");
  15454. E(this, "_room");
  15455. E(this, "_canvas");
  15456. E(this, "handleTouchStart", function (e) {
  15457. var t = e.touches[0];
  15458. _this.touchStartX = t.pageX, _this.touchStartY = t.pageY, _this._room.emit("touchStart", {
  15459. event: e
  15460. });
  15461. });
  15462. E(this, "handleMouseDown", function (e) {
  15463. _this.touchStartX = e.pageX, _this.touchStartY = e.pageY;
  15464. });
  15465. E(this, "handleMouseMove", function (e) {
  15466. if (!_this.touchStartX || !_this.touchStartY) return;
  15467. var t = e.pageX,
  15468. r = e.pageY,
  15469. n = t - _this.touchStartX,
  15470. o = r - _this.touchStartY,
  15471. a = _this._room.options.canvas.offsetHeight,
  15472. s = _this._room.options.canvas.offsetWidth;
  15473. var l = 2 * o / a,
  15474. u = 2 * n / s;
  15475. l > 1 && (l = 1), u > 1 && (u = 1), _this._room.actionsHandler.rotate({
  15476. pitch: l,
  15477. yaw: u
  15478. }), _this.touchStartX = t, _this.touchStartY = r;
  15479. });
  15480. E(this, "handleMouseUp", function () {
  15481. _this.touchStartX = void 0, _this.touchStartY = void 0;
  15482. });
  15483. E(this, "handleTouchMove", function (e) {
  15484. if (!_this.touchStartX || !_this.touchStartY) return;
  15485. var t = e.touches[0],
  15486. r = t.pageX,
  15487. n = t.pageY,
  15488. o = r - _this.touchStartX,
  15489. a = n - _this.touchStartY,
  15490. s = _this._room.options.canvas.offsetHeight,
  15491. l = _this._room.options.canvas.offsetWidth;
  15492. var u = 2 * a / s,
  15493. c = 2 * o / l;
  15494. u > 1 && (u = 1), c > 1 && (c = 1), _this._room.actionsHandler.rotate({
  15495. pitch: u,
  15496. yaw: c
  15497. }), _this.touchStartX = r, _this.touchStartY = n, _this._room.emit("touchMove", {
  15498. pitch: u,
  15499. yaw: c,
  15500. event: e
  15501. });
  15502. });
  15503. E(this, "handleTouchEnd", function (e) {
  15504. _this._room.emit("touchEnd", {
  15505. event: e
  15506. });
  15507. });
  15508. this._room = e, this._canvas = e.canvas, this.handelResize = this.reiszeChange();
  15509. }
  15510. _createClass(RotationEvent, [{
  15511. key: "init",
  15512. value: function init() {
  15513. 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);
  15514. }
  15515. }, {
  15516. key: "clear",
  15517. value: function clear() {
  15518. 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);
  15519. }
  15520. }, {
  15521. key: "reiszeChange",
  15522. value: function reiszeChange() {
  15523. window.addEventListener("resize", function () {});
  15524. }
  15525. }]);
  15526. return RotationEvent;
  15527. }();
  15528. var EventsController = /*#__PURE__*/function () {
  15529. function EventsController(e) {
  15530. var _this = this;
  15531. _classCallCheck(this, EventsController);
  15532. E(this, "staticmeshEvent");
  15533. E(this, "rotationEvent");
  15534. E(this, "resize", function () {
  15535. _this.room.sceneManager.cameraComponent.cameraFovChange(_this.room.sceneManager.yuvInfo);
  15536. });
  15537. E(this, "clickEvent", function (e) {
  15538. var t = e.point,
  15539. r = e.name,
  15540. n = e.type,
  15541. o = e.id;
  15542. logger$1.debug("pointEvent", e), _this.room.proxyEvents("pointTap", {
  15543. point: t,
  15544. meshName: r,
  15545. type: n,
  15546. id: o
  15547. }), _this.room.proxyEvents("_coreClick", e);
  15548. });
  15549. E(this, "longPressEvent", function (e) {
  15550. _this.room.proxyEvents("_corePress", e);
  15551. });
  15552. E(this, "handleActionResponseTimeout", function (_ref) {
  15553. var e = _ref.error,
  15554. t = _ref.event;
  15555. _this.room.proxyEvents("actionResponseTimeout", {
  15556. error: e,
  15557. event: t
  15558. });
  15559. });
  15560. E(this, "handleNetworkStateChange", function (e) {
  15561. var t = e.state,
  15562. r = e.count;
  15563. t == "reconnecting" ? _this.room.proxyEvents("reconnecting", {
  15564. count: r || 1
  15565. }) : t === "reconnected" ? (_this.room.networkController.rtcp.workers.reset(), _this.room.proxyEvents("reconnected"), _this.room.afterReconnected()) : t === "disconnected" && _this.room.proxyEvents("disconnected");
  15566. });
  15567. this.room = e, this.staticmeshEvent = new StaticMeshEvent(this.room.sceneManager), this.rotationEvent = new RotationEvent(e);
  15568. }
  15569. _createClass(EventsController, [{
  15570. key: "bindEvents",
  15571. value: function bindEvents() {
  15572. 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);
  15573. }
  15574. }, {
  15575. key: "clearEvents",
  15576. value: function clearEvents() {
  15577. 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();
  15578. }
  15579. }]);
  15580. return EventsController;
  15581. }();
  15582. var Panorama = /*#__PURE__*/function () {
  15583. function Panorama(e) {
  15584. var _this = this;
  15585. _classCallCheck(this, Panorama);
  15586. E(this, "_actived", !1);
  15587. E(this, "handleReceivePanorama", /*#__PURE__*/function () {
  15588. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e, t) {
  15589. var r, n, _this$room$currentSta, o, a, s, _ref2, l;
  15590. return regenerator.wrap(function _callee$(_context) {
  15591. while (1) {
  15592. switch (_context.prev = _context.next) {
  15593. case 0:
  15594. logger$1.warn("handle panorama", e.uuid, e.pos, e.finished);
  15595. r = {
  15596. data: e.data,
  15597. pose: {
  15598. position: e.pos
  15599. }
  15600. }, n = _this.room.sceneManager;
  15601. _this.room.networkController.rtcp.workers.changePanoMode(!0);
  15602. _context.next = 5;
  15603. return n.materialComponent.changePanoImg(0, r);
  15604. case 5:
  15605. if (!e.finished) {
  15606. _context.next = 23;
  15607. break;
  15608. }
  15609. _context.next = 8;
  15610. return n.changePanoShaderForLowModel(0);
  15611. case 8:
  15612. _this.room.isPano = !0;
  15613. _this._actived = !0;
  15614. if (!t) {
  15615. _context.next = 14;
  15616. break;
  15617. }
  15618. _this.room.sceneManager.cameraComponent.changeToFirstPersonView({
  15619. position: t.position,
  15620. rotation: t.angle
  15621. });
  15622. _context.next = 23;
  15623. break;
  15624. case 14:
  15625. _this$room$currentSta = _this.room.currentState, o = _this$room$currentSta.skinId, a = _this$room$currentSta.pathName;
  15626. if (!(!o || !a)) {
  15627. _context.next = 17;
  15628. break;
  15629. }
  15630. return _context.abrupt("return");
  15631. case 17:
  15632. _context.next = 19;
  15633. return _this.room.modelManager.findRoute(o, a);
  15634. case 19:
  15635. s = _context.sent;
  15636. _ref2 = util.getRandomItem(s.birthPointList) || {};
  15637. l = _ref2.camera;
  15638. l && _this.room.sceneManager.cameraComponent.changeToFirstPersonView(le(oe({}, l), {
  15639. rotation: l.angle
  15640. }));
  15641. case 23:
  15642. case "end":
  15643. return _context.stop();
  15644. }
  15645. }
  15646. }, _callee);
  15647. }));
  15648. return function (_x, _x2) {
  15649. return _ref.apply(this, arguments);
  15650. };
  15651. }());
  15652. this.room = e;
  15653. }
  15654. _createClass(Panorama, [{
  15655. key: "actived",
  15656. get: function get() {
  15657. return this._actived;
  15658. }
  15659. }, {
  15660. key: "bindListener",
  15661. value: function bindListener(e) {
  15662. var _this2 = this;
  15663. this.room.networkController.rtcp.workers.registerFunction("panorama", function (r) {
  15664. 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));
  15665. });
  15666. }
  15667. }, {
  15668. key: "access",
  15669. value: function access(e, t, r) {
  15670. var _this3 = this;
  15671. var n = e.camera,
  15672. o = e.player,
  15673. a = e.attitude,
  15674. s = e.areaName,
  15675. l = e.pathName,
  15676. u = e.tag;
  15677. return this.room.actionsHandler.requestPanorama({
  15678. camera: n,
  15679. player: o,
  15680. attitude: a,
  15681. areaName: s,
  15682. pathName: l,
  15683. tag: u
  15684. }, t, r).then(function (c) {
  15685. return _this3.handleReceivePanorama(c, o);
  15686. });
  15687. }
  15688. }, {
  15689. key: "exit",
  15690. value: function exit(e) {
  15691. var _this4 = this;
  15692. var t = e.camera,
  15693. r = e.player,
  15694. n = e.attitude,
  15695. o = e.areaName,
  15696. a = e.pathName;
  15697. return this.room.networkController.rtcp.workers.changePanoMode(!1), this.room.actionsHandler.changeRotationRenderType({
  15698. renderType: RenderType.RotationVideo,
  15699. player: r,
  15700. camera: t,
  15701. attitude: n,
  15702. areaName: o,
  15703. pathName: a
  15704. }).then(function () {
  15705. return _this4.handleExitPanorama();
  15706. }).catch(function (s) {
  15707. return _this4.room.networkController.rtcp.workers.changePanoMode(!0), Promise.reject(s);
  15708. });
  15709. }
  15710. }, {
  15711. key: "handleExitPanorama",
  15712. value: function handleExitPanorama() {
  15713. var e, t, r, n, o, a;
  15714. this.room.isPano = !1, this._actived = !1, (n = (e = this.room.sceneManager) == null ? void 0 : e.cameraComponent) == null || n.forceChangeSavedCameraPose({
  15715. position: (t = this.room._currentClickingState) == null ? void 0 : t.camera.position,
  15716. rotation: (r = this.room._currentClickingState) == null ? void 0 : r.camera.angle
  15717. }), this.room.sceneManager.changeVideoShaderForLowModel(), (a = (o = this.room.sceneManager) == null ? void 0 : o.cameraComponent) == null || a.changeToThirdPersonView();
  15718. }
  15719. }]);
  15720. return Panorama;
  15721. }();
  15722. var BREATH_POINT_TYPE = "debugBreathPoint",
  15723. TAP_BREATH_POINT_TYPE = "debugTapBreathPoint",
  15724. DEFAULT_SEARCH_RANGE = 1e3;
  15725. var Debug = /*#__PURE__*/function () {
  15726. function Debug(e) {
  15727. _classCallCheck(this, Debug);
  15728. E(this, "isShowNearbyBreathPoints", !1);
  15729. E(this, "isShowTapBreathPoints", !1);
  15730. E(this, "isSceneShading", !0);
  15731. E(this, "searchRange", DEFAULT_SEARCH_RANGE);
  15732. E(this, "nearbyBreathPointListening", !1);
  15733. E(this, "tapBreathPointListening", !1);
  15734. E(this, "dumpStreamTimer", 0);
  15735. this.room = e;
  15736. }
  15737. _createClass(Debug, [{
  15738. key: "toggleStats",
  15739. value: function toggleStats() {
  15740. return this.room.stats.isShow ? this.room.stats.hide() : this.room.stats.show();
  15741. }
  15742. }, {
  15743. key: "toggleNearbyBreathPoint",
  15744. value: function toggleNearbyBreathPoint() {
  15745. var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_SEARCH_RANGE;
  15746. this.searchRange = e, this.isShowNearbyBreathPoints = !this.isShowNearbyBreathPoints, this.isShowNearbyBreathPoints ? (this.getPointsAndRender(), this.setupNearbyBreathPointListener()) : this.room.breathPointManager.clearBreathPoints(BREATH_POINT_TYPE);
  15747. }
  15748. }, {
  15749. key: "toggleTapBreathPoint",
  15750. value: function toggleTapBreathPoint() {
  15751. this.isShowTapBreathPoints = !this.isShowTapBreathPoints, this.isShowTapBreathPoints ? this.setupTapPointListener() : this.room.breathPointManager.clearBreathPoints(TAP_BREATH_POINT_TYPE);
  15752. }
  15753. }, {
  15754. key: "dumpStream",
  15755. value: function dumpStream(e) {
  15756. var _this = this;
  15757. var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10 * 1e3;
  15758. if (this.dumpStreamTimer) throw new Error("dumpStream running");
  15759. this.room.networkController.rtcp.workers.saveframe = !0, this.dumpStreamTimer = window.setTimeout(function () {
  15760. _this.room.networkController.rtcp.workers.SaveMediaStream = !0, _this.dumpStreamTimer = 0, e && e();
  15761. }, t);
  15762. }
  15763. }, {
  15764. key: "toggleSceneshading",
  15765. value: function toggleSceneshading() {
  15766. this.isSceneShading = !this.isSceneShading, this.isSceneShading ? this.room.sceneManager.changeVideoShaderForLowModel() : this.room.sceneManager.changeDefaultShaderForLowModel();
  15767. }
  15768. }, {
  15769. key: "setupTapPointListener",
  15770. value: function setupTapPointListener() {
  15771. var _this2 = this;
  15772. this.tapBreathPointListening || (this.tapBreathPointListening = !0, this.room.on("_coreClick", function (_ref) {
  15773. var e = _ref.point;
  15774. _this2.isShowTapBreathPoints && _this2.renderTapBreathPoint({
  15775. id: "tapToint",
  15776. position: e
  15777. });
  15778. }));
  15779. }
  15780. }, {
  15781. key: "renderTapBreathPoint",
  15782. value: function renderTapBreathPoint(_ref2) {
  15783. var e = _ref2.position,
  15784. t = _ref2.id;
  15785. var r;
  15786. if (r = this.room.breathPointManager.breathPoints.get(t)) {
  15787. r.position = e;
  15788. return;
  15789. }
  15790. this.room.breathPointManager.addBreathPoint({
  15791. id: t,
  15792. position: e,
  15793. type: TAP_BREATH_POINT_TYPE,
  15794. size: .8,
  15795. forceLeaveGround: !0,
  15796. billboardMode: !0,
  15797. rotation: Math.abs(e.z) < 20 ? {
  15798. pitch: 90,
  15799. yaw: 0,
  15800. roll: 0
  15801. } : {
  15802. pitch: 0,
  15803. yaw: 270,
  15804. roll: 0
  15805. }
  15806. });
  15807. }
  15808. }, {
  15809. key: "setupNearbyBreathPointListener",
  15810. value: function setupNearbyBreathPointListener() {
  15811. var _this3 = this;
  15812. var e;
  15813. this.nearbyBreathPointListening || (this.nearbyBreathPointListening = !0, (e = this.room._userAvatar) == null || e.on("stopMoving", function () {
  15814. _this3.isShowNearbyBreathPoints && _this3.getPointsAndRender();
  15815. }));
  15816. }
  15817. }, {
  15818. key: "getPointsAndRender",
  15819. value: function () {
  15820. var _getPointsAndRender = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  15821. var _this4 = this;
  15822. var r, n, e, t;
  15823. return regenerator.wrap(function _callee$(_context) {
  15824. while (1) {
  15825. switch (_context.prev = _context.next) {
  15826. case 0:
  15827. e = this.searchRange;
  15828. _context.t1 = (r = this.room._userAvatar) == null ? void 0 : r.position;
  15829. if (!_context.t1) {
  15830. _context.next = 6;
  15831. break;
  15832. }
  15833. _context.next = 5;
  15834. return this.getNeighborPoints({
  15835. point: (n = this.room._userAvatar) == null ? void 0 : n.position,
  15836. containSelf: !0,
  15837. searchRange: e
  15838. });
  15839. case 5:
  15840. _context.t1 = _context.sent;
  15841. case 6:
  15842. _context.t0 = _context.t1;
  15843. if (_context.t0) {
  15844. _context.next = 9;
  15845. break;
  15846. }
  15847. _context.t0 = [];
  15848. case 9:
  15849. t = _context.t0;
  15850. this.room.breathPointManager.breathPoints.forEach(function (o) {
  15851. !!t.find(function (s) {
  15852. return JSON.stringify(s) === o._id;
  15853. }) || _this4.room.breathPointManager.clearBreathPoints(o._id);
  15854. }), t.forEach(function (o) {
  15855. var a = JSON.stringify(o);
  15856. _this4.room.breathPointManager.breathPoints.get(a) || _this4.room.breathPointManager.addBreathPoint({
  15857. id: a,
  15858. position: o,
  15859. type: BREATH_POINT_TYPE,
  15860. rotation: {
  15861. pitch: 90,
  15862. yaw: 0,
  15863. roll: 0
  15864. },
  15865. forceLeaveGround: !0
  15866. });
  15867. });
  15868. case 11:
  15869. case "end":
  15870. return _context.stop();
  15871. }
  15872. }
  15873. }, _callee, this);
  15874. }));
  15875. function getPointsAndRender() {
  15876. return _getPointsAndRender.apply(this, arguments);
  15877. }
  15878. return getPointsAndRender;
  15879. }()
  15880. }, {
  15881. key: "getNeighborPoints",
  15882. value: function getNeighborPoints(e) {
  15883. var t = e.point,
  15884. _e$containSelf = e.containSelf,
  15885. r = _e$containSelf === void 0 ? !1 : _e$containSelf,
  15886. _e$searchRange = e.searchRange,
  15887. n = _e$searchRange === void 0 ? 500 : _e$searchRange;
  15888. return this.room.actionsHandler.getNeighborPoints({
  15889. point: t,
  15890. containSelf: r,
  15891. searchRange: n
  15892. });
  15893. }
  15894. }]);
  15895. return Debug;
  15896. }();
  15897. 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); }; }
  15898. 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; } }
  15899. var Xverse_Room = /*#__PURE__*/function (_EventEmitter) {
  15900. _inherits(Xverse_Room, _EventEmitter);
  15901. var _super = _createSuper$1(Xverse_Room);
  15902. function Xverse_Room(e) {
  15903. var _this;
  15904. _classCallCheck(this, Xverse_Room);
  15905. _this = _super.call(this);
  15906. E(_assertThisInitialized(_this), "disableAutoTurn", !1);
  15907. E(_assertThisInitialized(_this), "options");
  15908. E(_assertThisInitialized(_this), "_currentNetworkOptions");
  15909. E(_assertThisInitialized(_this), "lastSkinId");
  15910. E(_assertThisInitialized(_this), "debug");
  15911. E(_assertThisInitialized(_this), "isFirstDataUsed", !1);
  15912. E(_assertThisInitialized(_this), "userId", null);
  15913. E(_assertThisInitialized(_this), "pathManager", new PathManager());
  15914. E(_assertThisInitialized(_this), "networkController");
  15915. E(_assertThisInitialized(_this), "_startTime", Date.now());
  15916. E(_assertThisInitialized(_this), "canvas");
  15917. E(_assertThisInitialized(_this), "modelManager");
  15918. E(_assertThisInitialized(_this), "eventsController");
  15919. E(_assertThisInitialized(_this), "panorama");
  15920. E(_assertThisInitialized(_this), "engineProxy");
  15921. E(_assertThisInitialized(_this), "_id");
  15922. E(_assertThisInitialized(_this), "skinList", []);
  15923. E(_assertThisInitialized(_this), "isHost", !1);
  15924. E(_assertThisInitialized(_this), "avatarManager", new XverseAvatarManager(_assertThisInitialized(_this)));
  15925. E(_assertThisInitialized(_this), "effectManager", new XverseEffectManager(_assertThisInitialized(_this)));
  15926. E(_assertThisInitialized(_this), "sceneManager");
  15927. E(_assertThisInitialized(_this), "scene");
  15928. E(_assertThisInitialized(_this), "breathPointManager");
  15929. E(_assertThisInitialized(_this), "_currentState");
  15930. E(_assertThisInitialized(_this), "joined", !1);
  15931. E(_assertThisInitialized(_this), "disableRotate", !1);
  15932. E(_assertThisInitialized(_this), "isPano", !1);
  15933. E(_assertThisInitialized(_this), "movingByClick", !0);
  15934. E(_assertThisInitialized(_this), "camera", new Camera(_assertThisInitialized(_this)));
  15935. E(_assertThisInitialized(_this), "stats", new Stats(_assertThisInitialized(_this)));
  15936. E(_assertThisInitialized(_this), "isUpdatedRawYUVData", !1);
  15937. E(_assertThisInitialized(_this), "actionsHandler", new ActionsHandler(_assertThisInitialized(_this)));
  15938. E(_assertThisInitialized(_this), "_currentClickingState", null);
  15939. E(_assertThisInitialized(_this), "signal", new Signal(_assertThisInitialized(_this)));
  15940. E(_assertThisInitialized(_this), "firstFrameTimestamp");
  15941. E(_assertThisInitialized(_this), "receiveRtcData", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  15942. var e, t, r, n;
  15943. return regenerator.wrap(function _callee$(_context) {
  15944. while (1) {
  15945. switch (_context.prev = _context.next) {
  15946. case 0:
  15947. logger$1.info("Invoke receiveRtcData");
  15948. e = !1, t = !1, r = !1, n = !1;
  15949. return _context.abrupt("return", _this.viewMode === "serverless" ? (logger$1.warn("set view mode to serverless"), _this.setViewMode("observer").then(function () {
  15950. return _assertThisInitialized(_this);
  15951. }, function () {
  15952. return _assertThisInitialized(_this);
  15953. })) : new Promise(function (o) {
  15954. var a = _this.networkController.rtcp.workers;
  15955. a.registerFunction("signal", function (s) {
  15956. _this.signal.handleSignal(s);
  15957. }), a.registerFunction("stream", function (s) {
  15958. var l;
  15959. if (_this.emit("streamTimestamp", {
  15960. timestamp: Date.now()
  15961. }), t || (t = !0, logger$1.info("Invoke stream event")), s.stream) {
  15962. r || (r = !0, logger$1.info("Invoke updateRawYUVData")), _this.isUpdatedRawYUVData = !1;
  15963. var u = (l = _this._currentState.skin) == null ? void 0 : l.fov;
  15964. _this.sceneManager.materialComponent.updateRawYUVData(s.stream, s.width, s.height, u), _this.isUpdatedRawYUVData = !0;
  15965. }
  15966. e || (logger$1.info("Invoke isAfterRenderRegistered"), e = !0, _this.scene.registerAfterRender(function () {
  15967. _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()));
  15968. }));
  15969. }), _this.panorama.bindListener(function () {
  15970. o(_assertThisInitialized(_this)), _this.afterJoinRoom();
  15971. }), a.registerFunction("reconnectedFrame", function () {}), logger$1.info("Invoke decoderWorker.postMessage"), a.decoderWorker.postMessage({
  15972. t: 5
  15973. });
  15974. }));
  15975. case 3:
  15976. case "end":
  15977. return _context.stop();
  15978. }
  15979. }
  15980. }, _callee);
  15981. })));
  15982. E(_assertThisInitialized(_this), "moveToExtra", "");
  15983. _this.options = e, _this.options.wsServerUrl || (_this.options.wsServerUrl = SERVER_URLS.DEV), _this.modelManager = ModelManager.getInstance(e.appId, e.releaseId), _this.updateReporter();
  15984. var n = e;
  15985. n.canvas;
  15986. var r = Oe(n, ["canvas"]);
  15987. logger$1.infoAndReportMeasurement({
  15988. metric: "startJoinRoomAt",
  15989. startTime: Date.now(),
  15990. group: "joinRoom",
  15991. extra: r,
  15992. value: 0
  15993. });
  15994. return _this;
  15995. }
  15996. _createClass(Xverse_Room, [{
  15997. key: "currentNetworkOptions",
  15998. get: function get() {
  15999. return this._currentNetworkOptions;
  16000. }
  16001. }, {
  16002. key: "viewMode",
  16003. get: function get() {
  16004. var e;
  16005. return ((e = this._currentState) == null ? void 0 : e.viewMode) || "full";
  16006. }
  16007. }, {
  16008. key: "id",
  16009. get: function get() {
  16010. return this._id;
  16011. }
  16012. }, {
  16013. key: "skinId",
  16014. get: function get() {
  16015. return this._currentState.skinId;
  16016. }
  16017. }, {
  16018. key: "skin",
  16019. get: function get() {
  16020. return this._currentState.skin;
  16021. }
  16022. }, {
  16023. key: "sessionId",
  16024. get: function get() {
  16025. return this.currentNetworkOptions.sessionId;
  16026. }
  16027. }, {
  16028. key: "pictureQualityLevel",
  16029. get: function get() {
  16030. return this.currentState.pictureQualityLevel;
  16031. }
  16032. }, {
  16033. key: "avatars",
  16034. get: function get() {
  16035. return Array.from(this.avatarManager.avatars.values());
  16036. }
  16037. }, {
  16038. key: "currentState",
  16039. get: function get() {
  16040. var e;
  16041. return le(oe({}, this._currentState), {
  16042. state: (e = this.networkController) == null ? void 0 : e._state
  16043. });
  16044. }
  16045. }, {
  16046. key: "_userAvatar",
  16047. get: function get() {
  16048. var _this2 = this;
  16049. return this.avatars.find(function (e) {
  16050. return e.userId === _this2.userId;
  16051. });
  16052. }
  16053. }, {
  16054. key: "tvs",
  16055. get: function get() {
  16056. return this.engineProxy._tvs;
  16057. }
  16058. }, {
  16059. key: "tv",
  16060. get: function get() {
  16061. return this.tvs[0];
  16062. }
  16063. }, {
  16064. key: "currentClickingState",
  16065. get: function get() {
  16066. return this._currentClickingState;
  16067. }
  16068. }, {
  16069. key: "afterJoinRoomHook",
  16070. value: function afterJoinRoomHook() {}
  16071. }, {
  16072. key: "beforeJoinRoomResolveHook",
  16073. value: function beforeJoinRoomResolveHook() {}
  16074. }, {
  16075. key: "afterReconnectedHook",
  16076. value: function afterReconnectedHook() {}
  16077. }, {
  16078. key: "handleSignalHook",
  16079. value: function handleSignalHook(e) {}
  16080. }, {
  16081. key: "skinChangedHook",
  16082. value: function skinChangedHook() {}
  16083. }, {
  16084. key: "beforeStartGameHook",
  16085. value: function () {
  16086. var _beforeStartGameHook = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e) {
  16087. return regenerator.wrap(function _callee2$(_context2) {
  16088. while (1) {
  16089. switch (_context2.prev = _context2.next) {
  16090. case 0:
  16091. case "end":
  16092. return _context2.stop();
  16093. }
  16094. }
  16095. }, _callee2);
  16096. }));
  16097. function beforeStartGameHook(_x) {
  16098. return _beforeStartGameHook.apply(this, arguments);
  16099. }
  16100. return beforeStartGameHook;
  16101. }()
  16102. }, {
  16103. key: "loadAssetsHook",
  16104. value: function loadAssetsHook() {}
  16105. }, {
  16106. key: "afterUserAvatarLoadedHook",
  16107. value: function afterUserAvatarLoadedHook() {}
  16108. }, {
  16109. key: "audienceViewModeHook",
  16110. value: function audienceViewModeHook() {}
  16111. }, {
  16112. key: "setViewModeToObserver",
  16113. value: function setViewModeToObserver() {}
  16114. }, {
  16115. key: "handleVehicleHook",
  16116. value: function handleVehicleHook(e) {}
  16117. }, {
  16118. key: "updateReporter",
  16119. value: function updateReporter() {
  16120. var _this$options = this.options,
  16121. e = _this$options.avatarId,
  16122. t = _this$options.skinId,
  16123. r = _this$options.userId,
  16124. n = _this$options.roomId,
  16125. o = _this$options.role,
  16126. a = _this$options.appId,
  16127. s = _this$options.wsServerUrl;
  16128. reporter$1.updateHeader({
  16129. userId: r
  16130. }), reporter$1.updateBody({
  16131. roomId: n,
  16132. role: o,
  16133. skinId: t,
  16134. avatarId: e,
  16135. appId: a,
  16136. wsServerUrl: s
  16137. });
  16138. }
  16139. }, {
  16140. key: "initRoom",
  16141. value: function () {
  16142. var _initRoom2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
  16143. var _this$options$timeout, e;
  16144. return regenerator.wrap(function _callee3$(_context3) {
  16145. while (1) {
  16146. switch (_context3.prev = _context3.next) {
  16147. case 0:
  16148. _this$options$timeout = this.options.timeout, e = _this$options$timeout === void 0 ? DEFAULT_JOINROOM_TIMEOUT : _this$options$timeout;
  16149. if (!util.isSupported()) {
  16150. _context3.next = 5;
  16151. break;
  16152. }
  16153. return _context3.abrupt("return", this._initRoom()._timeout(e, new TimeoutError("initRoom timeout")));
  16154. case 5:
  16155. return _context3.abrupt("return", Promise.reject(new UnsupportedError()));
  16156. case 6:
  16157. case "end":
  16158. return _context3.stop();
  16159. }
  16160. }
  16161. }, _callee3, this);
  16162. }));
  16163. function initRoom() {
  16164. return _initRoom2.apply(this, arguments);
  16165. }
  16166. return initRoom;
  16167. }()
  16168. }, {
  16169. key: "_initRoom",
  16170. value: function () {
  16171. var _initRoom3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4() {
  16172. 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;
  16173. return regenerator.wrap(function _callee4$(_context4) {
  16174. while (1) {
  16175. switch (_context4.prev = _context4.next) {
  16176. case 0:
  16177. e = this.validateOptions(this.options);
  16178. if (!e) {
  16179. _context4.next = 3;
  16180. break;
  16181. }
  16182. return _context4.abrupt("return", (logger$1.error("initRoom param error", e), Promise.reject(e)));
  16183. case 3:
  16184. _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;
  16185. this.setCurrentNetworkOptions({
  16186. avatarId: r,
  16187. skinId: n,
  16188. roomId: R,
  16189. userId: o,
  16190. wsServerUrl: a,
  16191. role: s,
  16192. token: l,
  16193. pageSession: u,
  16194. rotationRenderType: c,
  16195. isAllSync: h,
  16196. appId: f,
  16197. camera: d,
  16198. player: _,
  16199. avatarComponents: g,
  16200. nickname: m,
  16201. avatarScale: v,
  16202. firends: y,
  16203. syncByEvent: b,
  16204. areaName: T,
  16205. attitude: C,
  16206. pathName: A,
  16207. person: P,
  16208. roomTypeId: M,
  16209. hasAvatar: x,
  16210. syncToOthers: I,
  16211. prioritySync: w,
  16212. extra: D,
  16213. removeWhenDisconnected: O
  16214. });
  16215. this.userId = o;
  16216. this.canvas = t;
  16217. T && (this.pathManager.currentArea = T);
  16218. this.networkController = new NetworkController(this);
  16219. this.setCurrentState({
  16220. areaName: T,
  16221. pathName: A,
  16222. attitude: C,
  16223. speed: 0,
  16224. viewMode: S,
  16225. state: this.networkController._state,
  16226. skinId: n
  16227. });
  16228. _context4.prev = 10;
  16229. _context4.next = 13;
  16230. return Promise.all([this.initNetwork(), this.initConfig(), this.initWasm()]);
  16231. case 13:
  16232. logger$1.info("network config wasm all ready, start to create game");
  16233. _context4.next = 16;
  16234. return this.requestCreateRoom({
  16235. skinId: n
  16236. });
  16237. case 16:
  16238. F = _context4.sent;
  16239. V = F.routeList.find(function (L) {
  16240. return L.areaName === T;
  16241. });
  16242. N = ((V == null ? void 0 : V.step) || 7.5) * 30;
  16243. this.updateCurrentState({
  16244. skin: F,
  16245. skinId: F.id,
  16246. versionId: F.versionId,
  16247. speed: N
  16248. });
  16249. _context4.next = 22;
  16250. return this.initEngine(F);
  16251. case 22:
  16252. _context4.next = 27;
  16253. break;
  16254. case 24:
  16255. _context4.prev = 24;
  16256. _context4.t0 = _context4["catch"](10);
  16257. return _context4.abrupt("return", Promise.reject(_context4.t0));
  16258. case 27:
  16259. this.beforeJoinRoomResolve();
  16260. return _context4.abrupt("return", this.receiveRtcData());
  16261. case 29:
  16262. case "end":
  16263. return _context4.stop();
  16264. }
  16265. }
  16266. }, _callee4, this, [[10, 24]]);
  16267. }));
  16268. function _initRoom() {
  16269. return _initRoom3.apply(this, arguments);
  16270. }
  16271. return _initRoom;
  16272. }()
  16273. }, {
  16274. key: "beforeJoinRoomResolve",
  16275. value: function beforeJoinRoomResolve() {
  16276. this.setupStats(), this.eventsController = new EventsController(this), this.eventsController.bindEvents(), this.panorama = new Panorama(this), this.beforeJoinRoomResolveHook();
  16277. }
  16278. }, {
  16279. key: "afterJoinRoom",
  16280. value: function afterJoinRoom() {
  16281. this.joined = !0, this.viewMode === "observer" && this.setViewModeToObserver(), logger$1.infoAndReportMeasurement({
  16282. tag: this.viewMode,
  16283. value: this.firstFrameTimestamp - this._startTime,
  16284. startTime: Date.now(),
  16285. metric: "joinRoom"
  16286. }), this.camera.initialFov = this.sceneManager.cameraComponent.getCameraFov(), this.stats.on("stats", function (_ref2) {
  16287. var e = _ref2.stats;
  16288. reporter$1.report("stats", oe({}, e));
  16289. }), this.debug = new Debug(this), this.afterJoinRoomHook();
  16290. }
  16291. }, {
  16292. key: "afterReconnected",
  16293. value: function afterReconnected() {
  16294. this.avatarManager.clearOtherUsers(), this.afterReconnectedHook();
  16295. }
  16296. }, {
  16297. key: "leave",
  16298. value: function leave() {
  16299. var e, t;
  16300. return logger$1.info("Invoke room.leave"), (e = this.eventsController) == null || e.clearEvents(), (t = this.networkController) == null || t.quit(), this;
  16301. }
  16302. }, {
  16303. key: "validateOptions",
  16304. value: function validateOptions(e) {
  16305. var _ref3 = e || {},
  16306. t = _ref3.canvas,
  16307. r = _ref3.avatarId,
  16308. n = _ref3.skinId,
  16309. o = _ref3.userId,
  16310. a = _ref3.role;
  16311. _ref3.roomId;
  16312. var l = _ref3.token,
  16313. u = _ref3.appId;
  16314. _ref3.avatarComponents;
  16315. var h = [];
  16316. t instanceof HTMLCanvasElement || h.push(new ParamError$1("`canvas` must be instanceof of HTMLCanvasElement"));
  16317. (!o || typeof o != "string") && h.push(new ParamError$1("`userId` must be string"));
  16318. (!l || typeof l != "string") && h.push(new ParamError$1("`token` must be string"));
  16319. (!u || typeof u != "string") && h.push(new ParamError$1("`appId` must be string"));
  16320. a == "audience" || (!r || !n) && h.push(new ParamError$1("`avatarId` and `skinId` is required when create room"));
  16321. return h[0];
  16322. }
  16323. }, {
  16324. key: "initNetwork",
  16325. value: function () {
  16326. var _initNetwork = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5() {
  16327. var e;
  16328. return regenerator.wrap(function _callee5$(_context5) {
  16329. while (1) {
  16330. switch (_context5.prev = _context5.next) {
  16331. case 0:
  16332. if (!(this.viewMode === "serverless")) {
  16333. _context5.next = 2;
  16334. break;
  16335. }
  16336. return _context5.abrupt("return", Promise.resolve());
  16337. case 2:
  16338. e = Date.now();
  16339. _context5.prev = 3;
  16340. _context5.next = 6;
  16341. return this.networkController.connect()._timeout(8e3, new InitNetworkTimeoutError());
  16342. case 6:
  16343. logger$1.infoAndReportMeasurement({
  16344. metric: "networkInitAt",
  16345. startTime: this._startTime,
  16346. group: "joinRoom"
  16347. });
  16348. logger$1.infoAndReportMeasurement({
  16349. metric: "networkInitCost",
  16350. startTime: e,
  16351. group: "joinRoom"
  16352. });
  16353. _context5.next = 13;
  16354. break;
  16355. case 10:
  16356. _context5.prev = 10;
  16357. _context5.t0 = _context5["catch"](3);
  16358. throw logger$1.infoAndReportMeasurement({
  16359. metric: "networkInitAt",
  16360. startTime: e,
  16361. group: "joinRoom",
  16362. error: _context5.t0
  16363. }), _context5.t0;
  16364. case 13:
  16365. case "end":
  16366. return _context5.stop();
  16367. }
  16368. }
  16369. }, _callee5, this, [[3, 10]]);
  16370. }));
  16371. function initNetwork() {
  16372. return _initNetwork.apply(this, arguments);
  16373. }
  16374. return initNetwork;
  16375. }()
  16376. }, {
  16377. key: "initConfig",
  16378. value: function () {
  16379. var _initConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6() {
  16380. var e;
  16381. return regenerator.wrap(function _callee6$(_context6) {
  16382. while (1) {
  16383. switch (_context6.prev = _context6.next) {
  16384. case 0:
  16385. e = Date.now();
  16386. _context6.prev = 1;
  16387. _context6.next = 4;
  16388. return this.modelManager.getApplicationConfig()._timeout(8e3, new InitConfigTimeoutError());
  16389. case 4:
  16390. logger$1.infoAndReportMeasurement({
  16391. metric: "configInitAt",
  16392. startTime: this._startTime,
  16393. group: "joinRoom"
  16394. });
  16395. logger$1.infoAndReportMeasurement({
  16396. metric: "configInitCost",
  16397. startTime: e,
  16398. group: "joinRoom"
  16399. });
  16400. _context6.next = 11;
  16401. break;
  16402. case 8:
  16403. _context6.prev = 8;
  16404. _context6.t0 = _context6["catch"](1);
  16405. throw logger$1.infoAndReportMeasurement({
  16406. metric: "configInitAt",
  16407. startTime: e,
  16408. group: "joinRoom",
  16409. error: _context6.t0
  16410. }), _context6.t0;
  16411. case 11:
  16412. case "end":
  16413. return _context6.stop();
  16414. }
  16415. }
  16416. }, _callee6, this, [[1, 8]]);
  16417. }));
  16418. function initConfig() {
  16419. return _initConfig.apply(this, arguments);
  16420. }
  16421. return initConfig;
  16422. }()
  16423. }, {
  16424. key: "initEngine",
  16425. value: function () {
  16426. var _initEngine = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7(e) {
  16427. var t, n;
  16428. return regenerator.wrap(function _callee7$(_context7) {
  16429. while (1) {
  16430. switch (_context7.prev = _context7.next) {
  16431. case 0:
  16432. t = Date.now();
  16433. _context7.prev = 1;
  16434. this.engineProxy = new EngineProxy(this);
  16435. _context7.next = 5;
  16436. return this.engineProxy.initEngine(e);
  16437. case 5:
  16438. logger$1.infoAndReportMeasurement({
  16439. metric: "webglInitAt",
  16440. startTime: this._startTime,
  16441. group: "joinRoom"
  16442. });
  16443. logger$1.infoAndReportMeasurement({
  16444. metric: "webglInitCost",
  16445. startTime: t,
  16446. group: "joinRoom"
  16447. });
  16448. return _context7.abrupt("return");
  16449. case 10:
  16450. _context7.prev = 10;
  16451. _context7.t0 = _context7["catch"](1);
  16452. n = _context7.t0;
  16453. return _context7.abrupt("return", (_context7.t0.code !== Codes.InitEngineTimeout && (n = new InitEngineError()), logger$1.error(_context7.t0), logger$1.infoAndReportMeasurement({
  16454. metric: "webglInitAt",
  16455. startTime: t,
  16456. group: "joinRoom",
  16457. error: n
  16458. }), Promise.reject(n)));
  16459. case 14:
  16460. case "end":
  16461. return _context7.stop();
  16462. }
  16463. }
  16464. }, _callee7, this, [[1, 10]]);
  16465. }));
  16466. function initEngine(_x2) {
  16467. return _initEngine.apply(this, arguments);
  16468. }
  16469. return initEngine;
  16470. }()
  16471. }, {
  16472. key: "initWasm",
  16473. value: function () {
  16474. var _initWasm = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8() {
  16475. var _this3 = this;
  16476. var e;
  16477. return regenerator.wrap(function _callee8$(_context8) {
  16478. while (1) {
  16479. switch (_context8.prev = _context8.next) {
  16480. case 0:
  16481. if (!(this.viewMode === "serverless")) {
  16482. _context8.next = 2;
  16483. break;
  16484. }
  16485. return _context8.abrupt("return", Promise.resolve());
  16486. case 2:
  16487. e = Date.now();
  16488. _context8.prev = 3;
  16489. _context8.next = 6;
  16490. return this.networkController.rtcp.workers.init(this.options.resolution)._timeout(8e3, new InitDecoderTimeoutError());
  16491. case 6:
  16492. this.networkController.rtcp.workers.registerFunction("error", function (t) {
  16493. logger$1.error("decode error", t);
  16494. var r = t.code,
  16495. n = t.message;
  16496. _this3.emit("error", {
  16497. code: r,
  16498. msg: n
  16499. });
  16500. });
  16501. logger$1.infoAndReportMeasurement({
  16502. metric: "wasmInitAt",
  16503. group: "joinRoom",
  16504. startTime: this._startTime
  16505. });
  16506. logger$1.infoAndReportMeasurement({
  16507. metric: "wasmInitCost",
  16508. group: "joinRoom",
  16509. startTime: e
  16510. });
  16511. eventsManager.on("traceId", function (t) {
  16512. _this3.networkController.rtcp.workers.onTraceId(t);
  16513. });
  16514. _context8.next = 15;
  16515. break;
  16516. case 12:
  16517. _context8.prev = 12;
  16518. _context8.t0 = _context8["catch"](3);
  16519. throw logger$1.infoAndReportMeasurement({
  16520. metric: "wasmInitAt",
  16521. group: "joinRoom",
  16522. startTime: e,
  16523. error: _context8.t0
  16524. }), _context8.t0;
  16525. case 15:
  16526. case "end":
  16527. return _context8.stop();
  16528. }
  16529. }
  16530. }, _callee8, this, [[3, 12]]);
  16531. }));
  16532. function initWasm() {
  16533. return _initWasm.apply(this, arguments);
  16534. }
  16535. return initWasm;
  16536. }()
  16537. }, {
  16538. key: "requestCreateRoom",
  16539. value: function () {
  16540. var _requestCreateRoom = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9(_ref4) {
  16541. var e, t, r, _ref5, n, o, _yield$this$networkCo, _r, _n, _o, a, s;
  16542. return regenerator.wrap(function _callee9$(_context9) {
  16543. while (1) {
  16544. switch (_context9.prev = _context9.next) {
  16545. case 0:
  16546. e = _ref4.skinId;
  16547. if (!e) {
  16548. _context9.next = 11;
  16549. break;
  16550. }
  16551. _context9.next = 4;
  16552. return this.getSkin(e);
  16553. case 4:
  16554. t = _context9.sent;
  16555. _context9.next = 7;
  16556. return this.modelManager.findRoute(e, this.options.pathName);
  16557. case 7:
  16558. r = _context9.sent;
  16559. this.updateCurrentNetworkOptions({
  16560. areaName: r.areaName,
  16561. attitude: r.attitude,
  16562. versionId: t.versionId
  16563. });
  16564. _ref5 = util.getRandomItem(r.birthPointList) || this.options, n = _ref5.camera, o = _ref5.player;
  16565. this.options.camera || this.updateCurrentNetworkOptions({
  16566. camera: n
  16567. }), this.options.player || this.updateCurrentNetworkOptions({
  16568. player: o
  16569. });
  16570. case 11:
  16571. if (!(this.viewMode === "serverless")) {
  16572. _context9.next = 13;
  16573. break;
  16574. }
  16575. return _context9.abrupt("return", t);
  16576. case 13:
  16577. _context9.prev = 13;
  16578. _context9.next = 16;
  16579. return this.beforeStartGameHook(this.options);
  16580. case 16:
  16581. _context9.next = 18;
  16582. return this.networkController.startGame();
  16583. case 18:
  16584. _yield$this$networkCo = _context9.sent;
  16585. _r = _yield$this$networkCo.room_id;
  16586. _n = _yield$this$networkCo.data;
  16587. _o = _yield$this$networkCo.session_id;
  16588. this._id = _r;
  16589. a = JSON.parse(_n);
  16590. this.isHost = a.IsHost, e = a.SkinID || e;
  16591. _context9.next = 27;
  16592. return this.getSkin(e);
  16593. case 27:
  16594. s = _context9.sent;
  16595. return _context9.abrupt("return", (this.updateCurrentNetworkOptions({
  16596. roomId: _r,
  16597. sessionId: _o
  16598. }), reporter$1.updateBody({
  16599. roomId: _r,
  16600. skinId: e,
  16601. serverSession: _o
  16602. }), s));
  16603. case 31:
  16604. _context9.prev = 31;
  16605. _context9.t0 = _context9["catch"](13);
  16606. throw logger$1.error("Request create room error", _context9.t0), _context9.t0;
  16607. case 34:
  16608. case "end":
  16609. return _context9.stop();
  16610. }
  16611. }
  16612. }, _callee9, this, [[13, 31]]);
  16613. }));
  16614. function requestCreateRoom(_x3) {
  16615. return _requestCreateRoom.apply(this, arguments);
  16616. }
  16617. return requestCreateRoom;
  16618. }()
  16619. }, {
  16620. key: "pause",
  16621. value: function pause() {
  16622. return this.engineProxy.pause();
  16623. }
  16624. }, {
  16625. key: "resume",
  16626. value: function resume() {
  16627. return this.engineProxy.resume();
  16628. }
  16629. }, {
  16630. key: "reconnect",
  16631. value: function reconnect() {
  16632. this.networkController.reconnect();
  16633. }
  16634. }, {
  16635. key: "setViewMode",
  16636. value: function () {
  16637. var _setViewMode = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10(e) {
  16638. return regenerator.wrap(function _callee10$(_context10) {
  16639. while (1) {
  16640. switch (_context10.prev = _context10.next) {
  16641. case 0:
  16642. case "end":
  16643. return _context10.stop();
  16644. }
  16645. }
  16646. }, _callee10);
  16647. }));
  16648. function setViewMode(_x4) {
  16649. return _setViewMode.apply(this, arguments);
  16650. }
  16651. return setViewMode;
  16652. }()
  16653. }, {
  16654. key: "handleRepetLogin",
  16655. value: function handleRepetLogin() {
  16656. logger$1.warn("receive " + Codes.RepeatLogin + " for repeat login"), this.emit("repeatLogin"), reporter$1.disable(), this.networkController.quit();
  16657. }
  16658. }, {
  16659. key: "setPictureQualityLevel",
  16660. value: function setPictureQualityLevel(e) {
  16661. var t = {
  16662. high: EImageQuality.high,
  16663. low: EImageQuality.low,
  16664. average: EImageQuality.mid
  16665. };
  16666. return this.updateCurrentState({
  16667. pictureQualityLevel: e
  16668. }), this.sceneManager.setImageQuality(t[e]);
  16669. }
  16670. }, {
  16671. key: "getSkin",
  16672. value: function () {
  16673. var _getSkin = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee11(e) {
  16674. var t, n;
  16675. return regenerator.wrap(function _callee11$(_context11) {
  16676. while (1) {
  16677. switch (_context11.prev = _context11.next) {
  16678. case 0:
  16679. t = null;
  16680. _context11.next = 3;
  16681. return this.modelManager.getSkinsList();
  16682. case 3:
  16683. t = (this.skinList = _context11.sent).find(function (n) {
  16684. return n.id === e || n.id === e;
  16685. });
  16686. if (!t) {
  16687. _context11.next = 6;
  16688. break;
  16689. }
  16690. return _context11.abrupt("return", t);
  16691. case 6:
  16692. n = "skin is invalid: skinId: ".concat(e);
  16693. return _context11.abrupt("return", Promise.reject(new ParamError$1(n)));
  16694. case 8:
  16695. case "end":
  16696. return _context11.stop();
  16697. }
  16698. }
  16699. }, _callee11, this);
  16700. }));
  16701. function getSkin(_x5) {
  16702. return _getSkin.apply(this, arguments);
  16703. }
  16704. return getSkin;
  16705. }()
  16706. }, {
  16707. key: "setupStats",
  16708. value: function setupStats() {
  16709. this.stats.assign({
  16710. roomId: this.id,
  16711. userId: this.userId
  16712. }), setInterval(this.engineProxy.updateStats, 1e3);
  16713. }
  16714. }, {
  16715. key: "proxyEvents",
  16716. value: function proxyEvents(e, t) {
  16717. this.emit(e, t);
  16718. }
  16719. }, {
  16720. key: "setCurrentNetworkOptions",
  16721. value: function setCurrentNetworkOptions(e) {
  16722. this._currentNetworkOptions = e;
  16723. }
  16724. }, {
  16725. key: "updateCurrentNetworkOptions",
  16726. value: function updateCurrentNetworkOptions(e) {
  16727. Object.assign(this._currentNetworkOptions, e), Object.assign(this.options, e);
  16728. }
  16729. }, {
  16730. key: "setCurrentState",
  16731. value: function setCurrentState(e) {
  16732. this._currentState = e;
  16733. }
  16734. }, {
  16735. key: "updateCurrentState",
  16736. value: function updateCurrentState(e) {
  16737. e.skinId && (this.lastSkinId = this.currentState.skinId, this.updateCurrentNetworkOptions({
  16738. skinId: e.skinId
  16739. })), e.versionId && this.updateCurrentNetworkOptions({
  16740. versionId: e.versionId
  16741. }), Object.assign(this._currentState, e);
  16742. }
  16743. }]);
  16744. return Xverse_Room;
  16745. }(EventEmitter);
  16746. 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); }; }
  16747. 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; } }
  16748. var XverseRoom = /*#__PURE__*/function (_Xverse_Room) {
  16749. _inherits(XverseRoom, _Xverse_Room);
  16750. var _super = _createSuper(XverseRoom);
  16751. function XverseRoom(e) {
  16752. var _this;
  16753. _classCallCheck(this, XverseRoom);
  16754. _this = _super.call(this, e);
  16755. _this.joyStick = new JoyStick(_assertThisInitialized(_this));
  16756. return _this;
  16757. }
  16758. _createClass(XverseRoom, [{
  16759. key: "afterJoinRoomHook",
  16760. value: function afterJoinRoomHook() {
  16761. this.joyStick.init({});
  16762. }
  16763. }]);
  16764. return XverseRoom;
  16765. }(Xverse_Room);
  16766. var Preload = /*#__PURE__*/function () {
  16767. function Preload(e) {
  16768. _classCallCheck(this, Preload);
  16769. this.config = null;
  16770. this.allKeys = [];
  16771. this.oldResourcesDeleted = !1;
  16772. this.requests = {
  16773. simple: {
  16774. stopped: !0,
  16775. requests: {}
  16776. },
  16777. observer: {
  16778. stopped: !0,
  16779. requests: {}
  16780. },
  16781. full: {
  16782. stopped: !0,
  16783. requests: {}
  16784. }
  16785. };
  16786. this.modelManager = e, this.init(e.appId);
  16787. }
  16788. _createClass(Preload, [{
  16789. key: "init",
  16790. value: function init(e) {
  16791. reporter$1.updateBody({
  16792. appId: e
  16793. });
  16794. }
  16795. }, {
  16796. key: "getConfig",
  16797. value: function () {
  16798. var _getConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
  16799. var _yield$this$modelMana, t;
  16800. return regenerator.wrap(function _callee$(_context) {
  16801. while (1) {
  16802. switch (_context.prev = _context.next) {
  16803. case 0:
  16804. if (!this.config) {
  16805. _context.next = 2;
  16806. break;
  16807. }
  16808. return _context.abrupt("return", this.config);
  16809. case 2:
  16810. _context.next = 4;
  16811. return this.modelManager.requestConfig();
  16812. case 4:
  16813. _yield$this$modelMana = _context.sent;
  16814. t = _yield$this$modelMana.preload;
  16815. return _context.abrupt("return", t ? (this.config = t, Promise.resolve(t)) : Promise.reject("no preload config"));
  16816. case 7:
  16817. case "end":
  16818. return _context.stop();
  16819. }
  16820. }
  16821. }, _callee, this);
  16822. }));
  16823. function getConfig(_x) {
  16824. return _getConfig.apply(this, arguments);
  16825. }
  16826. return getConfig;
  16827. }()
  16828. }, {
  16829. key: "getAllKeys",
  16830. value: function () {
  16831. var _getAllKeys = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  16832. var e, t;
  16833. return regenerator.wrap(function _callee2$(_context2) {
  16834. while (1) {
  16835. switch (_context2.prev = _context2.next) {
  16836. case 0:
  16837. if (!this.allKeys.length) {
  16838. _context2.next = 2;
  16839. break;
  16840. }
  16841. return _context2.abrupt("return", this.allKeys);
  16842. case 2:
  16843. _context2.prev = 2;
  16844. _context2.next = 5;
  16845. return modelTable.getAllKeys();
  16846. case 5:
  16847. e = _context2.sent;
  16848. this.allKeys = e;
  16849. return _context2.abrupt("return", e);
  16850. case 10:
  16851. _context2.prev = 10;
  16852. _context2.t0 = _context2["catch"](2);
  16853. t = "preload getAllKeys error";
  16854. return _context2.abrupt("return", (logger$1.error(t), Promise.reject(t)));
  16855. case 14:
  16856. case "end":
  16857. return _context2.stop();
  16858. }
  16859. }
  16860. }, _callee2, this, [[2, 10]]);
  16861. }));
  16862. function getAllKeys() {
  16863. return _getAllKeys.apply(this, arguments);
  16864. }
  16865. return getAllKeys;
  16866. }()
  16867. }, {
  16868. key: "stop",
  16869. value: function stop(e) {
  16870. e === "serverless" && (e = "observer"), this.requests[e].stopped = !0;
  16871. var t = this.requests[e].requests;
  16872. Object.keys(t).forEach(function (r) {
  16873. http1.canceler.removePending(r), delete t[r];
  16874. });
  16875. }
  16876. }, {
  16877. key: "clearPreload",
  16878. value: function clearPreload(e) {
  16879. this.requests[e].stopped = !1, this.allKeys = [];
  16880. }
  16881. }, {
  16882. key: "start",
  16883. value: function () {
  16884. var _start = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e, t, r) {
  16885. var n, o, a, s, l, u, h, f, _s;
  16886. return regenerator.wrap(function _callee3$(_context3) {
  16887. while (1) {
  16888. switch (_context3.prev = _context3.next) {
  16889. case 0:
  16890. n = Date.now(), o = 0;
  16891. _context3.prev = 1;
  16892. if (!(e === "serverless" && (e = "observer"), !this.requests[e])) {
  16893. _context3.next = 4;
  16894. break;
  16895. }
  16896. return _context3.abrupt("return", Promise.reject(new ParamError("invalid stage name: " + e)));
  16897. case 4:
  16898. this.clearPreload(e);
  16899. _context3.next = 7;
  16900. return this.getConfig(e);
  16901. case 7:
  16902. a = _context3.sent;
  16903. _context3.next = 10;
  16904. return this.getAllKeys();
  16905. case 10:
  16906. s = _context3.sent;
  16907. _context3.prev = 11;
  16908. _context3.next = 14;
  16909. return this.deleteOldResources(a.assetUrls.map(function (d) {
  16910. return d.url;
  16911. }), s);
  16912. case 14:
  16913. _context3.next = 19;
  16914. break;
  16915. case 16:
  16916. _context3.prev = 16;
  16917. _context3.t0 = _context3["catch"](11);
  16918. logger$1.error(_context3.t0);
  16919. case 19:
  16920. l = a.baseUrls, u = a.assetUrls;
  16921. _context3.t1 = e;
  16922. _context3.next = _context3.t1 === "simple" ? 23 : _context3.t1 === "observer" ? 25 : _context3.t1 === "full" ? 27 : 29;
  16923. break;
  16924. case 23:
  16925. h = l;
  16926. return _context3.abrupt("break", 30);
  16927. case 25:
  16928. h = u;
  16929. return _context3.abrupt("break", 30);
  16930. case 27:
  16931. h = u;
  16932. return _context3.abrupt("break", 30);
  16933. case 29:
  16934. h = u;
  16935. case 30:
  16936. f = h.filter(function (d) {
  16937. return !s.includes(d.url);
  16938. });
  16939. r && isFunction(r) && (f = f.filter(r));
  16940. o = f.length;
  16941. logger$1.debug("keysNeedToPreload", f);
  16942. f.length || t && t(h.length, h.length);
  16943. n = Date.now();
  16944. _context3.next = 38;
  16945. return this._preload(e, f, t);
  16946. case 38:
  16947. logger$1.infoAndReportMeasurement({
  16948. tag: e,
  16949. startTime: n,
  16950. metric: "assetsPreload",
  16951. extra: {
  16952. total: o
  16953. }
  16954. });
  16955. return _context3.abrupt("return");
  16956. case 42:
  16957. _context3.prev = 42;
  16958. _context3.t2 = _context3["catch"](1);
  16959. _s = _context3.t2;
  16960. return _context3.abrupt("return", ((this.requests[e].stopped || axios.isCancel(_context3.t2)) && (_s = new PreloadCanceledError()), logger$1.infoAndReportMeasurement({
  16961. tag: e,
  16962. startTime: n,
  16963. metric: "assetsPreload",
  16964. extra: {
  16965. total: o
  16966. },
  16967. error: _s,
  16968. reportOptions: {
  16969. immediate: !0
  16970. }
  16971. }), Promise.reject(_s)));
  16972. case 46:
  16973. case "end":
  16974. return _context3.stop();
  16975. }
  16976. }
  16977. }, _callee3, this, [[1, 42], [11, 16]]);
  16978. }));
  16979. function start(_x2, _x3, _x4) {
  16980. return _start.apply(this, arguments);
  16981. }
  16982. return start;
  16983. }()
  16984. }, {
  16985. key: "deleteOldResources",
  16986. value: function deleteOldResources(e, t) {
  16987. if (!this.oldResourcesDeleted) this.oldResourcesDeleted = !0;else return Promise.resolve();
  16988. var r = t.filter(function (n) {
  16989. return !e.includes(n);
  16990. });
  16991. return logger$1.debug("keysNeedToDelete", r), logger$1.warn("keysNeedToDelete", r.length), Promise.all(r.map(function (n) {
  16992. return modelTable.delete(n);
  16993. }));
  16994. }
  16995. }, {
  16996. key: "_preload",
  16997. value: function () {
  16998. var _preload2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e, t, r) {
  16999. var _this = this;
  17000. var n, o, a;
  17001. return regenerator.wrap(function _callee6$(_context6) {
  17002. while (1) {
  17003. switch (_context6.prev = _context6.next) {
  17004. case 0:
  17005. n = t.length;
  17006. if (n) {
  17007. _context6.next = 3;
  17008. break;
  17009. }
  17010. return _context6.abrupt("return", Promise.resolve());
  17011. case 3:
  17012. o = 0;
  17013. a = window.setInterval(function () {
  17014. r && r(o, n), o >= n && window.clearInterval(a);
  17015. }, 1e3);
  17016. return _context6.abrupt("return", util.mapLimit(t, 10, /*#__PURE__*/function () {
  17017. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(s) {
  17018. var l, u;
  17019. return regenerator.wrap(function _callee5$(_context5) {
  17020. while (1) {
  17021. switch (_context5.prev = _context5.next) {
  17022. case 0:
  17023. l = s.size, u = s.url;
  17024. return _context5.abrupt("return", _this.requests[e].stopped ? Promise.reject(new PreloadCanceledError()) : http1.get({
  17025. url: u,
  17026. timeout: Preload.getTimeoutBySize(l),
  17027. responseType: "blob",
  17028. retry: 2,
  17029. beforeRequest: function beforeRequest() {
  17030. _this.requests[e].requests[u] = !0;
  17031. }
  17032. }).then( /*#__PURE__*/function () {
  17033. var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(c) {
  17034. var h, f;
  17035. return regenerator.wrap(function _callee4$(_context4) {
  17036. while (1) {
  17037. switch (_context4.prev = _context4.next) {
  17038. case 0:
  17039. h = c.data;
  17040. if (h instanceof Blob) {
  17041. _context4.next = 3;
  17042. break;
  17043. }
  17044. return _context4.abrupt("return", (logger$1.error("request blob failed, type:", typeof h, u), Promise.reject("request blob failed " + u)));
  17045. case 3:
  17046. _context4.next = 5;
  17047. return blobToDataURI(h);
  17048. case 5:
  17049. f = _context4.sent;
  17050. _context4.prev = 6;
  17051. _context4.next = 9;
  17052. return modelTable.put({
  17053. url: u,
  17054. model: f
  17055. });
  17056. case 9:
  17057. return _context4.abrupt("return");
  17058. case 12:
  17059. _context4.prev = 12;
  17060. _context4.t0 = _context4["catch"](6);
  17061. return _context4.abrupt("return", (logger$1.error("unable to add data to indexedDB", _context4.t0), Promise.reject(new InternalError("preload db error"))));
  17062. case 15:
  17063. case "end":
  17064. return _context4.stop();
  17065. }
  17066. }
  17067. }, _callee4, null, [[6, 12]]);
  17068. }));
  17069. return function (_x9) {
  17070. return _ref2.apply(this, arguments);
  17071. };
  17072. }()).then(function () {
  17073. o++, delete _this.requests[e].requests[u];
  17074. }, function (c) {
  17075. return delete _this.requests[e].requests[u], window.clearInterval(a), Promise.reject(c);
  17076. }));
  17077. case 2:
  17078. case "end":
  17079. return _context5.stop();
  17080. }
  17081. }
  17082. }, _callee5);
  17083. }));
  17084. return function (_x8) {
  17085. return _ref.apply(this, arguments);
  17086. };
  17087. }()));
  17088. case 6:
  17089. case "end":
  17090. return _context6.stop();
  17091. }
  17092. }
  17093. }, _callee6);
  17094. }));
  17095. function _preload(_x5, _x6, _x7) {
  17096. return _preload2.apply(this, arguments);
  17097. }
  17098. return _preload;
  17099. }()
  17100. }], [{
  17101. key: "getTimeoutBySize",
  17102. value: function getTimeoutBySize(e) {
  17103. return e ? e < 500 * 1e3 ? 30 * 1e3 : e < 1e3 * 1e3 ? 60 * 1e3 : 100 * 1e3 : 100 * 1e3;
  17104. }
  17105. }]);
  17106. return Preload;
  17107. }();
  17108. var RenderType$1 = {
  17109. PathVideo: 0,
  17110. RotationVideo: 1,
  17111. RotationImage: 2,
  17112. PanoramaImage: 3,
  17113. CGVideo: 4,
  17114. ClientRotationPano: 5,
  17115. CloudRotationPano: 6
  17116. };
  17117. var Xverse = /*#__PURE__*/function () {
  17118. function Xverse(e) {
  17119. _classCallCheck(this, Xverse);
  17120. e || (e = {});
  17121. var _e = e,
  17122. t = _e.onLog,
  17123. r = _e.env,
  17124. n = _e.appId,
  17125. o = _e.releaseId,
  17126. a = _e.subPackageVersion;
  17127. this.NO_CACHE = !1, this.env = r || "PROD", this.SUB_PACKAGE_VERSION = a, this.debug && logger$1.setLevel(LoggerLevels.Debug);
  17128. var s = this.pageSession = util.uuid();
  17129. reporter$1.updateHeader({
  17130. pageSession: s
  17131. });
  17132. reporter$1.updateReportUrl(REPORT_URL[this.env]);
  17133. a && reporter$1.updateBody({
  17134. sdkVersion: a
  17135. });
  17136. logger$1.infoAndReportMeasurement({
  17137. metric: "sdkInit",
  17138. startTime: Date.now(),
  17139. extra: {
  17140. version: a,
  17141. enviroment: r,
  17142. pageSession: s
  17143. }
  17144. });
  17145. logger$1.debug("debug mode:", this.debug);
  17146. reporter$1.on("report", function (l) {
  17147. t && t(l);
  17148. });
  17149. if (n) {
  17150. this.appId = n, this.releaseId = o;
  17151. var l = ModelManager.getInstance(n, o);
  17152. this.preload = new Preload(l);
  17153. }
  17154. }
  17155. _createClass(Xverse, [{
  17156. key: "isSupported",
  17157. get: function get() {
  17158. return isSupported();
  17159. }
  17160. }, {
  17161. key: "disableLogUpload",
  17162. value: function disableLogUpload() {
  17163. reporter$1.disable(), logger$1.debug("logger upload has been disabled");
  17164. }
  17165. }, {
  17166. key: "getSkinList",
  17167. value: function () {
  17168. var _getSkinList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  17169. return regenerator.wrap(function _callee$(_context) {
  17170. while (1) {
  17171. switch (_context.prev = _context.next) {
  17172. case 0:
  17173. return _context.abrupt("return", []);
  17174. case 1:
  17175. case "end":
  17176. return _context.stop();
  17177. }
  17178. }
  17179. }, _callee);
  17180. }));
  17181. function getSkinList() {
  17182. return _getSkinList.apply(this, arguments);
  17183. }
  17184. return getSkinList;
  17185. }()
  17186. }, {
  17187. key: "getAvatarList",
  17188. value: function () {
  17189. var _getAvatarList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  17190. return regenerator.wrap(function _callee2$(_context2) {
  17191. while (1) {
  17192. switch (_context2.prev = _context2.next) {
  17193. case 0:
  17194. return _context2.abrupt("return", []);
  17195. case 1:
  17196. case "end":
  17197. return _context2.stop();
  17198. }
  17199. }
  17200. }, _callee2);
  17201. }));
  17202. function getAvatarList() {
  17203. return _getAvatarList.apply(this, arguments);
  17204. }
  17205. return getAvatarList;
  17206. }()
  17207. }, {
  17208. key: "getGiftList",
  17209. value: function () {
  17210. var _getGiftList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
  17211. return regenerator.wrap(function _callee3$(_context3) {
  17212. while (1) {
  17213. switch (_context3.prev = _context3.next) {
  17214. case 0:
  17215. return _context3.abrupt("return", [{
  17216. id: "hack "
  17217. }]);
  17218. case 1:
  17219. case "end":
  17220. return _context3.stop();
  17221. }
  17222. }
  17223. }, _callee3);
  17224. }));
  17225. function getGiftList() {
  17226. return _getGiftList.apply(this, arguments);
  17227. }
  17228. return getGiftList;
  17229. }()
  17230. }, {
  17231. key: "joinRoom",
  17232. value: function () {
  17233. var _joinRoom = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
  17234. var t, r, n, o;
  17235. return regenerator.wrap(function _callee4$(_context4) {
  17236. while (1) {
  17237. switch (_context4.prev = _context4.next) {
  17238. case 0:
  17239. t = e.pathName || "thirdwalk", r = e.rotationRenderType || RenderType$1.RotationVideo, n = e.person || Person.Third, o = new XverseRoom(le(oe({}, e), {
  17240. appId: e.appId || this.appId,
  17241. releaseId: e.releaseId || this.releaseId,
  17242. pageSession: this.pageSession,
  17243. isAllSync: !0,
  17244. rotationRenderType: r,
  17245. syncByEvent: !0,
  17246. pathName: t,
  17247. person: n,
  17248. role: e.role || "audience"
  17249. }));
  17250. return _context4.abrupt("return", o.initRoom().then(function () {
  17251. return o;
  17252. }));
  17253. case 2:
  17254. case "end":
  17255. return _context4.stop();
  17256. }
  17257. }
  17258. }, _callee4, this);
  17259. }));
  17260. function joinRoom(_x) {
  17261. return _joinRoom.apply(this, arguments);
  17262. }
  17263. return joinRoom;
  17264. }()
  17265. }]);
  17266. return Xverse;
  17267. }();
  17268. var xverse = new Xverse({
  17269. env: "DEV",
  17270. appId: "10016",
  17271. releaseId: '2203120033_29769e'
  17272. });
  17273. var l = /*#__PURE__*/function () {
  17274. var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  17275. var R, room;
  17276. return regenerator.wrap(function _callee$(_context) {
  17277. while (1) {
  17278. switch (_context.prev = _context.next) {
  17279. case 0:
  17280. _context.prev = 0;
  17281. _context.next = 3;
  17282. return (R = xverse.preload) == null ? void 0 : R.start('full', function (M, x) {
  17283. });
  17284. case 3:
  17285. _context.next = 12;
  17286. break;
  17287. case 5:
  17288. _context.prev = 5;
  17289. _context.t0 = _context["catch"](0);
  17290. if (!(console.error(_context.t0), _context.t0.code === Codes.PreloadCanceled)) {
  17291. _context.next = 10;
  17292. break;
  17293. }
  17294. toast("\u9884\u52A0\u8F7D\u88AB\u53D6\u6D88");
  17295. return _context.abrupt("return");
  17296. case 10:
  17297. toast("\u8FDB\u5165\u5931\u8D25, \u8BF7\u91CD\u8BD5");
  17298. return _context.abrupt("return");
  17299. case 12:
  17300. _context.prev = 12;
  17301. _context.next = 15;
  17302. return xverse.joinRoom({
  17303. canvas: document.getElementById('canvas'),
  17304. skinId: '10092',
  17305. avatarId: 'KGe_Boy',
  17306. roomId: 'e629ef3e-022d-4e64-8654-703bb96410eb',
  17307. userId: '1f7acca1db9d5',
  17308. wsServerUrl: 'wss://uat-eks.xverse.cn/ws',
  17309. appId: "10016",
  17310. token: " ",
  17311. nickname: '1f7acca1db9d5',
  17312. firends: ["user1"],
  17313. viewMode: "full",
  17314. resolution: {
  17315. width: 1728,
  17316. height: 720
  17317. },
  17318. pathName: 'thirdwalk',
  17319. objectFit: null,
  17320. hasAvatar: !0,
  17321. syncToOthers: !0
  17322. });
  17323. case 15:
  17324. room = _context.sent;
  17325. window.room = room;
  17326. u();
  17327. c(); //e(!1);
  17328. _context.next = 26;
  17329. break;
  17330. case 21:
  17331. _context.prev = 21;
  17332. _context.t1 = _context["catch"](12);
  17333. console.error(_context.t1);
  17334. alert(_context.t1);
  17335. return _context.abrupt("return");
  17336. case 26:
  17337. case "end":
  17338. return _context.stop();
  17339. }
  17340. }
  17341. }, _callee, null, [[0, 5], [12, 21]]);
  17342. }));
  17343. return function l() {
  17344. return _ref.apply(this, arguments);
  17345. };
  17346. }();
  17347. var u = function u() {
  17348. window.room.on("_coreClick", function (_ref2) {
  17349. var f = _ref2.point;
  17350. window.room._userAvatar.moveTo({
  17351. point: f
  17352. });
  17353. });
  17354. };
  17355. var c = function c() {
  17356. window.room.on("repeatLogin", function () {
  17357. toast("\u8BE5\u7528\u6237\u5DF2\u7ECF\u5728\u5176\u4ED6\u5730\u70B9\u767B\u5F55", {
  17358. duration: 1e4
  17359. });
  17360. }), window.room.on("reconnecting", function (_ref3) {
  17361. var f = _ref3.count;
  17362. toast("\u5C1D\u8BD5\u7B2C".concat(f, "\u6B21\u91CD\u8FDE"));
  17363. }), window.room.on("reconnected", function () {
  17364. toast("\u91CD\u8FDE\u6210\u529F");
  17365. }), window.room.on("disconnected", function () {
  17366. var f = toast("\u8FDE\u63A5\u5931\u8D25\uFF0C\u624B\u52A8\u70B9\u51FB\u91CD\u8BD5", {
  17367. duration: 1e5,
  17368. onClick() {
  17369. f.hideToast(), window.room.reconnect();
  17370. }
  17371. });
  17372. });
  17373. };
  17374. l();
  17375. }));
  17376. //# sourceMappingURL=index.js.map