jsb-adapter_jsb-engine.js 203 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578
  1. (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
  2. module.exports={
  3. "O_RDONLY": 0,
  4. "O_WRONLY": 1,
  5. "O_RDWR": 2,
  6. "S_IFMT": 61440,
  7. "S_IFREG": 32768,
  8. "S_IFDIR": 16384,
  9. "S_IFCHR": 8192,
  10. "S_IFBLK": 24576,
  11. "S_IFIFO": 4096,
  12. "S_IFLNK": 40960,
  13. "S_IFSOCK": 49152,
  14. "O_CREAT": 512,
  15. "O_EXCL": 2048,
  16. "O_NOCTTY": 131072,
  17. "O_TRUNC": 1024,
  18. "O_APPEND": 8,
  19. "O_DIRECTORY": 1048576,
  20. "O_NOFOLLOW": 256,
  21. "O_SYNC": 128,
  22. "O_SYMLINK": 2097152,
  23. "O_NONBLOCK": 4,
  24. "S_IRWXU": 448,
  25. "S_IRUSR": 256,
  26. "S_IWUSR": 128,
  27. "S_IXUSR": 64,
  28. "S_IRWXG": 56,
  29. "S_IRGRP": 32,
  30. "S_IWGRP": 16,
  31. "S_IXGRP": 8,
  32. "S_IRWXO": 7,
  33. "S_IROTH": 4,
  34. "S_IWOTH": 2,
  35. "S_IXOTH": 1,
  36. "E2BIG": 7,
  37. "EACCES": 13,
  38. "EADDRINUSE": 48,
  39. "EADDRNOTAVAIL": 49,
  40. "EAFNOSUPPORT": 47,
  41. "EAGAIN": 35,
  42. "EALREADY": 37,
  43. "EBADF": 9,
  44. "EBADMSG": 94,
  45. "EBUSY": 16,
  46. "ECANCELED": 89,
  47. "ECHILD": 10,
  48. "ECONNABORTED": 53,
  49. "ECONNREFUSED": 61,
  50. "ECONNRESET": 54,
  51. "EDEADLK": 11,
  52. "EDESTADDRREQ": 39,
  53. "EDOM": 33,
  54. "EDQUOT": 69,
  55. "EEXIST": 17,
  56. "EFAULT": 14,
  57. "EFBIG": 27,
  58. "EHOSTUNREACH": 65,
  59. "EIDRM": 90,
  60. "EILSEQ": 92,
  61. "EINPROGRESS": 36,
  62. "EINTR": 4,
  63. "EINVAL": 22,
  64. "EIO": 5,
  65. "EISCONN": 56,
  66. "EISDIR": 21,
  67. "ELOOP": 62,
  68. "EMFILE": 24,
  69. "EMLINK": 31,
  70. "EMSGSIZE": 40,
  71. "EMULTIHOP": 95,
  72. "ENAMETOOLONG": 63,
  73. "ENETDOWN": 50,
  74. "ENETRESET": 52,
  75. "ENETUNREACH": 51,
  76. "ENFILE": 23,
  77. "ENOBUFS": 55,
  78. "ENODATA": 96,
  79. "ENODEV": 19,
  80. "ENOENT": 2,
  81. "ENOEXEC": 8,
  82. "ENOLCK": 77,
  83. "ENOLINK": 97,
  84. "ENOMEM": 12,
  85. "ENOMSG": 91,
  86. "ENOPROTOOPT": 42,
  87. "ENOSPC": 28,
  88. "ENOSR": 98,
  89. "ENOSTR": 99,
  90. "ENOSYS": 78,
  91. "ENOTCONN": 57,
  92. "ENOTDIR": 20,
  93. "ENOTEMPTY": 66,
  94. "ENOTSOCK": 38,
  95. "ENOTSUP": 45,
  96. "ENOTTY": 25,
  97. "ENXIO": 6,
  98. "EOPNOTSUPP": 102,
  99. "EOVERFLOW": 84,
  100. "EPERM": 1,
  101. "EPIPE": 32,
  102. "EPROTO": 100,
  103. "EPROTONOSUPPORT": 43,
  104. "EPROTOTYPE": 41,
  105. "ERANGE": 34,
  106. "EROFS": 30,
  107. "ESPIPE": 29,
  108. "ESRCH": 3,
  109. "ESTALE": 70,
  110. "ETIME": 101,
  111. "ETIMEDOUT": 60,
  112. "ETXTBSY": 26,
  113. "EWOULDBLOCK": 35,
  114. "EXDEV": 18,
  115. "SIGHUP": 1,
  116. "SIGINT": 2,
  117. "SIGQUIT": 3,
  118. "SIGILL": 4,
  119. "SIGTRAP": 5,
  120. "SIGABRT": 6,
  121. "SIGIOT": 6,
  122. "SIGBUS": 10,
  123. "SIGFPE": 8,
  124. "SIGKILL": 9,
  125. "SIGUSR1": 30,
  126. "SIGSEGV": 11,
  127. "SIGUSR2": 31,
  128. "SIGPIPE": 13,
  129. "SIGALRM": 14,
  130. "SIGTERM": 15,
  131. "SIGCHLD": 20,
  132. "SIGCONT": 19,
  133. "SIGSTOP": 17,
  134. "SIGTSTP": 18,
  135. "SIGTTIN": 21,
  136. "SIGTTOU": 22,
  137. "SIGURG": 16,
  138. "SIGXCPU": 24,
  139. "SIGXFSZ": 25,
  140. "SIGVTALRM": 26,
  141. "SIGPROF": 27,
  142. "SIGWINCH": 28,
  143. "SIGIO": 23,
  144. "SIGSYS": 12,
  145. "SSL_OP_ALL": 2147486719,
  146. "SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION": 262144,
  147. "SSL_OP_CIPHER_SERVER_PREFERENCE": 4194304,
  148. "SSL_OP_CISCO_ANYCONNECT": 32768,
  149. "SSL_OP_COOKIE_EXCHANGE": 8192,
  150. "SSL_OP_CRYPTOPRO_TLSEXT_BUG": 2147483648,
  151. "SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS": 2048,
  152. "SSL_OP_EPHEMERAL_RSA": 0,
  153. "SSL_OP_LEGACY_SERVER_CONNECT": 4,
  154. "SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER": 32,
  155. "SSL_OP_MICROSOFT_SESS_ID_BUG": 1,
  156. "SSL_OP_MSIE_SSLV2_RSA_PADDING": 0,
  157. "SSL_OP_NETSCAPE_CA_DN_BUG": 536870912,
  158. "SSL_OP_NETSCAPE_CHALLENGE_BUG": 2,
  159. "SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG": 1073741824,
  160. "SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG": 8,
  161. "SSL_OP_NO_COMPRESSION": 131072,
  162. "SSL_OP_NO_QUERY_MTU": 4096,
  163. "SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION": 65536,
  164. "SSL_OP_NO_SSLv2": 16777216,
  165. "SSL_OP_NO_SSLv3": 33554432,
  166. "SSL_OP_NO_TICKET": 16384,
  167. "SSL_OP_NO_TLSv1": 67108864,
  168. "SSL_OP_NO_TLSv1_1": 268435456,
  169. "SSL_OP_NO_TLSv1_2": 134217728,
  170. "SSL_OP_PKCS1_CHECK_1": 0,
  171. "SSL_OP_PKCS1_CHECK_2": 0,
  172. "SSL_OP_SINGLE_DH_USE": 1048576,
  173. "SSL_OP_SINGLE_ECDH_USE": 524288,
  174. "SSL_OP_SSLEAY_080_CLIENT_DH_BUG": 128,
  175. "SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG": 0,
  176. "SSL_OP_TLS_BLOCK_PADDING_BUG": 512,
  177. "SSL_OP_TLS_D5_BUG": 256,
  178. "SSL_OP_TLS_ROLLBACK_BUG": 8388608,
  179. "ENGINE_METHOD_DSA": 2,
  180. "ENGINE_METHOD_DH": 4,
  181. "ENGINE_METHOD_RAND": 8,
  182. "ENGINE_METHOD_ECDH": 16,
  183. "ENGINE_METHOD_ECDSA": 32,
  184. "ENGINE_METHOD_CIPHERS": 64,
  185. "ENGINE_METHOD_DIGESTS": 128,
  186. "ENGINE_METHOD_STORE": 256,
  187. "ENGINE_METHOD_PKEY_METHS": 512,
  188. "ENGINE_METHOD_PKEY_ASN1_METHS": 1024,
  189. "ENGINE_METHOD_ALL": 65535,
  190. "ENGINE_METHOD_NONE": 0,
  191. "DH_CHECK_P_NOT_SAFE_PRIME": 2,
  192. "DH_CHECK_P_NOT_PRIME": 1,
  193. "DH_UNABLE_TO_CHECK_GENERATOR": 4,
  194. "DH_NOT_SUITABLE_GENERATOR": 8,
  195. "NPN_ENABLED": 1,
  196. "RSA_PKCS1_PADDING": 1,
  197. "RSA_SSLV23_PADDING": 2,
  198. "RSA_NO_PADDING": 3,
  199. "RSA_PKCS1_OAEP_PADDING": 4,
  200. "RSA_X931_PADDING": 5,
  201. "RSA_PKCS1_PSS_PADDING": 6,
  202. "POINT_CONVERSION_COMPRESSED": 2,
  203. "POINT_CONVERSION_UNCOMPRESSED": 4,
  204. "POINT_CONVERSION_HYBRID": 6,
  205. "F_OK": 0,
  206. "R_OK": 4,
  207. "W_OK": 2,
  208. "X_OK": 1,
  209. "UV_UDP_REUSEADDR": 4
  210. }
  211. },{}],2:[function(require,module,exports){
  212. "use strict";
  213. cc.Assembler2D.prototype.updateWorldVerts = function (comp) {
  214. var local = this._local;
  215. var verts = this._renderData.vDatas[0];
  216. var vl = local[0],
  217. vr = local[2],
  218. vb = local[1],
  219. vt = local[3];
  220. var floatsPerVert = this.floatsPerVert;
  221. var vertexOffset = 0; // left bottom
  222. verts[vertexOffset] = vl;
  223. verts[vertexOffset + 1] = vb;
  224. vertexOffset += floatsPerVert; // right bottom
  225. verts[vertexOffset] = vr;
  226. verts[vertexOffset + 1] = vb;
  227. vertexOffset += floatsPerVert; // left top
  228. verts[vertexOffset] = vl;
  229. verts[vertexOffset + 1] = vt;
  230. vertexOffset += floatsPerVert; // right top
  231. verts[vertexOffset] = vr;
  232. verts[vertexOffset + 1] = vt;
  233. };
  234. var _updateColor = cc.Assembler2D.prototype.updateColor;
  235. cc.Assembler2D.prototype.updateColor = function (comp, color) {
  236. this._dirtyPtr[0] |= cc.Assembler.FLAG_VERTICES_OPACITY_CHANGED;
  237. _updateColor.call(this, comp, color);
  238. };
  239. },{}],3:[function(require,module,exports){
  240. "use strict";
  241. (function () {
  242. if (!cc.Assembler3D) return;
  243. cc.Assembler3D.updateWorldVerts = function (comp) {
  244. var local = this._local;
  245. var world = this._renderData.vDatas[0];
  246. var vl = local[0],
  247. vr = local[2],
  248. vb = local[1],
  249. vt = local[3]; // left bottom
  250. var floatsPerVert = this.floatsPerVert;
  251. var offset = 0;
  252. world[offset] = vl;
  253. world[offset + 1] = vb;
  254. world[offset + 2] = 0;
  255. offset += floatsPerVert; // right bottom
  256. world[offset] = vr;
  257. world[offset + 1] = vb;
  258. world[offset + 2] = 0;
  259. offset += floatsPerVert; // left top
  260. world[offset] = vl;
  261. world[offset + 1] = vt;
  262. world[offset + 2] = 0;
  263. offset += floatsPerVert; // right top
  264. world[offset] = vr;
  265. world[offset + 1] = vt;
  266. world[offset + 2] = 0;
  267. };
  268. })();
  269. },{}],4:[function(require,module,exports){
  270. "use strict";
  271. /****************************************************************************
  272. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  273. http://www.cocos.com
  274. Permission is hereby granted, free of charge, to any person obtaining a copy
  275. of this software and associated engine source code (the "Software"), a limited,
  276. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  277. to use Cocos Creator solely to develop games on your target platforms. You shall
  278. not use Cocos Creator software for developing other software or tools that's
  279. used for developing games. You are not granted to publish, distribute,
  280. sublicense, and/or sell copies of Cocos Creator.
  281. The software or tools in this License Agreement are licensed, not sold.
  282. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  283. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  284. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  285. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  286. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  287. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  288. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  289. THE SOFTWARE.
  290. ****************************************************************************/
  291. var RenderFlow = cc.RenderFlow;
  292. var originInit = cc.Assembler.prototype.init;
  293. var FLAG_VERTICES_OPACITY_CHANGED = 1 << 0;
  294. var FLAG_VERTICES_DIRTY = 1 << 1;
  295. var Assembler = {
  296. _ctor: function _ctor() {
  297. this._dirtyPtr = new Uint32Array(1);
  298. this.setDirty(this._dirtyPtr);
  299. this.initVertexFormat();
  300. },
  301. destroy: function destroy() {
  302. this._renderComp = null;
  303. this._effect = null;
  304. },
  305. clear: function clear() {
  306. this._renderData.clear();
  307. },
  308. _extendNative: function _extendNative() {
  309. renderer.Assembler.prototype.ctor.call(this);
  310. },
  311. initVertexFormat: function initVertexFormat() {
  312. var vfmt = this.getVfmt();
  313. if (!vfmt) return;
  314. this.setVertexFormat(vfmt._nativeObj);
  315. },
  316. init: function init(renderComp) {
  317. this._effect = [];
  318. originInit.call(this, renderComp);
  319. if (renderComp.node && renderComp.node._proxy) {
  320. renderComp.node._proxy.setAssembler(this);
  321. }
  322. },
  323. _updateRenderData: function _updateRenderData() {
  324. if (!this._renderComp || !this._renderComp.isValid) return;
  325. this.updateRenderData(this._renderComp);
  326. var materials = this._renderComp._materials;
  327. for (var i = 0; i < materials.length; i++) {
  328. var m = materials[i]; // TODO: find why material can be null
  329. if (!m) continue;
  330. m.getHash();
  331. this.updateMaterial(i, m);
  332. }
  333. },
  334. updateRenderData: function updateRenderData(comp) {
  335. comp._assembler.updateMaterial(0, comp._materials[0]);
  336. },
  337. updateMaterial: function updateMaterial(iaIndex, material) {
  338. var effect = material && material.effect;
  339. if (this._effect[iaIndex] !== effect) {
  340. this._effect[iaIndex] = effect;
  341. this.updateEffect(iaIndex, effect ? effect._nativeObj : null);
  342. }
  343. },
  344. updateColor: function updateColor(comp, color) {
  345. this._dirtyPtr[0] |= FLAG_VERTICES_OPACITY_CHANGED;
  346. },
  347. updateIADatas: function updateIADatas(iaIndex, meshIndex) {
  348. // When the MeshBuffer is switched, it is necessary to synchronize the iaData of the native assembler.
  349. this.updateMeshIndex(iaIndex, meshIndex);
  350. var materials = this._renderComp._materials;
  351. var material = materials[iaIndex] || materials[0];
  352. this.updateMaterial(iaIndex, material);
  353. }
  354. };
  355. cc.Assembler.FLAG_VERTICES_OPACITY_CHANGED = FLAG_VERTICES_OPACITY_CHANGED;
  356. cc.Assembler.FLAG_VERTICES_DIRTY = FLAG_VERTICES_DIRTY;
  357. Object.setPrototypeOf(cc.Assembler.prototype, renderer.Assembler.prototype);
  358. cc.js.mixin(cc.Assembler.prototype, Assembler);
  359. module.exports = Assembler;
  360. },{}],5:[function(require,module,exports){
  361. "use strict";
  362. var proto = cc.Graphics.__assembler__.prototype;
  363. var _init = proto.init;
  364. proto.init = function (renderComp) {
  365. _init.call(this, renderComp);
  366. this.ignoreOpacityFlag();
  367. };
  368. proto.genBuffer = function (graphics, cverts) {
  369. var buffers = this.getBuffers();
  370. var buffer = buffers[this._bufferOffset];
  371. var meshbuffer = buffer.meshbuffer;
  372. meshbuffer.requestStatic(cverts, cverts * 3);
  373. this._buffer = buffer;
  374. meshbuffer.setNativeAssembler(this);
  375. return buffer;
  376. };
  377. var _stroke = proto.stroke;
  378. proto.stroke = function (graphics) {
  379. _stroke.call(this, graphics);
  380. var buffer = this._buffer;
  381. buffer.meshbuffer.used(buffer.vertexStart, buffer.indiceStart);
  382. };
  383. var _fill = proto.fill;
  384. proto.fill = function (graphics) {
  385. _fill.call(this, graphics);
  386. var buffer = this._buffer;
  387. buffer.meshbuffer.used(buffer.vertexStart, buffer.indiceStart);
  388. };
  389. var _updateIADatas = proto.updateIADatas;
  390. proto.updateIADatas = function (iaIndex, meshIndex) {
  391. _updateIADatas.call(this, iaIndex, meshIndex); // Reset vertexStart and indiceStart when buffer is switched.
  392. this._buffer.vertexStart = 0;
  393. this._buffer.indiceStart = 0;
  394. };
  395. },{}],6:[function(require,module,exports){
  396. "use strict";
  397. /****************************************************************************
  398. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  399. http://www.cocos.com
  400. Permission is hereby granted, free of charge, to any person obtaining a copy
  401. of this software and associated engine source code (the "Software"), a limited,
  402. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  403. to use Cocos Creator solely to develop games on your target platforms. You shall
  404. not use Cocos Creator software for developing other software or tools that's
  405. used for developing games. You are not granted to publish, distribute,
  406. sublicense, and/or sell copies of Cocos Creator.
  407. The software or tools in this License Agreement are licensed, not sold.
  408. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  409. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  410. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  411. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  412. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  413. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  414. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  415. THE SOFTWARE.
  416. ****************************************************************************/
  417. var originReserveQuads = cc.Label.__assembler__.Bmfont.prototype._reserveQuads;
  418. Object.assign(cc.Label.__assembler__.Bmfont.prototype, {
  419. updateWorldVerts: function updateWorldVerts(comp) {
  420. var local = this._local;
  421. var world = this._renderData.vDatas[0];
  422. var floatsPerVert = this.floatsPerVert;
  423. for (var offset = 0, l = local.length; offset < l; offset += floatsPerVert) {
  424. world[offset] = local[offset];
  425. world[offset + 1] = local[offset + 1];
  426. }
  427. }
  428. });
  429. },{}],7:[function(require,module,exports){
  430. "use strict";
  431. (function () {
  432. if (!cc.Label.__assembler__.Bmfont3D) return;
  433. var proto = cc.Label.__assembler__.Bmfont3D.prototype;
  434. Object.assign(proto, {
  435. updateWorldVerts: function updateWorldVerts(comp) {
  436. var local = this._local;
  437. var world = this._renderData.vDatas[0];
  438. var floatsPerVert = this.floatsPerVert;
  439. for (var offset = 0, l = world.length; offset < l; offset += floatsPerVert) {
  440. world[offset] = local[offset];
  441. world[offset + 1] = local[offset + 1];
  442. world[offset + 2] = 0;
  443. }
  444. }
  445. });
  446. })();
  447. },{}],8:[function(require,module,exports){
  448. "use strict";
  449. (function () {
  450. if (!cc.Label.__assembler__.Letter3D) return;
  451. var proto = cc.Label.__assembler__.Letter3D.prototype;
  452. Object.assign(proto, {
  453. updateWorldVerts: function updateWorldVerts(comp) {
  454. var local = this._local;
  455. var world = this._renderData.vDatas[0];
  456. var floatsPerVert = this.floatsPerVert;
  457. for (var offset = 0, l = world.length; offset < l; offset += floatsPerVert) {
  458. world[offset] = local[offset];
  459. world[offset + 1] = local[offset + 1];
  460. world[offset + 2] = 0;
  461. }
  462. }
  463. });
  464. })();
  465. },{}],9:[function(require,module,exports){
  466. "use strict";
  467. (function () {
  468. if (!cc.Label.__assembler__.TTF3D) return;
  469. var proto = cc.Label.__assembler__.TTF3D.prototype;
  470. Object.assign(proto, {
  471. updateWorldVerts: cc.Assembler3D.updateWorldVerts
  472. });
  473. })();
  474. },{}],10:[function(require,module,exports){
  475. "use strict";
  476. /****************************************************************************
  477. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  478. http://www.cocos.com
  479. Permission is hereby granted, free of charge, to any person obtaining a copy
  480. of this software and associated engine source code (the "Software"), a limited,
  481. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  482. to use Cocos Creator solely to develop games on your target platforms. You shall
  483. not use Cocos Creator software for developing other software or tools that's
  484. used for developing games. You are not granted to publish, distribute,
  485. sublicense, and/or sell copies of Cocos Creator.
  486. The software or tools in this License Agreement are licensed, not sold.
  487. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  488. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  489. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  490. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  491. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  492. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  493. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  494. THE SOFTWARE.
  495. ****************************************************************************/
  496. require('./2d/bmfont.js');
  497. require('./3d/bmfont.js');
  498. require('./3d/ttf.js');
  499. require('./3d/letter.js');
  500. },{"./2d/bmfont.js":6,"./3d/bmfont.js":7,"./3d/letter.js":8,"./3d/ttf.js":9}],11:[function(require,module,exports){
  501. "use strict";
  502. /****************************************************************************
  503. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  504. http://www.cocos.com
  505. Permission is hereby granted, free of charge, to any person obtaining a copy
  506. of this software and associated engine source code (the "Software"), a limited,
  507. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  508. to use Cocos Creator solely to develop games on your target platforms. You shall
  509. not use Cocos Creator software for developing other software or tools that's
  510. used for developing games. You are not granted to publish, distribute,
  511. sublicense, and/or sell copies of Cocos Creator.
  512. The software or tools in this License Agreement are licensed, not sold.
  513. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  514. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  515. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  516. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  517. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  518. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  519. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  520. THE SOFTWARE.
  521. ****************************************************************************/
  522. var Mask = cc.Mask;
  523. var RenderFlow = cc.RenderFlow;
  524. var spriteAssembler = cc.Sprite.__assembler__.Simple.prototype;
  525. var graphicsAssembler = cc.Graphics.__assembler__.prototype;
  526. var proto = cc.Mask.__assembler__.prototype;
  527. var _updateRenderData = proto.updateRenderData; // Avoid constructor being overridden.
  528. renderer.MaskAssembler.prototype.constructor = cc.Mask.__assembler__;
  529. cc.js.mixin(proto, {
  530. _extendNative: function _extendNative() {
  531. renderer.MaskAssembler.prototype.ctor.call(this);
  532. },
  533. initLocal: function initLocal() {
  534. this._local = new Float32Array(4);
  535. renderer.MaskAssembler.prototype.setLocalData.call(this, this._local);
  536. },
  537. updateRenderData: function updateRenderData(mask) {
  538. _updateRenderData.call(this, mask);
  539. mask._clearGraphics._assembler.updateMaterial(0, mask._clearMaterial);
  540. this.setMaskInverted(mask.inverted);
  541. this.setUseModel(mask._type !== Mask.Type.IMAGE_STENCIL);
  542. this.setImageStencil(mask._type === Mask.Type.IMAGE_STENCIL);
  543. if (mask._graphics) {
  544. mask._graphics._assembler.setUseModel(mask._type !== Mask.Type.IMAGE_STENCIL);
  545. }
  546. mask.node._renderFlag |= cc.RenderFlow.FLAG_UPDATE_RENDER_DATA;
  547. }
  548. }, renderer.MaskAssembler.prototype);
  549. var originCreateGraphics = cc.Mask.prototype._createGraphics;
  550. var originRemoveGraphics = cc.Mask.prototype._removeGraphics;
  551. cc.js.mixin(cc.Mask.prototype, {
  552. _createGraphics: function _createGraphics() {
  553. originCreateGraphics.call(this);
  554. if (this._graphics) {
  555. this._assembler.setRenderSubHandle(this._graphics._assembler);
  556. } // TODO: remove clearGraphics
  557. if (!this._clearGraphics) {
  558. this._clearGraphics = new cc.Graphics();
  559. cc.Assembler.init(this._clearGraphics);
  560. this._clearGraphics.node = new cc.Node();
  561. this._clearGraphics._activateMaterial();
  562. this._clearGraphics.lineWidth = 0;
  563. this._clearGraphics.rect(-1, -1, 2, 2);
  564. this._clearGraphics.fill();
  565. this._clearGraphics._assembler.ignoreWorldMatrix();
  566. this._assembler.setClearSubHandle(this._clearGraphics._assembler);
  567. }
  568. },
  569. _removeGraphics: function _removeGraphics() {
  570. originRemoveGraphics.call(this); // TODO: remove clearGraphics
  571. if (this._clearGraphics) {
  572. this._clearGraphics.destroy();
  573. this._clearGraphics = null;
  574. }
  575. }
  576. });
  577. },{}],12:[function(require,module,exports){
  578. "use strict";
  579. (function () {
  580. var Mesh = cc.MeshRenderer;
  581. if (Mesh === undefined) return;
  582. var proto = cc.MeshRenderer.__assembler__.prototype;
  583. var _init = proto.init;
  584. cc.js.mixin(proto, {
  585. initVertexFormat: function initVertexFormat() {},
  586. _extendNative: function _extendNative() {
  587. renderer.MeshAssembler.prototype.ctor.call(this);
  588. },
  589. init: function init(comp) {
  590. _init.call(this, comp);
  591. this.updateMeshData(true);
  592. },
  593. setRenderNode: function setRenderNode(node) {
  594. this.setNode(node._proxy);
  595. },
  596. updateRenderData: function updateRenderData(comp) {
  597. this.updateMeshData();
  598. comp.node._renderFlag |= cc.RenderFlow.FLAG_UPDATE_RENDER_DATA;
  599. },
  600. updateMeshData: function updateMeshData(force) {
  601. var comp = this._renderComp;
  602. var mesh = comp.mesh;
  603. if (!mesh || !mesh.loaded) return;
  604. var subdatas = comp.mesh.subDatas;
  605. for (var i = 0, len = subdatas.length; i < len; i++) {
  606. var data = subdatas[i];
  607. if (force || data.vDirty || data.iDirty) {
  608. this.updateIAData(i, data.vfm._nativeObj, data.vData, data.iData);
  609. data.vDirty = false;
  610. data.iDirty = false;
  611. }
  612. }
  613. }
  614. }, renderer.MeshAssembler.prototype);
  615. })();
  616. },{}],13:[function(require,module,exports){
  617. "use strict";
  618. var proto = cc.MotionStreak.__assembler__.prototype;
  619. var _init = proto.init;
  620. var _update = proto.update;
  621. cc.js.mixin(proto, {
  622. init: function init(comp) {
  623. _init.call(this, comp);
  624. this.setUseModel(false);
  625. this.ignoreWorldMatrix();
  626. this.ignoreOpacityFlag();
  627. },
  628. update: function update(comp, dt) {
  629. comp.node._updateWorldMatrix();
  630. _update.call(this, comp, dt);
  631. var _this$_renderData$_fl = this._renderData._flexBuffer,
  632. iData = _this$_renderData$_fl.iData,
  633. usedVertices = _this$_renderData$_fl.usedVertices;
  634. var indiceOffset = 0;
  635. for (var i = 0, l = usedVertices; i < l; i += 2) {
  636. iData[indiceOffset++] = i;
  637. iData[indiceOffset++] = i + 2;
  638. iData[indiceOffset++] = i + 1;
  639. iData[indiceOffset++] = i + 1;
  640. iData[indiceOffset++] = i + 2;
  641. iData[indiceOffset++] = i + 3;
  642. }
  643. }
  644. });
  645. },{}],14:[function(require,module,exports){
  646. "use strict";
  647. (function () {
  648. var PS = cc.ParticleSystem3D;
  649. if (PS === undefined) return;
  650. var proto = PS.__assembler__.prototype;
  651. var _init = proto.init;
  652. var _updateRenderData = proto.updateRenderData;
  653. cc.js.mixin(proto, {
  654. initVertexFormat: function initVertexFormat() {},
  655. _extendNative: function _extendNative() {
  656. renderer.Particle3DAssembler.prototype.ctor.call(this);
  657. },
  658. init: function init(comp) {
  659. _init.call(this, comp);
  660. this._renderDataList = new renderer.RenderDataList();
  661. this.setRenderDataList(this._renderDataList);
  662. this.ignoreOpacityFlag();
  663. this.updateMeshData();
  664. this.setUseModel(true);
  665. },
  666. updateRenderData: function updateRenderData(comp) {
  667. _updateRenderData.call(this, comp);
  668. if (comp._vertsDirty) {
  669. this.updateMeshData();
  670. comp._vertsDirty = false;
  671. }
  672. },
  673. setRenderNode: function setRenderNode(node) {
  674. this.setNode(node._proxy);
  675. },
  676. updateMeshData: function updateMeshData() {
  677. if (!this._model) {
  678. return;
  679. }
  680. var subdatas = this._model._subDatas;
  681. for (var i = 0, len = subdatas.length; i < len; i++) {
  682. var data = subdatas[i];
  683. if (data.vDirty && data.enable) {
  684. this._renderDataList.updateMesh(i, data.vData, data.iData);
  685. }
  686. }
  687. this.setVertexFormat(subdatas[0].vfm._nativeObj);
  688. this.setSimulationSpace(this._particleSystem.simulationSpace);
  689. if (subdatas[1] && subdatas[1].enable) {
  690. this.setTrailVertexFormat(subdatas[1].vfm._nativeObj);
  691. this.setTrailModuleSpace(this._particleSystem.trailModule.space);
  692. }
  693. },
  694. setSimulationSpace: function setSimulationSpace(space) {
  695. this.setParticleSpace(space);
  696. },
  697. setTrailModuleSpace: function setTrailModuleSpace(space) {
  698. this.setTrailSpace(space);
  699. },
  700. updateIA: function updateIA(index, count, vDirty, iDirty) {
  701. this.updateIndicesRange(index, 0, count);
  702. }
  703. }, renderer.Particle3DAssembler.prototype);
  704. })();
  705. },{}],15:[function(require,module,exports){
  706. "use strict";
  707. /****************************************************************************
  708. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  709. http://www.cocos.com
  710. Permission is hereby granted, free of charge, to any person obtaining a copy
  711. of this software and associated engine source code (the "Software"), a limited,
  712. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  713. to use Cocos Creator solely to develop games on your target platforms. You shall
  714. not use Cocos Creator software for developing other software or tools that's
  715. used for developing games. You are not granted to publish, distribute,
  716. sublicense, and/or sell copies of Cocos Creator.
  717. The software or tools in this License Agreement are licensed, not sold.
  718. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  719. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  720. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  721. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  722. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  723. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  724. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  725. THE SOFTWARE.
  726. ****************************************************************************/
  727. Object.assign(cc.Sprite.__assembler__.Mesh.prototype, {
  728. updateWorldVerts: function updateWorldVerts(sprite) {
  729. var local = this._local;
  730. var world = this._renderData.vDatas[0];
  731. var floatsPerVert = this.floatsPerVert;
  732. for (var i = 0, l = local.length / 2; i < l; i++) {
  733. world[i * floatsPerVert] = local[i * 2];
  734. world[i * floatsPerVert + 1] = local[i * 2 + 1];
  735. }
  736. }
  737. });
  738. },{}],16:[function(require,module,exports){
  739. "use strict";
  740. /****************************************************************************
  741. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  742. http://www.cocos.com
  743. Permission is hereby granted, free of charge, to any person obtaining a copy
  744. of this software and associated engine source code (the "Software"), a limited,
  745. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  746. to use Cocos Creator solely to develop games on your target platforms. You shall
  747. not use Cocos Creator software for developing other software or tools that's
  748. used for developing games. You are not granted to publish, distribute,
  749. sublicense, and/or sell copies of Cocos Creator.
  750. The software or tools in this License Agreement are licensed, not sold.
  751. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  752. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  753. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  754. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  755. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  756. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  757. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  758. THE SOFTWARE.
  759. ****************************************************************************/
  760. Object.assign(cc.Sprite.__assembler__.RadialFilled.prototype, {
  761. updateWorldVerts: function updateWorldVerts(sprite) {
  762. var local = this._local;
  763. var world = this._renderData.vDatas[0];
  764. var floatsPerVert = this.floatsPerVert;
  765. for (var offset = 0, l = world.length; offset < l; offset += floatsPerVert) {
  766. world[offset] = local[offset];
  767. world[offset + 1] = local[offset + 1];
  768. }
  769. }
  770. });
  771. },{}],17:[function(require,module,exports){
  772. "use strict";
  773. /****************************************************************************
  774. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  775. http://www.cocos.com
  776. Permission is hereby granted, free of charge, to any person obtaining a copy
  777. of this software and associated engine source code (the "Software"), a limited,
  778. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  779. to use Cocos Creator solely to develop games on your target platforms. You shall
  780. not use Cocos Creator software for developing other software or tools that's
  781. used for developing games. You are not granted to publish, distribute,
  782. sublicense, and/or sell copies of Cocos Creator.
  783. The software or tools in this License Agreement are licensed, not sold.
  784. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  785. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  786. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  787. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  788. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  789. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  790. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  791. THE SOFTWARE.
  792. ****************************************************************************/
  793. var proto = cc.Sprite.__assembler__.Simple.prototype;
  794. var nativeProto = renderer.SimpleSprite2D.prototype;
  795. proto.updateWorldVerts = function (comp) {
  796. this._dirtyPtr[0] |= cc.Assembler.FLAG_VERTICES_DIRTY;
  797. };
  798. proto._extendNative = function () {
  799. nativeProto.ctor.call(this);
  800. };
  801. proto.initLocal = function () {
  802. this._local = new Float32Array(4);
  803. nativeProto.setLocalData.call(this, this._local);
  804. };
  805. },{}],18:[function(require,module,exports){
  806. "use strict";
  807. /****************************************************************************
  808. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  809. http://www.cocos.com
  810. Permission is hereby granted, free of charge, to any person obtaining a copy
  811. of this software and associated engine source code (the "Software"), a limited,
  812. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  813. to use Cocos Creator solely to develop games on your target platforms. You shall
  814. not use Cocos Creator software for developing other software or tools that's
  815. used for developing games. You are not granted to publish, distribute,
  816. sublicense, and/or sell copies of Cocos Creator.
  817. The software or tools in this License Agreement are licensed, not sold.
  818. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  819. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  820. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  821. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  822. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  823. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  824. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  825. THE SOFTWARE.
  826. ****************************************************************************/
  827. var proto = cc.Sprite.__assembler__.Sliced.prototype;
  828. var nativeProto = renderer.SlicedSprite2D.prototype;
  829. proto.updateWorldVerts = function (comp) {
  830. this._dirtyPtr[0] |= cc.Assembler.FLAG_VERTICES_DIRTY;
  831. };
  832. proto._extendNative = function () {
  833. nativeProto.ctor.call(this);
  834. };
  835. proto.initLocal = function () {
  836. this._local = new Float32Array(8);
  837. nativeProto.setLocalData.call(this, this._local);
  838. };
  839. },{}],19:[function(require,module,exports){
  840. "use strict";
  841. /****************************************************************************
  842. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  843. http://www.cocos.com
  844. Permission is hereby granted, free of charge, to any person obtaining a copy
  845. of this software and associated engine source code (the "Software"), a limited,
  846. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  847. to use Cocos Creator solely to develop games on your target platforms. You shall
  848. not use Cocos Creator software for developing other software or tools that's
  849. used for developing games. You are not granted to publish, distribute,
  850. sublicense, and/or sell copies of Cocos Creator.
  851. The software or tools in this License Agreement are licensed, not sold.
  852. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  853. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  854. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  855. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  856. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  857. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  858. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  859. THE SOFTWARE.
  860. ****************************************************************************/
  861. Object.assign(cc.Sprite.__assembler__.Tiled.prototype, {
  862. updateWorldVerts: function updateWorldVerts(sprite) {
  863. var renderData = this._renderData;
  864. var local = this._local;
  865. var localX = local.x,
  866. localY = local.y;
  867. var world = renderData.vDatas[0];
  868. var row = this.row,
  869. col = this.col;
  870. var x, x1, y, y1;
  871. var floatsPerVert = this.floatsPerVert;
  872. var vertexOffset = 0;
  873. for (var yindex = 0, ylength = row; yindex < ylength; ++yindex) {
  874. y = localY[yindex];
  875. y1 = localY[yindex + 1];
  876. for (var xindex = 0, xlength = col; xindex < xlength; ++xindex) {
  877. x = localX[xindex];
  878. x1 = localX[xindex + 1]; // lb
  879. world[vertexOffset] = x;
  880. world[vertexOffset + 1] = y;
  881. vertexOffset += floatsPerVert; // rb
  882. world[vertexOffset] = x1;
  883. world[vertexOffset + 1] = y;
  884. vertexOffset += floatsPerVert; // lt
  885. world[vertexOffset] = x;
  886. world[vertexOffset + 1] = y1;
  887. vertexOffset += floatsPerVert; // rt
  888. world[vertexOffset] = x1;
  889. world[vertexOffset + 1] = y1;
  890. vertexOffset += floatsPerVert;
  891. }
  892. }
  893. }
  894. });
  895. },{}],20:[function(require,module,exports){
  896. "use strict";
  897. (function () {
  898. if (!cc.Sprite.__assembler__.BarFilled3D) return;
  899. var proto = cc.Sprite.__assembler__.BarFilled3D.prototype;
  900. Object.assign(proto, {
  901. updateWorldVerts: cc.Assembler3D.updateWorldVerts
  902. });
  903. })();
  904. },{}],21:[function(require,module,exports){
  905. "use strict";
  906. (function () {
  907. if (!cc.Sprite.__assembler__.Mesh3D) return;
  908. var proto = cc.Sprite.__assembler__.Mesh3D.prototype;
  909. Object.assign(proto, {
  910. updateWorldVerts: function updateWorldVerts(sprite) {
  911. var local = this._local;
  912. var world = this._renderData.vDatas[0];
  913. var floatsPerVert = this.floatsPerVert,
  914. offset = 0;
  915. for (var i = 0, j = 0, l = local.length / 2; i < l; i++, offset += floatsPerVert) {
  916. j = i * 2;
  917. world[offset] = local[j];
  918. world[offset + 1] = local[j + 1];
  919. world[offset + 2] = 0;
  920. }
  921. }
  922. });
  923. })();
  924. },{}],22:[function(require,module,exports){
  925. "use strict";
  926. (function () {
  927. if (!cc.Sprite.__assembler__.RadialFilled3D) return;
  928. var proto = cc.Sprite.__assembler__.RadialFilled3D.prototype;
  929. Object.assign(proto, {
  930. updateWorldVerts: function updateWorldVerts(sprite) {
  931. var local = this._local;
  932. var world = this._renderData.vDatas[0];
  933. var floatsPerVert = this.floatsPerVert;
  934. for (var offset = 0, l = world.length; offset < l; offset += floatsPerVert) {
  935. world[offset] = local[offset];
  936. world[offset + 1] = local[offset + 1];
  937. world[offset + 2] = 0;
  938. }
  939. }
  940. });
  941. })();
  942. },{}],23:[function(require,module,exports){
  943. "use strict";
  944. (function () {
  945. if (!cc.Sprite.__assembler__.Simple3D) return;
  946. var proto = cc.Sprite.__assembler__.Simple3D.prototype;
  947. var nativeProto = renderer.SimpleSprite3D.prototype;
  948. Object.assign(proto, {
  949. _extendNative: nativeProto.ctor
  950. });
  951. })();
  952. },{}],24:[function(require,module,exports){
  953. "use strict";
  954. (function () {
  955. if (!cc.Sprite.__assembler__.Sliced3D) return;
  956. var proto = cc.Sprite.__assembler__.Sliced3D.prototype;
  957. var nativeProto = renderer.SlicedSprite3D.prototype;
  958. Object.assign(proto, {
  959. _extendNative: nativeProto.ctor
  960. });
  961. })();
  962. },{}],25:[function(require,module,exports){
  963. "use strict";
  964. (function () {
  965. if (!cc.Sprite.__assembler__.Tiled3D) return;
  966. var proto = cc.Sprite.__assembler__.Tiled3D.prototype;
  967. Object.assign(proto, {
  968. updateWorldVerts: function updateWorldVerts(sprite) {
  969. var local = this._local;
  970. var localX = local.x,
  971. localY = local.y;
  972. var world = this._renderData.vDatas[0];
  973. var row = this.row,
  974. col = this.col;
  975. var x, x1, y, y1;
  976. var vertexOffset = 0;
  977. for (var yindex = 0, ylength = row; yindex < ylength; ++yindex) {
  978. y = localY[yindex];
  979. y1 = localY[yindex + 1];
  980. for (var xindex = 0, xlength = col; xindex < xlength; ++xindex) {
  981. x = localX[xindex];
  982. x1 = localX[xindex + 1]; // left bottom
  983. var padding = 6;
  984. world[vertexOffset] = x;
  985. world[vertexOffset + 1] = y;
  986. world[vertexOffset + 2] = 0;
  987. vertexOffset += padding; // right bottom
  988. world[vertexOffset] = x1;
  989. world[vertexOffset + 1] = y;
  990. world[vertexOffset + 2] = 0;
  991. vertexOffset += padding; // left top
  992. world[vertexOffset] = x;
  993. world[vertexOffset + 1] = y1;
  994. world[vertexOffset + 2] = 0;
  995. vertexOffset += padding; // right top
  996. world[vertexOffset] = x1;
  997. world[vertexOffset + 1] = y1;
  998. world[vertexOffset + 2] = 0;
  999. vertexOffset += padding;
  1000. }
  1001. }
  1002. }
  1003. });
  1004. })();
  1005. },{}],26:[function(require,module,exports){
  1006. "use strict";
  1007. /****************************************************************************
  1008. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  1009. http://www.cocos.com
  1010. Permission is hereby granted, free of charge, to any person obtaining a copy
  1011. of this software and associated engine source code (the "Software"), a limited,
  1012. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  1013. to use Cocos Creator solely to develop games on your target platforms. You shall
  1014. not use Cocos Creator software for developing other software or tools that's
  1015. used for developing games. You are not granted to publish, distribute,
  1016. sublicense, and/or sell copies of Cocos Creator.
  1017. The software or tools in this License Agreement are licensed, not sold.
  1018. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  1019. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1020. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1021. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1022. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1023. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1024. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1025. THE SOFTWARE.
  1026. ****************************************************************************/
  1027. require('./2d/sliced.js');
  1028. require('./2d/tiled.js');
  1029. require('./2d/radial-filled.js');
  1030. require('./2d/simple.js');
  1031. require('./2d/mesh.js');
  1032. require('./3d/sliced.js');
  1033. require('./3d/simple.js');
  1034. require('./3d/tiled.js');
  1035. require('./3d/mesh.js');
  1036. require('./3d/bar-filled.js');
  1037. require('./3d/radial-filled.js');
  1038. },{"./2d/mesh.js":15,"./2d/radial-filled.js":16,"./2d/simple.js":17,"./2d/sliced.js":18,"./2d/tiled.js":19,"./3d/bar-filled.js":20,"./3d/mesh.js":21,"./3d/radial-filled.js":22,"./3d/simple.js":23,"./3d/sliced.js":24,"./3d/tiled.js":25}],27:[function(require,module,exports){
  1039. "use strict";
  1040. /****************************************************************************
  1041. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  1042. http://www.cocos.com
  1043. Permission is hereby granted, free of charge, to any person obtaining a copy
  1044. of this software and associated engine source code (the "Software"), a limited,
  1045. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  1046. to use Cocos Creator solely to develop games on your target platforms. You shall
  1047. not use Cocos Creator software for developing other software or tools that's
  1048. used for developing games. You are not granted to publish, distribute,
  1049. sublicense, and/or sell copies of Cocos Creator.
  1050. The software or tools in this License Agreement are licensed, not sold.
  1051. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  1052. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1053. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1054. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1055. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1056. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1057. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1058. THE SOFTWARE.
  1059. ****************************************************************************/
  1060. require('./jsb-sys.js');
  1061. require('./jsb-game.js');
  1062. require('./jsb-videoplayer.js');
  1063. require('./jsb-webview.js');
  1064. require('./jsb-audio.js');
  1065. require('./jsb-loader.js');
  1066. require('./jsb-editbox.js');
  1067. require('./jsb-reflection.js');
  1068. require('./jsb-assets-manager.js');
  1069. require('./jsb-safearea.js');
  1070. if (CC_NATIVERENDERER) {
  1071. require('./jsb-effect.js');
  1072. require('./jsb-effect-variant.js');
  1073. require('./scene/camera.js');
  1074. require('./scene/light.js');
  1075. require('./scene/node-proxy.js');
  1076. require('./scene/render-flow.js'); // must be required after render flow
  1077. require('./scene/node.js');
  1078. cc.game.on(cc.game.EVENT_ENGINE_INITED, function () {
  1079. require('./scene/mesh-buffer.js');
  1080. require('./scene/quad-buffer.js');
  1081. require('./scene/render-data.js');
  1082. require('./assemblers/assembler.js');
  1083. require('./assemblers/assembler-2d.js');
  1084. require('./assemblers/assembler-3d.js');
  1085. require('./assemblers/sprite/index.js');
  1086. require('./assemblers/label/index.js');
  1087. require('./assemblers/mask-assembler.js');
  1088. require('./assemblers/graphics-assembler.js');
  1089. require('./assemblers/motion-streak.js');
  1090. require('./assemblers/mesh-renderer.js');
  1091. require('./assemblers/particle-3d-assembler.js');
  1092. require('./jsb-dragonbones.js');
  1093. require('./jsb-spine-skeleton.js');
  1094. require('./jsb-particle.js');
  1095. require('./jsb-tiledmap.js');
  1096. require('./jsb-skin-mesh.js');
  1097. });
  1098. }
  1099. },{"./assemblers/assembler-2d.js":2,"./assemblers/assembler-3d.js":3,"./assemblers/assembler.js":4,"./assemblers/graphics-assembler.js":5,"./assemblers/label/index.js":10,"./assemblers/mask-assembler.js":11,"./assemblers/mesh-renderer.js":12,"./assemblers/motion-streak.js":13,"./assemblers/particle-3d-assembler.js":14,"./assemblers/sprite/index.js":26,"./jsb-assets-manager.js":28,"./jsb-audio.js":29,"./jsb-dragonbones.js":31,"./jsb-editbox.js":32,"./jsb-effect-variant.js":33,"./jsb-effect.js":34,"./jsb-game.js":36,"./jsb-loader.js":37,"./jsb-particle.js":38,"./jsb-reflection.js":39,"./jsb-safearea.js":40,"./jsb-skin-mesh.js":41,"./jsb-spine-skeleton.js":42,"./jsb-sys.js":43,"./jsb-tiledmap.js":44,"./jsb-videoplayer.js":45,"./jsb-webview.js":46,"./scene/camera.js":47,"./scene/light.js":48,"./scene/mesh-buffer.js":49,"./scene/node-proxy.js":50,"./scene/node.js":51,"./scene/quad-buffer.js":52,"./scene/render-data.js":53,"./scene/render-flow.js":54}],28:[function(require,module,exports){
  1100. "use strict";
  1101. /*
  1102. * Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  1103. *
  1104. * Permission is hereby granted, free of charge, to any person obtaining a copy
  1105. * of this software and associated documentation files (the "Software"), to deal
  1106. * in the Software without restriction, including without limitation the rights
  1107. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1108. * copies of the Software, and to permit persons to whom the Software is
  1109. * furnished to do so, subject to the following conditions:
  1110. *
  1111. * The above copyright notice and this permission notice shall be included in
  1112. * all copies or substantial portions of the Software.
  1113. *
  1114. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1115. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1116. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1117. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1118. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1119. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1120. * THE SOFTWARE.
  1121. */
  1122. if (jsb.AssetsManager) {
  1123. jsb.AssetsManager.State = {
  1124. UNINITED: 0,
  1125. UNCHECKED: 1,
  1126. PREDOWNLOAD_VERSION: 2,
  1127. DOWNLOADING_VERSION: 3,
  1128. VERSION_LOADED: 4,
  1129. PREDOWNLOAD_MANIFEST: 5,
  1130. DOWNLOADING_MANIFEST: 6,
  1131. MANIFEST_LOADED: 7,
  1132. NEED_UPDATE: 8,
  1133. READY_TO_UPDATE: 9,
  1134. UPDATING: 10,
  1135. UNZIPPING: 11,
  1136. UP_TO_DATE: 12,
  1137. FAIL_TO_UPDATE: 13
  1138. };
  1139. jsb.Manifest.DownloadState = {
  1140. UNSTARTED: 0,
  1141. DOWNLOADING: 1,
  1142. SUCCESSED: 2,
  1143. UNMARKED: 3
  1144. };
  1145. jsb.EventAssetsManager.ERROR_NO_LOCAL_MANIFEST = 0;
  1146. jsb.EventAssetsManager.ERROR_DOWNLOAD_MANIFEST = 1;
  1147. jsb.EventAssetsManager.ERROR_PARSE_MANIFEST = 2;
  1148. jsb.EventAssetsManager.NEW_VERSION_FOUND = 3;
  1149. jsb.EventAssetsManager.ALREADY_UP_TO_DATE = 4;
  1150. jsb.EventAssetsManager.UPDATE_PROGRESSION = 5;
  1151. jsb.EventAssetsManager.ASSET_UPDATED = 6;
  1152. jsb.EventAssetsManager.ERROR_UPDATING = 7;
  1153. jsb.EventAssetsManager.UPDATE_FINISHED = 8;
  1154. jsb.EventAssetsManager.UPDATE_FAILED = 9;
  1155. jsb.EventAssetsManager.ERROR_DECOMPRESS = 10;
  1156. }
  1157. },{}],29:[function(require,module,exports){
  1158. "use strict";
  1159. /****************************************************************************
  1160. Copyright (c) 2013-2016 Chukong Technologies Inc.
  1161. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  1162. http://www.cocos.com
  1163. Permission is hereby granted, free of charge, to any person obtaining a copy
  1164. of this software and associated engine source code (the "Software"), a limited,
  1165. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  1166. to use Cocos Creator solely to develop games on your target platforms. You shall
  1167. not use Cocos Creator software for developing other software or tools that's
  1168. used for developing games. You are not granted to publish, distribute,
  1169. sublicense, and/or sell copies of Cocos Creator.
  1170. The software or tools in this License Agreement are licensed, not sold.
  1171. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  1172. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1173. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1174. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1175. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1176. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1177. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1178. THE SOFTWARE.
  1179. ****************************************************************************/
  1180. var cacheManager = require('./jsb-cache-manager');
  1181. var Audio = cc._Audio = function (src) {
  1182. this.src = src;
  1183. this.volume = 1;
  1184. this.loop = false;
  1185. this.id = -1;
  1186. };
  1187. var handleVolume = function handleVolume(volume) {
  1188. if (volume === undefined) {
  1189. // set default volume as 1
  1190. volume = 1;
  1191. } else if (typeof volume === 'string') {
  1192. volume = Number.parseFloat(volume);
  1193. }
  1194. return volume;
  1195. };
  1196. (function (proto, audioEngine) {
  1197. if (!audioEngine) return; // Using the new audioEngine
  1198. cc.audioEngine = audioEngine;
  1199. audioEngine.setMaxWebAudioSize = function () {};
  1200. Audio.State = audioEngine.AudioState;
  1201. proto.play = function () {
  1202. audioEngine.stop(this.id);
  1203. var clip = this.src;
  1204. this.id = audioEngine.play(clip, this.loop, this.volume);
  1205. };
  1206. proto.pause = function () {
  1207. audioEngine.pause(this.id);
  1208. };
  1209. proto.resume = function () {
  1210. audioEngine.resume(this.id);
  1211. };
  1212. proto.stop = function () {
  1213. audioEngine.stop(this.id);
  1214. };
  1215. proto.destroy = function () {};
  1216. proto.setLoop = function (loop) {
  1217. this.loop = loop;
  1218. audioEngine.setLoop(this.id, loop);
  1219. };
  1220. proto.getLoop = function () {
  1221. return this.loop;
  1222. };
  1223. proto.setVolume = function (volume) {
  1224. volume = handleVolume(volume);
  1225. this.volume = volume;
  1226. return audioEngine.setVolume(this.id, volume);
  1227. };
  1228. proto.getVolume = function () {
  1229. return this.volume;
  1230. };
  1231. proto.setCurrentTime = function (time) {
  1232. audioEngine.setCurrentTime(this.id, time);
  1233. };
  1234. proto.getCurrentTime = function () {
  1235. return audioEngine.getCurrentTime(this.id);
  1236. };
  1237. proto.getDuration = function () {
  1238. return audioEngine.getDuration(this.id);
  1239. };
  1240. proto.getState = function () {
  1241. return audioEngine.getState(this.id);
  1242. }; // polyfill audioEngine
  1243. var _music = {
  1244. id: -1,
  1245. clip: '',
  1246. loop: false,
  1247. volume: 1
  1248. };
  1249. var _effect = {
  1250. volume: 1
  1251. };
  1252. audioEngine.play = function (clip, loop, volume) {
  1253. if (typeof volume !== 'number') {
  1254. volume = 1;
  1255. }
  1256. var audioFilePath;
  1257. if (typeof clip === 'string') {
  1258. // backward compatibility since 1.10
  1259. cc.warnID(8401, 'cc.audioEngine', 'cc.AudioClip', 'AudioClip', 'cc.AudioClip', 'audio');
  1260. audioFilePath = clip;
  1261. } else {
  1262. if (clip.loaded) {
  1263. audioFilePath = clip._nativeAsset;
  1264. } else {
  1265. // audio delay loading
  1266. clip._nativeAsset = audioFilePath = cacheManager.getCache(clip.nativeUrl) || clip.nativeUrl;
  1267. clip.loaded = true;
  1268. }
  1269. }
  1270. return audioEngine.play2d(audioFilePath, loop, volume);
  1271. };
  1272. audioEngine.playMusic = function (clip, loop) {
  1273. audioEngine.stop(_music.id);
  1274. _music.id = audioEngine.play(clip, loop, _music.volume);
  1275. _music.loop = loop;
  1276. _music.clip = clip;
  1277. return _music.id;
  1278. };
  1279. audioEngine.stopMusic = function () {
  1280. audioEngine.stop(_music.id);
  1281. };
  1282. audioEngine.pauseMusic = function () {
  1283. audioEngine.pause(_music.id);
  1284. return _music.id;
  1285. };
  1286. audioEngine.resumeMusic = function () {
  1287. audioEngine.resume(_music.id);
  1288. return _music.id;
  1289. };
  1290. audioEngine.getMusicVolume = function () {
  1291. return _music.volume;
  1292. };
  1293. audioEngine.setMusicVolume = function (volume) {
  1294. _music.volume = handleVolume(volume);
  1295. audioEngine.setVolume(_music.id, _music.volume);
  1296. return volume;
  1297. };
  1298. audioEngine.isMusicPlaying = function () {
  1299. return audioEngine.getState(_music.id) === audioEngine.AudioState.PLAYING;
  1300. };
  1301. audioEngine.playEffect = function (filePath, loop) {
  1302. return audioEngine.play(filePath, loop || false, _effect.volume);
  1303. };
  1304. audioEngine.setEffectsVolume = function (volume) {
  1305. _effect.volume = handleVolume(volume);
  1306. };
  1307. audioEngine.getEffectsVolume = function () {
  1308. return _effect.volume;
  1309. };
  1310. audioEngine.pauseEffect = function (audioID) {
  1311. return audioEngine.pause(audioID);
  1312. };
  1313. audioEngine.pauseAllEffects = function () {
  1314. var musicPlay = audioEngine.getState(_music.id) === audioEngine.AudioState.PLAYING;
  1315. audioEngine.pauseAll();
  1316. if (musicPlay) {
  1317. audioEngine.resume(_music.id);
  1318. }
  1319. };
  1320. audioEngine.resumeEffect = function (id) {
  1321. audioEngine.resume(id);
  1322. };
  1323. audioEngine.resumeAllEffects = function () {
  1324. var musicPaused = audioEngine.getState(_music.id) === audioEngine.AudioState.PAUSED;
  1325. audioEngine.resumeAll();
  1326. if (musicPaused && audioEngine.getState(_music.id) === audioEngine.AudioState.PLAYING) {
  1327. audioEngine.pause(_music.id);
  1328. }
  1329. };
  1330. audioEngine.stopEffect = function (id) {
  1331. return audioEngine.stop(id);
  1332. };
  1333. audioEngine.stopAllEffects = function () {
  1334. var musicPlaying = audioEngine.getState(_music.id) === audioEngine.AudioState.PLAYING;
  1335. var currentTime = audioEngine.getCurrentTime(_music.id);
  1336. audioEngine.stopAll();
  1337. if (musicPlaying) {
  1338. _music.id = audioEngine.play(_music.clip, _music.loop);
  1339. audioEngine.setCurrentTime(_music.id, currentTime);
  1340. }
  1341. }; // Unnecessary on native platform
  1342. audioEngine._break = function () {};
  1343. audioEngine._restore = function () {}; // deprecated
  1344. audioEngine._uncache = audioEngine.uncache;
  1345. audioEngine.uncache = function (clip) {
  1346. var path;
  1347. if (typeof clip === 'string') {
  1348. // backward compatibility since 1.10
  1349. cc.warnID(8401, 'cc.audioEngine', 'cc.AudioClip', 'AudioClip', 'cc.AudioClip', 'audio');
  1350. path = clip;
  1351. } else {
  1352. if (!clip) {
  1353. return;
  1354. }
  1355. path = clip._nativeAsset;
  1356. }
  1357. audioEngine._uncache(path);
  1358. };
  1359. audioEngine._preload = audioEngine.preload;
  1360. audioEngine.preload = function (filePath, callback) {
  1361. cc.warn('`cc.audioEngine.preload` is deprecated, use `cc.assetManager.loadRes(url, cc.AudioClip)` instead please.');
  1362. audioEngine._preload(filePath, callback);
  1363. };
  1364. })(Audio.prototype, jsb.AudioEngine);
  1365. },{"./jsb-cache-manager":30}],30:[function(require,module,exports){
  1366. "use strict";
  1367. /****************************************************************************
  1368. Copyright (c) 2019 Xiamen Yaji Software Co., Ltd.
  1369. https://www.cocos.com/
  1370. Permission is hereby granted, free of charge, to any person obtaining a copy
  1371. of cache-manager software and associated engine source code (the "Software"), a limited,
  1372. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  1373. to use Cocos Creator solely to develop games on your target platforms. You shall
  1374. not use Cocos Creator software for developing other software or tools that's
  1375. used for developing games. You are not granted to publish, distribute,
  1376. sublicense, and/or sell copies of Cocos Creator.
  1377. The software or tools in cache-manager License Agreement are licensed, not sold.
  1378. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  1379. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1380. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1381. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1382. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1383. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1384. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1385. THE SOFTWARE.
  1386. ****************************************************************************/
  1387. var _require = require('./jsb-fs-utils'),
  1388. getUserDataPath = _require.getUserDataPath,
  1389. readJsonSync = _require.readJsonSync,
  1390. makeDirSync = _require.makeDirSync,
  1391. writeFileSync = _require.writeFileSync,
  1392. writeFile = _require.writeFile,
  1393. deleteFile = _require.deleteFile,
  1394. rmdirSync = _require.rmdirSync;
  1395. var writeCacheFileList = null;
  1396. var startWrite = false;
  1397. var nextCallbacks = [];
  1398. var callbacks = [];
  1399. var cleaning = false;
  1400. var REGEX = /^\w+:\/\/.*/;
  1401. var cacheManager = {
  1402. cacheDir: 'gamecaches',
  1403. cachedFileName: 'cacheList.json',
  1404. deleteInterval: 500,
  1405. writeFileInterval: 2000,
  1406. cachedFiles: null,
  1407. version: '1.1',
  1408. getCache: function getCache(url) {
  1409. this.updateLastTime(url);
  1410. return this.cachedFiles.has(url) ? "".concat(this.cacheDir, "/").concat(this.cachedFiles.get(url).url) : '';
  1411. },
  1412. getTemp: function getTemp(url) {
  1413. return '';
  1414. },
  1415. init: function init() {
  1416. this.cacheDir = getUserDataPath() + '/' + this.cacheDir;
  1417. var cacheFilePath = this.cacheDir + '/' + this.cachedFileName;
  1418. var result = readJsonSync(cacheFilePath);
  1419. if (result instanceof Error || !result.version || result.version !== this.version) {
  1420. if (!(result instanceof Error)) rmdirSync(this.cacheDir, true);
  1421. this.cachedFiles = new cc.AssetManager.Cache();
  1422. makeDirSync(this.cacheDir, true);
  1423. writeFileSync(cacheFilePath, JSON.stringify({
  1424. files: this.cachedFiles._map,
  1425. version: this.version
  1426. }), 'utf8');
  1427. } else {
  1428. this.cachedFiles = new cc.AssetManager.Cache(result.files);
  1429. }
  1430. },
  1431. updateLastTime: function updateLastTime(url) {
  1432. if (this.cachedFiles.has(url)) {
  1433. var cache = this.cachedFiles.get(url);
  1434. cache.lastTime = Date.now();
  1435. }
  1436. },
  1437. _write: function _write() {
  1438. writeCacheFileList = null;
  1439. startWrite = true;
  1440. writeFile(this.cacheDir + '/' + this.cachedFileName, JSON.stringify({
  1441. files: this.cachedFiles._map,
  1442. version: this.version
  1443. }), 'utf8', function () {
  1444. startWrite = false;
  1445. for (var i = 0, j = callbacks.length; i < j; i++) {
  1446. callbacks[i]();
  1447. }
  1448. callbacks.length = 0;
  1449. callbacks.push.apply(callbacks, nextCallbacks);
  1450. nextCallbacks.length = 0;
  1451. });
  1452. },
  1453. writeCacheFile: function writeCacheFile(cb) {
  1454. if (!writeCacheFileList) {
  1455. writeCacheFileList = setTimeout(this._write.bind(this), this.writeFileInterval);
  1456. if (startWrite === true) {
  1457. cb && nextCallbacks.push(cb);
  1458. } else {
  1459. cb && callbacks.push(cb);
  1460. }
  1461. } else {
  1462. cb && callbacks.push(cb);
  1463. }
  1464. },
  1465. cacheFile: function cacheFile(id, url, cacheBundleRoot) {
  1466. this.cachedFiles.add(id, {
  1467. bundle: cacheBundleRoot,
  1468. url: url,
  1469. lastTime: Date.now()
  1470. });
  1471. this.writeCacheFile();
  1472. },
  1473. clearCache: function clearCache() {
  1474. var _this = this;
  1475. rmdirSync(this.cacheDir, true);
  1476. this.cachedFiles = new cc.AssetManager.Cache();
  1477. makeDirSync(this.cacheDir, true);
  1478. var cacheFilePath = this.cacheDir + '/' + this.cachedFileName;
  1479. writeFileSync(cacheFilePath, JSON.stringify({
  1480. files: this.cachedFiles._map,
  1481. version: this.version
  1482. }), 'utf8');
  1483. cc.assetManager.bundles.forEach(function (bundle) {
  1484. if (REGEX.test(bundle.base)) _this.makeBundleFolder(bundle.name);
  1485. });
  1486. },
  1487. clearLRU: function clearLRU() {
  1488. var _this2 = this;
  1489. if (cleaning) return;
  1490. cleaning = true;
  1491. var caches = [];
  1492. var self = this;
  1493. this.cachedFiles.forEach(function (val, key) {
  1494. if (val.bundle === 'internal') return;
  1495. caches.push({
  1496. originUrl: key,
  1497. url: _this2.getCache(key),
  1498. lastTime: val.lastTime
  1499. });
  1500. });
  1501. caches.sort(function (a, b) {
  1502. return a.lastTime - b.lastTime;
  1503. });
  1504. caches.length = Math.floor(this.cachedFiles.count / 3);
  1505. if (caches.length === 0) return;
  1506. for (var i = 0, l = caches.length; i < l; i++) {
  1507. this.cachedFiles.remove(caches[i].originUrl);
  1508. }
  1509. this.writeCacheFile(function () {
  1510. function deferredDelete() {
  1511. var item = caches.pop();
  1512. deleteFile(item.url);
  1513. if (caches.length > 0) {
  1514. setTimeout(deferredDelete, self.deleteInterval);
  1515. } else {
  1516. cleaning = false;
  1517. }
  1518. }
  1519. setTimeout(deferredDelete, self.deleteInterval);
  1520. });
  1521. },
  1522. removeCache: function removeCache(url) {
  1523. if (this.cachedFiles.has(url)) {
  1524. var path = this.getCache(url);
  1525. this.cachedFiles.remove(url);
  1526. this.writeCacheFile(function () {
  1527. deleteFile(path);
  1528. });
  1529. }
  1530. },
  1531. makeBundleFolder: function makeBundleFolder(bundleName) {
  1532. makeDirSync(this.cacheDir + '/' + bundleName, true);
  1533. }
  1534. };
  1535. cc.assetManager.cacheManager = module.exports = cacheManager;
  1536. },{"./jsb-fs-utils":35}],31:[function(require,module,exports){
  1537. "use strict";
  1538. var _constants = require("constants");
  1539. /****************************************************************************
  1540. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  1541. http://www.cocos.com
  1542. Permission is hereby granted, free of charge, to any person obtaining a copy
  1543. of this software and associated engine source code (the "Software"), a limited,
  1544. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  1545. to use Cocos Creator solely to develop games on your target platforms. You shall
  1546. not use Cocos Creator software for developing other software or tools that's
  1547. used for developing games. You are not granted to publish, distribute,
  1548. sublicense, and/or sell copies of Cocos Creator.
  1549. The software or tools in this License Agreement are licensed, not sold.
  1550. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  1551. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1552. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1553. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1554. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1555. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1556. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1557. THE SOFTWARE.
  1558. ****************************************************************************/
  1559. var cacheManager = require('./jsb-cache-manager');
  1560. (function () {
  1561. if (window.dragonBones === undefined || window.middleware === undefined) return;
  1562. if (dragonBones.DragonBonesAtlasAsset === undefined) return; // dragonbones global time scale.
  1563. Object.defineProperty(dragonBones, 'timeScale', {
  1564. get: function get() {
  1565. return this._timeScale;
  1566. },
  1567. set: function set(value) {
  1568. this._timeScale = value;
  1569. var factory = this.CCFactory.getInstance();
  1570. factory.setTimeScale(value);
  1571. },
  1572. configurable: true
  1573. });
  1574. jsb.generateGetSet(dragonBones);
  1575. var _slotColor = cc.color(0, 0, 255, 255);
  1576. var _boneColor = cc.color(255, 0, 0, 255);
  1577. var _originColor = cc.color(0, 255, 0, 255); ////////////////////////////////////////////////////////////
  1578. // override dragonBones library by native dragonBones
  1579. ////////////////////////////////////////////////////////////
  1580. //--------------------
  1581. // adapt event name
  1582. //--------------------
  1583. dragonBones.EventObject.START = "start";
  1584. dragonBones.EventObject.LOOP_COMPLETE = "loopComplete";
  1585. dragonBones.EventObject.COMPLETE = "complete";
  1586. dragonBones.EventObject.FADE_IN = "fadeIn";
  1587. dragonBones.EventObject.FADE_IN_COMPLETE = "fadeInComplete";
  1588. dragonBones.EventObject.FADE_OUT = "fadeOut";
  1589. dragonBones.EventObject.FADE_OUT_COMPLETE = "fadeOutComplete";
  1590. dragonBones.EventObject.FRAME_EVENT = "frameEvent";
  1591. dragonBones.EventObject.SOUND_EVENT = "soundEvent";
  1592. dragonBones.DragonBones = {
  1593. ANGLE_TO_RADIAN: Math.PI / 180,
  1594. RADIAN_TO_ANGLE: 180 / Math.PI
  1595. }; //-------------------
  1596. // native factory
  1597. //-------------------
  1598. var factoryProto = dragonBones.CCFactory.prototype;
  1599. factoryProto.createArmatureNode = function (comp, armatureName, node) {
  1600. node = node || new cc.Node();
  1601. var display = node.getComponent(dragonBones.ArmatureDisplay);
  1602. if (!display) {
  1603. display = node.addComponent(dragonBones.ArmatureDisplay);
  1604. }
  1605. node.name = armatureName;
  1606. display._armatureName = armatureName;
  1607. display._N$dragonAsset = comp.dragonAsset;
  1608. display._N$dragonAtlasAsset = comp.dragonAtlasAsset;
  1609. display._init();
  1610. return display;
  1611. };
  1612. var _replaceSkin = factoryProto.replaceSkin;
  1613. factoryProto.replaceSkin = function (armatrue, skinData, isOverride, exclude) {
  1614. if (isOverride == undefined) isOverride = false;
  1615. exclude = exclude || [];
  1616. _replaceSkin.call(this, armatrue, skinData, isOverride, exclude);
  1617. };
  1618. var _changeSkin = factoryProto.changeSkin;
  1619. factoryProto.changeSkin = function (armatrue, skinData, exclude) {
  1620. _changeSkin.call(this, armatrue, skinData, exclude);
  1621. }; //-------------------
  1622. // native animation state
  1623. //-------------------
  1624. var animationStateProto = dragonBones.AnimationState.prototype;
  1625. var _isPlaying = animationStateProto.isPlaying;
  1626. Object.defineProperty(animationStateProto, 'isPlaying', {
  1627. get: function get() {
  1628. return _isPlaying.call(this);
  1629. }
  1630. }); //-------------------
  1631. // native armature
  1632. //-------------------
  1633. var armatureProto = dragonBones.Armature.prototype;
  1634. armatureProto.addEventListener = function (eventType, listener, target) {
  1635. if (!this.__persistentDisplay__) {
  1636. this.__persistentDisplay__ = this.getDisplay();
  1637. }
  1638. this.__persistentDisplay__.on(eventType, listener, target);
  1639. };
  1640. armatureProto.removeEventListener = function (eventType, listener, target) {
  1641. if (!this.__persistentDisplay__) {
  1642. this.__persistentDisplay__ = this.getDisplay();
  1643. }
  1644. this.__persistentDisplay__.off(eventType, listener, target);
  1645. }; //--------------------------
  1646. // native CCArmatureDisplay
  1647. //--------------------------
  1648. var nativeArmatureDisplayProto = dragonBones.CCArmatureDisplay.prototype;
  1649. Object.defineProperty(nativeArmatureDisplayProto, "node", {
  1650. get: function get() {
  1651. return this;
  1652. }
  1653. });
  1654. nativeArmatureDisplayProto.getRootNode = function () {
  1655. var rootDisplay = this.getRootDisplay();
  1656. return rootDisplay && rootDisplay._ccNode;
  1657. };
  1658. nativeArmatureDisplayProto.convertToWorldSpace = function (point) {
  1659. var newPos = this.convertToRootSpace(point);
  1660. newPos = cc.v2(newPos.x, newPos.y);
  1661. var ccNode = this.getRootNode();
  1662. if (!ccNode) return newPos;
  1663. var finalPos = ccNode.convertToWorldSpaceAR(newPos);
  1664. return finalPos;
  1665. };
  1666. nativeArmatureDisplayProto.initEvent = function () {
  1667. if (this._eventTarget) {
  1668. return;
  1669. }
  1670. this._eventTarget = new cc.EventTarget();
  1671. this.setDBEventCallback(function (eventObject) {
  1672. this._eventTarget.emit(eventObject.type, eventObject);
  1673. });
  1674. };
  1675. nativeArmatureDisplayProto.on = function (type, listener, target) {
  1676. this.initEvent();
  1677. this._eventTarget.on(type, listener, target);
  1678. this.addDBEventListener(type, listener);
  1679. };
  1680. nativeArmatureDisplayProto.off = function (type, listener, target) {
  1681. this.initEvent();
  1682. this._eventTarget.off(type, listener, target);
  1683. this.removeDBEventListener(type, listener);
  1684. };
  1685. nativeArmatureDisplayProto.once = function (type, listener, target) {
  1686. this.initEvent();
  1687. this._eventTarget.once(type, listener, target);
  1688. this.addDBEventListener(type, listener);
  1689. }; ////////////////////////////////////////////////////////////
  1690. // override DragonBonesAtlasAsset
  1691. ////////////////////////////////////////////////////////////
  1692. var dbAtlas = dragonBones.DragonBonesAtlasAsset.prototype;
  1693. var _gTextureIdx = 1;
  1694. var _textureKeyMap = {};
  1695. var _textureMap = new WeakMap();
  1696. var _textureIdx2Name = {};
  1697. dbAtlas.removeRecordTexture = function (texture) {
  1698. if (!texture) return;
  1699. delete _textureIdx2Name[texture.url];
  1700. var index = texture.__textureIndex__;
  1701. if (index) {
  1702. var texKey = _textureKeyMap[index];
  1703. if (texKey && _textureMap.has(texKey)) {
  1704. _textureMap["delete"](texKey);
  1705. delete _textureKeyMap[index];
  1706. }
  1707. }
  1708. };
  1709. dbAtlas.recordTexture = function () {
  1710. if (this._texture && this._oldTexture !== this._texture) {
  1711. this.removeRecordTexture(this._oldTexture);
  1712. var texKey = _textureKeyMap[_gTextureIdx] = {
  1713. key: _gTextureIdx
  1714. };
  1715. _textureMap.set(texKey, this._texture);
  1716. this._oldTexture = this._texture;
  1717. this._texture.__textureIndex__ = _gTextureIdx;
  1718. _gTextureIdx++;
  1719. }
  1720. };
  1721. dbAtlas.getTextureByIndex = function (textureIdx) {
  1722. var texKey = _textureKeyMap[textureIdx];
  1723. if (!texKey) return;
  1724. return _textureMap.get(texKey);
  1725. };
  1726. dbAtlas.updateTextureAtlasData = function (factory) {
  1727. var url = this._texture.url;
  1728. var preAtlasInfo = _textureIdx2Name[url];
  1729. var index; // If the texture has store the atlas info before,then get native atlas object,and
  1730. // update script texture map.
  1731. if (preAtlasInfo) {
  1732. index = preAtlasInfo.index;
  1733. this._textureAtlasData = factory.getTextureAtlasDataByIndex(preAtlasInfo.name, index);
  1734. var texKey = _textureKeyMap[preAtlasInfo.index];
  1735. _textureMap.set(texKey, this._texture);
  1736. this._texture.__textureIndex__ = index; // If script has store the atlas info,but native has no atlas object,then
  1737. // still new native texture2d object,but no call recordTexture to increase
  1738. // textureIndex.
  1739. if (this._textureAtlasData) {
  1740. return;
  1741. }
  1742. } else {
  1743. this.recordTexture();
  1744. }
  1745. index = this._texture.__textureIndex__;
  1746. this.jsbTexture = new middleware.Texture2D();
  1747. this.jsbTexture.setRealTextureIndex(index);
  1748. this.jsbTexture.setPixelsWide(this._texture.width);
  1749. this.jsbTexture.setPixelsHigh(this._texture.height);
  1750. this._textureAtlasData = factory.parseTextureAtlasData(this.atlasJson, this.jsbTexture, this._uuid);
  1751. this.jsbTexture.setNativeTexture(this._texture.getImpl());
  1752. _textureIdx2Name[url] = {
  1753. name: this._textureAtlasData.name,
  1754. index: index
  1755. };
  1756. };
  1757. dbAtlas.init = function (factory) {
  1758. this._factory = factory; // If create by manual, uuid is empty.
  1759. if (!this._uuid) {
  1760. var atlasJsonObj = JSON.parse(this.atlasJson);
  1761. this._uuid = atlasJsonObj.name;
  1762. }
  1763. if (this._textureAtlasData) {
  1764. factory.addTextureAtlasData(this._textureAtlasData, this._uuid);
  1765. } else {
  1766. this.updateTextureAtlasData(factory);
  1767. }
  1768. };
  1769. dbAtlas._clear = function (dontRecordTexture) {
  1770. if (this._factory) {
  1771. this._factory.removeTextureAtlasData(this._uuid, true);
  1772. this._factory.removeDragonBonesDataByUUID(this._uuid, true);
  1773. }
  1774. this._textureAtlasData = null;
  1775. if (!dontRecordTexture) {
  1776. this.recordTexture();
  1777. }
  1778. };
  1779. dbAtlas.destroy = function () {
  1780. this.removeRecordTexture(this._texture);
  1781. this._clear(true);
  1782. cc.Asset.prototype.destroy.call(this);
  1783. }; ////////////////////////////////////////////////////////////
  1784. // override DragonBonesAsset
  1785. ////////////////////////////////////////////////////////////
  1786. var dbAsset = dragonBones.DragonBonesAsset.prototype;
  1787. dbAsset.init = function (factory, atlasUUID) {
  1788. this._factory = factory; // If create by manual, uuid is empty.
  1789. // Only support json format, if remote load dbbin, must set uuid by manual.
  1790. if (!this._uuid && this.dragonBonesJson) {
  1791. var rawData = JSON.parse(this.dragonBonesJson);
  1792. this._uuid = rawData.name;
  1793. }
  1794. var armatureKey = this._uuid + "#" + atlasUUID;
  1795. var dragonBonesData = this._factory.getDragonBonesData(armatureKey);
  1796. if (dragonBonesData) return armatureKey;
  1797. var filePath = null;
  1798. if (this.dragonBonesJson) {
  1799. filePath = this.dragonBonesJson;
  1800. } else {
  1801. filePath = cacheManager.getCache(this.nativeUrl) || this.nativeUrl;
  1802. }
  1803. this._factory.parseDragonBonesDataByPath(filePath, armatureKey);
  1804. return armatureKey;
  1805. };
  1806. var armatureCacheMgr = dragonBones.ArmatureCacheMgr.getInstance();
  1807. dragonBones.armatureCacheMgr = armatureCacheMgr;
  1808. dbAsset._clear = function () {
  1809. if (this._factory) {
  1810. this._factory.removeDragonBonesDataByUUID(this._uuid, true);
  1811. }
  1812. armatureCacheMgr.removeArmatureCache(this._uuid);
  1813. }; ////////////////////////////////////////////////////////////
  1814. // adapt attach util
  1815. ////////////////////////////////////////////////////////////
  1816. var attachUtilProto = dragonBones.AttachUtil.prototype;
  1817. var _attachUtilInit = attachUtilProto.init;
  1818. attachUtilProto.init = function (armatureDisplay) {
  1819. _attachUtilInit.call(this, armatureDisplay);
  1820. this._nativeDisplay = armatureDisplay._nativeDisplay;
  1821. this._attachUtilNative = null;
  1822. };
  1823. var _generateAllAttachedNodes = attachUtilProto.generateAllAttachedNodes;
  1824. attachUtilProto.generateAllAttachedNodes = function () {
  1825. var res = _generateAllAttachedNodes.call(this);
  1826. this._associateAttachedNode();
  1827. return res;
  1828. };
  1829. var _generateAttachedNodes = attachUtilProto.generateAttachedNodes;
  1830. attachUtilProto.generateAttachedNodes = function (boneName) {
  1831. var res = _generateAttachedNodes.call(this, boneName);
  1832. this._associateAttachedNode();
  1833. return res;
  1834. };
  1835. var _associateAttachedNode = attachUtilProto._associateAttachedNode;
  1836. attachUtilProto._associateAttachedNode = function () {
  1837. if (!this._inited) return;
  1838. var rootNode = this._armatureNode.getChildByName('ATTACHED_NODE_TREE');
  1839. if (!rootNode || !rootNode.isValid) return; // associate js
  1840. _associateAttachedNode.call(this); // associate native
  1841. if (!this._attachUtilNative) {
  1842. if (this._armatureDisplay.isAnimationCached()) {
  1843. this._attachUtilNative = new dragonBones.CacheModeAttachUtil();
  1844. } else {
  1845. this._attachUtilNative = new dragonBones.RealTimeAttachUtil();
  1846. }
  1847. this._nativeDisplay.setAttachUtil(this._attachUtilNative);
  1848. }
  1849. this._attachUtilNative.associateAttachedNode(this._armature, this._armatureNode._proxy);
  1850. }; ////////////////////////////////////////////////////////////
  1851. // override ArmatureDisplay
  1852. ////////////////////////////////////////////////////////////
  1853. dragonBones.ArmatureDisplay._assembler = null;
  1854. var armatureDisplayProto = dragonBones.ArmatureDisplay.prototype;
  1855. var renderCompProto = cc.RenderComponent.prototype;
  1856. var AnimationCacheMode = dragonBones.ArmatureDisplay.AnimationCacheMode;
  1857. Object.defineProperty(armatureDisplayProto, 'armatureName', {
  1858. get: function get() {
  1859. return this._armatureName;
  1860. },
  1861. set: function set(value) {
  1862. this._armatureName = value;
  1863. var animNames = this.getAnimationNames(this._armatureName);
  1864. if (!this.animationName || animNames.indexOf(this.animationName) < 0) {
  1865. this.animationName = '';
  1866. }
  1867. var oldArmature = this._armature;
  1868. if (this._armature) {
  1869. if (!this.isAnimationCached()) {
  1870. this._factory.remove(this._armature);
  1871. }
  1872. this._armature = null;
  1873. }
  1874. this._nativeDisplay = null;
  1875. this._refresh();
  1876. if (oldArmature && oldArmature != this._armature) {
  1877. oldArmature.dispose();
  1878. }
  1879. if (this._armature && !this.isAnimationCached()) {
  1880. this._factory.add(this._armature);
  1881. }
  1882. },
  1883. visible: false
  1884. });
  1885. Object.defineProperty(armatureDisplayProto, "premultipliedAlpha", {
  1886. get: function get() {
  1887. if (this._premultipliedAlpha === undefined) {
  1888. return false;
  1889. }
  1890. return this._premultipliedAlpha;
  1891. },
  1892. set: function set(value) {
  1893. this._premultipliedAlpha = value;
  1894. if (this._nativeDisplay) {
  1895. this._nativeDisplay.setOpacityModifyRGB(this._premultipliedAlpha);
  1896. }
  1897. }
  1898. });
  1899. var _initDebugDraw = armatureDisplayProto._initDebugDraw;
  1900. armatureDisplayProto._initDebugDraw = function () {
  1901. _initDebugDraw.call(this);
  1902. if (this._armature && !this.isAnimationCached()) {
  1903. this._nativeDisplay.setDebugBonesEnabled(this.debugBones);
  1904. }
  1905. };
  1906. var _updateBatch = armatureDisplayProto._updateBatch;
  1907. armatureDisplayProto._updateBatch = function () {
  1908. _updateBatch.call(this);
  1909. if (this._nativeDisplay) {
  1910. this._nativeDisplay.setBatchEnabled(this.enableBatch);
  1911. }
  1912. this._assembler && this._assembler.clearEffect();
  1913. };
  1914. armatureDisplayProto._clearRenderData = function () {
  1915. this._nativeDisplay = null;
  1916. };
  1917. armatureDisplayProto._resetAssembler = function () {
  1918. this._assembler = new renderer.CustomAssembler();
  1919. this.node._proxy.setAssembler(this._assembler);
  1920. };
  1921. var _updateMaterial = armatureDisplayProto._updateMaterial;
  1922. var _materialHash2IDMap = {};
  1923. var _materialId = 1;
  1924. armatureDisplayProto._updateMaterial = function () {
  1925. _updateMaterial.call(this);
  1926. this._assembler && this._assembler.clearEffect();
  1927. var baseMaterial = this.getMaterial(0);
  1928. if (this._nativeDisplay && baseMaterial) {
  1929. var originHash = baseMaterial.effect.getHash();
  1930. var id = _materialHash2IDMap[originHash] || _materialId++;
  1931. _materialHash2IDMap[originHash] = id;
  1932. baseMaterial.effect.updateHash(id);
  1933. var nativeEffect = baseMaterial.effect._nativeObj;
  1934. this._nativeDisplay.setEffect(nativeEffect);
  1935. }
  1936. };
  1937. armatureDisplayProto._buildArmature = function () {
  1938. if (!this.dragonAsset || !this.dragonAtlasAsset || !this.armatureName) {
  1939. this._clearRenderData();
  1940. return;
  1941. }
  1942. if (this._nativeDisplay) {
  1943. this._nativeDisplay.dispose();
  1944. this._nativeDisplay._comp = null;
  1945. this._nativeDisplay = null;
  1946. }
  1947. var atlasUUID = this.dragonAtlasAsset._uuid;
  1948. this._armatureKey = this.dragonAsset.init(this._factory, atlasUUID);
  1949. if (this.isAnimationCached()) {
  1950. this._nativeDisplay = new dragonBones.CCArmatureCacheDisplay(this.armatureName, this._armatureKey, atlasUUID, this._cacheMode == AnimationCacheMode.SHARED_CACHE);
  1951. this._armature = this._nativeDisplay.armature();
  1952. } else {
  1953. this._nativeDisplay = this._factory.buildArmatureDisplay(this.armatureName, this._armatureKey, "", atlasUUID);
  1954. if (!this._nativeDisplay) {
  1955. this._clearRenderData();
  1956. return;
  1957. }
  1958. this._nativeDisplay.setDebugBonesEnabled(this.debugBones);
  1959. this._armature = this._nativeDisplay.armature();
  1960. this._armature.animation.timeScale = this.timeScale;
  1961. this._factory.add(this._armature);
  1962. } // add all event into native display
  1963. var callbackTable = this._eventTarget._callbackTable; // just use to adapt to native api
  1964. var emptyHandle = function emptyHandle() {};
  1965. for (var key in callbackTable) {
  1966. var list = callbackTable[key];
  1967. if (!list || !list.callbackInfos || !list.callbackInfos.length) continue;
  1968. if (this.isAnimationCached()) {
  1969. this._nativeDisplay.addDBEventListener(key);
  1970. } else {
  1971. this._nativeDisplay.addDBEventListener(key, emptyHandle);
  1972. }
  1973. }
  1974. this._preCacheMode = this._cacheMode;
  1975. this._nativeDisplay._ccNode = this.node;
  1976. this._nativeDisplay._comp = this;
  1977. this._nativeDisplay._eventTarget = this._eventTarget;
  1978. this._nativeDisplay.bindNodeProxy(this.node._proxy);
  1979. this._nativeDisplay.setOpacityModifyRGB(this.premultipliedAlpha);
  1980. this._nativeDisplay.setBatchEnabled(this.enableBatch);
  1981. this._nativeDisplay.setColor(this.node.color);
  1982. this._nativeDisplay.setDBEventCallback(function (eventObject) {
  1983. this._eventTarget.emit(eventObject.type, eventObject);
  1984. });
  1985. this.attachUtil.init(this);
  1986. this.attachUtil._associateAttachedNode();
  1987. if (this.animationName) {
  1988. this.playAnimation(this.animationName, this.playTimes);
  1989. }
  1990. this._updateMaterial();
  1991. this.markForRender(true);
  1992. };
  1993. armatureDisplayProto._updateColor = function () {
  1994. if (this._nativeDisplay) {
  1995. this._nativeDisplay.setColor(this.node.color);
  1996. }
  1997. };
  1998. armatureDisplayProto.playAnimation = function (animName, playTimes) {
  1999. this.playTimes = playTimes === undefined ? -1 : playTimes;
  2000. this.animationName = animName;
  2001. if (this._nativeDisplay) {
  2002. if (this.isAnimationCached()) {
  2003. return this._nativeDisplay.playAnimation(animName, this.playTimes);
  2004. } else {
  2005. if (this._armature) {
  2006. return this._armature.animation.play(animName, this.playTimes);
  2007. }
  2008. }
  2009. }
  2010. return null;
  2011. };
  2012. armatureDisplayProto.updateAnimationCache = function (animName) {
  2013. if (!this.isAnimationCached()) return;
  2014. if (this._nativeDisplay) {
  2015. if (animName) {
  2016. this._nativeDisplay.updateAnimationCache(animName);
  2017. } else {
  2018. this._nativeDisplay.updateAllAnimationCache();
  2019. }
  2020. }
  2021. };
  2022. armatureDisplayProto.invalidAnimationCache = function () {
  2023. if (!this.isAnimationCached()) return;
  2024. if (this._nativeDisplay) {
  2025. this._nativeDisplay.updateAllAnimationCache();
  2026. }
  2027. };
  2028. armatureDisplayProto.onEnable = function () {
  2029. renderCompProto.onEnable.call(this);
  2030. if (this._armature && !this.isAnimationCached()) {
  2031. this._factory.add(this._armature);
  2032. }
  2033. };
  2034. armatureDisplayProto.onDisable = function () {
  2035. renderCompProto.onDisable.call(this);
  2036. if (this._armature && !this.isAnimationCached()) {
  2037. this._factory.remove(this._armature);
  2038. }
  2039. };
  2040. var _onLoad = armatureDisplayProto.onLoad;
  2041. armatureDisplayProto.onLoad = function () {
  2042. if (_onLoad) {
  2043. _onLoad.call(this);
  2044. }
  2045. };
  2046. armatureDisplayProto.once = function (eventType, listener, target) {
  2047. if (this._nativeDisplay) {
  2048. if (this.isAnimationCached()) {
  2049. this._nativeDisplay.addDBEventListener(eventType);
  2050. } else {
  2051. this._nativeDisplay.addDBEventListener(eventType, listener);
  2052. }
  2053. }
  2054. this._eventTarget.once(eventType, listener, target);
  2055. };
  2056. armatureDisplayProto.addEventListener = function (eventType, listener, target) {
  2057. if (this._nativeDisplay) {
  2058. if (this.isAnimationCached()) {
  2059. this._nativeDisplay.addDBEventListener(eventType);
  2060. } else {
  2061. this._nativeDisplay.addDBEventListener(eventType, listener);
  2062. }
  2063. }
  2064. this._eventTarget.on(eventType, listener, target);
  2065. };
  2066. armatureDisplayProto.removeEventListener = function (eventType, listener, target) {
  2067. if (this._nativeDisplay) {
  2068. if (this.isAnimationCached()) {
  2069. this._nativeDisplay.removeDBEventListener(eventType);
  2070. } else {
  2071. this._nativeDisplay.removeDBEventListener(eventType, listener);
  2072. }
  2073. }
  2074. this._eventTarget.off(eventType, listener, target);
  2075. };
  2076. var _onDestroy = armatureDisplayProto.onDestroy;
  2077. armatureDisplayProto.onDestroy = function () {
  2078. _onDestroy.call(this);
  2079. if (this._nativeDisplay) {
  2080. this._nativeDisplay.dispose();
  2081. this._nativeDisplay._comp = null;
  2082. this._nativeDisplay = null;
  2083. }
  2084. this._materialCache = null;
  2085. };
  2086. armatureDisplayProto.update = function () {
  2087. var nativeDisplay = this._nativeDisplay;
  2088. if (!nativeDisplay) return;
  2089. var node = this.node;
  2090. if (!node) return;
  2091. if (!this.isAnimationCached() && this._debugDraw && this.debugBones) {
  2092. var _nativeDisplay = this._nativeDisplay;
  2093. this._debugData = this._debugData || _nativeDisplay.getDebugData();
  2094. if (!this._debugData) return;
  2095. var graphics = this._debugDraw;
  2096. graphics.clear();
  2097. var debugData = this._debugData;
  2098. var debugIdx = 0;
  2099. graphics.lineWidth = 5;
  2100. graphics.strokeColor = _boneColor;
  2101. graphics.fillColor = _slotColor; // Root bone color is same as slot color.
  2102. var debugBonesLen = debugData[debugIdx++];
  2103. for (var i = 0; i < debugBonesLen; i += 4) {
  2104. var bx = debugData[debugIdx++];
  2105. var by = debugData[debugIdx++];
  2106. var x = debugData[debugIdx++];
  2107. var y = debugData[debugIdx++]; // Bone lengths.
  2108. graphics.moveTo(bx, by);
  2109. graphics.lineTo(x, y);
  2110. graphics.stroke(); // Bone origins.
  2111. graphics.circle(bx, by, Math.PI * 2);
  2112. graphics.fill();
  2113. if (i === 0) {
  2114. graphics.fillColor = _originColor;
  2115. }
  2116. }
  2117. }
  2118. };
  2119. })();
  2120. },{"./jsb-cache-manager":30,"constants":1}],32:[function(require,module,exports){
  2121. "use strict";
  2122. /****************************************************************************
  2123. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  2124. http://www.cocos.com
  2125. Permission is hereby granted, free of charge, to any person obtaining a copy
  2126. of this software and associated engine source code (the "Software"), a limited,
  2127. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  2128. to use Cocos Creator solely to develop games on your target platforms. You shall
  2129. not use Cocos Creator software for developing other software or tools that's
  2130. used for developing games. You are not granted to publish, distribute,
  2131. sublicense, and/or sell copies of Cocos Creator.
  2132. The software or tools in this License Agreement are licensed, not sold.
  2133. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  2134. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  2135. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  2136. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  2137. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  2138. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  2139. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  2140. THE SOFTWARE.
  2141. ****************************************************************************/
  2142. (function () {
  2143. if (!(cc && cc.EditBox)) {
  2144. return;
  2145. }
  2146. var EditBox = cc.EditBox;
  2147. var js = cc.js;
  2148. var KeyboardReturnType = EditBox.KeyboardReturnType;
  2149. var InputMode = EditBox.InputMode;
  2150. var InputFlag = EditBox.InputFlag;
  2151. var MAX_VALUE = 65535;
  2152. var worldMat = new cc.Mat4(),
  2153. cameraMat = new cc.Mat4();
  2154. function getInputType(type) {
  2155. switch (type) {
  2156. case InputMode.EMAIL_ADDR:
  2157. return 'email';
  2158. case InputMode.NUMERIC:
  2159. case InputMode.DECIMAL:
  2160. return 'number';
  2161. case InputMode.PHONE_NUMBER:
  2162. return 'phone';
  2163. case InputMode.URL:
  2164. return 'url';
  2165. case InputMode.SINGLE_LINE:
  2166. case InputMode.ANY:
  2167. default:
  2168. return 'text';
  2169. }
  2170. }
  2171. function getKeyboardReturnType(type) {
  2172. switch (type) {
  2173. case KeyboardReturnType.DEFAULT:
  2174. case KeyboardReturnType.DONE:
  2175. return 'done';
  2176. case KeyboardReturnType.SEND:
  2177. return 'send';
  2178. case KeyboardReturnType.SEARCH:
  2179. return 'search';
  2180. case KeyboardReturnType.GO:
  2181. return 'go';
  2182. case KeyboardReturnType.NEXT:
  2183. return 'next';
  2184. }
  2185. return 'done';
  2186. }
  2187. var BaseClass = EditBox._ImplClass;
  2188. function JsbEditBoxImpl() {
  2189. BaseClass.call(this);
  2190. }
  2191. js.extend(JsbEditBoxImpl, BaseClass);
  2192. EditBox._ImplClass = JsbEditBoxImpl;
  2193. Object.assign(JsbEditBoxImpl.prototype, {
  2194. init: function init(delegate) {
  2195. if (!delegate) {
  2196. cc.error('EditBox init failed');
  2197. return;
  2198. }
  2199. this._delegate = delegate;
  2200. },
  2201. _onResize: function _onResize() {
  2202. var _this$_getRect = this._getRect(),
  2203. x = _this$_getRect.x,
  2204. y = _this$_getRect.y,
  2205. width = _this$_getRect.width,
  2206. height = _this$_getRect.height;
  2207. jsb.inputBox.updateRect(x, y, width, height);
  2208. },
  2209. beginEditing: function beginEditing() {
  2210. var self = this;
  2211. var delegate = this._delegate;
  2212. var multiline = delegate.inputMode === InputMode.ANY;
  2213. var rect = this._getRect();
  2214. var maxLength = delegate.maxLength < 0 ? MAX_VALUE : delegate.maxLength;
  2215. var inputTypeString = getInputType(delegate.inputMode);
  2216. if (delegate.inputFlag === InputFlag.PASSWORD) {
  2217. inputTypeString = 'password';
  2218. }
  2219. function onConfirm(res) {
  2220. delegate.editBoxEditingReturn();
  2221. }
  2222. function onInput(res) {
  2223. if (delegate._string !== res.value) {
  2224. delegate.editBoxTextChanged(res.value);
  2225. }
  2226. }
  2227. function onComplete(res) {
  2228. self.endEditing();
  2229. }
  2230. jsb.inputBox.onInput(onInput);
  2231. jsb.inputBox.onConfirm(onConfirm);
  2232. jsb.inputBox.onComplete(onComplete);
  2233. if (!cc.sys.isMobile) {
  2234. this._delegate._hideLabels();
  2235. }
  2236. jsb.inputBox.show({
  2237. defaultValue: delegate._string,
  2238. maxLength: maxLength,
  2239. multiple: multiline,
  2240. confirmHold: false,
  2241. confirmType: getKeyboardReturnType(delegate.returnType),
  2242. inputType: inputTypeString,
  2243. originX: rect.x,
  2244. originY: rect.y,
  2245. width: rect.width,
  2246. height: rect.height
  2247. });
  2248. this._editing = true;
  2249. delegate.editBoxEditingDidBegan();
  2250. if (!cc.sys.isMobile) {
  2251. cc.view.on('canvas-resize', this._onResize, this);
  2252. }
  2253. },
  2254. endEditing: function endEditing() {
  2255. jsb.inputBox.offConfirm();
  2256. jsb.inputBox.offInput();
  2257. jsb.inputBox.offComplete();
  2258. this._editing = false;
  2259. if (!cc.sys.isMobile) {
  2260. this._delegate._showLabels();
  2261. }
  2262. jsb.inputBox.hide();
  2263. this._delegate.editBoxEditingDidEnded();
  2264. if (!cc.sys.isMobile) {
  2265. cc.view.off('canvas-resize', this._onResize, this);
  2266. }
  2267. },
  2268. _getRect: function _getRect() {
  2269. var node = this._delegate.node,
  2270. viewScaleX = cc.view._scaleX,
  2271. viewScaleY = cc.view._scaleY;
  2272. var dpr = cc.view._devicePixelRatio;
  2273. node.getWorldMatrix(worldMat);
  2274. var camera = cc.Camera.findCamera(node);
  2275. if (!camera) {
  2276. return new cc.Rect();
  2277. }
  2278. camera.getWorldToScreenMatrix2D(cameraMat);
  2279. cc.Mat4.multiply(cameraMat, cameraMat, worldMat);
  2280. var contentSize = node._contentSize;
  2281. var vec3 = cc.v3();
  2282. vec3.x = -node._anchorPoint.x * contentSize.width;
  2283. vec3.y = -node._anchorPoint.y * contentSize.height;
  2284. cc.Mat4.translate(cameraMat, cameraMat, vec3);
  2285. viewScaleX /= dpr;
  2286. viewScaleY /= dpr;
  2287. var finalScaleX = cameraMat.m[0] * viewScaleX;
  2288. var finaleScaleY = cameraMat.m[5] * viewScaleY;
  2289. var viewportRect = cc.view._viewportRect;
  2290. var offsetX = viewportRect.x / dpr,
  2291. offsetY = viewportRect.y / dpr;
  2292. return {
  2293. x: cameraMat.m[12] * viewScaleX + offsetX,
  2294. y: cameraMat.m[13] * viewScaleY + offsetY,
  2295. width: contentSize.width * finalScaleX,
  2296. height: contentSize.height * finaleScaleY
  2297. };
  2298. }
  2299. });
  2300. })();
  2301. },{}],33:[function(require,module,exports){
  2302. "use strict";
  2303. // Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  2304. (function () {
  2305. if (!cc.EffectVariant) return;
  2306. var EffectVariant = cc.EffectVariant;
  2307. var _init = EffectVariant.prototype.init;
  2308. Object.assign(EffectVariant.prototype, {
  2309. init: function init(effect) {
  2310. _init.call(this, effect);
  2311. this._nativeObj = new renderer.EffectVariant(effect._nativeObj);
  2312. },
  2313. _onEffectChanged: function _onEffectChanged() {
  2314. var nativeEffect = this._effect ? this._effect._nativeObj : null;
  2315. this._nativeObj.setEffect(nativeEffect);
  2316. },
  2317. updateHash: function updateHash(hash) {
  2318. this._nativeObj.updateHash(hash);
  2319. }
  2320. });
  2321. })();
  2322. },{}],34:[function(require,module,exports){
  2323. "use strict";
  2324. // Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  2325. var gfx = window.gfx; // Effect
  2326. var Effect = cc.Effect;
  2327. var _init = Effect.prototype.init;
  2328. var _clone = Effect.prototype.clone;
  2329. var _switchTechnique = Effect.prototype.switchTechnique;
  2330. Object.assign(Effect.prototype, {
  2331. init: function init(name, techniques, techniqueIndex, asset, createNative) {
  2332. _init.call(this, name, techniques, techniqueIndex, asset);
  2333. if (createNative) {
  2334. this._nativeObj = new renderer.EffectNative();
  2335. this._nativeObj.init(techniques);
  2336. this._nativePtr = this._nativeObj.self();
  2337. }
  2338. },
  2339. clone: function clone() {
  2340. var effect = _clone.call(this);
  2341. effect._nativeObj = new renderer.EffectNative();
  2342. effect._nativeObj.copy(this._nativeObj);
  2343. effect._nativePtr = effect._nativeObj.self();
  2344. return effect;
  2345. },
  2346. switchTechnique: function switchTechnique(techniqueIndex) {
  2347. _switchTechnique.call(this, techniqueIndex);
  2348. this._nativeObj.switchTechnique(techniqueIndex);
  2349. }
  2350. }); // EffectBase
  2351. var EffectBase = cc.EffectBase;
  2352. var _setCullMode = EffectBase.prototype.setCullMode;
  2353. var _setBlend = EffectBase.prototype.setBlend;
  2354. var _setStencilEnabled = EffectBase.prototype.setStencilEnabled;
  2355. var _setStencil = EffectBase.prototype.setStencil;
  2356. var _setDepth = EffectBase.prototype.setDepth;
  2357. var _define = EffectBase.prototype.define;
  2358. var _setProperty = EffectBase.prototype.setProperty;
  2359. Object.assign(EffectBase.prototype, {
  2360. setCullMode: function setCullMode() {
  2361. var cullMode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : gfx.CULL_BACK;
  2362. var passIdx = arguments.length > 1 ? arguments[1] : undefined;
  2363. _setCullMode.call(this, cullMode, passIdx);
  2364. this._nativeObj.setCullMode(cullMode, passIdx === undefined ? -1 : passIdx);
  2365. },
  2366. setBlend: function setBlend() {
  2367. var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  2368. var blendEq = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : gfx.BLEND_FUNC_ADD;
  2369. var blendSrc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : gfx.BLEND_SRC_ALPHA;
  2370. var blendDst = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : gfx.BLEND_ONE_MINUS_SRC_ALPHA;
  2371. var blendAlphaEq = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : gfx.BLEND_FUNC_ADD;
  2372. var blendSrcAlpha = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : gfx.BLEND_SRC_ALPHA;
  2373. var blendDstAlpha = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : gfx.BLEND_ONE_MINUS_SRC_ALPHA;
  2374. var blendColor = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0xffffffff;
  2375. var passIdx = arguments.length > 8 ? arguments[8] : undefined;
  2376. _setBlend.call(this, enabled, blendEq, blendSrc, blendDst, blendAlphaEq, blendSrcAlpha, blendDstAlpha, blendColor, passIdx);
  2377. this._nativeObj.setBlend(enabled, blendEq, blendSrc, blendDst, blendAlphaEq, blendSrcAlpha, blendDstAlpha, blendColor, passIdx === undefined ? -1 : passIdx);
  2378. },
  2379. setDepth: function setDepth(depthTest, depthWrite, depthFunc, passIdx) {
  2380. _setDepth.call(this, depthTest, depthWrite, depthFunc, passIdx);
  2381. this._nativeObj.setDepth(depthTest, depthWrite, depthFunc, passIdx === undefined ? -1 : passIdx);
  2382. },
  2383. setStencilEnabled: function setStencilEnabled(enabled, passIdx) {
  2384. _setStencilEnabled.call(this, enabled, passIdx);
  2385. this._nativeObj.setStencilTest(enabled, passIdx === undefined ? -1 : passIdx);
  2386. },
  2387. setStencil: function setStencil() {
  2388. var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : gfx.STENCIL_INHERIT;
  2389. var stencilFunc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : gfx.DS_FUNC_ALWAYS;
  2390. var stencilRef = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  2391. var stencilMask = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0xff;
  2392. var stencilFailOp = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : gfx.STENCIL_OP_KEEP;
  2393. var stencilZFailOp = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : gfx.STENCIL_OP_KEEP;
  2394. var stencilZPassOp = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : gfx.STENCIL_OP_KEEP;
  2395. var stencilWriteMask = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0xff;
  2396. var passIdx = arguments.length > 8 ? arguments[8] : undefined;
  2397. _setStencil.call(this, enabled, stencilFunc, stencilRef, stencilMask, stencilFailOp, stencilZFailOp, stencilZPassOp, stencilWriteMask, passIdx);
  2398. this._nativeObj.setStencil(stencilFunc, stencilRef, stencilMask, stencilFailOp, stencilZFailOp, stencilZPassOp, stencilWriteMask, passIdx === undefined ? -1 : passIdx);
  2399. },
  2400. define: function define(name, value, passIdx, force) {
  2401. _define.call(this, name, value, passIdx, force);
  2402. this._nativeObj.define(name, value, passIdx === undefined ? -1 : passIdx);
  2403. },
  2404. updateHash: function updateHash(hash) {
  2405. this._nativeObj.updateHash(hash);
  2406. },
  2407. setProperty: function setProperty(name, val, passIdx, directly) {
  2408. _setProperty.call(this, name, val, passIdx);
  2409. var prop = this.getProperty(name);
  2410. if (prop !== undefined) {
  2411. this._nativeObj.setProperty(name, prop, passIdx === undefined ? -1 : passIdx, directly);
  2412. }
  2413. }
  2414. });
  2415. },{}],35:[function(require,module,exports){
  2416. "use strict";
  2417. /****************************************************************************
  2418. Copyright (c) 2017-2019 Xiamen Yaji Software Co., Ltd.
  2419. https://www.cocos.com/
  2420. Permission is hereby granted, free of charge, to any person obtaining a copy
  2421. of fsUtils software and associated engine source code (the "Software"), a limited,
  2422. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  2423. to use Cocos Creator solely to develop games on your target platforms. You shall
  2424. not use Cocos Creator software for developing other software or tools that's
  2425. used for developing games. You are not granted to publish, distribute,
  2426. sublicense, and/or sell copies of Cocos Creator.
  2427. The software or tools in fsUtils License Agreement are licensed, not sold.
  2428. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  2429. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  2430. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  2431. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  2432. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  2433. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  2434. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  2435. THE SOFTWARE.
  2436. ****************************************************************************/
  2437. var fs = jsb.fileUtils;
  2438. var jsb_downloader = null;
  2439. var downloading = new cc.AssetManager.Cache();
  2440. var tempDir = '';
  2441. var fsUtils = {
  2442. fs: fs,
  2443. initJsbDownloader: function initJsbDownloader(jsbDownloaderMaxTasks, jsbDownloaderTimeout) {
  2444. jsb_downloader = new jsb.Downloader({
  2445. countOfMaxProcessingTasks: jsbDownloaderMaxTasks || 32,
  2446. timeoutInSeconds: jsbDownloaderTimeout || 30,
  2447. tempFileNameSuffix: '.tmp'
  2448. });
  2449. tempDir = fsUtils.getUserDataPath() + '/temp';
  2450. !fs.isDirectoryExist(tempDir) && fs.createDirectory(tempDir);
  2451. jsb_downloader.setOnFileTaskSuccess(function (task) {
  2452. if (!downloading.has(task.requestURL)) return;
  2453. var _downloading$remove = downloading.remove(task.requestURL),
  2454. onComplete = _downloading$remove.onComplete;
  2455. onComplete && onComplete(null, task.storagePath);
  2456. });
  2457. jsb_downloader.setOnTaskError(function (task, errorCode, errorCodeInternal, errorStr) {
  2458. if (!downloading.has(task.requestURL)) return;
  2459. var _downloading$remove2 = downloading.remove(task.requestURL),
  2460. onComplete = _downloading$remove2.onComplete;
  2461. cc.error("Download file failed: path: ".concat(task.requestURL, " message: ").concat(errorStr, ", ").concat(errorCode));
  2462. onComplete(new Error(errorStr), null);
  2463. });
  2464. jsb_downloader.setOnTaskProgress(function (task, bytesReceived, totalBytesReceived, totalBytesExpected) {
  2465. if (!downloading.has(task.requestURL)) return;
  2466. var _downloading$get = downloading.get(task.requestURL),
  2467. onProgress = _downloading$get.onProgress;
  2468. onProgress && onProgress(totalBytesReceived, totalBytesExpected);
  2469. });
  2470. },
  2471. getUserDataPath: function getUserDataPath() {
  2472. return fs.getWritablePath().replace(/[\/\\]*$/, '');
  2473. },
  2474. checkFsValid: function checkFsValid() {
  2475. if (!fs) {
  2476. cc.warn('can not get the file system!');
  2477. return false;
  2478. }
  2479. return true;
  2480. },
  2481. deleteFile: function deleteFile(filePath, onComplete) {
  2482. var result = fs.removeFile(filePath);
  2483. if (result === true) {
  2484. onComplete && onComplete(null);
  2485. } else {
  2486. cc.warn("Delete file failed: path: ".concat(filePath));
  2487. onComplete && onComplete(new Error('delete file failed'));
  2488. }
  2489. },
  2490. downloadFile: function downloadFile(remoteUrl, filePath, header, onProgress, onComplete) {
  2491. downloading.add(remoteUrl, {
  2492. onProgress: onProgress,
  2493. onComplete: onComplete
  2494. });
  2495. var storagePath = filePath;
  2496. if (!storagePath) storagePath = tempDir + '/' + performance.now() + cc.path.extname(remoteUrl);
  2497. jsb_downloader.createDownloadFileTask(remoteUrl, storagePath, header);
  2498. },
  2499. saveFile: function saveFile(srcPath, destPath, onComplete) {
  2500. var err = null;
  2501. var result = fs.writeDataToFile(fs.getDataFromFile(srcPath), destPath);
  2502. fs.removeFile(srcPath);
  2503. if (!result) {
  2504. err = new Error("Save file failed: path: ".concat(srcPath));
  2505. cc.warn(err.message);
  2506. }
  2507. onComplete && onComplete(err);
  2508. },
  2509. copyFile: function copyFile(srcPath, destPath, onComplete) {
  2510. var err = null;
  2511. var result = fs.writeDataToFile(fs.getDataFromFile(srcPath), destPath);
  2512. if (!result) {
  2513. err = new Error("Copy file failed: path: ".concat(srcPath));
  2514. cc.warn(err.message);
  2515. }
  2516. onComplete && onComplete(err);
  2517. },
  2518. writeFile: function writeFile(path, data, encoding, onComplete) {
  2519. var result = null;
  2520. var err = null;
  2521. if (encoding === 'utf-8' || encoding === 'utf8') {
  2522. result = fs.writeStringToFile(data, path);
  2523. } else {
  2524. result = fs.writeDataToFile(data, path);
  2525. }
  2526. if (!result) {
  2527. err = new Error("Write file failed: path: ".concat(path));
  2528. cc.warn(err.message);
  2529. }
  2530. onComplete && onComplete(err);
  2531. },
  2532. writeFileSync: function writeFileSync(path, data, encoding) {
  2533. var result = null;
  2534. if (encoding === 'utf-8' || encoding === 'utf8') {
  2535. result = fs.writeStringToFile(data, path);
  2536. } else {
  2537. result = fs.writeDataToFile(data, path);
  2538. }
  2539. if (!result) {
  2540. cc.warn("Write file failed: path: ".concat(path));
  2541. return new Error("Write file failed: path: ".concat(path));
  2542. }
  2543. },
  2544. readFile: function readFile(filePath, encoding, onComplete) {
  2545. var content = null,
  2546. err = null;
  2547. if (encoding === 'utf-8' || encoding === 'utf8') {
  2548. content = fs.getStringFromFile(filePath);
  2549. } else {
  2550. content = fs.getDataFromFile(filePath);
  2551. }
  2552. if (!content) {
  2553. err = new Error("Read file failed: path: ".concat(filePath));
  2554. cc.warn(err.message);
  2555. }
  2556. onComplete && onComplete(err, content);
  2557. },
  2558. readDir: function readDir(filePath, onComplete) {
  2559. var files = null,
  2560. err = null;
  2561. try {
  2562. files = fs.listFiles(filePath);
  2563. } catch (e) {
  2564. cc.warn("Read dir failed: path: ".concat(filePath, " message: ").concat(e.message));
  2565. err = new Error(e.message);
  2566. }
  2567. onComplete && onComplete(err, files);
  2568. },
  2569. readText: function readText(filePath, onComplete) {
  2570. fsUtils.readFile(filePath, 'utf8', onComplete);
  2571. },
  2572. readArrayBuffer: function readArrayBuffer(filePath, onComplete) {
  2573. fsUtils.readFile(filePath, '', onComplete);
  2574. },
  2575. readJson: function readJson(filePath, onComplete) {
  2576. fsUtils.readFile(filePath, 'utf8', function (err, text) {
  2577. var out = null;
  2578. if (!err) {
  2579. try {
  2580. out = JSON.parse(text);
  2581. } catch (e) {
  2582. cc.warn("Read json failed: path: ".concat(filePath, " message: ").concat(e.message));
  2583. err = new Error(e.message);
  2584. }
  2585. }
  2586. onComplete && onComplete(err, out);
  2587. });
  2588. },
  2589. readJsonSync: function readJsonSync(path) {
  2590. try {
  2591. var str = fs.getStringFromFile(path);
  2592. return JSON.parse(str);
  2593. } catch (e) {
  2594. cc.warn("Read json failed: path: ".concat(path, " message: ").concat(e.message));
  2595. return new Error(e.message);
  2596. }
  2597. },
  2598. makeDirSync: function makeDirSync(path, recursive) {
  2599. var result = fs.createDirectory(path);
  2600. if (!result) {
  2601. cc.warn("Make directory failed: path: ".concat(path));
  2602. return new Error("Make directory failed: path: ".concat(path));
  2603. }
  2604. },
  2605. rmdirSync: function rmdirSync(dirPath, recursive) {
  2606. var result = fs.removeDirectory(dirPath);
  2607. if (!result) {
  2608. cc.warn("rm directory failed: path: ".concat(dirPath));
  2609. return new Error("rm directory failed: path: ".concat(dirPath));
  2610. }
  2611. },
  2612. exists: function exists(filePath, onComplete) {
  2613. var result = fs.isFileExist(filePath);
  2614. onComplete && onComplete(result);
  2615. },
  2616. loadSubpackage: function loadSubpackage(name, onProgress, onComplete) {
  2617. throw new Error('not implement');
  2618. }
  2619. };
  2620. window.fsUtils = module.exports = fsUtils;
  2621. },{}],36:[function(require,module,exports){
  2622. "use strict";
  2623. /****************************************************************************
  2624. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  2625. http://www.cocos.com
  2626. Permission is hereby granted, free of charge, to any person obtaining a copy
  2627. of this software and associated engine source code (the "Software"), a limited,
  2628. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  2629. to use Cocos Creator solely to develop games on your target platforms. You shall
  2630. not use Cocos Creator software for developing other software or tools that's
  2631. used for developing games. You are not granted to publish, distribute,
  2632. sublicense, and/or sell copies of Cocos Creator.
  2633. The software or tools in this License Agreement are licensed, not sold.
  2634. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  2635. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  2636. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  2637. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  2638. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  2639. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  2640. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  2641. THE SOFTWARE.
  2642. ****************************************************************************/
  2643. cc.game.restart = function () {
  2644. // Need to clear scene, or native object destructor won't be invoke.
  2645. cc.director.getScene().destroy();
  2646. cc.Object._deferredDestroy();
  2647. cc.game.pause();
  2648. __restartVM();
  2649. };
  2650. jsb.onError(function (location, message, stack) {
  2651. console.error(location, message, stack);
  2652. });
  2653. jsb.onPause = function () {
  2654. cc.game.emit(cc.game.EVENT_HIDE);
  2655. };
  2656. jsb.onResume = function () {
  2657. cc.game.emit(cc.game.EVENT_SHOW);
  2658. };
  2659. jsb.onResize = function (size) {
  2660. if (size.width === 0 || size.height === 0) return;
  2661. size.width /= window.devicePixelRatio;
  2662. size.height /= window.devicePixelRatio;
  2663. window.resize(size.width, size.height);
  2664. };
  2665. },{}],37:[function(require,module,exports){
  2666. /****************************************************************************
  2667. Copyright (c) 2013-2016 Chukong Technologies Inc.
  2668. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  2669. http://www.cocos.com
  2670. Permission is hereby granted, free of charge, to any person obtaining a copy
  2671. of this software and associated engine source code (the "Software"), a limited,
  2672. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  2673. to use Cocos Creator solely to develop games on your target platforms. You shall
  2674. not use Cocos Creator software for developing other software or tools that's
  2675. used for developing games. You are not granted to publish, distribute,
  2676. sublicense, and/or sell copies of Cocos Creator.
  2677. The software or tools in this License Agreement are licensed, not sold.
  2678. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  2679. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  2680. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  2681. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  2682. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  2683. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  2684. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  2685. THE SOFTWARE.
  2686. ****************************************************************************/
  2687. 'use strict';
  2688. var cacheManager = require('./jsb-cache-manager');
  2689. var _require = require('./jsb-fs-utils'),
  2690. downloadFile = _require.downloadFile,
  2691. readText = _require.readText,
  2692. readArrayBuffer = _require.readArrayBuffer,
  2693. readJson = _require.readJson,
  2694. getUserDataPath = _require.getUserDataPath,
  2695. initJsbDownloader = _require.initJsbDownloader;
  2696. var REGEX = /^\w+:\/\/.*/;
  2697. var downloader = cc.assetManager.downloader;
  2698. var parser = cc.assetManager.parser;
  2699. var presets = cc.assetManager.presets;
  2700. downloader.maxConcurrency = 30;
  2701. downloader.maxRequestsPerFrame = 60;
  2702. presets['preload'].maxConcurrency = 15;
  2703. presets['preload'].maxRequestsPerFrame = 30;
  2704. presets['scene'].maxConcurrency = 32;
  2705. presets['scene'].maxRequestsPerFrame = 64;
  2706. presets['bundle'].maxConcurrency = 32;
  2707. presets['bundle'].maxRequestsPerFrame = 64;
  2708. var suffix = 0;
  2709. var REMOTE_SERVER_ROOT = '';
  2710. var remoteBundles = {};
  2711. var failureMap = {};
  2712. var maxRetryCountFromBreakpoint = 5;
  2713. var loadedScripts = {};
  2714. function downloadScript(url, options, onComplete) {
  2715. if (typeof options === 'function') {
  2716. onComplete = options;
  2717. options = null;
  2718. }
  2719. if (loadedScripts[url]) return onComplete && onComplete();
  2720. download(url, function (src, options, onComplete) {
  2721. window.require(src);
  2722. loadedScripts[url] = true;
  2723. onComplete && onComplete(null);
  2724. }, options, options.onFileProgress, onComplete);
  2725. }
  2726. function download(url, func, options, onFileProgress, onComplete) {
  2727. var result = transformUrl(url, options);
  2728. if (result.inLocal) {
  2729. func(result.url, options, onComplete);
  2730. } else if (result.inCache) {
  2731. cacheManager.updateLastTime(url);
  2732. func(result.url, options, function (err, data) {
  2733. if (err) {
  2734. cacheManager.removeCache(url);
  2735. }
  2736. onComplete(err, data);
  2737. });
  2738. } else {
  2739. var time = Date.now();
  2740. var storagePath = '';
  2741. var failureRecord = failureMap[url];
  2742. if (failureRecord) {
  2743. storagePath = failureRecord.storagePath;
  2744. } else if (options.__cacheBundleRoot__) {
  2745. storagePath = "".concat(options.__cacheBundleRoot__, "/").concat(time).concat(suffix++).concat(cc.path.extname(url));
  2746. } else {
  2747. storagePath = "".concat(time).concat(suffix++).concat(cc.path.extname(url));
  2748. }
  2749. downloadFile(url, "".concat(cacheManager.cacheDir, "/").concat(storagePath), options.header, onFileProgress, function (err, path) {
  2750. if (err) {
  2751. if (failureRecord) {
  2752. failureRecord.retryCount++;
  2753. if (failureRecord.retryCount >= maxRetryCountFromBreakpoint) {
  2754. delete failureMap[url];
  2755. }
  2756. } else {
  2757. failureMap[url] = {
  2758. retryCount: 0,
  2759. storagePath: storagePath
  2760. };
  2761. }
  2762. onComplete(err, null);
  2763. return;
  2764. }
  2765. delete failureMap[url];
  2766. func(path, options, function (err, data) {
  2767. if (!err) {
  2768. cacheManager.cacheFile(url, storagePath, options.__cacheBundleRoot__);
  2769. }
  2770. onComplete(err, data);
  2771. });
  2772. });
  2773. }
  2774. }
  2775. function transformUrl(url, options) {
  2776. var inLocal = false;
  2777. var inCache = false;
  2778. if (REGEX.test(url)) {
  2779. if (options.reload) {
  2780. return {
  2781. url: url
  2782. };
  2783. } else {
  2784. var cache = cacheManager.getCache(url);
  2785. if (cache) {
  2786. inCache = true;
  2787. url = cache;
  2788. }
  2789. }
  2790. } else {
  2791. inLocal = true;
  2792. }
  2793. return {
  2794. url: url,
  2795. inLocal: inLocal,
  2796. inCache: inCache
  2797. };
  2798. }
  2799. function doNothing(content, options, onComplete) {
  2800. onComplete(null, content);
  2801. }
  2802. function downloadAsset(url, options, onComplete) {
  2803. download(url, doNothing, options, options.onFileProgress, onComplete);
  2804. }
  2805. function _getFontFamily(fontHandle) {
  2806. var ttfIndex = fontHandle.lastIndexOf(".ttf");
  2807. if (ttfIndex === -1) return fontHandle;
  2808. var slashPos = fontHandle.lastIndexOf("/");
  2809. var fontFamilyName;
  2810. if (slashPos === -1) {
  2811. fontFamilyName = fontHandle.substring(0, ttfIndex) + "_LABEL";
  2812. } else {
  2813. fontFamilyName = fontHandle.substring(slashPos + 1, ttfIndex) + "_LABEL";
  2814. }
  2815. if (fontFamilyName.indexOf(' ') !== -1) {
  2816. fontFamilyName = '"' + fontFamilyName + '"';
  2817. }
  2818. return fontFamilyName;
  2819. }
  2820. function parseText(url, options, onComplete) {
  2821. readText(url, onComplete);
  2822. }
  2823. function parseJson(url, options, onComplete) {
  2824. readJson(url, onComplete);
  2825. }
  2826. function downloadText(url, options, onComplete) {
  2827. download(url, parseText, options, options.onFileProgress, onComplete);
  2828. }
  2829. function parseArrayBuffer(url, options, onComplete) {
  2830. readArrayBuffer(url, onComplete);
  2831. }
  2832. function downloadJson(url, options, onComplete) {
  2833. download(url, parseJson, options, options.onFileProgress, onComplete);
  2834. }
  2835. function downloadBundle(nameOrUrl, options, onComplete) {
  2836. var bundleName = cc.path.basename(nameOrUrl);
  2837. var version = options.version || cc.assetManager.downloader.bundleVers[bundleName];
  2838. var url;
  2839. if (REGEX.test(nameOrUrl) || nameOrUrl.startsWith(getUserDataPath())) {
  2840. url = nameOrUrl;
  2841. cacheManager.makeBundleFolder(bundleName);
  2842. } else {
  2843. if (remoteBundles[bundleName]) {
  2844. url = "".concat(REMOTE_SERVER_ROOT, "remote/").concat(bundleName);
  2845. cacheManager.makeBundleFolder(bundleName);
  2846. } else {
  2847. url = "assets/".concat(bundleName);
  2848. }
  2849. }
  2850. var config = "".concat(url, "/config.").concat(version ? version + '.' : '', "json");
  2851. options.__cacheBundleRoot__ = bundleName;
  2852. downloadJson(config, options, function (err, response) {
  2853. if (err) {
  2854. return onComplete(err, null);
  2855. }
  2856. var out = response;
  2857. out && (out.base = url + '/');
  2858. var js = "".concat(url, "/index.").concat(version ? version + '.' : '').concat(out.encrypted ? 'jsc' : "js");
  2859. downloadScript(js, options, function (err) {
  2860. if (err) {
  2861. return onComplete(err, null);
  2862. }
  2863. onComplete(err, out);
  2864. });
  2865. });
  2866. }
  2867. ;
  2868. function loadFont(url, options, onComplete) {
  2869. var fontFamilyName = _getFontFamily(url);
  2870. var fontFace = new FontFace(fontFamilyName, "url('" + url + "')");
  2871. document.fonts.add(fontFace);
  2872. fontFace.load();
  2873. fontFace.loaded.then(function () {
  2874. onComplete(null, fontFamilyName);
  2875. }, function () {
  2876. cc.warnID(4933, fontFamilyName);
  2877. onComplete(null, fontFamilyName);
  2878. });
  2879. }
  2880. function parsePlist(url, options, onComplete) {
  2881. readText(url, function (err, file) {
  2882. var result = null;
  2883. if (!err) {
  2884. result = cc.plistParser.parse(file);
  2885. if (!result) err = new Error('parse failed');
  2886. }
  2887. onComplete && onComplete(err, result);
  2888. });
  2889. }
  2890. parser.parsePVRTex = downloader.downloadDomImage;
  2891. parser.parsePKMTex = downloader.downloadDomImage;
  2892. downloader.downloadScript = downloadScript;
  2893. downloader.register({
  2894. // JS
  2895. '.js': downloadScript,
  2896. '.jsc': downloadScript,
  2897. // Images
  2898. '.png': downloadAsset,
  2899. '.jpg': downloadAsset,
  2900. '.bmp': downloadAsset,
  2901. '.jpeg': downloadAsset,
  2902. '.gif': downloadAsset,
  2903. '.ico': downloadAsset,
  2904. '.tiff': downloadAsset,
  2905. '.webp': downloadAsset,
  2906. '.image': downloadAsset,
  2907. '.pvr': downloadAsset,
  2908. '.pkm': downloadAsset,
  2909. // Audio
  2910. '.mp3': downloadAsset,
  2911. '.ogg': downloadAsset,
  2912. '.wav': downloadAsset,
  2913. '.m4a': downloadAsset,
  2914. // Video
  2915. '.mp4': downloadAsset,
  2916. '.avi': downloadAsset,
  2917. '.mov': downloadAsset,
  2918. '.mpg': downloadAsset,
  2919. '.mpeg': downloadAsset,
  2920. '.rm': downloadAsset,
  2921. '.rmvb': downloadAsset,
  2922. // Text
  2923. '.txt': downloadAsset,
  2924. '.xml': downloadAsset,
  2925. '.vsh': downloadAsset,
  2926. '.fsh': downloadAsset,
  2927. '.atlas': downloadAsset,
  2928. '.tmx': downloadAsset,
  2929. '.tsx': downloadAsset,
  2930. '.fnt': downloadAsset,
  2931. '.plist': downloadAsset,
  2932. '.json': downloadJson,
  2933. '.ExportJson': downloadAsset,
  2934. '.binary': downloadAsset,
  2935. '.bin': downloadAsset,
  2936. '.dbbin': downloadAsset,
  2937. '.skel': downloadAsset,
  2938. // Font
  2939. '.font': downloadAsset,
  2940. '.eot': downloadAsset,
  2941. '.ttf': downloadAsset,
  2942. '.woff': downloadAsset,
  2943. '.svg': downloadAsset,
  2944. '.ttc': downloadAsset,
  2945. 'bundle': downloadBundle,
  2946. 'default': downloadText
  2947. });
  2948. parser.register({
  2949. // Images
  2950. '.png': downloader.downloadDomImage,
  2951. '.jpg': downloader.downloadDomImage,
  2952. '.bmp': downloader.downloadDomImage,
  2953. '.jpeg': downloader.downloadDomImage,
  2954. '.gif': downloader.downloadDomImage,
  2955. '.ico': downloader.downloadDomImage,
  2956. '.tiff': downloader.downloadDomImage,
  2957. '.webp': downloader.downloadDomImage,
  2958. '.image': downloader.downloadDomImage,
  2959. // compressed texture
  2960. '.pvr': downloader.downloadDomImage,
  2961. '.pkm': downloader.downloadDomImage,
  2962. '.binary': parseArrayBuffer,
  2963. '.bin': parseArrayBuffer,
  2964. '.dbbin': parseArrayBuffer,
  2965. '.skel': parseArrayBuffer,
  2966. // Text
  2967. '.txt': parseText,
  2968. '.xml': parseText,
  2969. '.vsh': parseText,
  2970. '.fsh': parseText,
  2971. '.atlas': parseText,
  2972. '.tmx': parseText,
  2973. '.tsx': parseText,
  2974. '.fnt': parseText,
  2975. '.plist': parsePlist,
  2976. // Font
  2977. '.font': loadFont,
  2978. '.eot': loadFont,
  2979. '.ttf': loadFont,
  2980. '.woff': loadFont,
  2981. '.svg': loadFont,
  2982. '.ttc': loadFont,
  2983. '.ExportJson': parseJson
  2984. });
  2985. cc.assetManager.transformPipeline.append(function (task) {
  2986. var input = task.output = task.input;
  2987. for (var i = 0, l = input.length; i < l; i++) {
  2988. var item = input[i];
  2989. if (item.config) {
  2990. item.options.__cacheBundleRoot__ = item.config.name;
  2991. }
  2992. }
  2993. });
  2994. var originInit = cc.assetManager.init;
  2995. cc.assetManager.init = function (options) {
  2996. originInit.call(cc.assetManager, options);
  2997. options.remoteBundles && options.remoteBundles.forEach(function (x) {
  2998. return remoteBundles[x] = true;
  2999. });
  3000. REMOTE_SERVER_ROOT = options.server || '';
  3001. if (REMOTE_SERVER_ROOT && !REMOTE_SERVER_ROOT.endsWith('/')) REMOTE_SERVER_ROOT += '/';
  3002. initJsbDownloader(options.jsbDownloaderMaxTasks, options.jsbDownloaderTimeout);
  3003. cacheManager.init();
  3004. };
  3005. },{"./jsb-cache-manager":30,"./jsb-fs-utils":35}],38:[function(require,module,exports){
  3006. "use strict";
  3007. /****************************************************************************
  3008. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  3009. http://www.cocos.com
  3010. Permission is hereby granted, free of charge, to any person obtaining a copy
  3011. of this software and associated engine source code (the "Software"), a limited,
  3012. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  3013. to use Cocos Creator solely to develop games on your target platforms. You shall
  3014. not use Cocos Creator software for developing other software or tools that's
  3015. used for developing games. You are not granted to publish, distribute,
  3016. sublicense, and/or sell copies of Cocos Creator.
  3017. The software or tools in this License Agreement are licensed, not sold.
  3018. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  3019. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3020. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3021. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3022. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3023. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3024. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3025. THE SOFTWARE.
  3026. ****************************************************************************/
  3027. (function () {
  3028. if (window.middleware === undefined) return;
  3029. var ParticleSystem = cc.ParticleSystem;
  3030. if (ParticleSystem === undefined) return;
  3031. var PSProto = ParticleSystem.prototype;
  3032. PSProto.initProperties = function () {
  3033. this._simulator = new middleware.ParticleSimulator();
  3034. this._previewTimer = null;
  3035. this._focused = false;
  3036. this._texture = null;
  3037. this._renderData = null;
  3038. this._simulator.__particleSystem__ = this;
  3039. this._simulator.setFinishedCallback(function () {
  3040. var self = this.__particleSystem__;
  3041. self._finishedSimulation();
  3042. });
  3043. this._simulator.setStopCallback(function () {
  3044. var self = this.__particleSystem__;
  3045. self.stopSystem();
  3046. });
  3047. this._initProperties();
  3048. }; // value type properties
  3049. var propertiesList = ["positionType", "emissionRate", "totalParticles", "duration", "emitterMode", "life", "lifeVar", "startSize", "startSizeVar", "endSize", "endSizeVar", "startSpin", "startSpinVar", "endSpin", "endSpinVar", "angle", "angleVar", "speed", "speedVar", "radialAccel", "radialAccelVar", "tangentialAccel", "tangentialAccelVar", "rotationIsDir", "startRadius", "startRadiusVar", "endRadius", "endRadiusVar", "rotatePerS", "rotatePerSVar"];
  3050. propertiesList.forEach(function (getSetName) {
  3051. var varName = "_" + getSetName;
  3052. Object.defineProperty(PSProto, getSetName, {
  3053. get: function get() {
  3054. this[varName] === undefined && (this[varName] = 0);
  3055. return this[varName];
  3056. },
  3057. set: function set(val) {
  3058. this[varName] = val;
  3059. this._simulator && (this._simulator[getSetName] = val);
  3060. }
  3061. });
  3062. }); // object type properties
  3063. var objPropList = ['gravity', 'sourcePos', 'posVar', 'startColor', 'startColorVar', 'endColor', 'endColorVar'];
  3064. PSProto._initProperties = function () {
  3065. // init properties
  3066. for (var key in propertiesList) {
  3067. var propName = propertiesList[key];
  3068. this[propName] = this[propName];
  3069. }
  3070. for (var _key in objPropList) {
  3071. var _propName = objPropList[_key];
  3072. this[_propName] = this[_propName];
  3073. }
  3074. }, Object.defineProperty(PSProto, 'gravity', {
  3075. get: function get() {
  3076. !this._gravity && (this._gravity = cc.v2(0, 0));
  3077. return this._gravity;
  3078. },
  3079. set: function set(val) {
  3080. if (!val) return;
  3081. !this._gravity && (this._gravity = cc.v2(0, 0));
  3082. this.gravity.x = val.x;
  3083. this.gravity.y = val.y;
  3084. this._simulator && this._simulator.setGravity(val.x, val.y, 0);
  3085. }
  3086. });
  3087. Object.defineProperty(PSProto, 'sourcePos', {
  3088. get: function get() {
  3089. !this._sourcePos && (this._sourcePos = cc.v2(0, 0));
  3090. return this._sourcePos;
  3091. },
  3092. set: function set(val) {
  3093. if (!val) return;
  3094. !this._sourcePos && (this._sourcePos = cc.v2(0, 0));
  3095. this._sourcePos.x = val.x;
  3096. this._sourcePos.y = val.y;
  3097. this._simulator && this._simulator.setSourcePos(val.x, val.y, 0);
  3098. }
  3099. });
  3100. Object.defineProperty(PSProto, 'posVar', {
  3101. get: function get() {
  3102. !this._posVar && (this._posVar = cc.v2(0, 0));
  3103. return this._posVar;
  3104. },
  3105. set: function set(val) {
  3106. if (!val) return;
  3107. !this._posVar && (this._posVar = cc.v2(0, 0));
  3108. this._posVar.x = val.x;
  3109. this._posVar.y = val.y;
  3110. this._simulator && this._simulator.setPosVar(val.x, val.y, 0);
  3111. }
  3112. });
  3113. Object.defineProperty(PSProto, 'startColor', {
  3114. get: function get() {
  3115. !this._startColor && (this._startColor = cc.color(255, 255, 255, 255));
  3116. return this._startColor;
  3117. },
  3118. set: function set(val) {
  3119. if (!val) return;
  3120. !this._startColor && (this._startColor = cc.color(255, 255, 255, 255));
  3121. this._startColor.r = val.r;
  3122. this._startColor.g = val.g;
  3123. this._startColor.b = val.b;
  3124. this._startColor.a = val.a;
  3125. this._simulator && this._simulator.setStartColor(val.r, val.g, val.b, val.a);
  3126. }
  3127. });
  3128. Object.defineProperty(PSProto, 'startColorVar', {
  3129. get: function get() {
  3130. !this._startColorVar && (this._startColorVar = cc.color(0, 0, 0, 0));
  3131. return this._startColorVar;
  3132. },
  3133. set: function set(val) {
  3134. if (!val) return;
  3135. !this._startColorVar && (this._startColorVar = cc.color(0, 0, 0, 0));
  3136. this._startColorVar.r = val.r;
  3137. this._startColorVar.g = val.g;
  3138. this._startColorVar.b = val.b;
  3139. this._startColorVar.a = val.a;
  3140. this._simulator && this._simulator.setStartColorVar(val.r, val.g, val.b, val.a);
  3141. }
  3142. });
  3143. Object.defineProperty(PSProto, 'endColor', {
  3144. get: function get() {
  3145. !this._endColor && (this._endColor = cc.color(255, 255, 255, 0));
  3146. return this._endColor;
  3147. },
  3148. set: function set(val) {
  3149. if (!val) return;
  3150. !this._endColor && (this._endColor = cc.color(255, 255, 255, 0));
  3151. this._endColor.r = val.r;
  3152. this._endColor.g = val.g;
  3153. this._endColor.b = val.b;
  3154. this._endColor.a = val.a;
  3155. this._simulator && this._simulator.setEndColor(val.r, val.g, val.b, val.a);
  3156. }
  3157. });
  3158. Object.defineProperty(PSProto, 'endColorVar', {
  3159. get: function get() {
  3160. !this._endColorVar && (this._endColorVar = cc.color(0, 0, 0, 0));
  3161. return this._endColorVar;
  3162. },
  3163. set: function set(val) {
  3164. if (!val) return;
  3165. !this._endColorVar && (this._endColorVar = cc.color(0, 0, 0, 0));
  3166. this._endColorVar.r = val.r;
  3167. this._endColorVar.g = val.g;
  3168. this._endColorVar.b = val.b;
  3169. this._endColorVar.a = val.a;
  3170. this._simulator && this._simulator.setEndColorVar(val.r, val.g, val.b, val.a);
  3171. }
  3172. });
  3173. Object.defineProperty(PSProto, 'particleCount', {
  3174. get: function get() {
  3175. if (!this._simulator) {
  3176. return 0;
  3177. }
  3178. return this._simulator.getParticleCount();
  3179. }
  3180. });
  3181. Object.defineProperty(PSProto, 'active', {
  3182. get: function get() {
  3183. if (!this._simulator) {
  3184. return false;
  3185. }
  3186. return this._simulator.active();
  3187. }
  3188. });
  3189. PSProto.onLoad = function () {
  3190. this._simulator.bindNodeProxy(this.node._proxy);
  3191. }; // shield in native
  3192. PSProto.update = null;
  3193. PSProto.lateUpdate = null;
  3194. PSProto._resetAssembler = function () {
  3195. this._assembler = new renderer.CustomAssembler();
  3196. this._assembler.setUseModel(true);
  3197. this.node._proxy.setAssembler(this._assembler);
  3198. };
  3199. var _onEnable = PSProto.onEnable;
  3200. PSProto.onEnable = function () {
  3201. _onEnable.call(this);
  3202. if (this._simulator) {
  3203. this._simulator.onEnable();
  3204. }
  3205. };
  3206. var _onDisable = PSProto.onDisable;
  3207. PSProto.onDisable = function () {
  3208. _onDisable.call(this);
  3209. if (this._simulator) {
  3210. this._simulator.onDisable();
  3211. }
  3212. };
  3213. PSProto._onTextureLoaded = function () {
  3214. this._simulator.updateUVs(this._renderSpriteFrame.uv);
  3215. this._syncAspect();
  3216. this._simulator.aspectRatio = this._aspectRatio || 1.0;
  3217. this._updateMaterial();
  3218. this.markForRender(true);
  3219. };
  3220. var _updateMaterial = PSProto._updateMaterial;
  3221. PSProto._updateMaterial = function () {
  3222. _updateMaterial.call(this);
  3223. var material = this._materials[0];
  3224. material && this._simulator.setEffect(material.effect._nativeObj); // upload hash value to native
  3225. material && material.getHash();
  3226. };
  3227. var _initWithDictionary = PSProto._initWithDictionary;
  3228. PSProto._initWithDictionary = function (content) {
  3229. _initWithDictionary.call(this, content);
  3230. this._initProperties();
  3231. };
  3232. var __preload = PSProto.__preload;
  3233. PSProto.__preload = function () {
  3234. __preload.call(this);
  3235. this._initProperties();
  3236. };
  3237. })();
  3238. },{}],39:[function(require,module,exports){
  3239. "use strict";
  3240. /****************************************************************************
  3241. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  3242. http://www.cocos.com
  3243. Permission is hereby granted, free of charge, to any person obtaining a copy
  3244. of this software and associated engine source code (the "Software"), a limited,
  3245. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  3246. to use Cocos Creator solely to develop games on your target platforms. You shall
  3247. not use Cocos Creator software for developing other software or tools that's
  3248. used for developing games. You are not granted to publish, distribute,
  3249. sublicense, and/or sell copies of Cocos Creator.
  3250. The software or tools in this License Agreement are licensed, not sold.
  3251. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  3252. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3253. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3254. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3255. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3256. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3257. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3258. THE SOFTWARE.
  3259. ****************************************************************************/
  3260. // JS to Native bridges
  3261. if (window.JavascriptJavaBridge && cc.sys.os == cc.sys.OS_ANDROID) {
  3262. jsb.reflection = new JavascriptJavaBridge();
  3263. cc.sys.capabilities["keyboard"] = true;
  3264. } else if (window.JavaScriptObjCBridge && (cc.sys.os == cc.sys.OS_IOS || cc.sys.os == cc.sys.OS_OSX)) {
  3265. jsb.reflection = new JavaScriptObjCBridge();
  3266. }
  3267. },{}],40:[function(require,module,exports){
  3268. "use strict";
  3269. var SafeArea = cc.SafeArea;
  3270. if (SafeArea) {
  3271. var _onEnable = SafeArea.prototype.onEnable;
  3272. var _onDisable = SafeArea.prototype.onDisable;
  3273. Object.assign(SafeArea.prototype, {
  3274. onEnable: function onEnable() {
  3275. _onEnable.call(this);
  3276. this._adaptSafeAreaChangeWithThis = this.adaptSafeAreaChange.bind(this);
  3277. this._updateAreaWithThis = this.adaptSafeAreaChange.bind(this);
  3278. window.addEventListener('orientationchange', this._adaptSafeAreaChangeWithThis);
  3279. window.addEventListener('safearea-change', this._updateAreaWithThis);
  3280. },
  3281. onDisable: function onDisable() {
  3282. _onDisable.call(this);
  3283. window.removeEventListener('orientationchange', this._adaptSafeAreaChangeWithThis);
  3284. window.removeEventListener('safearea-change', this._updateAreaWithThis);
  3285. },
  3286. adaptSafeAreaChange: function adaptSafeAreaChange() {
  3287. var _this = this;
  3288. if (CC_JSB && (cc.sys.os === cc.sys.OS_IOS || cc.sys.os === cc.sys.OS_ANDROID)) {
  3289. setTimeout(function () {
  3290. _this.updateArea();
  3291. }, 200);
  3292. }
  3293. }
  3294. });
  3295. }
  3296. },{}],41:[function(require,module,exports){
  3297. "use strict";
  3298. (function () {
  3299. if (!cc.SkinnedMeshRenderer) return;
  3300. var SkinnedMeshAssembler = cc.SkinnedMeshRenderer.__assembler__.prototype;
  3301. cc.js.mixin(SkinnedMeshAssembler, {
  3302. updateRenderData: function updateRenderData(comp) {
  3303. comp.calcJointMatrix();
  3304. comp.node._renderFlag |= cc.RenderFlow.FLAG_UPDATE_RENDER_DATA;
  3305. }
  3306. });
  3307. })();
  3308. },{}],42:[function(require,module,exports){
  3309. "use strict";
  3310. /****************************************************************************
  3311. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  3312. http://www.cocos.com
  3313. Permission is hereby granted, free of charge, to any person obtaining a copy
  3314. of this software and associated engine source code (the "Software"), a limited,
  3315. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  3316. to use Cocos Creator solely to develop games on your target platforms. You shall
  3317. not use Cocos Creator software for developing other software or tools that's
  3318. used for developing games. You are not granted to publish, distribute,
  3319. sublicense, and/or sell copies of Cocos Creator.
  3320. The software or tools in this License Agreement are licensed, not sold.
  3321. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  3322. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3323. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3324. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3325. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3326. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3327. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3328. THE SOFTWARE.
  3329. ****************************************************************************/
  3330. var cacheManager = require('./jsb-cache-manager');
  3331. (function () {
  3332. if (window.sp === undefined || window.spine === undefined || window.middleware === undefined) return;
  3333. sp.VertexEffectDelegate = spine.VertexEffectDelegate;
  3334. jsb.generateGetSet(spine); // spine global time scale
  3335. Object.defineProperty(sp, 'timeScale', {
  3336. get: function get() {
  3337. return this._timeScale;
  3338. },
  3339. set: function set(value) {
  3340. this._timeScale = value;
  3341. spine.SkeletonAnimation.setGlobalTimeScale(value);
  3342. },
  3343. configurable: true
  3344. });
  3345. var _slotColor = cc.color(0, 0, 255, 255);
  3346. var _boneColor = cc.color(255, 0, 0, 255);
  3347. var _meshColor = cc.color(255, 255, 0, 255);
  3348. var _originColor = cc.color(0, 255, 0, 255);
  3349. var skeletonDataProto = sp.SkeletonData.prototype;
  3350. var _gTextureIdx = 1;
  3351. var _textureKeyMap = {};
  3352. var _textureMap = new WeakMap();
  3353. var skeletonDataMgr = spine.SkeletonDataMgr.getInstance();
  3354. spine.skeletonDataMgr = skeletonDataMgr;
  3355. skeletonDataMgr.setDestroyCallback(function (textureIndex) {
  3356. if (!textureIndex) return;
  3357. var texKey = _textureKeyMap[textureIndex];
  3358. if (texKey && _textureMap.has(texKey)) {
  3359. _textureMap["delete"](texKey);
  3360. delete _textureKeyMap[textureIndex];
  3361. }
  3362. });
  3363. var skeletonCacheMgr = spine.SkeletonCacheMgr.getInstance();
  3364. spine.skeletonCacheMgr = skeletonCacheMgr;
  3365. skeletonDataProto.destroy = function () {
  3366. this.reset();
  3367. skeletonCacheMgr.removeSkeletonCache(this._uuid);
  3368. cc.Asset.prototype.destroy.call(this);
  3369. };
  3370. skeletonDataProto.reset = function () {
  3371. if (this._skeletonCache) {
  3372. spine.disposeSkeletonData(this._uuid);
  3373. this._jsbTextures = null;
  3374. this._skeletonCache = null;
  3375. }
  3376. this._atlasCache = null;
  3377. };
  3378. skeletonDataProto.getRuntimeData = function () {
  3379. if (!this._skeletonCache) {
  3380. this.init();
  3381. }
  3382. return this._skeletonCache;
  3383. };
  3384. skeletonDataProto.init = function () {
  3385. if (this._skeletonCache) return;
  3386. var uuid = this._uuid;
  3387. if (!uuid) {
  3388. cc.errorID(7504);
  3389. return;
  3390. }
  3391. var skeletonCache = spine.retainSkeletonData(uuid);
  3392. if (skeletonCache) {
  3393. this._skeletonCache = skeletonCache;
  3394. this.width = this._skeletonCache.getWidth();
  3395. this.height = this._skeletonCache.getHeight();
  3396. return;
  3397. }
  3398. var atlasText = this.atlasText;
  3399. if (!atlasText) {
  3400. cc.errorID(7508, this.name);
  3401. return;
  3402. }
  3403. var textures = this.textures;
  3404. var textureNames = this.textureNames;
  3405. if (!(textures && textures.length > 0 && textureNames && textureNames.length > 0)) {
  3406. cc.errorID(7507, this.name);
  3407. return;
  3408. }
  3409. var jsbTextures = {};
  3410. for (var i = 0; i < textures.length; ++i) {
  3411. var texture = textures[i];
  3412. var textureIdx = this.recordTexture(texture);
  3413. var spTex = new middleware.Texture2D();
  3414. spTex.setRealTextureIndex(textureIdx);
  3415. spTex.setPixelsWide(texture.width);
  3416. spTex.setPixelsHigh(texture.height);
  3417. spTex.setTexParamCallback(function (texIdx, minFilter, magFilter, wrapS, warpT) {
  3418. var tex = this.getTextureByIndex(texIdx);
  3419. tex.setFilters(minFilter, magFilter);
  3420. tex.setWrapMode(wrapS, warpT);
  3421. }.bind(this));
  3422. spTex.setNativeTexture(texture.getImpl());
  3423. jsbTextures[textureNames[i]] = spTex;
  3424. }
  3425. this._jsbTextures = jsbTextures;
  3426. var filePath = null;
  3427. if (this.skeletonJsonStr) {
  3428. filePath = this.skeletonJsonStr;
  3429. } else {
  3430. filePath = cacheManager.getCache(this.nativeUrl) || this.nativeUrl;
  3431. }
  3432. this._skeletonCache = spine.initSkeletonData(uuid, filePath, atlasText, jsbTextures, this.scale);
  3433. if (this._skeletonCache) {
  3434. this.width = this._skeletonCache.getWidth();
  3435. this.height = this._skeletonCache.getHeight();
  3436. }
  3437. };
  3438. skeletonDataProto.recordTexture = function (texture) {
  3439. var index = _gTextureIdx;
  3440. var texKey = _textureKeyMap[index] = {
  3441. key: index
  3442. };
  3443. _textureMap.set(texKey, texture);
  3444. _gTextureIdx++;
  3445. return index;
  3446. };
  3447. skeletonDataProto.getTextureByIndex = function (textureIdx) {
  3448. var texKey = _textureKeyMap[textureIdx];
  3449. if (!texKey) return;
  3450. return _textureMap.get(texKey);
  3451. };
  3452. var renderCompProto = cc.RenderComponent.prototype;
  3453. var animation = spine.SkeletonAnimation.prototype; // The methods are added to be compatibility with old versions.
  3454. animation.setCompleteListener = function (listener) {
  3455. this._compeleteListener = listener;
  3456. this.setCompleteListenerNative(function (trackEntry) {
  3457. var loopCount = Math.floor(trackEntry.trackTime / trackEntry.animationEnd);
  3458. this._compeleteListener && this._compeleteListener(trackEntry, loopCount);
  3459. });
  3460. }; // The methods are added to be compatibility with old versions.
  3461. animation.setTrackCompleteListener = function (trackEntry, listener) {
  3462. this._trackCompeleteListener = listener;
  3463. this.setTrackCompleteListenerNative(trackEntry, function (trackEntryNative) {
  3464. var loopCount = Math.floor(trackEntryNative.trackTime / trackEntryNative.animationEnd);
  3465. this._trackCompeleteListener && this._trackCompeleteListener(trackEntryNative, loopCount);
  3466. });
  3467. }; // Temporary solution before upgrade the Spine API
  3468. animation.setAnimationListener = function (target, callback) {
  3469. this._target = target;
  3470. this._callback = callback;
  3471. this.setStartListener(function (trackEntry) {
  3472. if (this._target && this._callback) {
  3473. this._callback.call(this._target, this, trackEntry, sp.AnimationEventType.START, null, 0);
  3474. }
  3475. });
  3476. this.setInterruptListener(function (trackEntry) {
  3477. if (this._target && this._callback) {
  3478. this._callback.call(this._target, this, trackEntry, sp.AnimationEventType.INTERRUPT, null, 0);
  3479. }
  3480. });
  3481. this.setEndListener(function (trackEntry) {
  3482. if (this._target && this._callback) {
  3483. this._callback.call(this._target, this, trackEntry, sp.AnimationEventType.END, null, 0);
  3484. }
  3485. });
  3486. this.setDisposeListener(function (trackEntry) {
  3487. if (this._target && this._callback) {
  3488. this._callback.call(this._target, this, trackEntry, sp.AnimationEventType.DISPOSE, null, 0);
  3489. }
  3490. });
  3491. this.setCompleteListener(function (trackEntry, loopCount) {
  3492. if (this._target && this._callback) {
  3493. this._callback.call(this._target, this, trackEntry, sp.AnimationEventType.COMPLETE, null, loopCount);
  3494. }
  3495. });
  3496. this.setEventListener(function (trackEntry, event) {
  3497. if (this._target && this._callback) {
  3498. this._callback.call(this._target, this, trackEntry, sp.AnimationEventType.EVENT, event, 0);
  3499. }
  3500. });
  3501. };
  3502. sp.Skeleton._assembler = null;
  3503. var skeleton = sp.Skeleton.prototype;
  3504. var AnimationCacheMode = sp.Skeleton.AnimationCacheMode;
  3505. Object.defineProperty(skeleton, 'paused', {
  3506. get: function get() {
  3507. return this._paused || false;
  3508. },
  3509. set: function set(value) {
  3510. this._paused = value;
  3511. if (this._nativeSkeleton) {
  3512. this._nativeSkeleton.paused(value);
  3513. }
  3514. }
  3515. });
  3516. Object.defineProperty(skeleton, "premultipliedAlpha", {
  3517. get: function get() {
  3518. if (this._premultipliedAlpha === undefined) {
  3519. return true;
  3520. }
  3521. return this._premultipliedAlpha;
  3522. },
  3523. set: function set(value) {
  3524. this._premultipliedAlpha = value;
  3525. if (this._nativeSkeleton) {
  3526. this._nativeSkeleton.setOpacityModifyRGB(this._premultipliedAlpha);
  3527. }
  3528. }
  3529. });
  3530. Object.defineProperty(skeleton, "timeScale", {
  3531. get: function get() {
  3532. if (this._timeScale === undefined) return 1.0;
  3533. return this._timeScale;
  3534. },
  3535. set: function set(value) {
  3536. this._timeScale = value;
  3537. if (this._nativeSkeleton) {
  3538. this._nativeSkeleton.setTimeScale(this._timeScale);
  3539. }
  3540. }
  3541. });
  3542. var _updateDebugDraw = skeleton._updateDebugDraw;
  3543. skeleton._updateDebugDraw = function () {
  3544. _updateDebugDraw.call(this);
  3545. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3546. this._nativeSkeleton.setDebugMeshEnabled(this.debugMesh);
  3547. this._nativeSkeleton.setDebugSlotsEnabled(this.debugSlots);
  3548. this._nativeSkeleton.setDebugBonesEnabled(this.debugBones);
  3549. }
  3550. };
  3551. var _updateUseTint = skeleton._updateUseTint;
  3552. skeleton._updateUseTint = function () {
  3553. _updateUseTint.call(this);
  3554. if (this._nativeSkeleton) {
  3555. this._nativeSkeleton.setUseTint(this.useTint);
  3556. }
  3557. this._assembler && this._assembler.clearEffect();
  3558. };
  3559. var _updateBatch = skeleton._updateBatch;
  3560. skeleton._updateBatch = function () {
  3561. _updateBatch.call(this);
  3562. if (this._nativeSkeleton) {
  3563. this._nativeSkeleton.setBatchEnabled(this.enableBatch);
  3564. }
  3565. this._assembler && this._assembler.clearEffect();
  3566. };
  3567. var _onLoad = skeleton.onLoad;
  3568. skeleton.onLoad = function () {
  3569. if (_onLoad) {
  3570. _onLoad.call(this);
  3571. }
  3572. };
  3573. skeleton._resetAssembler = function () {
  3574. this._assembler = new renderer.CustomAssembler();
  3575. this.node._proxy.setAssembler(this._assembler);
  3576. };
  3577. var _updateMaterial = skeleton._updateMaterial;
  3578. var _materialHashMap = {};
  3579. var _materialId = 1;
  3580. skeleton._updateMaterial = function () {
  3581. _updateMaterial.call(this);
  3582. this._assembler && this._assembler.clearEffect();
  3583. var baseMaterial = this.getMaterial(0);
  3584. if (this._nativeSkeleton && baseMaterial) {
  3585. var originHash = baseMaterial.effect.getHash();
  3586. var id = _materialHashMap[originHash] || _materialId++;
  3587. _materialHashMap[originHash] = id;
  3588. baseMaterial.effect.updateHash(id);
  3589. var nativeEffect = baseMaterial.effect._nativeObj;
  3590. this._nativeSkeleton.setEffect(nativeEffect);
  3591. }
  3592. };
  3593. skeleton.setSkeletonData = function (skeletonData) {
  3594. null != skeletonData.width && null != skeletonData.height && this.node.setContentSize(skeletonData.width, skeletonData.height);
  3595. var uuid = skeletonData._uuid;
  3596. if (!uuid) {
  3597. cc.errorID(7504);
  3598. return;
  3599. }
  3600. var texValues = skeletonData.textures;
  3601. var texKeys = skeletonData.textureNames;
  3602. if (!(texValues && texValues.length > 0 && texKeys && texKeys.length > 0)) {
  3603. cc.errorID(7507, skeletonData.name);
  3604. return;
  3605. }
  3606. if (this._nativeSkeleton) {
  3607. this._nativeSkeleton.stopSchedule();
  3608. this._nativeSkeleton._comp = null;
  3609. this._nativeSkeleton = null;
  3610. }
  3611. var nativeSkeleton = null;
  3612. if (this.isAnimationCached()) {
  3613. nativeSkeleton = new spine.SkeletonCacheAnimation(uuid, this._cacheMode == AnimationCacheMode.SHARED_CACHE);
  3614. } else {
  3615. nativeSkeleton = new spine.SkeletonAnimation();
  3616. try {
  3617. spine.initSkeletonRenderer(nativeSkeleton, uuid);
  3618. } catch (e) {
  3619. cc._throw(e);
  3620. return;
  3621. }
  3622. nativeSkeleton.setDebugSlotsEnabled(this.debugSlots);
  3623. nativeSkeleton.setDebugMeshEnabled(this.debugMesh);
  3624. nativeSkeleton.setDebugBonesEnabled(this.debugBones);
  3625. }
  3626. this._nativeSkeleton = nativeSkeleton;
  3627. nativeSkeleton._comp = this;
  3628. nativeSkeleton.setUseTint(this.useTint);
  3629. nativeSkeleton.setOpacityModifyRGB(this.premultipliedAlpha);
  3630. nativeSkeleton.setTimeScale(this.timeScale);
  3631. nativeSkeleton.setBatchEnabled(this.enableBatch);
  3632. nativeSkeleton.bindNodeProxy(this.node._proxy);
  3633. nativeSkeleton.setColor(this.node.color);
  3634. this._skeleton = nativeSkeleton.getSkeleton(); // init skeleton listener
  3635. this._startListener && this.setStartListener(this._startListener);
  3636. this._endListener && this.setEndListener(this._endListener);
  3637. this._completeListener && this.setCompleteListener(this._completeListener);
  3638. this._eventListener && this.setEventListener(this._eventListener);
  3639. this._interruptListener && this.setInterruptListener(this._interruptListener);
  3640. this._disposeListener && this.setDisposeListener(this._disposeListener);
  3641. this._updateMaterial();
  3642. this.markForRender(true);
  3643. };
  3644. skeleton._updateColor = function () {
  3645. if (this._nativeSkeleton) {
  3646. this._nativeSkeleton.setColor(this.node.color);
  3647. }
  3648. };
  3649. skeleton.setAnimationStateData = function (stateData) {
  3650. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3651. this._stateData = stateData;
  3652. return this._nativeSkeleton.setAnimationStateData(stateData);
  3653. }
  3654. };
  3655. skeleton.onEnable = function () {
  3656. renderCompProto.onEnable.call(this);
  3657. if (this._nativeSkeleton) {
  3658. this._nativeSkeleton.onEnable();
  3659. }
  3660. };
  3661. skeleton.onDisable = function () {
  3662. renderCompProto.onDisable.call(this);
  3663. if (this._nativeSkeleton) {
  3664. this._nativeSkeleton.onDisable();
  3665. }
  3666. };
  3667. skeleton.setVertexEffectDelegate = function (effectDelegate) {
  3668. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3669. this._nativeSkeleton.setVertexEffectDelegate(effectDelegate);
  3670. }
  3671. };
  3672. skeleton.update = function () {
  3673. var nativeSkeleton = this._nativeSkeleton;
  3674. if (!nativeSkeleton) return;
  3675. var node = this.node;
  3676. if (!node) return;
  3677. if (!this.isAnimationCached() && (this.debugBones || this.debugSlots || this.debugMesh) && this._debugRenderer) {
  3678. var graphics = this._debugRenderer;
  3679. graphics.clear();
  3680. graphics.lineWidth = 2;
  3681. var debugData = this._debugData || nativeSkeleton.getDebugData();
  3682. if (!debugData) return;
  3683. var debugIdx = 0,
  3684. debugType = 0,
  3685. debugLen = 0;
  3686. while (true) {
  3687. debugType = debugData[debugIdx++];
  3688. if (debugType == 0) break;
  3689. debugLen = debugData[debugIdx++];
  3690. switch (debugType) {
  3691. case 1:
  3692. // slots
  3693. graphics.strokeColor = _slotColor;
  3694. for (var i = 0; i < debugLen; i += 8) {
  3695. graphics.moveTo(debugData[debugIdx++], debugData[debugIdx++]);
  3696. graphics.lineTo(debugData[debugIdx++], debugData[debugIdx++]);
  3697. graphics.lineTo(debugData[debugIdx++], debugData[debugIdx++]);
  3698. graphics.lineTo(debugData[debugIdx++], debugData[debugIdx++]);
  3699. graphics.close();
  3700. graphics.stroke();
  3701. }
  3702. break;
  3703. case 2:
  3704. // mesh
  3705. graphics.strokeColor = _meshColor;
  3706. for (var _i = 0; _i < debugLen; _i += 6) {
  3707. graphics.moveTo(debugData[debugIdx++], debugData[debugIdx++]);
  3708. graphics.lineTo(debugData[debugIdx++], debugData[debugIdx++]);
  3709. graphics.lineTo(debugData[debugIdx++], debugData[debugIdx++]);
  3710. graphics.close();
  3711. graphics.stroke();
  3712. }
  3713. break;
  3714. case 3:
  3715. // bones
  3716. graphics.strokeColor = _boneColor;
  3717. graphics.fillColor = _slotColor; // Root bone color is same as slot color.
  3718. for (var _i2 = 0; _i2 < debugLen; _i2 += 4) {
  3719. var bx = debugData[debugIdx++];
  3720. var by = debugData[debugIdx++];
  3721. var x = debugData[debugIdx++];
  3722. var y = debugData[debugIdx++]; // Bone lengths.
  3723. graphics.moveTo(bx, by);
  3724. graphics.lineTo(x, y);
  3725. graphics.stroke(); // Bone origins.
  3726. graphics.circle(bx, by, Math.PI * 1.5);
  3727. graphics.fill();
  3728. if (_i2 === 0) {
  3729. graphics.fillColor = _originColor;
  3730. }
  3731. }
  3732. break;
  3733. default:
  3734. return;
  3735. }
  3736. }
  3737. }
  3738. };
  3739. skeleton.updateWorldTransform = function () {
  3740. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3741. this._nativeSkeleton.updateWorldTransform();
  3742. }
  3743. };
  3744. skeleton.setToSetupPose = function () {
  3745. if (this._nativeSkeleton) {
  3746. this._nativeSkeleton.setToSetupPose();
  3747. }
  3748. };
  3749. skeleton.setBonesToSetupPose = function () {
  3750. if (this._nativeSkeleton) {
  3751. this._nativeSkeleton.setBonesToSetupPose();
  3752. }
  3753. };
  3754. skeleton.setSlotsToSetupPose = function () {
  3755. if (this._nativeSkeleton) {
  3756. this._nativeSkeleton.setSlotsToSetupPose();
  3757. }
  3758. };
  3759. skeleton.setSlotsRange = function (startSlotIndex, endSlotIndex) {
  3760. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3761. this._nativeSkeleton.setSlotsRange(startSlotIndex, endSlotIndex);
  3762. }
  3763. };
  3764. skeleton.updateAnimationCache = function (animName) {
  3765. if (!this.isAnimationCached()) return;
  3766. if (this._nativeSkeleton) {
  3767. if (animName) {
  3768. this._nativeSkeleton.updateAnimationCache(animName);
  3769. } else {
  3770. this._nativeSkeleton.updateAllAnimationCache();
  3771. }
  3772. }
  3773. };
  3774. skeleton.invalidAnimationCache = function () {
  3775. if (!this.isAnimationCached()) return;
  3776. if (this._nativeSkeleton) {
  3777. this._nativeSkeleton.updateAllAnimationCache();
  3778. }
  3779. };
  3780. skeleton.findBone = function (boneName) {
  3781. if (this._nativeSkeleton) return this._nativeSkeleton.findBone(boneName);
  3782. return null;
  3783. };
  3784. skeleton.findSlot = function (slotName) {
  3785. if (this._nativeSkeleton) return this._nativeSkeleton.findSlot(slotName);
  3786. return null;
  3787. };
  3788. skeleton.setSkin = function (skinName) {
  3789. if (this._nativeSkeleton) return this._nativeSkeleton.setSkin(skinName);
  3790. return null;
  3791. };
  3792. skeleton.getAttachment = function (slotName, attachmentName) {
  3793. if (this._nativeSkeleton) return this._nativeSkeleton.getAttachment(slotName, attachmentName);
  3794. return null;
  3795. };
  3796. skeleton.setAttachment = function (slotName, attachmentName) {
  3797. this._nativeSkeleton && this._nativeSkeleton.setAttachment(slotName, attachmentName);
  3798. };
  3799. skeleton.getTextureAtlas = function (regionAttachment) {
  3800. cc.warn("sp.Skeleton getTextureAtlas not support in native");
  3801. return null;
  3802. };
  3803. skeleton.setMix = function (fromAnimation, toAnimation, duration) {
  3804. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3805. this._nativeSkeleton.setMix(fromAnimation, toAnimation, duration);
  3806. }
  3807. };
  3808. skeleton.setAnimation = function (trackIndex, name, loop) {
  3809. if (this._nativeSkeleton) {
  3810. if (this.isAnimationCached()) {
  3811. return this._nativeSkeleton.setAnimation(name, loop);
  3812. } else {
  3813. return this._nativeSkeleton.setAnimation(trackIndex, name, loop);
  3814. }
  3815. }
  3816. return null;
  3817. };
  3818. skeleton.addAnimation = function (trackIndex, name, loop, delay) {
  3819. if (this._nativeSkeleton) {
  3820. delay = delay || 0;
  3821. if (this.isAnimationCached()) {
  3822. return this._nativeSkeleton.addAnimation(name, loop, delay);
  3823. } else {
  3824. return this._nativeSkeleton.addAnimation(trackIndex, name, loop, delay);
  3825. }
  3826. }
  3827. return null;
  3828. };
  3829. skeleton.findAnimation = function (name) {
  3830. if (this._nativeSkeleton) return this._nativeSkeleton.findAnimation(name);
  3831. return null;
  3832. };
  3833. skeleton.getCurrent = function (trackIndex) {
  3834. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3835. return this._nativeSkeleton.getCurrent(trackIndex);
  3836. }
  3837. return null;
  3838. };
  3839. skeleton.clearTracks = function () {
  3840. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3841. this._nativeSkeleton.clearTracks();
  3842. }
  3843. };
  3844. skeleton.clearTrack = function (trackIndex) {
  3845. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3846. this._nativeSkeleton.clearTrack(trackIndex);
  3847. }
  3848. };
  3849. skeleton.setStartListener = function (listener) {
  3850. this._startListener = listener;
  3851. if (this._nativeSkeleton) {
  3852. if (this.isAnimationCached()) {
  3853. this._nativeSkeleton.setStartListener(function (animationName) {
  3854. var self = this._comp;
  3855. self._startEntry.animation.name = animationName;
  3856. self._startListener && self._startListener(self._startEntry);
  3857. });
  3858. } else {
  3859. this._nativeSkeleton.setStartListener(listener);
  3860. }
  3861. }
  3862. };
  3863. skeleton.setInterruptListener = function (listener) {
  3864. this._interruptListener = listener;
  3865. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3866. this._nativeSkeleton.setInterruptListener(listener);
  3867. }
  3868. };
  3869. skeleton.setEndListener = function (listener) {
  3870. this._endListener = listener;
  3871. if (this._nativeSkeleton) {
  3872. if (this.isAnimationCached()) {
  3873. this._nativeSkeleton.setEndListener(function (animationName) {
  3874. var self = this._comp;
  3875. self._endEntry.animation.name = animationName;
  3876. self._endListener && self._endListener(self._endEntry);
  3877. });
  3878. } else {
  3879. this._nativeSkeleton.setEndListener(listener);
  3880. }
  3881. }
  3882. };
  3883. skeleton.setDisposeListener = function (listener) {
  3884. this._disposeListener = listener;
  3885. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3886. this._nativeSkeleton.setDisposeListener(listener);
  3887. }
  3888. };
  3889. skeleton.setCompleteListener = function (listener) {
  3890. this._completeListener = listener;
  3891. if (this._nativeSkeleton) {
  3892. if (this.isAnimationCached()) {
  3893. this._nativeSkeleton.setCompleteListener(function (animationName) {
  3894. var self = this._comp;
  3895. self._endEntry.animation.name = animationName;
  3896. self._completeListener && self._completeListener(self._endEntry);
  3897. });
  3898. } else {
  3899. this._nativeSkeleton.setCompleteListener(listener);
  3900. }
  3901. }
  3902. };
  3903. skeleton.setEventListener = function (listener) {
  3904. this._eventListener = listener;
  3905. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3906. this._nativeSkeleton.setEventListener(listener);
  3907. }
  3908. };
  3909. skeleton.setTrackStartListener = function (entry, listener) {
  3910. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3911. this._nativeSkeleton.setTrackStartListener(entry, listener);
  3912. }
  3913. };
  3914. skeleton.setTrackInterruptListener = function (entry, listener) {
  3915. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3916. this._nativeSkeleton.setTrackInterruptListener(entry, listener);
  3917. }
  3918. };
  3919. skeleton.setTrackEndListener = function (entry, listener) {
  3920. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3921. this._nativeSkeleton.setTrackEndListener(entry, listener);
  3922. }
  3923. };
  3924. skeleton.setTrackDisposeListener = function (entry, listener) {
  3925. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3926. this._nativeSkeleton.setTrackDisposeListener(entry, listener);
  3927. }
  3928. };
  3929. skeleton.setTrackCompleteListener = function (entry, listener) {
  3930. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3931. this._nativeSkeleton.setTrackCompleteListener(entry, listener);
  3932. }
  3933. };
  3934. skeleton.setTrackEventListener = function (entry, listener) {
  3935. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3936. this._nativeSkeleton.setTrackEventListener(entry, listener);
  3937. }
  3938. };
  3939. skeleton.getState = function () {
  3940. if (this._nativeSkeleton && !this.isAnimationCached()) {
  3941. return this._nativeSkeleton.getState();
  3942. }
  3943. };
  3944. skeleton._ensureListener = function () {
  3945. cc.warn("sp.Skeleton _ensureListener not need in native");
  3946. };
  3947. skeleton._updateSkeletonData = function () {
  3948. if (this.skeletonData) {
  3949. this.skeletonData.init();
  3950. this.setSkeletonData(this.skeletonData);
  3951. this.attachUtil.init(this);
  3952. this.attachUtil._associateAttachedNode();
  3953. this._preCacheMode = this._cacheMode;
  3954. this.defaultSkin && this._nativeSkeleton.setSkin(this.defaultSkin);
  3955. this.animation = this.defaultAnimation;
  3956. } else {
  3957. if (this._nativeSkeleton) {
  3958. this._nativeSkeleton.stopSchedule();
  3959. this._nativeSkeleton._comp = null;
  3960. this._nativeSkeleton = null;
  3961. }
  3962. }
  3963. };
  3964. var _onDestroy = skeleton.onDestroy;
  3965. skeleton.onDestroy = function () {
  3966. _onDestroy.call(this);
  3967. if (this._nativeSkeleton) {
  3968. this._nativeSkeleton.stopSchedule();
  3969. this._nativeSkeleton._comp = null;
  3970. this._nativeSkeleton = null;
  3971. }
  3972. this._stateData = null;
  3973. this._materialCache = null;
  3974. }; ////////////////////////////////////////////////////////////
  3975. // adapt attach util
  3976. ////////////////////////////////////////////////////////////
  3977. var attachUtilProto = sp.AttachUtil.prototype;
  3978. var _attachUtilInit = attachUtilProto.init;
  3979. attachUtilProto.init = function (skeletonComp) {
  3980. _attachUtilInit.call(this, skeletonComp);
  3981. this._nativeSkeleton = skeletonComp._nativeSkeleton;
  3982. this._attachUtilNative = null;
  3983. };
  3984. var _generateAllAttachedNodes = attachUtilProto.generateAllAttachedNodes;
  3985. attachUtilProto.generateAllAttachedNodes = function () {
  3986. var res = _generateAllAttachedNodes.call(this);
  3987. this._associateAttachedNode();
  3988. return res;
  3989. };
  3990. var _generateAttachedNodes = attachUtilProto.generateAttachedNodes;
  3991. attachUtilProto.generateAttachedNodes = function (boneName) {
  3992. var res = _generateAttachedNodes.call(this, boneName);
  3993. this._associateAttachedNode();
  3994. return res;
  3995. };
  3996. var _associateAttachedNode = attachUtilProto._associateAttachedNode;
  3997. attachUtilProto._associateAttachedNode = function () {
  3998. if (!this._inited) return;
  3999. var rootNode = this._skeletonNode.getChildByName('ATTACHED_NODE_TREE');
  4000. if (!rootNode || !rootNode.isValid) return; // associate js
  4001. _associateAttachedNode.call(this); // associate native
  4002. if (!this._attachUtilNative) {
  4003. if (this._skeletonComp.isAnimationCached()) {
  4004. this._attachUtilNative = new spine.CacheModeAttachUtil();
  4005. } else {
  4006. this._attachUtilNative = new spine.RealTimeAttachUtil();
  4007. }
  4008. this._nativeSkeleton.setAttachUtil(this._attachUtilNative);
  4009. }
  4010. this._attachUtilNative.associateAttachedNode(this._skeleton, this._skeletonNode._proxy);
  4011. };
  4012. })();
  4013. },{"./jsb-cache-manager":30}],43:[function(require,module,exports){
  4014. /****************************************************************************
  4015. Copyright (c) 2013-2016 Chukong Technologies Inc.
  4016. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  4017. http://www.cocos.com
  4018. Permission is hereby granted, free of charge, to any person obtaining a copy
  4019. of this software and associated engine source code (the "Software"), a limited,
  4020. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  4021. to use Cocos Creator solely to develop games on your target platforms. You shall
  4022. not use Cocos Creator software for developing other software or tools that's
  4023. used for developing games. You are not granted to publish, distribute,
  4024. sublicense, and/or sell copies of Cocos Creator.
  4025. The software or tools in this License Agreement are licensed, not sold.
  4026. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  4027. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4028. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4029. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4030. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4031. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4032. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4033. THE SOFTWARE.
  4034. ****************************************************************************/
  4035. 'use strict';
  4036. var sys = cc.sys;
  4037. sys.getNetworkType = jsb.Device.getNetworkType;
  4038. sys.getBatteryLevel = jsb.Device.getBatteryLevel;
  4039. sys.garbageCollect = jsb.garbageCollect;
  4040. sys.restartVM = __restartVM;
  4041. sys.isObjectValid = __isObjectValid;
  4042. sys.getSafeAreaRect = function () {
  4043. // x(top), y(left), z(bottom), w(right)
  4044. var edge = jsb.Device.getSafeAreaEdge();
  4045. var screenSize = cc.view.getFrameSize(); // Get leftBottom and rightTop point in UI coordinates
  4046. var leftBottom = new cc.Vec2(edge.y, screenSize.height - edge.z);
  4047. var rightTop = new cc.Vec2(screenSize.width - edge.w, edge.x); // Returns the real location in view.
  4048. var relatedPos = {
  4049. left: 0,
  4050. top: 0,
  4051. width: screenSize.width,
  4052. height: screenSize.height
  4053. };
  4054. cc.view.convertToLocationInView(leftBottom.x, leftBottom.y, relatedPos, leftBottom);
  4055. cc.view.convertToLocationInView(rightTop.x, rightTop.y, relatedPos, rightTop); // convert view point to design resolution size
  4056. cc.view._convertPointWithScale(leftBottom);
  4057. cc.view._convertPointWithScale(rightTop);
  4058. return cc.rect(leftBottom.x, leftBottom.y, rightTop.x - leftBottom.x, rightTop.y - leftBottom.y);
  4059. };
  4060. },{}],44:[function(require,module,exports){
  4061. "use strict";
  4062. /****************************************************************************
  4063. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  4064. https://www.cocos.com/
  4065. Permission is hereby granted, free of charge, to any person obtaining a copy
  4066. of this software and associated engine source code (the "Software"), a limited,
  4067. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  4068. to use Cocos Creator solely to develop games on your target platforms. You shall
  4069. not use Cocos Creator software for developing other software or tools that's
  4070. used for developing games. You are not granted to publish, distribute,
  4071. sublicense, and/or sell copies of Cocos Creator.
  4072. The software or tools in this License Agreement are licensed, not sold.
  4073. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  4074. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4075. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4076. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4077. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4078. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4079. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4080. THE SOFTWARE.
  4081. ****************************************************************************/
  4082. (function () {
  4083. if (!cc.TiledMap) return;
  4084. var RenderFlow = cc.RenderFlow; // tiled layer
  4085. var TiledLayer = cc.TiledLayer.prototype;
  4086. var _addUserNode = TiledLayer.addUserNode;
  4087. TiledLayer.addUserNode = function (node) {
  4088. var result = _addUserNode.call(this, node);
  4089. if (result) {
  4090. var proxy = node._proxy;
  4091. proxy && proxy.enableVisit(false);
  4092. }
  4093. };
  4094. var _removeUserNode = TiledLayer.removeUserNode;
  4095. TiledLayer.removeUserNode = function (node) {
  4096. var result = _removeUserNode.call(this, node);
  4097. if (result) {
  4098. var proxy = node._proxy;
  4099. proxy && proxy.enableVisit(true);
  4100. }
  4101. }; // override _buildMaterial to upload hash value to native
  4102. var _buildMaterial = TiledLayer._buildMaterial;
  4103. TiledLayer._buildMaterial = function (tilesetIdx) {
  4104. var material = _buildMaterial.call(this, tilesetIdx);
  4105. if (material) material.getHash();
  4106. }; // tiledmap buffer
  4107. var TiledMapBuffer = cc.TiledMapBuffer.prototype;
  4108. TiledMapBuffer._updateOffset = function () {
  4109. var offsetInfo = this._offsetInfo;
  4110. offsetInfo.vertexOffset = this.vertexOffset;
  4111. offsetInfo.indiceOffset = this.indiceOffset;
  4112. offsetInfo.byteOffset = this.byteOffset;
  4113. }; // tiledmap render data list
  4114. var TiledMapRenderDataList = cc.TiledMapRenderDataList.prototype;
  4115. TiledMapRenderDataList._pushRenderData = function () {
  4116. var renderData = {};
  4117. renderData.ia = {};
  4118. renderData.nodesRenderList = [];
  4119. this._dataList.push(renderData);
  4120. };
  4121. TiledMapRenderDataList.reset = function () {
  4122. this._offset = 0;
  4123. var assembler = this._nativeAssembler;
  4124. assembler._effect.length = 0;
  4125. assembler.reset();
  4126. };
  4127. TiledMapRenderDataList.setNativeAssembler = function (assembler) {
  4128. this._nativeAssembler = assembler;
  4129. };
  4130. TiledMapRenderDataList.popRenderData = function (buffer) {
  4131. if (this._offset >= this._dataList.length) {
  4132. this._pushRenderData();
  4133. }
  4134. var renderData = this._dataList[this._offset];
  4135. renderData.nodesRenderList.length = 0;
  4136. this._nativeAssembler.clearNodes(this._offset);
  4137. var ia = renderData.ia;
  4138. ia._meshIndex = buffer.getCurMeshIndex();
  4139. ia._start = buffer.indiceOffset;
  4140. ia._count = 0;
  4141. ia._verticesStart = buffer.vertexOffset;
  4142. ia._index = this._offset;
  4143. this._offset++;
  4144. return renderData;
  4145. };
  4146. TiledMapRenderDataList.pushNodesList = function (renderData, nodesList) {
  4147. var nodesRenderList = renderData.nodesRenderList;
  4148. nodesRenderList.push(nodesList);
  4149. var nativeNodes = [];
  4150. for (var j = 0; j < nodesRenderList.length; j++) {
  4151. var _nodesList = nodesRenderList[j];
  4152. if (!_nodesList) continue;
  4153. for (var idx = 0; idx < _nodesList.length; idx++) {
  4154. var dataComp = _nodesList[idx];
  4155. if (!dataComp) continue;
  4156. nativeNodes.push(dataComp.node._id);
  4157. }
  4158. }
  4159. this._nativeAssembler.updateNodes(renderData.ia._index, nativeNodes);
  4160. };
  4161. var ModelBatcherDelegate = cc.Class({
  4162. ctor: function ctor() {
  4163. this._nativeAssembler = null;
  4164. },
  4165. setNativeAssembler: function setNativeAssembler(assembler) {
  4166. this._nativeAssembler = assembler;
  4167. },
  4168. setBuffer: function setBuffer(buffer) {
  4169. this._buffer = buffer;
  4170. },
  4171. _flushIA: function _flushIA(ia) {
  4172. var iaIndex = ia._index;
  4173. var meshIndex = ia._meshIndex;
  4174. this._nativeAssembler.updateMeshIndex(iaIndex, meshIndex);
  4175. var verticesStart = ia._verticesStart;
  4176. var verticesOffset = this._buffer.vertexOffset;
  4177. var vertexCount = verticesOffset - verticesStart;
  4178. this._nativeAssembler.updateVerticesRange(iaIndex, verticesStart, vertexCount);
  4179. this._nativeAssembler.updateIndicesRange(iaIndex, ia._start, ia._count);
  4180. this._nativeAssembler.updateMaterial(iaIndex, this.material);
  4181. },
  4182. _flush: function _flush() {}
  4183. });
  4184. var TiledMapAssembler = cc.TiledLayer.__assembler__.prototype;
  4185. var _fillBuffers = TiledMapAssembler.fillBuffers;
  4186. cc.js.mixin(TiledMapAssembler, {
  4187. _extendNative: function _extendNative() {
  4188. renderer.TiledMapAssembler.prototype.ctor.call(this);
  4189. },
  4190. // override _updateRenderData function avoid base class cover material
  4191. _updateRenderData: function _updateRenderData() {
  4192. if (!this._renderComp || !this._renderComp.isValid) return;
  4193. this.updateRenderData(this._renderComp);
  4194. },
  4195. updateRenderData: function updateRenderData(comp) {
  4196. if (!comp._modelBatcherDelegate) {
  4197. comp._buffer = new cc.TiledMapBuffer(null, cc.gfx.VertexFormat.XY_UV_Color);
  4198. comp._renderDataList = new cc.TiledMapRenderDataList();
  4199. comp._modelBatcherDelegate = new ModelBatcherDelegate();
  4200. comp._buffer.setNativeAssembler(this);
  4201. comp._renderDataList.setNativeAssembler(this);
  4202. comp._modelBatcherDelegate.setBuffer(comp._buffer);
  4203. comp._modelBatcherDelegate.setNativeAssembler(this);
  4204. }
  4205. _fillBuffers.call(this, comp, comp._modelBatcherDelegate);
  4206. comp.node._renderFlag |= RenderFlow.FLAG_UPDATE_RENDER_DATA;
  4207. }
  4208. }, renderer.TiledMapAssembler.prototype);
  4209. })();
  4210. },{}],45:[function(require,module,exports){
  4211. "use strict";
  4212. /****************************************************************************
  4213. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  4214. https://www.cocos.com/
  4215. Permission is hereby granted, free of charge, to any person obtaining a copy
  4216. of this software and associated engine source code (the "Software"), a limited,
  4217. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  4218. to use Cocos Creator solely to develop games on your target platforms. You shall
  4219. not use Cocos Creator software for developing other software or tools that's
  4220. used for developing games. You are not granted to publish, distribute,
  4221. sublicense, and/or sell copies of Cocos Creator.
  4222. The software or tools in this License Agreement are licensed, not sold.
  4223. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  4224. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4225. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4226. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4227. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4228. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4229. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4230. THE SOFTWARE.
  4231. ****************************************************************************/
  4232. (function () {
  4233. if (!(cc && cc.VideoPlayer && cc.VideoPlayer.Impl)) {
  4234. return;
  4235. }
  4236. var vec3 = cc.Vec3;
  4237. var _worldMat = new cc.Mat4();
  4238. var _topLeft = new vec3();
  4239. var _bottomRight = new vec3();
  4240. var _impl = cc.VideoPlayer.Impl;
  4241. var _p = cc.VideoPlayer.Impl.prototype;
  4242. _p._bindEvent = function () {
  4243. var video = this._video,
  4244. self = this;
  4245. if (!video) {
  4246. return;
  4247. } //binding event
  4248. var cbs = this.__eventListeners;
  4249. cbs.loadedmetadata = function () {
  4250. self._loadedmeta = true;
  4251. self._dispatchEvent(_impl.EventType.META_LOADED);
  4252. if (self._playing) {
  4253. self._video.play();
  4254. }
  4255. };
  4256. cbs.ended = function () {
  4257. if (self._video !== video) return;
  4258. self._playing = false;
  4259. self._dispatchEvent(_impl.EventType.COMPLETED);
  4260. };
  4261. cbs.play = function () {
  4262. if (self._video !== video) return;
  4263. self._playing = true;
  4264. self._dispatchEvent(_impl.EventType.PLAYING);
  4265. };
  4266. cbs.pause = function () {
  4267. if (self._ignorePause || self._video !== video) return;
  4268. self._playing = false;
  4269. self._dispatchEvent(_impl.EventType.PAUSED);
  4270. };
  4271. cbs.click = function () {
  4272. self._dispatchEvent(_impl.EventType.CLICKED);
  4273. };
  4274. cbs.stoped = function () {
  4275. self._dispatchEvent(_impl.EventType.STOPPED);
  4276. self._ignorePause = false;
  4277. };
  4278. video.addEventListener("loadedmetadata", cbs.loadedmetadata);
  4279. video.addEventListener("ended", cbs.ended);
  4280. video.addEventListener("play", cbs.play);
  4281. video.addEventListener("pause", cbs.pause);
  4282. video.addEventListener("click", cbs.click);
  4283. video.addEventListener("stoped", cbs.stoped);
  4284. function onCanPlay() {
  4285. if (this._loaded) return;
  4286. this._loaded = true;
  4287. this._dispatchEvent(_impl.EventType.READY_TO_PLAY);
  4288. this._updateVisibility();
  4289. }
  4290. cbs.onCanPlay = onCanPlay.bind(this);
  4291. video.addEventListener('canplay', cbs.onCanPlay);
  4292. video.addEventListener('canplaythrough', cbs.onCanPlay);
  4293. video.addEventListener('suspend', cbs.onCanPlay);
  4294. };
  4295. _p._updateVisibility = function () {
  4296. if (!this._video) return;
  4297. var video = this._video;
  4298. if (this._visible) {
  4299. this._video.setVisible(true);
  4300. } else {
  4301. this._video.setVisible(false);
  4302. video.pause();
  4303. this._playing = false;
  4304. }
  4305. };
  4306. _p._updateSize = function (width, height) {};
  4307. _p.createDomElementIfNeeded = function () {
  4308. if (!jsb.VideoPlayer) {
  4309. cc.warn('VideoPlayer is not supported.');
  4310. return null;
  4311. }
  4312. if (!this._video) {
  4313. this._video = new jsb.VideoPlayer();
  4314. }
  4315. };
  4316. _p.removeDom = function () {
  4317. var video = this._video;
  4318. if (video) {
  4319. video.stop();
  4320. video.setVisible(false);
  4321. var cbs = this.__eventListeners;
  4322. cbs.loadedmetadata = null;
  4323. cbs.ended = null;
  4324. cbs.play = null;
  4325. cbs.pause = null;
  4326. cbs.click = null;
  4327. cbs.onCanPlay = null;
  4328. video.destroy();
  4329. }
  4330. this._video = null;
  4331. this._url = "";
  4332. };
  4333. _p.setURL = function (path) {
  4334. var source, extname;
  4335. if (this._url === path) {
  4336. return;
  4337. }
  4338. this.removeDom();
  4339. this._url = path;
  4340. this.createDomElementIfNeeded();
  4341. this._bindEvent();
  4342. var video = this._video;
  4343. if (!video) {
  4344. return;
  4345. }
  4346. video.setVisible(this._visible);
  4347. this._loaded = false;
  4348. this._played = false;
  4349. this._playing = false;
  4350. this._loadedmeta = false;
  4351. video.setURL(this._url);
  4352. this._forceUpdate = true;
  4353. };
  4354. _p.getURL = function () {
  4355. return this._url;
  4356. };
  4357. _p.play = function () {
  4358. var video = this._video;
  4359. if (!video || !this._visible || this._playing) return;
  4360. video.play();
  4361. this._playing = true;
  4362. };
  4363. _p.setStayOnBottom = function (enabled) {};
  4364. _p.pause = function () {
  4365. var video = this._video;
  4366. if (!this._playing || !video) return;
  4367. video.pause();
  4368. this._playing = false;
  4369. };
  4370. _p.resume = function () {
  4371. var video = this._video;
  4372. if (this._playing || !video) return;
  4373. video.resume();
  4374. this._playing = true;
  4375. };
  4376. _p.stop = function () {
  4377. var video = this._video;
  4378. if (!video || !this._visible) return;
  4379. this._ignorePause = true;
  4380. video.stop();
  4381. this._playing = false;
  4382. };
  4383. _p.setVolume = function (volume) {};
  4384. _p.seekTo = function (time) {
  4385. var video = this._video;
  4386. if (!video) return;
  4387. if (this._loaded) {
  4388. video.seekTo(time);
  4389. } else {
  4390. var cb = function cb() {
  4391. video.seekTo(time);
  4392. };
  4393. video.addEventListener(_impl._polyfill.event, cb);
  4394. }
  4395. };
  4396. _p.isPlaying = function () {
  4397. return this._playing;
  4398. };
  4399. _p.duration = function () {
  4400. var video = this._video;
  4401. var duration = -1;
  4402. if (!video) return duration;
  4403. duration = video.duration();
  4404. if (duration <= 0) {
  4405. cc.logID(7702);
  4406. }
  4407. return duration;
  4408. };
  4409. _p.currentTime = function () {
  4410. var video = this._video;
  4411. if (!video) return -1;
  4412. return video.currentTime();
  4413. };
  4414. _p.setKeepAspectRatioEnabled = function (isEnabled) {
  4415. if (!this._video) {
  4416. return false;
  4417. }
  4418. return this._video.setKeepAspectRatioEnabled(isEnabled);
  4419. };
  4420. _p.isKeepAspectRatioEnabled = function () {
  4421. if (!this._video) {
  4422. return false;
  4423. }
  4424. return this._video.isKeepAspectRatioEnabled();
  4425. };
  4426. _p.isFullScreenEnabled = function () {
  4427. return this._fullScreenEnabled;
  4428. };
  4429. _p.setEventListener = function (event, callback) {
  4430. this._EventList[event] = callback;
  4431. };
  4432. _p.removeEventListener = function (event) {
  4433. this._EventList[event] = null;
  4434. };
  4435. _p._dispatchEvent = function (event) {
  4436. var callback = this._EventList[event];
  4437. if (callback) callback.call(this, this, this._video.src);
  4438. };
  4439. _p.onPlayEvent = function () {
  4440. var callback = this._EventList[_impl.EventType.PLAYING];
  4441. callback.call(this, this, this._video.src);
  4442. };
  4443. _p.enable = function () {
  4444. var list = _impl.elements;
  4445. if (list.indexOf(this) === -1) list.push(this);
  4446. this.setVisible(true);
  4447. };
  4448. _p.disable = function () {
  4449. var list = _impl.elements;
  4450. var index = list.indexOf(this);
  4451. if (index !== -1) list.splice(index, 1);
  4452. this.setVisible(false);
  4453. };
  4454. _p.destroy = function () {
  4455. this.disable();
  4456. this.removeDom();
  4457. };
  4458. _p.setVisible = function (visible) {
  4459. if (this._visible !== visible) {
  4460. this._visible = !!visible;
  4461. this._updateVisibility();
  4462. }
  4463. };
  4464. _p.setFullScreenEnabled = function (enable) {
  4465. var video = this._video;
  4466. if (!video) {
  4467. return;
  4468. }
  4469. this._fullScreenEnabled = enable;
  4470. video.setFullScreenEnabled(enable);
  4471. };
  4472. _p.updateMatrix = function (node) {
  4473. if (!this._video || !this._visible) return;
  4474. var camera = cc.Camera.findCamera(node)._camera;
  4475. if (!camera) {
  4476. return;
  4477. }
  4478. node.getWorldMatrix(_worldMat);
  4479. if (!this._forceUpdate && this._m00 === _worldMat.m[0] && this._m01 === _worldMat.m[1] && this._m04 === _worldMat.m[4] && this._m05 === _worldMat.m[5] && this._m12 === _worldMat.m[12] && this._m13 === _worldMat.m[13] && this._w === node._contentSize.width && this._h === node._contentSize.height) {
  4480. return;
  4481. } // update matrix cache
  4482. this._m00 = _worldMat.m[0];
  4483. this._m01 = _worldMat.m[1];
  4484. this._m04 = _worldMat.m[4];
  4485. this._m05 = _worldMat.m[5];
  4486. this._m12 = _worldMat.m[12];
  4487. this._m13 = _worldMat.m[13];
  4488. this._w = node._contentSize.width;
  4489. this._h = node._contentSize.height;
  4490. var canvas_width = cc.game.canvas.width;
  4491. var canvas_height = cc.game.canvas.height;
  4492. var ap = node._anchorPoint; // Vectors in node space
  4493. vec3.set(_topLeft, -ap.x * this._w, (1.0 - ap.y) * this._h, 0);
  4494. vec3.set(_bottomRight, (1 - ap.x) * this._w, -ap.y * this._h, 0); // Convert to world space
  4495. vec3.transformMat4(_topLeft, _topLeft, _worldMat);
  4496. vec3.transformMat4(_bottomRight, _bottomRight, _worldMat); // Convert to Screen space
  4497. camera.worldToScreen(_topLeft, _topLeft, canvas_width, canvas_height);
  4498. camera.worldToScreen(_bottomRight, _bottomRight, canvas_width, canvas_height);
  4499. var finalWidth = _bottomRight.x - _topLeft.x;
  4500. var finalHeight = _topLeft.y - _bottomRight.y;
  4501. this._video.setFrame(_topLeft.x, canvas_height - _topLeft.y, finalWidth, finalHeight);
  4502. };
  4503. _impl.EventType = {
  4504. PLAYING: 0,
  4505. PAUSED: 1,
  4506. STOPPED: 2,
  4507. COMPLETED: 3,
  4508. META_LOADED: 4,
  4509. CLICKED: 5,
  4510. READY_TO_PLAY: 6
  4511. }; // video 队列,所有 vidoe 在 onEnter 的时候都会插入这个队列
  4512. _impl.elements = []; // video 在 game_hide 事件中被自动暂停的队列,用于回复的时候重新开始播放
  4513. _impl.pauseElements = [];
  4514. cc.game.on(cc.game.EVENT_HIDE, function () {
  4515. var list = _impl.elements;
  4516. for (var element, i = 0; i < list.length; i++) {
  4517. element = list[i];
  4518. if (element.isPlaying()) {
  4519. element.pause();
  4520. _impl.pauseElements.push(element);
  4521. }
  4522. }
  4523. });
  4524. cc.game.on(cc.game.EVENT_SHOW, function () {
  4525. var list = _impl.pauseElements;
  4526. var element = list.pop();
  4527. while (element) {
  4528. element.play();
  4529. element = list.pop();
  4530. }
  4531. });
  4532. })();
  4533. },{}],46:[function(require,module,exports){
  4534. "use strict";
  4535. /****************************************************************************
  4536. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  4537. https://www.cocos.com/
  4538. Permission is hereby granted, free of charge, to any person obtaining a copy
  4539. of this software and associated engine source code (the "Software"), a limited,
  4540. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  4541. to use Cocos Creator solely to develop games on your target platforms. You shall
  4542. not use Cocos Creator software for developing other software or tools that's
  4543. used for developing games. You are not granted to publish, distribute,
  4544. sublicense, and/or sell copies of Cocos Creator.
  4545. The software or tools in this License Agreement are licensed, not sold.
  4546. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  4547. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4548. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4549. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4550. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4551. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4552. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4553. THE SOFTWARE.
  4554. ****************************************************************************/
  4555. (function () {
  4556. if (!(cc && cc.WebView && cc.WebView.Impl)) {
  4557. return;
  4558. }
  4559. var vec3 = cc.Vec3;
  4560. var _worldMat = new cc.Mat4();
  4561. var _topLeft = new vec3();
  4562. var _bottomRight = new vec3();
  4563. cc.WebView.Impl = cc.Class({
  4564. "extends": cc.WebView.Impl,
  4565. ctor: function ctor() {
  4566. // keep webview data
  4567. this.jsCallback = null;
  4568. this.interfaceSchema = null;
  4569. }
  4570. });
  4571. var _impl = cc.WebView.Impl;
  4572. var _p = cc.WebView.Impl.prototype;
  4573. _p._updateVisibility = function () {
  4574. if (!this._iframe) return;
  4575. this._iframe.setVisible(this._visible);
  4576. };
  4577. _p._updateSize = function (w, h) {};
  4578. _p._initEvent = function () {
  4579. var iframe = this._iframe;
  4580. if (iframe) {
  4581. var cbs = this.__eventListeners,
  4582. self = this;
  4583. cbs.load = function () {
  4584. self._dispatchEvent(_impl.EventType.LOADED);
  4585. };
  4586. cbs.error = function () {
  4587. self._dispatchEvent(_impl.EventType.ERROR);
  4588. }; // native event callback
  4589. this._iframe.setOnDidFinishLoading(cbs.load);
  4590. this._iframe.setOnDidFailLoading(cbs.error);
  4591. }
  4592. };
  4593. _p._initExtraSetting = function () {
  4594. this.jsCallback && this.setOnJSCallback(this.jsCallback);
  4595. this.interfaceSchema && this.setJavascriptInterfaceScheme(this.interfaceSchema); // remove obj
  4596. this.jsCallback = null;
  4597. this.interfaceSchema = null;
  4598. };
  4599. _p._setOpacity = function (opacity) {
  4600. var iframe = this._iframe;
  4601. if (iframe && iframe.style) {
  4602. iframe.style.opacity = opacity / 255; // TODO, add impl to Native
  4603. }
  4604. };
  4605. _p.createDomElementIfNeeded = function (w, h) {
  4606. if (!jsb.WebView) {
  4607. cc.warn('WebView only supports mobile platform.');
  4608. return;
  4609. }
  4610. if (!this._iframe) {
  4611. this._iframe = jsb.WebView.create();
  4612. this._initEvent();
  4613. this._initExtraSetting();
  4614. }
  4615. };
  4616. _p.removeDom = function () {
  4617. var iframe = this._iframe;
  4618. if (iframe) {
  4619. var cbs = this.__eventListeners;
  4620. cbs.load = null;
  4621. cbs.error = null;
  4622. iframe.destroy();
  4623. this._iframe = null;
  4624. }
  4625. };
  4626. _p.setOnJSCallback = function (callback) {
  4627. var iframe = this._iframe;
  4628. if (iframe) {
  4629. iframe.setOnJSCallback(callback);
  4630. } else {
  4631. this.jsCallback = callback;
  4632. }
  4633. };
  4634. _p.setJavascriptInterfaceScheme = function (scheme) {
  4635. var iframe = this._iframe;
  4636. if (iframe) {
  4637. iframe.setJavascriptInterfaceScheme(scheme);
  4638. } else {
  4639. this.interfaceSchema = scheme;
  4640. }
  4641. };
  4642. _p.loadData = function (data, MIMEType, encoding, baseURL) {
  4643. var iframe = this._iframe;
  4644. if (iframe) {
  4645. iframe.loadData(data, MIMEType, encoding, baseURL);
  4646. }
  4647. };
  4648. _p.loadHTMLString = function (string, baseURL) {
  4649. var iframe = this._iframe;
  4650. if (iframe) {
  4651. iframe.loadHTMLString(string, baseURL);
  4652. }
  4653. };
  4654. /**
  4655. * Load an URL
  4656. * @param {String} url
  4657. */
  4658. _p.loadURL = function (url) {
  4659. var iframe = this._iframe;
  4660. if (iframe) {
  4661. iframe.src = url;
  4662. iframe.loadURL(url);
  4663. this._dispatchEvent(_impl.EventType.LOADING);
  4664. }
  4665. };
  4666. /**
  4667. * Stop loading
  4668. */
  4669. _p.stopLoading = function () {
  4670. cc.logID(7800);
  4671. };
  4672. /**
  4673. * Reload the WebView
  4674. */
  4675. _p.reload = function () {
  4676. var iframe = this._iframe;
  4677. if (iframe) {
  4678. iframe.reload();
  4679. }
  4680. };
  4681. /**
  4682. * Determine whether to go back
  4683. */
  4684. _p.canGoBack = function () {
  4685. var iframe = this._iframe;
  4686. if (iframe) {
  4687. return iframe.canGoBack();
  4688. }
  4689. };
  4690. /**
  4691. * Determine whether to go forward
  4692. */
  4693. _p.canGoForward = function () {
  4694. var iframe = this._iframe;
  4695. if (iframe) {
  4696. return iframe.canGoForward();
  4697. }
  4698. };
  4699. /**
  4700. * go back
  4701. */
  4702. _p.goBack = function () {
  4703. var iframe = this._iframe;
  4704. if (iframe) {
  4705. return iframe.goBack();
  4706. }
  4707. };
  4708. /**
  4709. * go forward
  4710. */
  4711. _p.goForward = function () {
  4712. var iframe = this._iframe;
  4713. if (iframe) {
  4714. return iframe.goForward();
  4715. }
  4716. };
  4717. /**
  4718. * In the webview execution within a period of js string
  4719. * @param {String} str
  4720. */
  4721. _p.evaluateJS = function (str) {
  4722. var iframe = this._iframe;
  4723. if (iframe) {
  4724. return iframe.evaluateJS(str);
  4725. }
  4726. };
  4727. /**
  4728. * Limited scale
  4729. */
  4730. _p.setScalesPageToFit = function () {
  4731. var iframe = this._iframe;
  4732. if (iframe) {
  4733. return iframe.setScalesPageToFit();
  4734. }
  4735. };
  4736. /**
  4737. * The binding event
  4738. * @param {_impl.EventType} event
  4739. * @param {Function} callback
  4740. */
  4741. _p.setEventListener = function (event, callback) {
  4742. this._EventList[event] = callback;
  4743. };
  4744. /**
  4745. * Delete events
  4746. * @param {_impl.EventType} event
  4747. */
  4748. _p.removeEventListener = function (event) {
  4749. this._EventList[event] = null;
  4750. };
  4751. _p._dispatchEvent = function (event) {
  4752. var callback = this._EventList[event];
  4753. if (callback) callback.call(this, this, this._iframe.src);
  4754. };
  4755. _p._createRenderCmd = function () {
  4756. return new _impl.RenderCmd(this);
  4757. };
  4758. _p.destroy = function () {
  4759. this.removeDom();
  4760. };
  4761. _p.setVisible = function (visible) {
  4762. if (this._visible !== visible) {
  4763. this._visible = !!visible;
  4764. this._updateVisibility();
  4765. }
  4766. };
  4767. _p.updateMatrix = function (node) {
  4768. if (!this._iframe || !this._visible) return;
  4769. var camera = cc.Camera.findCamera(node)._camera;
  4770. if (!camera) {
  4771. return;
  4772. }
  4773. node.getWorldMatrix(_worldMat);
  4774. if (this._m00 === _worldMat.m[0] && this._m01 === _worldMat.m[1] && this._m04 === _worldMat.m[4] && this._m05 === _worldMat.m[5] && this._m12 === _worldMat.m[12] && this._m13 === _worldMat.m[13] && this._w === node._contentSize.width && this._h === node._contentSize.height) {
  4775. return;
  4776. } // update matrix cache
  4777. this._m00 = _worldMat.m[0];
  4778. this._m01 = _worldMat.m[1];
  4779. this._m04 = _worldMat.m[4];
  4780. this._m05 = _worldMat.m[5];
  4781. this._m12 = _worldMat.m[12];
  4782. this._m13 = _worldMat.m[13];
  4783. this._w = node._contentSize.width;
  4784. this._h = node._contentSize.height;
  4785. var canvas_width = cc.game.canvas.width;
  4786. var canvas_height = cc.game.canvas.height;
  4787. var ap = node._anchorPoint; // Vectors in node space
  4788. vec3.set(_topLeft, -ap.x * this._w, (1.0 - ap.y) * this._h, 0);
  4789. vec3.set(_bottomRight, (1 - ap.x) * this._w, -ap.y * this._h, 0); // Convert to world space
  4790. vec3.transformMat4(_topLeft, _topLeft, _worldMat);
  4791. vec3.transformMat4(_bottomRight, _bottomRight, _worldMat); // Convert to screen space
  4792. camera.worldToScreen(_topLeft, _topLeft, canvas_width, canvas_height);
  4793. camera.worldToScreen(_bottomRight, _bottomRight, canvas_width, canvas_height);
  4794. var finalWidth = _bottomRight.x - _topLeft.x;
  4795. var finalHeight = _topLeft.y - _bottomRight.y;
  4796. this._iframe.setFrame(_topLeft.x, canvas_height - _topLeft.y, finalWidth, finalHeight);
  4797. };
  4798. })();
  4799. },{}],47:[function(require,module,exports){
  4800. "use strict";
  4801. /****************************************************************************
  4802. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  4803. http://www.cocos.com
  4804. Permission is hereby granted, free of charge, to any person obtaining a copy
  4805. of this software and associated engine source code (the "Software"), a limited,
  4806. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  4807. to use Cocos Creator solely to develop games on your target platforms. You shall
  4808. not use Cocos Creator software for developing other software or tools that's
  4809. used for developing games. You are not granted to publish, distribute,
  4810. sublicense, and/or sell copies of Cocos Creator.
  4811. The software or tools in this License Agreement are licensed, not sold.
  4812. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  4813. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4814. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4815. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4816. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4817. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4818. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4819. THE SOFTWARE.
  4820. ****************************************************************************/
  4821. var nativeCameraProto = renderer.Camera.prototype;
  4822. var _setNode = nativeCameraProto.setNode;
  4823. cc.js.mixin(nativeCameraProto, {
  4824. setNode: function setNode(node) {
  4825. this._persistentNode = node;
  4826. _setNode.call(this, node);
  4827. }
  4828. });
  4829. },{}],48:[function(require,module,exports){
  4830. "use strict";
  4831. /****************************************************************************
  4832. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  4833. http://www.cocos.com
  4834. Permission is hereby granted, free of charge, to any person obtaining a copy
  4835. of this software and associated engine source code (the "Software"), a limited,
  4836. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  4837. to use Cocos Creator solely to develop games on your target platforms. You shall
  4838. not use Cocos Creator software for developing other software or tools that's
  4839. used for developing games. You are not granted to publish, distribute,
  4840. sublicense, and/or sell copies of Cocos Creator.
  4841. The software or tools in this License Agreement are licensed, not sold.
  4842. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  4843. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4844. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4845. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4846. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4847. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4848. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4849. THE SOFTWARE.
  4850. ****************************************************************************/
  4851. var nativeLightProto = renderer.Light.prototype;
  4852. var _setNode = nativeLightProto.setNode;
  4853. cc.js.mixin(nativeLightProto, {
  4854. setNode: function setNode(node) {
  4855. this._node = node;
  4856. _setNode.call(this, node);
  4857. }
  4858. });
  4859. },{}],49:[function(require,module,exports){
  4860. "use strict";
  4861. /****************************************************************************
  4862. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  4863. https://www.cocos.com/
  4864. Permission is hereby granted, free of charge, to any person obtaining a copy
  4865. of this software and associated engine source code (the "Software"), a limited,
  4866. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  4867. to use Cocos Creator solely to develop games on your target platforms. You shall
  4868. not use Cocos Creator software for developing other software or tools that's
  4869. used for developing games. You are not granted to publish, distribute,
  4870. sublicense, and/or sell copies of Cocos Creator.
  4871. The software or tools in this License Agreement are licensed, not sold.
  4872. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  4873. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4874. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4875. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4876. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4877. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4878. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4879. THE SOFTWARE.
  4880. ****************************************************************************/
  4881. (function () {
  4882. if (!cc.MeshBuffer) return;
  4883. var MeshBuffer = cc.MeshBuffer.prototype;
  4884. MeshBuffer.init = function (batcher, vertexFormat) {
  4885. this.byteOffset = 0;
  4886. this.indiceOffset = 0;
  4887. this.vertexOffset = 0;
  4888. this._vertexFormat = vertexFormat;
  4889. this._vertexBytes = this._vertexFormat._bytes;
  4890. this._vDatas = [];
  4891. this._uintVDatas = [];
  4892. this._iDatas = [];
  4893. this._arrOffset = 0;
  4894. this._vData = null;
  4895. this._uintVData = null;
  4896. this._iData = null;
  4897. this._initVDataCount = 256 * vertexFormat._bytes; // actually 256 * 4 * (vertexFormat._bytes / 4)
  4898. this._initIDataCount = 256 * 6;
  4899. this._offsetInfo = {
  4900. byteOffset: 0,
  4901. vertexOffset: 0,
  4902. indiceOffset: 0
  4903. };
  4904. this._renderDataList = new renderer.RenderDataList();
  4905. this._reallocBuffer();
  4906. };
  4907. MeshBuffer.setNativeAssembler = function (assembler) {
  4908. if (assembler !== this._nativeAssembler) {
  4909. this._nativeAssembler = assembler;
  4910. assembler.setRenderDataList(this._renderDataList);
  4911. }
  4912. };
  4913. MeshBuffer._updateVIDatas = function () {
  4914. var offset = this._arrOffset;
  4915. this._vDatas[offset] = this._vData;
  4916. this._uintVDatas[offset] = this._uintVData;
  4917. this._iDatas[offset] = this._iData;
  4918. this._renderDataList.updateMesh(offset, this._vData, this._iData);
  4919. };
  4920. MeshBuffer.getNativeAssembler = function () {
  4921. return this._nativeAssembler;
  4922. };
  4923. MeshBuffer.getCurMeshIndex = function () {
  4924. return this._arrOffset;
  4925. };
  4926. MeshBuffer.uploadData = function () {};
  4927. MeshBuffer.switchBuffer = function () {
  4928. var offset = ++this._arrOffset;
  4929. this.byteOffset = 0;
  4930. this.vertexOffset = 0;
  4931. this.indiceOffset = 0;
  4932. if (offset < this._vDatas.length) {
  4933. this._vData = this._vDatas[offset];
  4934. this._uintVData = this._uintVDatas[offset];
  4935. this._iData = this._iDatas[offset];
  4936. } else {
  4937. this._reallocBuffer();
  4938. }
  4939. };
  4940. MeshBuffer.checkAndSwitchBuffer = function (vertexCount) {
  4941. if (this.vertexOffset + vertexCount > 65535) {
  4942. this.switchBuffer();
  4943. if (!this._nativeAssembler) return;
  4944. this._nativeAssembler.updateIADatas && this._nativeAssembler.updateIADatas(this._arrOffset, this._arrOffset);
  4945. }
  4946. };
  4947. MeshBuffer.used = function (vertexCount, indiceCount) {
  4948. if (!this._nativeAssembler) return;
  4949. this._nativeAssembler.updateVerticesRange(this._arrOffset, 0, vertexCount);
  4950. this._nativeAssembler.updateIndicesRange(this._arrOffset, 0, indiceCount);
  4951. };
  4952. MeshBuffer.request = function (vertexCount, indiceCount) {
  4953. this.requestStatic(vertexCount, indiceCount);
  4954. return this._offsetInfo;
  4955. };
  4956. MeshBuffer._reallocBuffer = function () {
  4957. this._reallocVData(true);
  4958. this._reallocIData(true);
  4959. this._updateVIDatas();
  4960. };
  4961. MeshBuffer._reallocVData = function (copyOldData) {
  4962. var oldVData;
  4963. if (this._vData) {
  4964. oldVData = new Uint8Array(this._vData.buffer);
  4965. }
  4966. this._vData = new Float32Array(this._initVDataCount);
  4967. this._uintVData = new Uint32Array(this._vData.buffer);
  4968. var newData = new Uint8Array(this._uintVData.buffer);
  4969. if (oldVData && copyOldData) {
  4970. for (var i = 0, l = oldVData.length; i < l; i++) {
  4971. newData[i] = oldVData[i];
  4972. }
  4973. }
  4974. };
  4975. MeshBuffer._reallocIData = function (copyOldData) {
  4976. var oldIData = this._iData;
  4977. this._iData = new Uint16Array(this._initIDataCount);
  4978. if (oldIData && copyOldData) {
  4979. var iData = this._iData;
  4980. for (var i = 0, l = oldIData.length; i < l; i++) {
  4981. iData[i] = oldIData[i];
  4982. }
  4983. }
  4984. };
  4985. MeshBuffer.reset = function () {
  4986. this._arrOffset = 0;
  4987. this._vData = this._vDatas[0];
  4988. this._uintVData = this._uintVDatas[0];
  4989. this._iData = this._iDatas[0];
  4990. this.byteOffset = 0;
  4991. this.indiceOffset = 0;
  4992. this.vertexOffset = 0;
  4993. if (!this._nativeAssembler) return;
  4994. for (var i = 0, len = this._vDatas.length; i < len; i++) {
  4995. this._nativeAssembler.updateVerticesRange(i, 0, 0);
  4996. this._nativeAssembler.updateIndicesRange(i, 0, 0);
  4997. }
  4998. };
  4999. MeshBuffer.destroy = function () {
  5000. this.reset();
  5001. };
  5002. })();
  5003. },{}],50:[function(require,module,exports){
  5004. "use strict";
  5005. /****************************************************************************
  5006. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  5007. http://www.cocos.com
  5008. Permission is hereby granted, free of charge, to any person obtaining a copy
  5009. of this software and associated engine source code (the "Software"), a limited,
  5010. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  5011. to use Cocos Creator solely to develop games on your target platforms. You shall
  5012. not use Cocos Creator software for developing other software or tools that's
  5013. used for developing games. You are not granted to publish, distribute,
  5014. sublicense, and/or sell copies of Cocos Creator.
  5015. The software or tools in this License Agreement are licensed, not sold.
  5016. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  5017. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  5018. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  5019. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  5020. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  5021. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  5022. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  5023. THE SOFTWARE.
  5024. ****************************************************************************/
  5025. var RenderFlow = cc.RenderFlow;
  5026. cc.js.mixin(renderer.NodeProxy.prototype, {
  5027. _ctor: function _ctor() {
  5028. this._owner = null;
  5029. },
  5030. init: function init(owner) {
  5031. this._owner = owner;
  5032. var spaceInfo = owner._spaceInfo;
  5033. this._owner._dirtyPtr = spaceInfo.dirty;
  5034. this._dirtyPtr = spaceInfo.dirty;
  5035. this._parentPtr = spaceInfo.parent;
  5036. this._zOrderPtr = spaceInfo.zOrder;
  5037. this._cullingMaskPtr = spaceInfo.cullingMask;
  5038. this._opacityPtr = spaceInfo.opacity;
  5039. this._is3DPtr = spaceInfo.is3D;
  5040. this._skewPtr = spaceInfo.skew;
  5041. this._isVisitingTraversal = false;
  5042. owner._proxy = this;
  5043. this.updateOpacity();
  5044. this.update3DNode();
  5045. this.updateZOrder();
  5046. this.updateCullingMask();
  5047. this.updateSkew();
  5048. owner.on(cc.Node.EventType.SIBLING_ORDER_CHANGED, this.updateZOrder, this);
  5049. },
  5050. initNative: function initNative() {
  5051. this.setName(this._owner._name);
  5052. this.updateParent();
  5053. this.updateOpacity();
  5054. this.update3DNode();
  5055. this.updateZOrder();
  5056. this.updateSkew();
  5057. this.updateCullingMask();
  5058. },
  5059. destroy: function destroy() {
  5060. this.destroyImmediately();
  5061. this._owner.off(cc.Node.EventType.SIBLING_ORDER_CHANGED, this.updateZOrder, this);
  5062. this._owner._proxy = null;
  5063. this._owner = null;
  5064. },
  5065. updateParent: function updateParent() {
  5066. var parent = this._owner._parent;
  5067. if (parent) {
  5068. var parentSpaceInfo = parent._spaceInfo;
  5069. this._parentPtr[0] = parentSpaceInfo.unitID;
  5070. this._parentPtr[1] = parentSpaceInfo.index;
  5071. var parentDirtyPtr = parentSpaceInfo.dirty;
  5072. parentDirtyPtr[0] |= RenderFlow.FLAG_REORDER_CHILDREN;
  5073. this._dirtyPtr[0] |= RenderFlow.FLAG_OPACITY;
  5074. } else {
  5075. this._parentPtr[0] = 0xffffffff;
  5076. this._parentPtr[1] = 0xffffffff;
  5077. }
  5078. this.notifyUpdateParent();
  5079. },
  5080. updateZOrder: function updateZOrder() {
  5081. this._zOrderPtr[0] = this._owner._localZOrder;
  5082. var parent = this._owner._parent;
  5083. if (parent && parent._proxy) {
  5084. parent._proxy._dirtyPtr[0] |= RenderFlow.FLAG_REORDER_CHILDREN;
  5085. }
  5086. },
  5087. updateCullingMask: function updateCullingMask() {
  5088. this._cullingMaskPtr[0] = this._owner._cullingMask;
  5089. },
  5090. updateOpacity: function updateOpacity() {
  5091. this._opacityPtr[0] = this._owner.opacity;
  5092. this._dirtyPtr[0] |= RenderFlow.FLAG_OPACITY;
  5093. },
  5094. update3DNode: function update3DNode() {
  5095. this._is3DPtr[0] = this._owner.is3DNode ? 0x1 : 0x0;
  5096. this._dirtyPtr[0] |= RenderFlow.FLAG_LOCAL_TRANSFORM;
  5097. },
  5098. updateSkew: function updateSkew() {
  5099. var skewPtr = this._skewPtr;
  5100. var owner = this._owner;
  5101. var skx = owner._skewX;
  5102. var sky = owner._skewY;
  5103. skewPtr[0] = skx;
  5104. skewPtr[1] = sky;
  5105. if (!this._isVisitingTraversal && (skx !== 0 || sky !== 0)) {
  5106. this.switchTraverseToVisit();
  5107. this._isVisitingTraversal = true;
  5108. }
  5109. }
  5110. });
  5111. },{}],51:[function(require,module,exports){
  5112. /****************************************************************************
  5113. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  5114. http://www.cocos.com
  5115. Permission is hereby granted, free of charge, to any person obtaining a copy
  5116. of this software and associated engine source code (the "Software"), a limited,
  5117. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  5118. to use Cocos Creator solely to develop games on your target platforms. You shall
  5119. not use Cocos Creator software for developing other software or tools that's
  5120. used for developing games. You are not granted to publish, distribute,
  5121. sublicense, and/or sell copies of Cocos Creator.
  5122. The software or tools in this License Agreement are licensed, not sold.
  5123. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  5124. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  5125. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  5126. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  5127. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  5128. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  5129. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  5130. THE SOFTWARE.
  5131. ****************************************************************************/
  5132. 'use strict';
  5133. var RenderFlow = cc.RenderFlow;
  5134. var LOCAL_TRANSFORM = RenderFlow.FLAG_LOCAL_TRANSFORM;
  5135. var COLOR = RenderFlow.FLAG_COLOR;
  5136. var UPDATE_RENDER_DATA = RenderFlow.FLAG_UPDATE_RENDER_DATA;
  5137. var POSITION_ON = 1 << 0;
  5138. cc.Node.prototype.setLocalDirty = function (flag) {
  5139. this._localMatDirty |= flag;
  5140. this._worldMatDirty = true;
  5141. this._dirtyPtr[0] |= RenderFlow.FLAG_TRANSFORM;
  5142. };
  5143. cc.js.getset(cc.Node.prototype, "_renderFlag", function () {
  5144. return this._dirtyPtr[0];
  5145. }, function (flag) {
  5146. this._dirtyPtr[0] = flag;
  5147. if (flag & UPDATE_RENDER_DATA || flag & COLOR) {
  5148. cc.RenderFlow.register(this);
  5149. }
  5150. });
  5151. cc.PrivateNode.prototype._posDirty = function (sendEvent) {
  5152. var parent = this.parent;
  5153. if (parent) {
  5154. // Position correction for transform calculation
  5155. this._trs[0] = this._originPos.x - (parent._anchorPoint.x - 0.5) * parent._contentSize.width;
  5156. this._trs[1] = this._originPos.y - (parent._anchorPoint.y - 0.5) * parent._contentSize.height;
  5157. }
  5158. this.setLocalDirty(cc.Node._LocalDirtyFlag.POSITION);
  5159. if (sendEvent === true && this._eventMask & POSITION_ON) {
  5160. this.emit(cc.Node.EventType.POSITION_CHANGED);
  5161. }
  5162. };
  5163. },{}],52:[function(require,module,exports){
  5164. "use strict";
  5165. /****************************************************************************
  5166. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  5167. https://www.cocos.com/
  5168. Permission is hereby granted, free of charge, to any person obtaining a copy
  5169. of this software and associated engine source code (the "Software"), a limited,
  5170. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  5171. to use Cocos Creator solely to develop games on your target platforms. You shall
  5172. not use Cocos Creator software for developing other software or tools that's
  5173. used for developing games. You are not granted to publish, distribute,
  5174. sublicense, and/or sell copies of Cocos Creator.
  5175. The software or tools in this License Agreement are licensed, not sold.
  5176. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  5177. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  5178. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  5179. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  5180. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  5181. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  5182. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  5183. THE SOFTWARE.
  5184. ****************************************************************************/
  5185. (function () {
  5186. if (!cc.QuadBuffer) return;
  5187. var QuadBuffer = cc.QuadBuffer.prototype;
  5188. QuadBuffer._fillQuadBuffer = function () {
  5189. var count = this._initIDataCount / 6;
  5190. var buffer = this._iData;
  5191. for (var i = 0, idx = 0; i < count; i++) {
  5192. var vertextID = i * 4;
  5193. buffer[idx++] = vertextID;
  5194. buffer[idx++] = vertextID + 1;
  5195. buffer[idx++] = vertextID + 2;
  5196. buffer[idx++] = vertextID + 1;
  5197. buffer[idx++] = vertextID + 3;
  5198. buffer[idx++] = vertextID + 2;
  5199. }
  5200. };
  5201. QuadBuffer._reallocBuffer = function () {
  5202. this._reallocVData(true);
  5203. this._reallocIData();
  5204. this._fillQuadBuffer();
  5205. this._updateVIDatas();
  5206. };
  5207. QuadBuffer.uploadData = function () {};
  5208. QuadBuffer.switchBuffer = function () {
  5209. cc.MeshBuffer.prototype.switchBuffer.call(this);
  5210. };
  5211. })();
  5212. },{}],53:[function(require,module,exports){
  5213. "use strict";
  5214. var proto = cc.RenderData.prototype;
  5215. cc.RenderData.prototype.init = function (assembler) {
  5216. this._renderDataList = new renderer.RenderDataList();
  5217. assembler.setRenderDataList(this._renderDataList);
  5218. this._nativeAssembler = assembler;
  5219. };
  5220. var originClear = proto.clear;
  5221. proto.clear = function () {
  5222. originClear.call(this);
  5223. this._renderDataList.clear();
  5224. };
  5225. var originUpdateMesh = proto.updateMesh;
  5226. proto.updateMesh = function (meshIndex, vertices, indices) {
  5227. originUpdateMesh.call(this, meshIndex, vertices, indices);
  5228. if (vertices && indices) {
  5229. this._renderDataList.updateMesh(meshIndex, vertices, indices);
  5230. }
  5231. };
  5232. proto.updateMeshRange = function (verticesCount, indicesCount) {
  5233. this._nativeAssembler.updateVerticesRange(0, 0, verticesCount);
  5234. this._nativeAssembler.updateIndicesRange(0, 0, indicesCount);
  5235. };
  5236. },{}],54:[function(require,module,exports){
  5237. "use strict";
  5238. /****************************************************************************
  5239. Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
  5240. http://www.cocos.com
  5241. Permission is hereby granted, free of charge, to any person obtaining a copy
  5242. of this software and associated engine source code (the "Software"), a limited,
  5243. worldwide, royalty-free, non-assignable, revocable and non-exclusive license
  5244. to use Cocos Creator solely to develop games on your target platforms. You shall
  5245. not use Cocos Creator software for developing other software or tools that's
  5246. used for developing games. You are not granted to publish, distribute,
  5247. sublicense, and/or sell copies of Cocos Creator.
  5248. The software or tools in this License Agreement are licensed, not sold.
  5249. Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
  5250. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  5251. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  5252. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  5253. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  5254. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  5255. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  5256. THE SOFTWARE.
  5257. ****************************************************************************/
  5258. var RenderFlow = cc.RenderFlow;
  5259. RenderFlow.FLAG_REORDER_CHILDREN = 1 << 29;
  5260. RenderFlow.FLAG_WORLD_TRANSFORM_CHANGED = 1 << 30;
  5261. RenderFlow.FLAG_OPACITY_CHANGED = 1 << 31;
  5262. var _dirtyTargets = [];
  5263. var _dirtyWaiting = [];
  5264. var _rendering = false;
  5265. var director = cc.director;
  5266. RenderFlow.render = function (scene, dt) {
  5267. var camera = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  5268. _rendering = true;
  5269. RenderFlow.validateRenderers();
  5270. for (var i = 0, l = _dirtyTargets.length; i < l; i++) {
  5271. var node = _dirtyTargets[i];
  5272. node._inJsbDirtyList = false;
  5273. var comp = node._renderComponent;
  5274. if (!comp) continue;
  5275. var assembler = comp._assembler;
  5276. if (!assembler) continue;
  5277. var flag = node._dirtyPtr[0];
  5278. if (flag & RenderFlow.FLAG_UPDATE_RENDER_DATA) {
  5279. node._dirtyPtr[0] &= ~RenderFlow.FLAG_UPDATE_RENDER_DATA;
  5280. assembler._updateRenderData && assembler._updateRenderData();
  5281. }
  5282. if (flag & RenderFlow.FLAG_COLOR) {
  5283. node._dirtyPtr[0] &= ~RenderFlow.FLAG_COLOR;
  5284. comp._updateColor && comp._updateColor();
  5285. }
  5286. }
  5287. _dirtyTargets.length = 0;
  5288. dt = dt || 0;
  5289. this._nativeFlow.render(scene._proxy, dt, camera);
  5290. _dirtyTargets = _dirtyWaiting.slice(0);
  5291. _dirtyWaiting.length = 0;
  5292. _rendering = false;
  5293. };
  5294. RenderFlow.renderCamera = function (camera, scene) {
  5295. RenderFlow.render(scene, 0, camera);
  5296. };
  5297. RenderFlow.init = function (nativeFlow) {
  5298. cc.EventTarget.call(this);
  5299. this._nativeFlow = nativeFlow;
  5300. };
  5301. RenderFlow.register = function (target) {
  5302. if (target._inJsbDirtyList) return;
  5303. if (_rendering) {
  5304. _dirtyWaiting.push(target);
  5305. } else {
  5306. _dirtyTargets.push(target);
  5307. }
  5308. target._inJsbDirtyList = true;
  5309. };
  5310. },{}]},{},[27]);