123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251 |
- /**
- * Name: Metaverse
- * Date: 2022/4/11
- * Author: https://www.4dkankan.com
- * Copyright © 2022 4DAGE Co., Ltd. All rights reserved.
- * Licensed under the GLP license
- */
- (function (factory) {
- typeof define === 'function' && define.amd ? define(factory) :
- factory();
- })((function () { 'use strict';
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
- try {
- var info = gen[key](arg);
- var value = info.value;
- } catch (error) {
- reject(error);
- return;
- }
- if (info.done) {
- resolve(value);
- } else {
- Promise.resolve(value).then(_next, _throw);
- }
- }
- function _asyncToGenerator(fn) {
- return function () {
- var self = this,
- args = arguments;
- return new Promise(function (resolve, reject) {
- var gen = fn.apply(self, args);
- function _next(value) {
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
- }
- function _throw(err) {
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
- }
- _next(undefined);
- });
- };
- }
- function createCommonjsModule(fn) {
- var module = { exports: {} };
- return fn(module, module.exports), module.exports;
- }
- /**
- * Copyright (c) 2014-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
- var runtime_1 = createCommonjsModule(function (module) {
- var runtime = (function (exports) {
- var Op = Object.prototype;
- var hasOwn = Op.hasOwnProperty;
- var undefined$1; // More compressible than void 0.
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
- function define(obj, key, value) {
- Object.defineProperty(obj, key, {
- value: value,
- enumerable: true,
- configurable: true,
- writable: true
- });
- return obj[key];
- }
- try {
- // IE 8 has a broken Object.defineProperty that only works on DOM objects.
- define({}, "");
- } catch (err) {
- define = function(obj, key, value) {
- return obj[key] = value;
- };
- }
- function wrap(innerFn, outerFn, self, tryLocsList) {
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
- var generator = Object.create(protoGenerator.prototype);
- var context = new Context(tryLocsList || []);
- // The ._invoke method unifies the implementations of the .next,
- // .throw, and .return methods.
- generator._invoke = makeInvokeMethod(innerFn, self, context);
- return generator;
- }
- exports.wrap = wrap;
- // Try/catch helper to minimize deoptimizations. Returns a completion
- // record like context.tryEntries[i].completion. This interface could
- // have been (and was previously) designed to take a closure to be
- // invoked without arguments, but in all the cases we care about we
- // already have an existing method we want to call, so there's no need
- // to create a new function object. We can even get away with assuming
- // the method takes exactly one argument, since that happens to be true
- // in every case, so we don't have to touch the arguments object. The
- // only additional allocation required is the completion record, which
- // has a stable shape and so hopefully should be cheap to allocate.
- function tryCatch(fn, obj, arg) {
- try {
- return { type: "normal", arg: fn.call(obj, arg) };
- } catch (err) {
- return { type: "throw", arg: err };
- }
- }
- var GenStateSuspendedStart = "suspendedStart";
- var GenStateSuspendedYield = "suspendedYield";
- var GenStateExecuting = "executing";
- var GenStateCompleted = "completed";
- // Returning this object from the innerFn has the same effect as
- // breaking out of the dispatch switch statement.
- var ContinueSentinel = {};
- // Dummy constructor functions that we use as the .constructor and
- // .constructor.prototype properties for functions that return Generator
- // objects. For full spec compliance, you may wish to configure your
- // minifier not to mangle the names of these two functions.
- function Generator() {}
- function GeneratorFunction() {}
- function GeneratorFunctionPrototype() {}
- // This is a polyfill for %IteratorPrototype% for environments that
- // don't natively support it.
- var IteratorPrototype = {};
- define(IteratorPrototype, iteratorSymbol, function () {
- return this;
- });
- var getProto = Object.getPrototypeOf;
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
- if (NativeIteratorPrototype &&
- NativeIteratorPrototype !== Op &&
- hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
- // This environment has a native %IteratorPrototype%; use it instead
- // of the polyfill.
- IteratorPrototype = NativeIteratorPrototype;
- }
- var Gp = GeneratorFunctionPrototype.prototype =
- Generator.prototype = Object.create(IteratorPrototype);
- GeneratorFunction.prototype = GeneratorFunctionPrototype;
- define(Gp, "constructor", GeneratorFunctionPrototype);
- define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
- GeneratorFunction.displayName = define(
- GeneratorFunctionPrototype,
- toStringTagSymbol,
- "GeneratorFunction"
- );
- // Helper for defining the .next, .throw, and .return methods of the
- // Iterator interface in terms of a single ._invoke method.
- function defineIteratorMethods(prototype) {
- ["next", "throw", "return"].forEach(function(method) {
- define(prototype, method, function(arg) {
- return this._invoke(method, arg);
- });
- });
- }
- exports.isGeneratorFunction = function(genFun) {
- var ctor = typeof genFun === "function" && genFun.constructor;
- return ctor
- ? ctor === GeneratorFunction ||
- // For the native GeneratorFunction constructor, the best we can
- // do is to check its .name property.
- (ctor.displayName || ctor.name) === "GeneratorFunction"
- : false;
- };
- exports.mark = function(genFun) {
- if (Object.setPrototypeOf) {
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
- } else {
- genFun.__proto__ = GeneratorFunctionPrototype;
- define(genFun, toStringTagSymbol, "GeneratorFunction");
- }
- genFun.prototype = Object.create(Gp);
- return genFun;
- };
- // Within the body of any async function, `await x` is transformed to
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
- // meant to be awaited.
- exports.awrap = function(arg) {
- return { __await: arg };
- };
- function AsyncIterator(generator, PromiseImpl) {
- function invoke(method, arg, resolve, reject) {
- var record = tryCatch(generator[method], generator, arg);
- if (record.type === "throw") {
- reject(record.arg);
- } else {
- var result = record.arg;
- var value = result.value;
- if (value &&
- typeof value === "object" &&
- hasOwn.call(value, "__await")) {
- return PromiseImpl.resolve(value.__await).then(function(value) {
- invoke("next", value, resolve, reject);
- }, function(err) {
- invoke("throw", err, resolve, reject);
- });
- }
- return PromiseImpl.resolve(value).then(function(unwrapped) {
- // When a yielded Promise is resolved, its final value becomes
- // the .value of the Promise<{value,done}> result for the
- // current iteration.
- result.value = unwrapped;
- resolve(result);
- }, function(error) {
- // If a rejected Promise was yielded, throw the rejection back
- // into the async generator function so it can be handled there.
- return invoke("throw", error, resolve, reject);
- });
- }
- }
- var previousPromise;
- function enqueue(method, arg) {
- function callInvokeWithMethodAndArg() {
- return new PromiseImpl(function(resolve, reject) {
- invoke(method, arg, resolve, reject);
- });
- }
- return previousPromise =
- // If enqueue has been called before, then we want to wait until
- // all previous Promises have been resolved before calling invoke,
- // so that results are always delivered in the correct order. If
- // enqueue has not been called before, then it is important to
- // call invoke immediately, without waiting on a callback to fire,
- // so that the async generator function has the opportunity to do
- // any necessary setup in a predictable way. This predictability
- // is why the Promise constructor synchronously invokes its
- // executor callback, and why async functions synchronously
- // execute code before the first await. Since we implement simple
- // async functions in terms of async generators, it is especially
- // important to get this right, even though it requires care.
- previousPromise ? previousPromise.then(
- callInvokeWithMethodAndArg,
- // Avoid propagating failures to Promises returned by later
- // invocations of the iterator.
- callInvokeWithMethodAndArg
- ) : callInvokeWithMethodAndArg();
- }
- // Define the unified helper method that is used to implement .next,
- // .throw, and .return (see defineIteratorMethods).
- this._invoke = enqueue;
- }
- defineIteratorMethods(AsyncIterator.prototype);
- define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
- return this;
- });
- exports.AsyncIterator = AsyncIterator;
- // Note that simple async functions are implemented on top of
- // AsyncIterator objects; they just return a Promise for the value of
- // the final result produced by the iterator.
- exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
- if (PromiseImpl === void 0) PromiseImpl = Promise;
- var iter = new AsyncIterator(
- wrap(innerFn, outerFn, self, tryLocsList),
- PromiseImpl
- );
- return exports.isGeneratorFunction(outerFn)
- ? iter // If outerFn is a generator, return the full iterator.
- : iter.next().then(function(result) {
- return result.done ? result.value : iter.next();
- });
- };
- function makeInvokeMethod(innerFn, self, context) {
- var state = GenStateSuspendedStart;
- return function invoke(method, arg) {
- if (state === GenStateExecuting) {
- throw new Error("Generator is already running");
- }
- if (state === GenStateCompleted) {
- if (method === "throw") {
- throw arg;
- }
- // Be forgiving, per 25.3.3.3.3 of the spec:
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
- return doneResult();
- }
- context.method = method;
- context.arg = arg;
- while (true) {
- var delegate = context.delegate;
- if (delegate) {
- var delegateResult = maybeInvokeDelegate(delegate, context);
- if (delegateResult) {
- if (delegateResult === ContinueSentinel) continue;
- return delegateResult;
- }
- }
- if (context.method === "next") {
- // Setting context._sent for legacy support of Babel's
- // function.sent implementation.
- context.sent = context._sent = context.arg;
- } else if (context.method === "throw") {
- if (state === GenStateSuspendedStart) {
- state = GenStateCompleted;
- throw context.arg;
- }
- context.dispatchException(context.arg);
- } else if (context.method === "return") {
- context.abrupt("return", context.arg);
- }
- state = GenStateExecuting;
- var record = tryCatch(innerFn, self, context);
- if (record.type === "normal") {
- // If an exception is thrown from innerFn, we leave state ===
- // GenStateExecuting and loop back for another invocation.
- state = context.done
- ? GenStateCompleted
- : GenStateSuspendedYield;
- if (record.arg === ContinueSentinel) {
- continue;
- }
- return {
- value: record.arg,
- done: context.done
- };
- } else if (record.type === "throw") {
- state = GenStateCompleted;
- // Dispatch the exception by looping back around to the
- // context.dispatchException(context.arg) call above.
- context.method = "throw";
- context.arg = record.arg;
- }
- }
- };
- }
- // Call delegate.iterator[context.method](context.arg) and handle the
- // result, either by returning a { value, done } result from the
- // delegate iterator, or by modifying context.method and context.arg,
- // setting context.delegate to null, and returning the ContinueSentinel.
- function maybeInvokeDelegate(delegate, context) {
- var method = delegate.iterator[context.method];
- if (method === undefined$1) {
- // A .throw or .return when the delegate iterator has no .throw
- // method always terminates the yield* loop.
- context.delegate = null;
- if (context.method === "throw") {
- // Note: ["return"] must be used for ES3 parsing compatibility.
- if (delegate.iterator["return"]) {
- // If the delegate iterator has a return method, give it a
- // chance to clean up.
- context.method = "return";
- context.arg = undefined$1;
- maybeInvokeDelegate(delegate, context);
- if (context.method === "throw") {
- // If maybeInvokeDelegate(context) changed context.method from
- // "return" to "throw", let that override the TypeError below.
- return ContinueSentinel;
- }
- }
- context.method = "throw";
- context.arg = new TypeError(
- "The iterator does not provide a 'throw' method");
- }
- return ContinueSentinel;
- }
- var record = tryCatch(method, delegate.iterator, context.arg);
- if (record.type === "throw") {
- context.method = "throw";
- context.arg = record.arg;
- context.delegate = null;
- return ContinueSentinel;
- }
- var info = record.arg;
- if (! info) {
- context.method = "throw";
- context.arg = new TypeError("iterator result is not an object");
- context.delegate = null;
- return ContinueSentinel;
- }
- if (info.done) {
- // Assign the result of the finished delegate to the temporary
- // variable specified by delegate.resultName (see delegateYield).
- context[delegate.resultName] = info.value;
- // Resume execution at the desired location (see delegateYield).
- context.next = delegate.nextLoc;
- // If context.method was "throw" but the delegate handled the
- // exception, let the outer generator proceed normally. If
- // context.method was "next", forget context.arg since it has been
- // "consumed" by the delegate iterator. If context.method was
- // "return", allow the original .return call to continue in the
- // outer generator.
- if (context.method !== "return") {
- context.method = "next";
- context.arg = undefined$1;
- }
- } else {
- // Re-yield the result returned by the delegate method.
- return info;
- }
- // The delegate iterator is finished, so forget it and continue with
- // the outer generator.
- context.delegate = null;
- return ContinueSentinel;
- }
- // Define Generator.prototype.{next,throw,return} in terms of the
- // unified ._invoke helper method.
- defineIteratorMethods(Gp);
- define(Gp, toStringTagSymbol, "Generator");
- // A Generator should always return itself as the iterator object when the
- // @@iterator function is called on it. Some browsers' implementations of the
- // iterator prototype chain incorrectly implement this, causing the Generator
- // object to not be returned from this call. This ensures that doesn't happen.
- // See https://github.com/facebook/regenerator/issues/274 for more details.
- define(Gp, iteratorSymbol, function() {
- return this;
- });
- define(Gp, "toString", function() {
- return "[object Generator]";
- });
- function pushTryEntry(locs) {
- var entry = { tryLoc: locs[0] };
- if (1 in locs) {
- entry.catchLoc = locs[1];
- }
- if (2 in locs) {
- entry.finallyLoc = locs[2];
- entry.afterLoc = locs[3];
- }
- this.tryEntries.push(entry);
- }
- function resetTryEntry(entry) {
- var record = entry.completion || {};
- record.type = "normal";
- delete record.arg;
- entry.completion = record;
- }
- function Context(tryLocsList) {
- // The root entry object (effectively a try statement without a catch
- // or a finally block) gives us a place to store values thrown from
- // locations where there is no enclosing try statement.
- this.tryEntries = [{ tryLoc: "root" }];
- tryLocsList.forEach(pushTryEntry, this);
- this.reset(true);
- }
- exports.keys = function(object) {
- var keys = [];
- for (var key in object) {
- keys.push(key);
- }
- keys.reverse();
- // Rather than returning an object with a next method, we keep
- // things simple and return the next function itself.
- return function next() {
- while (keys.length) {
- var key = keys.pop();
- if (key in object) {
- next.value = key;
- next.done = false;
- return next;
- }
- }
- // To avoid creating an additional object, we just hang the .value
- // and .done properties off the next function object itself. This
- // also ensures that the minifier will not anonymize the function.
- next.done = true;
- return next;
- };
- };
- function values(iterable) {
- if (iterable) {
- var iteratorMethod = iterable[iteratorSymbol];
- if (iteratorMethod) {
- return iteratorMethod.call(iterable);
- }
- if (typeof iterable.next === "function") {
- return iterable;
- }
- if (!isNaN(iterable.length)) {
- var i = -1, next = function next() {
- while (++i < iterable.length) {
- if (hasOwn.call(iterable, i)) {
- next.value = iterable[i];
- next.done = false;
- return next;
- }
- }
- next.value = undefined$1;
- next.done = true;
- return next;
- };
- return next.next = next;
- }
- }
- // Return an iterator with no values.
- return { next: doneResult };
- }
- exports.values = values;
- function doneResult() {
- return { value: undefined$1, done: true };
- }
- Context.prototype = {
- constructor: Context,
- reset: function(skipTempReset) {
- this.prev = 0;
- this.next = 0;
- // Resetting context._sent for legacy support of Babel's
- // function.sent implementation.
- this.sent = this._sent = undefined$1;
- this.done = false;
- this.delegate = null;
- this.method = "next";
- this.arg = undefined$1;
- this.tryEntries.forEach(resetTryEntry);
- if (!skipTempReset) {
- for (var name in this) {
- // Not sure about the optimal order of these conditions:
- if (name.charAt(0) === "t" &&
- hasOwn.call(this, name) &&
- !isNaN(+name.slice(1))) {
- this[name] = undefined$1;
- }
- }
- }
- },
- stop: function() {
- this.done = true;
- var rootEntry = this.tryEntries[0];
- var rootRecord = rootEntry.completion;
- if (rootRecord.type === "throw") {
- throw rootRecord.arg;
- }
- return this.rval;
- },
- dispatchException: function(exception) {
- if (this.done) {
- throw exception;
- }
- var context = this;
- function handle(loc, caught) {
- record.type = "throw";
- record.arg = exception;
- context.next = loc;
- if (caught) {
- // If the dispatched exception was caught by a catch block,
- // then let that catch block handle the exception normally.
- context.method = "next";
- context.arg = undefined$1;
- }
- return !! caught;
- }
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
- var entry = this.tryEntries[i];
- var record = entry.completion;
- if (entry.tryLoc === "root") {
- // Exception thrown outside of any try block that could handle
- // it, so set the completion value of the entire function to
- // throw the exception.
- return handle("end");
- }
- if (entry.tryLoc <= this.prev) {
- var hasCatch = hasOwn.call(entry, "catchLoc");
- var hasFinally = hasOwn.call(entry, "finallyLoc");
- if (hasCatch && hasFinally) {
- if (this.prev < entry.catchLoc) {
- return handle(entry.catchLoc, true);
- } else if (this.prev < entry.finallyLoc) {
- return handle(entry.finallyLoc);
- }
- } else if (hasCatch) {
- if (this.prev < entry.catchLoc) {
- return handle(entry.catchLoc, true);
- }
- } else if (hasFinally) {
- if (this.prev < entry.finallyLoc) {
- return handle(entry.finallyLoc);
- }
- } else {
- throw new Error("try statement without catch or finally");
- }
- }
- }
- },
- abrupt: function(type, arg) {
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
- var entry = this.tryEntries[i];
- if (entry.tryLoc <= this.prev &&
- hasOwn.call(entry, "finallyLoc") &&
- this.prev < entry.finallyLoc) {
- var finallyEntry = entry;
- break;
- }
- }
- if (finallyEntry &&
- (type === "break" ||
- type === "continue") &&
- finallyEntry.tryLoc <= arg &&
- arg <= finallyEntry.finallyLoc) {
- // Ignore the finally entry if control is not jumping to a
- // location outside the try/catch block.
- finallyEntry = null;
- }
- var record = finallyEntry ? finallyEntry.completion : {};
- record.type = type;
- record.arg = arg;
- if (finallyEntry) {
- this.method = "next";
- this.next = finallyEntry.finallyLoc;
- return ContinueSentinel;
- }
- return this.complete(record);
- },
- complete: function(record, afterLoc) {
- if (record.type === "throw") {
- throw record.arg;
- }
- if (record.type === "break" ||
- record.type === "continue") {
- this.next = record.arg;
- } else if (record.type === "return") {
- this.rval = this.arg = record.arg;
- this.method = "return";
- this.next = "end";
- } else if (record.type === "normal" && afterLoc) {
- this.next = afterLoc;
- }
- return ContinueSentinel;
- },
- finish: function(finallyLoc) {
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
- var entry = this.tryEntries[i];
- if (entry.finallyLoc === finallyLoc) {
- this.complete(entry.completion, entry.afterLoc);
- resetTryEntry(entry);
- return ContinueSentinel;
- }
- }
- },
- "catch": function(tryLoc) {
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
- var entry = this.tryEntries[i];
- if (entry.tryLoc === tryLoc) {
- var record = entry.completion;
- if (record.type === "throw") {
- var thrown = record.arg;
- resetTryEntry(entry);
- }
- return thrown;
- }
- }
- // The context.catch method must only be called with a location
- // argument that corresponds to a known catch block.
- throw new Error("illegal catch attempt");
- },
- delegateYield: function(iterable, resultName, nextLoc) {
- this.delegate = {
- iterator: values(iterable),
- resultName: resultName,
- nextLoc: nextLoc
- };
- if (this.method === "next") {
- // Deliberately forget the last sent value so that we don't
- // accidentally pass it on to the delegate.
- this.arg = undefined$1;
- }
- return ContinueSentinel;
- }
- };
- // Regardless of whether this script is executing as a CommonJS module
- // or not, return the runtime object so that we can declare the variable
- // regeneratorRuntime in the outer scope, which allows this module to be
- // injected easily by `bin/regenerator --include-runtime script.js`.
- return exports;
- }(
- // If this script is executing as a CommonJS module, use module.exports
- // as the regeneratorRuntime namespace. Otherwise create a new empty
- // object. Either way, the resulting object will be used to initialize
- // the regeneratorRuntime variable at the top of this file.
- module.exports
- ));
- try {
- regeneratorRuntime = runtime;
- } catch (accidentalStrictMode) {
- // This module should not be running in strict mode, so the above
- // assignment should always work unless something is misconfigured. Just
- // in case runtime.js accidentally runs in strict mode, in modern engines
- // we can explicitly access globalThis. In older engines we can escape
- // strict mode using a global Function call. This could conceivably fail
- // if a Content Security Policy forbids using Function, but in that case
- // the proper solution is to fix the accidental strict mode problem. If
- // you've misconfigured your bundler to force strict mode and applied a
- // CSP to forbid Function, and you're not willing to fix either of those
- // problems, please detail your unique predicament in a GitHub issue.
- if (typeof globalThis === "object") {
- globalThis.regeneratorRuntime = runtime;
- } else {
- Function("r", "regeneratorRuntime = r")(runtime);
- }
- }
- });
- var regenerator = runtime_1;
- function _classCallCheck(instance, Constructor) {
- if (!(instance instanceof Constructor)) {
- throw new TypeError("Cannot call a class as a function");
- }
- }
- function _defineProperties(target, props) {
- for (var i = 0; i < props.length; i++) {
- var descriptor = props[i];
- descriptor.enumerable = descriptor.enumerable || false;
- descriptor.configurable = true;
- if ("value" in descriptor) descriptor.writable = true;
- Object.defineProperty(target, descriptor.key, descriptor);
- }
- }
- function _createClass(Constructor, protoProps, staticProps) {
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
- if (staticProps) _defineProperties(Constructor, staticProps);
- Object.defineProperty(Constructor, "prototype", {
- writable: false
- });
- return Constructor;
- }
- var Codes = {
- Success: 0,
- Param: 1001,
- Internal: 1002,
- Timeout: 1003,
- Authentication: 1004,
- TokenExpired: 1005,
- Unsupported: 1006,
- InitNetworkTimeout: 1007,
- InitDecoderTimeout: 1008,
- InitConfigTimeout: 1009,
- InitEngineTimeout: 1010,
- InitEngine: 1011,
- ActionBlocked: 1012,
- PreloadCanceled: 1013,
- FrequencyLimit: 1014,
- UsersUpperLimit: 2e3,
- RoomsUpperLimit: 2001,
- ServerParam: 2002,
- LackOfToken: 2003,
- LoginFailed: 2004,
- VerifyServiceDown: 2005,
- CreateSessionFailed: 2006,
- RtcConnection: 2008,
- DoActionFailed: 2009,
- StateSyncFailed: 2010,
- BroadcastFailed: 2011,
- DataAbnormal: 2012,
- GetOnVehicle: 2015,
- RepeatLogin: 2017,
- RoomDoseNotExist: 2018,
- TicketExpire: 2019,
- ServerRateLimit: 2020,
- DoActionBlocked: 2333,
- ActionMaybeDelay: 2334,
- ActionResponseTimeout: 2999
- };
- function _setPrototypeOf(o, p) {
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
- o.__proto__ = p;
- return o;
- };
- return _setPrototypeOf(o, p);
- }
- function _inherits(subClass, superClass) {
- if (typeof superClass !== "function" && superClass !== null) {
- throw new TypeError("Super expression must either be null or a function");
- }
- subClass.prototype = Object.create(superClass && superClass.prototype, {
- constructor: {
- value: subClass,
- writable: true,
- configurable: true
- }
- });
- Object.defineProperty(subClass, "prototype", {
- writable: false
- });
- if (superClass) _setPrototypeOf(subClass, superClass);
- }
- function _typeof(obj) {
- "@babel/helpers - typeof";
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
- return typeof obj;
- } : function (obj) {
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
- }, _typeof(obj);
- }
- function _assertThisInitialized(self) {
- if (self === void 0) {
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
- }
- return self;
- }
- function _possibleConstructorReturn(self, call) {
- if (call && (_typeof(call) === "object" || typeof call === "function")) {
- return call;
- } else if (call !== void 0) {
- throw new TypeError("Derived constructors may only return object or undefined");
- }
- return _assertThisInitialized(self);
- }
- function _getPrototypeOf(o) {
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
- return o.__proto__ || Object.getPrototypeOf(o);
- };
- return _getPrototypeOf(o);
- }
- function _isNativeFunction(fn) {
- return Function.toString.call(fn).indexOf("[native code]") !== -1;
- }
- 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;
- }
- }
- function _construct(Parent, args, Class) {
- if (_isNativeReflectConstruct$P()) {
- _construct = Reflect.construct;
- } else {
- _construct = function _construct(Parent, args, Class) {
- var a = [null];
- a.push.apply(a, args);
- var Constructor = Function.bind.apply(Parent, a);
- var instance = new Constructor();
- if (Class) _setPrototypeOf(instance, Class.prototype);
- return instance;
- };
- }
- return _construct.apply(null, arguments);
- }
- function _wrapNativeSuper(Class) {
- var _cache = typeof Map === "function" ? new Map() : undefined;
- _wrapNativeSuper = function _wrapNativeSuper(Class) {
- if (Class === null || !_isNativeFunction(Class)) return Class;
- if (typeof Class !== "function") {
- throw new TypeError("Super expression must either be null or a function");
- }
- if (typeof _cache !== "undefined") {
- if (_cache.has(Class)) return _cache.get(Class);
- _cache.set(Class, Wrapper);
- }
- function Wrapper() {
- return _construct(Class, arguments, _getPrototypeOf(this).constructor);
- }
- Wrapper.prototype = Object.create(Class.prototype, {
- constructor: {
- value: Wrapper,
- enumerable: false,
- writable: true,
- configurable: true
- }
- });
- return _setPrototypeOf(Wrapper, Class);
- };
- return _wrapNativeSuper(Class);
- }
- 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); }; }
- 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; } }
- var XverseError = /*#__PURE__*/function (_Error) {
- _inherits(XverseError, _Error);
- var _super = _createSuper$O(XverseError);
- function XverseError(e, t) {
- var _this;
- _classCallCheck(this, XverseError);
- _this = _super.call(this, t);
- _this.code = e;
- return _this;
- }
- _createClass(XverseError, [{
- key: "toJSON",
- value: function toJSON() {
- return {
- code: this.code,
- message: this.message
- };
- }
- }, {
- key: "toString",
- value: function toString() {
- if (Object(this) !== this) throw new TypeError();
- var t = this.name;
- t = t === void 0 ? "Error" : String(t);
- var r = this.message;
- r = r === void 0 ? "" : String(r);
- var n = this.code;
- return r = n === void 0 ? r : n + "," + r, t === "" ? r : r === "" ? t : t + ": " + r;
- }
- }]);
- return XverseError;
- }( /*#__PURE__*/_wrapNativeSuper(Error));
- 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); }; }
- 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; } }
- var ParamError$1 = /*#__PURE__*/function (_XverseError) {
- _inherits(ParamError, _XverseError);
- var _super = _createSuper$N(ParamError);
- function ParamError(e) {
- _classCallCheck(this, ParamError);
- return _super.call(this, 1001, e || "\u53C2\u6570\u9519\u8BEF");
- }
- return _createClass(ParamError);
- }(XverseError);
- 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); }; }
- 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; } }
- var InternalError = /*#__PURE__*/function (_XverseError) {
- _inherits(InternalError, _XverseError);
- var _super = _createSuper$M(InternalError);
- function InternalError(e) {
- _classCallCheck(this, InternalError);
- return _super.call(this, 1002, e || "\u5185\u90E8\u9519\u8BEF");
- }
- return _createClass(InternalError);
- }(XverseError);
- 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); }; }
- 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; } }
- var TimeoutError = /*#__PURE__*/function (_XverseError) {
- _inherits(TimeoutError, _XverseError);
- var _super = _createSuper$L(TimeoutError);
- function TimeoutError(e) {
- _classCallCheck(this, TimeoutError);
- return _super.call(this, 1003, e || "\u8D85\u65F6");
- }
- return _createClass(TimeoutError);
- }(XverseError);
- 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); }; }
- 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; } }
- var AuthenticationError$1 = /*#__PURE__*/function (_XverseError) {
- _inherits(AuthenticationError, _XverseError);
- var _super = _createSuper$K(AuthenticationError);
- function AuthenticationError(e) {
- _classCallCheck(this, AuthenticationError);
- return _super.call(this, 1004, e || "\u9274\u6743\u5931\u8D25");
- }
- return _createClass(AuthenticationError);
- }(XverseError);
- 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); }; }
- 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; } }
- var TokenExpiredError$1 = /*#__PURE__*/function (_XverseError) {
- _inherits(TokenExpiredError, _XverseError);
- var _super = _createSuper$J(TokenExpiredError);
- function TokenExpiredError(e) {
- _classCallCheck(this, TokenExpiredError);
- return _super.call(this, 1005, e || "Token \u5DF2\u8FC7\u671F");
- }
- return _createClass(TokenExpiredError);
- }(XverseError);
- 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); }; }
- 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; } }
- var UnsupportedError$1 = /*#__PURE__*/function (_XverseError) {
- _inherits(UnsupportedError, _XverseError);
- var _super = _createSuper$I(UnsupportedError);
- function UnsupportedError(e) {
- _classCallCheck(this, UnsupportedError);
- return _super.call(this, 1006, e || "\u624B\u673A\u7CFB\u7EDF\u4E0D\u652F\u6301XVerse");
- }
- return _createClass(UnsupportedError);
- }(XverseError);
- 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); }; }
- 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; } }
- var InitNetworkTimeoutError = /*#__PURE__*/function (_XverseError) {
- _inherits(InitNetworkTimeoutError, _XverseError);
- var _super = _createSuper$H(InitNetworkTimeoutError);
- function InitNetworkTimeoutError(e) {
- _classCallCheck(this, InitNetworkTimeoutError);
- return _super.call(this, 1007, e || "\u7F51\u7EDC\u521D\u59CB\u5316\u8D85\u65F6");
- }
- return _createClass(InitNetworkTimeoutError);
- }(XverseError);
- 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); }; }
- 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; } }
- var InitDecoderTimeoutError = /*#__PURE__*/function (_XverseError) {
- _inherits(InitDecoderTimeoutError, _XverseError);
- var _super = _createSuper$G(InitDecoderTimeoutError);
- function InitDecoderTimeoutError(e) {
- _classCallCheck(this, InitDecoderTimeoutError);
- return _super.call(this, 1008, e || "Decoder \u521D\u59CB\u5316\u8D85\u65F6");
- }
- return _createClass(InitDecoderTimeoutError);
- }(XverseError);
- 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); }; }
- 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; } }
- var InitConfigTimeoutError = /*#__PURE__*/function (_XverseError) {
- _inherits(InitConfigTimeoutError, _XverseError);
- var _super = _createSuper$F(InitConfigTimeoutError);
- function InitConfigTimeoutError(e) {
- _classCallCheck(this, InitConfigTimeoutError);
- return _super.call(this, 1009, e || "\u914D\u7F6E\u521D\u59CB\u5316\u8D85\u65F6");
- }
- return _createClass(InitConfigTimeoutError);
- }(XverseError);
- 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); }; }
- 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; } }
- var InitEngineTimeoutError = /*#__PURE__*/function (_XverseError) {
- _inherits(InitEngineTimeoutError, _XverseError);
- var _super = _createSuper$E(InitEngineTimeoutError);
- function InitEngineTimeoutError(e) {
- _classCallCheck(this, InitEngineTimeoutError);
- return _super.call(this, 1010, e || "\u5F15\u64CE\u521D\u59CB\u5316\u8D85\u65F6");
- }
- return _createClass(InitEngineTimeoutError);
- }(XverseError);
- 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); }; }
- 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; } }
- var InitEngineError = /*#__PURE__*/function (_XverseError) {
- _inherits(InitEngineError, _XverseError);
- var _super = _createSuper$D(InitEngineError);
- function InitEngineError(e) {
- _classCallCheck(this, InitEngineError);
- return _super.call(this, 1011, e || "\u5F15\u64CE\u521D\u59CB\u5316\u9519\u8BEF");
- }
- return _createClass(InitEngineError);
- }(XverseError);
- 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); }; }
- 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; } }
- var ActionBlockedError = /*#__PURE__*/function (_XverseError) {
- _inherits(ActionBlockedError, _XverseError);
- var _super = _createSuper$C(ActionBlockedError);
- function ActionBlockedError(e) {
- _classCallCheck(this, ActionBlockedError);
- return _super.call(this, 1012, e || "\u52A8\u4F5C\u88AB\u5C4F\u853D");
- }
- return _createClass(ActionBlockedError);
- }(XverseError);
- 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); }; }
- 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; } }
- var PreloadCanceledError$1 = /*#__PURE__*/function (_XverseError) {
- _inherits(PreloadCanceledError, _XverseError);
- var _super = _createSuper$B(PreloadCanceledError);
- function PreloadCanceledError(e) {
- _classCallCheck(this, PreloadCanceledError);
- return _super.call(this, 1013, e || "\u9884\u52A0\u8F7D\u88AB\u53D6\u6D88");
- }
- return _createClass(PreloadCanceledError);
- }(XverseError);
- 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); }; }
- 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; } }
- var FrequencyLimitError$1 = /*#__PURE__*/function (_XverseError) {
- _inherits(FrequencyLimitError, _XverseError);
- var _super = _createSuper$A(FrequencyLimitError);
- function FrequencyLimitError(e) {
- _classCallCheck(this, FrequencyLimitError);
- return _super.call(this, 1014, e || "\u9891\u7387\u9650\u5236");
- }
- return _createClass(FrequencyLimitError);
- }(XverseError);
- 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); }; }
- 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; } }
- var UsersUpperLimitError = /*#__PURE__*/function (_XverseError) {
- _inherits(UsersUpperLimitError, _XverseError);
- var _super = _createSuper$z(UsersUpperLimitError);
- function UsersUpperLimitError(e) {
- _classCallCheck(this, UsersUpperLimitError);
- return _super.call(this, 2e3, e || "\u76F4\u64AD\u95F4\u4EBA\u6570\u5DF2\u6EE1");
- }
- return _createClass(UsersUpperLimitError);
- }(XverseError);
- 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); }; }
- 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; } }
- var RoomsUpperLimitError = /*#__PURE__*/function (_XverseError) {
- _inherits(RoomsUpperLimitError, _XverseError);
- var _super = _createSuper$y(RoomsUpperLimitError);
- function RoomsUpperLimitError(e) {
- _classCallCheck(this, RoomsUpperLimitError);
- return _super.call(this, 2001, e || "\u623F\u95F4\u5230\u8FBE\u4E0A\u9650");
- }
- return _createClass(RoomsUpperLimitError);
- }(XverseError);
- 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); }; }
- 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; } }
- var ServerParamError = /*#__PURE__*/function (_XverseError) {
- _inherits(ServerParamError, _XverseError);
- var _super = _createSuper$x(ServerParamError);
- function ServerParamError(e) {
- _classCallCheck(this, ServerParamError);
- return _super.call(this, 2002, e || "\u670D\u52A1\u5668\u53C2\u6570\u9519\u8BEF");
- }
- return _createClass(ServerParamError);
- }(XverseError);
- 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); }; }
- 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; } }
- var LackOfTokenError = /*#__PURE__*/function (_XverseError) {
- _inherits(LackOfTokenError, _XverseError);
- var _super = _createSuper$w(LackOfTokenError);
- function LackOfTokenError(e) {
- _classCallCheck(this, LackOfTokenError);
- return _super.call(this, 2003, e || "\u7F3A\u5C11 Token");
- }
- return _createClass(LackOfTokenError);
- }(XverseError);
- 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); }; }
- 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; } }
- var LoginFailedError = /*#__PURE__*/function (_XverseError) {
- _inherits(LoginFailedError, _XverseError);
- var _super = _createSuper$v(LoginFailedError);
- function LoginFailedError(e) {
- _classCallCheck(this, LoginFailedError);
- return _super.call(this, 2004, e || "\u8FDB\u5165\u623F\u95F4\u5931\u8D25");
- }
- return _createClass(LoginFailedError);
- }(XverseError);
- 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); }; }
- 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; } }
- var VerifyServiceDownError = /*#__PURE__*/function (_XverseError) {
- _inherits(VerifyServiceDownError, _XverseError);
- var _super = _createSuper$u(VerifyServiceDownError);
- function VerifyServiceDownError(e) {
- _classCallCheck(this, VerifyServiceDownError);
- return _super.call(this, 2005, e || "\u9274\u6743\u670D\u52A1\u5F02\u5E38");
- }
- return _createClass(VerifyServiceDownError);
- }(XverseError);
- 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); }; }
- 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; } }
- var CreateSessionFailedError = /*#__PURE__*/function (_XverseError) {
- _inherits(CreateSessionFailedError, _XverseError);
- var _super = _createSuper$t(CreateSessionFailedError);
- function CreateSessionFailedError(e) {
- _classCallCheck(this, CreateSessionFailedError);
- return _super.call(this, 2006, e || "\u521B\u5EFA session \u5931\u8D25");
- }
- return _createClass(CreateSessionFailedError);
- }(XverseError);
- 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); }; }
- 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; } }
- var RtcConnectionError = /*#__PURE__*/function (_XverseError) {
- _inherits(RtcConnectionError, _XverseError);
- var _super = _createSuper$s(RtcConnectionError);
- function RtcConnectionError(e) {
- _classCallCheck(this, RtcConnectionError);
- return _super.call(this, 2008, e || "RTC\u5EFA\u8054\u5931\u8D25");
- }
- return _createClass(RtcConnectionError);
- }(XverseError);
- 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); }; }
- 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; } }
- var DoActionFailedError = /*#__PURE__*/function (_XverseError) {
- _inherits(DoActionFailedError, _XverseError);
- var _super = _createSuper$r(DoActionFailedError);
- function DoActionFailedError(e) {
- _classCallCheck(this, DoActionFailedError);
- return _super.call(this, 2009, e || "\u52A8\u4F5C\u6267\u884C\u5931\u8D25");
- }
- return _createClass(DoActionFailedError);
- }(XverseError);
- 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); }; }
- 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; } }
- var StateSyncFailedError = /*#__PURE__*/function (_XverseError) {
- _inherits(StateSyncFailedError, _XverseError);
- var _super = _createSuper$q(StateSyncFailedError);
- function StateSyncFailedError(e) {
- _classCallCheck(this, StateSyncFailedError);
- return _super.call(this, 2010, e || "\u72B6\u6001\u540C\u6B65\u5931\u8D25");
- }
- return _createClass(StateSyncFailedError);
- }(XverseError);
- 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); }; }
- 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; } }
- var BroadcastFailedError = /*#__PURE__*/function (_XverseError) {
- _inherits(BroadcastFailedError, _XverseError);
- var _super = _createSuper$p(BroadcastFailedError);
- function BroadcastFailedError(e) {
- _classCallCheck(this, BroadcastFailedError);
- return _super.call(this, 2011, e || "\u5E7F\u64AD\u63A5\u53E3\u63A5\u53E3\u5F02\u5E38");
- }
- return _createClass(BroadcastFailedError);
- }(XverseError);
- 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); }; }
- 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; } }
- var DataAbnormalError = /*#__PURE__*/function (_XverseError) {
- _inherits(DataAbnormalError, _XverseError);
- var _super = _createSuper$o(DataAbnormalError);
- function DataAbnormalError(e) {
- _classCallCheck(this, DataAbnormalError);
- return _super.call(this, 2012, e || "\u6570\u636E\u5F02\u5E38");
- }
- return _createClass(DataAbnormalError);
- }(XverseError);
- 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); }; }
- 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; } }
- var GetOnVehicleError = /*#__PURE__*/function (_XverseError) {
- _inherits(GetOnVehicleError, _XverseError);
- var _super = _createSuper$n(GetOnVehicleError);
- function GetOnVehicleError(e) {
- _classCallCheck(this, GetOnVehicleError);
- return _super.call(this, 2015, e || "\u4E0A\u8F7D\u5177\u5931\u8D25\u9700\u8981\u9884\u7EA6");
- }
- return _createClass(GetOnVehicleError);
- }(XverseError);
- 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); }; }
- 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; } }
- var RepeatLoginError = /*#__PURE__*/function (_XverseError) {
- _inherits(RepeatLoginError, _XverseError);
- var _super = _createSuper$m(RepeatLoginError);
- function RepeatLoginError(e) {
- _classCallCheck(this, RepeatLoginError);
- return _super.call(this, 2017, e || "\u5F02\u5730\u767B\u5F55");
- }
- return _createClass(RepeatLoginError);
- }(XverseError);
- 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); }; }
- 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; } }
- var RoomDoseNotExistError = /*#__PURE__*/function (_XverseError) {
- _inherits(RoomDoseNotExistError, _XverseError);
- var _super = _createSuper$l(RoomDoseNotExistError);
- function RoomDoseNotExistError(e) {
- _classCallCheck(this, RoomDoseNotExistError);
- return _super.call(this, 2018, e || "\u6307\u5B9A\u623F\u95F4\u4E0D\u5B58\u5728");
- }
- return _createClass(RoomDoseNotExistError);
- }(XverseError);
- 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); }; }
- 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; } }
- var TicketExpireError = /*#__PURE__*/function (_XverseError) {
- _inherits(TicketExpireError, _XverseError);
- var _super = _createSuper$k(TicketExpireError);
- function TicketExpireError(e) {
- _classCallCheck(this, TicketExpireError);
- return _super.call(this, 2019, e || "\u7968\u636E\u8FC7\u671F");
- }
- return _createClass(TicketExpireError);
- }(XverseError);
- 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); }; }
- 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; } }
- var ServerRateLimitError = /*#__PURE__*/function (_XverseError) {
- _inherits(ServerRateLimitError, _XverseError);
- var _super = _createSuper$j(ServerRateLimitError);
- function ServerRateLimitError(e) {
- _classCallCheck(this, ServerRateLimitError);
- return _super.call(this, 2020, e || "\u670D\u52A1\u7AEF\u9891\u7387\u9650\u5236");
- }
- return _createClass(ServerRateLimitError);
- }(XverseError);
- 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); }; }
- 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; } }
- var DoActionBlockedError = /*#__PURE__*/function (_XverseError) {
- _inherits(DoActionBlockedError, _XverseError);
- var _super = _createSuper$i(DoActionBlockedError);
- function DoActionBlockedError(e) {
- _classCallCheck(this, DoActionBlockedError);
- return _super.call(this, 2333, e || "\u52A8\u4F5C\u88AB\u5C4F\u853D");
- }
- return _createClass(DoActionBlockedError);
- }(XverseError);
- 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); }; }
- 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; } }
- var ActionMaybeDelayError = /*#__PURE__*/function (_XverseError) {
- _inherits(ActionMaybeDelayError, _XverseError);
- var _super = _createSuper$h(ActionMaybeDelayError);
- function ActionMaybeDelayError(e) {
- _classCallCheck(this, ActionMaybeDelayError);
- return _super.call(this, 2334, e || "\u52A8\u4F5C\u53EF\u80FD\u5EF6\u8FDF\u6267\u884C");
- }
- return _createClass(ActionMaybeDelayError);
- }(XverseError);
- 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); }; }
- 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; } }
- var ActionResponseTimeoutError$1 = /*#__PURE__*/function (_XverseError) {
- _inherits(ActionResponseTimeoutError, _XverseError);
- var _super = _createSuper$g(ActionResponseTimeoutError);
- function ActionResponseTimeoutError(e) {
- _classCallCheck(this, ActionResponseTimeoutError);
- return _super.call(this, 2999, e || "action\u56DE\u5305\u8D85\u65F6");
- }
- return _createClass(ActionResponseTimeoutError);
- }(XverseError);
- var CodeErrorMap = {
- 1001: ParamError$1,
- 1002: InternalError,
- 1003: TimeoutError,
- 1004: AuthenticationError$1,
- 1005: TokenExpiredError$1,
- 1006: UnsupportedError$1,
- 1007: InitNetworkTimeoutError,
- 1008: InitDecoderTimeoutError,
- 1009: InitConfigTimeoutError,
- 1010: InitEngineTimeoutError,
- 1011: InitEngineError,
- 1012: ActionBlockedError,
- 1013: PreloadCanceledError$1,
- 1014: FrequencyLimitError$1,
- 2e3: UsersUpperLimitError,
- 2001: RoomsUpperLimitError,
- 2002: ServerParamError,
- 2003: LackOfTokenError,
- 2004: LoginFailedError,
- 2005: VerifyServiceDownError,
- 2006: CreateSessionFailedError,
- 2008: RtcConnectionError,
- 2009: DoActionFailedError,
- 2010: StateSyncFailedError,
- 2011: BroadcastFailedError,
- 2012: DataAbnormalError,
- 2015: GetOnVehicleError,
- 2017: RepeatLoginError,
- 2018: RoomDoseNotExistError,
- 2019: TicketExpireError,
- 2020: ServerRateLimitError,
- 2333: DoActionBlockedError,
- 2334: ActionMaybeDelayError,
- 2999: ActionResponseTimeoutError$1
- };
- var util = {
- uuid() {
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (i) {
- var e = Math.random() * 16 | 0;
- return (i === "x" ? e : e & 3 | 8).toString(16);
- });
- },
- getFormattedDate(i) {
- var e = i.getMonth() + 1,
- t = i.getDate(),
- r = i.getHours(),
- n = i.getMinutes(),
- o = i.getSeconds(),
- a = i.getMilliseconds(),
- s = (e < 10 ? "0" : "") + e,
- l = (t < 10 ? "0" : "") + t,
- u = (r < 10 ? "0" : "") + r,
- c = (n < 10 ? "0" : "") + n,
- h = (o < 10 ? "0" : "") + o;
- return i.getFullYear() + "-" + s + "-" + l + " " + u + ":" + c + ":" + h + "." + a;
- },
- createInstance(i) {
- var e = new Axios(i),
- t = bind(Axios.prototype.request, e);
- return utils.extend(t, Axios.prototype, e), utils.extend(t, e), t.create = function (n) {
- return createInstance(mergeConfig(i, n));
- }, t;
- },
- mapLimit(i, e, t) {
- return new Promise(function (r, n) {
- var o = i.length;
- var a = e - 1,
- s = 0;
- var l = function l(u) {
- u.forEach(function (c) {
- t(c).then(function () {
- if (s++, s === o) {
- r();
- return;
- }
- a++;
- var h = i[a];
- h && l([h]);
- }, function (h) {
- n(h);
- });
- });
- };
- l(i.slice(0, e));
- });
- },
- isWebAssemblySupported() {
- try {
- if (typeof WebAssembly == "object" && typeof WebAssembly.instantiate == "function") {
- var i = new WebAssembly.Module(Uint8Array.of(0, 97, 115, 109, 1, 0, 0, 0));
- if (i instanceof WebAssembly.Module) return new WebAssembly.Instance(i) instanceof WebAssembly.Instance;
- }
- } catch (_unused) {}
- return console.log("wasm is not supported"), !1;
- },
- isSupported() {
- return typeof RTCPeerConnection == "function" && this.isWebAssemblySupported();
- },
- objectParseFloat(i) {
- var e = {};
- return i && Object.keys(i).forEach(function (t) {
- e[t] = parseFloat(i[t]);
- }), e;
- },
- getRandomItem(i) {
- i.length === 0 ? null : i[Math.floor(Math.random() * i.length)];
- },
- getErrorByCode(i) {
- if (i === Codes.Success) return InternalError;
- var e = CodeErrorMap[i];
- return e || console.warn("unkown code", i), e || InternalError;
- }
- };
- 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); }; }
- 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; } }
- var Reporter = /*#__PURE__*/function (_EventEmitter) {
- _inherits(Reporter, _EventEmitter);
- var _super = _createSuper$f(Reporter);
- function Reporter() {
- var _this;
- _classCallCheck(this, Reporter);
- _this = _super.call(this);
- _this._header = {};
- _this._body = {};
- _this._queue = [];
- _this._disabled = !1;
- _this._interval = null;
- _this._reportUrl = null;
- _this.isDocumentLoaded = function () {
- return document.readyState === "complete";
- };
- _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 () {
- _this._flushReport();
- }, 10 * 1e3);
- return _this;
- }
- _createClass(Reporter, [{
- key: "disable",
- value: function disable() {
- this._disabled = !0, this._interval && window.clearInterval(this._interval);
- }
- }, {
- key: "updateHeader",
- value: function updateHeader(e) {
- Object.assign(this._header, e);
- }
- }, {
- key: "updateBody",
- value: function updateBody(e) {
- Object.assign(this._body, e);
- }
- }, {
- key: "updateReportUrl",
- value: function updateReportUrl(e) {
- this._reportUrl = e;
- }
- }, {
- key: "report",
- value: function report(e, t, r) {
- var _this2 = this;
- if (this._disabled) return;
- r || (r = {});
- var _r = r,
- n = _r.immediate,
- o = _r.sampleRate;
- if (o && o > Math.random()) return;
- this.updateBody({
- logTime: util.getFormattedDate(new Date()),
- logTimestamp: Date.now()
- });
- var a = function a(s) {
- var l = oe(le(oe({}, _this2._body), {
- type: e
- }), s);
- _this2._queue.push(l), e === "measurement" && _this2.emit("report", s);
- };
- Array.isArray(t) ? t.forEach(function (s) {
- return a(s);
- }) : a(t), (n || this._queue.length >= REPORT_NUM_PER_REQUEST) && this._flushReport();
- }
- }, {
- key: "_flushReport",
- value: function _flushReport() {
- if (this._disabled || !this._queue.length || !this.isDocumentLoaded()) return;
- var e = {
- header: this._header,
- body: this._queue.splice(0, REPORT_NUM_PER_REQUEST)
- };
- this._post(e);
- }
- }, {
- key: "_post",
- value: function _post(e) {
- var t = this._reportUrl || REPORT_URL.DEV;
- return new Promise(function (r, n) {
- var o = new XMLHttpRequest();
- o.open("POST", t), o.setRequestHeader("Content-Type", "application/json");
- try {
- o.send(JSON.stringify(e));
- } catch (a) {
- console.error(a);
- }
- o.addEventListener("readystatechange", function () {
- if (o.readyState == 4) return o.status == 200 ? r(o) : n("Unable to send log");
- });
- });
- }
- }]);
- return Reporter;
- }(EventEmitter);
- var reporter$1 = new Reporter();
- 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;
- }
- function _arrayWithoutHoles(arr) {
- if (Array.isArray(arr)) return _arrayLikeToArray$5(arr);
- }
- function _iterableToArray(iter) {
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
- }
- 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);
- }
- function _nonIterableSpread() {
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
- }
- function _toConsumableArray(arr) {
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray$5(arr) || _nonIterableSpread();
- }
- var Logger = /*#__PURE__*/function () {
- function Logger(e) {
- _classCallCheck(this, Logger);
- this.level = 3;
- this.module = e;
- }
- _createClass(Logger, [{
- key: "setLevel",
- value: function setLevel(e) {
- this.level = e;
- }
- }, {
- key: "atleast",
- value: function atleast(e) {
- return e >= this.level && e >= this.level;
- }
- }, {
- key: "print",
- value: function print(e, t) {
- for (var _len = arguments.length, r = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
- r[_key - 2] = arguments[_key];
- }
- if (this.atleast(t)) {
- var _console$n;
- var n = e == "debug" ? "info" : e,
- o = this.prefix(e);
- (_console$n = console[n]).call.apply(_console$n, [null, o].concat(r));
- }
- if (e !== "debug" && e !== "info") {
- var _n = r.map(function (o) {
- if (o instanceof Object) try {
- return JSON.stringify(o);
- } catch (_unused) {
- return o;
- } else return o;
- }).join(",");
- reporter$1.report("log", {
- message: _n,
- level: e,
- module: this.module
- });
- }
- }
- }, {
- key: "debug",
- value: function debug() {
- for (var _len2 = arguments.length, e = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
- e[_key2] = arguments[_key2];
- }
- return this.print.apply(this, ["debug", 1].concat(e));
- }
- }, {
- key: "info",
- value: function info() {
- for (var _len3 = arguments.length, e = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
- e[_key3] = arguments[_key3];
- }
- return this.print.apply(this, ["info", 2].concat(e));
- }
- }, {
- key: "infoAndReportLog",
- value: function infoAndReportLog(e) {
- for (var _len4 = arguments.length, t = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
- t[_key4 - 1] = arguments[_key4];
- }
- var r = e.reportOptions;
- delete e.reportOptions, reporter$1.report("log", e, r), t.length || (t = [e.message]), this.debug.apply(this, _toConsumableArray(t));
- }
- }, {
- key: "infoAndReportMeasurement",
- value: function infoAndReportMeasurement(e) {
- for (var _len5 = arguments.length, t = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
- t[_key5 - 1] = arguments[_key5];
- }
- var n;
- var r = e.reportOptions;
- if (e.startTime) {
- var o = Date.now();
- e.value === void 0 && (e.endTime = o), e.value === void 0 && (e.value = o - e.startTime);
- }
- 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) {
- this.error.apply(this, _toConsumableArray(t));
- return;
- }
- this.warn.apply(this, _toConsumableArray(t));
- }
- }, {
- key: "warn",
- value: function warn() {
- for (var _len6 = arguments.length, e = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
- e[_key6] = arguments[_key6];
- }
- return this.print.apply(this, ["warn", 3].concat(e));
- }
- }, {
- key: "error",
- value: function error() {
- for (var _len7 = arguments.length, e = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
- e[_key7] = arguments[_key7];
- }
- return this.print.apply(this, ["error", 4].concat(e));
- }
- }, {
- key: "prefix",
- value: function prefix(e) {
- return "[".concat(this.module, "][").concat(e, "] ").concat(util.getFormattedDate(new Date()), ":");
- }
- }], [{
- key: "setLevel",
- value: function setLevel(e) {
- this.level = e;
- }
- }]);
- return Logger;
- }();
- var logger$1 = new Logger();
- var AxiosCanceler = /*#__PURE__*/function () {
- function AxiosCanceler() {
- _classCallCheck(this, AxiosCanceler);
- this.pendingMap = new Map();
- }
- _createClass(AxiosCanceler, [{
- key: "addPending",
- value: function addPending(e) {
- var _this = this;
- return new axios.CancelToken(function (t) {
- _this.pendingMap.has(e) || _this.pendingMap.set(e, t);
- });
- }
- }, {
- key: "removeAllPending",
- value: function removeAllPending() {
- this.pendingMap.forEach(function (e) {
- e && isFunction(e) && e();
- }), this.pendingMap.clear();
- }
- }, {
- key: "removePending",
- value: function removePending(e) {
- if (this.pendingMap.has(e)) {
- var t = this.pendingMap.get(e);
- t && t(e), this.pendingMap.delete(e);
- }
- }
- }, {
- key: "removeCancelToken",
- value: function removeCancelToken(e) {
- this.pendingMap.has(e) && this.pendingMap.delete(e);
- }
- }, {
- key: "reset",
- value: function reset() {
- this.pendingMap = new Map();
- }
- }]);
- return AxiosCanceler;
- }();
- 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); }; }
- 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; } }
- var Http1 = /*#__PURE__*/function (_EventEmitter) {
- _inherits(Http1, _EventEmitter);
- var _super = _createSuper$e(Http1);
- function Http1() {
- var _this;
- _classCallCheck(this, Http1);
- _this = _super.call(this);
- _this.instatnce = axios.create(), _this.canceler = new AxiosCanceler();
- return _this;
- }
- _createClass(Http1, [{
- key: "requestConstant",
- value: function requestConstant() {
- return {
- x_nounce: this.randomString(),
- x_timestamp: new Date().getTime(),
- x_os: "web"
- };
- }
- }, {
- key: "requestParams",
- value: function requestParams(e) {
- return oe({}, e.params);
- }
- }, {
- key: "get",
- value: function get(e) {
- return this.request(le(oe({}, e), {
- method: "GET"
- }));
- }
- }, {
- key: "post",
- value: function post(e) {
- return this.request(le(oe({}, e), {
- method: "POST"
- }));
- }
- }, {
- key: "request",
- value: function request(e) {
- var _this2 = this;
- var t = e.url,
- _e$timeout = e.timeout,
- r = _e$timeout === void 0 ? 1e4 : _e$timeout,
- n = e.method,
- o = e.key,
- a = e.beforeRequest,
- s = e.responseType,
- l = e.data;
- var _e$retry = e.retry,
- u = _e$retry === void 0 ? 0 : _e$retry;
- var c = this.patchUrl(t),
- h = this.canceler.addPending(t);
- a && isFunction(a) && a(e);
- var f = this.requestParams(e);
- var d = {
- url: c,
- method: n,
- timeout: r,
- cancelToken: h,
- responseType: s,
- params: f
- };
- n === "POST" && (d = oe({
- data: l
- }, d));
- var _ = Date.now(),
- g = function g() {
- return _this2.instatnce.request(d).then(function (m) {
- return o && logger$1.infoAndReportMeasurement({
- metric: "http",
- startTime: _,
- extra: t,
- group: "http",
- tag: o
- }), _this2.canceler.removeCancelToken(t), m;
- }).catch(function (m) {
- var v = axios.isCancel(m);
- return u > 0 && !v ? (u--, logger$1.warn("request ".concat(t, " retry, left retry count"), u), g()) : (logger$1.infoAndReportMeasurement({
- metric: "http",
- startTime: _,
- error: m,
- extra: {
- url: t,
- isCanceled: v
- },
- tag: o,
- group: "http"
- }), _this2.canceler.removeCancelToken(t), Promise.reject(m));
- });
- };
- return g();
- }
- }, {
- key: "patchUrl",
- value: function patchUrl(e) {
- return e;
- }
- }, {
- key: "randomString",
- value: function randomString() {
- var e = "";
- var t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
- r = t.length;
- for (var n = 0; n < 8; n++) {
- e += t.charAt(Math.floor(Math.random() * r));
- }
- return e;
- }
- }]);
- return Http1;
- }(EventEmitter);
- var http1 = new Http1();
- var ModelManager = /*#__PURE__*/function () {
- function ModelManager(e, t) {
- _classCallCheck(this, ModelManager);
- this.avatarModelList = [];
- this.skinList = [];
- this.applicationConfig = null;
- this.config = null;
- this.appId = e, this.releaseId = t;
- }
- _createClass(ModelManager, [{
- key: "findSkinConfig",
- value: function () {
- var _findSkinConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
- var t, n;
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- t = null;
- _context.next = 3;
- return this.getSkinsList();
- case 3:
- t = (this.skinList = _context.sent).find(function (n) {
- return n.id === e;
- });
- if (!t) {
- _context.next = 6;
- break;
- }
- return _context.abrupt("return", t);
- case 6:
- n = "skin is invalid: skinId: ".concat(e);
- return _context.abrupt("return", Promise.reject(new ParamError(n)));
- case 8:
- case "end":
- return _context.stop();
- }
- }
- }, _callee, this);
- }));
- function findSkinConfig(_x) {
- return _findSkinConfig.apply(this, arguments);
- }
- return findSkinConfig;
- }()
- }, {
- key: "findRoute",
- value: function () {
- var _findRoute = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e, t) {
- var n, o;
- return regenerator.wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- _context2.next = 2;
- return this.findSkinConfig(e);
- case 2:
- n = _context2.sent.routeList.find(function (o) {
- return o.pathName === t;
- });
- if (n) {
- _context2.next = 6;
- break;
- }
- o = "find path failed: skinId: ".concat(e, ", pathName: ").concat(t);
- return _context2.abrupt("return", Promise.reject(new ParamError(o)));
- case 6:
- return _context2.abrupt("return", (logger$1.debug("find route success", n), n));
- case 7:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2, this);
- }));
- function findRoute(_x2, _x3) {
- return _findRoute.apply(this, arguments);
- }
- return findRoute;
- }()
- }, {
- key: "findAssetList",
- value: function () {
- var _findAssetList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
- var r, n;
- return regenerator.wrap(function _callee3$(_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- _context3.next = 2;
- return this.findSkinConfig(e);
- case 2:
- r = _context3.sent.assetList;
- if (r) {
- _context3.next = 6;
- break;
- }
- n = "find path failed: skinId: ".concat(e);
- return _context3.abrupt("return", Promise.reject(new ParamError(n)));
- case 6:
- return _context3.abrupt("return", (logger$1.debug("find route success", r), r));
- case 7:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee3, this);
- }));
- function findAssetList(_x4) {
- return _findAssetList.apply(this, arguments);
- }
- return findAssetList;
- }()
- }, {
- key: "findAsset",
- value: function () {
- var _findAsset = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e, t) {
- var r,
- n,
- o,
- a,
- _args4 = arguments;
- return regenerator.wrap(function _callee4$(_context4) {
- while (1) {
- switch (_context4.prev = _context4.next) {
- case 0:
- r = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : "id";
- _context4.next = 3;
- return this.findSkinConfig(e);
- case 3:
- n = _context4.sent;
- if (!Array.isArray(t)) {
- _context4.next = 6;
- break;
- }
- return _context4.abrupt("return", t.map(function (a) {
- return n.models.find(function (s) {
- return s[r] === a;
- });
- }).filter(Boolean));
- case 6:
- o = n.models.find(function (a) {
- return a[r] === t;
- });
- if (o) {
- _context4.next = 10;
- break;
- }
- a = "find asset failed: skinId: ".concat(e, ", keyValue: ").concat(t);
- return _context4.abrupt("return", Promise.reject(new ParamError(a)));
- case 10:
- return _context4.abrupt("return", (logger$1.debug("find asset success", o), o));
- case 11:
- case "end":
- return _context4.stop();
- }
- }
- }, _callee4, this);
- }));
- function findAsset(_x5, _x6) {
- return _findAsset.apply(this, arguments);
- }
- return findAsset;
- }()
- }, {
- key: "findPoint",
- value: function () {
- var _findPoint = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(e, t) {
- var n, o;
- return regenerator.wrap(function _callee5$(_context5) {
- while (1) {
- switch (_context5.prev = _context5.next) {
- case 0:
- _context5.next = 2;
- return this.findSkinConfig(e);
- case 2:
- n = _context5.sent.pointList.find(function (o) {
- return o.id === t;
- });
- if (n) {
- _context5.next = 6;
- break;
- }
- o = "find point failed: skinId: ".concat(e, ", id: ").concat(t);
- return _context5.abrupt("return", Promise.reject(new ParamError(o)));
- case 6:
- return _context5.abrupt("return", (logger$1.debug("find point success", n), n));
- case 7:
- case "end":
- return _context5.stop();
- }
- }
- }, _callee5, this);
- }));
- function findPoint(_x7, _x8) {
- return _findPoint.apply(this, arguments);
- }
- return findPoint;
- }()
- }, {
- key: "requestConfig",
- value: function () {
- var _requestConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6() {
- var t, r, _ref, n, o;
- return regenerator.wrap(function _callee6$(_context6) {
- while (1) {
- switch (_context6.prev = _context6.next) {
- case 0:
- if (!this.config) {
- _context6.next = 2;
- break;
- }
- return _context6.abrupt("return", this.config);
- case 2:
- // let e = `https://static.xverse.cn/console/config/${this.appId}/config.json`;
- // this.releaseId && (e = `https://static.xverse.cn/console/config/${this.appId}/${this.releaseId}/config.json`);
- // const t = Xverse.USE_TME_CDN ? "https://static.xverse.cn/tmeland/config/tme_config.json" : e;
- t = './assets/config.json';
- _context6.prev = 3;
- _context6.next = 6;
- return http1.get({
- url: "".concat(t, "?t=").concat(Date.now()),
- key: "config",
- timeout: 6e3,
- retry: 2
- });
- case 6:
- r = _context6.sent;
- _ref = r.data.data || {}, n = _ref.config, o = _ref.preload;
- if (n) {
- _context6.next = 10;
- break;
- }
- throw new Error("config data parse error" + r.data);
- case 10:
- return _context6.abrupt("return", (this.config = {
- config: n,
- preload: o
- }, logger$1.debug("get config success", this.config), this.config));
- case 13:
- _context6.prev = 13;
- _context6.t0 = _context6["catch"](3);
- return _context6.abrupt("return", Promise.reject(_context6.t0));
- case 16:
- case "end":
- return _context6.stop();
- }
- }
- }, _callee6, this, [[3, 13]]);
- }));
- function requestConfig() {
- return _requestConfig.apply(this, arguments);
- }
- return requestConfig;
- }()
- }, {
- key: "getApplicationConfig",
- value: function () {
- var _getApplicationConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7() {
- var e;
- return regenerator.wrap(function _callee7$(_context7) {
- while (1) {
- switch (_context7.prev = _context7.next) {
- case 0:
- if (!this.applicationConfig) {
- _context7.next = 2;
- break;
- }
- return _context7.abrupt("return", this.applicationConfig);
- case 2:
- _context7.prev = 2;
- _context7.next = 5;
- return this.requestConfig();
- case 5:
- e = _context7.sent;
- return _context7.abrupt("return", (this.applicationConfig = e.config, this.applicationConfig));
- case 9:
- _context7.prev = 9;
- _context7.t0 = _context7["catch"](2);
- return _context7.abrupt("return", Promise.reject(_context7.t0));
- case 12:
- case "end":
- return _context7.stop();
- }
- }
- }, _callee7, this, [[2, 9]]);
- }));
- function getApplicationConfig() {
- return _getApplicationConfig.apply(this, arguments);
- }
- return getApplicationConfig;
- }()
- }, {
- key: "getAvatarModelList",
- value: function () {
- var _getAvatarModelList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8() {
- var _yield$this$getApplic, e;
- return regenerator.wrap(function _callee8$(_context8) {
- while (1) {
- switch (_context8.prev = _context8.next) {
- case 0:
- if (!this.avatarModelList.length) {
- _context8.next = 2;
- break;
- }
- return _context8.abrupt("return", this.avatarModelList);
- case 2:
- _context8.prev = 2;
- _context8.next = 5;
- return this.getApplicationConfig();
- case 5:
- _yield$this$getApplic = _context8.sent;
- e = _yield$this$getApplic.avatars;
- return _context8.abrupt("return", (this.avatarModelList = e.map(function (t) {
- return {
- name: t.name,
- id: t.id,
- modelUrl: t.url,
- gender: t.gender,
- components: t.components
- };
- }), this.avatarModelList));
- case 10:
- _context8.prev = 10;
- _context8.t0 = _context8["catch"](2);
- return _context8.abrupt("return", (logger$1.error(_context8.t0), []));
- case 13:
- case "end":
- return _context8.stop();
- }
- }
- }, _callee8, this, [[2, 10]]);
- }));
- function getAvatarModelList() {
- return _getAvatarModelList.apply(this, arguments);
- }
- return getAvatarModelList;
- }()
- }, {
- key: "getSkinsList",
- value: function () {
- var _getSkinsList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9() {
- var _yield$this$getApplic2, e;
- return regenerator.wrap(function _callee9$(_context9) {
- while (1) {
- switch (_context9.prev = _context9.next) {
- case 0:
- if (!this.skinList.length) {
- _context9.next = 2;
- break;
- }
- return _context9.abrupt("return", this.skinList);
- case 2:
- _context9.prev = 2;
- _context9.next = 5;
- return this.getApplicationConfig();
- case 5:
- _yield$this$getApplic2 = _context9.sent;
- e = _yield$this$getApplic2.skins;
- return _context9.abrupt("return", (this.skinList = e.map(function (t) {
- var r;
- return {
- name: t.name,
- dataVersion: t.id + t.versionId,
- id: t.id,
- fov: parseInt(t.fov || 90),
- models: t.assetList.map(function (n) {
- var o = n.assetId,
- a = n.url,
- s = n.thumbnailUrl,
- l = n.typeName,
- u = n.className;
- return {
- id: o,
- modelUrl: a,
- name: n.name,
- thumbnailUrl: s,
- typeName: l,
- className: u === "\u4F4E\u6A21" ? "\u7C97\u6A21" : u
- };
- }),
- routeList: (r = t.routeList) == null ? void 0 : r.map(function (n) {
- var o = n.areaName,
- a = n.attitude,
- s = n.id,
- l = n.pathName,
- u = n.step,
- c = n.birthPointList;
- return {
- areaName: o,
- attitude: a,
- id: s,
- pathName: l,
- step: u,
- birthPointList: c.map(function (h) {
- return {
- camera: h.camera && {
- position: util.objectParseFloat(h.camera.position),
- angle: util.objectParseFloat(h.camera.rotation)
- },
- player: h.player && {
- position: util.objectParseFloat(h.player.position),
- angle: util.objectParseFloat(h.player.rotation)
- }
- };
- })
- };
- }),
- pointList: t.pointList.map(function (n) {
- return le(oe({}, n), {
- position: util.objectParseFloat(n.position),
- rotation: util.objectParseFloat(n.rotation)
- });
- }),
- versionId: t.versionId,
- isEnable: t.isEnable,
- assetList: t.assetList,
- visibleRules: t.visibleRules,
- animationList: t.animationList
- };
- }), this.skinList));
- case 10:
- _context9.prev = 10;
- _context9.t0 = _context9["catch"](2);
- return _context9.abrupt("return", (logger$1.error(_context9.t0), []));
- case 13:
- case "end":
- return _context9.stop();
- }
- }
- }, _callee9, this, [[2, 10]]);
- }));
- function getSkinsList() {
- return _getSkinsList.apply(this, arguments);
- }
- return getSkinsList;
- }()
- }, {
- key: "getBreathPointTextrueList",
- value: function () {
- var _getBreathPointTextrueList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10() {
- return regenerator.wrap(function _callee10$(_context10) {
- while (1) {
- switch (_context10.prev = _context10.next) {
- case 0:
- return _context10.abrupt("return", [{
- url: TEXTURE_URL
- }]);
- case 1:
- case "end":
- return _context10.stop();
- }
- }
- }, _callee10);
- }));
- function getBreathPointTextrueList() {
- return _getBreathPointTextrueList.apply(this, arguments);
- }
- return getBreathPointTextrueList;
- }()
- }], [{
- key: "getInstance",
- value: function getInstance(e, t) {
- //getInstance(e, t) {
- return this.instance || (this.instance = new ModelManager(e, t)), this.instance;
- }
- }, {
- key: "findModels",
- value: function findModels(e, t, r) {
- //findModels(e, t, r) {
- return e.filter(function (o) {
- return o.typeName === t && o.className === r;
- });
- }
- }, {
- key: "findModel",
- value: function findModel(e, t, r) {
- //findModel(e, t, r) {
- var n = e.filter(function (o) {
- return o.typeName === t && o.className === r;
- })[0];
- return n || null;
- }
- }]);
- return ModelManager;
- }();
- // export { modelManager };
- var JoyStick = /*#__PURE__*/function () {
- function JoyStick(e) {
- _classCallCheck(this, JoyStick);
- this._zone = document.createElement("div");
- this._joystick = null;
- this._room = e;
- }
- _createClass(JoyStick, [{
- key: "init",
- value: function init(e) {
- var _this = this;
- var _e$interval = e.interval,
- t = _e$interval === void 0 ? 33 : _e$interval,
- _e$triggerDistance = e.triggerDistance,
- r = _e$triggerDistance === void 0 ? 25 : _e$triggerDistance,
- _e$style = e.style,
- n = _e$style === void 0 ? {
- left: 0,
- bottom: 0
- } : _e$style,
- o = function o(u, c) {
- _this._room.actionsHandler.joystick({
- degree: Math.floor(u),
- level: Math.floor(c / 5)
- });
- },
- a = this._zone;
- 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({
- zone: a,
- mode: "static",
- position: {
- left: "50%",
- top: "50%"
- },
- color: "white"
- });
- var s, l;
- return this._joystick.on("move", function (u, c) {
- s = c;
- }), this._joystick.on("start", function () {
- l = window.setInterval(function () {
- s && s.distance > r && o && o(s.angle.degree, s.distance);
- }, t);
- }), this._joystick.on("end", function () {
- l && window.clearInterval(l), l = void 0;
- }), this._joystick;
- }
- }, {
- key: "show",
- value: function show() {
- if (!this._joystick) throw new Error("joystick is not created");
- this._zone.style.display = "block";
- }
- }, {
- key: "hide",
- value: function hide() {
- if (!this._joystick) throw new Error("joystick is not created");
- this._zone.style.display = "none";
- }
- }]);
- return JoyStick;
- }();
- var CoreBroadcastType = {
- PlayAnimation: 'PlayAnimation'
- };
- var AvatarGroup = {
- Npc: 'npc',
- User: 'user'
- };
- var MessageHandleType$1 = {
- MHT_Undefined: 0,
- MHT_RoomMulticast: 1,
- MHT_FollowListMulticast: 2,
- MHT_CustomTargetSync: 3
- };
- var Broadcast$1 = /*#__PURE__*/function () {
- function Broadcast(e, t) {
- _classCallCheck(this, Broadcast);
- this.room = e;
- this.handlers = [];
- this.init(t);
- }
- _createClass(Broadcast, [{
- key: "init",
- value: function init(t) {
- this.handlers.push(t);
- }
- }, {
- key: "handleBroadcast",
- value: function () {
- var _handleBroadcast = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- _context.prev = 1;
- JSON.parse(e.broadcastAction.data);
- _context.next = 9;
- break;
- case 5:
- _context.prev = 5;
- _context.t0 = _context["catch"](1);
- logger$1.error(_context.t0);
- return _context.abrupt("return");
- case 9:
- case "end":
- return _context.stop();
- }
- }
- }, _callee, null, [[1, 5]]);
- }));
- function handleBroadcast(_x) {
- return _handleBroadcast.apply(this, arguments);
- }
- return handleBroadcast;
- }()
- }, {
- key: "broadcast",
- value: function broadcast(e) {
- var t = e.data,
- _e$msgType = e.msgType,
- r = _e$msgType === void 0 ? MessageHandleType$1.MHT_FollowListMulticast : _e$msgType,
- n = e.targetUserIds;
- return this.room.actionsHandler.broadcast({
- data: t,
- msgType: r,
- targetUserIds: n
- });
- }
- }]);
- return Broadcast;
- }();
- var XAvatarLoader = /*#__PURE__*/function () {
- function XAvatarLoader() {
- _classCallCheck(this, XAvatarLoader);
- E(this, "containers", new Map());
- E(this, "meshes", new Map());
- E(this, "animations", new Map());
- E(this, "aniPath", new Map());
- E(this, "binPath", new Map());
- E(this, "texPath", new Map());
- E(this, "matPath", new Map());
- E(this, "mshPath", new Map());
- E(this, "rootPath", new Map());
- E(this, "meshTexList", new Map());
- E(this, "_enableIdb", !0);
- E(this, "_mappings", new Map());
- E(this, "_sharedTex", new Map());
- E(this, "avaliableAnimation", new Map());
- E(this, "enableShareTexture", !0);
- E(this, "enableShareAnimation", !0);
- E(this, "fillEmptyLod", !0);
- var e = new BABYLON.GLTFFileLoader();
- BABYLON.SceneLoader.RegisterPlugin(e), e.preprocessUrlAsync = function (t) {
- var r = avatarLoader._mappings.get(t);
- return r ? Promise.resolve(r) : Promise.resolve(t);
- };
- }
- _createClass(XAvatarLoader, [{
- key: "getParsedUrl",
- value: function getParsedUrl(e, t, r) {
- var _this = this;
- return new Promise(function (o, a) {
- if (!r || r.indexOf(".zip") === -1) return o(r);
- var s = _this.rootPath.get(r);
- if (s) return o(s);
- {
- var l = ".zip",
- u = r.replace(l, "") + COMPONENT_LIST_PREFIX;
- e.urlTransformer(u, !0).then(function (c) {
- if (!c) return a("Loading Failed");
- new Response(c).json().then(function (h) {
- var _, g, m, v, y, b, T;
- var f = r.replace(l, ""),
- d = f + ((_ = h == null ? void 0 : h.components) == null ? void 0 : _.url.replace("./", ""));
- 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) {
- var A = f + "/" + C.url;
- _this.matPath.set(C.name, A);
- }), h.bin) {
- var C = f + "/" + h.bin.url;
- _this.binPath.set(t, C);
- var A = f + "/" + h.bin.url_lod2;
- _this.binPath.set(t + "_" + avatarSetting.lod[1].level, A);
- var S = f + "/" + h.bin.url_lod4;
- _this.binPath.set(t + "_" + avatarSetting.lod[2].level, S);
- }
- return h.textures && h.textures.forEach(function (C) {
- var A = f + "/" + C.url;
- _this.texPath.set(C.url, A);
- var S = _this.meshTexList.get(h.components.url);
- C.type === "png" && (S ? S.find(function (P) {
- return P === C.name;
- }) || S.push(C.url) : _this.meshTexList.set(t, [C.name]));
- }), o(d);
- }).catch(function (h) {
- logger$1.error("[Engine] parse json file error,".concat(h));
- });
- }).catch(function (c) {
- logger$1.error("[Engine] ulrtransform error, cannot find resource in db,".concat(c));
- });
- }
- });
- }
- }, {
- key: "parse",
- value: function () {
- var _parse = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e, t) {
- var _this2 = this;
- var r;
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- r = [];
- t.forEach(function (n) {
- _this2._setAnimationList(n.id, n.animations), r.push(_this2.getParsedUrl(e, n.id, n.url)), n.components.forEach(function (o) {
- o.units.forEach(function (a) {
- r.push(_this2.getParsedUrl(e, a.name, a.url));
- });
- });
- });
- _context.next = 4;
- return Promise.all(r);
- case 4:
- case "end":
- return _context.stop();
- }
- }
- }, _callee);
- }));
- function parse(_x, _x2) {
- return _parse.apply(this, arguments);
- }
- return parse;
- }()
- }, {
- key: "_setAnimationList",
- value: function _setAnimationList(e, t) {
- var _this3 = this;
- t ? t.forEach(function (r) {
- _this3.aniPath.set(e + "_" + r.name, r.url);
- }) : logger$1.error("[Engine] no animation list exist, please check config for details");
- }
- }, {
- key: "disposeContainer",
- value: function disposeContainer() {
- var _this4 = this;
- this.containers.forEach(function (e, t) {
- 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));
- }), this._sharedTex.forEach(function (e, t) {
- e.xReferenceCount == 0 && (e.dispose(), _this4._sharedTex.delete(t));
- });
- }
- }, {
- key: "enableIdb",
- set: function set(e) {
- this._enableIdb = e;
- }
- }, {
- key: "getGlbPath",
- value: function getGlbPath(e) {
- return this.aniPath.get(e + ".glb");
- }
- }, {
- key: "getGltfPath",
- value: function getGltfPath(e) {
- return this.mshPath.get(e + ".gltf");
- }
- }, {
- key: "getPngUrl",
- value: function getPngUrl(e) {
- return this.texPath.get(e + ".png");
- }
- }, {
- key: "getMeshUrl",
- value: function getMeshUrl(e) {
- return this.mshPath.get(e);
- }
- }, {
- key: "_getSourceKey",
- value: function _getSourceKey(e, t) {
- return t && avatarSetting.lod[t] ? e + avatarSetting.lod[t].fileName.split(".")[0] : e;
- }
- }, {
- key: "_getAnimPath",
- value: function _getAnimPath(e, t) {
- var r = this.aniPath.get(t + "_animations_" + t.split("_")[1]);
- return r || (r = this.aniPath.get(t + "_" + e)), r;
- }
- }, {
- key: "load",
- value: function load(e, t, r, n) {
- var _this5 = this;
- return new Promise(function (o, a) {
- _this5.loadGlb(e, t, r).then(function (s) {
- return s ? o(s) : a("[Engine] container load failed");
- }).catch(function () {
- return a("[Engine] container load failed");
- });
- });
- }
- }, {
- key: "_searchAnimation",
- value: function _searchAnimation(e, t) {
- var r;
- return this.containers.forEach(function (n, o) {
- var a = t.split("_")[0];
- o.indexOf(a) != -1 && o.indexOf(e) != -1 && (r = n);
- }), r;
- }
- }, {
- key: "loadAnimRes",
- value: function loadAnimRes(e, t, r) {
- var _this6 = this;
- return new Promise(function (n, o) {
- var a = _this6._getAnimPath(t, r),
- s = getAnimationKey(t, r);
- if (a && _this6.containers.get(a)) return n(_this6.containers.get(a));
- if (a) _this6._loadGlbFromBlob(e, s, a).then(function (l) {
- return l.animationGroups.length == 0 ? (_this6.containers.delete(s), l.dispose(), Promise.reject("container does not contains animation data")) : n(l);
- });else return o("no such url");
- });
- }
- }, {
- key: "loadGlb",
- value: function loadGlb(e, t, r) {
- var n = this.getMeshUrl(this._getSourceKey(t, r));
- 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");
- }
- }, {
- key: "loadGltf",
- value: function loadGltf(e, t, r, n) {
- var o = this._getSourceKey(t, r || 0);
- var a = this.getGltfPath(o);
- 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();
- }
- }, {
- key: "loadSubsequence",
- value: function loadSubsequence() {}
- }, {
- key: "loadVAT",
- value: function loadVAT() {}
- }, {
- key: "getResourceName",
- value: function getResourceName(e) {
- return this.meshTexList.get(e);
- }
- }, {
- key: "_loadGltfFromUrl",
- value: function _loadGltfFromUrl(e, t, r) {
- return BABYLON.SceneLoader.LoadAssetContainerAsync(r, t + ".gltf", e.Scene, null, ".gltf");
- }
- }, {
- key: "_loadGlbFromBlob",
- value: function _loadGlbFromBlob(e, t, r) {
- var _this7 = this;
- return new Promise(function (n, o) {
- e.urlTransformer(r).then(function (a) {
- BABYLON.SceneLoader.LoadAssetContainerAsync("", a, e.Scene, null, ".glb").then(function (s) {
- if (s) {
- if (_this7.enableShareTexture && s.textures.length > 0) {
- var l = t.indexOf("_lod") != -1 ? t.slice(0, -5) : t,
- u = _this7._sharedTex.get(l);
- u ? (s.meshes[1].material._albedoTexture = u, s.textures.forEach(function (c) {
- c.dispose();
- }), s.textures = [u], u.xReferenceCount++) : (_this7._sharedTex.set(l, s.textures[0]), s.textures[0].xReferenceCount = 1);
- }
- return s.addAllToScene(), s.xReferenceCount = 0, s.meshes.forEach(function (l) {
- l.setEnabled(!1);
- }), _this7.containers.set(r, s), n(s);
- } else o("glb file load failed");
- });
- });
- });
- }
- }, {
- key: "_loadGlbFromUrl",
- value: function _loadGlbFromUrl(e, t, r) {
- var _this8 = this;
- return new Promise(function (n, o) {
- BABYLON.SceneLoader.LoadAssetContainerAsync("", r, e.Scene, null, ".glb").then(function (a) {
- if (a) {
- if (a.addAllToScene(), a.meshes.forEach(function (s) {
- s.setEnabled(!1);
- }), _this8.enableShareTexture && a.textures.length > 0) {
- var s = t.indexOf("_lod") != -1 ? t.slice(0, -5) : t,
- l = _this8._sharedTex.get(s);
- l ? (a.meshes[1].material._albedoTexture = l, a.textures.forEach(function (u) {
- u.dispose();
- }), a.textures = [l], l.xReferenceCount++) : (_this8._sharedTex.set(s, a.textures[0]), a.textures[0].xReferenceCount = 1);
- }
- return a.xReferenceCount = 0, _this8.containers.set(r, a), n(a);
- } else o("glb file load failed");
- });
- });
- }
- }, {
- key: "_loadGltfFromBlob",
- value: function _loadGltfFromBlob(e, t, r, n) {
- var _this9 = this;
- return new Promise(function (o, a) {
- var s = [];
- var l = _this9._getSourceKey(t, r),
- u = _this9.getGltfPath(l);
- 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."));
- var c = _this9.mshPath.get(l + ".gltf");
- if (!c) return a("cannot find asset mshPath");
- var h = _this9.binPath.get(l + ".bin");
- if (!h) return a("cannot find asset binPath");
- if (!n) {
- var _ = _this9.meshTexList.get(t);
- if (!_ || _.length == 0) return a("cannot find texture");
- n = _[0];
- }
- var f = _this9.texPath.get(n + ".png");
- if (!f) return a();
- var d = _this9.texPath.get(n + "-astc.ktx");
- if (!d) return a();
- 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 () {
- var _ = u.replace(l + ".gltf", "");
- BABYLON.SceneLoader.LoadAssetContainerAsync(_, l + ".gltf", e.Scene, null, ".gltf").then(function (g) {
- var v;
- _this9.containers.set(u, g), g.addAllToScene(), g.meshes.forEach(function (y) {
- y.setEnabled(!1);
- });
- var m = _this9._sharedTex.get(t);
- 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);
- });
- });
- });
- }
- }, {
- key: "_blobMapping",
- value: function _blobMapping(e, t) {
- var _this10 = this;
- return new Promise(function (r, n) {
- e.urlTransformer(t).then(function (o) {
- return o ? (_this10._mappings.set(t, o), r(t)) : n("[Engine] url urlTransformer parse error ".concat(t));
- });
- });
- }
- }]);
- return XAvatarLoader;
- }();
- var avatarLoader = new XAvatarLoader();
- 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); }; }
- 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; } }
- var XverseAvatarManager = /*#__PURE__*/function (_EventEmitter) {
- _inherits(XverseAvatarManager, _EventEmitter);
- var _super = _createSuper$d(XverseAvatarManager);
- function XverseAvatarManager(e) {
- var _this;
- _classCallCheck(this, XverseAvatarManager);
- _this = _super.call(this);
- _this.xAvatarManager = null;
- _this.avatars = new Map();
- _this.syncAvatarsLength = 0;
- _this._room = e;
- _this._usersStatistics();
- _this.broadcast = _this.setupBroadcast();
- e.on("skinChanged", function () {
- _this.avatars.forEach(function (t) {
- t.disconnected && _this.removeAvatar(t.userId, !0);
- });
- });
- return _this;
- }
- _createClass(XverseAvatarManager, [{
- key: "setupBroadcast",
- value: function setupBroadcast() {
- var _this2 = this;
- return new Broadcast$1(this._room, /*#__PURE__*/function () {
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
- var t, r, n, o, a, _r$loop, s, l;
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- t = e.broadcastType, r = e.info;
- if (!(t !== CoreBroadcastType.PlayAnimation)) {
- _context.next = 3;
- break;
- }
- return _context.abrupt("return");
- case 3:
- 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);
- _context.t0 = l && !l.isSelf;
- if (!_context.t0) {
- _context.next = 10;
- break;
- }
- l.emit("animationStart", {
- animationName: o,
- extra: decodeURIComponent(a)
- });
- _context.next = 9;
- return l == null ? void 0 : l._playAnimation(o, s);
- case 9:
- l.emit("animationEnd", {
- animationName: o,
- extra: decodeURIComponent(a)
- });
- case 10:
- case "end":
- return _context.stop();
- }
- }
- }, _callee);
- }));
- return function (_x) {
- return _ref.apply(this, arguments);
- };
- }());
- }
- }, {
- key: "hideAll",
- value: function hideAll() {
- var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !0;
- this.xAvatarManager.hideAll(e);
- }
- }, {
- key: "showAll",
- value: function showAll() {
- var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !0;
- this.xAvatarManager.showAll(e);
- }
- }, {
- key: "init",
- value: function () {
- var _init = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
- var e, t;
- return regenerator.wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- this.xAvatarManager = this._room.sceneManager.avatarComponent;
- _context2.prev = 1;
- _context2.next = 4;
- return this._room.modelManager.getApplicationConfig();
- case 4:
- e = _context2.sent;
- t = e.avatars;
- if (!t) {
- _context2.next = 10;
- break;
- }
- _context2.next = 9;
- return avatarLoader.parse(this._room.sceneManager, t);
- case 9:
- return _context2.abrupt("return");
- case 10:
- return _context2.abrupt("return", Promise.reject("cannot find avatar config list"));
- case 13:
- _context2.prev = 13;
- _context2.t0 = _context2["catch"](1);
- return _context2.abrupt("return", (logger$1.error(_context2.t0), Promise.reject("avatar mananger init error!")));
- case 16:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2, this, [[1, 13]]);
- }));
- function init() {
- return _init.apply(this, arguments);
- }
- return init;
- }()
- }, {
- key: "handleAvatar",
- value: function () {
- var _handleAvatar2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
- var _this3 = this;
- var r, t, n, o, _n, a;
- return regenerator.wrap(function _callee3$(_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- if (!(this._room.viewMode === "simple" || !this._room.joined || !e.newUserStates)) {
- _context3.next = 2;
- break;
- }
- return _context3.abrupt("return");
- case 2:
- t = e.newUserStates;
- if (((r = this._room._userAvatar) == null ? void 0 : r.isMoving) && this._room._userAvatar.motionType === MotionType.Run) {
- n = t.filter(function (a) {
- return a.userId === _this3._room.userId;
- }), o = t.filter(function (a) {
- return a.userId !== _this3._room.userId;
- }).slice(0, 2);
- t = n.concat(o);
- }
- if (e.getStateType === GetStateTypes.Event) {
- this.syncAvatarsLength = (t || []).length;
- _n = this._room.avatars.filter(function (s) {
- return s.group == AvatarGroup.User;
- });
- _n.filter(function (s) {
- return !(t != null && t.find(function (l) {
- return l.userId == s.userId;
- }));
- }).forEach(function (s) {
- _this3.removeAvatar(s.userId);
- });
- a = t.filter(function (s) {
- return !_n.find(function (l) {
- return l.userId == s.userId;
- });
- });
- this._handleAvatar(a);
- }
- this._handleAvatar(t);
- case 6:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee3, this);
- }));
- function handleAvatar(_x2) {
- return _handleAvatar2.apply(this, arguments);
- }
- return handleAvatar;
- }()
- }, {
- key: "_handleAvatar",
- value: function () {
- var _handleAvatar3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
- var _this4 = this;
- return regenerator.wrap(function _callee4$(_context4) {
- while (1) {
- switch (_context4.prev = _context4.next) {
- case 0:
- e == null || e.forEach(function (t) {
- var n, o, a, s, l, u, c, h, f;
- var r = _this4._room.userId === t.userId;
- if (((n = t.event) == null ? void 0 : n.type) === SyncEventType.ET_RemoveVisitor) {
- var d = (a = (o = t.event) == null ? void 0 : o.removeVisitorEvent) == null ? void 0 : a.removeVisitorEvent,
- _ = JSON.parse(safeDecodeURIComponent(((l = (s = t.event) == null ? void 0 : s.removeVisitorEvent) == null ? void 0 : l.extraInfo) || "")),
- g = _.code,
- m = _.msg;
- d === RemoveVisitorType.RVT_ChangeToObserver ? _this4._room.audienceViewModeHook() : d === RemoveVisitorType.RVT_MoveOutOfTheRoom && _this4._room.leave(), _this4._room.emit("visitorStatusChanged", {
- code: g,
- msg: m
- });
- }
- if (t.event && [SyncEventType.Appear, SyncEventType.Reset].includes(t.event.type) || !t.event) {
- var _d = _this4.avatars.get(t.userId);
- if (t.playerState.avatarId && (_d == null ? void 0 : _d.avatarId) !== t.playerState.avatarId && (_d = void 0, _this4.removeAvatar(t.userId)), _d) {
- 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) {
- var _2 = safeParseComponents(t.playerState.avatarComponents);
- _d._changeComponents({
- avatarComponents: _2,
- mode: ChangeComponentsMode.Preview
- });
- }
- } else {
- var _t$playerState$player = t.playerState.player,
- _3 = _t$playerState$player.position,
- _g = _t$playerState$player.angle,
- _m = t.playerState.avatarId,
- v = t.playerState.prioritySync,
- y = safelyJsonParse(t.playerState.extra);
- if (!_m) return;
- var b = safeParseComponents(t.playerState.avatarComponents),
- T = safeDecodeURIComponent(t.playerState.nickName),
- C = _this4.calculatePriority(t.userId, y);
- _this4.addAvatar({
- userId: t.userId,
- isHost: t.playerState.isHost,
- nickname: T,
- avatarPosition: _3,
- avatarRotation: _g,
- avatarScale: t.playerState.avatarSize,
- avatarId: _m,
- avatarComponents: t.playerState.person === Person.First ? [] : b,
- priority: C,
- group: AvatarGroup.User,
- prioritySync: v,
- extraInfo: y
- }).then(function () {
- var A;
- (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"));
- }).catch(function (A) {
- r && (_this4.xAvatarManager.setMainAvatar(t.userId), _this4._room.emit("userAvatarFailed", {
- error: A
- }), logger$1.error("userAvatarFailed", A));
- });
- }
- }
- 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) {
- (h = t == null ? void 0 : t.event) != null && h.id && _this4._room.actionsHandler.confirmEvent(t.event.id);
- var _d2 = _this4.avatars.get(t.userId);
- _d2 && _d2.withModel && !_d2.isLoading && _this4.updateAvatarPositionAndRotation(t);
- }
- if (!r && ((f = t.event) == null ? void 0 : f.type) === SyncEventType.Rotate) {
- var _d3 = _this4.avatars.get(t.userId);
- _d3.statusSyncQueue.append({
- type: QueueType.Rotate,
- action: function action() {
- return _d3.statusSync(t);
- }
- });
- }
- });
- case 1:
- case "end":
- return _context4.stop();
- }
- }
- }, _callee4);
- }));
- function _handleAvatar(_x3) {
- return _handleAvatar3.apply(this, arguments);
- }
- return _handleAvatar;
- }()
- }, {
- key: "calculatePriority",
- value: function calculatePriority(e, t) {
- var n;
- return e === this._room.userId ? EAvatarRelationRank.Self : (n = this._room.options.firends) != null && n.includes(e) ? EAvatarRelationRank.Friend : EAvatarRelationRank.Stranger;
- }
- }, {
- key: "updateAvatarPositionAndRotation",
- value: function updateAvatarPositionAndRotation(e) {
- var t, r;
- if ((t = e == null ? void 0 : e.playerState) != null && t.player) {
- var _e$playerState$player = e.playerState.player,
- n = _e$playerState$player.position,
- o = _e$playerState$player.angle;
- var a = this.avatars.get(e.userId);
- if (!a) return;
- 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({
- type: QueueType.Move,
- action: function action() {
- return a.statusSync(e);
- }
- }), e.renderInfo && a.isSelf) {
- var _e$renderInfo = e.renderInfo,
- s = _e$renderInfo.isMoving,
- l = _e$renderInfo.isRotating;
- this._updateAvatarMovingStatus({
- id: e.userId,
- isMoving: !!s,
- isRotating: !!l
- });
- }
- }
- }
- }, {
- key: "addAvatar",
- value: function () {
- var _addAvatar = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(e) {
- 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;
- return regenerator.wrap(function _callee5$(_context5) {
- while (1) {
- switch (_context5.prev = _context5.next) {
- case 0:
- 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;
- g = this.avatars.get(t);
- if (!g) {
- _context5.next = 4;
- break;
- }
- return _context5.abrupt("return", Promise.resolve(g));
- case 4:
- if (!(g = new xe.subAvatar({
- userId: t,
- isHost: r,
- isSelf: _,
- room: this._room,
- avatarComponents: l,
- avatarId: o,
- nickname: s,
- group: c
- }), this.avatars.set(t, g), !g.withModel)) {
- _context5.next = 6;
- break;
- }
- return _context5.abrupt("return", (g.isLoading = !1, g.avatarLoadedHook(), this._room.emit("avatarChanged", {
- avatars: this._room.avatars
- }), g));
- case 6:
- _context5.next = 8;
- return this._room.modelManager.getAvatarModelList();
- case 8:
- v = _context5.sent.find(function (b) {
- return b.id === o;
- });
- y = Date.now();
- if (v) {
- _context5.next = 12;
- break;
- }
- return _context5.abrupt("return", (this._room.emit("avatarChanged", {
- avatars: this._room.avatars
- }), this.avatars.delete(t), Promise.reject("no such avatar model with id: ".concat(o))));
- case 12:
- _context5.prev = 12;
- _context5.next = 15;
- return avatarComponentsModify(v, l);
- case 15:
- b = _context5.sent;
- b = b.filter(function (A) {
- return A.type != "pendant";
- });
- _context5.next = 19;
- return avatarComponentsParser(v, b);
- case 19:
- T = _context5.sent;
- _context5.next = 22;
- return this.xAvatarManager.loadAvatar({
- id: t,
- avatarType: o,
- priority: u,
- avatarManager: this.xAvatarManager,
- assets: T,
- status: {
- avatarPosition: n,
- avatarRotation: a,
- avatarScale: h
- }
- })._timeout(8e3, new TimeoutError$1("loadAvatar timeout(8s)"));
- case 22:
- C = _context5.sent;
- 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", {
- avatars: this._room.avatars
- }), s && g._setNickname(s), t === this._room.userId && (logger$1.infoAndReportMeasurement({
- metric: "avatarLoadDuration",
- startTime: y,
- group: "costs"
- }), logger$1.infoAndReportMeasurement({
- metric: "avatarLoadAt",
- startTime: this._room._startTime,
- group: "costs"
- })), g));
- case 26:
- _context5.prev = 26;
- _context5.t0 = _context5["catch"](12);
- return _context5.abrupt("return", (g.isLoading = !1, this._room.emit("avatarChanged", {
- avatars: this._room.avatars
- }), logger$1.error(_context5.t0), Promise.reject(_context5.t0)));
- case 29:
- case "end":
- return _context5.stop();
- }
- }
- }, _callee5, this, [[12, 26]]);
- }));
- function addAvatar(_x4) {
- return _addAvatar.apply(this, arguments);
- }
- return addAvatar;
- }()
- }, {
- key: "removeAvatar",
- value: function removeAvatar(e) {
- var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
- var r = this.avatars.get(e);
- if (!!r) {
- if (r.removeWhenDisconnected || t) {
- r.xAvatar && this.xAvatarManager.deleteAvatar(r.xAvatar), this.avatars.delete(e), this._room.emit("avatarChanged", {
- avatars: this._room.avatars
- });
- return;
- }
- r.setConnectionStatus(!0);
- }
- }
- }, {
- key: "clearOtherUsers",
- value: function clearOtherUsers() {
- var _this5 = this;
- this.avatars.forEach(function (e) {
- !e.isSelf && e.group === AvatarGroup.User && _this5.removeAvatar(e.userId);
- });
- }
- }, {
- key: "_updateAvatarMovingStatus",
- value: function () {
- var _updateAvatarMovingStatus2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e) {
- var t, r, n, o, a, _a;
- return regenerator.wrap(function _callee6$(_context6) {
- while (1) {
- switch (_context6.prev = _context6.next) {
- case 0:
- t = e.id, r = e.isMoving, n = e.isRotating, o = this.avatars.get(t);
- if (!!o) {
- if (o.isRotating !== n) {
- o.isRotating = n;
- a = "Idle";
- n && (a = "Walking", o.motionType === MotionType.Run && (a = "Running")), o._playAnimation(a, !0, !0), logger$1.infoAndReportMeasurement({
- startTime: Date.now(),
- value: 0,
- metric: n ? "userAvatarStartRotating" : "userAvatarStopRotating",
- extra: {
- motionType: o.motionType,
- moveToExtra: this._room.moveToExtra
- }
- });
- }
- if (o.isMoving !== r) {
- o.isMoving = r;
- _a = "Idle";
- r && (_a = "Walking", o.motionType === MotionType.Run && (_a = "Running")), r ? (o.avatarStartMovingHook(), o.emit("startMoving", {
- target: o,
- extra: this._room.moveToExtra
- })) : (o.avatarStopMovingHook(), o.emit("stopMoving", {
- target: o,
- extra: this._room.moveToExtra
- })), o._playAnimation(_a, !0, !0), logger$1.infoAndReportMeasurement({
- startTime: Date.now(),
- value: 0,
- metric: r ? "userAvatarStartMoving" : "userAvatarStopMoving",
- extra: {
- motionType: o.motionType,
- moveToExtra: this._room.moveToExtra
- }
- });
- }
- }
- case 2:
- case "end":
- return _context6.stop();
- }
- }
- }, _callee6, this);
- }));
- function _updateAvatarMovingStatus(_x5) {
- return _updateAvatarMovingStatus2.apply(this, arguments);
- }
- return _updateAvatarMovingStatus;
- }()
- }, {
- key: "_usersStatistics",
- value: function _usersStatistics() {
- var _this6 = this;
- this.on("userAvatarLoaded", function () {
- window.setInterval(function () {
- var e = _this6._room.avatars.filter(function (r) {
- return r.group === AvatarGroup.User;
- }).length || 0,
- t = _this6._room.avatars.filter(function (r) {
- return r.group === AvatarGroup.User && r.isRender;
- }).length || 0;
- _this6._room.stats.assign({
- userNum: e,
- syncUserNum: _this6.syncAvatarsLength,
- renderedUserNum: t
- });
- }, 3e3);
- });
- }
- }]);
- return XverseAvatarManager;
- }(EventEmitter);
- var PathManager = /*#__PURE__*/function () {
- function PathManager() {
- _classCallCheck(this, PathManager);
- this.currentArea = '';
- this.currentPathName = '';
- this.currentAttitude = '';
- this.speed = 0;
- }
- _createClass(PathManager, [{
- key: "getSpeed",
- value: function getSpeed(e) {
- var t = {
- guangchang: {
- [MotionType.Walk]: 17,
- [MotionType.Run]: 51
- },
- tower: {
- [MotionType.Walk]: 12.5,
- [MotionType.Run]: 25
- },
- zhiboting: {
- [MotionType.Walk]: 12.5,
- [MotionType.Run]: 25
- },
- youxiting: {
- [MotionType.Walk]: 12.5,
- [MotionType.Run]: 25
- },
- diqing: {
- [MotionType.Walk]: 12.5,
- [MotionType.Run]: 25
- }
- },
- r = t[this.currentArea] || t.guangchang;
- return this.speed = r[e] * 30, this.speed;
- }
- }]);
- return PathManager;
- }();
- var CameraStates = {
- Normal: 0,
- ItemView: 1,
- CGView: 2,
- PathView: 3
- };
- var Person$1 = {
- Third: 0,
- First: 1
- };
- var EImageQuality = {
- low: 0,
- mid: 1,
- high: 2
- };
- var Actions = {
- Clicking: 1,
- PlayCG: 6,
- Back: 7,
- ChangeRoom: 8,
- ChangeSkin: 13,
- Joystick: 15,
- Transfer: 18,
- GetOnVehicle: 22,
- GetOffVehicle: 23,
- StopMoving: 34,
- UnaryActionLine: 1e3,
- Init: 1001,
- Exit: 1002,
- SetIFrameInfo: 1003,
- GetNeighborPoints: 1004,
- ReserveSeat: 1005,
- GetReserveStatus: 1006,
- ChangeNickname: 1007,
- ChangeBitRateInfo: 1008,
- Echo: 1009,
- SetPlayerState: 1010,
- TurnTo: 1011,
- TurnToFace: 1012,
- RotateTo: 1013,
- Rotation: 1014,
- CameraTurnTo: 1015,
- ConfirmEvent: 1016,
- Broadcast: 1017,
- NotifyActionLine: 2e4,
- AudienceChangeToVisitor: 1020,
- VisitorChangeToAudience: 1021,
- RemoveVisitor: 1022,
- GetUserWithAvatar: 1023
- };
- 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); }; }
- 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; } }
- var Camera = /*#__PURE__*/function (_EventEmitter) {
- _inherits(Camera, _EventEmitter);
- var _super = _createSuper$c(Camera);
- function Camera(e) {
- var _this;
- _classCallCheck(this, Camera);
- _this = _super.call(this);
- _this.initialFov = 0;
- _this._state = CameraStates.Normal;
- _this._person = Person$1.Third;
- _this._cameraFollowing = !0;
- _this._room = e;
- return _this;
- }
- _createClass(Camera, [{
- key: "checkPointOnLeftOrRight",
- value: function checkPointOnLeftOrRight(e) {
- var t = ue4Position2Xverse(e);
- if (!t || this.checkPointInView(e)) return;
- var o = this._room.scene.activeCamera;
- if (!o) return;
- var a = [o.target.x, o.target.y, o.target.z],
- s = [o.position.x, o.position.y, o.position.z],
- l = t.x,
- u = t.y,
- c = t.z,
- h = calNormVector(s, a),
- f = calNormVector(s, [l, u, c]);
- return vectorCrossMulti(h, f) < 0 ? Direction.Right : Direction.Left;
- }
- }, {
- key: "checkPointInView",
- value: function checkPointInView(e, t, r) {
- var n = ue4Position2Xverse({
- x: e,
- y: t,
- z: r
- });
- if (!n) return !1;
- for (var o = 0; o < 6; o++) {
- if (this._room.scene.frustumPlanes[o].dotCoordinate(n) < 0) return !1;
- }
- return !0;
- }
- }, {
- key: "person",
- get: function get() {
- return this._person;
- }
- }, {
- key: "state",
- get: function get() {
- return this._state;
- }
- }, {
- key: "pose",
- get: function get() {
- return this._room.currentClickingState.camera;
- }
- }, {
- key: "cameraFollowing",
- get: function get() {
- return this._cameraFollowing;
- },
- set: function set(e) {
- logger$1.info("cameraFollowing setter", e), this.setCameraFollowing({
- isFollowHost: e
- });
- }
- }, {
- key: "setCameraFollowing",
- value: function setCameraFollowing(_ref) {
- _ref.isFollowHost;
- }
- }, {
- key: "handleRenderInfo",
- value: function handleRenderInfo(e) {
- var t = e.renderInfo.cameraStateType,
- r = this._room.sceneManager;
- 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", {
- state: t
- })), this._room.isHost) return;
- var n = e.playerState.isFollowHost;
- !!n !== this._cameraFollowing && (this._cameraFollowing = !!n, this.emit("cameraFollowingChanged", {
- cameraFollowing: !!n
- }));
- }
- }, {
- key: "setCameraState",
- value: function setCameraState(_ref2) {
- var e = _ref2.state;
- if (this._state === e) {
- logger$1.warn("You are already in ".concat(CameraStates[e], " camera state"));
- return;
- }
- e === CameraStates.Normal || this._state === CameraStates.ItemView && logger$1.warn("CloseUp camera state can only be triggerd by room internally");
- }
- }, {
- key: "turnToFace",
- value: function turnToFace(_ref3) {
- var _ref3$extra = _ref3.extra,
- e = _ref3$extra === void 0 ? "" : _ref3$extra,
- _ref3$offset = _ref3.offset,
- t = _ref3$offset === void 0 ? 0 : _ref3$offset;
- var r = {
- action_type: Actions.TurnToFace,
- turn_to_face_action: {
- offset: t
- }
- };
- return this.emit("viewChanged", {
- extra: e
- }), this._room.actionsHandler.sendData({
- data: r
- });
- }
- }, {
- key: "isInDefaultView",
- value: function isInDefaultView() {
- if (!this._room.isHost) {
- logger$1.warn("It is recommended to call the function on the host side");
- return;
- }
- if (!this._room._currentClickingState) return logger$1.error("CurrentState should not be empty"), !1;
- var _this$_room$_currentC = this._room._currentClickingState,
- e = _this$_room$_currentC.camera,
- t = _this$_room$_currentC.player;
- return Math.abs(t.angle.yaw - 180 - e.angle.yaw) % 360 <= 4;
- }
- }, {
- key: "screenShot",
- value: function () {
- var _screenShot = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(_ref4) {
- var e, _ref4$autoSave, t, r, n, o;
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- e = _ref4.name, _ref4$autoSave = _ref4.autoSave, t = _ref4$autoSave === void 0 ? !1 : _ref4$autoSave;
- r = this._room.scene.getEngine(), n = this._room.scene.activeCamera;
- _context.prev = 2;
- this._room.sceneManager.setImageQuality(EImageQuality.high);
- _context.next = 6;
- return CreateScreenshotAsync(r, n, {
- precision: 1
- });
- case 6:
- o = _context.sent;
- return _context.abrupt("return", (this._room.sceneManager.setImageQuality(EImageQuality.low), t === !0 && downloadFileByBase64(o, e), Promise.resolve(o)));
- case 10:
- _context.prev = 10;
- _context.t0 = _context["catch"](2);
- return _context.abrupt("return", (this._room.sceneManager.setImageQuality(EImageQuality.low), Promise.reject(_context.t0)));
- case 13:
- case "end":
- return _context.stop();
- }
- }
- }, _callee, this, [[2, 10]]);
- }));
- function screenShot(_x) {
- return _screenShot.apply(this, arguments);
- }
- return screenShot;
- }()
- }, {
- key: "changeToFirstPerson",
- value: function changeToFirstPerson(e, t, r) {
- var _this2 = this;
- var n = e.camera,
- o = e.player,
- a = e.attitude,
- s = e.areaName,
- l = e.pathName;
- return this._room.actionsHandler.requestPanorama({
- camera: n,
- player: o,
- attitude: a,
- areaName: s,
- pathName: l
- }, t, r).then(function () {
- _this2._room.networkController.rtcp.workers.changePanoMode(!0);
- var _ref5 = o || {},
- u = _ref5.position,
- c = _ref5.angle;
- _this2._room.sceneManager.cameraComponent.changeToFirstPersonView({
- position: u,
- rotation: c
- });
- });
- }
- }, {
- key: "setPerson",
- value: function setPerson(e) {
- var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
- camera: this._room._currentClickingState.camera,
- player: this._room._currentClickingState.player
- };
- var r = Date.now();
- return this._setPerson(e, t).then(function (n) {
- return logger$1.infoAndReportMeasurement({
- tag: Person$1[e],
- startTime: r,
- metric: "setPerson"
- }), n;
- }).catch(function (n) {
- return logger$1.infoAndReportMeasurement({
- tag: Person$1[e],
- startTime: r,
- metric: "setPerson",
- error: n
- }), Promise.reject(n);
- });
- }
- }, {
- key: "_setPerson",
- value: function _setPerson(e) {
- var _this3 = this;
- var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
- camera: this._room._currentClickingState.camera,
- player: this._room._currentClickingState.player
- };
- return e !== Person$1.First && e !== Person$1.Third ? Promise.reject("invalid person " + e) : !t.camera || !t.player ? Promise.reject(new ParamError("wrong camera or player")) : e === Person$1.First ? this._room.panorama.access({
- camera: t.camera,
- player: t.player,
- tag: "setPerson"
- }).then(function () {
- var o, a;
- _this3._person = e, (o = _this3._room._userAvatar) == null || o.hide();
- var _ref6 = ((a = _this3._room.currentClickingState) == null ? void 0 : a.camera) || {},
- r = _ref6.position,
- n = _ref6.angle;
- !r || !n || _this3._room.sceneManager.cameraComponent.changeToFirstPersonView({
- position: r,
- rotation: n
- });
- }) : this._room.panorama.exit({
- camera: t.camera,
- player: t.player
- }).then(function () {
- var r, n;
- _this3._person = e, (r = _this3._room._userAvatar) != null && r.xAvatar && ((n = _this3._room._userAvatar) == null || n.xAvatar.show());
- });
- }
- }, {
- key: "setCameraPose",
- value: function setCameraPose(e) {
- this._room.sceneManager.cameraComponent.setCameraPose({
- position: e.position,
- rotation: e.angle
- });
- }
- }, {
- key: "setMainCameraRotationLimit",
- value: function setMainCameraRotationLimit(e) {
- var t = e.limitAxis,
- r = e.limitRotation;
- this._room.sceneManager.cameraComponent.setMainCameraRotationLimit(t, r);
- }
- }]);
- return Camera;
- }(EventEmitter);
- 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); }; }
- 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; } }
- var numberFormat = new Intl.NumberFormat(window.navigator.language, {
- maximumFractionDigits: 0
- });
- var Stats = /*#__PURE__*/function (_EventEmitter) {
- _inherits(Stats, _EventEmitter);
- var _super = _createSuper$b(Stats);
- function Stats(e) {
- var _this;
- _classCallCheck(this, Stats);
- _this = _super.call(this);
- _this._netInterval = null;
- _this._disabled = !1;
- _this._show = !1;
- _this._aggregatedStats = {};
- _this._displayElement = null;
- _this._extraStats = {};
- _this._networkSamples = [];
- _this.externalStats = null;
- _this.constructedTime = null;
- _this.room = e, _this.constructedTime = Date.now(), _this._interval = window.setInterval(function () {
- var t, r, n;
- _this._disabled || _this.onStats((n = (r = (t = e.networkController) == null ? void 0 : t.rtcp) == null ? void 0 : r.workers) == null ? void 0 : n.uploadDataToServer());
- }, 1e3), _this._netInterval = window.setInterval(function () {
- _this.getIsWeakNet();
- }, NET_INTERVAL * 1e3);
- return _this;
- }
- _createClass(Stats, [{
- key: "isShow",
- get: function get() {
- return this._show;
- }
- }, {
- key: "assign",
- value: function assign(e) {
- Object.assign(this._extraStats, e), ((e == null ? void 0 : e.hb) || (e == null ? void 0 : e.rtt)) && this.startStatsNetSamples();
- }
- }, {
- key: "appendExternalStats",
- value: function appendExternalStats(e) {
- var _this2 = this;
- var t = {};
- if (!e || typeof e != "object") {
- console.warn("appendExternalStats should be plain object");
- return;
- }
- Object.keys(e).forEach(function (r) {
- Object.prototype.hasOwnProperty.call(_this2._aggregatedStats, r) ? console.warn("".concat(r, " is duplicate with internal stats")) : t[r] = e[r];
- }), !(Object.keys(t).length > 10) && (this.externalStats = t);
- }
- }, {
- key: "getRtt",
- value: function getRtt() {
- var e = this._extraStats.rtt;
- return typeof e != "number" ? 0 : e > 999 ? 999 : e;
- }
- }, {
- key: "enable",
- value: function enable() {
- this._disabled = !1;
- }
- }, {
- key: "disable",
- value: function disable() {
- this._disabled = !0;
- }
- }, {
- key: "disableNet",
- value: function disableNet() {
- this._netInterval && window.clearInterval(this._netInterval);
- }
- }, {
- key: "show",
- value: function show() {
- this._show = !0, this._render();
- }
- }, {
- key: "hide",
- value: function hide() {
- this._show = !1, this._displayElement && document.body.removeChild(this._displayElement), this._displayElement = null;
- }
- }, {
- key: "getIsWeakNet",
- value: function getIsWeakNet() {
- var _this3 = this;
- var e = !1;
- var t = this._networkSamples.length - 1;
- if (t < 0) return;
- var r = this._networkSamples[t].time,
- n = this._networkSamples[0].time,
- o = r - n,
- a = 1e3 * (DURATION - 2);
- if (o < a) return;
- var s = this._networkSamples.map(function (g) {
- return _this3.isNetDelay(g, "rtt");
- }),
- l = this._networkSamples.map(function (g) {
- return _this3.isNetDelay(g, "hb");
- }),
- u = s.reduce(function (g, m) {
- return g + m;
- }, 0),
- c = l.reduce(function (g, m) {
- return g + m;
- }, 0),
- h = Math.floor(u / this._networkSamples.length) * 100,
- f = Math.floor(c / this._networkSamples.length) * 100,
- d = 70;
- (h >= d || f >= d) && (e = !0);
- var _ = this.room.viewMode === "observer" || this.room.viewMode === "serverless";
- e && !_ && (logger$1.infoAndReportMeasurement({
- metric: "weakNetwork",
- startTime: Date.now(),
- extra: {
- msg: this._networkSamples.slice(20),
- netDelayRTTValues: u,
- netDelayHBValues: c
- }
- }), this.emit("weakNetwork"));
- }
- }, {
- key: "startStatsNetSamples",
- value: function startStatsNetSamples() {
- var _this$_extraStats = this._extraStats,
- e = _this$_extraStats.rtt,
- t = _this$_extraStats.hb;
- if (e || t) {
- var r = {
- rtt: e,
- hb: t,
- time: new Date().getTime()
- };
- this._networkSamples.push(r);
- var n = this._networkSamples.length - 1;
- if (n < 0) return;
- var o = this._networkSamples[n].time,
- a = 1e3 * DURATION;
- this._networkSamples = this._networkSamples.filter(function (s) {
- return s.time > o - a;
- });
- }
- }
- }, {
- key: "isNetDelay",
- value: function isNetDelay(e, t) {
- return t === "rtt" ? e.rtt > RTT_MAX_VALUE ? 1 : 0 : t === "hb" && e.hb > HB_MAX_VALUE ? 1 : 0;
- }
- }, {
- key: "getPreciesTimer",
- value: function getPreciesTimer(e, t) {
- var r = t * 1e3,
- n = new Date().getTime();
- var o = 0;
- o++;
- var a = new Date().getTime() - (n + o * 1e3),
- s = r - a,
- l = setTimeout(function () {
- clearTimeout(l), e();
- }, s);
- }
- }, {
- key: "_render",
- value: function _render() {
- var c, h, f, d, _, g, m, v, y, b, T, C, A, S, P, R, M, x, I, w;
- if (!this._aggregatedStats) return;
- 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));
- var e = [],
- t = Date.now() - this.constructedTime,
- r = Math.floor(t / 1e3 % 60),
- n = Math.floor(t / (1e3 * 60) % 60),
- o = Math.floor(t / (1e3 * 60 * 60) % 24),
- a = o < 10 ? "0" + o.toString() : o.toString(),
- s = n < 10 ? "0" + n : n,
- l = r < 10 ? "0" + r : r;
- e.push({
- key: new Date(Math.floor(this._aggregatedStats.timestamp || 0)).toLocaleString("en-GB"),
- value: a + ":" + s + ":" + l
- }), e.push({
- key: "rtt: " + this._extraStats.rtt + " hb: " + this._extraStats.hb,
- value: "FPS: " + this._extraStats.fps + " avatar: " + ((c = this.room._userAvatar) == null ? void 0 : c.state)
- }), e.push({
- key: "SDK: " + Xverse$1.SUB_PACKAGE_VERSION,
- value: "ENGINE:" + VERSION$1 + " uid:" + this._extraStats.userId
- }), e.push({
- key: "\u540C\u6B65/\u6709\u6548/\u663E\u793A\u73A9\u5BB6",
- value: "".concat(this._extraStats.syncUserNum || 0, "/").concat(this._extraStats.userNum || 0, "/").concat(this._extraStats.renderedUserNum || 0)
- }), e.push({
- key: "media/meta bitrate(kbps)",
- value: numberFormat.format(this._aggregatedStats.mediaBitrate || 0) + "/" + numberFormat.format(this._aggregatedStats.metaBitrate || 0)
- }), e.push({
- key: ":----------------Decoding---------------",
- value: ""
- }), e.push({
- key: "-max/avg decodeTime(ms)",
- value: numberFormat.format(this._aggregatedStats.decodeTimeMaxFrame || 0) + "/" + numberFormat.format(this._aggregatedStats.decodeTimePerFrame || 0)
- }), e.push({
- key: "-frmAwait/Lost/Drop",
- 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
- }), e.push({
- key: ":----------------FrameLoop-------------",
- value: ""
- }), e.push({
- key: "interval(max/avg/>40)",
- 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
- }), e.push({
- key: "systemStuck",
- value: this._extraStats.systemStuckCnt
- }), e.push({
- key: "--update",
- value: (this._aggregatedStats.maxGraphicTime.toFixed(1) || 0) + "/" + (((d = this._aggregatedStats.averageGraphicTime) == null ? void 0 : d.toFixed(0)) || 0)
- }), e.push({
- key: "--timeout",
- value: (((_ = this._extraStats.maxTimeoutTime) == null ? void 0 : _.toFixed(1)) || 0) + "/" + ((g = this._extraStats.avgTimeoutTime) == null ? void 0 : g.toFixed(0)) || 0
- }), e.push({
- key: "--render",
- value: (((m = this._extraStats.maxRenderFrameTime) == null ? void 0 : m.toFixed(1)) || 0) + "/" + (((v = this._extraStats.renderFrameTime) == null ? void 0 : v.toFixed(0)) || 0)
- }), e.push({
- key: "---anim/regBR/clip(avg ms)",
- value: (this._extraStats.animationTime.toFixed(2) || 0) + " / " + (this._extraStats.registerBeforeRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.meshSelectTime.toFixed(2) || 0)
- }), e.push({
- key: "---anim/regBR/clip(max ms)",
- value: (this._extraStats.maxAnimationTime.toFixed(2) || 0) + " / " + (this._extraStats.maxRegisterBeforeRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.maxMeshSelectTime.toFixed(2) || 0)
- }), e.push({
- key: "---rTR/drC/regAF(avg ms)",
- value: (this._extraStats.renderTargetRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.drawcallTime.toFixed(2) || 0) + " / " + (this._extraStats.registerAfterRenderTime.toFixed(2) || 0)
- }), e.push({
- key: "---rTR/drC/regAF(max ms)",
- value: (this._extraStats.maxRenderTargetRenderTime.toFixed(2) || 0) + " / " + (this._extraStats.maxDrawcallTime.toFixed(2) || 0) + " / " + (this._extraStats.maxRegisterAfterRenderTime.toFixed(2) || 0)
- }), e.push({
- key: "--tri/drC/pati/bones/anim(Num)",
- 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)
- }), e.push({
- key: "--rootN/mesh/geo/tex/mat(Num)",
- 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)
- }), e.push({
- key: "--registerBF/AF(Num)",
- value: (this._extraStats.registerBeforeCount.toFixed(0) || 0) + " / " + (this._extraStats.registerAfterCount.toFixed(0) || 0)
- }), e.push({
- key: ":----------------Rotation-------------------",
- value: ""
- }), e.push({
- key: "Total(ms/miss)",
- value: (((y = this._aggregatedStats.avgOverallTime) == null ? void 0 : y.toFixed(2)) || 0) + "/" + (this._aggregatedStats.responseMissPs + this._aggregatedStats.processMissPs + this._aggregatedStats.displayMissPs)
- }), e.push({
- key: "--rotateRsp",
- value: (((b = this._aggregatedStats.avgResponseTime) == null ? void 0 : b.toFixed(1)) || 0) + "/" + this._aggregatedStats.responseMissPs
- }), e.push({
- key: "--rotateProc",
- value: (((T = this._aggregatedStats.avgProcessTime) == null ? void 0 : T.toFixed(1)) || 0) + "/" + this._aggregatedStats.processMissPs
- }), e.push({
- key: "--rotateShow",
- value: (((C = this._aggregatedStats.avgDisplayTime) == null ? void 0 : C.toFixed(1)) || 0) + "/" + this._aggregatedStats.displayMissPs
- }), ((A = this.room._userAvatar) == null ? void 0 : A.state) == "moving", e.push({
- key: ":----------------Move----------------------",
- value: ""
- }), e.push({
- key: "-startDelay",
- 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)
- }), (((S = this.room._userAvatar) == null ? void 0 : S.state) == "moving" || this._aggregatedStats.moveEvent == "GetOnAirship" || this._aggregatedStats.moveEvent == "GetOnVehicle") && e.push({
- key: "-srvInterFrm(max/avg)",
- value: (this._aggregatedStats.maxServerDiff || 0) + "/" + (this._aggregatedStats.avgServerDiff.toFixed(1) || 0)
- }), e.push({
- key: "-interFrameDelay",
- value: "(max/avg/jank)"
- }), e.push({
- key: "--toDisplay",
- 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)
- }), e.push({
- key: "--received",
- 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)
- }), e.push({
- key: "--decoded",
- 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)
- }), e.push({
- key: ":----------------DevInfo-----------------",
- value: ""
- }), e.push({
- key: "sd",
- value: (this._aggregatedStats.sdMoveResponseLongTime.toFixed(1) || 0) + "/" + (this._aggregatedStats.sdMoveProcessLongTime.toFixed(1) || 0) + "/" + (this._aggregatedStats.sdMoveDisplayLongTime.toFixed(1) || 0)
- }), e.push({
- key: "----hardwareInfo",
- value: this._extraStats.hardwareInfo
- });
- var u = "";
- for (var _i = 0, _e = e; _i < _e.length; _i++) {
- var O = _e[_i];
- u += "<div><span>".concat(O.key, "</span>: <span>").concat(O.value, "</span> </div>");
- }
- this._displayElement.innerHTML = u;
- }
- }, {
- key: "onStats",
- value: function onStats(e) {
- var _this4 = this;
- var n;
- if (!e) return;
- var t = {},
- r = this;
- 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) {
- t[o] = _this4.externalStats[o];
- }), r._aggregatedStats = t, this.emit("stats", {
- stats: t
- });
- }
- }]);
- return Stats;
- }(EventEmitter);
- 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); }; }
- 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; } }
- var EventsManager = /*#__PURE__*/function (_EventEmitter) {
- _inherits(EventsManager, _EventEmitter);
- var _super = _createSuper$a(EventsManager);
- function EventsManager() {
- var _this;
- _classCallCheck(this, EventsManager);
- _this = _super.apply(this, arguments);
- E(_assertThisInitialized(_this), "events", new Map());
- E(_assertThisInitialized(_this), "specialEvents", new Map());
- return _this;
- }
- _createClass(EventsManager, [{
- key: "remove",
- value: function remove(e, t, r, n) {
- if (this.specialEvents.has(e) && !n && t === Codes$1.Success) return;
- this.events.get(e) && (this.emit(e, {
- code: t,
- data: r
- }), this.events.delete(e), this.specialEvents.delete(e));
- }
- }, {
- key: "track",
- value: function () {
- var _track = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e, t) {
- var _this2 = this;
- var r, _ref, n, _ref$noReport, o, a, s, l, u, c;
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- r = e.traceId;
- this.emitTraceIdToDecoder(e);
- _ref = t || {}, n = _ref.sampleRate, _ref$noReport = _ref.noReport, o = _ref$noReport === void 0 ? !1 : _ref$noReport, a = _ref.special;
- if (!(n && Math.random() > n)) {
- _context.next = 5;
- break;
- }
- return _context.abrupt("return", Promise.resolve());
- case 5:
- s = Actions[e.event] + "Action", l = e.tag;
- this.events.set(r, !0), a && this.specialEvents.set(r, !0);
- u = Date.now();
- c = null;
- return _context.abrupt("return", new Promise(function (h, f) {
- if (o) return _this2.off(r), _this2.events.delete(r), h(void 0);
- _this2.on(r, function (_ref2) {
- var _ = _ref2.code,
- g = _ref2.data,
- m = _ref2.msg;
- if (_ === Codes$1.Success) h(g), _this2.off(r), logger$1.infoAndReportMeasurement({
- metric: s,
- tag: l,
- extra: e.extra,
- startTime: u,
- traceId: r
- });else {
- if (_ === Codes$1.ActionMaybeDelay) return;
- if (_ === Codes$1.DoActionBlocked && e.event === Actions.Rotation) {
- logger$1.debug(s + " response code: " + _);
- return;
- }
- var v = util.getErrorByCode(_),
- y = new v(m);
- _this2.off(r), f(y), _this2.emit("actionResponseError", {
- error: y,
- event: e,
- tag: l
- }), logger$1.infoAndReportMeasurement({
- metric: s,
- tag: l,
- extra: e.extra,
- error: y,
- startTime: u,
- traceId: r
- });
- }
- });
- var d = e.timeout || 2e3;
- c = window.setTimeout(function () {
- if (c && clearTimeout(c), !_this2.events.get(r)) return;
- var _ = new ActionResponseTimeoutError("".concat(s, " timeout in ").concat(d, "ms"));
- _this2.emit("actionResponseTimeout", {
- error: _,
- event: e,
- tag: l
- }), f(_), _this2.events.delete(r), _this2.off(r), logger$1.infoAndReportMeasurement({
- metric: s,
- tag: l,
- extra: e.extra,
- error: _,
- startTime: u,
- traceId: r
- });
- }, d);
- }));
- case 10:
- case "end":
- return _context.stop();
- }
- }
- }, _callee, this);
- }));
- function track(_x, _x2) {
- return _track.apply(this, arguments);
- }
- return track;
- }()
- }, {
- key: "emitTraceIdToDecoder",
- value: function emitTraceIdToDecoder(e) {
- if (e.event === Actions.Rotation || e.event === Actions.Clicking || e.event === Actions.GetOnVehicle || e.event === Actions.GetOffVehicle) {
- var t = {
- [Actions.Rotation]: "Rotation",
- [Actions.GetOnVehicle]: "GetOnVehicle",
- [Actions.GetOffVehicle]: "GetOffVehicle",
- [Actions.Clicking]: "MoveTo"
- };
- this.emit("traceId", {
- traceId: e.traceId,
- timestamp: Date.now(),
- event: t[e.event]
- });
- }
- }
- }]);
- return EventsManager;
- }(EventEmitter);
- var eventsManager = new EventsManager();
- var QueueActions = [Actions.Transfer, Actions.ChangeSkin, Actions.GetOnVehicle, Actions.GetOffVehicle];
- var ActionsHandler = /*#__PURE__*/function () {
- function ActionsHandler(e) {
- _classCallCheck(this, ActionsHandler);
- this.currentActiveAction = null;
- this.room = e;
- }
- _createClass(ActionsHandler, [{
- key: "avatarComponentsSync",
- value: function () {
- var _avatarComponentsSync = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
- var t;
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- t = {
- action_type: Actions.SetPlayerState,
- set_player_state_action: {
- player_state: {
- avatar_components: JSON.stringify(e)
- }
- }
- };
- this.sendData({
- data: t
- });
- case 2:
- case "end":
- return _context.stop();
- }
- }
- }, _callee, this);
- }));
- function avatarComponentsSync(_x) {
- return _avatarComponentsSync.apply(this, arguments);
- }
- return avatarComponentsSync;
- }()
- }, {
- key: "sendData",
- value: function () {
- var _sendData = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e) {
- var _this = this;
- var t, _e$sampleRate, r, _e$timeout, n, o, a, s;
- return regenerator.wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- _context2.next = 2;
- return this.beforeSend(e);
- case 2:
- t = util.uuid();
- if (!(this.room.networkController.sendRtcData(le(oe({}, e.data), {
- trace_id: t,
- user_id: this.room.options.userId
- })), e.track === !1)) {
- _context2.next = 5;
- break;
- }
- return _context2.abrupt("return", Promise.resolve(null));
- case 5:
- _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;
- return _context2.abrupt("return", eventsManager.track({
- timeout: n,
- traceId: t,
- event: a.action_type,
- tag: o,
- extra: a
- }, {
- special: s,
- sampleRate: r,
- noReport: this.room.viewMode === "serverless" || this.room.options.viewMode === "serverless"
- }).finally(function () {
- QueueActions.includes(e.data.action_type) && (_this.currentActiveAction = void 0);
- }));
- case 7:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2, this);
- }));
- function sendData(_x2) {
- return _sendData.apply(this, arguments);
- }
- return sendData;
- }()
- }, {
- key: "beforeSend",
- value: function () {
- var _beforeSend = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
- var o, t, r;
- return regenerator.wrap(function _callee3$(_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- t = (o = this.room._userAvatar) == null ? void 0 : o.isMoving, r = e.data.action_type;
- if (!QueueActions.includes(r)) {
- _context3.next = 5;
- break;
- }
- if (!this.currentActiveAction) {
- _context3.next = 4;
- break;
- }
- 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")))));
- case 4:
- this.currentActiveAction = r;
- case 5:
- if (!(t && QueueActions.includes(e.data.action_type))) {
- _context3.next = 14;
- break;
- }
- _context3.prev = 6;
- _context3.next = 9;
- return this.stopMoving();
- case 9:
- _context3.next = 14;
- break;
- case 11:
- _context3.prev = 11;
- _context3.t0 = _context3["catch"](6);
- this.currentActiveAction = void 0, logger$1.error("before action stopMoving failed", _context3.t0);
- case 14:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee3, this, [[6, 11]]);
- }));
- function beforeSend(_x3) {
- return _beforeSend.apply(this, arguments);
- }
- return beforeSend;
- }()
- }, {
- key: "moveTo",
- value: function () {
- var _moveTo = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
- var t, _e$extra, r, n, o;
- return regenerator.wrap(function _callee4$(_context4) {
- while (1) {
- switch (_context4.prev = _context4.next) {
- case 0:
- t = e.point, _e$extra = e.extra, r = _e$extra === void 0 ? "" : _e$extra, n = e.motionType, o = {
- action_type: Actions.Clicking,
- clicking_action: {
- clicking_point: t,
- clicking_type: ClickType.IgnoreView,
- extra: encodeURIComponent(r),
- attitude: n
- },
- clicking_state: this.room._currentClickingState
- };
- return _context4.abrupt("return", this.sendData({
- data: o
- }));
- case 2:
- case "end":
- return _context4.stop();
- }
- }
- }, _callee4, this);
- }));
- function moveTo(_x4) {
- return _moveTo.apply(this, arguments);
- }
- return moveTo;
- }()
- }, {
- key: "transfer",
- value: function transfer(e) {
- var _this2 = this;
- var t = e.renderType,
- r = e.player,
- n = e.camera,
- o = e.areaName,
- a = e.attitude,
- s = e.pathName,
- l = e.person,
- u = e.noMedia,
- c = e.timeout,
- h = e.tag,
- f = e.special,
- d = {
- data: {
- action_type: Actions.Transfer,
- transfer_action: {
- render_type: t,
- player: r,
- camera: n,
- areaName: o,
- attitude: a,
- pathName: s,
- person: {
- type: l
- },
- noMedia: u,
- tiles: [0, 1, 2, 4]
- }
- },
- special: f,
- timeout: c || 4e3,
- tag: h
- };
- return this.sendData(d).then(function (_) {
- return typeof l != "undefined" && _this2.room.updateCurrentNetworkOptions({
- person: l,
- rotationRenderType: t
- }), _;
- });
- }
- }, {
- key: "changeRotationRenderType",
- value: function changeRotationRenderType(e) {
- var t = e.renderType,
- r = e.player,
- n = e.camera,
- o = e.areaName,
- a = e.attitude,
- s = e.pathName;
- return this.transfer({
- renderType: t,
- player: r,
- camera: n,
- areaName: o,
- attitude: a,
- pathName: s,
- tag: "changeToRotationVideo"
- });
- }
- }, {
- key: "requestPanorama",
- value: function requestPanorama(e, t, r) {
- var n = e.camera,
- o = e.player,
- a = e.areaName,
- s = e.attitude,
- l = e.pathName,
- u = e.tag;
- return this.transfer({
- renderType: RenderType.ClientRotationPano,
- player: o,
- camera: n,
- person: Person.First,
- areaName: a,
- attitude: s,
- pathName: l,
- noMedia: t,
- timeout: r,
- tag: u || "requestPanorama",
- special: !t
- });
- }
- }, {
- key: "setMotionType",
- value: function setMotionType(e) {
- return this.transfer({
- attitude: e,
- tag: "setMotionType"
- });
- }
- }, {
- key: "setNickName",
- value: function setNickName(e) {
- var t = {
- action_type: Actions.ChangeNickname,
- change_nickname_action: {
- nickname: e
- }
- };
- return this.sendData({
- data: t
- });
- }
- }, {
- key: "getReserveSeat",
- value: function getReserveSeat(_ref) {
- var e = _ref.routeId,
- t = _ref.name;
- var r = {
- action_type: Actions.ReserveSeat,
- reserve_seat_action: {
- route_id: e,
- name: t
- }
- };
- return this.sendData({
- data: r
- });
- }
- }, {
- key: "getReserveStatus",
- value: function getReserveStatus(_ref2) {
- var e = _ref2.routeId,
- t = _ref2.name,
- r = _ref2.need_detail;
- var n = {
- action_type: Actions.GetReserveStatus,
- get_reserve_status_action: {
- route_id: e,
- name: t,
- need_detail: r
- }
- };
- return this.sendData({
- data: n,
- timeout: 2e3
- }).then(function (o) {
- return o.reserveDetail;
- });
- }
- }, {
- key: "stopMoving",
- value: function stopMoving() {
- var e = {
- action_type: Actions.StopMoving,
- stop_move_action: {}
- };
- return this.sendData({
- data: e
- });
- }
- }, {
- key: "getOnVehicle",
- value: function getOnVehicle(_ref3) {
- var e = _ref3.routeId,
- t = _ref3.name,
- r = _ref3.camera;
- var n = {
- action_type: Actions.GetOnVehicle,
- get_on_vehicle_action: {
- route_id: e,
- name: t,
- camera: r
- }
- };
- return this.sendData({
- data: n
- });
- }
- }, {
- key: "getOffVehicle",
- value: function getOffVehicle(_ref4) {
- var e = _ref4.renderType,
- t = _ref4.player,
- r = _ref4.camera;
- var n = {
- action_type: Actions.GetOffVehicle,
- get_off_vehicle_action: {
- render_type: e,
- player: t,
- camera: r
- }
- };
- return this.sendData({
- data: n
- });
- }
- }, {
- key: "confirmEvent",
- value: function confirmEvent(e) {
- var t = {
- action_type: Actions.ConfirmEvent,
- confirm_event_action: {
- id: e
- }
- };
- return this.sendData({
- data: t,
- track: !1
- });
- }
- }, {
- key: "echo",
- value: function echo(e) {
- var t = {
- action_type: Actions.Echo,
- echo_msg: {
- echoMsg: e
- }
- };
- return this.sendData({
- data: t,
- track: !1
- });
- }
- }, {
- key: "changeSkin",
- value: function () {
- var _changeSkin = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e) {
- var _this3 = this;
- var t, r, n, _e$landingType, o, a, s, l, u, c, h, f, d, _, _e$roomTypeId, g, m, y, v;
- return regenerator.wrap(function _callee6$(_context6) {
- while (1) {
- switch (_context6.prev = _context6.next) {
- case 0:
- 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) {
- return y.id === r;
- })[0];
- if (m) {
- _context6.next = 4;
- break;
- }
- y = "skin ".concat(r, " is invalid");
- return _context6.abrupt("return", (logger$1.error(y), Promise.reject(new ParamError(y))));
- case 4:
- v = {
- action_type: Actions.ChangeSkin,
- change_skin_action: {
- skinID: r,
- mode: n === ChangeMode.Preview ? ChangeMode.Preview : ChangeMode.Confirm,
- skin_data_version: r + m.versionId,
- landing_type: o,
- landing_point: a,
- landing_camera: s,
- render_wrapper: {
- render_type: l
- },
- areaName: u,
- attitude: c,
- noMedia: d,
- person: f,
- pathName: h,
- roomTypeId: g
- }
- };
- return _context6.abrupt("return", this.sendData({
- data: v,
- timeout: _ || 6e3,
- special: t
- }).then( /*#__PURE__*/function () {
- var _ref5 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(y) {
- var b, _ref6, T;
- return regenerator.wrap(function _callee5$(_context5) {
- while (1) {
- switch (_context5.prev = _context5.next) {
- case 0:
- if (!(l === RenderType.ClientRotationPano && y)) {
- _context5.next = 8;
- break;
- }
- _context5.next = 3;
- return _this3.room.modelManager.findRoute(r, h);
- case 3:
- b = _context5.sent;
- _ref6 = util.getRandomItem(b.birthPointList) || {};
- T = _ref6.camera;
- _context5.next = 8;
- return _this3.room.panorama.handleReceivePanorama(y, T);
- case 8:
- return _context5.abrupt("return", _this3.handleChangeSkin(e));
- case 9:
- case "end":
- return _context5.stop();
- }
- }
- }, _callee5);
- }));
- return function (_x6) {
- return _ref5.apply(this, arguments);
- };
- }()).catch(function (y) {
- return d ? _this3.handleChangeSkin(e) : Promise.reject(y);
- }));
- case 6:
- case "end":
- return _context6.stop();
- }
- }
- }, _callee6, this);
- }));
- function changeSkin(_x5) {
- return _changeSkin.apply(this, arguments);
- }
- return changeSkin;
- }()
- }, {
- key: "handleChangeSkin",
- value: function handleChangeSkin(e) {
- var _this4 = this;
- var t = e.skinId,
- r = e.mode,
- n = e.renderType,
- o = e.areaName,
- a = e.attitude,
- s = e.pathName;
- return this.room.sceneManager.staticmeshComponent.getCgMesh().show(), this.room.sceneManager.cameraComponent.switchToCgCamera(), this.room.engineProxy._updateSkinAssets(t).then(function () {
- _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({
- pathName: s,
- attitude: a,
- areaName: o
- }), _this4.room.skinChangedHook(), _this4.room.emit("skinChanged", {
- skin: {
- id: t
- },
- mode: r
- }), n === RenderType.ClientRotationPano && _this4.room.sceneManager.cameraComponent.allowMainCameraController();
- });
- }
- }, {
- key: "rotate",
- value: function rotate(_ref7) {
- var e = _ref7.pitch,
- t = _ref7.yaw;
- var n;
- if (this.room.disableRotate || this.room.isPano || ((n = this.room._userAvatar) == null ? void 0 : n._isChangingComponentsMode)) return;
- var r = {
- action_type: Actions.Rotation,
- rotation_action: {
- vertical_move: e,
- horizontal_move: -t
- }
- };
- this.sendData({
- data: r,
- sampleRate: .02
- });
- }
- }, {
- key: "turnTo",
- value: function turnTo(e) {
- var _ref8 = e || {},
- t = _ref8.point,
- _ref8$timeout = _ref8.timeout,
- r = _ref8$timeout === void 0 ? 2e3 : _ref8$timeout,
- _ref8$offset = _ref8.offset,
- n = _ref8$offset === void 0 ? 8 : _ref8$offset,
- o = {
- action_type: Actions.TurnTo,
- turn_to_action: {
- turn_to_point: t,
- offset: n
- }
- };
- return this.sendData({
- data: o,
- timeout: r
- });
- }
- }, {
- key: "rotateTo",
- value: function rotateTo(e) {
- var _ref9 = e || {},
- t = _ref9.point,
- _ref9$offset = _ref9.offset,
- r = _ref9$offset === void 0 ? 0 : _ref9$offset,
- _ref9$speed = _ref9.speed,
- n = _ref9$speed === void 0 ? 3 : _ref9$speed,
- o = {
- action_type: Actions.RotateTo,
- rotate_to_action: {
- rotate_to_point: t,
- offset: r,
- speed: n
- }
- };
- return this.sendData({
- data: o
- });
- }
- }, {
- key: "broadcast",
- value: function broadcast(e) {
- var t = e.data,
- _e$msgType = e.msgType,
- r = _e$msgType === void 0 ? MessageHandleType.MHT_FollowListMulticast : _e$msgType,
- n = e.targetUserIds;
- if (r === MessageHandleType.MHT_CustomTargetSync && !Array.isArray(n)) return Promise.reject(new ParamError("param targetUserIds is required when msgType is ".concat(MessageHandleType[r])));
- var o = {
- action_type: Actions.Broadcast,
- broadcast_action: {
- data: JSON.stringify(t),
- user_id: this.room.options.userId,
- msgType: r
- }
- };
- return Array.isArray(n) && r === MessageHandleType.MHT_CustomTargetSync && (o.broadcast_action.target_user_ids = n), this.room.actionsHandler.sendData({
- data: o,
- tag: t.broadcastType
- });
- }
- }, {
- key: "getNeighborPoints",
- value: function getNeighborPoints(e) {
- var t = e.point,
- _e$containSelf = e.containSelf,
- r = _e$containSelf === void 0 ? !1 : _e$containSelf,
- _e$searchRange = e.searchRange,
- n = _e$searchRange === void 0 ? 500 : _e$searchRange,
- o = {
- action_type: Actions.GetNeighborPoints,
- get_neighbor_points_action: {
- point: t,
- level: 1,
- containSelf: r,
- searchRange: n
- }
- };
- return this.sendData({
- data: o
- }).then(function (a) {
- return a.nps;
- });
- }
- }, {
- key: "playCG",
- value: function playCG(e) {
- var t = {
- action_type: Actions.PlayCG,
- play_cg_action: {
- cg_name: e
- }
- };
- return this.sendData({
- data: t
- });
- }
- }, {
- key: "audienceToVisitor",
- value: function audienceToVisitor(e) {
- var t = e.avatarId,
- r = e.avatarComponents,
- n = e.player,
- o = e.camera,
- a = {
- action_type: Actions.AudienceChangeToVisitor,
- audienceChangeToVisitorAction: {
- avatarID: t,
- avatarComponents: r,
- player: n,
- camera: o
- }
- };
- return logger$1.debug("send data: audience to visitor"), this.sendData({
- data: a
- });
- }
- }, {
- key: "visitorToAudience",
- value: function visitorToAudience(e) {
- var t = e.renderType,
- r = e.player,
- n = e.camera,
- o = e.areaName,
- a = e.attitude,
- s = e.pathName,
- l = e.person,
- u = e.noMedia,
- c = {
- action_type: Actions.VisitorChangeToAudience,
- visitorChangeToAudienceAction: {
- transferAction: {
- render_type: t,
- player: r,
- camera: n,
- areaName: o,
- attitude: a,
- pathName: s,
- person: {
- type: l
- },
- noMedia: u,
- tiles: [0, 1, 2, 4]
- }
- }
- };
- return logger$1.debug("send data: visitor to audience"), this.sendData({
- data: c
- });
- }
- }, {
- key: "removeVisitor",
- value: function removeVisitor(e) {
- var t = e.removeType,
- r = e.userIDList,
- _e$extraInfo = e.extraInfo,
- n = _e$extraInfo === void 0 ? "" : _e$extraInfo,
- o = {
- action_type: Actions.RemoveVisitor,
- removeVisitorAction: {
- removeVisitorEvent: t,
- userIDList: r,
- extraInfo: encodeURIComponent(n)
- }
- };
- return logger$1.debug("send data: remove visitor"), this.sendData({
- data: o
- });
- }
- }, {
- key: "getUserWithAvatar",
- value: function getUserWithAvatar(e, t) {
- var r = {
- action_type: Actions.GetUserWithAvatar,
- getUserWithAvatarAction: {
- userType: e,
- roomID: t
- }
- };
- return logger$1.debug("send data: get user with avatar"), this.sendData({
- data: r
- }).then(function (n) {
- return n.userWithAvatarList;
- });
- }
- }, {
- key: "joystick",
- value: function joystick(e) {
- var t = e.degree,
- _e$level = e.level,
- r = _e$level === void 0 ? 1 : _e$level,
- n = util.uuid();
- var o = -t + 90 + 360;
- o >= 360 && (o -= 360);
- var a = {
- action_type: Actions.Joystick,
- dir_action: {
- move_angle: o,
- speed_level: r
- },
- trace_id: n,
- user_id: this.room.options.userId,
- packet_id: n
- };
- return this.sendData({
- data: a,
- track: !1
- });
- }
- }]);
- return ActionsHandler;
- }();
- var ECurrentShaderMode = {
- default: 0,
- video: 1,
- pano: 2
- };
- var Signal = /*#__PURE__*/function () {
- function Signal(e) {
- _classCallCheck(this, Signal);
- this.signalHandleActived = !0;
- this.isUpdatedYUV = !0;
- this._room = e;
- }
- _createClass(Signal, [{
- key: "handleSignal",
- value: function handleSignal(e) {
- var _this = this;
- var a, s, l;
- if (!this.signalHandleActived) return;
- var t = e.signal,
- r = e.alreadyUpdateYUV;
- if (this.handleActionResponses(t), this._room.handleSignalHook(t), !r) {
- var u = (a = t.newUserStates) == null ? void 0 : a.find(function (c) {
- return c.userId === _this._room.userId;
- });
- if ((u == null ? void 0 : u.renderInfo) && ((s = this._room._userAvatar) == null ? void 0 : s.isMoving)) {
- logger$1.debug("stream stoped, make avatar to stop");
- var _u$renderInfo = u.renderInfo,
- c = _u$renderInfo.isMoving,
- h = _u$renderInfo.isRotating;
- this._room.avatarManager._updateAvatarMovingStatus({
- id: u.userId,
- isMoving: !!c,
- isRotating: !!h
- });
- }
- return;
- }
- this.isUpdatedYUV = r;
- var n = t;
- if (!t) {
- logger$1.warn("metadata signal is empty");
- return;
- }
- if (n.code === Codes.RepeatLogin) {
- this._room.handleRepetLogin();
- return;
- }
- 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));
- var o = (l = n.newUserStates) == null ? void 0 : l.find(function (u) {
- return u.userId === _this._room.userId;
- });
- if (n.broadcastAction) try {
- var _u = JSON.parse(n.broadcastAction.data);
- Broadcast.handlers.forEach(function (c) {
- return c(_u);
- });
- } catch (u) {
- logger$1.error(u);
- }
- if (n.newUserStates && n.newUserStates.length > 0 && this._room.avatarManager.handleAvatar(n), o != null && o.playerState) {
- this._room._currentClickingState = o.playerState;
- var _o$playerState = o.playerState,
- _u2 = _o$playerState.pathName,
- _c = _o$playerState.attitude,
- _h = _o$playerState.areaName,
- f = _o$playerState.skinId;
- if (_u2 && (this._room.pathManager.currentPathName = _u2, this._room.updateCurrentState({
- pathName: _u2
- })), f && this.udpateSkinInfo(f), _h && this._room.updateCurrentState({
- areaName: _h
- }), _c) {
- var d = this._room.skin.routeList.find(function (g) {
- return g.areaName === _this._room.currentState.areaName;
- }),
- _ = ((d == null ? void 0 : d.step) || 7.5) * 30;
- this._room.updateCurrentState({
- speed: _,
- attitude: _c
- }), this._room.pathManager.currentAttitude = _c, this._room._userAvatar && (this._room._userAvatar.motionType = _c);
- }
- this._room.sceneManager.getCurrentShaderMode() !== ECurrentShaderMode.pano && !this._room.isPano && o.playerState.camera && this._room.camera.setCameraPose(o.playerState.camera);
- }
- if (o != null && o.renderInfo && this._room.camera.handleRenderInfo(o), n.actionType !== void 0) {
- var _u3 = n.actionType,
- _c2 = n.code,
- _h2 = n.echoMsg,
- _f = n.traceId;
- _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);
- }
- }
- }, {
- key: "handleActionResponses",
- value: function handleActionResponses(e) {
- var _this2 = this;
- !(e != null && e.actionResponses) || e.actionResponses.length === 0 || e.actionResponses.forEach(function (t) {
- if (t.actionType == null) return;
- var r = t.pointType,
- n = t.extra,
- o = t.actionType,
- a = t.traceId,
- s = t.code,
- l = t.msg;
- 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));
- });
- }
- }, {
- key: "udpateSkinInfo",
- value: function () {
- var _udpateSkinInfo = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
- var t;
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- this._room.updateCurrentState({
- skinId: e
- });
- _context.next = 3;
- return this._room.skinList.find(function (r) {
- return r.id === e;
- });
- case 3:
- t = _context.sent;
- t && this._room.updateCurrentState({
- skin: t
- });
- case 5:
- case "end":
- return _context.stop();
- }
- }
- }, _callee, this);
- }));
- function udpateSkinInfo(_x) {
- return _udpateSkinInfo.apply(this, arguments);
- }
- return udpateSkinInfo;
- }()
- }]);
- return Signal;
- }();
- 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); }; }
- 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; } }
- var XverseEffectManager = /*#__PURE__*/function (_EventEmitter) {
- _inherits(XverseEffectManager, _EventEmitter);
- var _super = _createSuper$9(XverseEffectManager);
- function XverseEffectManager(e) {
- var _this;
- _classCallCheck(this, XverseEffectManager);
- _this = _super.call(this);
- E(_assertThisInitialized(_this), "effects", new Map());
- E(_assertThisInitialized(_this), "room");
- _this.room = e;
- return _this;
- }
- _createClass(XverseEffectManager, [{
- key: "addEffect",
- value: function () {
- var _addEffect = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
- var o, t, r, _e$type, n, a;
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- t = e.jsonPath, r = e.id, _e$type = e.type, n = _e$type === void 0 ? IEffectType.SubSequence : _e$type;
- _context.prev = 1;
- this.effects.get(r) && ((o = this.effects.get(r)) == null || o.dispose());
- a = new Ae.subEffect({
- id: r,
- jsonPath: t,
- type: n,
- room: this.room
- });
- this.effects.set(r, a);
- _context.next = 7;
- return a.init();
- case 7:
- return _context.abrupt("return", a);
- case 10:
- _context.prev = 10;
- _context.t0 = _context["catch"](1);
- return _context.abrupt("return", (this.effects.delete(r), logger$1.error(_context.t0), Promise.reject(_context.t0)));
- case 13:
- case "end":
- return _context.stop();
- }
- }
- }, _callee, this, [[1, 10]]);
- }));
- function addEffect(_x) {
- return _addEffect.apply(this, arguments);
- }
- return addEffect;
- }()
- }, {
- key: "clearEffects",
- value: function clearEffects() {
- var _this2 = this;
- this.effects.forEach(function (e) {
- e.dispose(), _this2.effects.delete(e.id);
- });
- }
- }, {
- key: "removeEffect",
- value: function removeEffect(e) {
- var t = this.effects.get(e);
- t == null || t.dispose(), t && this.effects.delete(t.id);
- }
- }]);
- return XverseEffectManager;
- }(EventEmitter);
- var MotionType$1 = {
- Walk: 'walk',
- Run: 'run',
- Fly: 'fly'
- };
- var Heartbeat = /*#__PURE__*/function () {
- function Heartbeat(e) {
- var _this = this;
- _classCallCheck(this, Heartbeat);
- E(this, "_interval", null);
- E(this, "ping", function () {
- var e = Date.now().toString();
- _this.handler.ping(e);
- });
- this.handler = e;
- }
- _createClass(Heartbeat, [{
- key: "ping",
- value: function ping() {
- var e = Date.now().toString();
- this.handler.ping(e);
- }
- }, {
- key: "start",
- value: function start() {
- this.stop(), logger$1.debug("Setting ping interval to ".concat(PING_INTERVAL_MS, "ms")), this._interval = window.setInterval(this.ping, PING_INTERVAL_MS);
- }
- }, {
- key: "stop",
- value: function stop() {
- logger$1.debug("stop heartbeat"), this._interval && window.clearInterval(this._interval);
- }
- }, {
- key: "pong",
- value: function pong(e, t) {
- !e || typeof e == "string" && this.handler.pong(Date.now() - Number(e), t);
- }
- }]);
- return Heartbeat;
- }();
- var Timeout$1 = /*#__PURE__*/function () {
- function Timeout(e, t) {
- var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !0;
- _classCallCheck(this, Timeout);
- this._timeout = null;
- this._fn = e, this._delay = t, r && this.start();
- }
- _createClass(Timeout, [{
- key: "delay",
- get: function get() {
- return this._delay;
- }
- }, {
- key: "isSet",
- get: function get() {
- return !!this._timeout;
- }
- }, {
- key: "setDelay",
- value: function setDelay(e) {
- this._delay = e;
- }
- }, {
- key: "start",
- value: function start() {
- var _this = this;
- this.isSet || (this._timeout = window.setTimeout(function () {
- var e = _this._fn;
- _this.clear(), e();
- }, this._delay));
- }
- }, {
- key: "clear",
- value: function clear() {
- window.clearTimeout(this._timeout), this._timeout = void 0;
- }
- }, {
- key: "reset",
- value: function reset() {
- this.clear(), this.start();
- }
- }]);
- return Timeout;
- }();
- 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); }; }
- 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; } }
- var Socket = /*#__PURE__*/function (_EventEmitter) {
- _inherits(Socket, _EventEmitter);
- var _super = _createSuper$8(Socket);
- function Socket(e) {
- var _this;
- _classCallCheck(this, Socket);
- _this = _super.call(this);
- E(_assertThisInitialized(_this), "_ws");
- E(_assertThisInitialized(_this), "_openTimer");
- E(_assertThisInitialized(_this), "connected", !1);
- E(_assertThisInitialized(_this), "_hasTimeout", !1);
- E(_assertThisInitialized(_this), "heartbeat");
- E(_assertThisInitialized(_this), "latency", function (e, t) {
- return _this.send({
- id: "checkLatency",
- data: JSON.stringify(e),
- packet_id: t
- });
- });
- E(_assertThisInitialized(_this), "send", function (e) {
- if (_this.wsNoReady()) return;
- var t = JSON.stringify(e);
- e.id !== "heartbeat" && logger$1.info("send ws frame", t), _this._ws.send(t);
- });
- E(_assertThisInitialized(_this), "startGame", function () {
- var _this$network$room$cu = _this.network.room.currentNetworkOptions,
- e = _this$network$room$cu.roomId,
- t = _this$network$room$cu.userId,
- r = _this$network$room$cu.avatarId,
- n = _this$network$room$cu.skinId,
- o = _this$network$room$cu.role,
- a = _this$network$room$cu.avatarComponents,
- s = _this$network$room$cu.versionId,
- l = _this$network$room$cu.rotationRenderType,
- u = _this$network$room$cu.isAllSync,
- c = _this$network$room$cu.nickname,
- h = _this$network$room$cu.avatarScale,
- f = _this$network$room$cu.appId,
- d = _this$network$room$cu.camera,
- _ = _this$network$room$cu.player,
- g = _this$network$room$cu.firends,
- m = _this$network$room$cu.syncByEvent,
- v = _this$network$room$cu.areaName,
- y = _this$network$room$cu.attitude,
- b = _this$network$room$cu.pathName,
- T = _this$network$room$cu.person,
- _this$network$room$cu2 = _this$network$room$cu.roomTypeId,
- C = _this$network$room$cu2 === void 0 ? "" : _this$network$room$cu2,
- A = _this$network$room$cu.syncToOthers,
- S = _this$network$room$cu.hasAvatar,
- P = _this$network$room$cu.prioritySync,
- _this$network$room$cu3 = _this$network$room$cu.extra,
- R = _this$network$room$cu3 === void 0 ? {} : _this$network$room$cu3,
- M = _this$network$room$cu.removeWhenDisconnected;
- R.removeWhenDisconnected = M;
- var x = {
- id: "start",
- room_id: e,
- user_id: t,
- trace_id: util.uuid(),
- data: JSON.stringify({
- avatar_components: JSON.stringify(a),
- avatar_id: r,
- skin_id: n,
- is_host: o ? o == "host" : !0,
- skin_data_version: n !== void 0 && s !== void 0 ? n + s : void 0,
- rotation_render_type: l,
- is_all_sync: u,
- nick_name: encodeURIComponent(c || ""),
- app_id: f,
- camera: d,
- player: _,
- person: T,
- firends: JSON.stringify(g),
- sync_by_event: m,
- area_name: v,
- path_name: b,
- attitude: y,
- room_type_id: C,
- syncToOthers: A,
- hasAvatar: S,
- avatarSize: h,
- prioritySync: P,
- extra: JSON.stringify(R)
- })
- };
- _this.send(x), logger$1.warn("startGame", le(oe({}, x), {
- data: JSON.parse(x.data)
- }));
- });
- _this.network = e, _this.heartbeat = new Heartbeat({
- ping: function ping(t) {
- var r;
- if (!_this.connected) {
- _this.heartbeat.stop(), (r = e.room.stats) == null || r.assign({
- rtt: 0
- });
- return;
- }
- _this.send({
- id: "heartbeat",
- data: t
- });
- },
- pong(t) {
- var r;
- (r = e.room.stats) == null || r.assign({
- rtt: t
- });
- }
- });
- return _this;
- }
- _createClass(Socket, [{
- key: "connection",
- get: function get() {
- return this._ws;
- }
- }, {
- key: "start",
- value: function start() {
- var _this2 = this;
- this._hasTimeout = !1;
- var e = this.getAddress();
- logger$1.info("connecting to ".concat(e));
- var t = Date.now();
- this._ws = new WebSocket(e), this._openTimer = new Timeout$1(function () {
- var r = "Failed to open websocket in ".concat(DEFAULT_OPEN_TIMEOUT_MS, " ms");
- _this2._hasTimeout = !0, _this2.emit("socketClosed", new InitNetworkTimeoutError(r));
- }, DEFAULT_OPEN_TIMEOUT_MS), this._ws.onopen = function () {
- var r;
- (r = _this2._openTimer) == null || r.clear(), _this2.connected = !0, _this2.heartbeat.start(), _this2.network.room.currentNetworkOptions.reconnect || (logger$1.infoAndReportMeasurement({
- metric: "wsOpenedAt",
- group: "joinRoom",
- startTime: _this2.network.room._startTime
- }), logger$1.infoAndReportMeasurement({
- metric: "wsOpenedCost",
- group: "joinRoom",
- startTime: t
- }));
- }, this.handleWSEvent();
- }
- }, {
- key: "getAddress",
- value: function getAddress() {
- var _this$network$room$cu4 = this.network.room.currentNetworkOptions,
- e = _this$network$room$cu4.wsServerUrl,
- t = _this$network$room$cu4.reconnect,
- r = _this$network$room$cu4.sessionId,
- n = _this$network$room$cu4.token,
- o = _this$network$room$cu4.roomId,
- a = _this$network$room$cu4.userId,
- s = _this$network$room$cu4.pageSession,
- l = this.network.room.skinId;
- var u = e;
- t && (u = u + "?reconnect=true&lastSessionID=".concat(r));
- var c = "userId=".concat(a, "&roomId=").concat(o, "&pageSession=").concat(s) + (this.network.room.isHost ? "&skinId=".concat(l) : "") + (n ? "&token=".concat(n) : "");
- return u = u.indexOf("?") > -1 ? u + "&" + c : u + "?" + c, u;
- }
- }, {
- key: "handleWSEvent",
- value: function handleWSEvent() {
- var _this3 = this;
- var e = this._ws;
- e.addEventListener("error", function (t) {
- _this3.connected = !1, logger$1.error("webscoket error", t), _this3.emit("socketClosed", new InternalError("connect to address error: " + _this3.network.room.currentNetworkOptions.wsServerUrl));
- }), e.addEventListener("close", function (t) {
- _this3.connected = !1, _this3._onClose(t);
- }), e.addEventListener("message", function (t) {
- if (!t || _this3._hasTimeout || !_this3.connected) return;
- var r = null;
- try {
- r = JSON.parse(t.data);
- } catch (o) {
- logger$1.error(o);
- return;
- }
- if (!r) return;
- var n = r.id;
- if (!!n) switch (n !== "heartbeat" && logger$1.info("receive ws frame: ".concat(t.data)), n) {
- case "fail":
- break;
- case "init":
- try {
- var o = r.data.slice(-37, -1);
- reporter$1.updateBody({
- serverSession: o
- });
- } catch (o) {
- console.error(o);
- }
- _this3.network.rtcp.start();
- break;
- case "heartbeat":
- _this3.heartbeat.pong(r.data);
- break;
- case "offer":
- _this3.network.rtcp.setRemoteDescription(r.data, _this3.network.stream.el);
- break;
- case "ice_candidate":
- _this3.network.rtcp.addCandidate(r.data);
- break;
- case "start":
- _this3.emit("gameRoomAvailable", r);
- break;
- case "error":
- try {
- var _JSON$parse = JSON.parse(r.data),
- _o = _JSON$parse.Code,
- a = _JSON$parse.Msg;
- if (_o) {
- if (_o == 3003) return _this3.emit("socketClosed", new TokenExpiredError());
- if (authenticationErrorCodes.indexOf(_o) > -1) return _this3.emit("socketClosed", new AuthenticationError("\u9274\u6743\u9519\u8BEF:" + a));
- {
- var s = util.getErrorByCode(_o);
- _this3.emit("socketClosed", new s(a));
- }
- }
- } catch (o) {
- logger$1.error(o), _this3.emit("socketClosed", new InternalError(r.data));
- }
- break;
- case "checkLatency":
- {
- var _o2 = r.packet_id,
- _a = r.data.split(",");
- _this3.onLatencyCheck({
- packetId: _o2,
- addresses: _a
- });
- break;
- }
- default:
- logger$1.warn("unkown ws message type", n, r);
- }
- });
- }
- }, {
- key: "onLatencyCheck",
- value: function onLatencyCheck(e) {
- var _this4 = this;
- var t = _toConsumableArray(new Set(e.addresses || []));
- Promise.all(t.map(function (r) {
- return {
- [r]: 9999
- };
- })).then(function (r) {
- var n = Object.assign.apply(Object, [{}].concat(_toConsumableArray(r)));
- _this4.latency(n, e.packetId);
- });
- }
- }, {
- key: "wsNoReady",
- value: function wsNoReady() {
- return this._ws.readyState == WebSocket.CLOSED || this._ws.readyState == WebSocket.CLOSING || this._ws.readyState == WebSocket.CONNECTING;
- }
- }, {
- key: "prepareReconnect",
- value: function prepareReconnect() {
- this._close({
- code: WS_CLOSE_RECONNECT,
- reason: "reconnect"
- });
- }
- }, {
- key: "_onClose",
- value: function _onClose(_ref) {
- var e = _ref.code,
- t = _ref.reason;
- 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"));
- }
- }, {
- key: "_close",
- value: function _close(_ref2) {
- var e = _ref2.code,
- t = _ref2.reason;
- var r;
- (r = this._ws) == null || r.close(e, t);
- }
- }, {
- key: "quit",
- value: function quit() {
- this._close({
- code: WS_CLOSE_NORMAL,
- reason: "quit"
- });
- }
- }]);
- return Socket;
- }(EventEmitter);
- function add(i, e) {
- return e == -1 && (e = 0), i + e;
- }
- function max(i, e) {
- return Math.max(i, e);
- }
- function count_sd(i, e) {
- function t(r, n) {
- var o = 0;
- return n == -1 ? o = 0 : o = (n - e) * (n - e), r + o;
- }
- return Math.sqrt(i.reduce(t, 0) / i.reduce(count_valid, 0)) || 0;
- }
- function count_valid(i, e) {
- var t = 0;
- return e != -1 && (t = 1), i + t;
- }
- function count_less(i, e) {
- function t(r, n) {
- var o = 0;
- return n != -1 && n < e && (o = 1), r + o;
- }
- return i.reduce(t, 0);
- }
- var CircularArray = /*#__PURE__*/function () {
- function CircularArray(e, t, r) {
- _classCallCheck(this, CircularArray);
- 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);
- }
- _createClass(CircularArray, [{
- key: "add",
- value: function add(e) {
- 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);
- }
- }, {
- key: "computeAvg",
- value: function computeAvg(e) {
- return e.reduce(add, 0) / e.reduce(count_valid, 0) || 0;
- }
- }, {
- key: "computeMax",
- value: function computeMax(e) {
- return e.reduce(max, 0) || 0;
- }
- }, {
- key: "computeThreshPercent",
- value: function computeThreshPercent(e) {
- if (this.countLess) {
- var t = count_less(e, this.lessThreshes[0]) || 0,
- r = count_less(e, this.lessThreshes[1]) || 0,
- n = count_less(e, this.lessThreshes[2]) || 0,
- o = count_less(e, this.lessThreshes[3]) || 0,
- a = e.reduce(count_valid, 0);
- return [t, r, n, o, a];
- } else return [0, 0, 0, 0, 0];
- }
- }, {
- key: "getAvg",
- value: function getAvg() {
- var e = this.sum / this.count || 0,
- t = this.computeAvg(this.circularData) || 0;
- return Math.abs(e - t) > .01 && console.error("avg value mismatch: ", e, t), this.computeAvg(this.circularData) || 0;
- }
- }, {
- key: "getMax",
- value: function getMax() {
- var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !0;
- var t = this.computeMax(this.circularData) || 0;
- return e && Math.abs(t - this.max) > .01 && console.error("max value mismatch: ", this.max, t), this.computeMax(this.circularData) || 0;
- }
- }, {
- key: "getStandardDeviation",
- value: function getStandardDeviation() {
- return count_sd(this.circularData, this.getAvg());
- }
- }, {
- key: "getThreshPercent",
- value: function getThreshPercent() {
- return this.computeThreshPercent(this.circularData);
- }
- }, {
- key: "getIncomingMax",
- value: function getIncomingMax() {
- return this.computeMax(this.incomingData) || 0;
- }
- }, {
- key: "getIncomingAvg",
- value: function getIncomingAvg() {
- return this.computeAvg(this.incomingData) || 0;
- }
- }, {
- key: "getIncomingStandardDeviation",
- value: function getIncomingStandardDeviation() {
- return count_sd(this.incomingData, this.getIncomingAvg());
- }
- }, {
- key: "getIncomingThreshPercent",
- value: function getIncomingThreshPercent() {
- return this.computeThreshPercent(this.incomingData);
- }
- }, {
- key: "clearFastComputeItem",
- value: function clearFastComputeItem() {
- 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;
- }
- }, {
- key: "clearIncoming",
- value: function clearIncoming() {
- for (; this.incomingData.length > 0;) {
- this.incomingData.pop();
- }
- }
- }, {
- key: "clear",
- value: function clear() {
- this.circularData.fill(-1), this.circularPtr = 0, this.clearFastComputeItem(), this.clearIncoming();
- }
- }]);
- return CircularArray;
- }();
- function _createForOfIteratorHelper$4(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$4(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
- 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); }
- 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; }
- var defaultLogger = {
- info: console.log,
- debug: console.log,
- error: console.error,
- infoAndReportMeasurement: function infoAndReportMeasurement() {}
- };
- var FRAME_COMPOSE_LENGTH = 5;
- var Workers = /*#__PURE__*/function () {
- function Workers(e, t) {
- var _this = this;
- _classCallCheck(this, Workers);
- 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 = {
- x: 0,
- y: 0,
- z: 0,
- tiles: []
- }, 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 () {
- return DECODER_VERSION;
- }, this.downloadBlob = function (r, n, o) {
- var a = new Blob([r], {
- type: o
- }),
- s = window.URL.createObjectURL(a);
- _this.downloadURL(s, n), setTimeout(function () {
- return window.URL.revokeObjectURL(s);
- }, 1e3);
- }, this.downloadURL = function (r, n) {
- var o = document.createElement("a");
- o.href = r, o.download = n, document.body.appendChild(o), o.style.display = "none", o.click(), o.remove();
- }, this.Stringify = function (r) {
- var n = "";
- for (var a = 0; a < r.length / 8192; a++) {
- n += String.fromCharCode.apply(null, r.slice(a * 8192, (a + 1) * 8192));
- }
- return n;
- }, this._rtcp = e;
- }
- _createClass(Workers, [{
- key: "registerLogger",
- value: function registerLogger(e) {//defaultLogger = e
- }
- }, {
- key: "registerFunction",
- value: function registerFunction(e, t) {
- this.functionMap.set(e, t);
- }
- }, {
- key: "hasFrmCntInCache",
- value: function hasFrmCntInCache(e) {
- var t = -1;
- for (var r = 0; r < this.cacheFrameComposes.length; r++) {
- this.cacheFrameComposes[r].frameCnt == e && (t = r);
- }
- return t;
- }
- }, {
- key: "requestPanoramaTest",
- value: function requestPanoramaTest(e, t, r, n, o) {
- var a = o,
- s = {
- action_type: 16,
- change_rotation_render_type_action: {
- render_type: 5,
- player: {
- position: {
- x: 0,
- y: 0,
- z: 0
- },
- angle: {
- yaw: 0,
- pitch: 0,
- roll: 0
- }
- },
- camera: {
- position: {
- x: e,
- y: t,
- z: r
- },
- angle: {
- yaw: 0,
- pitch: 0,
- roll: 0
- }
- },
- client_pano_titles_bitmap: n
- },
- trace_id: a,
- user_id: this.userId_test,
- packet_id: a
- };
- defaultLogger.debug("send data: ", s), this._rtcp.sendData(s);
- }
- }, {
- key: "onRotateInPanoMode",
- value: function onRotateInPanoMode(e) {
- var t = e.traceId,
- r = {};
- r.width = 1280, r.height = 720, r.horz_fov = 92, r.angle = {
- yaw: 100,
- pitch: 30
- };
- var n = new ArrayBuffer(8),
- o = new DataView(n);
- getTilesInView(r, n);
- var a = n.slice(0);
- this.PendingMasks.unshift({
- buffer: a,
- angle: r.angle
- }), MaskSetToOne(18, this.PanoView), operateForDataView(o, this.PanoView, o, function (s, l) {
- return s ^ s & l;
- }), 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);
- }
- }, {
- key: "processMetaWithTraceId",
- value: function processMetaWithTraceId(e) {
- var _iterator = _createForOfIteratorHelper$4(e.traceIds),
- _step;
- try {
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
- var t = _step.value;
- if (this.traceIdMap.has(t)) {
- var r = this.traceIdMap.get(t);
- r != null && (r.receiveTime = Date.now(), r.status = 1);
- }
- if (t == this.PendingMovingTraceId) {
- 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());
- var _r = Date.now();
- this.lastMoveResponseTime = _r, this.lastMoveProcessTime = _r, this.lastMoveDisplayTime = _r, this.frameServerCircular.clear(), this.frameClientCircular.clear();
- }
- }
- } catch (err) {
- _iterator.e(err);
- } finally {
- _iterator.f();
- }
- }
- }, {
- key: "onTraceId",
- value: function onTraceId(e) {
- var _this2 = this;
- var r = e.traceId,
- n = e.timestamp,
- o = e.event;
- if (o === "Rotation") {
- var a = {
- traceId: r,
- pts: 0,
- startTime: n,
- receiveTime: 0,
- readyTime: 0,
- displayTime: 0,
- status: 0
- };
- this.traceIdMap.set(r, a);
- var s = setTimeout(function () {
- if (s && clearTimeout(s), _this2.traceIdMap.has(r)) {
- var l = _this2.traceIdMap.get(r);
- switch (l == null ? void 0 : l.status) {
- case 0:
- {
- _this2.responseMiss += 1;
- break;
- }
- case 1:
- {
- _this2.processMiss += 1;
- var u = l.receiveTime - l.startTime;
- _this2.responseTimeArray.push(u);
- break;
- }
- case 2:
- {
- _this2.displayMiss += 1;
- var _u = l.receiveTime - l.startTime,
- c = l.readyTime - l.receiveTime;
- _this2.responseTimeArray.push(_u), _this2.processTimeArray.push(c);
- break;
- }
- case 3:
- defaultLogger.debug("status is 3");
- }
- }
- }, 1e3);
- } 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();
- }
- }, {
- key: "executeFunction",
- value: function executeFunction(e, t) {
- if (this.functionMap.has(e)) {
- var r = this.functionMap.get(e);
- r != null && r(t);
- }
- }
- }, {
- key: "UpdateStats",
- value: function UpdateStats(e) {
- var _this3 = this;
- var t;
- (t = this._rtcp.connection) == null || t.getStats(null).then(function (r) {
- r.forEach(function (n) {
- n.type == "data-channel" && (_this3.rtcMessageReceived = n.messagesReceived - n.messagesSent, _this3.rtcBytesReceived = n.bytesReceived);
- });
- }), 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;
- }
- }, {
- key: "ReceiveDecodeMessage",
- value: function ReceiveDecodeMessage(e) {
- var n;
- if (!this.firstYUVReceived) {
- this.firstYUVDecoded = e.data.yuv_ts;
- var o = this.firstYUVDecoded - this.rtcp.network.room._startTime;
- defaultLogger.infoAndReportMeasurement({
- metric: "firstYUVDecodedAt",
- value: o,
- group: "joinRoom"
- }), this.firstRender = Date.now();
- var a = this.firstYUVDecoded - this.rtcp.network.room._startTime;
- defaultLogger.infoAndReportMeasurement({
- metric: "firstRenderAt",
- value: a,
- group: "joinRoom"
- }), this.firstYUVReceived = !0, this.lastRenderTs = Date.now();
- }
- !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", {
- stream: this.cachedStreams[this.setPtr],
- width: this.cachedResolution[this.setPtr].width,
- height: this.cachedResolution[this.setPtr].height,
- pts: this.cachedPtss[this.setPtr]
- }), this.executeFunction("signal", {
- signal: this.cachedMetas[this.setPtr],
- pts: this.cachedPtss[this.setPtr],
- alreadyUpdateYUV: !0
- })) : this.updateDropFrame += 1, this.decoderWorker.postMessage({
- t: 2,
- frameCnt: this.cachedPtss[this.setPtr],
- buffer: this.cachedStreams[this.setPtr]
- }, [this.cachedStreams[this.setPtr].buffer])), this.getPtr = (this.getPtr + 1) % this.cachedLength);
- var t = e.data.metadata;
- if ((n = t == null ? void 0 : t.traceIds) != null && n.length) {
- var _iterator2 = _createForOfIteratorHelper$4(t.traceIds),
- _step2;
- try {
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
- var _o = _step2.value;
- if (this.traceIdMap.has(_o)) {
- var _a = this.traceIdMap.get(_o);
- _a != null && (_a.readyTime = Date.now(), _a.status = 2);
- }
- }
- } catch (err) {
- _iterator2.e(err);
- } finally {
- _iterator2.f();
- }
- }
- if (e.data.pts == this.moveStartPts && (this.MoveProcessDelay = Date.now() - this.StartMovingTs), this.userId_test = this.rtcp.network.room.userId, this.inMovingMode) {
- var _o2 = Date.now(),
- _a2 = _o2 - this.lastMoveProcessTime;
- this.moveProcessCircular.add(_a2), this.lastMoveProcessTime = _o2;
- }
- var r = this.setPtr;
- 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] = {
- width: e.data.width,
- height: e.data.height
- }, this.setPtr = (this.setPtr + 1) % this.cachedLength;
- }
- }, {
- key: "SendCacheFrameInfo",
- value: function SendCacheFrameInfo(e) {
- var _this4 = this;
- var h, f, d, _, g, m, v;
- var t = e.data.cachedKey,
- r = e.data.metadata,
- n = t,
- o = r,
- a = (d = (f = (h = o.newUserStates) == null ? void 0 : h.find(function (y) {
- return y.userId === _this4.rtcp.network.room.userId;
- })) == null ? void 0 : f.playerState) == null ? void 0 : d.roomTypeId,
- s = this.rtcp.network.room.skinId,
- l = (v = (m = (g = (_ = o.newUserStates) == null ? void 0 : _.find(function (y) {
- return y.userId === _this4._rtcp.network.room.userId;
- })) == null ? void 0 : g.playerState) == null ? void 0 : m.player) == null ? void 0 : v.position,
- u = {
- MsgType: 1,
- FrameCacheMsg: {
- FrameIndex: n,
- RoomTypeId: a,
- SkinID: s,
- Position: l
- }
- };
- var c = "";
- try {
- c = JSON.stringify(u);
- } catch (y) {
- defaultLogger.error(y);
- return;
- }
- }
- }, {
- key: "ReceivePanoramaDecodeMessage",
- value: function ReceivePanoramaDecodeMessage(e) {
- defaultLogger.info("Receive Panorama Image in Workers.ts"), MaskSetToOne(e.data.tileId, this.PanoView);
- var t = 0,
- r;
- var n = this.PendingMasks.length;
- for (t = 0; t < n; t++) {
- var o = this.PendingMasks[t].buffer,
- a = new DataView(o),
- s = new ArrayBuffer(8),
- l = new DataView(s);
- if (operateForDataView(this.PanoView, a, l, function (u, c) {
- return c ^ u & c;
- }), IsAll0(l)) {
- r = this.PendingMasks[t].angle;
- break;
- }
- }
- for (var _o3 = t; _o3 < n; _o3++) {
- this.PendingMasks.pop();
- }
- this.executeFunction("panorama", {
- data: e.data.data,
- tileId: e.data.tileId,
- pos: {
- x: e.data.x,
- y: e.data.y,
- z: e.data.z
- },
- uuid: e.data.uuid,
- finished: !0,
- matchAngle: r
- });
- }
- }, {
- key: "enable_decoder_queue_logging",
- value: function enable_decoder_queue_logging() {
- this.decoderWorker.postMessage({
- t: 100,
- status: !0
- });
- }
- }, {
- key: "disable_decoder_queue_logging",
- value: function disable_decoder_queue_logging() {
- this.decoderWorker.postMessage({
- t: 100,
- status: !1
- });
- }
- }, {
- key: "init",
- value: function () {
- var _init = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
- var r,
- n,
- t;
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- for (r = 0; r < FRAME_COMPOSE_LENGTH; r++) {
- n = {
- buffer: new Uint8Array(2621440),
- size: 0,
- startReceiveTime: 0,
- serverTime: 0,
- frameCnt: -1
- };
- this.cacheFrameComposes.push(n);
- }
- t = new Blob([decoder], {
- type: "application/javascript"
- });
- return _context.abrupt("return", (this.decoderWorker = new Worker(URL.createObjectURL(t)), this.decoderWorker.postMessage({
- t: 9,
- url: WASM_URLS[WASM_Version],
- jitterLength: DECODER_PASSIVE_JITTER
- })));
- case 5:
- case "end":
- return _context.stop();
- }
- }
- }, _callee, this);
- }));
- function init() {
- return _init.apply(this, arguments);
- }
- return init;
- }()
- }, {
- key: "UpdateYUV",
- value: function UpdateYUV() {
- var t, r;
- var e = this.getPtr;
- if (this.cachedMetas[e] != null && !this.cachedRender[e]) {
- var n = Date.now();
- if (this.firstUpdateYUV) {
- var h = ((t = this.cachedStreams[e]) == null ? void 0 : t.byteLength) || 0;
- defaultLogger.infoAndReportMeasurement({
- metric: "firstUpdateStreamLength",
- value: h,
- group: "joinRoom"
- }), this.firstUpdateYUV = !1;
- }
- this.cachedStreams[e] != null && this.executeFunction("stream", {
- stream: this.cachedStreams[e],
- width: this.cachedResolution[e].width,
- height: this.cachedResolution[e].height,
- pts: this.cachedPtss[e]
- });
- var o = Date.now();
- this.cachedStreams[e] != null && this.decoderWorker.postMessage({
- t: 2,
- frameCnt: this.cachedPtss[e],
- buffer: this.cachedStreams[e]
- }, [this.cachedStreams[e].buffer]);
- var a = Date.now(),
- s = o - n,
- l = a - o;
- (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;
- var u = o - n;
- this.updateYUVCircular.add(u);
- var c = this.cachedMetas[e];
- if ((r = c == null ? void 0 : c.traceIds) != null && r.length) {
- var _iterator3 = _createForOfIteratorHelper$4(c.traceIds),
- _step3;
- try {
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
- var _h = _step3.value;
- if (this.traceIdMap.has(_h)) {
- var f = this.traceIdMap.get(_h);
- if (f != null) {
- f.displayTime = Date.now(), f.status = 3;
- var d = f.receiveTime - f.startTime,
- _ = f.readyTime - f.receiveTime,
- g = f.displayTime - f.readyTime,
- m = f.displayTime - f.startTime;
- this.responseTimeArray.push(d), this.processTimeArray.push(_), this.displayTimeArray.push(g), this.overallTimeArray.push(m), this.traceIdMap.delete(_h);
- }
- }
- }
- } catch (err) {
- _iterator3.e(err);
- } finally {
- _iterator3.f();
- }
- }
- if (this.cachedPtss[e] == this.moveStartPts && (this.MoveDisplayDelay = Date.now() - this.StartMovingTs), this.inMovingMode) {
- var _h2 = Date.now(),
- _f = _h2 - this.lastMoveDisplayTime;
- this.moveDisplayCircular.add(_f), this.lastMoveDisplayTime = _h2;
- }
- this.executeFunction("signal", {
- signal: this.cachedMetas[e],
- pts: this.cachedPtss[e],
- alreadyUpdateYUV: !0
- }), this.cachedRender[e] = !0, this.getPtr = (this.getPtr + 1) % this.cachedLength;
- }
- }
- }, {
- key: "unmarshalPano",
- value: function unmarshalPano(e) {
- var t = new DataView(e);
- if (t.getUint32(0) != 1723558763) return !1;
- console.log("Receive Pano Message"), t.getUint16(4);
- var n = t.getUint16(6),
- o = t.getUint32(8),
- a = t.getUint32(12) - (1 << 30) * 2,
- s = t.getUint32(16) - (1 << 30) * 2,
- l = t.getUint32(20) - (1 << 30) * 2,
- u = t.getUint32(24),
- c = new Uint8Array(e).subarray(28, 64),
- h = String.fromCharCode.apply(null, c),
- f = t.getUint32(64),
- d = e.byteLength - n;
- if (d == u) {
- var g = {
- data: new Uint8Array(e).subarray(n),
- mediaLen: u,
- tileId: o,
- uuid: h,
- x: a,
- y: s,
- z: l
- };
- this.decoderWorker.postMessage({
- t: 8,
- data: g
- });
- } else {
- var _ = new Uint8Array(e, n, d);
- if (this.cachePanoTileID == o) {
- if (this.panoCacheBuffer.set(_, f), this.panoCacheSize += d, this.panoCacheSize === u) {
- var m = {
- data: new Uint8Array(this.panoCacheBuffer).slice(0, u),
- mediaLen: u,
- tileId: o,
- uuid: h,
- x: a,
- y: s,
- z: l
- };
- this.decoderWorker.postMessage({
- t: 8,
- data: m
- }), this.panoCacheSize = 0;
- }
- } else this.panoCacheBuffer.set(_, f), this.panoCacheSize = d, this.cachePanoTileID = o;
- }
- return !0;
- }
- }, {
- key: "clearMoveArray",
- value: function clearMoveArray() {
- 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 = "";
- }
- }, {
- key: "getIsMoving",
- value: function getIsMoving(e) {
- var t;
- if (typeof e.newUserStates != "undefined") for (var r = 0; r < e.newUserStates.length; r++) {
- var n = e.newUserStates[r];
- if (n.userId == this.rtcp.network.room.userId) {
- t = n.renderInfo.isMoving;
- break;
- }
- }
- return t;
- }
- }, {
- key: "isHeartBeatPacket",
- value: function isHeartBeatPacket(e, t) {
- return new DataView(e).getUint32(0) == 2009889916;
- }
- }, {
- key: "resetSendTimeDiff",
- value: function resetSendTimeDiff() {
- this.prevSenderTs = 0, this.serverSendTimeArray.clear();
- }
- }, {
- key: "calcSendTimeDiff",
- value: function calcSendTimeDiff(e) {
- if (this.prevSenderTs == -1) {
- this.prevSenderTs = e;
- return;
- }
- var t = e - this.prevSenderTs;
- this.serverSendTimeArray.add(t), this.prevSenderTs = e;
- }
- }, {
- key: "unmarshalStream",
- value: function unmarshalStream(e) {
- var _this6 = this;
- var T, C, A, S, P, R, M, x, I, w;
- var t = new DataView(e);
- if (t.getUint32(0) != 1437227610) return !1;
- t.getUint16(4);
- var n = t.getUint16(6),
- o = t.getUint16(8),
- a = o,
- s = t.getUint16(10);
- var l = !1;
- s == 1 && (l = !0);
- var u = t.getUint32(12),
- c = t.getUint32(16),
- h = t.getUint32(20),
- f = t.getUint16(24),
- d = t.getUint16(26),
- _ = t.getUint32(28),
- g = t.getUint32(n - 4),
- m = u + c,
- v = e.byteLength - n,
- y = new Uint8Array(e, n, v);
- this.calcSendTimeDiff(h);
- var b;
- if (this.inPanoMode && (c > 0 || f)) return defaultLogger.error("Stream Protocal Violation: receive illegal stream in Pano mode"), !0;
- if (v === m) {
- this.receivedMedia++;
- var O = new Uint8Array(e).subarray(n);
- h - this.lastServerTS > 60 ? this.serverFrameSlow++ : h - this.lastServerTS < 16 && this.serverFrameFast++;
- var D = Date.now();
- D - this.lastClientTS > 60 ? this.clientFrameSlow++ : D - this.lastClientTS < 16 && this.clientFrameFast++;
- var F = c === 0,
- V = h - this.lastServerTS;
- 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;
- var N = O.subarray(0, u),
- L = Date.now(),
- k = JSON.parse(this.Stringify(N)),
- U = Date.now();
- 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));
- var z = this.getIsMoving(k);
- if (this.inMovingMode && z == 0 && this.lastIsMoving == 1 && this.clearMoveArray(), typeof z != "undefined" && (this.lastIsMoving = z), this.inMovingMode) {
- var G = Date.now(),
- W = G - this.lastMoveResponseTime;
- this.moveResponseCircular.add(W), this.lastMoveResponseTime = G;
- }
- (f || d) && (b = (P = (S = (A = (C = k.newUserStates) == null ? void 0 : C.find(function (G) {
- return G.userId === _this6._rtcp.network.room.userId;
- })) == null ? void 0 : A.playerState) == null ? void 0 : S.player) == null ? void 0 : P.position);
- var H = {
- t: 0,
- data: O,
- mediaLen: c,
- metaLen: u,
- metadata: k,
- frameCnt: a,
- server_ts: h,
- isIDR: l,
- cacheRequest: d,
- cached: f,
- cachedKey: _,
- position: b
- };
- if (this.inPanoMode) return this.executeFunction("signal", {
- signal: k,
- pts: -1,
- alreadyUpdateYUV: !0
- }), !0;
- if (this.decoderWorker.postMessage(H, [O.buffer]), !this.firstMediaReceived) {
- this.firstMediaArraval = Date.now();
- var _G = this.firstMediaArraval - this.rtcp.network.room._startTime;
- defaultLogger.infoAndReportMeasurement({
- metric: "firstMediaArravalAt",
- value: _G,
- group: "joinRoom"
- }), this.firstMediaReceived = !0;
- }
- } else {
- var _O = this.hasFrmCntInCache(a);
- if (_O != -1) {
- if (this.cacheFrameComposes[_O].buffer.set(y, g), this.cacheFrameComposes[_O].size += v, this.cacheFrameComposes[_O].size === m) {
- var _D = new Uint8Array(this.cacheFrameComposes[_O].buffer).slice(0, m);
- 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++;
- var _F = Date.now();
- _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;
- var _V = _D.subarray(0, u),
- _N = Date.now(),
- _L = JSON.parse(this.Stringify(_V)),
- _k = Date.now();
- 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);
- var _U = this.getIsMoving(_L);
- if (this.inMovingMode && _U == 0 && this.lastIsMoving == 1 && this.clearMoveArray(), typeof _U != "undefined" && (this.lastIsMoving = _U), this.inMovingMode) {
- var _H = Date.now(),
- _G2 = _H - this.lastMoveResponseTime;
- this.moveResponseCircular.add(_G2), this.lastMoveResponseTime = _H;
- }
- (f || d) && (b = (w = (I = (x = (M = _L.newUserStates) == null ? void 0 : M.find(function (H) {
- return H.userId === _this6._rtcp.network.room.userId;
- })) == null ? void 0 : x.playerState) == null ? void 0 : I.player) == null ? void 0 : w.position);
- var _z = {
- t: 0,
- data: _D,
- mediaLen: c,
- metaLen: u,
- metadata: _L,
- frameCnt: a,
- server_ts: h,
- isIDR: l,
- cacheRequest: d,
- cached: f,
- cachedKey: _,
- position: b
- };
- if (this.inPanoMode) return this.executeFunction("signal", {
- signal: _L,
- pts: -1,
- alreadyUpdateYUV: !0
- }), !0;
- if (this.decoderWorker.postMessage(_z, [_D.buffer]), !this.firstMediaReceived) {
- this.firstMediaArraval = Date.now();
- var _H2 = this.firstMediaArraval - this.rtcp.network.room._startTime;
- defaultLogger.infoAndReportMeasurement({
- metric: "firstMediaArravalAt",
- value: _H2,
- group: "joinRoom"
- }), this.firstMediaReceived = !0;
- }
- } else this.cacheFrameComposes[_O].size > m && defaultLogger.debug("I frame exceed, cache size is ", this.cacheSize, ", total size is ", m);
- } else if (_O == -1) {
- var _D2 = this.hasFrmCntInCache(-1);
- if (_D2 == -1) {
- var _F2 = Date.now() + 1e18,
- _V2 = -1;
- for (var _N2 = 0; _N2 < this.cacheFrameComposes.length; _N2++) {
- this.cacheFrameComposes[_N2].serverTime < _F2 && (_F2 = this.cacheFrameComposes[_N2].serverTime, _V2 = _N2);
- }
- _D2 = _V2;
- }
- 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;
- }
- }
- return !0;
- }
- }, {
- key: "reset",
- value: function reset() {
- defaultLogger.debug("Worker reset is called"), this.cacheFrameCnt = 0, this.receivedMedia = 0, this.reconnectSignal = !0, this.decoderWorker.postMessage({
- t: 4
- });
- }
- }, {
- key: "dataHandleOff",
- value: function dataHandleOff(e) {
- defaultLogger.debug("hhh");
- }
- }, {
- key: "dataHandle",
- value: function dataHandle(e) {
- this.saveframe && (this.decoderWorker.postMessage({
- t: 6
- }), this.saveframe = !1), this.SaveMediaStream && (this.decoderWorker.postMessage({
- t: 7
- }), this.SaveMediaStream = !1);
- var t = new Uint8Array(e);
- if (t.length >= 4 && this.isHeartBeatPacket(t.buffer, t.length) == !0) return;
- if (t.length > 36 && this.unmarshalStream(t.buffer) == !0) {
- this.reconnectSignal && (this.executeFunction("reconnectedFrame", {}), this.reconnectSignal = !1);
- return;
- }
- if (t.length > 20 && this.unmarshalPano(t.buffer) == !0) return;
- this.noWasmBytesReceived += e.byteLength;
- var r = JSON.parse(this.Stringify(t));
- this.executeFunction("signal", {
- signal: r,
- pts: -1,
- alreadyUpdateYUV: !0
- });
- }
- }, {
- key: "changePanoMode",
- value: function changePanoMode(e) {
- this.inPanoMode = e;
- }
- }, {
- key: "uploadDataToServer",
- value: function uploadDataToServer() {
- this.DynamicPanoTest == !0 && (this.onRotateInPanoMode({
- traceId: "b2e1a296-6438-4371-8a31-687beb724ebe"
- }), this.DynamicPanoTest = !1);
- function e(ie, ee) {
- return ee == -1 && (ee = 0), ie + ee;
- }
- function t(ie, ee) {
- return Math.max(ie, ee);
- }
- var r = this.responseTimeArray.reduce(e, 0) / this.responseTimeArray.length || 0,
- n = this.processTimeArray.reduce(e, 0) / this.processTimeArray.length || 0,
- o = this.displayTimeArray.reduce(e, 0) / this.displayTimeArray.length || 0,
- a = this.overallTimeArray.reduce(e, 0) / this.overallTimeArray.length || 0,
- s = this.overallTimeArray.length;
- this.responseTimeArray = [], this.processTimeArray = [], this.displayTimeArray = [], this.overallTimeArray = [];
- var l = this.moveResponseCircular.getThreshPercent(),
- u = l[0],
- c = l[1],
- h = l[2],
- f = l[3],
- d = l[4],
- _ = d - f,
- g = 1 - c / d || 0,
- m = [u, c - u, h - c, f - h, _],
- v = this.moveProcessCircular.getThreshPercent(),
- y = v[0],
- b = v[1],
- T = v[2],
- C = v[3],
- A = v[4],
- S = A - C,
- P = 1 - b / A || 0,
- R = [y, b - y, T - b, C - T, S],
- M = this.moveDisplayCircular.getThreshPercent(),
- x = M[0],
- I = M[1],
- w = M[2],
- O = M[3],
- D = M[4],
- F = D - O,
- V = 1 - I / D || 0,
- N = [x, I - x, w - I, O - w, F],
- L = x,
- k = I - x,
- U = w - I,
- z = O - w,
- H = F,
- G = this.moveResponseCircular.getAvg(),
- W = this.moveProcessCircular.getAvg(),
- j = this.moveDisplayCircular.getAvg(),
- B = this.moveResponseCircular.getMax(),
- X = this.moveProcessCircular.getMax(),
- $ = this.moveDisplayCircular.getMax(),
- Y = this.moveResponseCircular.getStandardDeviation(),
- K = this.moveProcessCircular.getStandardDeviation(),
- Z = this.moveDisplayCircular.getStandardDeviation();
- 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();
- var q = this.frameServerCircular.getAvg(),
- J = this.frameServerCircular.getMax();
- this.frameClientCircular.getAvg(), this.frameClientCircular.getMax();
- var Q = this.metaParseAraay.reduce(e, 0) / this.metaParseAraay.length || 0,
- te = this.metaParseAraay.reduce(t, 0);
- this.metaParseAraay = [];
- var re = {
- mediaBytesReceived: this.mediaBytesReceived,
- metaBytesReceived: this.metaBytesReceived,
- packetsLost: this.packetsLost,
- timestamp: Date.now(),
- frameHeight: 1280,
- frameWidth: 720,
- framesReceived: this.receivedMedia,
- framesReceivedWorker: this.receivedMedia_worker,
- framesDecoded: this.receivedYUV,
- framesEmited: this.receivedEmit,
- decodeTimePerFrame: this.decodeTimePerFrame,
- decodeTimeMaxFrame: this.decodeTimeMaxFrame,
- packetsDrop: this.packetsDrop,
- framesAwait: this.framesAwait,
- firstMediaArraval: this.firstMediaArraval,
- firstYUVDecoded: this.firstYUVDecoded,
- firstRender: this.firstRender,
- returnFrames: this.returnFrames,
- sendOutBuffer: this.sendOutBuffer,
- maxGraphicTime: this.updateYUVCircular.getMax(),
- averageGraphicTime: this.updateYUVCircular.getAvg(),
- jankTimes: this.JankTimes,
- bigJankTimes: this.bigJankTimes,
- decodeJankTimes: this.DecodeJankTimes,
- bigDecodeJankTimes: this.bigDecodeJankTimes,
- serverFrameSlow: this.serverFrameSlow,
- serverFrameFast: this.serverFrameFast,
- clientFrameSlow: this.clientFrameSlow,
- clientFrameFast: this.clientFrameFast,
- rtcMessageReceived: this.rtcMessageReceived,
- rtcBytesReceived: this.rtcBytesReceived - this.noWasmBytesReceived,
- receiveIframes: this.receiveIframes,
- decodeIframes: this.decodeIframes,
- avgResponseTime: r,
- avgProcessTime: n,
- avgDisplayTime: o,
- avgOverallTime: a,
- overallTimeCount: s,
- responseMiss: this.responseMiss,
- processMiss: this.processMiss,
- displayMiss: this.displayMiss,
- updateDropFrame: this.updateDropFrame,
- moveEvent: this.moveEvent,
- avgResponseMoveDiff: this.moveEvent == "MoveTo" ? G : 0,
- avgProcessMoveDiff: this.moveEvent == "MoveTo" ? W : 0,
- avgDisplayMoveDiff: this.moveEvent == "MoveTo" ? j : 0,
- maxResponseMoveDiff: this.moveEvent == "MoveTo" ? B : 0,
- maxProcessMoveDiff: this.moveEvent == "MoveTo" ? X : 0,
- maxDisplayMoveDiff: this.moveEvent == "MoveTo" ? $ : 0,
- moveResponseJank: this.moveEvent == "MoveTo" ? g : 0,
- moveProcessJank: this.moveEvent == "MoveTo" ? P : 0,
- moveDisplayJank: this.moveEvent == "MoveTo" ? V : 0,
- moveResponseCounts: this.moveEvent == "MoveTo" ? m.toString() : "0,0,0,0,0",
- moveProcessCounts: this.moveEvent == "MoveTo" ? R.toString() : "0,0,0,0,0",
- moveDisplayCounts: this.moveEvent == "MoveTo" ? N.toString() : "0,0,0,0,0",
- MoveDisplayCountGood: this.moveEvent == "MoveTo" ? L.toString() : "0",
- MoveDisplayCountWell: this.moveEvent == "MoveTo" ? k.toString() : "0",
- MoveDisplayCountFair: this.moveEvent == "MoveTo" ? U.toString() : "0",
- MoveDisplayCountBad: this.moveEvent == "MoveTo" ? z.toString() : "0",
- MoveDisplayCountRest: this.moveEvent == "MoveTo" ? H.toString() : "0",
- moveResponseDelay: this.moveEvent == "MoveTo" ? this.MoveResponseDelay : 0,
- moveProcessDelay: this.moveEvent == "MoveTo" ? this.MoveProcessDelay : 0,
- moveDisplayDelay: this.moveEvent == "MoveTo" ? this.MoveDisplayDelay : 0,
- sdMoveResponseLongTime: Y,
- sdMoveProcessLongTime: K,
- sdMoveDisplayLongTime: Z,
- avgResponseFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? G : 0,
- avgProcessFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? W : 0,
- avgDisplayFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? j : 0,
- maxResponseFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? B : 0,
- maxProcessFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? X : 0,
- maxDisplayFlyDiff: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? $ : 0,
- flyResponseJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? g : 0,
- flyProcessJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? P : 0,
- flyDisplayJank: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? V : 0,
- flyResponseCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? m.toString() : "0,0,0,0,0",
- flyProcessCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? R.toString() : "0,0,0,0,0",
- flyDisplayCounts: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? N.toString() : "0,0,0,0,0",
- flyResponseDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveResponseDelay : 0,
- flyProcessDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveProcessDelay : 0,
- flyDisplayDelay: this.moveEvent == "GetOnVehicle" || this.moveEvent == "GetOnAirship" ? this.MoveDisplayDelay : 0,
- avgMetaParseTime: Q,
- maxMetaParseTime: te,
- avgServerDiff: q,
- maxServerDiff: J,
- streamType: WASM_Version
- };
- return this.lastReturnFrames = this.returnFrames, this.lastReceivedEmit = this.receivedEmit, re;
- }
- }]);
- return Workers;
- }();
- 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); }; }
- 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; } }
- var Rtcp = /*#__PURE__*/function (_EventEmitter) {
- _inherits(Rtcp, _EventEmitter);
- var _super = _createSuper$7(Rtcp);
- function Rtcp(e) {
- var _this;
- _classCallCheck(this, Rtcp);
- _this = _super.call(this);
- E(_assertThisInitialized(_this), "connection", null);
- E(_assertThisInitialized(_this), "inputChannel", null);
- E(_assertThisInitialized(_this), "mediaStream");
- E(_assertThisInitialized(_this), "socket");
- E(_assertThisInitialized(_this), "connected", !1);
- E(_assertThisInitialized(_this), "candidates", []);
- E(_assertThisInitialized(_this), "isAnswered", !1);
- E(_assertThisInitialized(_this), "isFlushing", !1);
- E(_assertThisInitialized(_this), "inputReady", !1);
- E(_assertThisInitialized(_this), "workers");
- E(_assertThisInitialized(_this), "actived", !0);
- E(_assertThisInitialized(_this), "heartbeat");
- E(_assertThisInitialized(_this), "onIcecandidate", function (e) {
- if (e.candidate != null) {
- var t = JSON.stringify(e.candidate);
- logger$1.debug("Got ice candidate: ".concat(t)), _this.network.socket.send({
- id: "ice_candidate",
- data: btoa(t)
- });
- }
- });
- E(_assertThisInitialized(_this), "onIcecandidateerror", function (e) {
- logger$1.error("onicecandidateerror", e.errorCode, e.errorText, e);
- });
- E(_assertThisInitialized(_this), "onIceStateChange", function (e) {
- switch (e.target.iceGatheringState) {
- case "gathering":
- logger$1.info("ice gathering");
- break;
- case "complete":
- logger$1.info("Ice gathering completed");
- }
- });
- E(_assertThisInitialized(_this), "onIceConnectionStateChange", function () {
- if (!!_this.connection) switch (logger$1.info("iceConnectionState: ".concat(_this.connection.iceConnectionState)), _this.connection.iceConnectionState) {
- case "connected":
- {
- _this.connected = !0;
- break;
- }
- case "disconnected":
- {
- _this.connected = !1, _this.emit("rtcDisconnected");
- break;
- }
- case "failed":
- {
- _this.emit("rtcDisconnected"), _this.connected = !1;
- break;
- }
- }
- });
- E(_assertThisInitialized(_this), "setRemoteDescription", /*#__PURE__*/function () {
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e, t) {
- var a, s, l, r, n, o, u;
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- if (_this.connection) {
- _context.next = 2;
- break;
- }
- return _context.abrupt("return");
- case 2:
- r = JSON.parse(atob(e)), n = new RTCSessionDescription(r);
- _context.next = 5;
- return _this.connection.setRemoteDescription(n);
- case 5:
- _context.next = 7;
- return _this.connection.createAnswer();
- case 7:
- o = _context.sent;
- 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) {
- u = o.sdp.lastIndexOf("a=mid:1");
- o.sdp = o.sdp.slice(0, u) + "a=mid:2" + o.sdp.slice(u + 7);
- }
- _context.prev = 9;
- _context.next = 12;
- return _this.connection.setLocalDescription(o);
- case 12:
- _context.next = 17;
- break;
- case 14:
- _context.prev = 14;
- _context.t0 = _context["catch"](9);
- logger$1.error("error", _context.t0);
- case 17:
- _this.isAnswered = !0, _this.network.rtcp.flushCandidate(), _this.network.socket.send({
- id: "answer",
- data: btoa(JSON.stringify(o))
- }), t.srcObject = _this.mediaStream;
- case 18:
- case "end":
- return _context.stop();
- }
- }
- }, _callee, null, [[9, 14]]);
- }));
- return function (_x, _x2) {
- return _ref.apply(this, arguments);
- };
- }());
- E(_assertThisInitialized(_this), "flushCandidate", function () {
- _this.isFlushing || !_this.isAnswered || (_this.isFlushing = !0, _this.candidates.forEach(function (e) {
- var t = atob(e),
- r = JSON.parse(t);
- if (/172\./.test(r.candidate)) return;
- var n = new RTCIceCandidate(r);
- _this.connection && _this.connection.addIceCandidate(n).then(function () {}, function (o) {
- logger$1.info("add candidate failed", o);
- });
- }), _this.isFlushing = !1);
- });
- E(_assertThisInitialized(_this), "input", function (e) {
- var t;
- !_this.actived || !_this.inputChannel || _this.inputChannel.readyState === "open" && ((t = _this.inputChannel) == null || t.send(e));
- });
- _this.network = e, _this.workers = new Workers(_assertThisInitialized(_this), logger$1), _this.workers.registerLogger(logger$1), _this.workers.registerFunction("data", function (t) {
- _this.emit("data", t);
- }), _this.heartbeat = new Heartbeat({
- ping: function ping(t) {
- e.room.actionsHandler.echo(t);
- },
- pong(t, r) {
- var n;
- r && t > 500 && logger$1.warn("high hb value ".concat(t, ", traceId:") + r), (n = e.room.stats) == null || n.assign({
- hb: t
- });
- }
- });
- return _this;
- }
- _createClass(Rtcp, [{
- key: "start",
- value: function start() {
- var _this2 = this;
- this.connection = new RTCPeerConnection();
- var e = Date.now();
- this.connection.ondatachannel = function (t) {
- logger$1.info("ondatachannel: ".concat(t.channel.label));
- _this2.inputChannel = t.channel;
- _this2.inputChannel.onopen = function () {
- var r;
- 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({
- metric: "datachannelOpenedAt",
- startTime: _this2.network.room._startTime,
- group: "joinRoom"
- }), logger$1.infoAndReportMeasurement({
- metric: "datachannelOpenedCost",
- startTime: e,
- group: "joinRoom"
- }));
- console.log('this.inputChannel', _this2.inputChannel);
- }, _this2.inputChannel.onclose = function () {
- var r;
- return logger$1.info("The input channel has closed, id:", (r = _this2.inputChannel) == null ? void 0 : r.id);
- }, _this2.inputChannel.onmessage = function (r) {
- // console.log('this.workers',this.workers)
- //console.log('inputChannel',r.data)
- _this2.workers.dataHandle(r.data);
- };
- }, this.connection.oniceconnectionstatechange = this.onIceConnectionStateChange, this.connection.onicegatheringstatechange = this.onIceStateChange, this.connection.onicecandidate = this.onIcecandidate, this.connection.onicecandidateerror = this.onIcecandidateerror, this.network.socket.send({
- id: "init_webrtc",
- data: JSON.stringify({
- is_mobile: !0
- })
- });
- }
- }, {
- key: "addCandidate",
- value: function addCandidate(e) {
- e === "" ? this.network.rtcp.flushCandidate() : this.candidates.push(e);
- }
- }, {
- key: "disconnect",
- value: function disconnect() {
- var e, t, r;
- 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;
- }
- }, {
- key: "sendStringData",
- value: function sendStringData(e) {
- console.log('e', e);
- this.input(e);
- }
- }, {
- key: "sendData",
- value: function sendData(e) {
- var t = "";
- try {
- t = JSON.stringify(e);
- } catch (r) {
- logger$1.error(r);
- return;
- }
- this.input(t);
- }
- }]);
- return Rtcp;
- }(EventEmitter);
- var NetworkMonitor = /*#__PURE__*/function () {
- function NetworkMonitor(e) {
- _classCallCheck(this, NetworkMonitor);
- this._listener = e;
- }
- _createClass(NetworkMonitor, [{
- key: "isOnline",
- get: function get() {
- var e = window.navigator;
- return typeof e.onLine == "boolean" ? e.onLine : !0;
- }
- }, {
- key: "start",
- value: function start() {
- window.addEventListener("online", this._listener), window.addEventListener("offline", this._listener);
- }
- }, {
- key: "stop",
- value: function stop() {
- window.removeEventListener("online", this._listener), window.removeEventListener("offline", this._listener);
- }
- }]);
- return NetworkMonitor;
- }();
- var Stream = /*#__PURE__*/function () {
- function Stream(e) {
- _classCallCheck(this, Stream);
- this.el = null;
- this._streamPlayTimer = null;
- if (!e) {
- this.el = this.createVideoElement();
- return;
- }
- this.el = e;
- }
- _createClass(Stream, [{
- key: "play",
- value: function play() {
- var _this = this;
- return new Promise(function (e, t) {
- _this._streamPlayTimer = new Timeout(function () {
- t(new InternalError("Stream play timeout"));
- }, 5e3), _this.el && _this.el.play().then(function () {
- var r;
- e(), logger$1.info("Media can autoplay"), (r = _this._streamPlayTimer) == null || r.clear();
- }).catch(function (r) {
- var n;
- logger$1.error("Media Failed to autoplay"), logger$1.error(r), t(new InternalError("Media Failed to autoplay")), (n = _this._streamPlayTimer) == null || n.clear();
- });
- });
- }
- }, {
- key: "createVideoElement",
- value: function createVideoElement() {
- var e = document.createElement("video");
- 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;
- }
- }]);
- return Stream;
- }();
- 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); }; }
- 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; } }
- 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 ";
- var NetworkController = /*#__PURE__*/function (_EventEmitter) {
- _inherits(NetworkController, _EventEmitter);
- var _super = _createSuper$6(NetworkController);
- function NetworkController(e) {
- var _this;
- _classCallCheck(this, NetworkController);
- _this = _super.call(this);
- _this.socket = null;
- _this.rtcp = null;
- _this.stream = null;
- _this._state = 'connecting';
- _this._networkMonitor = null;
- _this.blockedActions = [];
- _this.reconnectCount = 0;
- _this.room = e, _this.socket = new Socket(_assertThisInitialized(_this));
- _this.rtcp = new Rtcp(_assertThisInitialized(_this));
- _this.stream = new Stream();
- _this._networkMonitor = new NetworkMonitor(function () {
- 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());
- });
- _this.checkNetworkQuality(_this.room.currentNetworkOptions.wsServerUrl);
- _this._networkMonitor.start();
- new VisibilityChangeHandler().subscribe(function (r) {
- var n, o;
- r ? ((o = _this.room.stats) == null || o.disable(), logger$1.infoAndReportMeasurement({
- metric: "pageHide",
- startTime: Date.now()
- })) : ((n = _this.room.stats) == null || n.enable(), logger$1.infoAndReportMeasurement({
- metric: "pageShow",
- startTime: Date.now(),
- extra: {
- state: _this._state
- }
- }), _this._state === "disconnected" && _this.reconnect());
- });
- return _this;
- }
- _createClass(NetworkController, [{
- key: "startGame",
- value: function startGame() {
- var _this2 = this;
- return new Promise(function (e, t) {
- if (!_this2.rtcp.connected) return t(new InternalError("Game cannot load. Please refresh"));
- if (!_this2.rtcp.inputReady) return t(new InternalError("Game is not ready yet. Please wait"));
- _this2.socket.on("gameRoomAvailable", function (r) {
- _this2.setState("connected"), e(r), _this2.rtcp.heartbeat.start();
- }), _this2.socket.on("socketClosed", function (r) {
- t(r);
- }), _this2.socket.startGame();
- });
- }
- }, {
- key: "addBlockedActions",
- value: function addBlockedActions(e) {
- var _this$blockedActions;
- (_this$blockedActions = this.blockedActions).push.apply(_this$blockedActions, _toConsumableArray(e));
- }
- }, {
- key: "removeBlockedActions",
- value: function removeBlockedActions(e) {
- if (!e) {
- this.blockedActions = [];
- return;
- }
- var t = this.blockedActions.indexOf(e);
- this.blockedActions.splice(t, 1);
- }
- }, {
- key: "setState",
- value: function setState(e) {
- this._state !== e && (logger$1.info("Set network state to ", e), this._state = e);
- }
- }, {
- key: "connectAndStart",
- value: function () {
- var _connectAndStart = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- return _context.abrupt("return", this.connect(e).then(this.startGame));
- case 1:
- case "end":
- return _context.stop();
- }
- }
- }, _callee, this);
- }));
- function connectAndStart(_x) {
- return _connectAndStart.apply(this, arguments);
- }
- return connectAndStart;
- }()
- }, {
- key: "connect",
- value: function () {
- var _connect = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
- var _this3 = this;
- var e,
- _args2 = arguments;
- return regenerator.wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- e = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : !1;
- this.room.updateCurrentNetworkOptions({
- reconnect: e
- });
- return _context2.abrupt("return", new Promise(function (t, r) {
- _this3.rtcp.on("rtcConnected", function () {
- _this3.setState("connected"), t();
- }), _this3.rtcp.on("rtcDisconnected", function () {
- 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());
- }), _this3.socket.on("socketQuit", function () {
- logger$1.info("socket quit success"), _this3.setState("closed");
- }), _this3.socket.on("socketClosed", function (n) {
- _this3._state === "connecting" && (_this3.setState("disconnected"), r(n)), r(n);
- }), _this3.socket.start();
- }));
- case 3:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2, this);
- }));
- function connect() {
- return _connect.apply(this, arguments);
- }
- return connect;
- }()
- }, {
- key: "reconnect",
- value: function reconnect() {
- var _this4 = this;
- if (this.room.viewMode === "observer") return;
- var e = Date.now();
- if (this.reconnectCount++, this.reconnectCount > MAX_RECONNECT_COUNT) {
- logger$1.error("reconnect failed, reached max reconnect count", MAX_RECONNECT_COUNT), this.reconnectCount = 0, this.emit("stateChanged", {
- state: "disconnected"
- });
- return;
- }
- return logger$1.info("start reconnect, count:", this.reconnectCount), this._reconnect().then(function () {
- logger$1.infoAndReportMeasurement({
- startTime: e,
- metric: "reconnect"
- });
- }).catch(function (t) {
- if (logger$1.infoAndReportMeasurement({
- startTime: e,
- metric: "reconnect",
- error: t
- }), t.code === Codes.RepeatLogin) {
- _this4.room.handleRepetLogin();
- return;
- }
- var r = 1e3;
- logger$1.info("reconnect failed, wait " + r + " ms for next reconnect"), setTimeout(function () {
- _this4.reconnect();
- }, r);
- });
- }
- }, {
- key: "_reconnect",
- value: function _reconnect() {
- var _this5 = this;
- 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", {
- state: "reconnecting",
- count: this.reconnectCount
- }), this.socket.off("gameRoomAvailable"), this.socket.off("socketClosed"), this.rtcp.off("rtcDisconnected"), this.rtcp.off("rtcConnected"), this.connectAndStart(!0).then(function (_ref) {
- var e = _ref.session_id;
- _this5.room.updateCurrentNetworkOptions({
- sessionId: e
- }), reporter.updateBody({
- serverSession: e
- }), logger$1.info("reconnect success"), _this5.setState("connected"), _this5.reconnectCount = 0, _this5.emit("stateChanged", {
- state: "reconnected"
- });
- }));
- }
- }, {
- key: "prepareReconnect",
- value: function prepareReconnect() {
- this.rtcp.disconnect(), this.socket.prepareReconnect(), this.prepareReconnectOptions();
- }
- }, {
- key: "prepareReconnectOptions",
- value: function prepareReconnectOptions() {
- var _ref2 = this.room.currentClickingState || {},
- e = _ref2.camera,
- t = _ref2.player;
- e && t && this.room.updateCurrentNetworkOptions({
- camera: e,
- player: t
- });
- }
- }, {
- key: "sendRtcData",
- value: function sendRtcData(e) {
- if (this.blockedActions.includes(e.action_type)) {
- logger$1.info("action: ".concat(Actions[e.action_type], " was blocked"));
- return;
- }
- this.rtcp.sendData(e);
- }
- }, {
- key: "sendSocketData",
- value: function sendSocketData(e) {
- logger$1.debug("ws send ->", e), this.socket.send(e);
- }
- }, {
- key: "quit",
- value: function quit() {
- var e = util.uuid(),
- t = {
- action_type: Actions.Exit,
- trace_id: e,
- exit_action: {},
- user_id: this.room.options.userId,
- packet_id: e
- };
- this.setState("closed"), this.socket.quit(), this.sendRtcData(t);
- }
- }, {
- key: "checkNetworkQuality",
- value: function checkNetworkQuality(i) {
- var worker = null;
- if (!i) return;
- var e = Date.now();
- if (this.pingOthers("https://www.baidu.com", function (t, r) {
- logger$1.infoAndReportMeasurement({
- metric: "baiduRtt",
- group: "http",
- value: r,
- startTime: e
- });
- }), !worker) {
- var t = new Blob([workerSourceCode], {
- type: "application/javascript"
- });
- worker = new Worker(URL.createObjectURL(t)), worker.onmessage = function (r) {
- logger$1.infoAndReportMeasurement({
- metric: "workerRtt",
- group: "http",
- startTime: e,
- value: r.data
- });
- };
- }
- }
- }, {
- key: "pingOthers",
- value: function pingOthers(i, e) {
- var t = !1;
- var r = new Image();
- r.onload = o, r.onerror = a;
- var n = Date.now();
- function o(l) {
- t = !0, s();
- }
- function a(l) {}
- function s() {
- var l = Date.now() - n;
- if (typeof e == "function") return t ? e(null, l) : (console.error("error loading resource"), e("error", l));
- }
- r.src = i + "/favicon.ico?" + +new Date();
- }
- }]);
- return NetworkController;
- }(EventEmitter);
- var AssetTypeName = {
- Config: 'CONFIG',
- Model: 'MODEL',
- Vedio: 'VEDIO',
- Media: 'MEDIA',
- Effects: 'EFFECTS',
- Gift: 'GIFT',
- Textures: 'TEXTURES'
- };
- var AssetClassName = {
- Effects: '\u7279\u6548',
- Tv: 'TV',
- Lpm: '\u7C97\u6A21',
- Reward: '\u571F\u8C6A\u699C',
- Env: '\u73AF\u5883\u5149',
- Gbq: '\u544A\u767D\u5899',
- BreathPoint: '\u547C\u5438\u70B9',
- Gifts: '\u9001\u793C',
- Panorama: '\u5168\u666F\u56FE',
- GiftBubble: '\u9001\u793C\u6C14\u6CE1',
- SayBubble: '\u804A\u5929\u6C14\u6CE1'
- };
- var LoggerLevels$1 = {
- Debug: 1,
- Info: 2,
- Warn: 3,
- Error: 4,
- Off: 5
- };
- var EShaderMode = {
- default: 0,
- video: 1,
- videoAndPano: 2
- };
- var EFitMode = {
- fill: 'fill',
- contain: 'contain',
- cover: 'cover'
- };
- var BaseTable = /*#__PURE__*/function () {
- function BaseTable(e, t) {
- _classCallCheck(this, BaseTable);
- this.db = null;
- this.isCreatingTable = !1;
- this.hasCleared = !1;
- this.dbName = e, this.dbVersion = t;
- }
- _createClass(BaseTable, [{
- key: "clearDataBase",
- value: function () {
- var _clearDataBase = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
- var _this = this;
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- return _context.abrupt("return", this.hasCleared || (e && (this.hasCleared = !0), !window.indexedDB.databases) ? Promise.resolve() : new Promise(function (t, r) {
- var n = window.indexedDB.deleteDatabase(_this.dbName);
- n.onsuccess = function () {
- t();
- }, n.onerror = r;
- }));
- case 1:
- case "end":
- return _context.stop();
- }
- }
- }, _callee, this);
- }));
- function clearDataBase(_x) {
- return _clearDataBase.apply(this, arguments);
- }
- return clearDataBase;
- }()
- }, {
- key: "tableName",
- value: function tableName() {
- throw new Error("Derived class have to override 'tableName', and set a proper table name!");
- }
- }, {
- key: "keyPath",
- value: function keyPath() {
- throw new Error("Derived class have to override 'keyPath', and set a proper index name!");
- }
- }, {
- key: "index",
- value: function index() {
- throw new Error("Derived class have to override 'index', and set a proper index name!");
- }
- }, {
- key: "checkAndOpenDatabase",
- value: function () {
- var _checkAndOpenDatabase = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
- var _this2 = this;
- return regenerator.wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- return _context2.abrupt("return", this.db ? Promise.resolve(this.db) : new Promise(function (e, t) {
- var n = setTimeout(function () {
- logger$1.info("wait db to open for", 200), _this2.db ? e(_this2.db) : e(_this2.checkAndOpenDatabase()), clearTimeout(n);
- }, 200);
- _this2.openDatabase(_this2.dbName, _this2.dbVersion || 1, function () {
- _this2.db && !_this2.isCreatingTable && e(_this2.db), logger$1.info("successCallback called, this.db: ".concat(!!_this2.db, ", this.isCreatingStore: ").concat(_this2.isCreatingTable)), clearTimeout(n);
- }, function () {
- t(new Error("Failed to open database!")), clearTimeout(n);
- }, function () {
- _this2.db && e(_this2.db), clearTimeout(n), logger$1.info("successCallback called, this.db: ".concat(!!_this2.db, ", this.isCreatingStore: ").concat(_this2.isCreatingTable));
- });
- }));
- case 1:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2, this);
- }));
- function checkAndOpenDatabase() {
- return _checkAndOpenDatabase.apply(this, arguments);
- }
- return checkAndOpenDatabase;
- }()
- }, {
- key: "openDatabase",
- value: function openDatabase(e, t, r, n, o) {
- var _this3 = this;
- if (this.isCreatingTable) return;
- this.isCreatingTable = !0, logger$1.info(e, t);
- var a = window.indexedDB.open(e, t),
- s = this.tableName();
- a.onsuccess = function (l) {
- _this3.db = a.result, logger$1.info("IndexedDb ".concat(e, " is opened.")), _this3.db.objectStoreNames.contains(s) && (_this3.isCreatingTable = !1), r && r(l);
- }, a.onerror = function (l) {
- var u;
- 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);
- }, a.onupgradeneeded = function (l) {
- var u = l.target.result,
- c = _this3.index();
- logger$1.info("Creating table ".concat(s, "."));
- var h = u.objectStoreNames.contains(s);
- if (h) h = u.transaction([s], "readwrite").objectStore(s);else {
- var f = _this3.keyPath();
- h = u.createObjectStore(s, {
- keyPath: f
- });
- }
- c.map(function (f) {
- h.createIndex(f, f, {
- unique: !1
- });
- }), _this3.isCreatingTable = !1, logger$1.info("Table ".concat(s, " opened")), o && o(l);
- };
- }
- }, {
- key: "add",
- value: function () {
- var _add = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
- var t, o;
- return regenerator.wrap(function _callee3$(_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- t = this.tableName();
- _context3.next = 3;
- return this.checkAndOpenDatabase();
- case 3:
- o = _context3.sent.transaction([t], "readwrite").objectStore(t).add(e);
- return _context3.abrupt("return", new Promise(function (a, s) {
- o.onsuccess = function (l) {
- a(l);
- }, o.onerror = function (l) {
- var u;
- logger$1.error((u = l.srcElement) == null ? void 0 : u.error), s(l);
- };
- }));
- case 5:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee3, this);
- }));
- function add(_x2) {
- return _add.apply(this, arguments);
- }
- return add;
- }()
- }, {
- key: "put",
- value: function () {
- var _put = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
- var t, o;
- return regenerator.wrap(function _callee4$(_context4) {
- while (1) {
- switch (_context4.prev = _context4.next) {
- case 0:
- t = this.tableName();
- _context4.next = 3;
- return this.checkAndOpenDatabase();
- case 3:
- o = _context4.sent.transaction([t], "readwrite").objectStore(t).put(e);
- return _context4.abrupt("return", new Promise(function (a, s) {
- o.onsuccess = function (l) {
- a(l);
- }, o.onerror = function (l) {
- var u;
- logger$1.error("db put error", (u = l.srcElement) == null ? void 0 : u.error), s(l);
- };
- }));
- case 5:
- case "end":
- return _context4.stop();
- }
- }
- }, _callee4, this);
- }));
- function put(_x3) {
- return _put.apply(this, arguments);
- }
- return put;
- }()
- }, {
- key: "delete",
- value: function _delete(e, t, r) {
- var n = this.tableName();
- this.checkAndOpenDatabase().then(function (o) {
- var s = o.transaction([n], "readwrite").objectStore(n).delete(e);
- s.onsuccess = t, s.onerror = r;
- });
- }
- }, {
- key: "update",
- value: function update() {
- this.checkAndOpenDatabase().then(function (e) {});
- }
- }, {
- key: "getAllKeys",
- value: function () {
- var _getAllKeys = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5() {
- var e, t;
- return regenerator.wrap(function _callee5$(_context5) {
- while (1) {
- switch (_context5.prev = _context5.next) {
- case 0:
- e = this.tableName();
- _context5.next = 3;
- return this.checkAndOpenDatabase();
- case 3:
- t = _context5.sent;
- return _context5.abrupt("return", new Promise(function (r, n) {
- var a = t.transaction([e], "readonly").objectStore(e).getAllKeys();
- a.onsuccess = function (s) {
- r(s.target.result);
- }, a.onerror = function (s) {
- logger$1.error("db getAllKeys error", s), n(s);
- };
- }));
- case 5:
- case "end":
- return _context5.stop();
- }
- }
- }, _callee5, this);
- }));
- function getAllKeys() {
- return _getAllKeys.apply(this, arguments);
- }
- return getAllKeys;
- }()
- }, {
- key: "query",
- value: function () {
- var _query = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e, t) {
- var r, n;
- return regenerator.wrap(function _callee6$(_context6) {
- while (1) {
- switch (_context6.prev = _context6.next) {
- case 0:
- r = this.tableName();
- _context6.next = 3;
- return this.checkAndOpenDatabase();
- case 3:
- n = _context6.sent;
- return _context6.abrupt("return", new Promise(function (o, a) {
- var u = n.transaction([r], "readonly").objectStore(r).index(e).get(t);
- u.onsuccess = function (c) {
- var f;
- var h = (f = c == null ? void 0 : c.target) == null ? void 0 : f.result;
- o && o(h);
- }, u.onerror = function (c) {
- logger$1.error("db query error", c), a(c);
- };
- }));
- case 5:
- case "end":
- return _context6.stop();
- }
- }
- }, _callee6, this);
- }));
- function query(_x4, _x5) {
- return _query.apply(this, arguments);
- }
- return query;
- }()
- }, {
- key: "sleep",
- value: function () {
- var _sleep = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7(e) {
- return regenerator.wrap(function _callee7$(_context7) {
- while (1) {
- switch (_context7.prev = _context7.next) {
- case 0:
- return _context7.abrupt("return", new Promise(function (t) {
- setTimeout(function () {
- t("");
- }, e);
- }));
- case 1:
- case "end":
- return _context7.stop();
- }
- }
- }, _callee7);
- }));
- function sleep(_x6) {
- return _sleep.apply(this, arguments);
- }
- return sleep;
- }()
- }]);
- return BaseTable;
- }();
- 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); }; }
- 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; } }
- var ModelTable = /*#__PURE__*/function (_BaseTable) {
- _inherits(ModelTable, _BaseTable);
- var _super = _createSuper$5(ModelTable);
- function ModelTable() {
- _classCallCheck(this, ModelTable);
- return _super.call(this, "XverseDatabase", 1);
- }
- _createClass(ModelTable, [{
- key: "tableName",
- value: function tableName() {
- return "models";
- }
- }, {
- key: "index",
- value: function index() {
- return ["url"];
- }
- }, {
- key: "keyPath",
- value: function keyPath() {
- return "url";
- }
- }]);
- return ModelTable;
- }(BaseTable);
- var modelTable = new ModelTable();
- 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); }; }
- 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; } }
- var isIndexedDbSupported = function isIndexedDbSupported() {
- return (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB) !== void 0;
- };
- var dataURItoBlob = function dataURItoBlob(i) {
- var e;
- i.split(",")[0].indexOf("base64") >= 0 ? e = atob(i.split(",")[1]) : e = unescape(i.split(",")[1]);
- var t = i.split(",")[0].split(":")[1].split(";")[0],
- r = new Uint8Array(e.length);
- for (var o = 0; o < e.length; o++) {
- r[o] = e.charCodeAt(o);
- }
- return new Blob([r], {
- type: t
- });
- };
- var Http = /*#__PURE__*/function (_EventEmitter) {
- _inherits(Http, _EventEmitter);
- var _super = _createSuper$4(Http);
- function Http() {
- _classCallCheck(this, Http);
- return _super.apply(this, arguments);
- }
- _createClass(Http, [{
- key: "get",
- value: function () {
- var _get = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(_ref) {
- var e, _ref$useIndexedDb, t, _ref$timeout, r, n, _ref$isOutPutObjectUR, o, a, s, l;
- return regenerator.wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- 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;
- if (!(Xverse.NO_CACHE !== void 0 && (t = !Xverse.NO_CACHE), t)) {
- _context2.next = 25;
- break;
- }
- if (!isIndexedDbSupported()) {
- _context2.next = 22;
- break;
- }
- window.performance.now();
- a = null;
- _context2.prev = 5;
- _context2.next = 8;
- return modelTable.query("url", e);
- case 8:
- a = _context2.sent;
- _context2.next = 14;
- break;
- case 11:
- _context2.prev = 11;
- _context2.t0 = _context2["catch"](5);
- return _context2.abrupt("return", (logger$1.debug(_context2.t0), logger$1.warn("cache query error", e), Promise.resolve(e)));
- case 14:
- if (!(a && a.model)) {
- _context2.next = 19;
- break;
- }
- s = dataURItoBlob(a.model), l = Promise.resolve(o ? URL.createObjectURL(s) : s);
- return _context2.abrupt("return", (window.performance.now(), l));
- case 19:
- return _context2.abrupt("return", this.request({
- url: e,
- timeout: r,
- contentType: "blob",
- key: n
- }).then( /*#__PURE__*/function () {
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(s) {
- var l;
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- _context.next = 2;
- return blobToDataURI(s.response);
- case 2:
- l = _context.sent;
- _context.prev = 3;
- _context.next = 6;
- return modelTable.put({
- url: e,
- model: l
- });
- case 6:
- _context.next = 11;
- break;
- case 8:
- _context.prev = 8;
- _context.t0 = _context["catch"](3);
- logger$1.warn("unable to add data to indexedDB", _context.t0);
- case 11:
- return _context.abrupt("return", Promise.resolve(o ? URL.createObjectURL(s.response) : s.response));
- case 12:
- case "end":
- return _context.stop();
- }
- }
- }, _callee, null, [[3, 8]]);
- }));
- return function (_x2) {
- return _ref2.apply(this, arguments);
- };
- }()));
- case 20:
- _context2.next = 23;
- break;
- case 22:
- return _context2.abrupt("return", this.request({
- url: e,
- timeout: r,
- contentType: "blob",
- key: n
- }).then(function (a) {
- var s = a.response;
- return Promise.resolve(o ? URL.createObjectURL(s) : s);
- }).catch(function (a) {
- return Promise.reject(a);
- }));
- case 23:
- _context2.next = 26;
- break;
- case 25:
- return _context2.abrupt("return", this.request({
- url: e,
- timeout: r,
- key: n
- }).then(function (a) {
- return a.getResponseHeader("content-type") === "application/json" ? Promise.resolve(JSON.parse(a.responseText)) : Promise.resolve(a.responseText);
- }));
- case 26:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2, this, [[5, 11]]);
- }));
- function get(_x) {
- return _get.apply(this, arguments);
- }
- return get;
- }()
- }, {
- key: "request",
- value: function request(e) {
- var _this = this;
- var _e$timeout = e.timeout,
- t = _e$timeout === void 0 ? 3e4 : _e$timeout,
- r = e.contentType;
- e.key;
- var o = e.onRequestStart,
- a = e.url;
- return new Promise(function (s, l) {
- window.performance.now();
- var u = new XMLHttpRequest();
- r && (u.responseType = r), u.timeout = t, u.addEventListener("readystatechange", function () {
- if (u.readyState == 4) {
- if (u.status == 200) return window.performance.now(), _this.emit("loadend", {
- message: "request ".concat(a, " load success")
- }), s(u);
- {
- var c = "Unable to load the request ".concat(a);
- return _this.emit("error", {
- message: c
- }), logger$1.error(c), l(c);
- }
- }
- }), o && o(u), u.open("GET", a), u.send();
- });
- }
- }]);
- return Http;
- }(EventEmitter); // const http = new Http();
- var Logger1 = /*#__PURE__*/function () {
- function Logger1(e) {
- _classCallCheck(this, Logger1);
- E(this, "module");
- this.module = e;
- }
- _createClass(Logger1, [{
- key: "debug",
- value: function debug() {
- var _Logger1$instance;
- return (_Logger1$instance = Logger1.instance).debug.apply(_Logger1$instance, arguments);
- }
- }, {
- key: "info",
- value: function info() {
- var _Logger1$instance2;
- return (_Logger1$instance2 = Logger1.instance).info.apply(_Logger1$instance2, arguments);
- }
- }, {
- key: "warn",
- value: function warn() {
- var _Logger1$instance3;
- return (_Logger1$instance3 = Logger1.instance).warn.apply(_Logger1$instance3, arguments);
- }
- }, {
- key: "error",
- value: function error() {
- var _Logger1$instance4;
- return (_Logger1$instance4 = Logger1.instance).error.apply(_Logger1$instance4, arguments);
- }
- }], [{
- key: "setLogger",
- value: function setLogger(e) {
- Logger1.instance = e;
- }
- }]);
- return Logger1;
- }();
- var XCameraComponent = /*#__PURE__*/function () {
- function XCameraComponent(e, t, r) {
- var _this = this;
- _classCallCheck(this, XCameraComponent);
- E(this, "maincameraRotLimitObserver", null);
- E(this, "mainCamera");
- E(this, "cgCamera");
- E(this, "saveCameraPose");
- E(this, "_cameraPose");
- E(this, "scene");
- E(this, "canvas");
- E(this, "yuvInfo");
- E(this, "forceKeepVertical", !1);
- E(this, "initCamera", function (e) {
- var _e$maxZ = e.maxZ,
- t = _e$maxZ === void 0 ? 1e4 : _e$maxZ,
- _e$minZ = e.minZ,
- r = _e$minZ === void 0 ? .1 : _e$minZ,
- _e$angularSensibility = e.angularSensibility,
- n = _e$angularSensibility === void 0 ? 2e3 : _e$angularSensibility;
- _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);
- });
- E(this, "cameraFovChange", function (e) {
- _this.yuvInfo = e;
- var t = e.width,
- r = e.height,
- n = _this.canvas.width,
- o = _this.canvas.height,
- a = e.fov;
- if (_this.forceKeepVertical == !0) {
- var s = t / (2 * Math.tan(Math.PI * a / 360)),
- l = 2 * Math.atan(r / (2 * s));
- _this.mainCamera.fov = l, _this.cgCamera.fov = l, _this.mainCamera.fovMode = BABYLON.Camera.FOVMODE_VERTICAL_FIXED, _this.cgCamera.fovMode = BABYLON.Camera.FOVMODE_VERTICAL_FIXED;
- } 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) {
- var _s = o,
- _l = n,
- u = _s * t / r / (2 * Math.tan(a * Math.PI / 360)),
- c = 2 * Math.atan(_l / (2 * u));
- _this.mainCamera.fov = c, _this.cgCamera.fov = c;
- } else _this.mainCamera.fov = Math.PI * a / 180, _this.cgCamera.fov = Math.PI * a / 180;
- });
- E(this, "setCameraPose", function (e) {
- var n;
- var t = ue4Position2Xverse(e.position);
- var r = null;
- e.rotation != null && (r = ue4Rotation2Xverse(e.rotation)), _this._cameraPose = {
- position: t
- }, r != null && (_this._cameraPose.rotation = r), _this.scene.activeCamera === _this.mainCamera && !((n = _this.mainCamera) != null && n.isDisposed()) && _this._setCamPositionRotation(_this.mainCamera, _this._cameraPose);
- });
- E(this, "_setCamPositionRotation", function (e, t) {
- var r, n;
- t.position && (e.position = (r = t.position) == null ? void 0 : r.clone()), t.rotation && (e.rotation = (n = t.rotation) == null ? void 0 : n.clone());
- });
- E(this, "switchCamera", function (e) {
- var t;
- (t = _this.scene.activeCamera) == null || t.detachControl(_this.canvas), _this.scene.activeCamera = e;
- });
- E(this, "reCalXYZRot", function (e, t) {
- return e = e % (2 * Math.PI), Math.abs(t - e) >= Math.PI && (e = e - 2 * Math.PI), e;
- });
- E(this, "_moveCam", function (e, t, r, n, o, a, s, l) {
- var u = function u(v, y, b) {
- 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);
- },
- c = function c(v, y, b) {
- 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);
- },
- h = new Animation("myAnimation1", "position", s, Animation.ANIMATIONTYPE_VECTOR3, Animation.ANIMATIONLOOPMODE_CONSTANT);
- var f = [],
- d = t,
- _ = r;
- for (var v = 0; v < a; ++v) {
- f.push({
- frame: v,
- value: c(d, _, v / a)
- });
- }
- f.push({
- frame: f.length,
- value: c(d, _, 1)
- }), h.setKeys(f);
- var g = new Animation("myAnimation2", "rotation", s, Animation.ANIMATIONTYPE_VECTOR3, Animation.ANIMATIONLOOPMODE_CONSTANT);
- f = [], d = n, _ = o;
- for (var _v = 0; _v < a; ++_v) {
- f.push({
- frame: _v,
- value: u(d, _, _v / a)
- });
- }
- f.push({
- frame: f.length,
- value: u(d, _, 1)
- }), g.setKeys(f), e.animations.push(g), e.animations.push(h);
- var m = _this.scene.beginAnimation(e, 0, a, !1);
- m.onAnimationEnd = function () {
- l(), m.stop(), m.animationStarted = !1;
- };
- });
- this.scene = t, this.canvas = e, this.yuvInfo = r.yuvInfo, r.forceKeepVertical != null && (this.forceKeepVertical = r.forceKeepVertical), this.initCamera(r.cameraParam);
- }
- _createClass(XCameraComponent, [{
- key: "MainCamera",
- get: function get() {
- return this.mainCamera;
- }
- }, {
- key: "CgCamera",
- get: function get() {
- return this.cgCamera;
- }
- }, {
- key: "getCameraHorizonFov",
- value: function getCameraHorizonFov() {
- return this.mainCamera.fovMode == BABYLON.Camera.FOVMODE_HORIZONTAL_FIXED ? this.mainCamera.fov : Math.PI * this.yuvInfo.fov / 180;
- }
- }, {
- key: "changeMainCameraRotationDamping",
- value: function changeMainCameraRotationDamping() {
- var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2e3;
- this.mainCamera.angularSensibility = e;
- }
- }, {
- key: "removeMainCameraRotationLimit",
- value: function removeMainCameraRotationLimit() {
- this.maincameraRotLimitObserver != null && this.mainCamera.onAfterCheckInputsObservable.remove(this.maincameraRotLimitObserver);
- }
- }, {
- key: "setMainCameraInfo",
- value: function setMainCameraInfo(e) {
- var _e$maxZ2 = e.maxZ,
- t = _e$maxZ2 === void 0 ? 1e4 : _e$maxZ2,
- _e$minZ2 = e.minZ,
- r = _e$minZ2 === void 0 ? .1 : _e$minZ2,
- _e$angularSensibility2 = e.angularSensibility,
- n = _e$angularSensibility2 === void 0 ? 2e3 : _e$angularSensibility2;
- this.mainCamera.maxZ = t, this.mainCamera.minZ = r, this.mainCamera.angularSensibility = n;
- }
- }, {
- key: "getMainCameraInfo",
- value: function getMainCameraInfo() {
- return {
- maxZ: this.mainCamera.maxZ,
- minZ: this.mainCamera.minZ,
- angularSensibility: this.mainCamera.angularSensibility
- };
- }
- }, {
- key: "_limitAngle",
- value: function _limitAngle(e, t) {
- 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;
- }
- }, {
- key: "setMainCameraRotationLimit",
- value: function setMainCameraRotationLimit(e, t) {
- var _this2 = this;
- this.maincameraRotLimitObserver != null && this.removeMainCameraRotationLimit();
- var r = this.mainCamera,
- n = e.yaw,
- o = e.pitch,
- a = e.roll,
- s = t.yaw,
- l = t.pitch,
- u = t.roll;
- if (s < 0 || l < 0 || u < 0) throw new Error("\u76F8\u673A\u65CB\u8F6C\u9650\u5236\u53EA\u80FD\u8BBE\u7F6E\u4E3A\u5927\u4E8E0");
- var c = [o - l, o + l],
- h = [n - s, n + s],
- f = [a - u, a + u];
- this.maincameraRotLimitObserver = r.onAfterCheckInputsObservable.add(function () {
- var _xverseRotation2Ue = xverseRotation2Ue4(r.rotation),
- d = _xverseRotation2Ue.pitch,
- _ = _xverseRotation2Ue.yaw,
- g = _xverseRotation2Ue.roll;
- d = _this2._limitAngle(d, c), _ = _this2._limitAngle(_, h), g = _this2._limitAngle(g, f), r.rotation = ue4Rotation2Xverse({
- pitch: d,
- yaw: _,
- roll: g
- });
- });
- }
- }, {
- key: "setMainCameraRotationLimitByAnchor",
- value: function setMainCameraRotationLimitByAnchor(e, t, r) {
- this.maincameraRotLimitObserver != null && this.removeMainCameraRotationLimit();
- var n = this.mainCamera,
- o = ue4Rotation2Xverse_mesh(t),
- a = ue4Rotation2Xverse_mesh(r);
- a != null && o != null && e.mesh != null && (this.maincameraRotLimitObserver = n.onAfterCheckInputsObservable.add(function () {
- var s = e.mesh.rotation;
- 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));
- }));
- }
- }, {
- key: "getCameraPose",
- value: function getCameraPose() {
- var e = xversePosition2Ue4({
- x: this.mainCamera.position.x,
- y: this.mainCamera.position.y,
- z: this.mainCamera.position.z
- }),
- t = xverseRotation2Ue4({
- x: this.mainCamera.rotation.x,
- y: this.mainCamera.rotation.y,
- z: this.mainCamera.rotation.z
- });
- return {
- position: e,
- rotation: t
- };
- }
- }, {
- key: "changeCameraFov",
- value: function changeCameraFov(e, t) {
- this.mainCamera.fov = e, t != null && (this.mainCamera.fovMode = t == 0 ? BABYLON.Camera.FOVMODE_HORIZONTAL_FIXED : BABYLON.Camera.FOVMODE_VERTICAL_FIXED);
- }
- }, {
- key: "controlCameraRotation",
- value: function controlCameraRotation(e, t) {
- var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : .5;
- var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : .5;
- var o = {
- pitch: n * t * 180,
- yaw: r * e * 180,
- roll: 0
- };
- this.addRot(o);
- }
- }, {
- key: "addRot",
- value: function addRot(e) {
- var t = this.mainCamera,
- r = ue4Rotation2Xverse_mesh(e);
- r != null && t.rotation.addInPlace(r);
- }
- }, {
- key: "getCameraFov",
- value: function getCameraFov() {
- return this.mainCamera.fov;
- }
- }, {
- key: "allowMainCameraController",
- value: function allowMainCameraController() {
- this.mainCamera.attachControl(this.canvas, !0);
- }
- }, {
- key: "detachMainCameraController",
- value: function detachMainCameraController() {
- this.mainCamera.detachControl(this.canvas);
- }
- }, {
- key: "forceChangeSavedCameraPose",
- value: function forceChangeSavedCameraPose(e) {
- this.saveCameraPose != null && (e.position != null && (this.saveCameraPose.position = ue4Position2Xverse(e.position)), e.rotation != null && (this.saveCameraPose.rotation = ue4Rotation2Xverse(e.rotation)));
- }
- }, {
- key: "changeToFirstPersonView",
- value: function changeToFirstPersonView(e) {
- this.saveCameraPose = {
- position: this.mainCamera.position.clone(),
- rotation: this.mainCamera.rotation.clone()
- }, this.mainCamera.attachControl(this.canvas, !0), e.position != null && (this.mainCamera.position = ue4Position2Xverse(e.position)), e.rotation != null && (this.mainCamera.rotation = ue4Rotation2Xverse(e.rotation));
- }
- }, {
- key: "changeToThirdPersonView",
- value: function changeToThirdPersonView() {
- 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));
- }
- }, {
- key: "switchToMainCamera",
- value: function switchToMainCamera() {
- this.switchCamera(this.mainCamera);
- }
- }, {
- key: "switchToCgCamera",
- value: function switchToCgCamera() {
- this.switchCamera(this.cgCamera);
- }
- }, {
- key: "moveMainCamera",
- value: function moveMainCamera(e, t, r, n, o) {
- this._moveCam(this.mainCamera, this.mainCamera.position, e, this.mainCamera.rotation, t, r, n, o);
- }
- }]);
- return XCameraComponent;
- }();
- var EMeshType = {
- XAvatar: 'XAvatar',
- XStaticMesh: 'XStaticMesh',
- XBreathPoint: 'breathpoint',
- Decal: 'decal',
- Cgplane: 'cgplane',
- Tv: 'tv',
- XSubSequence: 'XSubSequence',
- XBillboard: 'XBillboard'
- };
- var XStaticMesh = /*#__PURE__*/function () {
- function XStaticMesh(_ref) {
- var _this = this;
- var e = _ref.id,
- t = _ref.mesh,
- _ref$group = _ref.group,
- r = _ref$group === void 0 ? "default" : _ref$group,
- _ref$lod = _ref.lod,
- n = _ref$lod === void 0 ? 0 : _ref$lod,
- _ref$xtype = _ref.xtype,
- o = _ref$xtype === void 0 ? EMeshType.XStaticMesh : _ref$xtype,
- _ref$skinInfo = _ref.skinInfo,
- a = _ref$skinInfo === void 0 ? "default" : _ref$skinInfo,
- _ref$url = _ref.url,
- s = _ref$url === void 0 ? "" : _ref$url;
- _classCallCheck(this, XStaticMesh);
- E(this, "_mesh");
- E(this, "_id", "-1");
- E(this, "_group");
- E(this, "_lod");
- E(this, "_isMoving", !1);
- E(this, "_isRotating", !1);
- E(this, "_isVisible", !0);
- E(this, "_skinInfo");
- E(this, "setVisibility", function (e, t) {
- Array.isArray(e) ? e.forEach(function (r) {
- _this.setVisibility(r, t);
- }) : e.isAnInstance || (e.visibility = t);
- });
- E(this, "setPickable", function (e, t) {
- Array.isArray(e) ? e.forEach(function (r) {
- _this.setPickable(r, t);
- }) : ("isPickable" in e && (e.isPickable = t), e.setEnabled(t));
- });
- E(this, "hide", function () {
- var e;
- _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) {
- _this.setVisibility(t, 0), _this.setPickable(t, !1);
- });
- });
- E(this, "show", function () {
- var e;
- _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) {
- _this.setVisibility(t, 1), _this.setPickable(t, !0);
- });
- });
- E(this, "attachToAvatar", function (e) {
- var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
- x: 0,
- y: .5,
- z: 0
- };
- var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
- yaw: 0,
- pitch: 0,
- roll: 0
- };
- var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
- x: .35,
- y: .35,
- z: .35
- };
- var o = ue4Scaling2Xverse(n),
- a = ue4Rotation2Xverse(r),
- s = ue4Position2Xverse(t),
- l = _this._mesh;
- e && l ? (e.setParent(l), e.position = s, e.rotation = a, e.scaling = o) : logger$1.error("[Engine] avatar or attachment not found!");
- });
- E(this, "detachFromAvatar", function (e) {
- _this._mesh && e ? _this._mesh.removeChild(e) : logger$1.error("[Engine] avatar not found!");
- });
- 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;
- }
- _createClass(XStaticMesh, [{
- key: "mesh",
- get: function get() {
- return this._mesh;
- }
- }, {
- key: "position",
- get: function get() {
- var o;
- if (!this._mesh) return null;
- var _ref2 = (o = this._mesh) == null ? void 0 : o.position,
- e = _ref2.x,
- t = _ref2.y,
- r = _ref2.z;
- return xversePosition2Ue4({
- x: e,
- y: t,
- z: r
- });
- }
- }, {
- key: "id",
- get: function get() {
- return this._id;
- }
- }, {
- key: "group",
- get: function get() {
- return this._group;
- }
- }, {
- key: "isMoving",
- get: function get() {
- return this._isMoving;
- }
- }, {
- key: "isVisible",
- get: function get() {
- return this._isVisible;
- }
- }, {
- key: "isRotating",
- get: function get() {
- return this._isRotating;
- }
- }, {
- key: "skinInfo",
- get: function get() {
- return this._skinInfo;
- }
- }, {
- key: "allowMove",
- value: function allowMove() {
- this._mesh != null && (this._mesh.getChildMeshes().forEach(function (e) {
- e.unfreezeWorldMatrix();
- }), this._mesh.unfreezeWorldMatrix());
- }
- }, {
- key: "unallowMove",
- value: function unallowMove() {
- this._mesh != null && (this._mesh.getChildMeshes().forEach(function (e) {
- e.freezeWorldMatrix();
- }), this._mesh.freezeWorldMatrix());
- }
- }, {
- key: "getID",
- value: function getID() {
- return this._id;
- }
- }, {
- key: "setPosition",
- value: function setPosition(e) {
- if (this._mesh) {
- var t = ue4Position2Xverse(e);
- this._mesh.position = t;
- } else logger$1.error("[Engine] no root for positioning");
- }
- }, {
- key: "setRotation",
- value: function setRotation(e) {
- var t = ue4Rotation2Xverse_mesh(e);
- this._mesh ? this._mesh.rotation = t : logger$1.error("[Engine] no root for rotating");
- }
- }, {
- key: "setScale",
- value: function setScale(e) {
- this._mesh ? this._mesh.scaling = new BABYLON.Vector3(e, e, -e) : logger$1.error("[Engine] no root for scaling");
- }
- }, {
- key: "disableAvatar",
- value: function disableAvatar() {
- var e;
- (e = this._mesh) == null || e.setEnabled(!1);
- }
- }, {
- key: "enableAvatar",
- value: function enableAvatar() {
- var e;
- (e = this._mesh) == null || e.setEnabled(!0);
- }
- }, {
- key: "togglePickable",
- value: function togglePickable(e) {
- var t;
- (t = this.mesh) == null || t.getChildMeshes().forEach(function (r) {
- "instances" in r && "isPickable" in r && (r.isPickable = e);
- }), this.mesh != null && "isPickable" in this.mesh && (this.mesh.isPickable = e);
- }
- }, {
- key: "setMaterial",
- value: function setMaterial(e) {
- var t;
- (t = this.mesh) == null || t.getChildMeshes().forEach(function (r) {
- "instances" in r && "material" in r && (r.material = e);
- }), this.mesh != null && "material" in this.mesh && (this.mesh.material = e);
- }
- }, {
- key: "dispose",
- value: function dispose() {
- var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !1;
- var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
- !this.mesh.isDisposed() && this.mesh.dispose(e, t);
- }
- }]);
- return XStaticMesh;
- }();
- 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); }; }
- 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; } }
- var XLowpolyModelError = /*#__PURE__*/function (_XverseError) {
- _inherits(XLowpolyModelError, _XverseError);
- var _super = _createSuper$3(XLowpolyModelError);
- function XLowpolyModelError(e) {
- _classCallCheck(this, XLowpolyModelError);
- return _super.call(this, 5204, e || "[Engine] \u4F20\u5165\u6A21\u578Burl\u9519\u8BEF");
- }
- return _createClass(XLowpolyModelError);
- }(XverseError);
- var XStaticMeshFromOneGltf = /*#__PURE__*/function () {
- function XStaticMeshFromOneGltf(e, t) {
- var _this = this;
- _classCallCheck(this, XStaticMeshFromOneGltf);
- E(this, "_scene");
- E(this, "_url");
- E(this, "_group");
- E(this, "_pickable");
- E(this, "_meshes");
- E(this, "_id");
- E(this, "_lod");
- E(this, "_groupUuid");
- E(this, "_isInScene");
- E(this, "_skinInfo");
- E(this, "loadMesh", function (e, t) {
- var r = _this._meshes.length,
- n = t ? 1 : 0,
- o = _this._url;
- return BABYLON.SceneLoader.LoadAssetContainerAsync("", o, _this._scene, function () {
- _this._scene.blockMaterialDirtyMechanism = !0;
- }, ".glb").then(function (a) {
- for (var s = a.materials.length - 1; s >= 0; --s) {
- a.materials[s].dispose();
- }
- _this._scene.blockMaterialDirtyMechanism = !0;
- for (var _s = 0; _s < a.meshes.length; ++_s) {
- var l = a.meshes[_s];
- if ("instances" in l) {
- "visibility" in l && (l.visibility = 0), "isPickable" in l && (l.isPickable = _this._pickable), e != null && (l.material = e), "hasVertexAlpha" in l && (l.hasVertexAlpha = !1);
- var u = new XStaticMesh({
- id: _this._groupUuid + "-" + Math.random().toString(36).substr(2, 5),
- mesh: l,
- lod: _this._lod,
- group: _this._group,
- url: _this._url,
- xtype: EMeshType.XStaticMesh,
- skinInfo: _this._skinInfo
- });
- _this._meshes.push(u);
- }
- _this._scene.addMesh(l);
- }
- return !0;
- }).then(function () {
- _this._isInScene = !0;
- for (var a = r; a < _this._meshes.length; ++a) {
- _this._meshes[a].mesh.visibility = n;
- }
- return Promise.resolve(!0);
- }).catch(function (a) {
- logger$1.error("[Engine] input gltf mesh uri error! " + a), Promise.reject(new XLowpolyModelError("[Engine] input gltf mesh uri error! " + a));
- });
- });
- 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;
- }
- _createClass(XStaticMeshFromOneGltf, [{
- key: "isinscene",
- get: function get() {
- return this._isInScene;
- }
- }, {
- key: "groupUuid",
- get: function get() {
- return this._groupUuid;
- }
- }, {
- key: "skinInfo",
- get: function get() {
- return this._skinInfo;
- }
- }, {
- key: "group",
- get: function get() {
- return this._group;
- }
- }, {
- key: "meshes",
- get: function get() {
- return this._meshes;
- }
- }, {
- key: "url",
- get: function get() {
- return this._url;
- }
- }, {
- key: "id",
- get: function get() {
- return this._id;
- }
- }, {
- key: "lod",
- get: function get() {
- return this._lod;
- }
- }, {
- key: "removeFromScene",
- value: function removeFromScene() {
- if (this._isInScene) {
- this._isInScene = !1;
- for (var e = 0, t = this._meshes.length; e < t; ++e) {
- this._meshes[e].mesh != null && this._scene.removeMesh(this._meshes[e].mesh);
- }
- }
- }
- }, {
- key: "addToScene",
- value: function addToScene() {
- if (this._isInScene == !1) {
- this._isInScene = !0;
- for (var e = 0, t = this._meshes.length; e < t; ++e) {
- this._meshes[e].mesh != null && this._scene.addMesh(this._meshes[e].mesh);
- }
- }
- }
- }, {
- key: "toggleVisibility",
- value: function toggleVisibility(e) {
- var t = e ? 1 : 0;
- for (var r = 0, n = this._meshes.length; r < n; ++r) {
- "visibility" in this._meshes[r].mesh && (this._meshes[r].mesh.visibility = t);
- }
- }
- }, {
- key: "togglePickable",
- value: function togglePickable(e) {
- for (var t = 0, r = this._meshes.length; t < r; ++t) {
- "isPickable" in this._meshes[t].mesh && (this._meshes[t].mesh.isPickable = e);
- }
- }
- }, {
- key: "setMaterial",
- value: function setMaterial(e) {
- for (var t = 0, r = this._meshes.length; t < r; ++t) {
- "material" in this._meshes[t].mesh && (this._meshes[t].mesh.material = e);
- }
- }
- }, {
- key: "dispose",
- value: function dispose() {
- for (var e = 0, t = this._meshes.length; e < t; ++e) {
- this._meshes[e].mesh.dispose(!1, !1);
- }
- }
- }]);
- return XStaticMeshFromOneGltf;
- }();
- var XStaticMeshComponent = /*#__PURE__*/function () {
- function XStaticMeshComponent(e) {
- var _this = this;
- _classCallCheck(this, XStaticMeshComponent);
- E(this, "scene");
- E(this, "_staticmeshes");
- E(this, "_lowModel_group");
- E(this, "_CgPlane");
- E(this, "_rootDir");
- E(this, "_abosoluteUrl");
- E(this, "_partMeshSkinInfo");
- E(this, "_meshInfoJson");
- E(this, "_orijson");
- E(this, "_notUsedRegionLists");
- E(this, "_meshInfoKeys");
- E(this, "_currentUpdateRegionCount");
- E(this, "_currentMeshUsedLod");
- E(this, "_currentPartGroup");
- E(this, "_allowRegionUpdate");
- E(this, "_allowRegionForceLod");
- E(this, "_forceLod");
- E(this, "_scenemanager");
- E(this, "regionIdInCamera");
- E(this, "regionIdInCameraConst");
- E(this, "_cameraInRegionId");
- E(this, "_meshVis");
- E(this, "_doMeshVisChangeNumber");
- E(this, "_meshVisTypeName");
- E(this, "_visCheckDurationFrameNumber");
- E(this, "_regionLodRule");
- E(this, "reg_staticmesh_partupdate", function () {
- if (_this._allowRegionUpdate && (_this.scene.getFrameId(), _this._meshUpdateFrame()), _this._allowRegionForceLod) {
- _this.scene.getFrameId() % 2 == 0 && _this.setOneRegionLod(_this._meshInfoKeys[_this._currentUpdateRegionCount % _this._meshInfoKeys.length].toString(), _this._forceLod);
- var t = !0;
- var r = Array.from(_this._currentMeshUsedLod.keys());
- if (r.length > 0) {
- for (var n = 0; n < r.length; ++n) {
- _this._currentMeshUsedLod.get(r[n]) != _this._forceLod && (t = !1);
- }
- t && (_this._allowRegionForceLod = !1);
- }
- }
- });
- E(this, "setMeshInfo", function (e) {
- var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
- _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 () {
- _this.startMeshUpdate();
- }));
- });
- E(this, "_meshUpdateFrame", function () {
- {
- var _e = _this._meshInfoKeys[_this._currentUpdateRegionCount % _this._meshInfoKeys.length];
- var t = !0;
- var r = 3;
- if (_this._scenemanager != null && _this._scenemanager.cameraComponent != null) {
- var n = _this._getMainPlayerPosition();
- if (n != null) {
- if (_this._cameraInRegionId >= 0) {
- var a = _this.getRegionIdWhichIncludeCamera(n);
- (_this._cameraInRegionId != a || _this.regionIdInCamera.length == 0) && (_this._cameraInRegionId = a, _this.regionIdInCamera = _this._getNeighborId(_this._cameraInRegionId.toString()), _this.regionIdInCameraConst = _this.regionIdInCamera.slice());
- var s = _this.regionIdInCamera.pop();
- for (; s != null;) {
- if (_this._notUsedRegionLists.indexOf(s) >= 0) s = _this.regionIdInCamera.pop();else break;
- }
- s != null && (_e = s.toString());
- } else _this._cameraInRegionId = _this.getRegionIdWhichIncludeCamera(n);
- if (_this._currentMeshUsedLod.size == 0 || _this._notUsedRegionLists.indexOf(parseInt(_e)) >= 0) {
- _e = _this._cameraInRegionId.toString();
- var _a = _this._getNeighborId(_e);
- for (; _a.length == 0 && (_e = _this.getNearestRegionIdWithCamera(n).toString()), _this._notUsedRegionLists.indexOf(parseInt(_e)) >= 0;) {
- _e = _a.pop().toString();
- }
- }
- var o = _this._meshInfoJson[_this._cameraInRegionId.toString()].lod;
- 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];
- }
- }
- _this.setOneRegionLod(_e, r, t), _this.updateRegionNotInLocalNeighbor(), _this.cleanRootNodes();
- }
- });
- E(this, "updateRegionNotInLocalNeighbor", function () {
- Array.from(_this._currentMeshUsedLod.keys()).forEach(function (t) {
- _this.regionIdInCameraConst.indexOf(parseInt(t)) < 0 && _this.setOneRegionLod(t, -1);
- });
- });
- E(this, "cleanRootNodes", function () {
- if (_this.scene.getFrameId() % 3 == 0) {
- var _e2 = [];
- _this.scene.rootNodes.forEach(function (t) {
- (t.getClassName() == "TransformNode" && t.getChildren().length == 0 || t.getClassName() == "Mesh" && t.name == "__root__" && t.getChildren().length == 0) && _e2.push(t);
- }), _e2.forEach(function (t) {
- t.dispose();
- });
- }
- });
- E(this, "setOneRegionLod", function (e, t) {
- _this._currentUpdateRegionCount++;
- var n = _this._calHashCode(_this._rootDir),
- o = "region_" + n + "_" + e;
- if (t < 0) {
- _this._currentMeshUsedLod.has(e) && (_this._currentMeshUsedLod.delete(e), _this._currentPartGroup.delete(o), _this.deleteMeshesByCustomProperty("group", "region_" + n + "_" + e));
- return;
- }
- var a = _this._rootDir + e + "_lod" + t + "_xverse.glb",
- s = _this._currentMeshUsedLod.get(e);
- _this._currentPartGroup.add(o), s != null ? s != t && (_this._currentMeshUsedLod.set(e, t), _this._scenemanager.addNewLowPolyMesh({
- url: a,
- group: "region_" + n + "_" + e,
- pick: !0,
- lod: t,
- skinInfo: _this._partMeshSkinInfo
- }, [{
- group: "region_" + n + "_" + e,
- mode: 0
- }])) : (_this._currentMeshUsedLod.set(e, t), _this._scenemanager.addNewLowPolyMesh({
- url: a,
- group: "region_" + n + "_" + e,
- pick: !0,
- lod: t,
- skinInfo: _this._partMeshSkinInfo
- }));
- });
- E(this, "checkPointInView", function (_ref) {
- var e = _ref.x,
- t = _ref.y,
- r = _ref.z;
- var n = ue4Position2Xverse({
- x: e,
- y: t,
- z: r
- });
- if (!n) return !1;
- for (var o = 0; o < 6; o++) {
- if (_this.scene.frustumPlanes[o].dotCoordinate(n) < 0) return !1;
- }
- return !0;
- });
- E(this, "addNewLowPolyMesh", function (e, t, r) {
- 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)));
- {
- var n = e.url;
- return new Promise(function (o, a) {
- return _this._scenemanager.urlTransformer(e.url).then(function (s) {
- e.url = s;
- var l = new XStaticMeshFromOneGltf(_this.scene, e),
- u = Date.now();
- return new Promise(function (c, h) {
- l.loadMesh(r, !0).then(function (f) {
- var d = Date.now();
- if (_this._scenemanager.engineRunTimeStats.timeArray_loadStaticMesh.add(d - u), f == !0) {
- var _ = _this.getLowModelType(e);
- var g = 0;
- 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) {
- var m = [];
- for (var v = 0; v < t.length; ++v) {
- m.push(t[v].group), _this.updateLowModelGroup(t[v], _, g);
- }
- }
- _this._scenemanager.engineRunTimeStats.timeArray_updateStaticMesh.add(Date.now() - d), c(!0);
- } else h(new XLowpolyModelError("[Engine] after lowmodel error!"));
- }).catch(function (f) {
- logger$1.error("[Engine] load Mesh [" + n + "] error! " + f), h(new XLowpolyModelError("[Engine] load Mesh [".concat(n, "] error! ").concat(f)));
- });
- });
- }).then(function (s) {
- s == !0 ? (logger$1.info("[Engine] load Mesh [".concat(n, "] successfully.")), o(!0)) : a(!1);
- }).catch(function (s) {
- logger$1.error("[Engine] addNewLowPolyMesh [" + n + "] error! " + s), a(new XLowpolyModelError("[Engine] addNewLowPolyMesh [".concat(n, "] error! ").concat(s)));
- });
- });
- }
- });
- E(this, "toggleLowModelVisibility", function (e) {
- var t = e.vis,
- _e$groupName = e.groupName,
- r = _e$groupName === void 0 ? "" : _e$groupName,
- _e$skinInfo = e.skinInfo,
- n = _e$skinInfo === void 0 ? "" : _e$skinInfo;
- _this._meshVis = t, _this._meshVisTypeName = {
- groupName: r,
- skinInfo: n
- }, _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;
- });
- E(this, "reg_staticmesh_visibility", function () {
- if (_this._doMeshVisChangeNumber >= 0) if (_this._doMeshVisChangeNumber < _this._visCheckDurationFrameNumber) {
- if (_this._doMeshVisChangeNumber = _this._doMeshVisChangeNumber + 1, _this._meshVisTypeName.groupName == Te.ALL_MESHES) _this._lowModel_group.forEach(function (e, t) {
- for (var r = 0, n = e.length; r < n; ++r) {
- e[r].toggleVisibility(_this._meshVis);
- }
- });else {
- if (_this._lowModel_group.has(_this._meshVisTypeName.groupName)) for (var _e3 = 0; _e3 < _this._lowModel_group.get(_this._meshVisTypeName.groupName).length; ++_e3) {
- _this._lowModel_group.get(_this._meshVisTypeName.groupName)[_e3].toggleVisibility(_this._meshVis);
- }
- if (_this._meshVisTypeName.skinInfo != "") for (var _e4 = 0; _e4 < _this._staticmeshes.length; ++_e4) {
- _this._staticmeshes[_e4].skinInfo == _this._meshVisTypeName.skinInfo && _this._staticmeshes[_e4].toggleVisibility(_this._meshVis);
- }
- }
- } else _this._meshVis = !0, _this._meshVisTypeName = {
- groupName: "",
- skinInfo: ""
- }, _this._doMeshVisChangeNumber = -1;
- });
- E(this, "_getMeshesByCustomProperty", function (e, t) {
- var r = [];
- return _this._staticmeshes.forEach(function (n) {
- n[e] != null && n[e] == t && (r = r.concat(n.meshes));
- }), r;
- });
- 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 = {
- groupName: "",
- skinInfo: ""
- }, this._doMeshVisChangeNumber = -1, this._visCheckDurationFrameNumber = -1, this._regionLodRule = [0, 1, 3, 3, -1], this.initCgLowModel(), this._regionPartLoop();
- }
- _createClass(XStaticMeshComponent, [{
- key: "cameraInRegionId",
- get: function get() {
- return this._cameraInRegionId;
- }
- }, {
- key: "setRegionLodRule",
- value: function setRegionLodRule(e) {
- return e.length != 5 ? !1 : (e.forEach(function (t) {}), this._regionLodRule = e, !0);
- }
- }, {
- key: "lowModel_group",
- get: function get() {
- return this._lowModel_group;
- }
- }, {
- key: "_regionPartLoop",
- value: function _regionPartLoop() {
- this.scene.registerBeforeRender(this.reg_staticmesh_partupdate), this.scene.registerAfterRender(this.reg_staticmesh_visibility);
- }
- }, {
- key: "_globalSearchCameraInWhichRegion",
- value: function _globalSearchCameraInWhichRegion(e, t) {
- var r = -1;
- for (var n = 0; n < t.length; ++n) {
- var o = this._meshInfoJson[t[n].toString()].boundingbox,
- a = o[0],
- s = o[1];
- 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]) {
- r = parseInt(t[n].toString());
- break;
- }
- }
- return r;
- }
- }, {
- key: "getRegionIdByPosition",
- value: function getRegionIdByPosition(e) {
- return this.getRegionIdWhichIncludeCamera(e);
- }
- }, {
- key: "getRegionIdWhichIncludeCamera",
- value: function getRegionIdWhichIncludeCamera(e) {
- var t = -1;
- if (this._allowRegionUpdate == !1) return t;
- 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) {
- var r = 1e7;
- for (var n = 0; n < this._meshInfoKeys.length; ++n) {
- var o = this._meshInfoJson[this._meshInfoKeys[n]].center,
- a = Math.abs(e.x - o[0]) + Math.abs(e.y - o[1]);
- r > a && (r = a, t = parseInt(this._meshInfoKeys[n]));
- }
- }
- return t;
- }
- }, {
- key: "getNearestRegionIdWithCamera",
- value: function getNearestRegionIdWithCamera(e) {
- var t = 1,
- r = 1e7;
- for (var n = 0; n < this._meshInfoKeys.length; ++n) {
- if (this._notUsedRegionLists.indexOf(parseInt(this._meshInfoKeys[n])) >= 0) continue;
- var o = this._meshInfoJson[this._meshInfoKeys[n]].center,
- a = Math.abs(e.x - o[0]) + Math.abs(e.y - o[1]);
- r > a && (r = a, t = parseInt(this._meshInfoKeys[n]));
- }
- return t;
- }
- }, {
- key: "_getNeighborId",
- value: function _getNeighborId(e) {
- var t = this._meshInfoJson[e].lod;
- var r = [];
- var n = Object.keys(t);
- for (var o = n.length - 1; o >= 0; --o) {
- r = r.concat(t[n[o]]);
- }
- return r.push(parseInt(e)), r;
- }
- }, {
- key: "_getMainPlayerPosition",
- value: function _getMainPlayerPosition() {
- var e = this._scenemanager.cameraComponent.getCameraPose().position,
- t = this._scenemanager.avatarComponent.getMainAvatar();
- if (t != null && t != null) {
- var r = t.position;
- if (r != null) return r;
- }
- return e;
- }
- }, {
- key: "_calHashCode",
- value: function _calHashCode(e) {
- return hashCode(e) + "_" + this._partMeshSkinInfo;
- }
- }, {
- key: "forceAllRegionLod",
- value: function forceAllRegionLod() {
- var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 3;
- e < 0 && (e = 0), e > 3 && (e = 3), this.stopMeshUpdate(), this._allowRegionForceLod = !0, this._forceLod = e;
- }
- }, {
- key: "deleteLastRegionMesh",
- value: function deleteLastRegionMesh() {
- if (this._rootDir != "") {
- var e = this._calHashCode(this._rootDir);
- 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);
- }
- }
- }, {
- key: "startMeshUpdate",
- value: function startMeshUpdate() {
- this._allowRegionUpdate == !1 && this._meshInfoJson != null && this._abosoluteUrl != "" && this._meshInfoKeys.length > 0 && (this._allowRegionUpdate = !0);
- }
- }, {
- key: "stopMeshUpdate",
- value: function stopMeshUpdate() {
- this._allowRegionUpdate = !1;
- }
- }, {
- key: "parseJson",
- value: function parseJson(e) {
- var _this2 = this;
- return new Promise(function (t, r) {
- return _this2._scenemanager.urlTransformer(e).then(function (n) {
- var o = new XMLHttpRequest();
- o.open("get", n), o.send(null), o.onload = function () {
- if (o.status == 200) {
- var a = JSON.parse(o.responseText);
- _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();
- }
- }, o.onerror = function () {
- 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)));
- };
- }).catch(function (n) {
- 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)));
- });
- });
- }
- }, {
- key: "initCgLowModel",
- value: function initCgLowModel() {
- var e = BABYLON.MeshBuilder.CreatePlane("CgPlane", {
- size: 400
- });
- e.position = new BABYLON.Vector3(0, 1010, 0), e.rotation = new BABYLON.Vector3(3 * Math.PI / 2, 0, 0), this._CgPlane = new XStaticMesh({
- id: "CgPlane",
- mesh: e,
- xtype: EMeshType.Cgplane
- }), this._CgPlane.hide();
- }
- }, {
- key: "getLowModelType",
- value: function getLowModelType(e) {
- var t = "";
- return e.group != null ? t = e.group : t = "default", t;
- }
- }, {
- key: "lowmodelGroupMapAddValue",
- value: function lowmodelGroupMapAddValue(e, t) {
- var r = this._lowModel_group.get(e);
- r != null ? (r.push(t), this._lowModel_group.set(e, r)) : this._lowModel_group.set(e, [t]);
- }
- }, {
- key: "updateLowModelGroup",
- value: function updateLowModelGroup(e, t, r) {
- var n = r;
- 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);
- }
- }, {
- key: "toggleVisibleLowModelGroup",
- value: function toggleVisibleLowModelGroup(e, t) {
- var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : -1;
- if (this._lowModel_group.has(t)) {
- var n = this._lowModel_group.get(t);
- var o = n.length;
- r >= 0 && o >= r && (o = r);
- for (var a = 0; a < o; ++a) {
- n[a].toggleVisibility(e);
- }
- }
- }
- }, {
- key: "deleteLowModelGroup",
- value: function deleteLowModelGroup(e) {
- var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
- if (this._lowModel_group.has(e)) {
- var o = this._lowModel_group.get(e);
- var a = o.length;
- t >= 0 && a >= t && (a = t);
- for (var s = 0; s < a; ++s) {
- o[s].dispose();
- }
- t >= 0 ? this._lowModel_group.set(e, this._lowModel_group.get(e).slice(a)) : this._lowModel_group.delete(e);
- }
- var r = this._lowModel_group.get(e),
- n = [];
- r != null && r.length > 0 ? this._staticmeshes.forEach(function (o) {
- if (o.group != e) n.push(o);else for (var _a2 = 0; _a2 < r.length; ++_a2) {
- o.groupUuid == r[_a2].groupUuid && n.push(o);
- }
- }) : this._staticmeshes.forEach(function (o) {
- o.group != e && n.push(o);
- }), this._staticmeshes = n;
- }
- }, {
- key: "deleteMeshesByGroup",
- value: function deleteMeshesByGroup(e) {
- this.deleteLowModelGroup(e);
- }
- }, {
- key: "deleteMeshesById",
- value: function deleteMeshesById(e) {
- this.deleteMeshesByCustomProperty("id", e);
- }
- }, {
- key: "deleteMeshesByLoD",
- value: function deleteMeshesByLoD(e) {
- this.deleteMeshesByCustomProperty("lod", e);
- }
- }, {
- key: "deleteMeshesBySkinInfo",
- value: function deleteMeshesBySkinInfo(e) {
- this.deleteMeshesByCustomProperty("skinInfo", e);
- }
- }, {
- key: "removeMeshesFromSceneByGroup",
- value: function removeMeshesFromSceneByGroup(e) {
- this.removeMeshesFromSceneByCustomProperty("group", e);
- }
- }, {
- key: "removeMeshesFromSceneById",
- value: function removeMeshesFromSceneById(e) {
- this.removeMeshesFromSceneByCustomProperty("id", e);
- }
- }, {
- key: "addMeshesToSceneByGroup",
- value: function addMeshesToSceneByGroup(e) {
- this.addMeshesToSceneByCustomProperty("group", e);
- }
- }, {
- key: "addMeshesToSceneById",
- value: function addMeshesToSceneById(e) {
- this.addMeshesToSceneByCustomProperty("id", e);
- }
- }, {
- key: "removeMeshesFromSceneByCustomProperty",
- value: function removeMeshesFromSceneByCustomProperty(e, t) {
- var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
- this._staticmeshes.forEach(function (n) {
- n.isinscene && n[e] != null && (r ? n[e].indexOf(t) < 0 || n.removeFromScene() : n[e] != t || n.removeFromScene());
- });
- }
- }, {
- key: "addMeshesToSceneByCustomProperty",
- value: function addMeshesToSceneByCustomProperty(e, t) {
- var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
- this._staticmeshes.forEach(function (n) {
- n.isinscene == !1 && n[e] != null && (r ? n[e].indexOf(t) < 0 || n.addToScene() : n[e] != t || n.addToScene());
- });
- }
- }, {
- key: "deleteMeshesByCustomProperty",
- value: function deleteMeshesByCustomProperty(e, t) {
- var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !1;
- var n = [];
- this._staticmeshes.forEach(function (a) {
- a[e] != null && (r ? a[e].indexOf(t) < 0 ? n.push(a) : a.dispose() : a[e] != t ? n.push(a) : a.dispose());
- }), this._staticmeshes = n;
- var o = Array.from(this._lowModel_group.keys());
- for (var a = 0; a < o.length; ++a) {
- var s = o[a],
- l = this._lowModel_group.get(s);
- if (l != null) {
- var u = [];
- for (var c = 0; c < l.length; ++c) {
- l[c][e] != null && (r ? l[c][e].indexOf(t) < 0 && u.push(l[c]) : l[c][e] != t && u.push(l[c]));
- }
- u.length > 0 ? this._lowModel_group.set(s, u) : this._lowModel_group.delete(s);
- }
- }
- }
- }, {
- key: "getMeshes",
- value: function getMeshes() {
- var e = [];
- for (var t = 0; t < this._staticmeshes.length; ++t) {
- e = e.concat(this._staticmeshes[t].meshes);
- }
- return e;
- }
- }, {
- key: "getCgMesh",
- value: function getCgMesh() {
- return this._CgPlane;
- }
- }, {
- key: "getMeshesByGroup",
- value: function getMeshesByGroup() {
- var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "default";
- var t = this._lowModel_group.get(e);
- if (t != null) {
- var r = [];
- for (var n = 0; n < t.length; ++n) {
- r = r.concat(t[n].meshes);
- }
- return r;
- } else return null;
- }
- }, {
- key: "getMeshesByGroup2",
- value: function getMeshesByGroup2() {
- var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "default";
- return this._getMeshesByCustomProperty("group", e);
- }
- }]);
- return XStaticMeshComponent;
- }();
- var XVideoRawYUV = /*#__PURE__*/function () {
- function XVideoRawYUV(e, t) {
- var _this = this;
- _classCallCheck(this, XVideoRawYUV);
- E(this, "scene");
- E(this, "_videoRawYUVTexture");
- E(this, "videosResOriArray");
- E(this, "_currentVideoId");
- this.scene = e, this._videoRawYUVTexture = [], this.videosResOriArray = t, this._currentVideoId = -1;
- for (var r = 0; r < t.length; ++r) {
- (function (n) {
- var o = BABYLON.RawTexture.CreateLuminanceTexture(null, t[n].width, t[n].height * 1.5, _this.scene, !1, !0);
- o.name = "videoTex_" + t[n].width + "_" + t[n].height, _this._videoRawYUVTexture.push(o);
- })(r);
- }
- }
- _createClass(XVideoRawYUV, [{
- key: "inRange",
- value: function inRange(e) {
- return e >= 0 && e < this._videoRawYUVTexture.length;
- }
- }, {
- key: "getVideoYUVTex",
- value: function getVideoYUVTex(e) {
- return this.inRange(e) ? this._videoRawYUVTexture[e] : null;
- }
- }, {
- key: "findId",
- value: function findId(e, t) {
- var r = 0;
- for (var n = 0; n < this.videosResOriArray.length; ++n) {
- if (this.videosResOriArray[n].width == e && this.videosResOriArray[n].height == t) {
- r = n;
- break;
- }
- }
- return r;
- }
- }, {
- key: "getCurrentVideoTexId",
- value: function getCurrentVideoTexId() {
- return this._currentVideoId;
- }
- }, {
- key: "setCurrentVideoTexId",
- value: function setCurrentVideoTexId(e) {
- this._currentVideoId = e;
- }
- }]);
- return XVideoRawYUV;
- }();
- var XMaterialComponent = /*#__PURE__*/function () {
- function XMaterialComponent(e, t) {
- var _this = this;
- _classCallCheck(this, XMaterialComponent);
- E(this, "scene");
- E(this, "engine");
- E(this, "yuvInfo");
- E(this, "shaderMode");
- E(this, "_panoInfo");
- E(this, "_dynamic_size");
- E(this, "_dynamic_babylonpose");
- E(this, "_dynamic_textures");
- E(this, "_dynamic_shaders");
- E(this, "_scenemanager");
- E(this, "_videoTexture");
- E(this, "_videoElement");
- E(this, "_lowModelShader");
- E(this, "_defaultShader");
- E(this, "_inputYUV420", !0);
- E(this, "_inputPanoYUV420", !0);
- E(this, "_videoRawYUVTexArray");
- E(this, "_isUpdateYUV", !0);
- E(this, "initMaterial", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- return _context.abrupt("return", new Promise(function (e, t) {
- _this._initDefaultShader(), _this.shaderMode == 2 ? _this.initDynamicData(_this._panoInfo.dynamicRange, _this._panoInfo.width, _this._panoInfo.height).then(function () {
- _this._initPureVideoShader(), _this._prepareRender(_this.yuvInfo);
- }) : _this.shaderMode == 1 ? (_this._initPureVideoShader(), _this._prepareRender(_this.yuvInfo)) : _this.shaderMode == 0, e(!0);
- }));
- case 1:
- case "end":
- return _context.stop();
- }
- }
- }, _callee);
- })));
- E(this, "_initPureVideoContent", function (e) {
- _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 () {
- _this._changePureVideoLowModelShaderCanvasSize(e);
- })) : (_this._videoElement = e.videoElement, _this._videoTexture || (_this._videoTexture = new VideoTexture("InterVideoTexture", _this._videoElement, _this.scene, !0, !1)), BABYLON.Texture.WhenAllReady([_this._videoTexture], function () {
- _this._changePureVideoLowModelShaderCanvasSize({
- width: _this._videoElement.height,
- height: _this._videoElement.width,
- fov: e.fov
- });
- }), _this._lowModelShader.setTexture("texture_video", _this._videoTexture), _this._lowModelShader.setFloat("isYUV", 0));
- });
- E(this, "_changePureVideoLowModelShaderCanvasSize", function (e) {
- var a;
- var t = e.fov || 50,
- r = e.width || 720,
- n = e.height || 1280,
- o = r / (2 * Math.tan(Math.PI * t / 360));
- (a = _this._lowModelShader) == null || a.setVector3("focal_width_height", new BABYLON.Vector3(o, r, n));
- });
- E(this, "updateRawYUVData", function (e, t, r) {
- var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : -1;
- var o, a;
- if (n == -1 && (n = _this.yuvInfo.fov), _this._isUpdateYUV == !0) {
- var s = {
- width: t,
- height: r,
- fov: n
- },
- l = _this._videoRawYUVTexArray.findId(t, r),
- u = _this._videoRawYUVTexArray.getCurrentVideoTexId();
- (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);
- }
- });
- E(this, "_changeVideoRes", function (e) {
- _this._lowModelShader.setTexture("texture_video", _this._videoRawYUVTexArray.getVideoYUVTex(e));
- });
- E(this, "initDynamicData", function (e, t, r) {
- return new Promise(function (n, o) {
- _this.setDynamicSize(e).then(function (a) {
- if (a) {
- for (var s = 0; s < e; ++s) {
- (function (l) {
- _this.initDynamicTexture(l, t, r), _this.initDynamicShaders(l).then(function () {
- _this._updatePanoShaderInput(l);
- });
- })(s);
- }
- n(!0);
- } else o(new XMaterialError("[Engine] DynamicRoomSize (".concat(e, ") is too small")));
- });
- }).catch(function (n) {
- return logger$1.error("[Engine] ".concat(n));
- });
- });
- E(this, "_initDefaultShader", function () {
- _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);
- });
- E(this, "_initPureVideoShader", function () {
- if (_this._lowModelShader == null) {
- var _e = new BABYLON.ShaderMaterial("PureVideoShader", _this.scene, {
- vertexSource: pureVideoVertex,
- fragmentSource: pureVideoFragment
- }, {
- attributes: ["uv", "position", "world0", "world1", "world2", "world3"],
- uniforms: ["view", "projection", "worldViewProjection", "world"],
- defines: ["#define SHADOWFULLFLOAT"]
- });
- _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;
- }
- });
- E(this, "setDynamicSize", function (e) {
- return new Promise(function (t, r) {
- e >= 1 && e <= 100 ? (_this._dynamic_size = e, t(!0)) : (_this._dynamic_size = 1, t(!1));
- });
- });
- E(this, "_isInDynamicRange", function (e) {
- return e < _this._dynamic_size && e >= 0;
- });
- E(this, "initDynamicTexture", function (e, t, r) {
- _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());
- });
- E(this, "initDynamicShaders", function (e) {
- return logger$1.info("[Engine] Material init dynamic shader."), new Promise(function (t, r) {
- _this._dynamic_shaders[e] != null && _this._dynamic_shaders[e].dispose();
- var n = new BABYLON.ShaderMaterial("Pano_Shader_" + e, _this.scene, {
- vertexSource: panoVertex,
- fragmentSource: panoFragment
- }, {
- attributes: ["uv", "position", "world0", "world1", "world2", "world3"],
- uniforms: ["view", "projection", "worldViewProjection", "world"],
- defines: ["#define SHADOWFULLFLOAT"]
- });
- 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);
- });
- });
- 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);
- }
- _createClass(XMaterialComponent, [{
- key: "stopYUVUpdate",
- value: function stopYUVUpdate() {
- this._isUpdateYUV = !1;
- }
- }, {
- key: "allowYUVUpdate",
- value: function allowYUVUpdate() {
- this._isUpdateYUV = !0;
- }
- }, {
- key: "setPanoInfo",
- value: function setPanoInfo(e) {
- this._panoInfo = e;
- }
- }, {
- key: "_prepareRender",
- value: function _prepareRender(e) {
- e && (this._initPureVideoContent(e), this._updatePureVideoShaderInput());
- }
- }, {
- key: "getPureVideoShader",
- value: function getPureVideoShader() {
- return this._lowModelShader;
- }
- }, {
- key: "getDefaultShader",
- value: function getDefaultShader() {
- return this._defaultShader;
- }
- }, {
- key: "updatePanoPartYUV",
- value: function updatePanoPartYUV(e, t, r) {
- var n = t.subarray(0, r.width * r.height),
- o = t.subarray(r.width * r.height, r.width * r.height * 1.25),
- a = t.subarray(r.width * r.height * 1.25),
- s = this._panoInfo.width,
- l = this._panoInfo.height;
- if (this._dynamic_textures[e] != null) {
- var u = this._dynamic_textures[e].getInternalTexture();
- if (u != null && u != null) {
- var c = this.engine._getTextureTarget(u);
- 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);
- }
- }
- }
- }, {
- key: "changePanoImg",
- value: function changePanoImg(e, t) {
- var _this2 = this;
- 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")));
- var r = ue4Position2Xverse(t.pose.position);
- return r && (this._dynamic_babylonpose[e] = {
- position: r
- }), new Promise(function (n, o) {
- try {
- typeof t.data == "string" ? (_this2.setPanoYUV420(!1), _this2._dynamic_textures[e].updateURL(t.data, null, function () {
- _this2._dynamic_textures[e].updateSamplingMode(BABYLON.Texture.NEAREST_SAMPLINGMODE);
- })) : (_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);
- } catch (a) {
- o(new XMaterialError("[Engine] ChangePanoImg Error! ".concat(a)));
- }
- }).then(function (n) {
- 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;
- });
- }
- }, {
- key: "setYUV420",
- value: function setYUV420(e) {
- this._inputYUV420 = e;
- }
- }, {
- key: "isYUV420",
- value: function isYUV420() {
- return this._inputYUV420;
- }
- }, {
- key: "setPanoYUV420",
- value: function setPanoYUV420(e) {
- this._inputPanoYUV420 = e;
- }
- }, {
- key: "isPanoYUV420",
- value: function isPanoYUV420() {
- return this._inputPanoYUV420;
- }
- }, {
- key: "getDynamicShader",
- value: function getDynamicShader(e) {
- return this._dynamic_shaders[e];
- }
- }, {
- key: "_updatePureVideoShaderInput",
- value: function _updatePureVideoShaderInput() {
- var _this3 = this;
- var e, t, r, n, o, a, s, l, u, c;
- 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 () {
- var h;
- _this3._lowModelShader.setFloat("fireworkLight", _this3.scene.getLightByName("fireworkLight").getScaledIntensity()), _this3._lowModelShader.setVector3("fireworkLightPosition", (h = _this3.scene.getLightByName("fireworkLight")) == null ? void 0 : h.position);
- });else {
- var h = new BABYLON.PointLight("fireworkLight", new BABYLON.Vector3(0, 0, 0), this.scene);
- h.intensity = 0;
- }
- }
- }, {
- key: "_updatePanoShaderInput",
- value: function _updatePanoShaderInput(e) {
- var _this4 = this;
- var t, r, n, o, a, s, l, u, c, h;
- 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 () {
- var f;
- _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);
- });else {
- var f = new BABYLON.PointLight("fireworkLight", new BABYLON.Vector3(0, 0, 0), this.scene);
- f.intensity = 0;
- }
- }
- }]);
- return XMaterialComponent;
- }();
- var XStats = /*#__PURE__*/function () {
- function XStats(e) {
- _classCallCheck(this, XStats);
- E(this, "scene");
- E(this, "sceneInstrumentation");
- E(this, "engineInstrumentation");
- E(this, "caps");
- E(this, "engine");
- E(this, "_canvas");
- E(this, "_osversion");
- E(this, "_scenemanager");
- this._scenemanager = e, this.scene = e.Scene, this._canvas = e.canvas, this.initSceneInstrument();
- }
- _createClass(XStats, [{
- key: "initSceneInstrument",
- value: function initSceneInstrument() {
- 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();
- }
- }, {
- key: "getFrameTimeCounter",
- value: function getFrameTimeCounter() {
- return this.sceneInstrumentation.frameTimeCounter.current;
- }
- }, {
- key: "getInterFrameTimeCounter",
- value: function getInterFrameTimeCounter() {
- return this.sceneInstrumentation.interFrameTimeCounter.current;
- }
- }, {
- key: "getActiveMeshEvaluationTime",
- value: function getActiveMeshEvaluationTime() {
- return this.sceneInstrumentation.activeMeshesEvaluationTimeCounter.current;
- }
- }, {
- key: "getDrawCall",
- value: function getDrawCall() {
- return this.sceneInstrumentation.drawCallsCounter.current;
- }
- }, {
- key: "getDrawCallTime",
- value: function getDrawCallTime() {
- return this.sceneInstrumentation.renderTimeCounter.current;
- }
- }, {
- key: "getAnimationTime",
- value: function getAnimationTime() {
- return this.sceneInstrumentation.animationsTimeCounter.current;
- }
- }, {
- key: "getActiveMesh",
- value: function getActiveMesh() {
- return this.scene.getActiveMeshes().length;
- }
- }, {
- key: "getActiveFaces",
- value: function getActiveFaces() {
- return Math.round(this.scene.getActiveIndices() / 3);
- }
- }, {
- key: "getActiveBones",
- value: function getActiveBones() {
- return this.scene.getActiveBones();
- }
- }, {
- key: "getActiveAnimation",
- value: function getActiveAnimation() {
- return this.scene._activeAnimatables.length;
- }
- }, {
- key: "getActiveParticles",
- value: function getActiveParticles() {
- return this.scene.getActiveParticles();
- }
- }, {
- key: "getTotalMaterials",
- value: function getTotalMaterials() {
- return this.scene.materials.length;
- }
- }, {
- key: "getTotalTextures",
- value: function getTotalTextures() {
- return this.scene.textures.length;
- }
- }, {
- key: "getTotalGeometries",
- value: function getTotalGeometries() {
- return this.scene.geometries.length;
- }
- }, {
- key: "getTotalMeshes",
- value: function getTotalMeshes() {
- return this.scene.meshes.length;
- }
- }, {
- key: "getCameraRenderTime",
- value: function getCameraRenderTime() {
- return this.sceneInstrumentation.cameraRenderTimeCounter.current;
- }
- }, {
- key: "getTotalRootNodes",
- value: function getTotalRootNodes() {
- return this.scene.rootNodes.length;
- }
- }, {
- key: "getRenderTargetRenderTime",
- value: function getRenderTargetRenderTime() {
- var e = this.getDrawCallTime(),
- t = this.getActiveMeshEvaluationTime(),
- r = this.getCameraRenderTime() - (t + e);
- return this.getRTT1Time() + r;
- }
- }, {
- key: "getRegisterBeforeRenderTime",
- value: function getRegisterBeforeRenderTime() {
- return this.sceneInstrumentation.registerBeforeTimeCounter.current;
- }
- }, {
- key: "getRegisterAfterRenderTime",
- value: function getRegisterAfterRenderTime() {
- return this.sceneInstrumentation.registerAfterTimeCounter.current;
- }
- }, {
- key: "getRTT1Time",
- value: function getRTT1Time() {
- return this.sceneInstrumentation.getRTT1TimeCounter.current;
- }
- }, {
- key: "getRegisterBeforeRenderObserverLength",
- value: function getRegisterBeforeRenderObserverLength() {
- return this.scene.onBeforeRenderObservable.observers.length;
- }
- }, {
- key: "getRegisterAfterRenderObserverLength",
- value: function getRegisterAfterRenderObserverLength() {
- return this.scene.onAfterRenderObservable.observers.length;
- }
- }, {
- key: "getTotalMeshByType",
- value: function getTotalMeshByType() {
- var e = new Map();
- return this.scene.meshes.forEach(function (t) {
- e.has(t.xtype) ? e.set(t.xtype, e.get(t.xtype) + 1) : e.set(t.xtype, 1);
- }), e;
- }
- }, {
- key: "getHardwareRenderInfo",
- value: function getHardwareRenderInfo() {
- return {
- maxTexturesUnits: this.caps.maxTexturesImageUnits,
- maxVertexTextureImageUnits: this.caps.maxVertexTextureImageUnits,
- maxCombinedTexturesImageUnits: this.caps.maxCombinedTexturesImageUnits,
- maxTextureSize: this.caps.maxTextureSize,
- maxSamples: this.caps.maxSamples,
- maxCubemapTextureSize: this.caps.maxCubemapTextureSize,
- maxRenderTextureSize: this.caps.maxRenderTextureSize,
- maxVertexAttribs: this.caps.maxVertexAttribs,
- maxVaryingVectors: this.caps.maxVaryingVectors,
- maxVertexUniformVectors: this.caps.maxVertexUniformVectors,
- maxFragmentUniformVectors: this.caps.maxFragmentUniformVectors,
- standardDerivatives: this.caps.standardDerivatives,
- supportTextureCompress: {
- s3tc: this.caps.s3tc !== void 0,
- s3tc_srgb: this.caps.s3tc_srgb !== void 0,
- pvrtc: this.caps.pvrtc !== void 0,
- etc1: this.caps.etc1 !== void 0,
- etc2: this.caps.etc2 !== void 0,
- astc: this.caps.astc !== void 0,
- bptc: this.caps.bptc !== void 0
- },
- textureFloat: this.caps.textureFloat,
- vertexArrayObject: this.caps.vertexArrayObject,
- textureAnisotropicFilterExtension: this.caps.textureAnisotropicFilterExtension !== void 0,
- maxAnisotropy: this.caps.maxAnisotropy,
- instancedArrays: this.caps.instancedArrays,
- uintIndices: this.caps.uintIndices,
- highPrecisionShaders: this.caps.highPrecisionShaderSupported,
- fragmentDepth: this.caps.fragmentDepthSupported,
- textureFloatLinearFiltering: this.caps.textureFloatLinearFiltering,
- renderToTextureFloat: this.caps.textureFloatRender,
- textureHalfFloat: this.caps.textureHalfFloat,
- textureHalfFloatLinearFiltering: this.caps.textureHalfFloatLinearFiltering,
- textureHalfFloatRender: this.caps.textureHalfFloatRender,
- textureLOD: this.caps.textureLOD,
- drawBuffersExtension: this.caps.drawBuffersExtension,
- depthTextureExtension: this.caps.depthTextureExtension,
- colorBufferFloat: this.caps.colorBufferFloat,
- supportTimerQuery: this.caps.timerQuery !== void 0,
- canUseTimestampForTimerQuery: this.caps.canUseTimestampForTimerQuery,
- supportOcclusionQuery: this.caps.supportOcclusionQuery,
- multiview: this.caps.multiview,
- oculusMultiview: this.caps.oculusMultiview,
- maxMSAASamples: this.caps.maxMSAASamples,
- blendMinMax: this.caps.blendMinMax,
- canUseGLInstanceID: this.caps.canUseGLInstanceID,
- canUseGLVertexID: this.caps.canUseGLVertexID,
- supportComputeShaders: this.caps.supportComputeShaders,
- supportSRGBBuffers: this.caps.supportSRGBBuffers,
- supportStencil: this.engine.isStencilEnable
- };
- }
- }, {
- key: "getSystemInfo",
- value: function getSystemInfo() {
- return {
- resolution: "real: " + this.engine.getRenderWidth() + "x" + this.engine.getRenderHeight() + " cavs: " + this._canvas.clientWidth + "x" + this._canvas.clientHeight,
- hardwareScalingLevel: this.engine.getHardwareScalingLevel().toFixed(2).toString() + "_" + this._scenemanager.initEngineScaleNumber.toFixed(2).toString(),
- driver: this.engine.getGlInfo().renderer,
- vender: this.engine.getGlInfo().vendor,
- version: this.engine.getGlInfo().version,
- os: this._osversion
- };
- }
- }, {
- key: "getFps",
- value: function getFps() {
- var e = this.sceneInstrumentation.frameTimeCounter.lastSecAverage,
- t = this.sceneInstrumentation.interFrameTimeCounter.lastSecAverage;
- return 1e3 / (e + t);
- }
- }, {
- key: "osVersion",
- value: function osVersion() {
- var e = window.navigator.userAgent;
- var t;
- 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;
- }
- }]);
- return XStats;
- }();
- function _arrayWithHoles(arr) {
- if (Array.isArray(arr)) return arr;
- }
- function _iterableToArrayLimit(arr, i) {
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
- if (_i == null) return;
- var _arr = [];
- var _n = true;
- var _d = false;
- var _s, _e;
- try {
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
- _arr.push(_s.value);
- if (i && _arr.length === i) break;
- }
- } catch (err) {
- _d = true;
- _e = err;
- } finally {
- try {
- if (!_n && _i["return"] != null) _i["return"]();
- } finally {
- if (_d) throw _e;
- }
- }
- return _arr;
- }
- function _nonIterableRest() {
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
- }
- function _slicedToArray(arr, i) {
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray$5(arr, i) || _nonIterableRest();
- }
- function _createForOfIteratorHelper$3(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$3(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
- 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); }
- 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; }
- var XBreathPointManager = /*#__PURE__*/function () {
- function XBreathPointManager(e) {
- var _this = this;
- _classCallCheck(this, XBreathPointManager);
- E(this, "_scene");
- E(this, "materialMap", new Map());
- E(this, "breathPoints", new Map());
- E(this, "_sceneManager");
- E(this, "_allIds", new Set());
- E(this, "_loopBPKeys", []);
- E(this, "addBreathPoint", /*#__PURE__*/function () {
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
- 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;
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- t = [{
- url: "https://static.xverse.cn/qqktv/texture.png"
- }];
- if (!(t.length <= 0)) {
- _context.next = 4;
- break;
- }
- logger$1.warn("[Engine] BreathPoint get texture list error: textureList.length <= 0"), new XBreathPointError("[Engine] BreathPoint get texture list error!");
- return _context.abrupt("return");
- case 4:
- 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 ? {
- pitch: -90,
- yaw: 270,
- roll: 0
- } : _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;
- if (!_this.breathPoints.get(n)) {
- _context.next = 8;
- break;
- }
- logger$1.warn("[Engine] Cannot add breathPoint with an existing id: [" + n + "]"), new XBreathPointError("[Engine] Cannot add breathPoint with an existing id: [" + n + "]");
- return _context.abrupt("return");
- case 8:
- if (g) {
- I = _this.castRay(new BABYLON.Vector3(l.x, l.y, l.z)) * scaleFromUE4toXverse;
- I != 0 ? l.z = l.z - I + 1 : l.z = l.z + 1;
- }
- if (_this.materialMap.get(m)) {
- _I = _this.materialMap.get(m);
- _I.count = _I.count + 1, C = _I.mat;
- } else {
- _I2 = new Texture(o, _this._scene, !0, !0, Texture.BILINEAR_SAMPLINGMODE, null, function () {
- logger$1.error("[Engine] Breathpoint create texture error."), new XBreathPointError("[Engine] Breathpoint create texture error.");
- }, null, !0);
- _I2.name = "TexBreathPoint_" + n, C = new StandardMaterial("MaterialBreathPoint_".concat(n), _this._scene), C.alpha = 1, C.emissiveTexture = _I2, C.backFaceCulling = y, C.diffuseTexture = _I2, C.diffuseTexture.hasAlpha = !0, C.useAlphaFromDiffuseTexture = !0, _this.materialMap.set(m, {
- mat: C,
- count: 1,
- lastRenderTime: Date.now(),
- fps: d,
- spriteWidthNumber: a,
- spriteHeightNumber: s,
- spriteSheet: o,
- texture: _I2
- });
- }
- A = new Array(6);
- for (_I3 = 0; _I3 < 6; _I3++) {
- A[_I3] = new Vector4(0, 0, 0, 0);
- }
- A[0] = new Vector4(0, 0, 1 / a, 1 / s), A[1] = new Vector4(0, 0, 1 / a, 1 / s);
- S = {};
- h > 0 && f > 0 ? S = {
- width: h,
- height: f,
- depth: .01,
- faceUV: A
- } : S = {
- size: c,
- depth: .01,
- faceUV: A
- };
- P = BABYLON.MeshBuilder.CreateBox(n, S, _this._scene);
- P.material = C;
- R = new XStaticMesh({
- id: n,
- mesh: P,
- xtype: EMeshType.XBreathPoint,
- skinInfo: T
- });
- M = u;
- _ && (P.billboardMode = Mesh.BILLBOARDMODE_ALL, R.allowMove(), M = {
- pitch: 0,
- yaw: 270,
- roll: 0
- });
- x = new BreathPoint({
- type: m,
- mesh: R,
- id: n,
- position: l,
- rotation: M,
- mat: C,
- maxVisibleRegion: b,
- scene: _this._scene,
- skinInfo: T
- });
- _this.breathPoints.set(n, x), _this._allIds.add(n), v > 0 && setTimeout(function () {
- _this.clearBreathPoints(n);
- }, v * 1e3);
- case 22:
- case "end":
- return _context.stop();
- }
- }
- }, _callee);
- }));
- return function (_x) {
- return _ref.apply(this, arguments);
- };
- }());
- E(this, "reg_breathpoint_update", function () {
- var e = new Date().getTime();
- if (_this.materialMap != null) {
- var _iterator = _createForOfIteratorHelper$3(_this.materialMap),
- _step;
- try {
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
- var _step$value = _slicedToArray(_step.value, 2),
- t = _step$value[0],
- r = _step$value[1];
- 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);
- }
- } catch (err) {
- _iterator.e(err);
- } finally {
- _iterator.f();
- }
- }
- });
- E(this, "reg_breathpoint_autovisible", function () {
- if (_this._scene.getFrameId() % 2 == 0) if (_this._loopBPKeys.length == 0) _this._loopBPKeys = Array.from(_this._allIds);else {
- var _e = _this._getMainPlayerPosition();
- for (var t = 0; t < 5 && _this._loopBPKeys.length > 0; ++t) {
- var r = _this._loopBPKeys.pop();
- if (r != null) {
- var n = _this.getBreathPoint(r);
- if (n != null && n.maxvisibleregion >= 0 && n.mesh.visibility == 1) {
- var o = n.mesh.position;
- calcDistance3DVector(_e, o) >= n.maxvisibleregion ? n == null || n.removeFromScene() : n == null || n.addToScene();
- }
- }
- }
- }
- });
- this._sceneManager = e, this._scene = e.Scene, this._scene.registerBeforeRender(this.reg_breathpoint_update), this._scene.registerBeforeRender(this.reg_breathpoint_autovisible);
- }
- _createClass(XBreathPointManager, [{
- key: "setAllBreathPointVisibility",
- value: function setAllBreathPointVisibility(e) {
- var _iterator2 = _createForOfIteratorHelper$3(this.breathPoints.entries()),
- _step2;
- try {
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
- var _step2$value = _slicedToArray(_step2.value, 2),
- t = _step2$value[0],
- r = _step2$value[1];
- r.toggleVisibility(e);
- }
- } catch (err) {
- _iterator2.e(err);
- } finally {
- _iterator2.f();
- }
- }
- }, {
- key: "toggleBPVisibilityBySkinInfo",
- value: function toggleBPVisibilityBySkinInfo(e, t) {
- var _iterator3 = _createForOfIteratorHelper$3(this.breathPoints.entries()),
- _step3;
- try {
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
- var _step3$value = _slicedToArray(_step3.value, 2),
- r = _step3$value[0],
- n = _step3$value[1];
- n.skinInfo == e && n.toggleVisibility(t);
- }
- } catch (err) {
- _iterator3.e(err);
- } finally {
- _iterator3.f();
- }
- }
- }, {
- key: "toggleBPVisibilityById",
- value: function toggleBPVisibilityById(e, t) {
- var r = this.getBreathPoint(e);
- r != null && r.toggleVisibility(t);
- }
- }, {
- key: "getBreathPointBySkinInfo",
- value: function getBreathPointBySkinInfo(e) {
- var t = [];
- var _iterator4 = _createForOfIteratorHelper$3(this.breathPoints.entries()),
- _step4;
- try {
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
- var _step4$value = _slicedToArray(_step4.value, 2),
- r = _step4$value[0],
- n = _step4$value[1];
- n.skinInfo == e && t.push(n);
- }
- } catch (err) {
- _iterator4.e(err);
- } finally {
- _iterator4.f();
- }
- return t;
- }
- }, {
- key: "getAllBreathPoint",
- value: function getAllBreathPoint() {
- return this.breathPoints;
- }
- }, {
- key: "getBreathPoint",
- value: function getBreathPoint(e) {
- return this.breathPoints.get(e);
- }
- }, {
- key: "delete",
- value: function _delete(e) {
- var t = this.breathPoints.get(e);
- if (t != null) {
- t.dispose(), this._allIds.delete(e);
- var r = this.materialMap.get(t._type);
- 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);
- }
- }
- }, {
- key: "castRay",
- value: function castRay(e) {
- var s;
- e = ue4Position2Xverse({
- x: e.x,
- y: e.y,
- z: e.z
- });
- var t = new BABYLON.Vector3(0, -1, 0),
- r = new Ray(e, t, length),
- n = [],
- o = (s = this._sceneManager) == null ? void 0 : s.getGround({
- x: e.x,
- y: e.y,
- z: e.z
- });
- var a = r.intersectsMeshes(o);
- if (a.length > 0) {
- var l = a[0];
- if (l && l.pickedMesh) {
- var u = l.distance;
- t.y = 1;
- var c = r.intersectsMeshes(n);
- var h = 1e8;
- if (c.length > 0) {
- var f = c[0];
- return f && f.pickedMesh && (h = -f.distance), h == 1e8 ? u : Math.abs(h) < Math.abs(u) ? h : u;
- }
- }
- } else if (t.y = 1, a = r.intersectsMeshes(n), a.length > 0) {
- var _l = a[0];
- if (_l && _l.pickedMesh) return _l.distance;
- }
- return 0;
- }
- }, {
- key: "changePickable",
- value: function changePickable(e) {
- var _iterator5 = _createForOfIteratorHelper$3(this.breathPoints.entries()),
- _step5;
- try {
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
- var _step5$value = _slicedToArray(_step5.value, 2),
- t = _step5$value[0],
- r = _step5$value[1];
- r.changePickable(e);
- }
- } catch (err) {
- _iterator5.e(err);
- } finally {
- _iterator5.f();
- }
- }
- }, {
- key: "clearBreathPoints",
- value: function clearBreathPoints(e) {
- logger$1.info("[Engine] clearBreathPoints: ".concat(e));
- var _iterator6 = _createForOfIteratorHelper$3(this.breathPoints.entries()),
- _step6;
- try {
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
- var _step6$value = _slicedToArray(_step6.value, 2),
- t = _step6$value[0],
- r = _step6$value[1];
- (r._type == e || r._id == e) && this.delete(r._id);
- }
- } catch (err) {
- _iterator6.e(err);
- } finally {
- _iterator6.f();
- }
- }
- }, {
- key: "clearBreathPointsBySkinInfo",
- value: function clearBreathPointsBySkinInfo(e) {
- logger$1.info("[Engine] clearBreathPointsBySkinInfo: ".concat(e));
- var _iterator7 = _createForOfIteratorHelper$3(this.breathPoints.entries()),
- _step7;
- try {
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
- var _step7$value = _slicedToArray(_step7.value, 2),
- t = _step7$value[0],
- r = _step7$value[1];
- r.skinInfo == e && this.delete(r._id);
- }
- } catch (err) {
- _iterator7.e(err);
- } finally {
- _iterator7.f();
- }
- }
- }, {
- key: "clearAllBreathPoints",
- value: function clearAllBreathPoints() {
- logger$1.info("[Engine] ClearAllBreathPoints");
- var _iterator8 = _createForOfIteratorHelper$3(this.breathPoints.entries()),
- _step8;
- try {
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
- var _step8$value = _slicedToArray(_step8.value, 2),
- e = _step8$value[0],
- t = _step8$value[1];
- this.delete(t._id);
- }
- } catch (err) {
- _iterator8.e(err);
- } finally {
- _iterator8.f();
- }
- }
- }, {
- key: "_getMainPlayerPosition",
- value: function _getMainPlayerPosition() {
- var r;
- var e = this._sceneManager.cameraComponent.MainCamera.position,
- t = this._sceneManager.avatarComponent.getMainAvatar();
- if (t != null && t != null) {
- var n = (r = t == null ? void 0 : t.rootNode) == null ? void 0 : r.position;
- if (n != null) return n;
- }
- return e;
- }
- }, {
- key: "changeBreathPointPose",
- value: function changeBreathPointPose(e, t, r) {
- var n = new BABYLON.Vector3(e.position.x, e.position.y, e.position.z);
- if (this.breathPoints.get(r) != null) {
- logger$1.info("[Engine] changeBreathPointPose, id:".concat(r));
- var o = this.breathPoints.get(r),
- a = o.mesh.position;
- var s = a.subtract(n);
- s = BABYLON.Vector3.Normalize(s);
- var l = BABYLON.Vector3.Distance(a, n),
- u = new Ray(n, s, l),
- c = this._scene.multiPickWithRay(u);
- if (c) {
- for (var h = 0; h < c.length; h++) {
- if (c[h].pickedMesh != null && t.mesh.name.indexOf(c[h].pickedMesh.name) >= 0) {
- var f = c[h].pickedPoint;
- o.mesh.position = n.add(f.subtract(n).scale(.99)), this.breathPoints.set(r, o);
- }
- }
- }
- } else logger$1.warn("[Engine] changeBreathPointPose, id:".concat(r, " is not existing!"));
- }
- }]);
- return XBreathPointManager;
- }();
- 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; } } }; }
- 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); }
- 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; }
- var XDecalManager = /*#__PURE__*/function () {
- function XDecalManager(e) {
- _classCallCheck(this, XDecalManager);
- E(this, "scene");
- E(this, "_decal");
- E(this, "_mat");
- E(this, "_sharedMat");
- E(this, "_scenemanager");
- this._decal = new Map(), this._mat = new Map(), this._sharedMat = new Map(), this._scenemanager = e, this.scene = e.Scene;
- }
- _createClass(XDecalManager, [{
- key: "decals",
- get: function get() {
- return Array.from(this._decal.values());
- }
- }, {
- key: "getMesh",
- value: function getMesh() {
- return this._decal;
- }
- }, {
- key: "addDecal",
- value: function () {
- var _addDecal = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
- var _this = this;
- var t, r, _e$skinInfo, n;
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- t = e.id, r = e.meshPath, _e$skinInfo = e.skinInfo, n = _e$skinInfo === void 0 ? "default" : _e$skinInfo;
- 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) {
- return _this._scenemanager.urlTransformer(r).then(function (s) {
- return new Promise(function (l, u) {
- if (_this._decal.get(t)) l(!0);else {
- var c = new XDecal({
- id: t,
- scene: _this.scene,
- meshPath: s,
- skinInfo: n
- });
- _this._decal.set(t, c), c.loadModel().then(function () {
- l(!0);
- }).catch(function (h) {
- 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)));
- });
- }
- });
- }).then(function (s) {
- s == !0 ? o(!0) : a(!1);
- }).catch(function (s) {
- 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)));
- });
- })));
- case 2:
- case "end":
- return _context.stop();
- }
- }
- }, _callee, this);
- }));
- function addDecal(_x) {
- return _addDecal.apply(this, arguments);
- }
- return addDecal;
- }()
- }, {
- key: "setDecalTexture",
- value: function setDecalTexture(e) {
- var _this2 = this;
- var t = e.id,
- r = e.buffer,
- _e$isDynamic = e.isDynamic,
- n = _e$isDynamic === void 0 ? !1 : _e$isDynamic,
- _e$width = e.width,
- o = _e$width === void 0 ? 1100 : _e$width,
- _e$height = e.height,
- a = _e$height === void 0 ? 25 : _e$height,
- _e$slots = e.slots,
- s = _e$slots === void 0 ? 1 : _e$slots,
- _e$visibleSlots = e.visibleSlots,
- l = _e$visibleSlots === void 0 ? 1 : _e$visibleSlots,
- u = !0;
- return logger.info("[Engine] setDecalTexture wiht id:[".concat(t, "]")), new Promise(function (c, h) {
- var f = _this2._decal.get(t);
- if (f != null) {
- if (_this2._mat.get(t) != null) _this2.changeDecalTexture({
- id: t,
- buffer: r,
- isUrl: u,
- isDynamic: n,
- width: o,
- height: a,
- slots: s,
- visibleSlots: l
- }), c(!0);else {
- var d = new XDecalMaterial(t, _this2.scene);
- d.setTexture(r, u, n, o, a, s, l).then(function () {
- f.setMat(d.getMat()), _this2._decal.set(t, f), _this2._mat.set(t, d), c(!0);
- }).catch(function (_) {
- logger.error("[Engine] setDecalTexture Error! " + _), h(new XDecalTextureError("[Engine] decal set texture error! ".concat(_)));
- });
- }
- } else logger.error("[Engine] Error! decal id: [" + t + "] is not find!"), h(new XDecalTextureError("[Engine] decal id: [".concat(t, "] is not find!")));
- });
- }
- }, {
- key: "shareDecal",
- value: function () {
- var _shareDecal = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e) {
- var _this3 = this;
- var t, r, n, _e$skinInfo2, o;
- return regenerator.wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- t = e.idTar, r = e.meshPath, n = e.idSrc, _e$skinInfo2 = e.skinInfo, o = _e$skinInfo2 === void 0 ? "default" : _e$skinInfo2;
- 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) {
- return _this3._scenemanager.urlTransformer(r).then(function (l) {
- var u = new XDecal({
- id: t,
- scene: _this3.scene,
- meshPath: l,
- skinInfo: o
- }),
- c = _this3._mat.get(n);
- c != null && (u.setMat(c.getMat()), u.sourceMatId = n, _this3._decal.set(t, u), _this3.addSharedMatCount(n)), a(!0);
- }).catch(function (l) {
- s(new XDecalError("[Engine] decal shareDecal error! ".concat(l)));
- });
- })) : (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!"))));
- case 2:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2, this);
- }));
- function shareDecal(_x2) {
- return _shareDecal.apply(this, arguments);
- }
- return shareDecal;
- }()
- }, {
- key: "changeDecalModel",
- value: function () {
- var _changeDecalModel = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
- var _this4 = this;
- var t, r, n;
- return regenerator.wrap(function _callee3$(_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- t = e.id, r = e.meshPath, n = this._decal.get(t);
- return _context3.abrupt("return", new Promise(function (o, a) {
- return n != null ? (logger.info("[Engine] changeDecalModel id:".concat(t)), n.changeModel(r).then(function () {
- _this4._decal.set(t, n), o(!0);
- })) : (logger.warn("[Engine] changeDecalModel id:".concat(t, " is not exist")), a("[Engine] changeDecalModel id:".concat(t, " is not exist")));
- }));
- case 2:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee3, this);
- }));
- function changeDecalModel(_x3) {
- return _changeDecalModel.apply(this, arguments);
- }
- return changeDecalModel;
- }()
- }, {
- key: "changeDecalTexture",
- value: function changeDecalTexture(e) {
- var t = e.id,
- r = e.buffer,
- _e$isUrl = e.isUrl,
- n = _e$isUrl === void 0 ? !1 : _e$isUrl,
- _e$isDynamic2 = e.isDynamic,
- o = _e$isDynamic2 === void 0 ? !1 : _e$isDynamic2,
- _e$width2 = e.width,
- a = _e$width2 === void 0 ? 1110 : _e$width2,
- _e$height2 = e.height,
- s = _e$height2 === void 0 ? 25 : _e$height2,
- _e$slots2 = e.slots,
- l = _e$slots2 === void 0 ? 1 : _e$slots2,
- _e$visibleSlots2 = e.visibleSlots,
- u = _e$visibleSlots2 === void 0 ? 1 : _e$visibleSlots2,
- c = this._mat.get(t);
- 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"));
- }
- }, {
- key: "deleteDecal",
- value: function deleteDecal(e) {
- var t, r;
- if (this._decal.has(e)) {
- var n = this._decal.get(e);
- 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);
- }
- }
- }, {
- key: "deleteDecalBySkinInfo",
- value: function deleteDecalBySkinInfo(e) {
- var _iterator = _createForOfIteratorHelper$2(this._decal.entries()),
- _step;
- try {
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
- var _step$value = _slicedToArray(_step.value, 2),
- t = _step$value[0],
- r = _step$value[1];
- r.skinInfo == e && this.deleteDecal(t);
- }
- } catch (err) {
- _iterator.e(err);
- } finally {
- _iterator.f();
- }
- }
- }, {
- key: "addSharedMatCount",
- value: function addSharedMatCount(e) {
- var t = this._sharedMat.get(e);
- t != null ? this._sharedMat.set(e, t + 1) : this._sharedMat.set(e, 1);
- }
- }, {
- key: "minusSharedMatCount",
- value: function minusSharedMatCount(e) {
- var r;
- var t = this._sharedMat.get(e);
- 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)));
- }
- }, {
- key: "toggle",
- value: function toggle(e, t) {
- var r = this._decal.get(e);
- r == null || r.toggle(t);
- }
- }, {
- key: "toggleDecalBySkinInfo",
- value: function toggleDecalBySkinInfo(e, t) {
- var _iterator2 = _createForOfIteratorHelper$2(this._decal.entries()),
- _step2;
- try {
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
- var _step2$value = _slicedToArray(_step2.value, 2),
- r = _step2$value[0],
- n = _step2$value[1];
- n.skinInfo == e && n.toggle(t);
- }
- } catch (err) {
- _iterator2.e(err);
- } finally {
- _iterator2.f();
- }
- }
- }, {
- key: "updateTexAsWords",
- value: function updateTexAsWords(e, t) {
- var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
- var _r$clearArea = r.clearArea,
- n = _r$clearArea === void 0 ? !0 : _r$clearArea,
- _r$w = r.w,
- o = _r$w === void 0 ? 480 : _r$w,
- _r$h = r.h,
- a = _r$h === void 0 ? 480 : _r$h,
- _r$y = r.y,
- s = _r$y === void 0 ? a / 2 : _r$y,
- _r$fontsize = r.fontsize,
- l = _r$fontsize === void 0 ? 70 : _r$fontsize,
- _r$slots = r.slots,
- u = _r$slots === void 0 ? 1 : _r$slots,
- _r$visibleSlots = r.visibleSlots,
- c = _r$visibleSlots === void 0 ? 1 : _r$visibleSlots,
- _r$font = r.font,
- h = _r$font === void 0 ? "black-body" : _r$font,
- _r$color = r.color,
- f = _r$color === void 0 ? "white" : _r$color,
- _r$fontweight = r.fontweight,
- d = _r$fontweight === void 0 ? 100 : _r$fontweight;
- var _r$x = r.x,
- _ = _r$x === void 0 ? o / 2 : _r$x;
- var g = this._mat.get(e);
- if (g) {
- _ == -1 && (_ = (g.getUOffset() + c / u) % 1 * o * u);
- var v = g.getMat().diffuseTexture,
- y = v.getContext();
- 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();
- }
- }
- }, {
- key: "updateTexAsImg",
- value: function () {
- var _updateTexAsImg = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e, t) {
- var _this5 = this;
- var r,
- _r$clearArea2,
- n,
- _r$w2,
- o,
- _r$h2,
- a,
- _r$x2,
- s,
- _r$y2,
- l,
- _r$clearW,
- u,
- _r$clearH,
- c,
- _args4 = arguments;
- return regenerator.wrap(function _callee4$(_context4) {
- while (1) {
- switch (_context4.prev = _context4.next) {
- case 0:
- r = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
- _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;
- 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) {
- return _this5._scenemanager.urlTransformer(t).then(function (d) {
- return new Promise(function (_, g) {
- var m = _this5._mat.get(e);
- if (m) {
- var y = m.getMat().diffuseTexture;
- if (typeof t == "string") {
- var b = new Image();
- b.crossOrigin = "anonymous", b.src = d, b.onload = function () {
- var T = y.getContext();
- 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);
- }, b.onerror = function () {
- 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!")));
- };
- } 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!")));
- } 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!")));
- }).then(function (_) {
- _ == !0 ? h(!0) : (logger.error("[Engine] updateTexAsImg Error. id: [".concat(e, "] !")), f(new XDecalError("[Engine] updateTexAsImg error! id: [".concat(e, "]"))));
- }).catch(function (_) {
- logger.error("[Engine] updateTexAsImg Error. id: [".concat(e, "]. ").concat(_));
- });
- });
- }));
- case 3:
- case "end":
- return _context4.stop();
- }
- }
- }, _callee4);
- }));
- function updateTexAsImg(_x4, _x5) {
- return _updateTexAsImg.apply(this, arguments);
- }
- return updateTexAsImg;
- }()
- }, {
- key: "startAnime",
- value: function startAnime(e, t) {
- logger.info("[Engine] Decal Start Anime. [".concat(e, "]"));
- var _t$speed = t.speed,
- r = _t$speed === void 0 ? .001 : _t$speed,
- n = t.callback,
- o = this._mat.get(e);
- 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!")));
- }
- }]);
- return XDecalManager;
- }();
- var PoolObject = /*#__PURE__*/function () {
- function PoolObject(e, t, r) {
- var n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : !0;
- _classCallCheck(this, PoolObject);
- E(this, "data");
- E(this, "nextFree");
- E(this, "previousFree");
- E(this, "free");
- this.data = e, this.nextFree = t, this.previousFree = r, this.free = n;
- }
- _createClass(PoolObject, [{
- key: "dispose",
- value: function dispose() {
- this.data && this.data instanceof Mesh && this.data.dispose(!0, !0), this.previousFree = null, this.nextFree = null, this.data = null;
- }
- }]);
- return PoolObject;
- }();
- var Pool = /*#__PURE__*/function () {
- function Pool(e, t, r, n) {
- _classCallCheck(this, Pool);
- this.lastFree = null;
- this.nextFree = null;
- this._pool = [], this.objCreator = e, this.objReseter = t;
- for (var _len = arguments.length, o = new Array(_len > 4 ? _len - 4 : 0), _key = 4; _key < _len; _key++) {
- o[_key - 4] = arguments[_key];
- }
- for (var a = 0; a < n; a++) {
- this.addNewObject(this.newPoolObject.apply(this, o));
- }
- this.capacity = r;
- }
- _createClass(Pool, [{
- key: "addNewObject",
- value: function addNewObject(e) {
- return this._pool.push(e), this.release(e), e;
- }
- }, {
- key: "release",
- value: function release(e) {
- 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);
- }
- }, {
- key: "getFree",
- value: function getFree() {
- var t = this.nextFree ? this.nextFree : this.addNewObject(this.newPoolObject.apply(this, arguments));
- return t.free = !1, this.nextFree = t.nextFree, this.nextFree || (this.lastFree = null), t;
- }
- }, {
- key: "newPoolObject",
- value: function newPoolObject() {
- var t = this.objCreator.apply(this, arguments);
- return new PoolObject(t, this.nextFree, this.lastFree);
- }
- }, {
- key: "releaseAll",
- value: function releaseAll() {
- var _this = this;
- this._pool.forEach(function (e) {
- return _this.release(e);
- });
- }
- }, {
- key: "clean",
- value: function clean() {
- var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
- var r = this.nextFree;
- if (!r) return;
- var n = 0;
- for (; r;) {
- n += 1, r = r.nextFree;
- }
- var o = !1;
- if (n > e && this._pool.length > this.capacity && (o = !0), o) for (r = this.nextFree; r;) {
- r.free = !1, this.nextFree = r.nextFree;
- var a = this._pool.indexOf(r);
- this._pool.splice(a, 1), this.nextFree || (this.lastFree = null), r == null || r.dispose(), r = this.nextFree;
- }
- }
- }]);
- return Pool;
- }();
- var BillboardStatus = {
- SHOW: 1,
- HIDE: 0,
- DISPOSE: -1
- };
- 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; } } }; }
- 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); }
- 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; }
- var XAvatarManager = /*#__PURE__*/function () {
- function XAvatarManager(e) {
- var _this = this;
- _classCallCheck(this, XAvatarManager);
- this.characterMap = new Map();
- this.curAnimList = [];
- this.extraComps = new Map();
- this._mainUser = null;
- this._lodSettings = null;
- this.maxBillBoardDist = 0;
- this.maxAvatarNum = 0;
- this.currentLODUsers = [];
- this.bboxMeshPool = null;
- this._distLevels = [];
- this._maxLODUsers = [];
- this._cullingDistance = 0;
- this._maxDistRange = null;
- this._delayTime = 100;
- this._queueLength = -1;
- this._queue = [];
- this._processList = [];
- this._process = null;
- this._updateLoopObserver = null;
- this._avatarInDistance = [];
- this._renderedAvatar = [];
- this._enableNickname = !0;
- this._tickObserver = null;
- this._tickInterval = null;
- this._defaultAnims = null;
- this._tickDispose = 0;
- this._disposeTime = 100;
- this.avatarLoader = avatarLoader;
- this._scene = e.mainScene;
- this._sceneManager = e;
- this.initAvatarMap();
- this._initSettings();
- 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;
- var t = 0;
- this._tickObserver = this._scene.onAfterRenderObservable.add(function () {
- t += 1, t == _this._tickInterval && (_this.tick(), t = 0);
- });
- }
- _createClass(XAvatarManager, [{
- key: "tick",
- value: function tick() {
- this.bboxMeshPool.clean(0);
- }
- }, {
- key: "createBboxAsset",
- value: function createBboxAsset(e, t, r, n) {
- return BABYLON.MeshBuilder.CreateBox("avatarBbox", {
- width: t,
- height: r,
- depth: n
- }, e);
- }
- }, {
- key: "resetBboxAsset",
- value: function resetBboxAsset(e) {
- var t = e.data;
- return t.setEnabled(!1), t.isPickable = !1, e;
- }
- }, {
- key: "_initSettings",
- value: function _initSettings() {
- this._defaultAnims = avatarSetting.defaultIdle, this._lodSettings = avatarSetting.lod, this._distLevels = avatarSetting.lod.map(function (e) {
- return e.dist;
- }), this._maxLODUsers = avatarSetting.lod.map(function (e) {
- return e.quota;
- }), this.currentLODUsers = new Array(this._distLevels.length).fill(0), this.maxAvatarNum = avatarSetting.maxAvatarNum, this.maxBillBoardDist = avatarSetting.maxBillBoardDist, this._cullingDistance = avatarSetting.cullingDistance;
- }
- }, {
- key: "maxRenderNum",
- value: function maxRenderNum() {
- var e = 0;
- return this._maxLODUsers.forEach(function (t) {
- e += t;
- }), e;
- }
- }, {
- key: "curRenderNum",
- value: function curRenderNum() {
- var e = 0;
- return this.currentLODUsers.forEach(function (t) {
- e += t;
- }), e;
- }
- }, {
- key: "setLoDLevels",
- value: function setLoDLevels(e) {
- this._distLevels = e;
- }
- }, {
- key: "cullingDistance",
- get: function get() {
- return this._cullingDistance;
- },
- set: function set(e) {
- this._cullingDistance = e;
- }
- }, {
- key: "getLoDLevels",
- value: function getLoDLevels() {
- return this._distLevels;
- }
- }, {
- key: "setLodUserLimits",
- value: function setLodUserLimits(e, t) {
- this._maxLODUsers.length > e && (this._maxLODUsers[e] = t);
- }
- }, {
- key: "setLodDist",
- value: function setLodDist(e, t) {
- this._distLevels[e] = t;
- }
- }, {
- key: "setMaxDistRange",
- value: function setMaxDistRange(e) {
- this._maxDistRange = e, this._distLevels[this._distLevels.length - 1] = e;
- }
- }, {
- key: "scene",
- get: function get() {
- return this._scene;
- }
- }, {
- key: "setMainAvatar",
- value: function setMainAvatar(e) {
- var t;
- this._mainUser = (t = this.characterMap.get(0)) == null ? void 0 : t.get(e);
- }
- }, {
- key: "getMainAvatar",
- value: function getMainAvatar() {
- return this._mainUser;
- }
- }, {
- key: "enableAllNickname",
- value: function enableAllNickname(e) {
- var _this2 = this;
- return this.characterMap.forEach(function (t, r) {
- r != 0 && t.forEach(function (n, o) {
- _this2._updateBillboardStatus(n, e ? BillboardStatus.SHOW : BillboardStatus.HIDE);
- });
- }), this._enableNickname = e;
- }
- }, {
- key: "getAvatarById",
- value: function getAvatarById(e) {
- var t;
- return this.characterMap.forEach(function (r, n) {
- r.get(e) && (t = r.get(e));
- }), t;
- }
- }, {
- key: "getAvatarNums",
- value: function getAvatarNums() {
- var e = 0;
- return this.characterMap.forEach(function (t, r) {
- e += t.size;
- }), e;
- }
- }, {
- key: "registerAvatar",
- value: function registerAvatar(e) {
- this.characterMap.get(e.priority).set(e.id, e);
- }
- }, {
- key: "unregisterAvatar",
- value: function unregisterAvatar(e) {
- this.characterMap.get(e.priority).delete(e.id);
- }
- }, {
- key: "initAvatarMap",
- value: function initAvatarMap() {
- 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());
- }
- }, {
- key: "loadAvatar",
- value: function loadAvatar(_ref) {
- var _this3 = this;
- var e = _ref.id,
- t = _ref.avatarType,
- r = _ref.priority,
- n = _ref.avatarManager,
- o = _ref.assets,
- a = _ref.status;
- return new Promise(function (s, l) {
- if (_this3.getAvatarById(e)) return l(new DuplicateAvatarIDError("[Engine] cannot init avatar with the same id = ".concat(e)));
- if (_this3.getAvatarNums() > _this3.maxAvatarNum) return l(new ExceedMaxAvatarNumError("[Engine] \u8D85\u51FA\u6700\u5927\u89D2\u8272\u9650\u5236 ".concat(_this3.maxAvatarNum)));
- var u = new XAvatar({
- id: e,
- avatarType: t,
- priority: r,
- avatarManager: n,
- assets: o,
- status: a
- });
- if (_this3.registerAvatar(u), r == 0) _this3.setMainAvatar(u.id), _this3.addAvatarToScene(u, 0).then(function (c) {
- return logger$1.debug("[Engine] avatar ".concat(u.id, " has been added to scene")), c ? (_this3._updateBillboardStatus(c, BillboardStatus.SHOW), setTimeout(function () {
- _this3.launchProcessLoadingLoop();
- }, _this3._delayTime), s(c)) : (u.removeAvatarFromScene(), l(new AvatarAssetLoadingError()));
- }).catch(function (c) {
- return u.removeAvatarFromScene(), l(new AvatarAssetLoadingError(c));
- });else return s(u);
- });
- }
- }, {
- key: "deleteAvatar",
- value: function deleteAvatar(e) {
- return e.isRender ? (e.removeAvatarFromScene(), this.currentLODUsers[e.distLevel]--) : e.bbComponent.disposeBillBoard(e), this._processList = this._processList.filter(function (t) {
- return t.id !== e.id;
- }), this.unregisterAvatar(e), e.rootNode && (e.rootNode.dispose(), e.rootNode = void 0), e.bbComponent.bbox && e.bbComponent.bbox.dispose(), e.removeObserver(), e;
- }
- }, {
- key: "_checkLODLevel",
- value: function _checkLODLevel(e) {
- if (e < this._distLevels[0]) return 0;
- for (var t = 1; t < this._distLevels.length; ++t) {
- if (e >= this._distLevels[t - 1] && e < this._distLevels[t]) return t;
- }
- return this._distLevels.length - 1;
- }
- }, {
- key: "sceneManager",
- get: function get() {
- return this._sceneManager;
- }
- }, {
- key: "launchProcessLoadingLoop",
- value: function launchProcessLoadingLoop() {
- this._updateAvatarStatus();
- }
- }, {
- key: "stopProcessLoadingLoop",
- value: function stopProcessLoadingLoop() {
- var e;
- this._updateLoopObserver && ((e = this._scene) == null || e.onBeforeRenderObservable.remove(this._updateLoopObserver));
- }
- }, {
- key: "_distToMain",
- value: function _distToMain(e) {
- var n;
- var t = (n = this._mainUser) == null ? void 0 : n.position,
- r = e.position;
- if (r && t) {
- var o = this.sceneManager.cameraComponent.MainCamera.getFrontPosition(1).subtract(this.sceneManager.cameraComponent.MainCamera.position).normalize(),
- a = e.rootNode.position.subtract(this.sceneManager.cameraComponent.MainCamera.position).normalize();
- var s = 1;
- if (o && a) {
- var l = a.multiply(o);
- s = Math.acos(l.x + l.y + l.z) < this.sceneManager.cameraComponent.MainCamera.fov / 2 ? 1 : 1e11;
- }
- return calcDistance3D(t, r) * s;
- } else return logger$1.warn("user position or camera position is not correct!"), 1e11;
- }
- }, {
- key: "_distToCamera",
- value: function _distToCamera(e) {
- var n;
- var t = (n = this._sceneManager) == null ? void 0 : n.cameraComponent.getCameraPose().position,
- r = e.position;
- return r && t ? calcDistance3D(t, r) : (logger$1.warn("user position or camera position is not correct!"), 1e11);
- }
- }, {
- key: "showAll",
- value: function showAll(e) {
- this.characterMap.forEach(function (t, r) {
- e && r == 0 && t.forEach(function (n, o) {
- n.show();
- }), r != 0 && t.forEach(function (n, o) {
- n.show();
- });
- });
- }
- }, {
- key: "hideAll",
- value: function hideAll(e) {
- this.characterMap.forEach(function (t, r) {
- e && r == 0 && t.forEach(function (n, o) {
- n.hide();
- }), r != 0 && t.forEach(function (n, o) {
- n.hide();
- });
- });
- }
- }, {
- key: "_assemblyAvatar",
- value: function _assemblyAvatar(e, t) {
- var _this4 = this;
- var n, o;
- var r = e.get(avatarSetting.body);
- if (r && !t.attachBody(r)) {
- t.isInLoadingList = !1, e.clear();
- return;
- }
- var _iterator = _createForOfIteratorHelper$1(e),
- _step;
- try {
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
- var a = _step.value;
- if (a[0] != avatarSetting.body && a[0] != avatarSetting.animations && !t.attachDecoration(a[1])) {
- t.isInLoadingList = !1, t.removeAvatarFromScene(), e.clear();
- return;
- }
- }
- } catch (err) {
- _iterator.e(err);
- } finally {
- _iterator.f();
- }
- t.isRender = !0, (n = t.controller) == null || n.playAnimation(t.controller.onPlay, t.controller.loop), (o = t.controller) == null || o.onPlayObservable.addOnce(function () {
- var a, s;
- if (!_this4.getAvatarById(t.id)) {
- t.isInLoadingList = !1, t.removeAvatarFromScene(), _this4.currentLODUsers[t.distLevel]--;
- return;
- }
- if (_this4.getAvatarById(t.id).rootNode.getChildMeshes().length < e.size) {
- 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]--;
- return;
- }
- 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));
- });
- }
- }, {
- key: "_disposeUnusedAssets",
- value: function _disposeUnusedAssets() {
- this._tickDispose++, this._tickDispose > this._disposeTime && (avatarLoader.disposeContainer(), this._tickDispose = 0);
- }
- }, {
- key: "_addResourcesToList",
- value: function _addResourcesToList(e, t) {
- var _this5 = this;
- return e.clothesList.forEach(function (r) {
- r.lod = t, _this5._queue.push(r);
- }), this._queue.push({
- type: avatarSetting.animations,
- id: this._defaultAnims
- }), this._queue.push({
- type: avatarSetting.body,
- id: e.avatarType,
- lod: t
- }), !0;
- }
- }, {
- key: "_updateBillboardStatus",
- value: function _updateBillboardStatus(e, t) {
- e.bbComponent.updateBillboardStatus(e, t);
- }
- }, {
- key: "_processLayer",
- value: function _processLayer(e) {
- var _this6 = this;
- var t = this.characterMap.get(e),
- r = [];
- for (t == null || t.forEach(function (n) {
- n.distToCam = _this6._distToCamera(n);
- var o = n.distToCam < _this6._cullingDistance;
- if (n.isRender && (!n.isHide && o ? n._hide_culling() : n._show_culling()), n.priority != 0) {
- n.distance = _this6._distToMain(n);
- var _a = BillboardStatus.SHOW;
- 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));
- }
- }), r.sort(function (n, o) {
- return o.distance - n.distance;
- }); r.length > 0 && this.curRenderNum() < this.maxRenderNum();) {
- var n = r.pop();
- var o = this._checkLODLevel(n.distance),
- a = !1;
- for (var s = 0; s < this._maxLODUsers.length; ++s) {
- if (this.currentLODUsers[s] < this._maxLODUsers[s]) {
- o = s, a = !0;
- break;
- }
- }
- if (!a || n.distance > this._maxDistRange) {
- if (n.isRender) {
- n._removeAvatarFromScene();
- var _s = BillboardStatus.HIDE;
- n.distance < this._maxDistRange && (_s = BillboardStatus.SHOW), this._updateBillboardStatus(n, _s);
- }
- break;
- }
- 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]++;
- }
- return this.curRenderNum() >= this.maxRenderNum() && r.forEach(function (n) {
- if (n.isRender) {
- n._removeAvatarFromScene();
- var _o = BillboardStatus.HIDE;
- n.distance < _this6._maxDistRange && (_o = BillboardStatus.SHOW), _this6._updateBillboardStatus(n, _o);
- }
- }), this.curRenderNum() < this.maxRenderNum();
- }
- }, {
- key: "_updateAvatar",
- value: function _updateAvatar() {
- var _this7 = this;
- this.currentLODUsers = [0, 0, 0];
- var e = [5, 4, 3, 2, 1, 0];
- for (; e.length > 0;) {
- var t = e.pop();
- if (!this._processLayer(t)) {
- e.forEach(function (n) {
- var o;
- (o = _this7.characterMap.get(n)) == null || o.forEach(function (a) {
- a.distance = _this7._distToMain(a);
- var s = BillboardStatus.HIDE;
- a.distToCam < _this7._maxDistRange && (s = BillboardStatus.SHOW, a.isRender && a._removeAvatarFromScene()), _this7._updateBillboardStatus(a, s);
- });
- });
- break;
- }
- }
- }
- }, {
- key: "_updateAvatarStatus",
- value: function _updateAvatarStatus() {
- var _this8 = this;
- var e = new Map();
- this._updateLoopObserver = this.scene.onBeforeRenderObservable.add(function () {
- var t;
- if (_this8._disposeUnusedAssets(), !(_this8.getAvatarNums() <= 0)) {
- if (!_this8._process && _this8._processList.length == 0 && _this8._updateAvatar(), !_this8._process && _this8._processList.length > 0) {
- var r = _this8._processList.shift();
- 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;
- }
- if (e.size === _this8._queueLength && _this8._process) {
- _this8._process.pendingLod && (_this8._process.pendingLod = !1, _this8._process._removeAvatarFromScene());
- var _r = Date.now();
- _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();
- }
- _this8._loadResByList(e);
- }
- });
- }
- }, {
- key: "_loadResByList",
- value: function _loadResByList(e) {
- var _this9 = this;
- var t = 0;
- var r = 5;
- if (!this._process) {
- e.clear();
- return;
- }
- var _loop = function _loop() {
- var n = Date.now(),
- o = _this9._queue.pop();
- setTimeout(function () {
- o ? o.type === avatarSetting.body ? _this9.loadBody(o.type, o.id, o.lod).then(function (a) {
- a && e.set(avatarSetting.body, a), t += Date.now() - n;
- }).catch(function (a) {
- _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);
- }) : o.type === avatarSetting.animations ? _this9.loadAnimation(_this9._process.avatarType, o.id).then(function (a) {
- a && e.set(avatarSetting.animations, a), t += Date.now() - n;
- }).catch(function (a) {
- _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);
- }) : _this9.loadDecoration(o.type, o.id, o.lod).then(function (a) {
- a && e.set(a.type, a), t += Date.now() - n;
- }).catch(function (a) {
- _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);
- }) : t += 100;
- }, 0);
- };
- for (; t < r && this._queue.length > 0;) {
- _loop();
- }
- }
- }, {
- key: "_validateContainer",
- value: function _validateContainer(e) {
- 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;
- }
- }, {
- key: "_getAssetContainer",
- value: function _getAssetContainer(e, t) {
- var _this10 = this;
- return new Promise(function (r, n) {
- var o = _this10._getSourceKey(e, t || 0),
- a = avatarLoader.containers.get(o);
- if (a) return r(a);
- avatarLoader.load(_this10.sceneManager, e, t).then(function (s) {
- 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, ".")));
- }).catch(function (s) {
- return n(new ContainerLoadingFailedError("[Engine] ".concat(s, " :: cannot load body type ").concat(e, ".")));
- });
- });
- }
- }, {
- key: "_clipContainerRes",
- value: function _clipContainerRes(e) {
- e.transformNodes.forEach(function (t) {
- t.dispose();
- }), e.transformNodes = [], e.skeletons.forEach(function (t) {
- t.dispose();
- }), e.skeletons = [];
- }
- }, {
- key: "loadBody",
- value: function loadBody(e, t, r) {
- var _this11 = this;
- return new Promise(function (n, o) {
- return avatarLoader.load(_this11.sceneManager, t, r).then(function (a) {
- if (a) {
- var s = a.instantiateModelsToScene();
- a.xReferenceCount++;
- var l = {
- isRender: !1,
- uId: Math.random(),
- root: s.rootNodes[0],
- skeletonType: e,
- name: t,
- animations: s.animationGroups,
- skeleton: s.skeletons[0],
- lod: r
- };
- return s.rootNodes[0]._parentContainer = a, s.rootNodes[0].setEnabled(!1), n(l);
- } else return o(new ContainerLoadingFailedError("[Engine] container failed instanciates failed"));
- }).catch(function () {
- return o(new ContainerLoadingFailedError("[Engine] body type ".concat(e, " instanciates failed")));
- });
- });
- }
- }, {
- key: "updateAnimationLists",
- value: function updateAnimationLists(e, t) {
- return new Promise(function (r, n) {
- return avatarLoader.avaliableAnimation.set(t, e), r();
- });
- }
- }, {
- key: "loadAnimation",
- value: function loadAnimation(e, t) {
- var _this12 = this;
- return new Promise(function (r, n) {
- return avatarLoader.loadAnimRes(_this12.sceneManager, t, e).then(function (o) {
- if (o) {
- var a;
- var s = _this12.avatarLoader.animations;
- return o.animationGroups.forEach(function (l) {
- l.stop(), l.name === t && (a = l, a.pContainer = o), s.set(getAnimationKey(l.name, e), l);
- }), _this12._clipContainerRes(o), o.xReferenceCount++, r(a);
- } else return n(new ContainerLoadingFailedError("[Engine] container failed instanciates failed"));
- });
- });
- }
- }, {
- key: "loadDecoration",
- value: function loadDecoration(e, t, r) {
- var _this13 = this;
- return new Promise(function (n, o) {
- return avatarLoader.load(_this13.sceneManager, t, r).then(function (a) {
- if (a) {
- _this13._clipContainerRes(a);
- var s = a.meshes[1].clone(a.meshes[1].name, null);
- if (!s) {
- logger$1.warn("[Engine] decoration does not exist!"), n(null);
- return;
- }
- var l = {
- isRender: !1,
- uId: Math.random(),
- root: s,
- type: e,
- name: t,
- isSelected: !1,
- lod: r
- };
- if (a.xReferenceCount++, s._parentContainer = a, a.meshes.length > 1) for (var u = 2; u < a.meshes.length; u++) {
- s.addChild(a.meshes[u].clone(a.meshes[u].name, null));
- }
- s.setEnabled(!1), l.isSelected = !0, n(l);
- } else return o(new ContainerLoadingFailedError("[Engine] container failed, instanciates failed."));
- }).catch(function () {
- return o(new ContainerLoadingFailedError("[Engine] body type ".concat(e, " instanciates failed.")));
- });
- });
- }
- }, {
- key: "_getSourceKey",
- value: function _getSourceKey(e, t) {
- return t && avatarSetting.lod[t] ? e + avatarSetting.lod[t].fileName.split(".")[0] : e;
- }
- }, {
- key: "addAvatarToScene",
- value: function addAvatarToScene(e, t) {
- var _this14 = this;
- var r = Date.now();
- return new Promise(function (n, o) {
- _this14.loadBody(e.avatarType, e.avatarType, t).then(function (a) {
- var s;
- if (!a) return e.isInLoadingList = !1, o(new ContainerLoadingFailedError("[Engine] avatar ".concat(e.id, " instanciates failed")));
- if (e.attachBody(a), a.animations.length > 0) return a.animations.forEach(function (l) {
- l.stop();
- }), 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);
- _this14.loadAnimation(e.avatarType, _this14._defaultAnims).then(function (l) {
- if (!l) return e.removeAvatarFromScene(), e.isInLoadingList = !1, o(new AvatarAnimationError());
- var u = [];
- e.clothesList.length > 0 && e.clothesList.forEach(function (c) {
- u.push(_this14.loadDecoration(c.type, c.id, t));
- }), Promise.all(u).then(function (c) {
- var d, _, g, m;
- c.forEach(function (v) {
- if (v && !v.isRender) e.attachDecoration(v);else return e.isInLoadingList = !1, e.removeAvatarFromScene(), o(new AvatarAssetLoadingError());
- }), e.isRender = !0, (d = e.controller) == null || d.playAnimation(e.controller.onPlay, e.controller.loop), e.setAvatarVisible(!0);
- var h = avatarLoader.mshPath.get("meshes/ygb.glb"),
- f = avatarLoader.matPath.get(avatarResources.ygb.mesh);
- h && f ? _this14.loadExtra(f, h).then(function (v) {
- var y;
- e.isRender = !0, e.isInLoadingList = !1, e.distLevel = t, (y = _this14._sceneManager) == null || y.engineRunTimeStats.timeArray_addAvatarToScene.add(Date.now() - r), n(e);
- }) : (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);
- }).catch(function () {
- return o(new AvatarAssetLoadingError("[Engine] avatar ".concat(e.id, " instanciates failed.")));
- });
- }).catch(function () {
- return o(new AvatarAssetLoadingError("[Engine] avatar ".concat(e.id, " instanciates failed.")));
- });
- }).catch(function () {
- return o(new AvatarAssetLoadingError("[Engine] avatar ".concat(e.id, " instanciates failed.")));
- });
- });
- }
- }, {
- key: "loadExtra",
- value: function loadExtra(e, t) {
- var _this15 = this;
- var r = avatarResources.ygb.name;
- return new Promise(function (n, o) {
- var a;
- (a = _this15.sceneManager) == null || a.urlTransformer(e).then(function (s) {
- BABYLON.SceneLoader.LoadAssetContainerAsync("", s, _this15.scene, null, avatarSetting.fileType).then(function (l) {
- var c;
- _this15.extraComps.set(r, l.meshes[0]);
- var u = new NodeMaterial("material_".concat(r), _this15._scene, {
- emitComments: !1
- });
- (c = _this15.sceneManager) == null || c.urlTransformer(t).then(function (h) {
- u.loadAsync(h).then(function () {
- l.meshes[2].material.dispose(!0, !0), u.build(!1), l.meshes[2].material = u, n(l.meshes[2]);
- });
- });
- });
- });
- });
- }
- }, {
- key: "getAvatarList",
- value: function getAvatarList() {
- var e = [];
- return this.characterMap.forEach(function (t, r) {
- t.forEach(function (n, o) {
- e.push(n);
- });
- }), e;
- }
- }, {
- key: "_debug_avatar",
- value: function _debug_avatar() {
- var t, r;
- 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);
- var e = 0;
- this.getAvatarList().forEach(function (n) {
- 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++);
- }), console.error("========= avatar num", e), console.error("loop:", this._updateLoopObserver ? "on" : "false", "=> process", this._process, "===> comp", this._processList), console.error("===>maxLODUsers", this._maxLODUsers);
- }
- }]);
- return XAvatarManager;
- }();
- var texRootDir = "https://app-asset-1258211750.file.myqcloud.com/1/textures/";
- var XBillboardManager = /*#__PURE__*/function () {
- function XBillboardManager(e) {
- var _this = this;
- _classCallCheck(this, XBillboardManager);
- E(this, "billboardMap", new Map());
- E(this, "sceneManager");
- E(this, "billboardPool");
- E(this, "userBackGroundBlob", new Array());
- E(this, "npcBackGroundBlob", new Array());
- E(this, "tickObserver");
- E(this, "tickInterval");
- E(this, "_updateLoopObserver");
- this.sceneManager = e, this.billboardPool = new Pool(this.createBillboardAsset, this.resetBillboardAsset, 0, 60, this.sceneManager.Scene, !1), this.tickInterval = 250;
- var t = 0;
- this.tickObserver = this.sceneManager.Scene.onAfterRenderObservable.add(function () {
- t += 1, t == _this.tickInterval && (_this.tick(), t = 0);
- }), this.launchBillboardStatusLoop();
- }
- _createClass(XBillboardManager, [{
- key: "tick",
- value: function tick() {
- this.billboardPool.clean(0, this.sceneManager.Scene, !1);
- }
- }, {
- key: "createBillboardAsset",
- value: function createBillboardAsset(e) {
- var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
- var r = BABYLON.MeshBuilder.CreatePlane("billboard-", {
- height: .001,
- width: .001,
- sideOrientation: BABYLON.Mesh.DOUBLESIDE
- }, e);
- r.isPickable = !0, r.setEnabled(!1);
- var n = new BABYLON.DynamicTexture("billboard-tex-", {
- width: .001 + 1,
- height: .001 + 1
- }, e, t, BABYLON.Texture.BILINEAR_SAMPLINGMODE);
- n.hasAlpha = !0;
- var o = new BABYLON.StandardMaterial("billboard-mat-", e);
- 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;
- }
- }, {
- key: "resetBillboardAsset",
- value: function resetBillboardAsset(e) {
- var t = e.data;
- return t.setEnabled(!1), t.isPickable = !1, e;
- }
- }, {
- key: "loadBackGroundTexToIDB",
- value: function () {
- var _loadBackGroundTexToIDB = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
- var _this2 = this;
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- XBillboardManager.userBubbleUrls.forEach(function (r) {
- _this2.sceneManager.urlTransformer(r).then(function (n) {
- _this2.userBackGroundBlob.push(n);
- });
- }), XBillboardManager.npcBubbleUrls.forEach(function (r) {
- _this2.sceneManager.urlTransformer(r).then(function (n) {
- _this2.npcBackGroundBlob.push(n);
- });
- });
- case 1:
- case "end":
- return _context.stop();
- }
- }
- }, _callee);
- }));
- function loadBackGroundTexToIDB() {
- return _loadBackGroundTexToIDB.apply(this, arguments);
- }
- return loadBackGroundTexToIDB;
- }()
- }, {
- key: "addBillboardToMap",
- value: function addBillboardToMap(e, t) {
- this.billboardMap.set(e, t);
- }
- }, {
- key: "addBillboard",
- value: function addBillboard(e, t, r) {
- var n = this.getBillboard(e);
- return n || (n = new XBillboard(this, t, r), this.addBillboardToMap(e, n)), n;
- }
- }, {
- key: "generateStaticBillboard",
- value: function generateStaticBillboard(e, _ref) {
- var _ref$id = _ref.id,
- t = _ref$id === void 0 ? "billboard" : _ref$id,
- r = _ref.isUser,
- n = _ref.background,
- _ref$font = _ref.font,
- o = _ref$font === void 0 ? "Arial" : _ref$font,
- _ref$fontsize = _ref.fontsize,
- a = _ref$fontsize === void 0 ? 40 : _ref$fontsize,
- _ref$fontcolor = _ref.fontcolor,
- s = _ref$fontcolor === void 0 ? "#ffffff" : _ref$fontcolor,
- _ref$fontstyle = _ref.fontstyle,
- l = _ref$fontstyle === void 0 ? "600" : _ref$fontstyle,
- _ref$linesize = _ref.linesize,
- u = _ref$linesize === void 0 ? 16 : _ref$linesize,
- c = _ref.linelimit,
- _ref$scale = _ref.scale,
- h = _ref$scale === void 0 ? 1 : _ref$scale,
- _ref$width = _ref.width,
- f = _ref$width === void 0 ? .01 : _ref$width,
- _ref$height = _ref.height,
- d = _ref$height === void 0 ? .01 : _ref$height,
- _ref$position = _ref.position,
- _ = _ref$position === void 0 ? {
- x: 0,
- y: 0,
- z: 0
- } : _ref$position;
- var g = this.addBillboard(t, !1, !0);
- g.getMesh() == null && g.init(t, f, d);
- var m;
- r != null && (m = r ? XBillboardManager.userBubbleUrls : XBillboardManager.npcBubbleUrls), g && g.getMesh() && (g.DEFAULT_CONFIGS = {
- id: t,
- isUser: r,
- background: n,
- font: o,
- fontsize: a,
- fontcolor: s,
- fontstyle: l,
- linesize: u,
- linelimit: c,
- scale: h,
- width: f,
- height: d,
- position: _
- }, g.drawBillboard({
- imageList: n || m
- }, {
- texts: e,
- font: o,
- fontsize: a,
- fontcolor: s,
- fontstyle: l,
- linesize: u,
- linelimit: c
- }, {
- position: _,
- scale: h
- }), t && g.setId(t), g.setStatus(BillboardStatus.SHOW));
- }
- }, {
- key: "getBillboard",
- value: function getBillboard(e) {
- return this.billboardMap.get(e);
- }
- }, {
- key: "toggle",
- value: function toggle(e, t) {
- var r;
- (r = this.getBillboard(e)) == null || r.setStatus(t ? BillboardStatus.SHOW : BillboardStatus.HIDE);
- }
- }, {
- key: "removeBillboard",
- value: function removeBillboard(e) {
- var t = this.getBillboard(e);
- t && (t.setStatus(BillboardStatus.DISPOSE), this.billboardMap.delete(e));
- }
- }, {
- key: "launchBillboardStatusLoop",
- value: function launchBillboardStatusLoop() {
- var _this3 = this;
- this._updateLoopObserver = this.sceneManager.Scene.onBeforeRenderObservable.add(function () {
- _this3.billboardMap.size <= 0 || _this3.billboardMap.forEach(function (e) {
- e.stageChanged && (e.status == BillboardStatus.SHOW ? e.show() : e.status == BillboardStatus.HIDE ? e.hide() : (e.hide(), e.dispose()), e.stageChanged = !1);
- });
- });
- }
- }]);
- return XBillboardManager;
- }();
- E(XBillboardManager, "alphaWidthMap", new Map()), E(XBillboardManager, "userBubbleUrls", [texRootDir + "bubble01.png", texRootDir + "bubble02.png", texRootDir + "bubble03.png"]), E(XBillboardManager, "npcBubbleUrls", [texRootDir + "bubble01_npc.png", texRootDir + "bubble02_npc.png", texRootDir + "bubble03_npc.png"]);
- var XLightManager = /*#__PURE__*/function () {
- function XLightManager(e) {
- _classCallCheck(this, XLightManager);
- E(this, "_scene");
- E(this, "_envTexture");
- E(this, "_shadowLight");
- E(this, "_shadowGenerator");
- E(this, "_avatarShadowMeshMap");
- E(this, "_cullingShadowObservers");
- E(this, "sceneManager");
- this.sceneManager = e, this._scene = this.sceneManager.Scene, this._envTexture = null, this.shadowLean = .1;
- var t = new BABYLON.Vector3(this.shadowLean, -1, 0),
- r = 1024;
- 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();
- }
- _createClass(XLightManager, [{
- key: "shadowLean",
- set: function set(e) {
- e = Math.min(e, 1), e = Math.max(e, -1), this._shadowLight && (this._shadowLight.direction = new BABYLON.Vector3(e, -1, 0));
- }
- }, {
- key: "setIBL",
- value: function setIBL(e) {
- var _this = this;
- return new Promise(function (t, r) {
- _this.sceneManager.urlTransformer(e).then(function (n) {
- var o;
- if (n == ((o = _this._envTexture) == null ? void 0 : o.url)) return t("env set success");
- _this._envTexture != null && _this.disposeIBL(), _this._envTexture = BABYLON.CubeTexture.CreateFromPrefilteredData(n, _this._scene, ".env"), _this._scene.environmentTexture = _this._envTexture, _this._envTexture.onLoadObservable.addOnce(function () {
- t("env set success"), logger$1.info("env set success");
- });
- }).catch(function () {
- r("env set fail");
- });
- });
- }
- }, {
- key: "disposeIBL",
- value: function disposeIBL() {
- 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"));
- }
- }, {
- key: "removeShadow",
- value: function removeShadow(e) {
- var t;
- if (this._avatarShadowMeshMap.has(e)) {
- this._avatarShadowMeshMap.delete(e), this._cullingShadowObservers.get(e) && (this._scene.onBeforeRenderObservable.remove(this._cullingShadowObservers.get(e)), this._cullingShadowObservers.delete(e));
- var r = e.rootNode;
- r && ((t = this._shadowGenerator) == null || t.removeShadowCaster(r));
- } else return;
- }
- }, {
- key: "setShadow",
- value: function setShadow(e) {
- if (this._avatarShadowMeshMap.has(e)) return;
- e.rootNode && this._avatarShadowMeshMap.set(e, e.rootNode.getChildMeshes());
- var t = 20,
- r = 10,
- n = this.cullingShadow(t, r, e);
- this._cullingShadowObservers.set(e, n);
- }
- }, {
- key: "cullingShadow",
- value: function cullingShadow(e, t, r) {
- var _this2 = this;
- var n = 0;
- var o = function o() {
- var s, l;
- if (n == t) {
- var u = _this2._avatarShadowMeshMap.get(r),
- c = (s = r.rootNode) == null ? void 0 : s.getChildMeshes(),
- h = _this2._scene.activeCamera;
- u == null || u.forEach(function (f) {
- var d;
- (d = _this2._shadowGenerator) == null || d.removeShadowCaster(f, !1);
- }), c == null || c.forEach(function (f) {
- var d;
- (d = _this2._shadowGenerator) == null || d.addShadowCaster(f, !1);
- }), h && r.rootNode && ((l = r.rootNode.position) == null ? void 0 : l.subtract(h.position).length()) > e && (c == null || c.forEach(function (f) {
- var d;
- (d = _this2._shadowGenerator) == null || d.removeShadowCaster(f, !1);
- })), c && _this2._avatarShadowMeshMap.set(r, c), n = 0;
- } else n += 1;
- };
- return this._scene.onBeforeRenderObservable.add(o);
- }
- }, {
- key: "attachLightToCamera",
- value: function attachLightToCamera(e) {
- var _this3 = this;
- var t = e,
- r = 15,
- n = function n() {
- var o = _this3._scene.activeCamera;
- if (o) {
- var a = t.direction,
- s = new BABYLON.Vector3(r * a.x, r * a.y, r * a.z),
- l = o.position;
- t.position = l.subtract(s);
- }
- };
- return t && this._scene.registerBeforeRender(n), n;
- }
- }]);
- return XLightManager;
- }();
- var RunTimeArray = /*#__PURE__*/function () {
- function RunTimeArray() {
- _classCallCheck(this, RunTimeArray);
- E(this, "circularData");
- this.circularData = [];
- }
- _createClass(RunTimeArray, [{
- key: "add",
- value: function add(e) {
- this.circularData.length > 1e3 && this.circularData.shift(), this.circularData.push(e);
- }
- }, {
- key: "getAvg",
- value: function getAvg() {
- var e = 0;
- for (var t = 0; t < this.circularData.length; t++) {
- e += this.circularData[t];
- }
- return {
- sum: e,
- avg: e / this.circularData.length || 0
- };
- }
- }, {
- key: "getMax",
- value: function getMax() {
- var e = 0;
- for (var t = 0; t < this.circularData.length; t++) {
- e < this.circularData[t] && (e = this.circularData[t]);
- }
- return e || 0;
- }
- }, {
- key: "clear",
- value: function clear() {
- this.circularData = [];
- }
- }, {
- key: "getStat",
- value: function getStat() {
- var e = this.getAvg(),
- t = {
- sum: e.sum,
- avg: e.avg,
- max: this.getMax()
- };
- return this.clear(), t;
- }
- }]);
- return RunTimeArray;
- }();
- var XEngineRunTimeStats = /*#__PURE__*/_createClass(function XEngineRunTimeStats() {
- _classCallCheck(this, XEngineRunTimeStats);
- E(this, "timeArray_loadStaticMesh", new RunTimeArray());
- E(this, "timeArray_updateStaticMesh", new RunTimeArray());
- E(this, "timeArray_addAvatarToScene", new RunTimeArray());
- });
- 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; } } }; }
- 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); }
- 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; }
- var getAlphaWidthMap = function getAlphaWidthMap(i, e) {
- var t = new BABYLON.DynamicTexture("test", 3, e),
- r = new Map();
- for (var n = 32; n < 127; n++) {
- var o = String.fromCodePoint(n),
- a = 2 + "px " + i;
- t.drawText(o, null, null, a, "#000000", "#ffffff", !0);
- var s = t.getContext();
- s.font = a;
- var l = s.measureText(o).width;
- r.set(n, l);
- }
- return t.dispose(), r;
- };
- var XSceneManager = /*#__PURE__*/function () {
- function XSceneManager(e, t) {
- var _this = this;
- _classCallCheck(this, XSceneManager);
- E(this, "scene");
- E(this, "engine");
- E(this, "canvas");
- E(this, "gl");
- E(this, "_yuvInfo");
- E(this, "cameraParam");
- E(this, "shaderMode");
- E(this, "panoInfo");
- E(this, "_initEngineScaleNumber");
- E(this, "_forceKeepVertical", !1);
- E(this, "_currentShader");
- E(this, "_currentPanoId");
- E(this, "_renderStatusCheckCount", 0);
- E(this, "_renderStatusNotChecktCount", 0);
- E(this, "_nonlinearCanvasResize", !1);
- E(this, "_bChangeEngineSize", !0);
- E(this, "_cameraManager");
- E(this, "_lowpolyManager");
- E(this, "_materialManager");
- E(this, "_statisticManager");
- E(this, "_breathPointManager");
- E(this, "_skytv");
- E(this, "_mv", []);
- E(this, "_decalManager");
- E(this, "_lightManager");
- E(this, "_avatarManager");
- E(this, "urlTransformer");
- E(this, "_billboardManager");
- E(this, "_backgroundImg");
- E(this, "engineRunTimeStats");
- E(this, "uploadHardwareSystemInfo", function () {
- var e = _this.statisticComponent.getHardwareRenderInfo(),
- t = _this.statisticComponent.getSystemInfo(),
- r = {
- driver: t.driver,
- vender: t.vender,
- webgl: t.version,
- os: t.os
- };
- logger$1.warn(JSON.stringify(e)), logger$1.warn(JSON.stringify(r));
- });
- E(this, "addNewLowPolyMesh", /*#__PURE__*/function () {
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e, t) {
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- _context.t0 = _this._currentShader == null;
- if (!_context.t0) {
- _context.next = 4;
- break;
- }
- _context.next = 4;
- return _this.initSceneManager();
- case 4:
- return _context.abrupt("return", _this._lowpolyManager.addNewLowPolyMesh(e, t, _this._currentShader));
- case 5:
- case "end":
- return _context.stop();
- }
- }
- }, _callee);
- }));
- return function (_x, _x2) {
- return _ref.apply(this, arguments);
- };
- }());
- E(this, "initSceneManager", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
- return regenerator.wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- _context2.next = 2;
- return _this._materialManager.initMaterial();
- case 2:
- return _context2.abrupt("return", _this.applyShader());
- case 3:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2);
- })));
- E(this, "registerAfterRender", function () {
- var e;
- if (_this._forceKeepVertical) {
- var _t = _this.canvas.width,
- _r = _this.canvas.height;
- var _n = 0,
- _o = [[0, 0, 0, 0], [0, 0, 0, 0]];
- 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) {
- _this.gl.enable(_this.gl.SCISSOR_TEST);
- for (var a = 0; a < _o.length; ++a) {
- _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);
- }
- _this.gl.disable(_this.gl.SCISSOR_TEST);
- }
- }
- });
- E(this, "resetRender", function () {
- _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));
- });
- var r = /iphone|ipad/gi.test(window.navigator.userAgent) || t.disableWebGL2,
- n = new BABYLON.Engine(e, !0, {
- preserveDrawingBuffer: !0,
- stencil: !0,
- disableWebGL2Support: r
- }, !0),
- o = new BABYLON.Scene(n);
- 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) {
- return Promise.resolve(s);
- }, t.logger && Logger1.setLogger(t.logger), this.gl = e.getContext("webgl2", {
- preserveDrawingBuffer: !0
- }) || e.getContext("webgl", {
- preserveDrawingBuffer: !0
- }) || e.getContext("experimental-webgl", {
- preserveDrawingBuffer: !0
- }), 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 = {
- width: t.videoResOriArray[0].width,
- height: t.videoResOriArray[0].height,
- fov: 50
- }, t.cameraParam != null && (this.cameraParam = t.cameraParam), t.nonlinearCanvasResize != null && (this._nonlinearCanvasResize = t.nonlinearCanvasResize), this._cameraManager = new XCameraComponent(this.canvas, this.scene, {
- cameraParam: this.cameraParam,
- yuvInfo: this._yuvInfo,
- forceKeepVertical: this._forceKeepVertical
- }), this._lowpolyManager = new XStaticMeshComponent(this), this._materialManager = new XMaterialComponent(this, {
- videoResOriArray: t.videoResOriArray,
- yuvInfo: this._yuvInfo,
- panoInfo: this.panoInfo,
- shaderMode: this.shaderMode
- }), this._statisticManager = new XStats(this), this._breathPointManager = new XBreathPointManager(this), this._decalManager = new XDecalManager(this), this._avatarManager = new XAvatarManager(this), this._billboardManager = new XBillboardManager(this), this.billboardComponent.loadBackGroundTexToIDB(), this._lightManager = new XLightManager(this), this.postprocessing(), this.initSceneManager(), this.engineRunTimeStats = new XEngineRunTimeStats(), /iphone/gi.test(window.navigator.userAgent) && window.devicePixelRatio && window.devicePixelRatio === 3 && window.screen.width === 375 && window.screen.height === 812 ? this.engine.setHardwareScalingLevel(this._initEngineScaleNumber * 2) : this.engine.setHardwareScalingLevel(this._initEngineScaleNumber * 1.8), this.scene.registerBeforeRender(function () {
- _this._nonlinearCanvasResize && _this._bChangeEngineSize && (_this.setEngineSize(_this._yuvInfo), _this._bChangeEngineSize = !1);
- }), this.scene.registerAfterRender(function () {
- _this._nonlinearCanvasResize || _this.registerAfterRender();
- }), window.addEventListener("resize", function () {
- _this._nonlinearCanvasResize ? _this._bChangeEngineSize = !0 : _this.engine.resize();
- }), XBillboardManager.alphaWidthMap = getAlphaWidthMap("Arial", this.scene), this.uploadHardwareSystemInfo();
- }
- _createClass(XSceneManager, [{
- key: "yuvInfo",
- get: function get() {
- return this.getCurrentShaderMode() == 1 ? this._yuvInfo : {
- width: -1,
- height: -1,
- fov: -1
- };
- },
- set: function set(e) {
- this.getCurrentShaderMode() == 1 && (this._yuvInfo = e, this._cameraManager.cameraFovChange(e));
- }
- }, {
- key: "mainScene",
- get: function get() {
- return this.scene;
- }
- }, {
- key: "cameraComponent",
- get: function get() {
- return this._cameraManager;
- }
- }, {
- key: "staticmeshComponent",
- get: function get() {
- return this._lowpolyManager;
- }
- }, {
- key: "materialComponent",
- get: function get() {
- return this._materialManager;
- }
- }, {
- key: "statisticComponent",
- get: function get() {
- return this._statisticManager;
- }
- }, {
- key: "avatarComponent",
- get: function get() {
- return this._avatarManager;
- }
- }, {
- key: "lightComponent",
- get: function get() {
- return this._lightManager;
- }
- }, {
- key: "Engine",
- get: function get() {
- return this.engine;
- }
- }, {
- key: "Scene",
- get: function get() {
- return this.scene;
- }
- }, {
- key: "billboardComponent",
- get: function get() {
- return this._billboardManager;
- }
- }, {
- key: "breathPointComponent",
- get: function get() {
- return this._breathPointManager;
- }
- }, {
- key: "skytvComponent",
- get: function get() {
- return this._skytv;
- }
- }, {
- key: "mvComponent",
- get: function get() {
- return this._mv;
- }
- }, {
- key: "decalComponent",
- get: function get() {
- return this._decalManager;
- }
- }, {
- key: "currentShader",
- get: function get() {
- return this._currentShader;
- }
- }, {
- key: "initEngineScaleNumber",
- get: function get() {
- return this._initEngineScaleNumber;
- }
- }, {
- key: "setImageQuality",
- value: function setImageQuality(e) {
- 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 + "]"));
- }
- }, {
- key: "setNonlinearCanvasResize",
- value: function setNonlinearCanvasResize(e) {
- this._nonlinearCanvasResize = e, this._bChangeEngineSize = e, e || this.engine.resize();
- }
- }, {
- key: "setBackgroundColor",
- value: function setBackgroundColor(e) {
- this.scene.clearColor = new Color4(e.r, e.g, e.b, e.a);
- }
- }, {
- key: "setBackgroundImg",
- value: function setBackgroundImg(e) {
- var _this2 = this;
- return this._backgroundImg != null && this._backgroundImg.url == e ? Promise.resolve(!0) : new Promise(function (t, r) {
- _this2.urlTransformer(e).then(function (n) {
- _this2._backgroundImg == null ? _this2._backgroundImg = {
- layer: new Layer("tex_background_" + Date.now(), n, _this2.Scene, !0),
- url: e
- } : _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);
- }).catch(function (n) {
- logger$1.error("[Engine] set background image Error: ".concat(n)), r("[Engine] set background image Error: ".concat(n));
- });
- });
- }
- }, {
- key: "cleanTheWholeScene",
- value: function cleanTheWholeScene() {
- var _this3 = this;
- var e = this.scene.getFrameId();
- this.scene.onBeforeRenderObservable.clear(), this.scene.onAfterRenderObservable.clear(), this.scene.clearCachedVertexData(), this.scene.cleanCachedTextureBuffer(), this.scene.registerBeforeRender(function () {
- _this3.scene.getFrameId() - e > 5 && _this3.scene.dispose();
- });
- }
- }, {
- key: "getAreaAvatar",
- value: function getAreaAvatar(e, t) {
- var r = [];
- return this._avatarManager.getAvatarList().forEach(function (n) {
- var o = e,
- a = n.position;
- a && o && calcDistance3D(o, a) < t && r.push(n.id);
- }), r;
- }
- }, {
- key: "setEngineSize",
- value: function setEngineSize(e) {
- var t = e.width,
- r = e.height,
- n = this.canvas.width;
- this.canvas.height, this.engine.setSize(Math.round(n), Math.round(n * (r / t)));
- }
- }, {
- key: "getCurrentShaderMode",
- value: function getCurrentShaderMode() {
- return this._currentShader === this._materialManager.getDefaultShader() ? 0 : this._currentShader === this._materialManager.getPureVideoShader() ? 1 : 2;
- }
- }, {
- key: "addSkyTV",
- value: function addSkyTV(e, t) {
- return this._skytv = new XTelevision(this.scene, e, this, t), this._skytv;
- }
- }, {
- key: "addMv",
- value: function addMv(e, t) {
- this._mv.push(new XTelevision(this.scene, e, this, t));
- }
- }, {
- key: "addMeshInfo",
- value: function addMeshInfo(e) {
- this._lowpolyManager.setMeshInfo(e);
- }
- }, {
- key: "applyShader",
- value: function applyShader() {
- var _this4 = this;
- return new Promise(function (e, t) {
- _this4.shaderMode == EShaderMode.videoAndPano || _this4.shaderMode == EShaderMode.video ? _this4.changeVideoShaderForLowModel() : _this4.shaderMode == EShaderMode.default && _this4.changeDefaultShaderForLowModel(), e(!0);
- });
- }
- }, {
- key: "changeHardwareScaling",
- value: function changeHardwareScaling(e) {
- e < 1 ? e = 1 : e > 2.5 && (e = 2.5), this._bChangeEngineSize = !0, this.engine.setHardwareScalingLevel(this._initEngineScaleNumber * e);
- }
- }, {
- key: "getCurrentUsedPanoId",
- value: function getCurrentUsedPanoId() {
- return this._currentPanoId;
- }
- }, {
- key: "render",
- value: function render() {
- try {
- this.scene.render();
- } catch (e) {
- throw logger$1.error("[Engine] Render Error: ".concat(e)), e;
- }
- }
- }, {
- key: "isReadyToRender",
- value: function isReadyToRender(e) {
- var _e$checkMesh = e.checkMesh,
- t = _e$checkMesh === void 0 ? !0 : _e$checkMesh,
- _e$checkEffect = e.checkEffect,
- r = _e$checkEffect === void 0 ? !1 : _e$checkEffect,
- _e$checkPostProgress = e.checkPostProgress,
- n = _e$checkPostProgress === void 0 ? !1 : _e$checkPostProgress,
- _e$checkParticle = e.checkParticle,
- o = _e$checkParticle === void 0 ? !1 : _e$checkParticle,
- _e$checkAnimation = e.checkAnimation,
- a = _e$checkAnimation === void 0 ? !1 : _e$checkAnimation;
- e.materialNameWhiteLists;
- if (this.scene._isDisposed) return logger$1.error("[Engine] this.scene._isDisposed== false "), !1;
- var l;
- var u = this.scene.getEngine();
- if (r && !u.areAllEffectsReady()) return logger$1.error("[Engine] engine.areAllEffectsReady == false"), !1;
- if (a && this.scene._pendingData.length > 0) return logger$1.error("[Engine] scene._pendingData.length > 0 && animation error"), !1;
- if (t) {
- for (l = 0; l < this.scene.meshes.length; l++) {
- var c = this.scene.meshes[l];
- 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;
- 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;
- var h = c.hasThinInstances || c.getClassName() === "InstancedMesh" || c.getClassName() === "InstancedLinesMesh" || u.getCaps().instancedArrays && c.instances.length > 0;
- var _iterator = _createForOfIteratorHelper(this.scene._isReadyForMeshStage),
- _step;
- try {
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
- var f = _step.value;
- 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;
- }
- } catch (err) {
- _iterator.e(err);
- } finally {
- _iterator.f();
- }
- }
- for (l = 0; l < this.scene.geometries.length; l++) {
- if (this.scene.geometries[l].delayLoadState === 2) return logger$1.error("[Engine] geometry.delayLoadState === 2"), !1;
- }
- }
- if (n) {
- if (this.scene.activeCameras && this.scene.activeCameras.length > 0) {
- var _iterator2 = _createForOfIteratorHelper(this.scene.activeCameras),
- _step2;
- try {
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
- var _c = _step2.value;
- if (!_c.isReady(!0)) return logger$1.error("[Engine] camera not ready === false, ", _c.name), !1;
- }
- } catch (err) {
- _iterator2.e(err);
- } finally {
- _iterator2.f();
- }
- } else if (this.scene.activeCamera && !this.scene.activeCamera.isReady(!0)) return logger$1.error("[Engine] activeCamera ready === false, ", this.scene.activeCamera.name), !1;
- }
- if (o) {
- var _iterator3 = _createForOfIteratorHelper(this.scene.particleSystems),
- _step3;
- try {
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
- var _c2 = _step3.value;
- if (!_c2.isReady()) return logger$1.error("[Engine] particleSystem ready === false, ", _c2.name), !1;
- }
- } catch (err) {
- _iterator3.e(err);
- } finally {
- _iterator3.f();
- }
- }
- return !0;
- }
- }, {
- key: "changePanoShaderForLowModel",
- value: function changePanoShaderForLowModel(e) {
- var _this5 = this;
- return logger$1.info("[Engine] changePanoShaderForLowModel: ".concat(e)), this._materialManager.allowYUVUpdate(), new Promise(function (t, r) {
- _this5._materialManager._isInDynamicRange(e) == !1 && r(!1), _this5._currentPanoId = e, _this5._currentShader = _this5._materialManager.getDynamicShader(e), _this5.changeShaderForLowModel().then(function () {
- t(!0);
- });
- });
- }
- }, {
- key: "changeVideoShaderForLowModel",
- value: function changeVideoShaderForLowModel() {
- return logger$1.info("[Engine] changeVideoShaderForLowModel"), this._currentShader = this._materialManager.getPureVideoShader(), this._materialManager.allowYUVUpdate(), this.changeShaderForLowModel();
- }
- }, {
- key: "changeDefaultShaderForLowModel",
- value: function changeDefaultShaderForLowModel() {
- return logger$1.info("[Engine] changeDefaultShaderForLowModel"), this._currentShader = this._materialManager.getDefaultShader(), this._materialManager.stopYUVUpdate(), this.changeShaderForLowModel();
- }
- }, {
- key: "changeShaderForLowModel",
- value: function changeShaderForLowModel() {
- var _this6 = this;
- return new Promise(function (e, t) {
- _this6._lowpolyManager.getMeshes().forEach(function (r) {
- r.setMaterial(_this6._currentShader);
- }), _this6._lowpolyManager.getCgMesh().mesh.material = _this6._currentShader, e(!0);
- });
- }
- }, {
- key: "setIBL",
- value: function setIBL(e) {
- this._lightManager.setIBL(e);
- }
- }, {
- key: "postprocessing",
- value: function postprocessing() {
- var e = new BABYLON.DefaultRenderingPipeline("default", !0, this.scene);
- e.imageProcessingEnabled = !1, e.bloomEnabled = !0, e.bloomThreshold = 1, e.bloomWeight = 1, e.bloomKernel = 64, e.bloomScale = .1;
- }
- }, {
- key: "getGround",
- value: function getGround(e) {
- var t = this._lowpolyManager.getMeshes(),
- r = [];
- return t.forEach(function (n) {
- n.mesh.name.indexOf("SM_Stage") >= 0 && r.push(n.mesh);
- }), this.Scene.meshes.forEach(function (n) {
- n.name.split("_")[0] === "ground" && r.push(n);
- }), r;
- }
- }]);
- return XSceneManager;
- }();
- var http = new Http();
- var urlMap = new Map(),
- urlTransformer = /*#__PURE__*/function () {
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(i) {
- var e,
- _args2 = arguments;
- return regenerator.wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- e = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : !1;
- return _context2.abrupt("return", typeof i != "string" ? (console.warn("url transformer error", i), i) : i.startsWith("blob:") ? i : e ? http.get({
- url: i,
- useIndexedDb: !0,
- key: "url",
- isOutPutObjectURL: !1
- }) : urlMap.has(i) ? urlMap.get(i) : http.get({
- url: i,
- useIndexedDb: !0,
- key: "url"
- }).then(function (t) {
- return urlMap.set(i, t), t;
- }));
- case 2:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2);
- }));
- return function urlTransformer(_x2) {
- return _ref2.apply(this, arguments);
- };
- }();
- var sceneManager;
- function getSceneManager(i, e) {
- return sceneManager || (sceneManager = new XSceneManager(i, e)), sceneManager;
- }
- var EngineProxy = /*#__PURE__*/function () {
- function EngineProxy(e) {
- var _this = this;
- _classCallCheck(this, EngineProxy);
- E(this, "_tvs", []);
- E(this, "isRenderFirstFrame", !1);
- E(this, "_idleTime", 0);
- E(this, "renderTimer");
- E(this, "lightManager");
- E(this, "_checkSceneNotReadyCount", 0);
- E(this, "_checkSceneDurationFrameNum", 0);
- E(this, "_checkSceneFrameCount", 0);
- E(this, "timeoutCircularArray", new CircularArray(120, !1, []));
- E(this, "frameCircularArray", new CircularArray(120, !1, []));
- E(this, "interFrameCircularArray", new CircularArray(120, !1, []));
- E(this, "drawCallCntCircularArray", new CircularArray(120, !1, []));
- E(this, "activeFacesCircularArray", new CircularArray(120, !1, []));
- E(this, "renderTimeCircularArray", new CircularArray(120, !1, []));
- E(this, "drawCallTimeCircularArray", new CircularArray(120, !1, []));
- E(this, "animationCircularArray", new CircularArray(120, !1, []));
- E(this, "meshSelectCircularArray", new CircularArray(120, !1, []));
- E(this, "renderTargetCircularArray", new CircularArray(120, !1, []));
- E(this, "regBeforeRenderCircularArray", new CircularArray(120, !1, []));
- E(this, "regAfterRenderCircularArray", new CircularArray(120, !1, []));
- E(this, "renderCnt", 0);
- E(this, "renderErrorCount", 0);
- E(this, "engineSloppyCnt", 0);
- E(this, "systemStuckCnt", 0);
- E(this, "frameRenderNumber", 0);
- E(this, "_setFPS", function (e) {
- var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 25;
- logger$1.info("Set fps to", t);
- var r = t > 60 ? 60 : t < 24 ? 24 : t;
- e.Engine.stopRenderLoop();
- var n = 1e3 / r;
- var o = Date.now(),
- a = Date.now(),
- s = n,
- l = 1;
- var u = function u() {
- var T;
- var c = Date.now(),
- h = c - o,
- f = c - a;
- a = c, _this.frameCircularArray.add(f), h - s > n && (_this.systemStuckCnt += 1);
- var d = h / s;
- l = .9 * l + .1 * d;
- var _ = Date.now();
- var g = 0,
- m = 0;
- if (_this.room.isUpdatedRawYUVData || _this.room.isPano) {
- 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", {
- error: new Error("[SDK] Scene not ready, skip render and reload.")
- })), _this.room.stats.assign({
- renderErrorCount: _this._checkSceneNotReadyCount
- }), logger$1.infoAndReportMeasurement({
- value: 0,
- startTime: Date.now(),
- metric: "renderError",
- error: new Error("[SDK] Scene not ready, skip render and reload."),
- reportOptions: {
- sampleRate: .1
- }
- }));else try {
- e.render();
- } catch (C) {
- _this.renderErrorCount++, _this.renderErrorCount > 10 && _this.room.proxyEvents("renderError", {
- error: C
- }), _this.room.stats.assign({
- renderErrorCount: _this.renderErrorCount
- }), logger$1.infoAndReportMeasurement({
- value: 0,
- startTime: Date.now(),
- metric: "renderError",
- error: C,
- reportOptions: {
- sampleRate: .1
- }
- });
- }
- g = Date.now() - _, _this.frameRenderNumber < 1e3 && _this.frameRenderNumber++, _this.room.networkController.rtcp.workers.UpdateYUV(), m = Date.now() - _ - g;
- }
- _this.isRenderFirstFrame || _this.room.networkController.rtcp.workers.UpdateYUV();
- var y = Date.now() - _;
- o = c + y, s = Math.min(Math.max((n - y) / l, 5), 200), y > n && (s = 10, _this.engineSloppyCnt += 1), _this._idleTime = s;
- var b = s;
- 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) {
- var C = _this.frameCircularArray.getAvg(),
- A = _this.timeoutCircularArray.getAvg(),
- S = _this.frameCircularArray.getMax(),
- P = _this.timeoutCircularArray.getMax();
- (T = _this.room.stats) == null || T.assign({
- avgFrameTime: C,
- avgTimeoutTime: A,
- maxFrameTime: S,
- maxTimeoutTime: P,
- systemStuckCnt: _this.systemStuckCnt
- });
- }
- _this.renderTimer = window.setTimeout(u, s);
- };
- _this.renderTimer = window.setTimeout(u, n / l);
- });
- E(this, "updateStats", function () {
- var e;
- (e = _this.room.stats) == null || e.assign({
- renderFrameTime: _this.renderTimeCircularArray.getAvg(),
- maxRenderFrameTime: _this.renderTimeCircularArray.getMax(),
- interFrameTime: _this.interFrameCircularArray.getAvg(),
- animationTime: _this.animationCircularArray.getAvg(),
- meshSelectTime: _this.meshSelectCircularArray.getAvg(),
- drawcallTime: _this.drawCallTimeCircularArray.getAvg(),
- idleTime: _this._idleTime,
- registerBeforeRenderTime: _this.regBeforeRenderCircularArray.getAvg(),
- registerAfterRenderTime: _this.regAfterRenderCircularArray.getAvg(),
- renderTargetRenderTime: _this.renderTargetCircularArray.getAvg(),
- fps: (1e3 / (_this.renderTimeCircularArray.getAvg() + _this.interFrameCircularArray.getAvg())).toFixed(2),
- drawcall: _this.drawCallCntCircularArray.getAvg(),
- engineSloppyCnt: _this.engineSloppyCnt,
- maxInterFrameTime: _this.interFrameCircularArray.getMax(),
- maxDrawcallTime: _this.drawCallTimeCircularArray.getMax(),
- maxMeshSelectTime: _this.meshSelectCircularArray.getMax(),
- maxAnimationTime: _this.animationCircularArray.getMax(),
- maxRegisterBeforeRenderTime: _this.regBeforeRenderCircularArray.getMax(),
- maxRegisterAfterRenderTime: _this.regAfterRenderCircularArray.getMax(),
- maxRenderTargetRenderTime: _this.renderTargetCircularArray.getMax(),
- avgFrameTime: _this.frameCircularArray.getAvg(),
- avgTimeoutTime: _this.timeoutCircularArray.getAvg(),
- maxFrameTime: _this.frameCircularArray.getMax(),
- maxTimeoutTime: _this.timeoutCircularArray.getMax()
- });
- });
- this.room = e;
- }
- _createClass(EngineProxy, [{
- key: "initEngine",
- value: function () {
- var _initEngine = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
- var t, r, n, o, a;
- return regenerator.wrap(function _callee3$(_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- _context3.next = 2;
- return this.updateBillboard();
- case 2:
- logger$1.info("engine version:", VERSION$1);
- t = logger$1;
- t.setLevel(LoggerLevels$1.Warn);
- r = {
- videoResOriArray: [{
- width: 720,
- height: 1280
- }, {
- width: 1280,
- height: 720
- }, {
- width: 480,
- height: 654
- }, {
- width: 654,
- height: 480
- }, {
- width: 1920,
- height: 1080
- }, {
- width: 1080,
- height: 1920
- }, {
- width: 414,
- height: 896
- }],
- forceKeepVertical: this.room.options.objectFit !== "cover",
- panoInfo: {
- dynamicRange: 1,
- width: 4096,
- height: 2048
- },
- shaderMode: EShaderMode.videoAndPano,
- yuvInfo: {
- width: 1280,
- height: 720,
- fov: e.fov || DEFAULT_MAIN_CAMERA_FOV
- },
- cameraParam: {
- maxZ: 1e4
- },
- urlTransformer,
- logger: t,
- disableWebGL2: this.room.options.disableWebGL2 || !1
- }, n = this.room.options.resolution;
- n && (r.videoResOriArray.some(function (l) {
- return l.width === n.width && l.height === n.height;
- }) || r.videoResOriArray.push(n));
- o = this.room.sceneManager = getSceneManager(this.room.canvas, r);
- this.room.setPictureQualityLevel(this.room.options.pictureQualityLevel || "high");
- this.room.sceneManager.staticmeshComponent.setRegionLodRule([2, 2, -1, -1, -1]);
- this.room.scene = o.Scene;
- this.room.breathPointManager = o.breathPointComponent;
- this.lightManager = o.lightComponent;
- this.registerStats();
- this.setEnv(e);
- _context3.next = 17;
- return this.room.avatarManager.init();
- case 17:
- a = this._createAssetList(e);
- _context3.next = 20;
- return this.loadAssets(a, "");
- case 20:
- this._setFPS(o);
- case 21:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee3, this);
- }));
- function initEngine(_x3) {
- return _initEngine.apply(this, arguments);
- }
- return initEngine;
- }()
- }, {
- key: "pause",
- value: function pause() {
- clearTimeout(this.renderTimer), logger$1.info("Invoke room.pause to pause render");
- var e = {
- roomId: this.room.id,
- effects: [],
- lowPolyModels: [],
- breathPointsConfig: [],
- skinId: this.room.skinId
- };
- return this.loadAssets(e, this.room.skinId);
- }
- }, {
- key: "resume",
- value: function () {
- var _resume = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4() {
- var e;
- return regenerator.wrap(function _callee4$(_context4) {
- while (1) {
- switch (_context4.prev = _context4.next) {
- case 0:
- this._setFPS(this.room.sceneManager), this.room.sceneManager.cameraComponent.cameraFovChange(this.room.sceneManager.yuvInfo), logger$1.info("Invoke room.resume to render");
- e = this._createAssetList(this.room.skin);
- _context4.next = 4;
- return this.loadAssets(e, "");
- case 4:
- case "end":
- return _context4.stop();
- }
- }
- }, _callee4, this);
- }));
- function resume() {
- return _resume.apply(this, arguments);
- }
- return resume;
- }()
- }, {
- key: "setEnv",
- value: function setEnv(e) {
- var r;
- this.lightManager || (this.lightManager = this.room.sceneManager.lightComponent), e = e || this.room.skin;
- var t = ModelManager.findModel(e.models, AssetTypeName.Config, AssetClassName.Env);
- return t ? (r = this.lightManager) == null ? void 0 : r.setIBL(t.modelUrl) : (logger$1.error("env file not found"), Promise.resolve());
- }
- }, {
- key: "_parseModelsAndLoad",
- value: function () {
- var _parseModelsAndLoad2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(e, t, r) {
- var n, o, a, u, c, h, _c, s, l, _u, _c2, _h;
- return regenerator.wrap(function _callee5$(_context5) {
- while (1) {
- switch (_context5.prev = _context5.next) {
- case 0:
- logger$1.info("Invoke _parseModelsAndLoad start", t);
- n = ["airship", "balloon", "default", "ground_feiting", "ground_reqiqiu"], o = new Map();
- r == null && (r = "xxxx");
- a = !0;
- u = 0;
- case 5:
- if (!(u < e.length)) {
- _context5.next = 20;
- break;
- }
- a = !0;
- c = 0;
- case 8:
- if (!(c < n.length)) {
- _context5.next = 16;
- break;
- }
- if (!(e[u].modelUrl.toLowerCase().indexOf(n[c]) >= 0)) {
- _context5.next = 13;
- break;
- }
- h = o.get(n[c]);
- h ? (h.push(e[u]), o.set(n[c], h)) : o.set(n[c], [e[u]]), a = !1;
- return _context5.abrupt("break", 16);
- case 13:
- ++c;
- _context5.next = 8;
- break;
- case 16:
- if (a) {
- _c = o.get("default");
- _c ? (_c.push(e[u]), o.set("default", _c)) : o.set("default", [e[u]]);
- }
- case 17:
- ++u;
- _context5.next = 5;
- break;
- case 20:
- s = o.get(t) || [];
- if (!(this.room.viewMode === "simple" && (s = s.filter(function (u) {
- return !u.modelUrl.endsWith("zip");
- })), !s)) {
- _context5.next = 23;
- break;
- }
- return _context5.abrupt("return", Promise.reject("no invalid scene model with group name: ".concat(t)));
- case 23:
- l = [];
- for (_u = 0; _u < s.length; ++_u) {
- _c2 = s[_u];
- if (_c2.modelUrl.toLowerCase().endsWith("zip")) _c2.modelUrl.toLowerCase().endsWith("zip") && l.push(this.room.sceneManager.addNewLowPolyMesh({
- url: _c2.modelUrl,
- skinInfo: r
- }));else {
- _h = t;
- l.push(this.room.sceneManager.addNewLowPolyMesh({
- url: _c2.modelUrl,
- group: _h,
- pick: !0,
- skinInfo: r
- }));
- }
- }
- return _context5.abrupt("return", Promise.all(l));
- case 26:
- case "end":
- return _context5.stop();
- }
- }
- }, _callee5, this);
- }));
- function _parseModelsAndLoad(_x4, _x5, _x6) {
- return _parseModelsAndLoad2.apply(this, arguments);
- }
- return _parseModelsAndLoad;
- }()
- }, {
- key: "_deleteAssetsLowpolyModel",
- value: function () {
- var _deleteAssetsLowpolyModel2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e) {
- var t;
- return regenerator.wrap(function _callee6$(_context6) {
- while (1) {
- switch (_context6.prev = _context6.next) {
- case 0:
- this.room.sceneManager.staticmeshComponent.deleteMeshesBySkinInfo(e), this.room.sceneManager.breathPointComponent.clearBreathPointsBySkinInfo(e), this.room.sceneManager.decalComponent.deleteDecalBySkinInfo(e);
- t = [];
- this.room.sceneManager.Scene.meshes.forEach(function (r) {
- r.xskinInfo == e && t.push(r);
- }), t.forEach(function (r) {
- r.dispose(!1, !1);
- });
- case 3:
- case "end":
- return _context6.stop();
- }
- }
- }, _callee6, this);
- }));
- function _deleteAssetsLowpolyModel(_x7) {
- return _deleteAssetsLowpolyModel2.apply(this, arguments);
- }
- return _deleteAssetsLowpolyModel;
- }()
- }, {
- key: "loadLandAssets",
- value: function () {
- var _loadLandAssets = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7() {
- var _this2 = this;
- var e;
- return regenerator.wrap(function _callee7$(_context7) {
- while (1) {
- switch (_context7.prev = _context7.next) {
- case 0:
- e = this._createAssetList(this.room.skin);
- return _context7.abrupt("return", this.loadAssets(e, this.room.skinId).catch(function () {
- return _this2.loadAssets(e, _this2.room.skinId);
- }));
- case 2:
- case "end":
- return _context7.stop();
- }
- }
- }, _callee7, this);
- }));
- function loadLandAssets() {
- return _loadLandAssets.apply(this, arguments);
- }
- return loadLandAssets;
- }()
- }, {
- key: "loadAssets",
- value: function () {
- var _loadAssets2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8(e) {
- var t,
- r,
- n,
- _args8 = arguments;
- return regenerator.wrap(function _callee8$(_context8) {
- while (1) {
- switch (_context8.prev = _context8.next) {
- case 0:
- t = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : "";
- r = _args8.length > 2 && _args8[2] !== undefined ? _args8[2] : 8e3;
- n = Date.now();
- return _context8.abrupt("return", this._loadAssets(e, t)._timeout(r, new InitEngineTimeoutError("loadAssets timeout(".concat(r, "ms)"))).then(function (o) {
- return logger$1.infoAndReportMeasurement({
- tag: "loadAssets",
- startTime: n,
- metric: "loadAssets"
- }), o;
- }).catch(function (o) {
- return logger$1.infoAndReportMeasurement({
- tag: "loadAssets",
- startTime: n,
- metric: "loadAssets",
- error: o
- }), Promise.reject(o);
- }));
- case 4:
- case "end":
- return _context8.stop();
- }
- }
- }, _callee8, this);
- }));
- function loadAssets(_x8) {
- return _loadAssets2.apply(this, arguments);
- }
- return loadAssets;
- }()
- }, {
- key: "_loadAssets",
- value: function () {
- var _loadAssets3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9(e) {
- var t,
- r,
- _args9 = arguments;
- return regenerator.wrap(function _callee9$(_context9) {
- while (1) {
- switch (_context9.prev = _context9.next) {
- case 0:
- t = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : "";
- _context9.prev = 1;
- r = [];
- r.push(this._loadAssetsLowpolyModel(e, t));
- _context9.next = 6;
- return Promise.all(r);
- case 6:
- _context9.next = 8;
- return this.setEnv();
- case 8:
- this._checkSceneDurationFrameNum = EngineProxy._CHECK_DURATION;
- this._checkSceneNotReadyCount = 0;
- this._checkSceneFrameCount = 0;
- this.updateAnimationList();
- this.room.loadAssetsHook();
- _context9.next = 18;
- break;
- case 15:
- _context9.prev = 15;
- _context9.t0 = _context9["catch"](1);
- return _context9.abrupt("return", Promise.reject(_context9.t0));
- case 18:
- case "end":
- return _context9.stop();
- }
- }
- }, _callee9, this, [[1, 15]]);
- }));
- function _loadAssets(_x9) {
- return _loadAssets3.apply(this, arguments);
- }
- return _loadAssets;
- }()
- }, {
- key: "updateAnimationList",
- value: function updateAnimationList() {
- var _this3 = this;
- if (this.room.avatarManager && this.room.avatarManager.xAvatarManager) {
- var e = this.room.skin.animationList;
- if (!e) return;
- e.forEach(function (t) {
- _this3.room.avatarManager.xAvatarManager.updateAnimationLists(t.animations, t.avatarId);
- });
- }
- }
- }, {
- key: "_loadAssetsLowpolyModel",
- value: function () {
- var _loadAssetsLowpolyModel2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee11(e) {
- var _this4 = this;
- var t,
- r,
- n,
- o,
- a,
- s,
- u,
- c,
- h,
- _args11 = arguments;
- return regenerator.wrap(function _callee11$(_context11) {
- while (1) {
- switch (_context11.prev = _context11.next) {
- case 0:
- t = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : "";
- r = [], n = [], o = [];
- e.lowPolyModels.forEach(function (f) {
- f.group === "TV" ? n.push({
- id: "",
- name: "",
- thumbnailUrl: "",
- typeName: AssetTypeName.Model,
- className: AssetClassName.Tv,
- modelUrl: f.url
- }) : f.group === "\u544A\u767D\u5899" ? o.push({
- id: "",
- name: "",
- thumbnailUrl: "",
- typeName: AssetTypeName.Model,
- className: AssetClassName.Lpm,
- modelUrl: f.url
- }) : r.push({
- id: "",
- name: "",
- thumbnailUrl: "",
- typeName: AssetTypeName.Model,
- className: AssetClassName.Lpm,
- modelUrl: f.url
- });
- }), t != "" && t != null && this._deleteAssetsLowpolyModel(t);
- a = e.skinId;
- logger$1.info("====> from ", t, " to ", a), this._tvs.forEach(function (f) {
- return f.clean();
- }), this._tvs = [];
- s = EFitMode.cover;
- a == "10048" && (s = EFitMode.contain), Array.isArray(n) && n.forEach(function (f, d) {
- _this4._tvs.push(new TV("squareTv" + d, f.modelUrl, _this4.room, {
- fitMode: s
- }));
- }), e.breathPointsConfig.forEach( /*#__PURE__*/function () {
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10(f) {
- var d;
- return regenerator.wrap(function _callee10$(_context10) {
- while (1) {
- switch (_context10.prev = _context10.next) {
- case 0:
- _context10.prev = 0;
- _context10.next = 3;
- return urlTransformer(f.imageUrl);
- case 3:
- d = _context10.sent;
- _context10.next = 9;
- break;
- case 6:
- _context10.prev = 6;
- _context10.t0 = _context10["catch"](0);
- d = f.imageUrl, logger$1.error("urlTransformer error", _context10.t0);
- case 9:
- _this4.room.breathPointManager.addBreathPoint({
- id: f.id,
- position: f.position,
- spriteSheet: d,
- rotation: f.rotation || {
- pitch: 0,
- yaw: 270,
- roll: 0
- },
- billboardMode: !0,
- type: f.type || "no_type",
- spriteWidthNumber: f.spriteWidthNum || 1,
- spriteHeightNumber: f.spriteHeightNum || 1,
- maxVisibleRegion: f.maxVisibleRegion || 150,
- width: f.width,
- height: f.height,
- skinInfo: f.skinId
- });
- case 10:
- case "end":
- return _context10.stop();
- }
- }
- }, _callee10, null, [[0, 6]]);
- }));
- return function (_x11) {
- return _ref3.apply(this, arguments);
- };
- }()), o.forEach(function (f) {
- _this4.room.sceneManager.decalComponent.addDecal({
- id: f.id || "gbq",
- meshPath: f.modelUrl,
- skinInfo: a
- });
- });
- u = this.room.sceneManager.staticmeshComponent.lowModel_group, c = Array.from(u.keys()).filter(function (f) {
- return !f.startsWith("region_");
- }), h = ["airship", "balloon", "ground_feiting", "ground_reqiqiu", "default"];
- return _context11.abrupt("return", new Promise(function (f, d) {
- Promise.all(h.map(function (_) {
- return _this4._parseModelsAndLoad(r, _, a);
- })).then(function () {
- var _ = !1;
- r.forEach(function (v) {
- v.modelUrl.endsWith("zip") && (_ = !0);
- }), _ == !1 && _this4.room.sceneManager.staticmeshComponent.deleteLastRegionMesh(), _this4.room.sceneManager.staticmeshComponent.lowModel_group;
- var g = Array.from(u.keys()).filter(function (v) {
- return !v.startsWith("region_");
- }),
- m = c.filter(function (v) {
- return g.indexOf(v) < 0;
- });
- m.length > 0 && m.forEach(function (v) {
- _this4.room.sceneManager.staticmeshComponent.deleteMeshesByGroup(v);
- }), f(!0);
- }).catch(function (_) {
- d(_);
- });
- }));
- case 9:
- case "end":
- return _context11.stop();
- }
- }
- }, _callee11, this);
- }));
- function _loadAssetsLowpolyModel(_x10) {
- return _loadAssetsLowpolyModel2.apply(this, arguments);
- }
- return _loadAssetsLowpolyModel;
- }()
- }, {
- key: "_updateSkinAssets",
- value: function () {
- var _updateSkinAssets2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee12(e) {
- var t, r, n;
- return regenerator.wrap(function _callee12$(_context12) {
- while (1) {
- switch (_context12.prev = _context12.next) {
- case 0:
- t = this.room.lastSkinId;
- _context12.next = 3;
- return this.room.getSkin(e);
- case 3:
- r = _context12.sent;
- n = this._createAssetList(r);
- _context12.prev = 5;
- _context12.next = 8;
- return this.loadAssets(n, t);
- case 8:
- this.room.updateCurrentState({
- versionId: r.versionId,
- skinId: r.id,
- skin: r
- });
- _context12.next = 16;
- break;
- case 11:
- _context12.prev = 11;
- _context12.t0 = _context12["catch"](5);
- _context12.next = 15;
- return this.loadAssets(n, t);
- case 15:
- this.room.updateCurrentState({
- versionId: r.versionId,
- skinId: r.id,
- skin: r
- });
- case 16:
- this.setEnv(r);
- case 17:
- case "end":
- return _context12.stop();
- }
- }
- }, _callee12, this, [[5, 11]]);
- }));
- function _updateSkinAssets(_x12) {
- return _updateSkinAssets2.apply(this, arguments);
- }
- return _updateSkinAssets;
- }()
- }, {
- key: "_createAssetList",
- value: function _createAssetList(e) {
- var t = [],
- r = [],
- n = [];
- var o = e.models;
- var a = this.room.modelManager.config.preload;
- return this.room.viewMode === "simple" ? a && (o = a.baseUrls.map(function (l) {
- return l.modelUrl = l.url, l;
- })) : this.room.viewMode, ModelManager.findModels(o, AssetTypeName.Effects, AssetClassName.Effects).forEach(function (l) {
- t.push({
- url: l.modelUrl,
- group: l.className,
- name: l.name
- });
- }), ModelManager.findModels(o, AssetTypeName.Model, AssetClassName.Lpm).forEach(function (l) {
- r.push({
- url: l.modelUrl,
- group: l.className
- });
- }), ModelManager.findModels(o, AssetTypeName.Model, AssetClassName.Gbq).forEach(function (l) {
- r.push({
- url: l.modelUrl,
- group: l.className
- });
- }), ModelManager.findModels(o, AssetTypeName.Model, AssetClassName.Tv).forEach(function (l) {
- r.push({
- url: l.modelUrl,
- group: l.className
- });
- }), [].forEach(function (l) {
- l.skinId == e.id && n.push(l);
- }), {
- roomId: this.room.id,
- effects: t,
- lowPolyModels: r,
- breathPointsConfig: n,
- skinId: e.id
- };
- }
- }, {
- key: "registerStats",
- value: function registerStats() {
- var _this5 = this;
- var e = this.room.sceneManager;
- this.room.scene.registerAfterRender(function () {
- var I;
- var t = e.statisticComponent.getInterFrameTimeCounter(),
- r = e.statisticComponent.getDrawCall(),
- n = e.statisticComponent.getActiveFaces(),
- o = e.statisticComponent.getFrameTimeCounter(),
- a = e.statisticComponent.getDrawCallTime(),
- s = e.statisticComponent.getAnimationTime(),
- l = e.statisticComponent.getActiveMeshEvaluationTime(),
- u = e.statisticComponent.getRenderTargetRenderTime(),
- c = e.statisticComponent.getRegisterBeforeRenderTime(),
- h = e.statisticComponent.getRegisterAfterRenderTime(),
- f = e.statisticComponent.getActiveParticles(),
- d = e.statisticComponent.getActiveBones(),
- _ = e.Scene._activeAnimatables.length,
- g = e.statisticComponent.getTotalRootNodes(),
- m = e.Scene.geometries.length,
- v = e.Scene.onBeforeRenderObservable.observers.length,
- y = e.Scene.onAfterRenderObservable.observers.length,
- b = e.statisticComponent.getTotalMeshes(),
- T = e.statisticComponent.getTotalTextures(),
- C = e.statisticComponent.getTotalMaterials(),
- A = e.statisticComponent.getSystemInfo(),
- S = A.resolution,
- P = A.driver;
- A.vender;
- var R = A.version,
- M = A.hardwareScalingLevel,
- x = S + "_" + P + "_" + R + "_" + M;
- _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({
- renderFrameTime: _this5.renderTimeCircularArray.getAvg(),
- maxRenderFrameTime: _this5.renderTimeCircularArray.getMax(),
- interFrameTime: _this5.interFrameCircularArray.getAvg(),
- animationTime: _this5.animationCircularArray.getAvg(),
- meshSelectTime: _this5.meshSelectCircularArray.getAvg(),
- drawcallTime: _this5.drawCallTimeCircularArray.getAvg(),
- idleTime: _this5._idleTime,
- registerBeforeRenderTime: _this5.regBeforeRenderCircularArray.getAvg(),
- registerAfterRenderTime: _this5.regAfterRenderCircularArray.getAvg(),
- renderTargetRenderTime: _this5.renderTargetCircularArray.getAvg(),
- fps: (1e3 / (_this5.renderTimeCircularArray.getAvg() + _this5.interFrameCircularArray.getAvg())).toFixed(2),
- drawcall: _this5.drawCallCntCircularArray.getAvg(),
- triangle: n.toString(),
- engineSloppyCnt: _this5.engineSloppyCnt,
- maxInterFrameTime: _this5.interFrameCircularArray.getMax(),
- maxDrawcallTime: _this5.drawCallTimeCircularArray.getMax(),
- maxMeshSelectTime: _this5.meshSelectCircularArray.getMax(),
- maxAnimationTime: _this5.animationCircularArray.getMax(),
- maxRegisterBeforeRenderTime: _this5.regBeforeRenderCircularArray.getMax(),
- maxRegisterAfterRenderTime: _this5.regAfterRenderCircularArray.getMax(),
- maxRenderTargetRenderTime: _this5.renderTargetCircularArray.getMax(),
- activeParticles: f,
- activeBones: d,
- activeAnimation: _,
- totalMeshes: b,
- totalRootNodes: g,
- totalGeometries: m,
- totalTextures: T,
- totalMaterials: C,
- registerBeforeCount: v,
- registerAfterCount: y,
- hardwareInfo: x
- }));
- });
- }
- }, {
- key: "updateBillboard",
- value: function () {
- var _updateBillboard = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee13() {
- var e, r, n, o, a, s;
- return regenerator.wrap(function _callee13$(_context13) {
- while (1) {
- switch (_context13.prev = _context13.next) {
- case 0:
- e = this.room.options.skinId;
- _context13.next = 3;
- return this.room.modelManager.findAssetList(e);
- case 3:
- r = _context13.sent.filter(function (a) {
- return a.typeName === AssetTypeName.Textures && a.className === AssetClassName.SayBubble;
- });
- n = ["bubble01", "bubble02", "bubble03"];
- o = ["bubble01_npc", "bubble02_npc", "bubble03_npc"];
- if (r.length) {
- a = r.filter(function (l) {
- return n.includes(l.name);
- }).map(function (l) {
- return l.url;
- }), s = r.filter(function (l) {
- return o.includes(l.name);
- }).map(function (l) {
- return l.url;
- });
- a.length && (XBillboardManager.userBubbleUrls = a), s.length && (XBillboardManager.npcBubbleUrls = s);
- }
- case 7:
- case "end":
- return _context13.stop();
- }
- }
- }, _callee13, this);
- }));
- function updateBillboard() {
- return _updateBillboard.apply(this, arguments);
- }
- return updateBillboard;
- }()
- }]);
- return EngineProxy;
- }();
- 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); }; }
- 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; } }
- var LongPressMesh = [EMeshType.XAvatar];
- var StaticMeshEvent = /*#__PURE__*/function (_EventEmitter) {
- _inherits(StaticMeshEvent, _EventEmitter);
- var _super = _createSuper$2(StaticMeshEvent);
- function StaticMeshEvent(e) {
- var _this;
- _classCallCheck(this, StaticMeshEvent);
- _this = _super.call(this);
- E(_assertThisInitialized(_this), "scene");
- E(_assertThisInitialized(_this), "_staringPointerTime", -1);
- E(_assertThisInitialized(_this), "_pickedMeshID", "0");
- E(_assertThisInitialized(_this), "_pointerDownTime", -1);
- E(_assertThisInitialized(_this), "_currentPickPoint");
- E(_assertThisInitialized(_this), "_longPressDelay", 500);
- E(_assertThisInitialized(_this), "_pointerTapDelay", 200);
- E(_assertThisInitialized(_this), "_pickedMeshType");
- E(_assertThisInitialized(_this), "registerEvent", function () {
- _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 () {
- _this.scene.onPrePointerObservable.removeCallback(_this.onUp), _this.scene.onPrePointerObservable.removeCallback(_this.onDown), _this.scene.onPrePointerObservable.removeCallback(_this.onDoubleTap);
- };
- });
- E(_assertThisInitialized(_this), "onUp", function () {
- if (Date.now() - _this._pointerDownTime < _this._pointerTapDelay && !_this.scene._inputManager._isPointerSwiping()) {
- _this.scene._inputManager._totalPointersPressed = 0;
- var _e = _this._currentPickPoint;
- _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) {
- return t.isPickable && LongPressMesh.indexOf(t.xtype) == -1;
- }), _e != null && _this.emit("pointTap", _e));
- }
- });
- E(_assertThisInitialized(_this), "onDown", function () {
- var e = _this.onPointerTap(function (t) {
- return t.isPickable;
- });
- _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 () {
- e = _this.onPointerTap(function (t) {
- return t.isPickable && t.xtype == _this._pickedMeshType && t.xid == _this._pickedMeshID;
- }), e !== null && Date.now() - _this._staringPointerTime > _this._longPressDelay && !_this.scene._inputManager._isPointerSwiping() && _this.scene._inputManager._totalPointersPressed !== 0 && (_this._staringPointerTime = 0, _this.emit("longPress", e));
- }, _this._longPressDelay));
- });
- E(_assertThisInitialized(_this), "onDoubleTap", function () {
- var e = _this.onPointerTap(void 0);
- e != null && _this.emit("pointDoubleTap", e);
- });
- _this.manager = e, _this.scene = e.Scene, _this.registerEvent(), _this._currentPickPoint = null, _this._pickedMeshType = null;
- return _this;
- }
- _createClass(StaticMeshEvent, [{
- key: "onPointerTap",
- value: function onPointerTap(e) {
- var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
- var n, o;
- var r = new BABYLON.PickingInfo();
- if (t) {
- var a = this.scene.multiPick(this.scene.pointerX, this.scene.pointerY, e, void 0, void 0);
- a && a.length > 1 ? r = a[1] : a && (r = a[0]);
- } else r = this.scene.pick(this.scene.pointerX, this.scene.pointerY, e, !1, null);
- if (r.hit) {
- var _a = (n = r == null ? void 0 : r.pickedPoint) == null ? void 0 : n.asArray();
- if (_a) {
- var _a2 = _slicedToArray(_a, 3),
- s = _a2[0],
- l = _a2[1],
- u = _a2[2],
- c = xversePosition2Ue4({
- x: s,
- y: l,
- z: u
- });
- return {
- name: (o = r.pickedMesh) == null ? void 0 : o.name,
- type: r.pickedMesh.xtype,
- id: r.pickedMesh.xid,
- point: c
- };
- }
- }
- return null;
- }
- }]);
- return StaticMeshEvent;
- }(EventEmitter);
- var RotationEvent = /*#__PURE__*/function () {
- function RotationEvent(e) {
- var _this = this;
- _classCallCheck(this, RotationEvent);
- E(this, "touchStartX");
- E(this, "touchStartY");
- E(this, "handelResize");
- E(this, "_room");
- E(this, "_canvas");
- E(this, "handleTouchStart", function (e) {
- var t = e.touches[0];
- _this.touchStartX = t.pageX, _this.touchStartY = t.pageY, _this._room.emit("touchStart", {
- event: e
- });
- });
- E(this, "handleMouseDown", function (e) {
- _this.touchStartX = e.pageX, _this.touchStartY = e.pageY;
- });
- E(this, "handleMouseMove", function (e) {
- if (!_this.touchStartX || !_this.touchStartY) return;
- var t = e.pageX,
- r = e.pageY,
- n = t - _this.touchStartX,
- o = r - _this.touchStartY,
- a = _this._room.options.canvas.offsetHeight,
- s = _this._room.options.canvas.offsetWidth;
- var l = 2 * o / a,
- u = 2 * n / s;
- l > 1 && (l = 1), u > 1 && (u = 1), _this._room.actionsHandler.rotate({
- pitch: l,
- yaw: u
- }), _this.touchStartX = t, _this.touchStartY = r;
- });
- E(this, "handleMouseUp", function () {
- _this.touchStartX = void 0, _this.touchStartY = void 0;
- });
- E(this, "handleTouchMove", function (e) {
- if (!_this.touchStartX || !_this.touchStartY) return;
- var t = e.touches[0],
- r = t.pageX,
- n = t.pageY,
- o = r - _this.touchStartX,
- a = n - _this.touchStartY,
- s = _this._room.options.canvas.offsetHeight,
- l = _this._room.options.canvas.offsetWidth;
- var u = 2 * a / s,
- c = 2 * o / l;
- u > 1 && (u = 1), c > 1 && (c = 1), _this._room.actionsHandler.rotate({
- pitch: u,
- yaw: c
- }), _this.touchStartX = r, _this.touchStartY = n, _this._room.emit("touchMove", {
- pitch: u,
- yaw: c,
- event: e
- });
- });
- E(this, "handleTouchEnd", function (e) {
- _this._room.emit("touchEnd", {
- event: e
- });
- });
- this._room = e, this._canvas = e.canvas, this.handelResize = this.reiszeChange();
- }
- _createClass(RotationEvent, [{
- key: "init",
- value: function init() {
- 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);
- }
- }, {
- key: "clear",
- value: function clear() {
- 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);
- }
- }, {
- key: "reiszeChange",
- value: function reiszeChange() {
- window.addEventListener("resize", function () {});
- }
- }]);
- return RotationEvent;
- }();
- var EventsController = /*#__PURE__*/function () {
- function EventsController(e) {
- var _this = this;
- _classCallCheck(this, EventsController);
- E(this, "staticmeshEvent");
- E(this, "rotationEvent");
- E(this, "resize", function () {
- _this.room.sceneManager.cameraComponent.cameraFovChange(_this.room.sceneManager.yuvInfo);
- });
- E(this, "clickEvent", function (e) {
- var t = e.point,
- r = e.name,
- n = e.type,
- o = e.id;
- logger$1.debug("pointEvent", e), _this.room.proxyEvents("pointTap", {
- point: t,
- meshName: r,
- type: n,
- id: o
- }), _this.room.proxyEvents("_coreClick", e);
- });
- E(this, "longPressEvent", function (e) {
- _this.room.proxyEvents("_corePress", e);
- });
- E(this, "handleActionResponseTimeout", function (_ref) {
- var e = _ref.error,
- t = _ref.event;
- _this.room.proxyEvents("actionResponseTimeout", {
- error: e,
- event: t
- });
- });
- E(this, "handleNetworkStateChange", function (e) {
- var t = e.state,
- r = e.count;
- t == "reconnecting" ? _this.room.proxyEvents("reconnecting", {
- count: r || 1
- }) : t === "reconnected" ? (_this.room.networkController.rtcp.workers.reset(), _this.room.proxyEvents("reconnected"), _this.room.afterReconnected()) : t === "disconnected" && _this.room.proxyEvents("disconnected");
- });
- this.room = e, this.staticmeshEvent = new StaticMeshEvent(this.room.sceneManager), this.rotationEvent = new RotationEvent(e);
- }
- _createClass(EventsController, [{
- key: "bindEvents",
- value: function bindEvents() {
- 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);
- }
- }, {
- key: "clearEvents",
- value: function clearEvents() {
- 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();
- }
- }]);
- return EventsController;
- }();
- var Panorama = /*#__PURE__*/function () {
- function Panorama(e) {
- var _this = this;
- _classCallCheck(this, Panorama);
- E(this, "_actived", !1);
- E(this, "handleReceivePanorama", /*#__PURE__*/function () {
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e, t) {
- var r, n, _this$room$currentSta, o, a, s, _ref2, l;
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- logger$1.warn("handle panorama", e.uuid, e.pos, e.finished);
- r = {
- data: e.data,
- pose: {
- position: e.pos
- }
- }, n = _this.room.sceneManager;
- _this.room.networkController.rtcp.workers.changePanoMode(!0);
- _context.next = 5;
- return n.materialComponent.changePanoImg(0, r);
- case 5:
- if (!e.finished) {
- _context.next = 23;
- break;
- }
- _context.next = 8;
- return n.changePanoShaderForLowModel(0);
- case 8:
- _this.room.isPano = !0;
- _this._actived = !0;
- if (!t) {
- _context.next = 14;
- break;
- }
- _this.room.sceneManager.cameraComponent.changeToFirstPersonView({
- position: t.position,
- rotation: t.angle
- });
- _context.next = 23;
- break;
- case 14:
- _this$room$currentSta = _this.room.currentState, o = _this$room$currentSta.skinId, a = _this$room$currentSta.pathName;
- if (!(!o || !a)) {
- _context.next = 17;
- break;
- }
- return _context.abrupt("return");
- case 17:
- _context.next = 19;
- return _this.room.modelManager.findRoute(o, a);
- case 19:
- s = _context.sent;
- _ref2 = util.getRandomItem(s.birthPointList) || {};
- l = _ref2.camera;
- l && _this.room.sceneManager.cameraComponent.changeToFirstPersonView(le(oe({}, l), {
- rotation: l.angle
- }));
- case 23:
- case "end":
- return _context.stop();
- }
- }
- }, _callee);
- }));
- return function (_x, _x2) {
- return _ref.apply(this, arguments);
- };
- }());
- this.room = e;
- }
- _createClass(Panorama, [{
- key: "actived",
- get: function get() {
- return this._actived;
- }
- }, {
- key: "bindListener",
- value: function bindListener(e) {
- var _this2 = this;
- this.room.networkController.rtcp.workers.registerFunction("panorama", function (r) {
- 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));
- });
- }
- }, {
- key: "access",
- value: function access(e, t, r) {
- var _this3 = this;
- var n = e.camera,
- o = e.player,
- a = e.attitude,
- s = e.areaName,
- l = e.pathName,
- u = e.tag;
- return this.room.actionsHandler.requestPanorama({
- camera: n,
- player: o,
- attitude: a,
- areaName: s,
- pathName: l,
- tag: u
- }, t, r).then(function (c) {
- return _this3.handleReceivePanorama(c, o);
- });
- }
- }, {
- key: "exit",
- value: function exit(e) {
- var _this4 = this;
- var t = e.camera,
- r = e.player,
- n = e.attitude,
- o = e.areaName,
- a = e.pathName;
- return this.room.networkController.rtcp.workers.changePanoMode(!1), this.room.actionsHandler.changeRotationRenderType({
- renderType: RenderType.RotationVideo,
- player: r,
- camera: t,
- attitude: n,
- areaName: o,
- pathName: a
- }).then(function () {
- return _this4.handleExitPanorama();
- }).catch(function (s) {
- return _this4.room.networkController.rtcp.workers.changePanoMode(!0), Promise.reject(s);
- });
- }
- }, {
- key: "handleExitPanorama",
- value: function handleExitPanorama() {
- var e, t, r, n, o, a;
- this.room.isPano = !1, this._actived = !1, (n = (e = this.room.sceneManager) == null ? void 0 : e.cameraComponent) == null || n.forceChangeSavedCameraPose({
- position: (t = this.room._currentClickingState) == null ? void 0 : t.camera.position,
- rotation: (r = this.room._currentClickingState) == null ? void 0 : r.camera.angle
- }), this.room.sceneManager.changeVideoShaderForLowModel(), (a = (o = this.room.sceneManager) == null ? void 0 : o.cameraComponent) == null || a.changeToThirdPersonView();
- }
- }]);
- return Panorama;
- }();
- 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); }; }
- 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; } }
- var Xverse_Room = /*#__PURE__*/function (_EventEmitter) {
- _inherits(Xverse_Room, _EventEmitter);
- var _super = _createSuper$1(Xverse_Room);
- function Xverse_Room(e) {
- var _this;
- _classCallCheck(this, Xverse_Room);
- _this = _super.call(this);
- E(_assertThisInitialized(_this), "disableAutoTurn", !1);
- E(_assertThisInitialized(_this), "options");
- E(_assertThisInitialized(_this), "_currentNetworkOptions");
- E(_assertThisInitialized(_this), "lastSkinId");
- E(_assertThisInitialized(_this), "debug");
- E(_assertThisInitialized(_this), "isFirstDataUsed", !1);
- E(_assertThisInitialized(_this), "userId", null);
- E(_assertThisInitialized(_this), "pathManager", new PathManager());
- E(_assertThisInitialized(_this), "networkController");
- E(_assertThisInitialized(_this), "_startTime", Date.now());
- E(_assertThisInitialized(_this), "canvas");
- E(_assertThisInitialized(_this), "modelManager");
- E(_assertThisInitialized(_this), "eventsController");
- E(_assertThisInitialized(_this), "panorama");
- E(_assertThisInitialized(_this), "engineProxy");
- E(_assertThisInitialized(_this), "_id");
- E(_assertThisInitialized(_this), "skinList", []);
- E(_assertThisInitialized(_this), "isHost", !1);
- E(_assertThisInitialized(_this), "avatarManager", new XverseAvatarManager(_assertThisInitialized(_this)));
- E(_assertThisInitialized(_this), "effectManager", new XverseEffectManager(_assertThisInitialized(_this)));
- E(_assertThisInitialized(_this), "sceneManager");
- E(_assertThisInitialized(_this), "scene");
- E(_assertThisInitialized(_this), "breathPointManager");
- E(_assertThisInitialized(_this), "_currentState");
- E(_assertThisInitialized(_this), "joined", !1);
- E(_assertThisInitialized(_this), "disableRotate", !1);
- E(_assertThisInitialized(_this), "isPano", !1);
- E(_assertThisInitialized(_this), "movingByClick", !0);
- E(_assertThisInitialized(_this), "camera", new Camera(_assertThisInitialized(_this)));
- E(_assertThisInitialized(_this), "stats", new Stats(_assertThisInitialized(_this)));
- E(_assertThisInitialized(_this), "isUpdatedRawYUVData", !1);
- E(_assertThisInitialized(_this), "actionsHandler", new ActionsHandler(_assertThisInitialized(_this)));
- E(_assertThisInitialized(_this), "_currentClickingState", null);
- E(_assertThisInitialized(_this), "signal", new Signal(_assertThisInitialized(_this)));
- E(_assertThisInitialized(_this), "firstFrameTimestamp");
- E(_assertThisInitialized(_this), "receiveRtcData", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
- var e, t, r, n;
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- logger$1.info("Invoke receiveRtcData");
- e = !1, t = !1, r = !1, n = !1;
- return _context.abrupt("return", _this.viewMode === "serverless" ? (logger$1.warn("set view mode to serverless"), _this.setViewMode("observer").then(function () {
- return _assertThisInitialized(_this);
- }, function () {
- return _assertThisInitialized(_this);
- })) : new Promise(function (o) {
- var a = _this.networkController.rtcp.workers;
- a.registerFunction("signal", function (s) {
- _this.signal.handleSignal(s);
- }), a.registerFunction("stream", function (s) {
- var l;
- if (_this.emit("streamTimestamp", {
- timestamp: Date.now()
- }), t || (t = !0, logger$1.info("Invoke stream event")), s.stream) {
- r || (r = !0, logger$1.info("Invoke updateRawYUVData")), _this.isUpdatedRawYUVData = !1;
- var u = (l = _this._currentState.skin) == null ? void 0 : l.fov;
- _this.sceneManager.materialComponent.updateRawYUVData(s.stream, s.width, s.height, u), _this.isUpdatedRawYUVData = !0;
- }
- e || (logger$1.info("Invoke isAfterRenderRegistered"), e = !0, _this.scene.registerAfterRender(function () {
- _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()));
- }));
- }), _this.panorama.bindListener(function () {
- o(_assertThisInitialized(_this)), _this.afterJoinRoom();
- }), a.registerFunction("reconnectedFrame", function () {}), logger$1.info("Invoke decoderWorker.postMessage"), a.decoderWorker.postMessage({
- t: 5
- });
- }));
- case 3:
- case "end":
- return _context.stop();
- }
- }
- }, _callee);
- })));
- E(_assertThisInitialized(_this), "moveToExtra", "");
- _this.options = e, _this.options.wsServerUrl || (_this.options.wsServerUrl = SERVER_URLS.DEV), _this.modelManager = ModelManager.getInstance(e.appId, e.releaseId), _this.updateReporter();
- var n = e;
- n.canvas;
- var r = Oe(n, ["canvas"]);
- logger$1.infoAndReportMeasurement({
- metric: "startJoinRoomAt",
- startTime: Date.now(),
- group: "joinRoom",
- extra: r,
- value: 0
- });
- return _this;
- }
- _createClass(Xverse_Room, [{
- key: "currentNetworkOptions",
- get: function get() {
- return this._currentNetworkOptions;
- }
- }, {
- key: "viewMode",
- get: function get() {
- var e;
- return ((e = this._currentState) == null ? void 0 : e.viewMode) || "full";
- }
- }, {
- key: "id",
- get: function get() {
- return this._id;
- }
- }, {
- key: "skinId",
- get: function get() {
- return this._currentState.skinId;
- }
- }, {
- key: "skin",
- get: function get() {
- return this._currentState.skin;
- }
- }, {
- key: "sessionId",
- get: function get() {
- return this.currentNetworkOptions.sessionId;
- }
- }, {
- key: "pictureQualityLevel",
- get: function get() {
- return this.currentState.pictureQualityLevel;
- }
- }, {
- key: "avatars",
- get: function get() {
- return Array.from(this.avatarManager.avatars.values());
- }
- }, {
- key: "currentState",
- get: function get() {
- var e;
- return le(oe({}, this._currentState), {
- state: (e = this.networkController) == null ? void 0 : e._state
- });
- }
- }, {
- key: "_userAvatar",
- get: function get() {
- var _this2 = this;
- return this.avatars.find(function (e) {
- return e.userId === _this2.userId;
- });
- }
- }, {
- key: "tvs",
- get: function get() {
- return this.engineProxy._tvs;
- }
- }, {
- key: "tv",
- get: function get() {
- return this.tvs[0];
- }
- }, {
- key: "currentClickingState",
- get: function get() {
- return this._currentClickingState;
- }
- }, {
- key: "afterJoinRoomHook",
- value: function afterJoinRoomHook() {}
- }, {
- key: "beforeJoinRoomResolveHook",
- value: function beforeJoinRoomResolveHook() {}
- }, {
- key: "afterReconnectedHook",
- value: function afterReconnectedHook() {}
- }, {
- key: "handleSignalHook",
- value: function handleSignalHook(e) {}
- }, {
- key: "skinChangedHook",
- value: function skinChangedHook() {}
- }, {
- key: "beforeStartGameHook",
- value: function () {
- var _beforeStartGameHook = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e) {
- return regenerator.wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2);
- }));
- function beforeStartGameHook(_x) {
- return _beforeStartGameHook.apply(this, arguments);
- }
- return beforeStartGameHook;
- }()
- }, {
- key: "loadAssetsHook",
- value: function loadAssetsHook() {}
- }, {
- key: "afterUserAvatarLoadedHook",
- value: function afterUserAvatarLoadedHook() {}
- }, {
- key: "audienceViewModeHook",
- value: function audienceViewModeHook() {}
- }, {
- key: "setViewModeToObserver",
- value: function setViewModeToObserver() {}
- }, {
- key: "handleVehicleHook",
- value: function handleVehicleHook(e) {}
- }, {
- key: "updateReporter",
- value: function updateReporter() {
- var _this$options = this.options,
- e = _this$options.avatarId,
- t = _this$options.skinId,
- r = _this$options.userId,
- n = _this$options.roomId,
- o = _this$options.role,
- a = _this$options.appId,
- s = _this$options.wsServerUrl;
- reporter$1.updateHeader({
- userId: r
- }), reporter$1.updateBody({
- roomId: n,
- role: o,
- skinId: t,
- avatarId: e,
- appId: a,
- wsServerUrl: s
- });
- }
- }, {
- key: "initRoom",
- value: function () {
- var _initRoom2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
- var _this$options$timeout, e;
- return regenerator.wrap(function _callee3$(_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- _this$options$timeout = this.options.timeout, e = _this$options$timeout === void 0 ? DEFAULT_JOINROOM_TIMEOUT : _this$options$timeout;
- if (!util.isSupported()) {
- _context3.next = 5;
- break;
- }
- return _context3.abrupt("return", this._initRoom()._timeout(e, new TimeoutError("initRoom timeout")));
- case 5:
- return _context3.abrupt("return", Promise.reject(new UnsupportedError()));
- case 6:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee3, this);
- }));
- function initRoom() {
- return _initRoom2.apply(this, arguments);
- }
- return initRoom;
- }()
- }, {
- key: "_initRoom",
- value: function () {
- var _initRoom3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4() {
- 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;
- return regenerator.wrap(function _callee4$(_context4) {
- while (1) {
- switch (_context4.prev = _context4.next) {
- case 0:
- e = this.validateOptions(this.options);
- if (!e) {
- _context4.next = 3;
- break;
- }
- return _context4.abrupt("return", (logger$1.error("initRoom param error", e), Promise.reject(e)));
- case 3:
- _this$options2 = this.options, t = _this$options2.canvas, r = _this$options2.avatarId, n = _this$options2.skinId, o = _this$options2.userId, a = _this$options2.wsServerUrl, s = _this$options2.role, l = _this$options2.token, u = _this$options2.pageSession, c = _this$options2.rotationRenderType, _this$options2$isAllS = _this$options2.isAllSync, h = _this$options2$isAllS === void 0 ? !1 : _this$options2$isAllS, f = _this$options2.appId, d = _this$options2.camera, _ = _this$options2.player, g = _this$options2.avatarComponents, m = _this$options2.nickname, v = _this$options2.avatarScale, _this$options2$firend = _this$options2.firends, y = _this$options2$firend === void 0 ? [] : _this$options2$firend, _this$options2$syncBy = _this$options2.syncByEvent, b = _this$options2$syncBy === void 0 ? !1 : _this$options2$syncBy, T = _this$options2.areaName, _this$options2$attitu = _this$options2.attitude, C = _this$options2$attitu === void 0 ? MotionType$1.Walk : _this$options2$attitu, A = _this$options2.pathName, _this$options2$viewMo = _this$options2.viewMode, S = _this$options2$viewMo === void 0 ? "full" : _this$options2$viewMo, P = _this$options2.person, R = _this$options2.roomId, M = _this$options2.roomTypeId, _this$options2$hasAva = _this$options2.hasAvatar, x = _this$options2$hasAva === void 0 ? !1 : _this$options2$hasAva, _this$options2$syncTo = _this$options2.syncToOthers, I = _this$options2$syncTo === void 0 ? !1 : _this$options2$syncTo, _this$options2$priori = _this$options2.prioritySync, w = _this$options2$priori === void 0 ? !1 : _this$options2$priori, _this$options2$remove = _this$options2.removeWhenDisconnected, O = _this$options2$remove === void 0 ? !0 : _this$options2$remove, D = _this$options2.extra;
- this.setCurrentNetworkOptions({
- avatarId: r,
- skinId: n,
- roomId: R,
- userId: o,
- wsServerUrl: a,
- role: s,
- token: l,
- pageSession: u,
- rotationRenderType: c,
- isAllSync: h,
- appId: f,
- camera: d,
- player: _,
- avatarComponents: g,
- nickname: m,
- avatarScale: v,
- firends: y,
- syncByEvent: b,
- areaName: T,
- attitude: C,
- pathName: A,
- person: P,
- roomTypeId: M,
- hasAvatar: x,
- syncToOthers: I,
- prioritySync: w,
- extra: D,
- removeWhenDisconnected: O
- });
- this.userId = o;
- this.canvas = t;
- T && (this.pathManager.currentArea = T);
- this.networkController = new NetworkController(this);
- this.setCurrentState({
- areaName: T,
- pathName: A,
- attitude: C,
- speed: 0,
- viewMode: S,
- state: this.networkController._state,
- skinId: n
- });
- _context4.prev = 10;
- _context4.next = 13;
- return Promise.all([this.initNetwork(), this.initConfig(), this.initWasm()]);
- case 13:
- logger$1.info("network config wasm all ready, start to create game");
- _context4.next = 16;
- return this.requestCreateRoom({
- skinId: n
- });
- case 16:
- F = _context4.sent;
- V = F.routeList.find(function (L) {
- return L.areaName === T;
- });
- N = ((V == null ? void 0 : V.step) || 7.5) * 30;
- this.updateCurrentState({
- skin: F,
- skinId: F.id,
- versionId: F.versionId,
- speed: N
- });
- _context4.next = 22;
- return this.initEngine(F);
- case 22:
- _context4.next = 27;
- break;
- case 24:
- _context4.prev = 24;
- _context4.t0 = _context4["catch"](10);
- return _context4.abrupt("return", Promise.reject(_context4.t0));
- case 27:
- return _context4.abrupt("return", (this.beforeJoinRoomResolve(), this.receiveRtcData()));
- case 28:
- case "end":
- return _context4.stop();
- }
- }
- }, _callee4, this, [[10, 24]]);
- }));
- function _initRoom() {
- return _initRoom3.apply(this, arguments);
- }
- return _initRoom;
- }()
- }, {
- key: "beforeJoinRoomResolve",
- value: function beforeJoinRoomResolve() {
- this.setupStats(), this.eventsController = new EventsController(this), this.eventsController.bindEvents(), this.panorama = new Panorama(this), this.beforeJoinRoomResolveHook();
- }
- }, {
- key: "afterJoinRoom",
- value: function afterJoinRoom() {
- this.joined = !0, this.viewMode === "observer" && this.setViewModeToObserver(), logger$1.infoAndReportMeasurement({
- tag: this.viewMode,
- value: this.firstFrameTimestamp - this._startTime,
- startTime: Date.now(),
- metric: "joinRoom"
- }), this.camera.initialFov = this.sceneManager.cameraComponent.getCameraFov(), this.stats.on("stats", function (_ref2) {
- var e = _ref2.stats;
- reporter$1.report("stats", oe({}, e));
- }), this.debug = new Debug(this), this.afterJoinRoomHook();
- }
- }, {
- key: "afterReconnected",
- value: function afterReconnected() {
- this.avatarManager.clearOtherUsers(), this.afterReconnectedHook();
- }
- }, {
- key: "leave",
- value: function leave() {
- var e, t;
- return logger$1.info("Invoke room.leave"), (e = this.eventsController) == null || e.clearEvents(), (t = this.networkController) == null || t.quit(), this;
- }
- }, {
- key: "validateOptions",
- value: function validateOptions(e) {
- var _ref3 = e || {},
- t = _ref3.canvas,
- r = _ref3.avatarId,
- n = _ref3.skinId,
- o = _ref3.userId,
- a = _ref3.role;
- _ref3.roomId;
- var l = _ref3.token,
- u = _ref3.appId;
- _ref3.avatarComponents;
- var h = [];
- t instanceof HTMLCanvasElement || h.push(new ParamError$1("`canvas` must be instanceof of HTMLCanvasElement"));
- (!o || typeof o != "string") && h.push(new ParamError$1("`userId` must be string"));
- (!l || typeof l != "string") && h.push(new ParamError$1("`token` must be string"));
- (!u || typeof u != "string") && h.push(new ParamError$1("`appId` must be string"));
- a == "audience" || (!r || !n) && h.push(new ParamError$1("`avatarId` and `skinId` is required when create room"));
- return h[0];
- }
- }, {
- key: "initNetwork",
- value: function () {
- var _initNetwork = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5() {
- var e;
- return regenerator.wrap(function _callee5$(_context5) {
- while (1) {
- switch (_context5.prev = _context5.next) {
- case 0:
- if (!(this.viewMode === "serverless")) {
- _context5.next = 2;
- break;
- }
- return _context5.abrupt("return", Promise.resolve());
- case 2:
- e = Date.now();
- _context5.prev = 3;
- _context5.next = 6;
- return this.networkController.connect()._timeout(8e3, new InitNetworkTimeoutError());
- case 6:
- logger$1.infoAndReportMeasurement({
- metric: "networkInitAt",
- startTime: this._startTime,
- group: "joinRoom"
- });
- logger$1.infoAndReportMeasurement({
- metric: "networkInitCost",
- startTime: e,
- group: "joinRoom"
- });
- _context5.next = 13;
- break;
- case 10:
- _context5.prev = 10;
- _context5.t0 = _context5["catch"](3);
- throw logger$1.infoAndReportMeasurement({
- metric: "networkInitAt",
- startTime: e,
- group: "joinRoom",
- error: _context5.t0
- }), _context5.t0;
- case 13:
- case "end":
- return _context5.stop();
- }
- }
- }, _callee5, this, [[3, 10]]);
- }));
- function initNetwork() {
- return _initNetwork.apply(this, arguments);
- }
- return initNetwork;
- }()
- }, {
- key: "initConfig",
- value: function () {
- var _initConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6() {
- var e;
- return regenerator.wrap(function _callee6$(_context6) {
- while (1) {
- switch (_context6.prev = _context6.next) {
- case 0:
- e = Date.now();
- _context6.prev = 1;
- _context6.next = 4;
- return this.modelManager.getApplicationConfig()._timeout(8e3, new InitConfigTimeoutError());
- case 4:
- logger$1.infoAndReportMeasurement({
- metric: "configInitAt",
- startTime: this._startTime,
- group: "joinRoom"
- });
- logger$1.infoAndReportMeasurement({
- metric: "configInitCost",
- startTime: e,
- group: "joinRoom"
- });
- _context6.next = 11;
- break;
- case 8:
- _context6.prev = 8;
- _context6.t0 = _context6["catch"](1);
- throw logger$1.infoAndReportMeasurement({
- metric: "configInitAt",
- startTime: e,
- group: "joinRoom",
- error: _context6.t0
- }), _context6.t0;
- case 11:
- case "end":
- return _context6.stop();
- }
- }
- }, _callee6, this, [[1, 8]]);
- }));
- function initConfig() {
- return _initConfig.apply(this, arguments);
- }
- return initConfig;
- }()
- }, {
- key: "initEngine",
- value: function () {
- var _initEngine = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7(e) {
- var t, n;
- return regenerator.wrap(function _callee7$(_context7) {
- while (1) {
- switch (_context7.prev = _context7.next) {
- case 0:
- t = Date.now();
- _context7.prev = 1;
- this.engineProxy = new EngineProxy(this);
- _context7.next = 5;
- return this.engineProxy.initEngine(e);
- case 5:
- logger$1.infoAndReportMeasurement({
- metric: "webglInitAt",
- startTime: this._startTime,
- group: "joinRoom"
- });
- logger$1.infoAndReportMeasurement({
- metric: "webglInitCost",
- startTime: t,
- group: "joinRoom"
- });
- return _context7.abrupt("return");
- case 10:
- _context7.prev = 10;
- _context7.t0 = _context7["catch"](1);
- n = _context7.t0;
- return _context7.abrupt("return", (_context7.t0.code !== Codes.InitEngineTimeout && (n = new InitEngineError()), logger$1.error(_context7.t0), logger$1.infoAndReportMeasurement({
- metric: "webglInitAt",
- startTime: t,
- group: "joinRoom",
- error: n
- }), Promise.reject(n)));
- case 14:
- case "end":
- return _context7.stop();
- }
- }
- }, _callee7, this, [[1, 10]]);
- }));
- function initEngine(_x2) {
- return _initEngine.apply(this, arguments);
- }
- return initEngine;
- }()
- }, {
- key: "initWasm",
- value: function () {
- var _initWasm = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8() {
- var _this3 = this;
- var e;
- return regenerator.wrap(function _callee8$(_context8) {
- while (1) {
- switch (_context8.prev = _context8.next) {
- case 0:
- if (!(this.viewMode === "serverless")) {
- _context8.next = 2;
- break;
- }
- return _context8.abrupt("return", Promise.resolve());
- case 2:
- e = Date.now();
- _context8.prev = 3;
- _context8.next = 6;
- return this.networkController.rtcp.workers.init(this.options.resolution)._timeout(8e3, new InitDecoderTimeoutError());
- case 6:
- this.networkController.rtcp.workers.registerFunction("error", function (t) {
- logger$1.error("decode error", t);
- var r = t.code,
- n = t.message;
- _this3.emit("error", {
- code: r,
- msg: n
- });
- });
- logger$1.infoAndReportMeasurement({
- metric: "wasmInitAt",
- group: "joinRoom",
- startTime: this._startTime
- });
- logger$1.infoAndReportMeasurement({
- metric: "wasmInitCost",
- group: "joinRoom",
- startTime: e
- });
- eventsManager.on("traceId", function (t) {
- _this3.networkController.rtcp.workers.onTraceId(t);
- });
- _context8.next = 15;
- break;
- case 12:
- _context8.prev = 12;
- _context8.t0 = _context8["catch"](3);
- throw logger$1.infoAndReportMeasurement({
- metric: "wasmInitAt",
- group: "joinRoom",
- startTime: e,
- error: _context8.t0
- }), _context8.t0;
- case 15:
- case "end":
- return _context8.stop();
- }
- }
- }, _callee8, this, [[3, 12]]);
- }));
- function initWasm() {
- return _initWasm.apply(this, arguments);
- }
- return initWasm;
- }()
- }, {
- key: "requestCreateRoom",
- value: function () {
- var _requestCreateRoom = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9(_ref4) {
- var e, t, r, _ref5, n, o, _yield$this$networkCo, _r, _n, _o, a, s;
- return regenerator.wrap(function _callee9$(_context9) {
- while (1) {
- switch (_context9.prev = _context9.next) {
- case 0:
- e = _ref4.skinId;
- if (!e) {
- _context9.next = 11;
- break;
- }
- _context9.next = 4;
- return this.getSkin(e);
- case 4:
- t = _context9.sent;
- _context9.next = 7;
- return this.modelManager.findRoute(e, this.options.pathName);
- case 7:
- r = _context9.sent;
- this.updateCurrentNetworkOptions({
- areaName: r.areaName,
- attitude: r.attitude,
- versionId: t.versionId
- });
- _ref5 = util.getRandomItem(r.birthPointList) || this.options, n = _ref5.camera, o = _ref5.player;
- this.options.camera || this.updateCurrentNetworkOptions({
- camera: n
- }), this.options.player || this.updateCurrentNetworkOptions({
- player: o
- });
- case 11:
- if (!(this.viewMode === "serverless")) {
- _context9.next = 13;
- break;
- }
- return _context9.abrupt("return", t);
- case 13:
- _context9.prev = 13;
- _context9.next = 16;
- return this.beforeStartGameHook(this.options);
- case 16:
- _context9.next = 18;
- return this.networkController.startGame();
- case 18:
- _yield$this$networkCo = _context9.sent;
- _r = _yield$this$networkCo.room_id;
- _n = _yield$this$networkCo.data;
- _o = _yield$this$networkCo.session_id;
- this._id = _r;
- a = JSON.parse(_n);
- this.isHost = a.IsHost, e = a.SkinID || e;
- _context9.next = 27;
- return this.getSkin(e);
- case 27:
- s = _context9.sent;
- return _context9.abrupt("return", (this.updateCurrentNetworkOptions({
- roomId: _r,
- sessionId: _o
- }), reporter$1.updateBody({
- roomId: _r,
- skinId: e,
- serverSession: _o
- }), s));
- case 31:
- _context9.prev = 31;
- _context9.t0 = _context9["catch"](13);
- throw logger$1.error("Request create room error", _context9.t0), _context9.t0;
- case 34:
- case "end":
- return _context9.stop();
- }
- }
- }, _callee9, this, [[13, 31]]);
- }));
- function requestCreateRoom(_x3) {
- return _requestCreateRoom.apply(this, arguments);
- }
- return requestCreateRoom;
- }()
- }, {
- key: "pause",
- value: function pause() {
- return this.engineProxy.pause();
- }
- }, {
- key: "resume",
- value: function resume() {
- return this.engineProxy.resume();
- }
- }, {
- key: "reconnect",
- value: function reconnect() {
- this.networkController.reconnect();
- }
- }, {
- key: "setViewMode",
- value: function () {
- var _setViewMode = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10(e) {
- return regenerator.wrap(function _callee10$(_context10) {
- while (1) {
- switch (_context10.prev = _context10.next) {
- case 0:
- case "end":
- return _context10.stop();
- }
- }
- }, _callee10);
- }));
- function setViewMode(_x4) {
- return _setViewMode.apply(this, arguments);
- }
- return setViewMode;
- }()
- }, {
- key: "handleRepetLogin",
- value: function handleRepetLogin() {
- logger$1.warn("receive " + Codes.RepeatLogin + " for repeat login"), this.emit("repeatLogin"), reporter$1.disable(), this.networkController.quit();
- }
- }, {
- key: "setPictureQualityLevel",
- value: function setPictureQualityLevel(e) {
- var t = {
- high: EImageQuality.high,
- low: EImageQuality.low,
- average: EImageQuality.mid
- };
- return this.updateCurrentState({
- pictureQualityLevel: e
- }), this.sceneManager.setImageQuality(t[e]);
- }
- }, {
- key: "getSkin",
- value: function () {
- var _getSkin = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee11(e) {
- var t, n;
- return regenerator.wrap(function _callee11$(_context11) {
- while (1) {
- switch (_context11.prev = _context11.next) {
- case 0:
- t = null;
- _context11.next = 3;
- return this.modelManager.getSkinsList();
- case 3:
- t = (this.skinList = _context11.sent).find(function (n) {
- return n.id === e || n.id === e;
- });
- if (!t) {
- _context11.next = 6;
- break;
- }
- return _context11.abrupt("return", t);
- case 6:
- n = "skin is invalid: skinId: ".concat(e);
- return _context11.abrupt("return", Promise.reject(new ParamError$1(n)));
- case 8:
- case "end":
- return _context11.stop();
- }
- }
- }, _callee11, this);
- }));
- function getSkin(_x5) {
- return _getSkin.apply(this, arguments);
- }
- return getSkin;
- }()
- }, {
- key: "setupStats",
- value: function setupStats() {
- this.stats.assign({
- roomId: this.id,
- userId: this.userId
- }), setInterval(this.engineProxy.updateStats, 1e3);
- }
- }, {
- key: "proxyEvents",
- value: function proxyEvents(e, t) {
- this.emit(e, t);
- }
- }, {
- key: "setCurrentNetworkOptions",
- value: function setCurrentNetworkOptions(e) {
- this._currentNetworkOptions = e;
- }
- }, {
- key: "updateCurrentNetworkOptions",
- value: function updateCurrentNetworkOptions(e) {
- Object.assign(this._currentNetworkOptions, e), Object.assign(this.options, e);
- }
- }, {
- key: "setCurrentState",
- value: function setCurrentState(e) {
- this._currentState = e;
- }
- }, {
- key: "updateCurrentState",
- value: function updateCurrentState(e) {
- e.skinId && (this.lastSkinId = this.currentState.skinId, this.updateCurrentNetworkOptions({
- skinId: e.skinId
- })), e.versionId && this.updateCurrentNetworkOptions({
- versionId: e.versionId
- }), Object.assign(this._currentState, e);
- }
- }]);
- return Xverse_Room;
- }(EventEmitter);
- 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); }; }
- 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; } }
- var XverseRoom = /*#__PURE__*/function (_Xverse_Room) {
- _inherits(XverseRoom, _Xverse_Room);
- var _super = _createSuper(XverseRoom);
- function XverseRoom(e) {
- var _this;
- _classCallCheck(this, XverseRoom);
- _this = _super.call(this, e);
- _this.joyStick = new JoyStick(_assertThisInitialized(_this));
- return _this;
- }
- _createClass(XverseRoom, [{
- key: "afterJoinRoomHook",
- value: function afterJoinRoomHook() {
- this.joyStick.init({});
- }
- }]);
- return XverseRoom;
- }(Xverse_Room);
- var Preload = /*#__PURE__*/function () {
- function Preload(e) {
- _classCallCheck(this, Preload);
- this.config = null;
- this.allKeys = [];
- this.oldResourcesDeleted = !1;
- this.requests = {
- simple: {
- stopped: !0,
- requests: {}
- },
- observer: {
- stopped: !0,
- requests: {}
- },
- full: {
- stopped: !0,
- requests: {}
- }
- };
- this.modelManager = e, this.init(e.appId);
- }
- _createClass(Preload, [{
- key: "init",
- value: function init(e) {
- reporter$1.updateBody({
- appId: e
- });
- }
- }, {
- key: "getConfig",
- value: function () {
- var _getConfig = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
- var _yield$this$modelMana, t;
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- if (!this.config) {
- _context.next = 2;
- break;
- }
- return _context.abrupt("return", this.config);
- case 2:
- _context.next = 4;
- return this.modelManager.requestConfig();
- case 4:
- _yield$this$modelMana = _context.sent;
- t = _yield$this$modelMana.preload;
- return _context.abrupt("return", t ? (this.config = t, Promise.resolve(t)) : Promise.reject("no preload config"));
- case 7:
- case "end":
- return _context.stop();
- }
- }
- }, _callee, this);
- }));
- function getConfig(_x) {
- return _getConfig.apply(this, arguments);
- }
- return getConfig;
- }()
- }, {
- key: "getAllKeys",
- value: function () {
- var _getAllKeys = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
- var e, t;
- return regenerator.wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- if (!this.allKeys.length) {
- _context2.next = 2;
- break;
- }
- return _context2.abrupt("return", this.allKeys);
- case 2:
- _context2.prev = 2;
- _context2.next = 5;
- return modelTable.getAllKeys();
- case 5:
- e = _context2.sent;
- this.allKeys = e;
- return _context2.abrupt("return", e);
- case 10:
- _context2.prev = 10;
- _context2.t0 = _context2["catch"](2);
- t = "preload getAllKeys error";
- return _context2.abrupt("return", (logger$1.error(t), Promise.reject(t)));
- case 14:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2, this, [[2, 10]]);
- }));
- function getAllKeys() {
- return _getAllKeys.apply(this, arguments);
- }
- return getAllKeys;
- }()
- }, {
- key: "stop",
- value: function stop(e) {
- e === "serverless" && (e = "observer"), this.requests[e].stopped = !0;
- var t = this.requests[e].requests;
- Object.keys(t).forEach(function (r) {
- http1.canceler.removePending(r), delete t[r];
- });
- }
- }, {
- key: "clearPreload",
- value: function clearPreload(e) {
- this.requests[e].stopped = !1, this.allKeys = [];
- }
- }, {
- key: "start",
- value: function () {
- var _start = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e, t, r) {
- var n, o, a, s, l, u, h, f, _s;
- return regenerator.wrap(function _callee3$(_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- n = Date.now(), o = 0;
- _context3.prev = 1;
- if (!(e === "serverless" && (e = "observer"), !this.requests[e])) {
- _context3.next = 4;
- break;
- }
- return _context3.abrupt("return", Promise.reject(new ParamError("invalid stage name: " + e)));
- case 4:
- this.clearPreload(e);
- _context3.next = 7;
- return this.getConfig(e);
- case 7:
- a = _context3.sent;
- _context3.next = 10;
- return this.getAllKeys();
- case 10:
- s = _context3.sent;
- _context3.prev = 11;
- _context3.next = 14;
- return this.deleteOldResources(a.assetUrls.map(function (d) {
- return d.url;
- }), s);
- case 14:
- _context3.next = 19;
- break;
- case 16:
- _context3.prev = 16;
- _context3.t0 = _context3["catch"](11);
- logger$1.error(_context3.t0);
- case 19:
- l = a.baseUrls, u = a.assetUrls;
- _context3.t1 = e;
- _context3.next = _context3.t1 === "simple" ? 23 : _context3.t1 === "observer" ? 25 : _context3.t1 === "full" ? 27 : 29;
- break;
- case 23:
- h = l;
- return _context3.abrupt("break", 30);
- case 25:
- h = u;
- return _context3.abrupt("break", 30);
- case 27:
- h = u;
- return _context3.abrupt("break", 30);
- case 29:
- h = u;
- case 30:
- f = h.filter(function (d) {
- return !s.includes(d.url);
- });
- r && isFunction(r) && (f = f.filter(r));
- o = f.length;
- logger$1.debug("keysNeedToPreload", f);
- f.length || t && t(h.length, h.length);
- n = Date.now();
- _context3.next = 38;
- return this._preload(e, f, t);
- case 38:
- logger$1.infoAndReportMeasurement({
- tag: e,
- startTime: n,
- metric: "assetsPreload",
- extra: {
- total: o
- }
- });
- return _context3.abrupt("return");
- case 42:
- _context3.prev = 42;
- _context3.t2 = _context3["catch"](1);
- _s = _context3.t2;
- return _context3.abrupt("return", ((this.requests[e].stopped || axios.isCancel(_context3.t2)) && (_s = new PreloadCanceledError()), logger$1.infoAndReportMeasurement({
- tag: e,
- startTime: n,
- metric: "assetsPreload",
- extra: {
- total: o
- },
- error: _s,
- reportOptions: {
- immediate: !0
- }
- }), Promise.reject(_s)));
- case 46:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee3, this, [[1, 42], [11, 16]]);
- }));
- function start(_x2, _x3, _x4) {
- return _start.apply(this, arguments);
- }
- return start;
- }()
- }, {
- key: "deleteOldResources",
- value: function deleteOldResources(e, t) {
- if (!this.oldResourcesDeleted) this.oldResourcesDeleted = !0;else return Promise.resolve();
- var r = t.filter(function (n) {
- return !e.includes(n);
- });
- return logger$1.debug("keysNeedToDelete", r), logger$1.warn("keysNeedToDelete", r.length), Promise.all(r.map(function (n) {
- return modelTable.delete(n);
- }));
- }
- }, {
- key: "_preload",
- value: function () {
- var _preload2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6(e, t, r) {
- var _this = this;
- var n, o, a;
- return regenerator.wrap(function _callee6$(_context6) {
- while (1) {
- switch (_context6.prev = _context6.next) {
- case 0:
- n = t.length;
- if (n) {
- _context6.next = 3;
- break;
- }
- return _context6.abrupt("return", Promise.resolve());
- case 3:
- o = 0;
- a = window.setInterval(function () {
- r && r(o, n), o >= n && window.clearInterval(a);
- }, 1e3);
- return _context6.abrupt("return", util.mapLimit(t, 10, /*#__PURE__*/function () {
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5(s) {
- var l, u;
- return regenerator.wrap(function _callee5$(_context5) {
- while (1) {
- switch (_context5.prev = _context5.next) {
- case 0:
- l = s.size, u = s.url;
- return _context5.abrupt("return", _this.requests[e].stopped ? Promise.reject(new PreloadCanceledError()) : http1.get({
- url: u,
- timeout: Preload.getTimeoutBySize(l),
- responseType: "blob",
- retry: 2,
- beforeRequest: function beforeRequest() {
- _this.requests[e].requests[u] = !0;
- }
- }).then( /*#__PURE__*/function () {
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(c) {
- var h, f;
- return regenerator.wrap(function _callee4$(_context4) {
- while (1) {
- switch (_context4.prev = _context4.next) {
- case 0:
- h = c.data;
- if (h instanceof Blob) {
- _context4.next = 3;
- break;
- }
- return _context4.abrupt("return", (logger$1.error("request blob failed, type:", typeof h, u), Promise.reject("request blob failed " + u)));
- case 3:
- _context4.next = 5;
- return blobToDataURI(h);
- case 5:
- f = _context4.sent;
- _context4.prev = 6;
- _context4.next = 9;
- return modelTable.put({
- url: u,
- model: f
- });
- case 9:
- return _context4.abrupt("return");
- case 12:
- _context4.prev = 12;
- _context4.t0 = _context4["catch"](6);
- return _context4.abrupt("return", (logger$1.error("unable to add data to indexedDB", _context4.t0), Promise.reject(new InternalError("preload db error"))));
- case 15:
- case "end":
- return _context4.stop();
- }
- }
- }, _callee4, null, [[6, 12]]);
- }));
- return function (_x9) {
- return _ref2.apply(this, arguments);
- };
- }()).then(function () {
- o++, delete _this.requests[e].requests[u];
- }, function (c) {
- return delete _this.requests[e].requests[u], window.clearInterval(a), Promise.reject(c);
- }));
- case 2:
- case "end":
- return _context5.stop();
- }
- }
- }, _callee5);
- }));
- return function (_x8) {
- return _ref.apply(this, arguments);
- };
- }()));
- case 6:
- case "end":
- return _context6.stop();
- }
- }
- }, _callee6);
- }));
- function _preload(_x5, _x6, _x7) {
- return _preload2.apply(this, arguments);
- }
- return _preload;
- }()
- }], [{
- key: "getTimeoutBySize",
- value: function getTimeoutBySize(e) {
- return e ? e < 500 * 1e3 ? 30 * 1e3 : e < 1e3 * 1e3 ? 60 * 1e3 : 100 * 1e3 : 100 * 1e3;
- }
- }]);
- return Preload;
- }();
- var RenderType$1 = {
- PathVideo: 0,
- RotationVideo: 1,
- RotationImage: 2,
- PanoramaImage: 3,
- CGVideo: 4,
- ClientRotationPano: 5,
- CloudRotationPano: 6
- };
- var Xverse = /*#__PURE__*/function () {
- function Xverse(e) {
- _classCallCheck(this, Xverse);
- e || (e = {});
- var _e = e,
- t = _e.onLog,
- r = _e.env,
- n = _e.appId,
- o = _e.releaseId,
- a = _e.subPackageVersion;
- this.NO_CACHE = !1, this.env = r || "PROD", this.SUB_PACKAGE_VERSION = a, this.debug && logger$1.setLevel(LoggerLevels.Debug);
- var s = this.pageSession = util.uuid();
- reporter$1.updateHeader({
- pageSession: s
- });
- reporter$1.updateReportUrl(REPORT_URL[this.env]);
- a && reporter$1.updateBody({
- sdkVersion: a
- });
- logger$1.infoAndReportMeasurement({
- metric: "sdkInit",
- startTime: Date.now(),
- extra: {
- version: a,
- enviroment: r,
- pageSession: s
- }
- });
- logger$1.debug("debug mode:", this.debug);
- reporter$1.on("report", function (l) {
- t && t(l);
- });
- if (n) {
- this.appId = n, this.releaseId = o;
- var l = ModelManager.getInstance(n, o);
- this.preload = new Preload(l);
- }
- }
- _createClass(Xverse, [{
- key: "isSupported",
- get: function get() {
- return isSupported();
- }
- }, {
- key: "disableLogUpload",
- value: function disableLogUpload() {
- reporter$1.disable(), logger$1.debug("logger upload has been disabled");
- }
- }, {
- key: "getSkinList",
- value: function () {
- var _getSkinList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- return _context.abrupt("return", []);
- case 1:
- case "end":
- return _context.stop();
- }
- }
- }, _callee);
- }));
- function getSkinList() {
- return _getSkinList.apply(this, arguments);
- }
- return getSkinList;
- }()
- }, {
- key: "getAvatarList",
- value: function () {
- var _getAvatarList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
- return regenerator.wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- return _context2.abrupt("return", []);
- case 1:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2);
- }));
- function getAvatarList() {
- return _getAvatarList.apply(this, arguments);
- }
- return getAvatarList;
- }()
- }, {
- key: "getGiftList",
- value: function () {
- var _getGiftList = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
- return regenerator.wrap(function _callee3$(_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- return _context3.abrupt("return", [{
- id: "hack "
- }]);
- case 1:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee3);
- }));
- function getGiftList() {
- return _getGiftList.apply(this, arguments);
- }
- return getGiftList;
- }()
- }, {
- key: "joinRoom",
- value: function () {
- var _joinRoom = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(e) {
- var t, r, n, o;
- return regenerator.wrap(function _callee4$(_context4) {
- while (1) {
- switch (_context4.prev = _context4.next) {
- case 0:
- t = e.pathName || "thirdwalk", r = e.rotationRenderType || RenderType$1.RotationVideo, n = e.person || Person$1.Third, o = new XverseRoom(le(oe({}, e), {
- appId: e.appId || this.appId,
- releaseId: e.releaseId || this.releaseId,
- pageSession: this.pageSession,
- isAllSync: !0,
- rotationRenderType: r,
- syncByEvent: !0,
- pathName: t,
- person: n,
- role: e.role || "audience"
- }));
- return _context4.abrupt("return", o.initRoom().then(function () {
- return o;
- }));
- case 2:
- case "end":
- return _context4.stop();
- }
- }
- }, _callee4, this);
- }));
- function joinRoom(_x) {
- return _joinRoom.apply(this, arguments);
- }
- return joinRoom;
- }()
- }]);
- return Xverse;
- }();
- var xverse = new Xverse({
- env: "DEV",
- appId: "10016",
- releaseId: '2203120033_29769e'
- });
- var l = /*#__PURE__*/function () {
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
- var R;
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- _context.prev = 0;
- _context.next = 3;
- return (R = xverse.preload) == null ? void 0 : R.start('full', function (M, x) {
- });
- case 3:
- _context.next = 12;
- break;
- case 5:
- _context.prev = 5;
- _context.t0 = _context["catch"](0);
- if (!(console.error(_context.t0), _context.t0.code === Codes.PreloadCanceled)) {
- _context.next = 10;
- break;
- }
- toast("\u9884\u52A0\u8F7D\u88AB\u53D6\u6D88");
- return _context.abrupt("return");
- case 10:
- toast("\u8FDB\u5165\u5931\u8D25, \u8BF7\u91CD\u8BD5");
- return _context.abrupt("return");
- case 12:
- _context.prev = 12;
- _context.next = 15;
- return xverse.joinRoom({
- canvas: document.getElementById('canvas'),
- skinId: '10092',
- avatarId: 'KGe_Boy',
- roomId: 'e629ef3e-022d-4e64-8654-703bb96410eb',
- userId: '1f7acca1db9d5',
- wsServerUrl: 'wss://uat-eks.xverse.cn/ws',
- appId: "10016",
- token: " ",
- nickname: '1f7acca1db9d5',
- firends: ["user1"],
- viewMode: "full",
- resolution: {
- width: 1728,
- height: 720
- },
- pathName: 'thirdwalk',
- objectFit: null,
- hasAvatar: !0,
- syncToOthers: !0
- });
- case 15:
- room = _context.sent;
- debugger;
- u();
- c();
- window.room = room;
- e(!1);
- _context.next = 28;
- break;
- case 23:
- _context.prev = 23;
- _context.t1 = _context["catch"](12);
- console.error(_context.t1);
- alert(_context.t1);
- return _context.abrupt("return");
- case 28:
- case "end":
- return _context.stop();
- }
- }
- }, _callee, null, [[0, 5], [12, 23]]);
- }));
- return function l() {
- return _ref.apply(this, arguments);
- };
- }();
- var u = function u() {
- room.on("_coreClick", function (_ref2) {
- var f = _ref2.point;
- room._userAvatar.moveTo({
- point: f
- });
- });
- };
- var c = function c() {
- room.on("repeatLogin", function () {
- toast("\u8BE5\u7528\u6237\u5DF2\u7ECF\u5728\u5176\u4ED6\u5730\u70B9\u767B\u5F55", {
- duration: 1e4
- });
- }), room.on("reconnecting", function (_ref3) {
- var f = _ref3.count;
- toast("\u5C1D\u8BD5\u7B2C".concat(f, "\u6B21\u91CD\u8FDE"));
- }), room.on("reconnected", function () {
- toast("\u91CD\u8FDE\u6210\u529F");
- }), room.on("disconnected", function () {
- var f = toast("\u8FDE\u63A5\u5931\u8D25\uFF0C\u624B\u52A8\u70B9\u51FB\u91CD\u8BD5", {
- duration: 1e5,
- onClick() {
- f.hideToast(), room.reconnect();
- }
- });
- });
- };
- l();
- }));
- //# sourceMappingURL=index.js.map
|