laya.d3.js 1.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694
  1. (function(window,document,Laya){
  2. var __un=Laya.un,__uns=Laya.uns,__static=Laya.static,__class=Laya.class,__getset=Laya.getset,__newvec=Laya.__newvec;
  3. var BaseTexture=laya.resource.BaseTexture,Browser=laya.utils.Browser,Buffer=laya.webgl.utils.Buffer;
  4. var BufferStateBase=laya.webgl.BufferStateBase,Byte=laya.utils.Byte,ClassUtils=laya.utils.ClassUtils,CommandEncoder=laya.layagl.CommandEncoder;
  5. var Component=laya.components.Component,Config=Laya.Config,Context=laya.resource.Context,Event=laya.events.Event;
  6. var EventDispatcher=laya.events.EventDispatcher,Handler=laya.utils.Handler,InlcudeFile=laya.webgl.utils.InlcudeFile;
  7. var LayaGL=laya.layagl.LayaGL,LayaGLRunner=laya.layagl.LayaGLRunner,Loader=laya.net.Loader,LoaderManager=laya.net.LoaderManager;
  8. var MathUtil=laya.maths.MathUtil,Node=laya.display.Node,Point=laya.maths.Point,Render=laya.renders.Render;
  9. var RenderTexture2D=laya.resource.RenderTexture2D,Resource=laya.resource.Resource,RunDriver=laya.utils.RunDriver;
  10. var Shader=laya.webgl.shader.Shader,ShaderCompile=laya.webgl.utils.ShaderCompile,ShaderNode=laya.webgl.utils.ShaderNode;
  11. var Sprite=laya.display.Sprite,Stat=laya.utils.Stat,Submit=laya.webgl.submit.Submit,SubmitKey=laya.webgl.submit.SubmitKey;
  12. var Texture2D=laya.resource.Texture2D,Timer=laya.utils.Timer,URL=laya.net.URL,WebGL=laya.webgl.WebGL,WebGLContext=laya.webgl.WebGLContext;
  13. Laya.interface('laya.d3.core.IClone');
  14. Laya.interface('laya.d3.graphics.IVertex');
  15. Laya.interface('laya.d3.core.scene.IOctreeObject');
  16. /**
  17. *<code>Quaternion</code> 类用于创建四元数。
  18. */
  19. //class laya.d3.math.Native.ConchQuaternion
  20. var ConchQuaternion=(function(){
  21. function ConchQuaternion(x,y,z,w,nativeElements){
  22. /**四元数元素数组*/
  23. //this.elements=null;
  24. (x===void 0)&& (x=0);
  25. (y===void 0)&& (y=0);
  26. (z===void 0)&& (z=0);
  27. (w===void 0)&& (w=1);
  28. var v;
  29. if (nativeElements){
  30. v=nativeElements;
  31. }else {
  32. v=new Float32Array(4);
  33. }
  34. v[0]=x;
  35. v[1]=y;
  36. v[2]=z;
  37. v[3]=w;
  38. this.elements=v;
  39. }
  40. __class(ConchQuaternion,'laya.d3.math.Native.ConchQuaternion');
  41. var __proto=ConchQuaternion.prototype;
  42. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  43. /**
  44. *根据缩放值缩放四元数
  45. *@param scale 缩放值
  46. *@param out 输出四元数
  47. */
  48. __proto.scaling=function(scaling,out){
  49. var e=out.elements;
  50. var f=this.elements;
  51. e[0]=f[0] *scaling;
  52. e[1]=f[1] *scaling;
  53. e[2]=f[2] *scaling;
  54. e[3]=f[3] *scaling;
  55. }
  56. /**
  57. *归一化四元数
  58. *@param out 输出四元数
  59. */
  60. __proto.normalize=function(out){
  61. ConchQuaternion._normalizeArray(this.elements,out.elements);
  62. }
  63. /**
  64. *计算四元数的长度
  65. *@return 长度
  66. */
  67. __proto.length=function(){
  68. var f=this.elements;
  69. var x=f[0],y=f[1],z=f[2],w=f[3];
  70. return Math.sqrt(x *x+y *y+z *z+w *w);
  71. }
  72. /**
  73. *根据绕X轴的角度旋转四元数
  74. *@param rad 角度
  75. *@param out 输出四元数
  76. */
  77. __proto.rotateX=function(rad,out){
  78. var e=out.elements;
  79. var f=this.elements;
  80. rad *=0.5;
  81. var ax=f[0],ay=f[1],az=f[2],aw=f[3];
  82. var bx=Math.sin(rad),bw=Math.cos(rad);
  83. e[0]=ax *bw+aw *bx;
  84. e[1]=ay *bw+az *bx;
  85. e[2]=az *bw-ay *bx;
  86. e[3]=aw *bw-ax *bx;
  87. }
  88. /**
  89. *根据绕Y轴的制定角度旋转四元数
  90. *@param rad 角度
  91. *@param out 输出四元数
  92. */
  93. __proto.rotateY=function(rad,out){
  94. var e=out.elements;
  95. var f=this.elements;
  96. rad *=0.5;
  97. var ax=f[0],ay=f[1],az=f[2],aw=f[3],by=Math.sin(rad),bw=Math.cos(rad);
  98. e[0]=ax *bw-az *by;
  99. e[1]=ay *bw+aw *by;
  100. e[2]=az *bw+ax *by;
  101. e[3]=aw *bw-ay *by;
  102. }
  103. /**
  104. *根据绕Z轴的制定角度旋转四元数
  105. *@param rad 角度
  106. *@param out 输出四元数
  107. */
  108. __proto.rotateZ=function(rad,out){
  109. var e=out.elements;
  110. var f=this.elements;
  111. rad *=0.5;
  112. var ax=f[0],ay=f[1],az=f[2],aw=f[3],bz=Math.sin(rad),bw=Math.cos(rad);
  113. e[0]=ax *bw+ay *bz;
  114. e[1]=ay *bw-ax *bz;
  115. e[2]=az *bw+aw *bz;
  116. e[3]=aw *bw-az *bz;
  117. }
  118. /**
  119. *分解四元数到欧拉角(顺序为Yaw、Pitch、Roll),参考自http://xboxforums.create.msdn.com/forums/p/4574/23988.aspx#23988,问题绕X轴翻转超过±90度时有,会产生瞬间反转
  120. *@param quaternion 源四元数
  121. *@param out 欧拉角值
  122. */
  123. __proto.getYawPitchRoll=function(out){
  124. ConchVector3.transformQuat(ConchVector3.ForwardRH,this,ConchQuaternion.TEMPVector31);
  125. ConchVector3.transformQuat(ConchVector3.Up,this,ConchQuaternion.TEMPVector32);
  126. var upe=ConchQuaternion.TEMPVector32.elements;
  127. ConchQuaternion.angleTo(ConchVector3.ZERO,ConchQuaternion.TEMPVector31,ConchQuaternion.TEMPVector33);
  128. var anglee=ConchQuaternion.TEMPVector33.elements;
  129. if (anglee[0]==Math.PI / 2){
  130. anglee[1]=ConchQuaternion.arcTanAngle(upe[2],upe[0]);
  131. anglee[2]=0;
  132. }else if (anglee[0]==-Math.PI / 2){
  133. anglee[1]=ConchQuaternion.arcTanAngle(-upe[2],-upe[0]);
  134. anglee[2]=0;
  135. }else {
  136. Matrix4x4.createRotationY(-anglee[1],ConchQuaternion.TEMPMatrix0);
  137. Matrix4x4.createRotationX(-anglee[0],ConchQuaternion.TEMPMatrix1);
  138. ConchVector3.transformCoordinate(ConchQuaternion.TEMPVector32,ConchQuaternion.TEMPMatrix0,ConchQuaternion.TEMPVector32);
  139. ConchVector3.transformCoordinate(ConchQuaternion.TEMPVector32,ConchQuaternion.TEMPMatrix1,ConchQuaternion.TEMPVector32);
  140. anglee[2]=ConchQuaternion.arcTanAngle(upe[1],-upe[0]);
  141. }
  142. if (anglee[1] <=-Math.PI)
  143. anglee[1]=Math.PI;
  144. if (anglee[2] <=-Math.PI)
  145. anglee[2]=Math.PI;
  146. if (anglee[1] >=Math.PI && anglee[2] >=Math.PI){
  147. anglee[1]=0;
  148. anglee[2]=0;
  149. anglee[0]=Math.PI-anglee[0];
  150. };
  151. var oe=out.elements;
  152. oe[0]=anglee[1];
  153. oe[1]=anglee[0];
  154. oe[2]=anglee[2];
  155. }
  156. /**
  157. *求四元数的逆
  158. *@param out 输出四元数
  159. */
  160. __proto.invert=function(out){
  161. var e=out.elements;
  162. var f=this.elements;
  163. var a0=f[0],a1=f[1],a2=f[2],a3=f[3];
  164. var dot=a0 *a0+a1 *a1+a2 *a2+a3 *a3;
  165. var invDot=dot ? 1.0 / dot :0;
  166. e[0]=-a0 *invDot;
  167. e[1]=-a1 *invDot;
  168. e[2]=-a2 *invDot;
  169. e[3]=a3 *invDot;
  170. }
  171. /**
  172. *设置四元数为单位算数
  173. *@param out 输出四元数
  174. */
  175. __proto.identity=function(){
  176. var e=this.elements;
  177. e[0]=0;
  178. e[1]=0;
  179. e[2]=0;
  180. e[3]=1;
  181. }
  182. /**
  183. *从Array数组拷贝值。
  184. *@param array 数组。
  185. *@param offset 数组偏移。
  186. */
  187. __proto.fromArray=function(array,offset){
  188. (offset===void 0)&& (offset=0);
  189. this.elements[0]=array[offset+0];
  190. this.elements[1]=array[offset+1];
  191. this.elements[2]=array[offset+2];
  192. this.elements[3]=array[offset+3];
  193. }
  194. /**
  195. *克隆。
  196. *@param destObject 克隆源。
  197. */
  198. __proto.cloneTo=function(destObject){
  199. var i,s,d;
  200. s=this.elements;
  201. d=destObject.elements;
  202. if (s===d){
  203. return;
  204. }
  205. for (i=0;i < 4;++i){
  206. d[i]=s[i];
  207. }
  208. }
  209. /**
  210. *克隆。
  211. *@return 克隆副本。
  212. */
  213. __proto.clone=function(){
  214. var dest=/*__JS__ */new this.constructor();
  215. this.cloneTo(dest);
  216. return dest;
  217. }
  218. __proto.equals=function(b){
  219. var ae=this.elements;
  220. var be=b.elements;
  221. return MathUtils3D.nearEqual(ae[0],be[0])&& MathUtils3D.nearEqual(ae[1],be[1])&& MathUtils3D.nearEqual(ae[2],be[2])&& MathUtils3D.nearEqual(ae[3],be[3]);
  222. }
  223. /**
  224. *计算长度的平方。
  225. *@return 长度的平方。
  226. */
  227. __proto.lengthSquared=function(){
  228. var x=this.elements[0];
  229. var y=this.elements[1];
  230. var z=this.elements[2];
  231. var w=this.elements[3];
  232. return (x *x)+(y *y)+(z *z)+(w *w);
  233. }
  234. /**
  235. *设置四元数的x值
  236. */
  237. /**
  238. *获取四元数的x值
  239. */
  240. __getset(0,__proto,'x',function(){
  241. return this.elements[0];
  242. },function(value){
  243. this.elements[0]=value;
  244. });
  245. /**
  246. *设置四元数的y值
  247. */
  248. /**
  249. *获取四元数的y值
  250. */
  251. __getset(0,__proto,'y',function(){
  252. return this.elements[1];
  253. },function(value){
  254. this.elements[1]=value;
  255. });
  256. /**
  257. *设置四元数的z值
  258. */
  259. /**
  260. *获取四元数的z值
  261. */
  262. __getset(0,__proto,'z',function(){
  263. return this.elements[2];
  264. },function(value){
  265. this.elements[2]=value;
  266. });
  267. /**
  268. *设置四元数的w值
  269. */
  270. /**
  271. *获取四元数的w值
  272. */
  273. __getset(0,__proto,'w',function(){
  274. return this.elements[3];
  275. },function(value){
  276. this.elements[3]=value;
  277. });
  278. ConchQuaternion._dotArray=function(l,r){
  279. return l[0] *r[0]+l[1] *r[1]+l[2] *r[2]+l[3] *r[3];
  280. }
  281. ConchQuaternion._normalizeArray=function(f,o){
  282. var x=f[0],y=f[1],z=f[2],w=f[3];
  283. var len=x *x+y *y+z *z+w *w;
  284. if (len > 0){
  285. len=1 / Math.sqrt(len);
  286. o[0]=x *len;
  287. o[1]=y *len;
  288. o[2]=z *len;
  289. o[3]=w *len;
  290. }
  291. }
  292. ConchQuaternion._lerpArray=function(l,r,amount,o){
  293. var inverse=1.0-amount;
  294. if (ConchQuaternion._dotArray(l,r)>=0){
  295. o[0]=(inverse *l[0])+(amount *r[0]);
  296. o[1]=(inverse *l[1])+(amount *r[1]);
  297. o[2]=(inverse *l[2])+(amount *r[2]);
  298. o[3]=(inverse *l[3])+(amount *r[3]);
  299. }else {
  300. o[0]=(inverse *l[0])-(amount *r[0]);
  301. o[1]=(inverse *l[1])-(amount *r[1]);
  302. o[2]=(inverse *l[2])-(amount *r[2]);
  303. o[3]=(inverse *l[3])-(amount *r[3]);
  304. }
  305. ConchQuaternion._normalizeArray(o,o);
  306. }
  307. ConchQuaternion.createFromYawPitchRoll=function(yaw,pitch,roll,out){
  308. var halfRoll=roll *0.5;
  309. var halfPitch=pitch *0.5;
  310. var halfYaw=yaw *0.5;
  311. var sinRoll=Math.sin(halfRoll);
  312. var cosRoll=Math.cos(halfRoll);
  313. var sinPitch=Math.sin(halfPitch);
  314. var cosPitch=Math.cos(halfPitch);
  315. var sinYaw=Math.sin(halfYaw);
  316. var cosYaw=Math.cos(halfYaw);
  317. var oe=out.elements;
  318. oe[0]=(cosYaw *sinPitch *cosRoll)+(sinYaw *cosPitch *sinRoll);
  319. oe[1]=(sinYaw *cosPitch *cosRoll)-(cosYaw *sinPitch *sinRoll);
  320. oe[2]=(cosYaw *cosPitch *sinRoll)-(sinYaw *sinPitch *cosRoll);
  321. oe[3]=(cosYaw *cosPitch *cosRoll)+(sinYaw *sinPitch *sinRoll);
  322. }
  323. ConchQuaternion.multiply=function(left,right,out){
  324. var le=left.elements;
  325. var re=right.elements;
  326. var oe=out.elements;
  327. var lx=le[0];
  328. var ly=le[1];
  329. var lz=le[2];
  330. var lw=le[3];
  331. var rx=re[0];
  332. var ry=re[1];
  333. var rz=re[2];
  334. var rw=re[3];
  335. var a=(ly *rz-lz *ry);
  336. var b=(lz *rx-lx *rz);
  337. var c=(lx *ry-ly *rx);
  338. var d=(lx *rx+ly *ry+lz *rz);
  339. oe[0]=(lx *rw+rx *lw)+a;
  340. oe[1]=(ly *rw+ry *lw)+b;
  341. oe[2]=(lz *rw+rz *lw)+c;
  342. oe[3]=lw *rw-d;
  343. }
  344. ConchQuaternion.arcTanAngle=function(x,y){
  345. if (x==0){
  346. if (y==1)
  347. return Math.PI / 2;
  348. return-Math.PI / 2;
  349. }
  350. if (x > 0)
  351. return Math.atan(y / x);
  352. if (x < 0){
  353. if (y > 0)
  354. return Math.atan(y / x)+Math.PI;
  355. return Math.atan(y / x)-Math.PI;
  356. }
  357. return 0;
  358. }
  359. ConchQuaternion.angleTo=function(from,location,angle){
  360. ConchVector3.subtract(location,from,ConchQuaternion.TEMPVector30);
  361. ConchVector3.normalize(ConchQuaternion.TEMPVector30,ConchQuaternion.TEMPVector30);
  362. angle.elements[0]=Math.asin(ConchQuaternion.TEMPVector30.y);
  363. angle.elements[1]=ConchQuaternion.arcTanAngle(-ConchQuaternion.TEMPVector30.z,-ConchQuaternion.TEMPVector30.x);
  364. }
  365. ConchQuaternion.createFromAxisAngle=function(axis,rad,out){
  366. var e=out.elements;
  367. var f=axis.elements;
  368. rad=rad *0.5;
  369. var s=Math.sin(rad);
  370. e[0]=s *f[0];
  371. e[1]=s *f[1];
  372. e[2]=s *f[2];
  373. e[3]=Math.cos(rad);
  374. }
  375. ConchQuaternion.createFromMatrix3x3=function(sou,out){
  376. var e=out.elements;
  377. var f=sou.elements;
  378. var fTrace=f[0]+f[4]+f[8];
  379. var fRoot;
  380. if (fTrace > 0.0){
  381. fRoot=Math.sqrt(fTrace+1.0);
  382. e[3]=0.5 *fRoot;
  383. fRoot=0.5 / fRoot;
  384. e[0]=(f[5]-f[7])*fRoot;
  385. e[1]=(f[6]-f[2])*fRoot;
  386. e[2]=(f[1]-f[3])*fRoot;
  387. }else {
  388. var i=0;
  389. if (f[4] > f[0])
  390. i=1;
  391. if (f[8] > f[i *3+i])
  392. i=2;
  393. var j=(i+1)% 3;
  394. var k=(i+2)% 3;
  395. fRoot=Math.sqrt(f[i *3+i]-f[j *3+j]-f[k *3+k]+1.0);
  396. e[i]=0.5 *fRoot;
  397. fRoot=0.5 / fRoot;
  398. e[3]=(f[j *3+k]-f[k *3+j])*fRoot;
  399. e[j]=(f[j *3+i]+f[i *3+j])*fRoot;
  400. e[k]=(f[k *3+i]+f[i *3+k])*fRoot;
  401. }
  402. return;
  403. }
  404. ConchQuaternion.createFromMatrix4x4=function(mat,out){
  405. var me=mat.elements;
  406. var oe=out.elements;
  407. var sqrt;
  408. var half;
  409. var scale=me[0]+me[5]+me[10];
  410. if (scale > 0.0){
  411. sqrt=Math.sqrt(scale+1.0);
  412. oe[3]=sqrt *0.5;
  413. sqrt=0.5 / sqrt;
  414. oe[0]=(me[6]-me[9])*sqrt;
  415. oe[1]=(me[8]-me[2])*sqrt;
  416. oe[2]=(me[1]-me[4])*sqrt;
  417. }else if ((me[0] >=me[5])&& (me[0] >=me[10])){
  418. sqrt=Math.sqrt(1.0+me[0]-me[5]-me[10]);
  419. half=0.5 / sqrt;
  420. oe[0]=0.5 *sqrt;
  421. oe[1]=(me[1]+me[4])*half;
  422. oe[2]=(me[2]+me[8])*half;
  423. oe[3]=(me[6]-me[9])*half;
  424. }else if (me[5] > me[10]){
  425. sqrt=Math.sqrt(1.0+me[5]-me[0]-me[10]);
  426. half=0.5 / sqrt;
  427. oe[0]=(me[4]+me[1])*half;
  428. oe[1]=0.5 *sqrt;
  429. oe[2]=(me[9]+me[6])*half;
  430. oe[3]=(me[8]-me[2])*half;
  431. }else {
  432. sqrt=Math.sqrt(1.0+me[10]-me[0]-me[5]);
  433. half=0.5 / sqrt;
  434. oe[0]=(me[8]+me[2])*half;
  435. oe[1]=(me[9]+me[6])*half;
  436. oe[2]=0.5 *sqrt;
  437. oe[3]=(me[1]-me[4])*half;
  438. }
  439. }
  440. ConchQuaternion.slerp=function(left,right,t,out){
  441. var a=left.elements;
  442. var b=right.elements;
  443. var oe=out.elements;
  444. var ax=a[0],ay=a[1],az=a[2],aw=a[3],bx=b[0],by=b[1],bz=b[2],bw=b[3];
  445. var omega,cosom,sinom,scale0,scale1;
  446. cosom=ax *bx+ay *by+az *bz+aw *bw;
  447. if (cosom < 0.0){
  448. cosom=-cosom;
  449. bx=-bx;
  450. by=-by;
  451. bz=-bz;
  452. bw=-bw;
  453. }
  454. if ((1.0-cosom)> 0.000001){
  455. omega=Math.acos(cosom);
  456. sinom=Math.sin(omega);
  457. scale0=Math.sin((1.0-t)*omega)/ sinom;
  458. scale1=Math.sin(t *omega)/ sinom;
  459. }else {
  460. scale0=1.0-t;
  461. scale1=t;
  462. }
  463. oe[0]=scale0 *ax+scale1 *bx;
  464. oe[1]=scale0 *ay+scale1 *by;
  465. oe[2]=scale0 *az+scale1 *bz;
  466. oe[3]=scale0 *aw+scale1 *bw;
  467. return oe;
  468. }
  469. ConchQuaternion.lerp=function(left,right,amount,out){
  470. ConchQuaternion._lerpArray(left.elements,right.elements,amount,out.elements);
  471. }
  472. ConchQuaternion.add=function(left,right,out){
  473. var e=out.elements;
  474. var f=left.elements;
  475. var g=right.elements;
  476. e[0]=f[0]+g[0];
  477. e[1]=f[1]+g[1];
  478. e[2]=f[2]+g[2];
  479. e[3]=f[3]+g[3];
  480. }
  481. ConchQuaternion.dot=function(left,right){
  482. return ConchQuaternion._dotArray(left.elements,right.elements);
  483. }
  484. ConchQuaternion.rotationLookAt=function(forward,up,out){
  485. ConchQuaternion.lookAt(ConchVector3.ZERO,forward,up,out);
  486. }
  487. ConchQuaternion.lookAt=function(eye,target,up,out){
  488. Matrix3x3.lookAt(eye,target,up,ConchQuaternion._tempMatrix3x3);
  489. ConchQuaternion.rotationMatrix(ConchQuaternion._tempMatrix3x3,out);
  490. }
  491. ConchQuaternion.invert=function(value,out){
  492. var vE=value.elements;
  493. var oE=out.elements;
  494. var lengthSq=value.lengthSquared();
  495. if (!MathUtils3D.isZero(lengthSq)){
  496. lengthSq=1.0 / lengthSq;
  497. oE[0]=-vE[0] *lengthSq;
  498. oE[1]=-vE[1] *lengthSq;
  499. oE[2]=-vE[2] *lengthSq;
  500. oE[3]=vE[3] *lengthSq;
  501. }
  502. }
  503. ConchQuaternion.rotationMatrix=function(matrix3x3,out){
  504. var me=matrix3x3.elements;
  505. var m11=me[0];
  506. var m12=me[1];
  507. var m13=me[2];
  508. var m21=me[3];
  509. var m22=me[4];
  510. var m23=me[5];
  511. var m31=me[6];
  512. var m32=me[7];
  513. var m33=me[8];
  514. var oe=out.elements;
  515. var sqrt=NaN,half=NaN;
  516. var scale=m11+m22+m33;
  517. if (scale > 0){
  518. sqrt=Math.sqrt(scale+1);
  519. oe[3]=sqrt *0.5;
  520. sqrt=0.5 / sqrt;
  521. oe[0]=(m23-m32)*sqrt;
  522. oe[1]=(m31-m13)*sqrt;
  523. oe[2]=(m12-m21)*sqrt;
  524. }else if ((m11 >=m22)&& (m11 >=m33)){
  525. sqrt=Math.sqrt(1+m11-m22-m33);
  526. half=0.5 / sqrt;
  527. oe[0]=0.5 *sqrt;
  528. oe[1]=(m12+m21)*half;
  529. oe[2]=(m13+m31)*half;
  530. oe[3]=(m23-m32)*half;
  531. }else if (m22 > m33){
  532. sqrt=Math.sqrt(1+m22-m11-m33);
  533. half=0.5 / sqrt;
  534. oe[0]=(m21+m12)*half;
  535. oe[1]=0.5 *sqrt;
  536. oe[2]=(m32+m23)*half;
  537. oe[3]=(m31-m13)*half;
  538. }else {
  539. sqrt=Math.sqrt(1+m33-m11-m22);
  540. half=0.5 / sqrt;
  541. oe[0]=(m31+m13)*half;
  542. oe[1]=(m32+m23)*half;
  543. oe[2]=0.5 *sqrt;
  544. oe[3]=(m12-m21)*half;
  545. }
  546. }
  547. ConchQuaternion.DEFAULT=new ConchQuaternion();
  548. __static(ConchQuaternion,
  549. ['TEMPVector30',function(){return this.TEMPVector30=new ConchVector3();},'TEMPVector31',function(){return this.TEMPVector31=new ConchVector3();},'TEMPVector32',function(){return this.TEMPVector32=new ConchVector3();},'TEMPVector33',function(){return this.TEMPVector33=new ConchVector3();},'TEMPMatrix0',function(){return this.TEMPMatrix0=new Matrix4x4();},'TEMPMatrix1',function(){return this.TEMPMatrix1=new Matrix4x4();},'_tempMatrix3x3',function(){return this._tempMatrix3x3=new Matrix3x3();},'NAN',function(){return this.NAN=new ConchQuaternion(NaN,NaN,NaN,NaN);}
  550. ]);
  551. return ConchQuaternion;
  552. })()
  553. /**
  554. *<code>Vector4</code> 类用于创建四维向量。
  555. */
  556. //class laya.d3.math.Native.ConchVector4
  557. var ConchVector4=(function(){
  558. function ConchVector4(x,y,z,w){
  559. /**[只读]向量元素集合。*/
  560. this.elements=null;
  561. (x===void 0)&& (x=0);
  562. (y===void 0)&& (y=0);
  563. (z===void 0)&& (z=0);
  564. (w===void 0)&& (w=0);
  565. var v=this.elements=new Float32Array(4);
  566. v[0]=x;
  567. v[1]=y;
  568. v[2]=z;
  569. v[3]=w;
  570. }
  571. __class(ConchVector4,'laya.d3.math.Native.ConchVector4');
  572. var __proto=ConchVector4.prototype;
  573. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  574. /**
  575. *从Array数组拷贝值。
  576. *@param array 数组。
  577. *@param offset 数组偏移。
  578. */
  579. __proto.fromArray=function(array,offset){
  580. (offset===void 0)&& (offset=0);
  581. this.elements[0]=array[offset+0];
  582. this.elements[1]=array[offset+1];
  583. this.elements[2]=array[offset+2];
  584. this.elements[3]=array[offset+3];
  585. }
  586. /**
  587. *克隆。
  588. *@param destObject 克隆源。
  589. */
  590. __proto.cloneTo=function(destObject){
  591. var destVector4=destObject;
  592. var destE=destVector4.elements;
  593. var s=this.elements;
  594. destE[0]=s[0];
  595. destE[1]=s[1];
  596. destE[2]=s[2];
  597. destE[3]=s[3];
  598. }
  599. /**
  600. *克隆。
  601. *@return 克隆副本。
  602. */
  603. __proto.clone=function(){
  604. var destVector4=/*__JS__ */new this.constructor();
  605. this.cloneTo(destVector4);
  606. return destVector4;
  607. }
  608. /**
  609. *求四维向量的长度。
  610. *@return 长度。
  611. */
  612. __proto.length=function(){
  613. return Math.sqrt(this.x *this.x+this.y *this.y+this.z *this.z+this.w *this.w);
  614. }
  615. /**
  616. *求四维向量长度的平方。
  617. *@return 长度的平方。
  618. */
  619. __proto.lengthSquared=function(){
  620. return this.x *this.x+this.y *this.y+this.z *this.z+this.w *this.w;
  621. }
  622. /**
  623. *设置X轴坐标。
  624. *@param value X轴坐标。
  625. */
  626. /**
  627. *获取X轴坐标。
  628. *@return X轴坐标。
  629. */
  630. __getset(0,__proto,'x',function(){
  631. return this.elements[0];
  632. },function(value){
  633. this.elements[0]=value;
  634. });
  635. /**
  636. *设置Y轴坐标。
  637. *@param value Y轴坐标。
  638. */
  639. /**
  640. *获取Y轴坐标。
  641. *@return Y轴坐标。
  642. */
  643. __getset(0,__proto,'y',function(){
  644. return this.elements[1];
  645. },function(value){
  646. this.elements[1]=value;
  647. });
  648. /**
  649. *设置Z轴坐标。
  650. *@param value Z轴坐标。
  651. */
  652. /**
  653. *获取Z轴坐标。
  654. *@return Z轴坐标。
  655. */
  656. __getset(0,__proto,'z',function(){
  657. return this.elements[2];
  658. },function(value){
  659. this.elements[2]=value;
  660. });
  661. /**
  662. *设置W轴坐标。
  663. *@param value W轴坐标。
  664. */
  665. /**
  666. *获取W轴坐标。
  667. *@return W轴坐标。
  668. */
  669. __getset(0,__proto,'w',function(){
  670. return this.elements[3];
  671. },function(value){
  672. this.elements[3]=value;
  673. });
  674. ConchVector4.lerp=function(a,b,t,out){
  675. var e=out.elements;
  676. var f=a.elements;
  677. var g=b.elements;
  678. var ax=f[0],ay=f[1],az=f[2],aw=f[3];
  679. e[0]=ax+t *(g[0]-ax);
  680. e[1]=ay+t *(g[1]-ay);
  681. e[2]=az+t *(g[2]-az);
  682. e[3]=aw+t *(g[3]-aw);
  683. }
  684. ConchVector4.transformByM4x4=function(vector4,m4x4,out){
  685. var ve=vector4.elements;
  686. var vx=ve[0];
  687. var vy=ve[1];
  688. var vz=ve[2];
  689. var vw=ve[3];
  690. var me=m4x4.elements;
  691. var oe=out.elements;
  692. oe[0]=vx *me[0]+vy *me[4]+vz *me[8]+vw *me[12];
  693. oe[1]=vx *me[1]+vy *me[5]+vz *me[9]+vw *me[13];
  694. oe[2]=vx *me[2]+vy *me[6]+vz *me[10]+vw *me[14];
  695. oe[3]=vx *me[3]+vy *me[7]+vz *me[11]+vw *me[15];
  696. }
  697. ConchVector4.equals=function(a,b){
  698. var ae=a.elements;
  699. var be=b.elements;
  700. return MathUtils3D.nearEqual(Math.abs(ae[0]),Math.abs(be[0]))&& MathUtils3D.nearEqual(Math.abs(ae[1]),Math.abs(be[1]))&& MathUtils3D.nearEqual(Math.abs(ae[2]),Math.abs(be[2]))&& MathUtils3D.nearEqual(Math.abs(ae[3]),Math.abs(be[3]));
  701. }
  702. ConchVector4.normalize=function(s,out){
  703. var se=s.elements;
  704. var oe=out.elements;
  705. var len=/*if err,please use iflash.method.xmlLength()*/s.length();
  706. if (len > 0){
  707. oe[0]=se[0] *len;
  708. oe[1]=se[1] *len;
  709. oe[2]=se[2] *len;
  710. oe[3]=se[3] *len;
  711. }
  712. }
  713. ConchVector4.add=function(a,b,out){
  714. var oe=out.elements;
  715. var ae=a.elements;
  716. var be=b.elements;
  717. oe[0]=ae[0]+be[0];
  718. oe[1]=ae[1]+be[1];
  719. oe[2]=ae[2]+be[2];
  720. oe[3]=ae[3]+be[3];
  721. }
  722. ConchVector4.subtract=function(a,b,out){
  723. var oe=out.elements;
  724. var ae=a.elements;
  725. var be=b.elements;
  726. oe[0]=ae[0]-be[0];
  727. oe[1]=ae[1]-be[1];
  728. oe[2]=ae[2]-be[2];
  729. oe[3]=ae[3]-be[3];
  730. }
  731. ConchVector4.multiply=function(a,b,out){
  732. var oe=out.elements;
  733. var ae=a.elements;
  734. var be=b.elements;
  735. oe[0]=ae[0] *be[0];
  736. oe[1]=ae[1] *be[1];
  737. oe[2]=ae[2] *be[2];
  738. oe[3]=ae[3] *be[3];
  739. }
  740. ConchVector4.scale=function(a,b,out){
  741. var oe=out.elements;
  742. var ae=a.elements;
  743. oe[0]=ae[0] *b;
  744. oe[1]=ae[1] *b;
  745. oe[2]=ae[2] *b;
  746. oe[3]=ae[3] *b;
  747. }
  748. ConchVector4.Clamp=function(value,min,max,out){
  749. var valuee=value.elements;
  750. var x=valuee[0];
  751. var y=valuee[1];
  752. var z=valuee[2];
  753. var w=valuee[3];
  754. var mine=min.elements;
  755. var mineX=mine[0];
  756. var mineY=mine[1];
  757. var mineZ=mine[2];
  758. var mineW=mine[3];
  759. var maxe=max.elements;
  760. var maxeX=maxe[0];
  761. var maxeY=maxe[1];
  762. var maxeZ=maxe[2];
  763. var maxeW=maxe[3];
  764. var oute=out.elements;
  765. x=(x > maxeX)? maxeX :x;
  766. x=(x < mineX)? mineX :x;
  767. y=(y > maxeY)? maxeY :y;
  768. y=(y < mineY)? mineY :y;
  769. z=(z > maxeZ)? maxeZ :z;
  770. z=(z < mineZ)? mineZ :z;
  771. w=(w > maxeW)? maxeW :w;
  772. w=(w < mineW)? mineW :w;
  773. oute[0]=x;
  774. oute[1]=y;
  775. oute[2]=z;
  776. oute[3]=w;
  777. }
  778. ConchVector4.distanceSquared=function(value1,value2){
  779. var value1e=value1.elements;
  780. var value2e=value2.elements;
  781. var x=value1e[0]-value2e[0];
  782. var y=value1e[1]-value2e[1];
  783. var z=value1e[2]-value2e[2];
  784. var w=value1e[3]-value2e[3];
  785. return (x *x)+(y *y)+(z *z)+(w *w);
  786. }
  787. ConchVector4.distance=function(value1,value2){
  788. var value1e=value1.elements;
  789. var value2e=value2.elements;
  790. var x=value1e[0]-value2e[0];
  791. var y=value1e[1]-value2e[1];
  792. var z=value1e[2]-value2e[2];
  793. var w=value1e[3]-value2e[3];
  794. return Math.sqrt((x *x)+(y *y)+(z *z)+(w *w));
  795. }
  796. ConchVector4.dot=function(a,b){
  797. var ae=a.elements;
  798. var be=b.elements;
  799. var r=(ae[0] *be[0])+(ae[1] *be[1])+(ae[2] *be[2])+(ae[3] *be[3]);
  800. return r;
  801. }
  802. ConchVector4.min=function(a,b,out){
  803. var e=out.elements;
  804. var f=a.elements;
  805. var g=b.elements
  806. e[0]=Math.min(f[0],g[0]);
  807. e[1]=Math.min(f[1],g[1]);
  808. e[2]=Math.min(f[2],g[2]);
  809. e[3]=Math.min(f[3],g[3]);
  810. }
  811. ConchVector4.max=function(a,b,out){
  812. var e=out.elements;
  813. var f=a.elements;
  814. var g=b.elements
  815. e[0]=Math.max(f[0],g[0]);
  816. e[1]=Math.max(f[1],g[1]);
  817. e[2]=Math.max(f[2],g[2]);
  818. e[3]=Math.max(f[3],g[3]);
  819. }
  820. __static(ConchVector4,
  821. ['ZERO',function(){return this.ZERO=new ConchVector4();},'ONE',function(){return this.ONE=new ConchVector4(1.0,1.0,1.0,1.0);},'UnitX',function(){return this.UnitX=new ConchVector4(1.0,0.0,0.0,0.0);},'UnitY',function(){return this.UnitY=new ConchVector4(0.0,1.0,0.0,0.0);},'UnitZ',function(){return this.UnitZ=new ConchVector4(0.0,0.0,1.0,0.0);},'UnitW',function(){return this.UnitW=new ConchVector4(0.0,0.0,0.0,1.0);}
  822. ]);
  823. return ConchVector4;
  824. })()
  825. /**
  826. *<code>Vector3</code> 类用于创建三维向量。
  827. */
  828. //class laya.d3.math.Native.ConchVector3
  829. var ConchVector3=(function(){
  830. function ConchVector3(x,y,z,nativeElements){
  831. /**[只读]向量元素集合。*/
  832. this.elements=null;
  833. (x===void 0)&& (x=0);
  834. (y===void 0)&& (y=0);
  835. (z===void 0)&& (z=0);
  836. var v;
  837. if (nativeElements){
  838. v=nativeElements;
  839. }else {
  840. v=new Float32Array(3);
  841. }
  842. this.elements=v;
  843. v[0]=x;
  844. v[1]=y;
  845. v[2]=z;
  846. }
  847. __class(ConchVector3,'laya.d3.math.Native.ConchVector3');
  848. var __proto=ConchVector3.prototype;
  849. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  850. /**
  851. *设置xyz值。
  852. *@param x X值。
  853. *@param y Y值。
  854. *@param z Z值。
  855. */
  856. __proto.setValue=function(x,y,z){
  857. this.elements[0]=x;
  858. this.elements[1]=y;
  859. this.elements[2]=z;
  860. }
  861. /**
  862. *从Array数组拷贝值。
  863. *@param array 数组。
  864. *@param offset 数组偏移。
  865. */
  866. __proto.fromArray=function(array,offset){
  867. (offset===void 0)&& (offset=0);
  868. this.elements[0]=array[offset+0];
  869. this.elements[1]=array[offset+1];
  870. this.elements[2]=array[offset+2];
  871. }
  872. /**
  873. *克隆。
  874. *@param destObject 克隆源。
  875. */
  876. __proto.cloneTo=function(destObject){
  877. var destVector3=destObject;
  878. var destE=destVector3.elements;
  879. var s=this.elements;
  880. destE[0]=s[0];
  881. destE[1]=s[1];
  882. destE[2]=s[2];
  883. }
  884. /**
  885. *克隆。
  886. *@return 克隆副本。
  887. */
  888. __proto.clone=function(){
  889. var destVector3=/*__JS__ */new this.constructor();
  890. this.cloneTo(destVector3);
  891. return destVector3;
  892. }
  893. __proto.toDefault=function(){
  894. this.elements[0]=0;
  895. this.elements[1]=0;
  896. this.elements[2]=0;
  897. }
  898. /**
  899. *设置X轴坐标。
  900. *@param value X轴坐标。
  901. */
  902. /**
  903. *获取X轴坐标。
  904. *@return X轴坐标。
  905. */
  906. __getset(0,__proto,'x',function(){
  907. return this.elements[0];
  908. },function(value){
  909. this.elements[0]=value;
  910. });
  911. /**
  912. *设置Y轴坐标。
  913. *@param value Y轴坐标。
  914. */
  915. /**
  916. *获取Y轴坐标。
  917. *@return Y轴坐标。
  918. */
  919. __getset(0,__proto,'y',function(){
  920. return this.elements[1];
  921. },function(value){
  922. this.elements[1]=value;
  923. });
  924. /**
  925. *设置Z轴坐标。
  926. *@param value Z轴坐标。
  927. */
  928. /**
  929. *获取Z轴坐标。
  930. *@return Z轴坐标。
  931. */
  932. __getset(0,__proto,'z',function(){
  933. return this.elements[2];
  934. },function(value){
  935. this.elements[2]=value;
  936. });
  937. ConchVector3.distanceSquared=function(value1,value2){
  938. var value1e=value1.elements;
  939. var value2e=value2.elements;
  940. var x=value1e[0]-value2e[0];
  941. var y=value1e[1]-value2e[1];
  942. var z=value1e[2]-value2e[2];
  943. return (x *x)+(y *y)+(z *z);
  944. }
  945. ConchVector3.distance=function(value1,value2){
  946. var value1e=value1.elements;
  947. var value2e=value2.elements;
  948. var x=value1e[0]-value2e[0];
  949. var y=value1e[1]-value2e[1];
  950. var z=value1e[2]-value2e[2];
  951. return Math.sqrt((x *x)+(y *y)+(z *z));
  952. }
  953. ConchVector3.min=function(a,b,out){
  954. var e=out.elements;
  955. var f=a.elements;
  956. var g=b.elements
  957. e[0]=Math.min(f[0],g[0]);
  958. e[1]=Math.min(f[1],g[1]);
  959. e[2]=Math.min(f[2],g[2]);
  960. }
  961. ConchVector3.max=function(a,b,out){
  962. var e=out.elements;
  963. var f=a.elements;
  964. var g=b.elements
  965. e[0]=Math.max(f[0],g[0]);
  966. e[1]=Math.max(f[1],g[1]);
  967. e[2]=Math.max(f[2],g[2]);
  968. }
  969. ConchVector3.transformQuat=function(source,rotation,out){
  970. var destination=out.elements;
  971. var se=source.elements;
  972. var re=rotation.elements;
  973. var x=se[0],y=se[1],z=se[2],qx=re[0],qy=re[1],qz=re[2],qw=re[3],
  974. ix=qw *x+qy *z-qz *y,iy=qw *y+qz *x-qx *z,iz=qw *z+qx *y-qy *x,iw=-qx *x-qy *y-qz *z;
  975. destination[0]=ix *qw+iw *-qx+iy *-qz-iz *-qy;
  976. destination[1]=iy *qw+iw *-qy+iz *-qx-ix *-qz;
  977. destination[2]=iz *qw+iw *-qz+ix *-qy-iy *-qx;
  978. }
  979. ConchVector3.scalarLength=function(a){
  980. var f=a.elements;
  981. var x=f[0],y=f[1],z=f[2];
  982. return Math.sqrt(x *x+y *y+z *z);
  983. }
  984. ConchVector3.scalarLengthSquared=function(a){
  985. var f=a.elements;
  986. var x=f[0],y=f[1],z=f[2];
  987. return x *x+y *y+z *z;
  988. }
  989. ConchVector3.normalize=function(s,out){
  990. var se=s.elements;
  991. var oe=out.elements;
  992. var x=se[0],y=se[1],z=se[2];
  993. var len=x *x+y *y+z *z;
  994. if (len > 0){
  995. len=1 / Math.sqrt(len);
  996. oe[0]=se[0] *len;
  997. oe[1]=se[1] *len;
  998. oe[2]=se[2] *len;
  999. }
  1000. }
  1001. ConchVector3.multiply=function(a,b,out){
  1002. var e=out.elements;
  1003. var f=a.elements;
  1004. var g=b.elements
  1005. e[0]=f[0] *g[0];
  1006. e[1]=f[1] *g[1];
  1007. e[2]=f[2] *g[2];
  1008. }
  1009. ConchVector3.scale=function(a,b,out){
  1010. var e=out.elements;
  1011. var f=a.elements;
  1012. e[0]=f[0] *b;
  1013. e[1]=f[1] *b;
  1014. e[2]=f[2] *b;
  1015. }
  1016. ConchVector3.lerp=function(a,b,t,out){
  1017. var e=out.elements;
  1018. var f=a.elements;
  1019. var g=b.elements;
  1020. var ax=f[0],ay=f[1],az=f[2];
  1021. e[0]=ax+t *(g[0]-ax);
  1022. e[1]=ay+t *(g[1]-ay);
  1023. e[2]=az+t *(g[2]-az);
  1024. }
  1025. ConchVector3.transformV3ToV3=function(vector,transform,result){
  1026. var intermediate=ConchVector3._tempVector4;
  1027. ConchVector3.transformV3ToV4(vector,transform,intermediate);
  1028. var intermediateElem=intermediate.elements;
  1029. var resultElem=result.elements;
  1030. resultElem[0]=intermediateElem[0];
  1031. resultElem[1]=intermediateElem[1];
  1032. resultElem[2]=intermediateElem[2];
  1033. }
  1034. ConchVector3.transformV3ToV4=function(vector,transform,result){
  1035. var vectorElem=vector.elements;
  1036. var vectorX=vectorElem[0];
  1037. var vectorY=vectorElem[1];
  1038. var vectorZ=vectorElem[2];
  1039. var transformElem=transform.elements;
  1040. var resultElem=result.elements;
  1041. resultElem[0]=(vectorX *transformElem[0])+(vectorY *transformElem[4])+(vectorZ *transformElem[8])+transformElem[12];
  1042. resultElem[1]=(vectorX *transformElem[1])+(vectorY *transformElem[5])+(vectorZ *transformElem[9])+transformElem[13];
  1043. resultElem[2]=(vectorX *transformElem[2])+(vectorY *transformElem[6])+(vectorZ *transformElem[10])+transformElem[14];
  1044. resultElem[3]=(vectorX *transformElem[3])+(vectorY *transformElem[7])+(vectorZ *transformElem[11])+transformElem[15];
  1045. }
  1046. ConchVector3.TransformNormal=function(normal,transform,result){
  1047. var normalElem=normal.elements;
  1048. var normalX=normalElem[0];
  1049. var normalY=normalElem[1];
  1050. var normalZ=normalElem[2];
  1051. var transformElem=transform.elements;
  1052. var resultElem=result.elements;
  1053. resultElem[0]=(normalX *transformElem[0])+(normalY *transformElem[4])+(normalZ *transformElem[8]);
  1054. resultElem[1]=(normalX *transformElem[1])+(normalY *transformElem[5])+(normalZ *transformElem[9]);
  1055. resultElem[2]=(normalX *transformElem[2])+(normalY *transformElem[6])+(normalZ *transformElem[10]);
  1056. }
  1057. ConchVector3.transformCoordinate=function(coordinate,transform,result){
  1058. var coordinateElem=coordinate.elements;
  1059. var coordinateX=coordinateElem[0];
  1060. var coordinateY=coordinateElem[1];
  1061. var coordinateZ=coordinateElem[2];
  1062. var transformElem=transform.elements;
  1063. var w=((coordinateX *transformElem[3])+(coordinateY *transformElem[7])+(coordinateZ *transformElem[11])+transformElem[15]);
  1064. var resultElem=result.elements;
  1065. resultElem[0]=(coordinateX *transformElem[0])+(coordinateY *transformElem[4])+(coordinateZ *transformElem[8])+transformElem[12] / w;
  1066. resultElem[1]=(coordinateX *transformElem[1])+(coordinateY *transformElem[5])+(coordinateZ *transformElem[9])+transformElem[13] / w;
  1067. resultElem[2]=(coordinateX *transformElem[2])+(coordinateY *transformElem[6])+(coordinateZ *transformElem[10])+transformElem[14] / w;
  1068. }
  1069. ConchVector3.Clamp=function(value,min,max,out){
  1070. var valuee=value.elements;
  1071. var x=valuee[0];
  1072. var y=valuee[1];
  1073. var z=valuee[2];
  1074. var mine=min.elements;
  1075. var mineX=mine[0];
  1076. var mineY=mine[1];
  1077. var mineZ=mine[2];
  1078. var maxe=max.elements;
  1079. var maxeX=maxe[0];
  1080. var maxeY=maxe[1];
  1081. var maxeZ=maxe[2];
  1082. var oute=out.elements;
  1083. x=(x > maxeX)? maxeX :x;
  1084. x=(x < mineX)? mineX :x;
  1085. y=(y > maxeY)? maxeY :y;
  1086. y=(y < mineY)? mineY :y;
  1087. z=(z > maxeZ)? maxeZ :z;
  1088. z=(z < mineZ)? mineZ :z;
  1089. oute[0]=x;
  1090. oute[1]=y;
  1091. oute[2]=z;
  1092. }
  1093. ConchVector3.add=function(a,b,out){
  1094. var e=out.elements;
  1095. var f=a.elements;
  1096. var g=b.elements
  1097. e[0]=f[0]+g[0];
  1098. e[1]=f[1]+g[1];
  1099. e[2]=f[2]+g[2];
  1100. }
  1101. ConchVector3.subtract=function(a,b,o){
  1102. var oe=o.elements;
  1103. var ae=a.elements;
  1104. var be=b.elements;
  1105. oe[0]=ae[0]-be[0];
  1106. oe[1]=ae[1]-be[1];
  1107. oe[2]=ae[2]-be[2];
  1108. }
  1109. ConchVector3.cross=function(a,b,o){
  1110. var ae=a.elements;
  1111. var be=b.elements;
  1112. var oe=o.elements;
  1113. var ax=ae[0],ay=ae[1],az=ae[2],bx=be[0],by=be[1],bz=be[2];
  1114. oe[0]=ay *bz-az *by;
  1115. oe[1]=az *bx-ax *bz;
  1116. oe[2]=ax *by-ay *bx;
  1117. }
  1118. ConchVector3.dot=function(a,b){
  1119. var ae=a.elements;
  1120. var be=b.elements;
  1121. var r=(ae[0] *be[0])+(ae[1] *be[1])+(ae[2] *be[2]);
  1122. return r;
  1123. }
  1124. ConchVector3.equals=function(a,b){
  1125. var ae=a.elements;
  1126. var be=b.elements;
  1127. return MathUtils3D.nearEqual(ae[0],be[0])&& MathUtils3D.nearEqual(ae[1],be[1])&& MathUtils3D.nearEqual(ae[2],be[2]);
  1128. }
  1129. ConchVector3.ZERO=new ConchVector3(0.0,0.0,0.0);
  1130. ConchVector3.ONE=new ConchVector3(1.0,1.0,1.0);
  1131. ConchVector3.NegativeUnitX=new ConchVector3(-1,0,0);
  1132. ConchVector3.UnitX=new ConchVector3(1,0,0);
  1133. ConchVector3.UnitY=new ConchVector3(0,1,0);
  1134. ConchVector3.UnitZ=new ConchVector3(0,0,1);
  1135. ConchVector3.ForwardRH=new ConchVector3(0,0,-1);
  1136. ConchVector3.ForwardLH=new ConchVector3(0,0,1);
  1137. ConchVector3.Up=new ConchVector3(0,1,0);
  1138. ConchVector3.NAN=new ConchVector3(NaN,NaN,NaN);
  1139. __static(ConchVector3,
  1140. ['_tempVector4',function(){return this._tempVector4=new ConchVector4();}
  1141. ]);
  1142. return ConchVector3;
  1143. })()
  1144. /**
  1145. *<code>ColorOverLifetime</code> 类用于粒子的生命周期颜色。
  1146. */
  1147. //class laya.d3.core.particleShuriKen.module.ColorOverLifetime
  1148. var ColorOverLifetime=(function(){
  1149. function ColorOverLifetime(color){
  1150. /**@private */
  1151. this._color=null;
  1152. /**是否启用。*/
  1153. this.enbale=false;
  1154. this._color=color;
  1155. }
  1156. __class(ColorOverLifetime,'laya.d3.core.particleShuriKen.module.ColorOverLifetime');
  1157. var __proto=ColorOverLifetime.prototype;
  1158. /**
  1159. *克隆。
  1160. *@param destObject 克隆源。
  1161. */
  1162. __proto.cloneTo=function(destObject){
  1163. var destColorOverLifetime=destObject;
  1164. this._color.cloneTo(destColorOverLifetime._color);
  1165. destColorOverLifetime.enbale=this.enbale;
  1166. }
  1167. /**
  1168. *克隆。
  1169. *@return 克隆副本。
  1170. */
  1171. __proto.clone=function(){
  1172. var destColor;
  1173. switch (this._color.type){
  1174. case 0:
  1175. destColor=GradientColor.createByConstant(this._color.constant.clone());
  1176. break ;
  1177. case 1:
  1178. destColor=GradientColor.createByGradient(this._color.gradient.clone());
  1179. break ;
  1180. case 2:
  1181. destColor=GradientColor.createByRandomTwoConstant(this._color.constantMin.clone(),this._color.constantMax.clone());
  1182. break ;
  1183. case 3:
  1184. destColor=GradientColor.createByRandomTwoGradient(this._color.gradientMin.clone(),this._color.gradientMax.clone());
  1185. break ;
  1186. };
  1187. var destColorOverLifetime=/*__JS__ */new this.constructor(destColor);
  1188. destColorOverLifetime.enbale=this.enbale;
  1189. return destColorOverLifetime;
  1190. }
  1191. /**
  1192. *获取颜色。
  1193. */
  1194. __getset(0,__proto,'color',function(){
  1195. return this._color;
  1196. });
  1197. return ColorOverLifetime;
  1198. })()
  1199. /**
  1200. *<code>BaseShape</code> 类用于粒子形状。
  1201. */
  1202. //class laya.d3.core.particleShuriKen.module.shape.BaseShape
  1203. var BaseShape=(function(){
  1204. function BaseShape(){
  1205. /**是否启用。*/
  1206. this.enable=false;
  1207. /**随机方向。*/
  1208. this.randomDirection=false;
  1209. }
  1210. __class(BaseShape,'laya.d3.core.particleShuriKen.module.shape.BaseShape');
  1211. var __proto=BaseShape.prototype;
  1212. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  1213. /**@private */
  1214. __proto._getShapeBoundBox=function(boundBox){
  1215. throw new Error("BaseShape: must override it.");
  1216. }
  1217. /**@private */
  1218. __proto._getSpeedBoundBox=function(boundBox){
  1219. throw new Error("BaseShape: must override it.");
  1220. }
  1221. /**
  1222. *用于生成粒子初始位置和方向。
  1223. *@param position 粒子位置。
  1224. *@param direction 粒子方向。
  1225. */
  1226. __proto.generatePositionAndDirection=function(position,direction,rand,randomSeeds){
  1227. throw new Error("BaseShape: must override it.");
  1228. }
  1229. /**
  1230. *@private
  1231. */
  1232. __proto._calculateProceduralBounds=function(boundBox,emitterPosScale,minMaxBounds){
  1233. this._getShapeBoundBox(boundBox);
  1234. var min=boundBox.min;
  1235. var max=boundBox.max;
  1236. Vector3.multiply(min,emitterPosScale,min);
  1237. Vector3.multiply(max,emitterPosScale,max);
  1238. var speedBounds=new BoundBox(new Vector3(),new Vector3());
  1239. if (this.randomDirection){
  1240. speedBounds.min=new Vector3(-1,-1,-1);
  1241. speedBounds.max=new Vector3(1,1,1);
  1242. }
  1243. else{
  1244. this._getSpeedBoundBox(speedBounds);
  1245. };
  1246. var maxSpeedBound=new BoundBox(new Vector3(),new Vector3());
  1247. var maxSpeedMin=maxSpeedBound.min;
  1248. var maxSpeedMax=maxSpeedBound.max;
  1249. Vector3.scale(speedBounds.min,minMaxBounds.y,maxSpeedMin);
  1250. Vector3.scale(speedBounds.max,minMaxBounds.y,maxSpeedMax);
  1251. Vector3.add(boundBox.min,maxSpeedMin,maxSpeedMin);
  1252. Vector3.add(boundBox.max,maxSpeedMax,maxSpeedMax);
  1253. Vector3.min(boundBox.min,maxSpeedMin,boundBox.min);
  1254. Vector3.max(boundBox.max,maxSpeedMin,boundBox.max);
  1255. var minSpeedBound=new BoundBox(new Vector3(),new Vector3());
  1256. var minSpeedMin=minSpeedBound.min;
  1257. var minSpeedMax=minSpeedBound.max;
  1258. Vector3.scale(speedBounds.min,minMaxBounds.x,minSpeedMin);
  1259. Vector3.scale(speedBounds.max,minMaxBounds.x,minSpeedMax);
  1260. Vector3.min(minSpeedBound.min,minSpeedMax,maxSpeedMin);
  1261. Vector3.max(minSpeedBound.min,minSpeedMax,maxSpeedMax);
  1262. Vector3.min(boundBox.min,maxSpeedMin,boundBox.min);
  1263. Vector3.max(boundBox.max,maxSpeedMin,boundBox.max);
  1264. }
  1265. /**
  1266. *克隆。
  1267. *@param destObject 克隆源。
  1268. */
  1269. __proto.cloneTo=function(destObject){
  1270. var destShape=destObject;
  1271. destShape.enable=this.enable;
  1272. }
  1273. /**
  1274. *克隆。
  1275. *@return 克隆副本。
  1276. */
  1277. __proto.clone=function(){
  1278. var destShape=/*__JS__ */new this.constructor();
  1279. this.cloneTo(destShape);
  1280. return destShape;
  1281. }
  1282. return BaseShape;
  1283. })()
  1284. /**
  1285. *<code>ColliderShape</code> 类用于创建形状碰撞器的父类,该类为抽象类。
  1286. */
  1287. //class laya.d3.physics.shape.ColliderShape
  1288. var ColliderShape=(function(){
  1289. function ColliderShape(){
  1290. /**@private */
  1291. //this._nativeShape=null;
  1292. /**@private */
  1293. //this._type=0;
  1294. /**@private */
  1295. this._attatched=false;
  1296. /**@private */
  1297. this._indexInCompound=-1;
  1298. /**@private */
  1299. this._compoundParent=null;
  1300. /**@private */
  1301. this._attatchedCollisionObject=null;
  1302. /**@private */
  1303. this._referenceCount=0;
  1304. this.needsCustomCollisionCallback=false;
  1305. this._scale=new Vector3(1,1,1);
  1306. this._centerMatrix=new Matrix4x4();
  1307. this._localOffset=new Vector3(0,0,0);
  1308. this._localRotation=new Quaternion(0,0,0,1);
  1309. }
  1310. __class(ColliderShape,'laya.d3.physics.shape.ColliderShape');
  1311. var __proto=ColliderShape.prototype;
  1312. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  1313. /**
  1314. *@private
  1315. */
  1316. __proto._setScale=function(value){
  1317. if (this._compoundParent){
  1318. this.updateLocalTransformations();
  1319. }else {
  1320. ColliderShape._nativeScale.setValue(value.x,value.y,value.z);
  1321. this._nativeShape.setLocalScaling(ColliderShape._nativeScale);
  1322. }
  1323. }
  1324. /**
  1325. *@private
  1326. */
  1327. __proto._addReference=function(){
  1328. this._referenceCount++;
  1329. }
  1330. /**
  1331. *@private
  1332. */
  1333. __proto._removeReference=function(){
  1334. this._referenceCount--;
  1335. }
  1336. /**
  1337. *更新本地偏移,如果修改LocalOffset或LocalRotation需要调用。
  1338. */
  1339. __proto.updateLocalTransformations=function(){
  1340. if (this._compoundParent){
  1341. var offset=ColliderShape._tempVector30;
  1342. Vector3.multiply(this.localOffset,this._scale,offset);
  1343. ColliderShape._createAffineTransformation(offset,this.localRotation,this._centerMatrix.elements);
  1344. }else {
  1345. ColliderShape._createAffineTransformation(this.localOffset,this.localRotation,this._centerMatrix.elements);
  1346. }
  1347. }
  1348. /**
  1349. *克隆。
  1350. *@param destObject 克隆源。
  1351. */
  1352. __proto.cloneTo=function(destObject){
  1353. var destColliderShape=destObject;
  1354. this._localOffset.cloneTo(destColliderShape.localOffset);
  1355. this._localRotation.cloneTo(destColliderShape.localRotation);
  1356. destColliderShape.localOffset=destColliderShape.localOffset;
  1357. destColliderShape.localRotation=destColliderShape.localRotation;
  1358. }
  1359. /**
  1360. *克隆。
  1361. *@return 克隆副本。
  1362. */
  1363. __proto.clone=function(){
  1364. return null;
  1365. }
  1366. /**
  1367. *@private
  1368. */
  1369. __proto.destroy=function(){
  1370. if (this._nativeShape){
  1371. Laya3D._physics3D.destroy(this._nativeShape);
  1372. this._nativeShape=null;
  1373. }
  1374. }
  1375. /**
  1376. *获取碰撞类型。
  1377. *@return 碰撞类型。
  1378. */
  1379. __getset(0,__proto,'type',function(){
  1380. return this._type;
  1381. });
  1382. /**
  1383. *设置Shape的本地偏移。
  1384. *@param Shape的本地偏移。
  1385. */
  1386. /**
  1387. *获取Shape的本地偏移。
  1388. *@return Shape的本地偏移。
  1389. */
  1390. __getset(0,__proto,'localOffset',function(){
  1391. return this._localOffset;
  1392. },function(value){
  1393. this._localOffset=value;
  1394. if (this._compoundParent)
  1395. this._compoundParent._updateChildTransform(this);
  1396. });
  1397. /**
  1398. *设置Shape的本地旋转。
  1399. *@param Shape的本地旋转。
  1400. */
  1401. /**
  1402. *获取Shape的本地旋转。
  1403. *@return Shape的本地旋转。
  1404. */
  1405. __getset(0,__proto,'localRotation',function(){
  1406. return this._localRotation;
  1407. },function(value){
  1408. this._localRotation=value;
  1409. if (this._compoundParent)
  1410. this._compoundParent._updateChildTransform(this);
  1411. });
  1412. ColliderShape._creatShape=function(shapeData){
  1413. var colliderShape;
  1414. switch (shapeData.type){
  1415. case "BoxColliderShape":;
  1416. var sizeData=shapeData.size;
  1417. colliderShape=sizeData ? new BoxColliderShape(sizeData[0],sizeData[1],sizeData[2]):new BoxColliderShape();
  1418. break ;
  1419. case "SphereColliderShape":
  1420. colliderShape=new SphereColliderShape(shapeData.radius);
  1421. break ;
  1422. case "CapsuleColliderShape":
  1423. colliderShape=new CapsuleColliderShape(shapeData.radius,shapeData.height,shapeData.orientation);
  1424. break ;
  1425. case "MeshColliderShape":;
  1426. var meshCollider=new MeshColliderShape();
  1427. shapeData.mesh && (meshCollider.mesh=Loader.getRes(shapeData.mesh));
  1428. colliderShape=meshCollider;
  1429. break ;
  1430. case "ConeColliderShape":
  1431. colliderShape=new ConeColliderShape(shapeData.radius,shapeData.height,shapeData.orientation);
  1432. break ;
  1433. case "CylinderColliderShape":
  1434. colliderShape=new CylinderColliderShape(shapeData.radius,shapeData.height,shapeData.orientation);
  1435. break ;
  1436. default :
  1437. throw "unknown shape type.";
  1438. }
  1439. if (shapeData.center){
  1440. var localOffset=colliderShape.localOffset;
  1441. localOffset.fromArray(shapeData.center);
  1442. colliderShape.localOffset=localOffset;
  1443. }
  1444. return colliderShape;
  1445. }
  1446. ColliderShape._createAffineTransformation=function(trans,rot,outE){
  1447. var x=rot.x,y=rot.y,z=rot.z,w=rot.w,x2=x+x,y2=y+y,z2=z+z;
  1448. var xx=x *x2,xy=x *y2,xz=x *z2,yy=y *y2,yz=y *z2,zz=z *z2;
  1449. var wx=w *x2,wy=w *y2,wz=w *z2;
  1450. outE[0]=(1-(yy+zz));
  1451. outE[1]=(xy+wz);
  1452. outE[2]=(xz-wy);
  1453. outE[3]=0;
  1454. outE[4]=(xy-wz);
  1455. outE[5]=(1-(xx+zz));
  1456. outE[6]=(yz+wx);
  1457. outE[7]=0;
  1458. outE[8]=(xz+wy);
  1459. outE[9]=(yz-wx);
  1460. outE[10]=(1-(xx+yy));
  1461. outE[11]=0;
  1462. outE[12]=trans.x;
  1463. outE[13]=trans.y;
  1464. outE[14]=trans.z;
  1465. outE[15]=1;
  1466. }
  1467. ColliderShape.SHAPEORIENTATION_UPX=0;
  1468. ColliderShape.SHAPEORIENTATION_UPY=1;
  1469. ColliderShape.SHAPEORIENTATION_UPZ=2;
  1470. ColliderShape.SHAPETYPES_BOX=0;
  1471. ColliderShape.SHAPETYPES_SPHERE=1;
  1472. ColliderShape.SHAPETYPES_CYLINDER=2;
  1473. ColliderShape.SHAPETYPES_CAPSULE=3;
  1474. ColliderShape.SHAPETYPES_CONVEXHULL=4;
  1475. ColliderShape.SHAPETYPES_COMPOUND=5;
  1476. ColliderShape.SHAPETYPES_STATICPLANE=6;
  1477. ColliderShape.SHAPETYPES_CONE=7;
  1478. __static(ColliderShape,
  1479. ['_tempVector30',function(){return this._tempVector30=new Vector3();},'_nativeScale',function(){return this._nativeScale=new Laya3D._physics3D.btVector3(1,1,1);},'_nativeVector30',function(){return this._nativeVector30=new Laya3D._physics3D.btVector3(0,0,0);},'_nativQuaternion0',function(){return this._nativQuaternion0=new Laya3D._physics3D.btQuaternion(0,0,0,1);},'_nativeTransform0',function(){return this._nativeTransform0=new Laya3D._physics3D.btTransform();}
  1480. ]);
  1481. return ColliderShape;
  1482. })()
  1483. /**
  1484. *<code>Laya3D</code> 类用于初始化3D设置。
  1485. */
  1486. //class Laya3D
  1487. var Laya3D=(function(){
  1488. /**
  1489. *创建一个 <code>Laya3D</code> 实例。
  1490. */
  1491. function Laya3D(){}
  1492. __class(Laya3D,'Laya3D');
  1493. /**
  1494. *获取是否可以启用物理。
  1495. *@param 是否启用物理。
  1496. */
  1497. __getset(1,Laya3D,'enbalePhysics',function(){
  1498. return Laya3D._enbalePhysics;
  1499. });
  1500. Laya3D._cancelLoadByUrl=function(url){
  1501. Laya.loader.cancelLoadByUrl(url);
  1502. Laya3D._innerFirstLevelLoaderManager.cancelLoadByUrl(url);
  1503. Laya3D._innerSecondLevelLoaderManager.cancelLoadByUrl(url);
  1504. Laya3D._innerThirdLevelLoaderManager.cancelLoadByUrl(url);
  1505. Laya3D._innerFourthLevelLoaderManager.cancelLoadByUrl(url);
  1506. }
  1507. Laya3D._changeWebGLSize=function(width,height){
  1508. WebGL.onStageResize(width,height);
  1509. RenderContext3D.clientWidth=width;
  1510. RenderContext3D.clientHeight=height;
  1511. }
  1512. Laya3D.__init__=function(width,height,config){
  1513. Config.isAntialias=config.isAntialias;
  1514. Config.isAlpha=config.isAlpha;
  1515. Config.premultipliedAlpha=config.premultipliedAlpha;
  1516. Config.isStencil=config.isStencil;
  1517. if (!WebGL.enable()){
  1518. alert("Laya3D init error,must support webGL!");
  1519. return;
  1520. }
  1521. RunDriver.changeWebGLSize=Laya3D._changeWebGLSize;
  1522. Render.is3DMode=true;
  1523. Laya.init(width,height);
  1524. if (!Render.supportWebGLPlusRendering){
  1525. LayaGL.instance=WebGL.mainContext;
  1526. LayaGL.instance.createCommandEncoder=function (reserveSize,adjustSize,isSyncToRenderThread){
  1527. (reserveSize===void 0)&& (reserveSize=128);
  1528. (adjustSize===void 0)&& (adjustSize=64);
  1529. (isSyncToRenderThread===void 0)&& (isSyncToRenderThread=false);
  1530. return new CommandEncoder(this,reserveSize,adjustSize,isSyncToRenderThread);
  1531. }
  1532. }
  1533. Laya3D.enableNative3D();
  1534. Sprite3D.__init__();
  1535. RenderableSprite3D.__init__();
  1536. MeshSprite3D.__init__();
  1537. SkinnedMeshSprite3D.__init__();
  1538. ShuriKenParticle3D.__init__();
  1539. BaseMaterial.__init__();
  1540. BlinnPhongMaterial.__init__();
  1541. PBRStandardMaterial.__init__();
  1542. PBRSpecularMaterial.__init__();
  1543. SkyProceduralMaterial.__init__();
  1544. UnlitMaterial.__init__();
  1545. TrailSprite3D.__init__();
  1546. TrailMaterial.__init__();
  1547. EffectMaterial.__init__();
  1548. WaterPrimaryMaterial.__init__();
  1549. ShurikenParticleMaterial.__init__();
  1550. TerrainMaterial.__init__();
  1551. ExtendTerrainMaterial.__init__();
  1552. ShaderInit3D.__init__();
  1553. PixelLineMaterial.defaultMaterial.lock=true;
  1554. BlinnPhongMaterial.defaultMaterial.lock=true;
  1555. EffectMaterial.defaultMaterial.lock=true;
  1556. PBRStandardMaterial.defaultMaterial.lock=true;
  1557. PBRSpecularMaterial.defaultMaterial.lock=true;
  1558. UnlitMaterial.defaultMaterial.lock=true;
  1559. ShurikenParticleMaterial.defaultMaterial.lock=true;
  1560. TrailMaterial.defaultMaterial.lock=true;
  1561. SkyProceduralMaterial.defaultMaterial.lock=true;
  1562. SkyBoxMaterial.defaultMaterial.lock=true;
  1563. WaterPrimaryMaterial.defaultMaterial.lock=true;
  1564. Texture2D.__init__();
  1565. TextureCube.__init__();
  1566. SkyBox.__init__();
  1567. SkyDome.__init__();
  1568. ScreenQuad.__init__();
  1569. PostProcess.__init__();
  1570. FrustumCulling.__init__();
  1571. HalfFloatUtils.__init__();
  1572. var createMap=LoaderManager.createMap;
  1573. createMap["lh"]=[ /*CLASS CONST:Laya3D.HIERARCHY*/"HIERARCHY",Sprite3D._parse];
  1574. createMap["ls"]=[ /*CLASS CONST:Laya3D.HIERARCHY*/"HIERARCHY",Scene3D._parse];
  1575. createMap["lm"]=[ /*CLASS CONST:Laya3D.MESH*/"MESH",Mesh._parse];
  1576. createMap["lmat"]=[ /*CLASS CONST:Laya3D.MATERIAL*/"MATERIAL",BaseMaterial._parse];
  1577. createMap["ltc"]=[ /*CLASS CONST:Laya3D.TEXTURECUBE*/"TEXTURECUBE",TextureCube._parse];
  1578. createMap["jpg"]=[ /*CLASS CONST:Laya3D.TEXTURE2D*/"TEXTURE2D",Texture2D._parse];
  1579. createMap["jpeg"]=[ /*CLASS CONST:Laya3D.TEXTURE2D*/"TEXTURE2D",Texture2D._parse];
  1580. createMap["bmp"]=[ /*CLASS CONST:Laya3D.TEXTURE2D*/"TEXTURE2D",Texture2D._parse];
  1581. createMap["gif"]=[ /*CLASS CONST:Laya3D.TEXTURE2D*/"TEXTURE2D",Texture2D._parse];
  1582. createMap["png"]=[ /*CLASS CONST:Laya3D.TEXTURE2D*/"TEXTURE2D",Texture2D._parse];
  1583. createMap["dds"]=[ /*CLASS CONST:Laya3D.TEXTURE2D*/"TEXTURE2D",Texture2D._parse];
  1584. createMap["ktx"]=[ /*CLASS CONST:Laya3D.TEXTURE2D*/"TEXTURE2D",Texture2D._parse];
  1585. createMap["pvr"]=[ /*CLASS CONST:Laya3D.TEXTURE2D*/"TEXTURE2D",Texture2D._parse];
  1586. createMap["lani"]=[ /*CLASS CONST:Laya3D.ANIMATIONCLIP*/"ANIMATIONCLIP",AnimationClip._parse];
  1587. createMap["lav"]=[ /*CLASS CONST:Laya3D.AVATAR*/"AVATAR",Avatar._parse];
  1588. createMap["thdata"]=[ /*CLASS CONST:Laya3D.TERRAINHEIGHTDATA*/"TERRAINHEIGHTDATA",TerrainHeightData._pharse];
  1589. var parserMap=Loader.parserMap;
  1590. parserMap[ /*CLASS CONST:Laya3D.HIERARCHY*/"HIERARCHY"]=Laya3D._loadHierarchy;
  1591. parserMap[ /*CLASS CONST:Laya3D.MESH*/"MESH"]=Laya3D._loadMesh;
  1592. parserMap[ /*CLASS CONST:Laya3D.MATERIAL*/"MATERIAL"]=Laya3D._loadMaterial;
  1593. parserMap[ /*CLASS CONST:Laya3D.TEXTURECUBE*/"TEXTURECUBE"]=Laya3D._loadTextureCube;
  1594. parserMap[ /*CLASS CONST:Laya3D.TEXTURE2D*/"TEXTURE2D"]=Laya3D._loadTexture2D;
  1595. parserMap[ /*CLASS CONST:Laya3D.ANIMATIONCLIP*/"ANIMATIONCLIP"]=Laya3D._loadAnimationClip;
  1596. parserMap[ /*CLASS CONST:Laya3D.AVATAR*/"AVATAR"]=Laya3D._loadAvatar;
  1597. Laya3D._innerFirstLevelLoaderManager.on(/*laya.events.Event.ERROR*/"error",null,Laya3D._eventLoadManagerError);
  1598. Laya3D._innerSecondLevelLoaderManager.on(/*laya.events.Event.ERROR*/"error",null,Laya3D._eventLoadManagerError);
  1599. Laya3D._innerThirdLevelLoaderManager.on(/*laya.events.Event.ERROR*/"error",null,Laya3D._eventLoadManagerError);
  1600. Laya3D._innerFourthLevelLoaderManager.on(/*laya.events.Event.ERROR*/"error",null,Laya3D._eventLoadManagerError);
  1601. }
  1602. Laya3D.enableNative3D=function(){
  1603. if (Render.isConchApp){
  1604. /*__JS__ */LayaGL=window.LayaGLContext;
  1605. var shaderData=ShaderData;
  1606. var shader3D=ShaderInstance;
  1607. var skinnedMeshRender=SkinnedMeshRenderer;
  1608. var avatar=Avatar;
  1609. var frustumCulling=FrustumCulling;
  1610. var meshRender=MeshRenderer;
  1611. if (Render.supportWebGLPlusRendering){
  1612. shaderData.prototype._initData=shaderData.prototype._initDataForNative;
  1613. shaderData.prototype.setBool=shaderData.prototype.setBoolForNative;
  1614. shaderData.prototype.getBool=shaderData.prototype.getBoolForNative;
  1615. shaderData.prototype.setInt=shaderData.prototype.setIntForNative;
  1616. shaderData.prototype.getInt=shaderData.prototype.getIntForNative;
  1617. shaderData.prototype.setNumber=shaderData.prototype.setNumberForNative;
  1618. shaderData.prototype.getNumber=shaderData.prototype.getNumberForNative;
  1619. shaderData.prototype.setVector=shaderData.prototype.setVectorForNative;
  1620. shaderData.prototype.getVector=shaderData.prototype.getVectorForNative;
  1621. shaderData.prototype.setVector2=shaderData.prototype.setVector2ForNative;
  1622. shaderData.prototype.getVector2=shaderData.prototype.getVector2ForNative;
  1623. shaderData.prototype.setVector3=shaderData.prototype.setVector3ForNative;
  1624. shaderData.prototype.getVector3=shaderData.prototype.getVector3ForNative;
  1625. shaderData.prototype.setQuaternion=shaderData.prototype.setQuaternionForNative;
  1626. shaderData.prototype.getQuaternion=shaderData.prototype.getQuaternionForNative;
  1627. shaderData.prototype.setMatrix4x4=shaderData.prototype.setMatrix4x4ForNative;
  1628. shaderData.prototype.getMatrix4x4=shaderData.prototype.getMatrix4x4ForNative;
  1629. shaderData.prototype.setBuffer=shaderData.prototype.setBufferForNative;
  1630. shaderData.prototype.getBuffer=shaderData.prototype.getBufferForNative;
  1631. shaderData.prototype.setTexture=shaderData.prototype.setTextureForNative;
  1632. shaderData.prototype.getTexture=shaderData.prototype.getTextureForNative;
  1633. shaderData.prototype.setAttribute=shaderData.prototype.setAttributeForNative;
  1634. shaderData.prototype.getAttribute=shaderData.prototype.getAttributeForNative;
  1635. shaderData.prototype.cloneTo=shaderData.prototype.cloneToForNative;
  1636. shaderData.prototype.getData=shaderData.prototype.getDataForNative;
  1637. shader3D.prototype._uniformMatrix2fv=shader3D.prototype._uniformMatrix2fvForNative;
  1638. shader3D.prototype._uniformMatrix3fv=shader3D.prototype._uniformMatrix3fvForNative;
  1639. shader3D.prototype._uniformMatrix4fv=shader3D.prototype._uniformMatrix4fvForNative;
  1640. meshRender.prototype._renderUpdateWithCamera=meshRender.prototype._renderUpdateWithCameraForNative;
  1641. }
  1642. if (Render.supportWebGLPlusCulling){
  1643. frustumCulling.renderObjectCulling=FrustumCulling.renderObjectCullingNative;
  1644. }
  1645. if (Render.supportWebGLPlusAnimation){
  1646. avatar.prototype._cloneDatasToAnimator=avatar.prototype._cloneDatasToAnimatorNative;
  1647. /*__JS__ */FloatKeyframe=window.conchFloatKeyframe;
  1648. /*__JS__ */Vector3Keyframe=window.conchFloatArrayKeyframe;
  1649. /*__JS__ */QuaternionKeyframe=window.conchFloatArrayKeyframe;
  1650. /*__JS__ */KeyframeNode=window.conchKeyframeNode;
  1651. /*__JS__ */KeyframeNodeList=window.conchKeyframeNodeList;
  1652. var animationClip=AnimationClip;
  1653. animationClip.prototype._evaluateClipDatasRealTime=animationClip.prototype._evaluateClipDatasRealTimeForNative;
  1654. }
  1655. }
  1656. WebGL.shaderHighPrecision=false;
  1657. var precisionFormat=LayaGL.instance.getShaderPrecisionFormat(/*laya.webgl.WebGLContext.FRAGMENT_SHADER*/0x8B30,/*laya.webgl.WebGLContext.HIGH_FLOAT*/0x8DF2);
  1658. precisionFormat.precision ? WebGL.shaderHighPrecision=true :WebGL.shaderHighPrecision=false;
  1659. }
  1660. Laya3D.formatRelativePath=function(base,value){
  1661. var path;
  1662. path=base+value;
  1663. var char1=value.charAt(0);
  1664. if (char1==="."){
  1665. var parts=path.split("/");
  1666. for (var i=0,len=parts.length;i < len;i++){
  1667. if (parts[i]=='..'){
  1668. var index=i-1;
  1669. if (index > 0 && parts[index]!=='..'){
  1670. parts.splice(index,2);
  1671. i-=2;
  1672. }
  1673. }
  1674. }
  1675. path=parts.join('/');
  1676. }
  1677. return path;
  1678. }
  1679. Laya3D._endLoad=function(loader,content,subResous){
  1680. if (subResous){
  1681. for (var i=0,n=subResous.length;i < n;i++){
  1682. var resou=Loader.getRes(subResous[i]);
  1683. (resou)&& (resou._removeReference());
  1684. }
  1685. }
  1686. loader.endLoad(content);
  1687. }
  1688. Laya3D._eventLoadManagerError=function(msg){
  1689. Laya.loader.event(/*laya.events.Event.ERROR*/"error",msg);
  1690. }
  1691. Laya3D._addHierarchyInnerUrls=function(urls,urlMap,urlVersion,hierarchyBasePath,path,type,constructParams,propertyParams){
  1692. var formatUrl=Laya3D.formatRelativePath(hierarchyBasePath,path);
  1693. (urlVersion)&& (formatUrl=formatUrl+urlVersion);
  1694. urls.push({url:formatUrl,type:type,constructParams:constructParams,propertyParams:propertyParams});
  1695. urlMap.push(formatUrl);
  1696. return formatUrl;
  1697. }
  1698. Laya3D._getSprite3DHierarchyInnerUrls=function(node,firstLevelUrls,secondLevelUrls,thirdLevelUrls,fourthLelUrls,subUrls,urlVersion,hierarchyBasePath){
  1699. var i=0,n=0;
  1700. var props=node.props;
  1701. switch (node.type){
  1702. case "Scene3D":;
  1703. var lightmaps=props.lightmaps;
  1704. for (i=0,n=lightmaps.length;i < n;i++){
  1705. var lightMap=lightmaps[i];
  1706. lightMap.path=Laya3D._addHierarchyInnerUrls(fourthLelUrls,subUrls,urlVersion,hierarchyBasePath,lightMap.path,/*CLASS CONST:Laya3D.TEXTURE2D*/"TEXTURE2D",lightMap.constructParams,lightMap.propertyParams);
  1707. };
  1708. var reflectionTextureData=props.reflectionTexture;
  1709. (reflectionTextureData)&& (props.reflectionTexture=Laya3D._addHierarchyInnerUrls(thirdLevelUrls,subUrls,urlVersion,hierarchyBasePath,reflectionTextureData,/*CLASS CONST:Laya3D.TEXTURECUBE*/"TEXTURECUBE"));
  1710. if (props.sky){
  1711. var skyboxMaterial=props.sky.material;
  1712. (skyboxMaterial)&& (skyboxMaterial.path=Laya3D._addHierarchyInnerUrls(secondLevelUrls,subUrls,urlVersion,hierarchyBasePath,skyboxMaterial.path,/*CLASS CONST:Laya3D.MATERIAL*/"MATERIAL"));
  1713. }
  1714. break ;
  1715. case "Camera":;
  1716. var skyboxMatData=props.skyboxMaterial;
  1717. (skyboxMatData)&& (skyboxMatData.path=Laya3D._addHierarchyInnerUrls(secondLevelUrls,subUrls,urlVersion,hierarchyBasePath,skyboxMatData.path,/*CLASS CONST:Laya3D.MATERIAL*/"MATERIAL"));
  1718. break ;
  1719. case "TrailSprite3D":
  1720. case "MeshSprite3D":
  1721. case "SkinnedMeshSprite3D":;
  1722. var meshPath=props.meshPath;
  1723. (meshPath)&& (props.meshPath=Laya3D._addHierarchyInnerUrls(firstLevelUrls,subUrls,urlVersion,hierarchyBasePath,meshPath,/*CLASS CONST:Laya3D.MESH*/"MESH"));
  1724. var materials=props.materials;
  1725. if (materials)
  1726. for (i=0,n=materials.length;i < n;i++)
  1727. materials[i].path=Laya3D._addHierarchyInnerUrls(secondLevelUrls,subUrls,urlVersion,hierarchyBasePath,materials[i].path,/*CLASS CONST:Laya3D.MATERIAL*/"MATERIAL");
  1728. break ;
  1729. case "ShuriKenParticle3D":;
  1730. var parMeshPath=props.meshPath;
  1731. (parMeshPath)&& (props.meshPath=Laya3D._addHierarchyInnerUrls(firstLevelUrls,subUrls,urlVersion,hierarchyBasePath,parMeshPath,/*CLASS CONST:Laya3D.MESH*/"MESH"));
  1732. props.material.path=Laya3D._addHierarchyInnerUrls(secondLevelUrls,subUrls,urlVersion,hierarchyBasePath,props.material.path,/*CLASS CONST:Laya3D.MATERIAL*/"MATERIAL");
  1733. break ;
  1734. case "Terrain":
  1735. Laya3D._addHierarchyInnerUrls(fourthLelUrls,subUrls,urlVersion,hierarchyBasePath,props.dataPath,"TERRAIN");
  1736. break ;
  1737. };
  1738. var components=node.components;
  1739. if (components){
  1740. for (var k=0,p=components.length;k < p;k++){
  1741. var component=components[k];
  1742. switch (component.type){
  1743. case "Animator":;
  1744. var avatarPath=component.avatarPath;
  1745. var avatarData=component.avatar;
  1746. (avatarData)&& (avatarData.path=Laya3D._addHierarchyInnerUrls(fourthLelUrls,subUrls,urlVersion,hierarchyBasePath,avatarData.path,"AVATAR"));
  1747. var clipPaths=component.clipPaths;
  1748. if (!clipPaths){
  1749. var layersData=component.layers;
  1750. for (i=0;i < layersData.length;i++){
  1751. var states=layersData[i].states;
  1752. for (var j=0,m=states.length;j < m;j++){
  1753. var clipPath=states[j].clipPath;
  1754. (clipPath)&& (states[j].clipPath=Laya3D._addHierarchyInnerUrls(fourthLelUrls,subUrls,urlVersion,hierarchyBasePath,clipPath,"ANIMATIONCLIP"));
  1755. }
  1756. }
  1757. }else {
  1758. for (i=0,n=clipPaths.length;i < n;i++)
  1759. clipPaths[i]=Laya3D._addHierarchyInnerUrls(fourthLelUrls,subUrls,urlVersion,hierarchyBasePath,clipPaths[i],"ANIMATIONCLIP");
  1760. }
  1761. break ;
  1762. case "PhysicsCollider":
  1763. case "Rigidbody3D":
  1764. case "CharacterController":;
  1765. var shapes=component.shapes;
  1766. for (i=0;i < shapes.length;i++){
  1767. var shape=shapes[i];
  1768. if (shape.type==="MeshColliderShape"){
  1769. var mesh=shape.mesh;
  1770. (mesh)&& (shape.mesh=Laya3D._addHierarchyInnerUrls(firstLevelUrls,subUrls,urlVersion,hierarchyBasePath,mesh,/*CLASS CONST:Laya3D.MESH*/"MESH"));
  1771. }
  1772. }
  1773. break ;
  1774. }
  1775. }
  1776. };
  1777. var children=node.child;
  1778. for (i=0,n=children.length;i < n;i++)
  1779. Laya3D._getSprite3DHierarchyInnerUrls(children[i],firstLevelUrls,secondLevelUrls,thirdLevelUrls,fourthLelUrls,subUrls,urlVersion,hierarchyBasePath);
  1780. }
  1781. Laya3D._loadHierarchy=function(loader){
  1782. loader.on(/*laya.events.Event.LOADED*/"loaded",null,Laya3D._onHierarchylhLoaded,[loader]);
  1783. loader.load(loader.url,/*laya.net.Loader.JSON*/"json",false,null,true);
  1784. }
  1785. Laya3D._onHierarchylhLoaded=function(loader,lhData){
  1786. var url=loader.url;
  1787. var urlVersion=Utils3D.getURLVerion(url);
  1788. var hierarchyBasePath=URL.getPath(url);
  1789. var firstLevUrls=[];
  1790. var secondLevUrls=[];
  1791. var thirdLevUrls=[];
  1792. var forthLevUrls=[];
  1793. var subUrls=[];
  1794. Laya3D._getSprite3DHierarchyInnerUrls(lhData.data,firstLevUrls,secondLevUrls,thirdLevUrls,forthLevUrls,subUrls,urlVersion,hierarchyBasePath);
  1795. var urlCount=firstLevUrls.length+secondLevUrls.length+forthLevUrls.length;
  1796. var totalProcessCount=urlCount+1;
  1797. var weight=1 / totalProcessCount;
  1798. Laya3D._onProcessChange(loader,0,weight,1.0);
  1799. if (forthLevUrls.length > 0){
  1800. var processCeil=urlCount / totalProcessCount;
  1801. var processHandler=Handler.create(null,Laya3D._onProcessChange,[loader,weight,processCeil],false);
  1802. Laya3D._innerFourthLevelLoaderManager._create(forthLevUrls,false,Handler.create(null,Laya3D._onHierarchyInnerForthLevResouLoaded,[loader,processHandler,lhData,subUrls,firstLevUrls,secondLevUrls,thirdLevUrls,weight+processCeil *forthLevUrls.length,processCeil]),processHandler,null,null,null,1,true);
  1803. }else {
  1804. Laya3D._onHierarchyInnerForthLevResouLoaded(loader,null,lhData,subUrls,firstLevUrls,secondLevUrls,thirdLevUrls,weight,processCeil);
  1805. }
  1806. }
  1807. Laya3D._onHierarchyInnerForthLevResouLoaded=function(loader,processHandler,lhData,subUrls,firstLevUrls,secondLevUrls,thirdLevUrls,processOffset,processCeil){
  1808. (processHandler)&& (processHandler.recover());
  1809. if (thirdLevUrls.length > 0){
  1810. var process=Handler.create(null,Laya3D._onProcessChange,[loader,processOffset,processCeil],false);
  1811. Laya3D._innerThirdLevelLoaderManager._create(thirdLevUrls,false,Handler.create(null,Laya3D._onHierarchyInnerThirdLevResouLoaded,[loader,process,lhData,subUrls,firstLevUrls,secondLevUrls,processOffset+processCeil *secondLevUrls.length,processCeil]),processHandler,null,null,null,1,true);
  1812. }else {
  1813. Laya3D._onHierarchyInnerThirdLevResouLoaded(loader,null,lhData,subUrls,firstLevUrls,secondLevUrls,processOffset,processCeil);
  1814. }
  1815. }
  1816. Laya3D._onHierarchyInnerThirdLevResouLoaded=function(loader,processHandler,lhData,subUrls,firstLevUrls,secondLevUrls,processOffset,processCeil){
  1817. (processHandler)&& (processHandler.recover());
  1818. if (secondLevUrls.length > 0){
  1819. var process=Handler.create(null,Laya3D._onProcessChange,[loader,processOffset,processCeil],false);
  1820. Laya3D._innerSecondLevelLoaderManager._create(secondLevUrls,false,Handler.create(null,Laya3D._onHierarchyInnerSecondLevResouLoaded,[loader,process,lhData,subUrls,firstLevUrls,processOffset+processCeil *secondLevUrls.length,processCeil]),processHandler,null,null,null,1,true);
  1821. }else {
  1822. Laya3D._onHierarchyInnerSecondLevResouLoaded(loader,null,lhData,subUrls,firstLevUrls,processOffset,processCeil);
  1823. }
  1824. }
  1825. Laya3D._onHierarchyInnerSecondLevResouLoaded=function(loader,processHandler,lhData,subUrls,firstLevUrls,processOffset,processCeil){
  1826. (processHandler)&& (processHandler.recover());
  1827. if (firstLevUrls.length > 0){
  1828. var process=Handler.create(null,Laya3D._onProcessChange,[loader,processOffset,processCeil],false);
  1829. Laya3D._innerFirstLevelLoaderManager._create(firstLevUrls,false,Handler.create(null,Laya3D._onHierarchyInnerFirstLevResouLoaded,[loader,process,lhData,subUrls]),processHandler,null,null,null,1,true);
  1830. }else {
  1831. Laya3D._onHierarchyInnerFirstLevResouLoaded(loader,null,lhData,subUrls);
  1832. }
  1833. }
  1834. Laya3D._onHierarchyInnerFirstLevResouLoaded=function(loader,processHandler,lhData,subUrls){
  1835. (processHandler)&& (processHandler.recover());
  1836. loader._cache=loader._createCache;
  1837. var item=lhData.data.type==="Scene3D" ? Scene3D._parse(lhData,loader._propertyParams,loader._constructParams):Sprite3D._parse(lhData,loader._propertyParams,loader._constructParams);
  1838. Laya3D._endLoad(loader,item,subUrls);
  1839. }
  1840. Laya3D._loadMesh=function(loader){
  1841. loader.on(/*laya.events.Event.LOADED*/"loaded",null,Laya3D._onMeshLmLoaded,[loader]);
  1842. loader.load(loader.url,/*laya.net.Loader.BUFFER*/"arraybuffer",false,null,true);
  1843. }
  1844. Laya3D._onMeshLmLoaded=function(loader,lmData){
  1845. loader._cache=loader._createCache;
  1846. var mesh=Mesh._parse(lmData,loader._propertyParams,loader._constructParams);
  1847. Laya3D._endLoad(loader,mesh);
  1848. }
  1849. Laya3D._loadMaterial=function(loader){
  1850. loader.on(/*laya.events.Event.LOADED*/"loaded",null,Laya3D._onMaterilLmatLoaded,[loader]);
  1851. loader.load(loader.url,/*laya.net.Loader.JSON*/"json",false,null,true);
  1852. }
  1853. Laya3D._onMaterilLmatLoaded=function(loader,lmatData){
  1854. var url=loader.url;
  1855. var urlVersion=Utils3D.getURLVerion(url);
  1856. var materialBasePath=URL.getPath(url);
  1857. var urls=[];
  1858. var subUrls=[];
  1859. var customProps=lmatData.customProps;
  1860. var formatSubUrl;
  1861. var version=lmatData.version;
  1862. switch (version){
  1863. case "LAYAMATERIAL:01":
  1864. case "LAYAMATERIAL:02":;
  1865. var i=0,n=0;
  1866. var textures=lmatData.props.textures;
  1867. if (textures){
  1868. for (i=0,n=textures.length;i < n;i++){
  1869. var tex2D=textures[i];
  1870. var tex2DPath=tex2D.path;
  1871. if (tex2DPath){
  1872. formatSubUrl=Laya3D.formatRelativePath(materialBasePath,tex2DPath);
  1873. (urlVersion)&& (formatSubUrl=formatSubUrl+urlVersion);
  1874. urls.push({url:formatSubUrl,constructParams:tex2D.constructParams,propertyParams:tex2D.propertyParams});
  1875. subUrls.push(formatSubUrl);
  1876. tex2D.path=formatSubUrl;
  1877. }
  1878. }
  1879. }
  1880. break ;
  1881. default :
  1882. throw new Error("Laya3D:unkonwn version.");
  1883. };
  1884. var urlCount=urls.length;
  1885. var totalProcessCount=urlCount+1;
  1886. var lmatWeight=1 / totalProcessCount;
  1887. Laya3D._onProcessChange(loader,0,lmatWeight,1.0);
  1888. if (urlCount > 0){
  1889. var processHandler=Handler.create(null,Laya3D._onProcessChange,[loader,lmatWeight,urlCount / totalProcessCount],false);
  1890. Laya3D._innerFourthLevelLoaderManager._create(urls,false,Handler.create(null,Laya3D._onMateialTexturesLoaded,[loader,processHandler,lmatData,subUrls]),processHandler,null,null,null,1,true);
  1891. }else {
  1892. Laya3D._onMateialTexturesLoaded(loader,null,lmatData,null);
  1893. }
  1894. }
  1895. Laya3D._onMateialTexturesLoaded=function(loader,processHandler,lmatData,subUrls){
  1896. loader._cache=loader._createCache;
  1897. var mat=BaseMaterial._parse(lmatData,loader._propertyParams,loader._constructParams);
  1898. Laya3D._endLoad(loader,mat,subUrls);
  1899. (processHandler)&& (processHandler.recover());
  1900. }
  1901. Laya3D._loadAvatar=function(loader){
  1902. loader.on(/*laya.events.Event.LOADED*/"loaded",null,function(data){
  1903. loader._cache=loader._createCache;
  1904. var avatar=Avatar._parse(data,loader._propertyParams,loader._constructParams);
  1905. Laya3D._endLoad(loader,avatar);
  1906. });
  1907. loader.load(loader.url,/*laya.net.Loader.JSON*/"json",false,null,true);
  1908. }
  1909. Laya3D._loadAnimationClip=function(loader){
  1910. loader.on(/*laya.events.Event.LOADED*/"loaded",null,function(data){
  1911. loader._cache=loader._createCache;
  1912. var clip=AnimationClip._parse(data,loader._propertyParams,loader._constructParams);
  1913. Laya3D._endLoad(loader,clip);
  1914. });
  1915. loader.load(loader.url,/*laya.net.Loader.BUFFER*/"arraybuffer",false,null,true);
  1916. }
  1917. Laya3D._loadTexture2D=function(loader){
  1918. var url=loader.url;
  1919. var index=url.lastIndexOf('.')+1;
  1920. var verIndex=url.indexOf('?');
  1921. var endIndex=verIndex==-1 ? url.length :verIndex;
  1922. var ext=url.substr(index,endIndex-index);
  1923. var type;
  1924. switch (ext){
  1925. case "jpg":
  1926. case "jpeg":
  1927. case "bmp":
  1928. case "gif":
  1929. case "png":
  1930. type="nativeimage";
  1931. break ;
  1932. case "dds":
  1933. case "ktx":
  1934. case "pvr":
  1935. type=/*laya.net.Loader.BUFFER*/"arraybuffer";
  1936. break ;
  1937. }
  1938. loader.on(/*laya.events.Event.LOADED*/"loaded",null,function(image){
  1939. loader._cache=loader._createCache;
  1940. var tex=Texture2D._parse(image,loader._propertyParams,loader._constructParams);
  1941. Laya3D._endLoad(loader,tex);
  1942. });
  1943. loader.load(loader.url,type,false,null,true);
  1944. }
  1945. Laya3D._loadTextureCube=function(loader){
  1946. loader.on(/*laya.events.Event.LOADED*/"loaded",null,Laya3D._onTextureCubeLtcLoaded,[loader]);
  1947. loader.load(loader.url,/*laya.net.Loader.JSON*/"json",false,null,true);
  1948. }
  1949. Laya3D._onTextureCubeLtcLoaded=function(loader,ltcData){
  1950. var ltcBasePath=URL.getPath(loader.url);
  1951. var urls=[Laya3D.formatRelativePath(ltcBasePath,ltcData.front),Laya3D.formatRelativePath(ltcBasePath,ltcData.back),Laya3D.formatRelativePath(ltcBasePath,ltcData.left),Laya3D.formatRelativePath(ltcBasePath,ltcData.right),Laya3D.formatRelativePath(ltcBasePath,ltcData.up),Laya3D.formatRelativePath(ltcBasePath,ltcData.down)];
  1952. var ltcWeight=1.0 / 7.0;
  1953. Laya3D._onProcessChange(loader,0,ltcWeight,1.0);
  1954. var processHandler=Handler.create(null,Laya3D._onProcessChange,[loader,ltcWeight,6 / 7],false);
  1955. Laya3D._innerFourthLevelLoaderManager.load(urls,Handler.create(null,Laya3D._onTextureCubeImagesLoaded,[loader,urls,processHandler]),processHandler,"nativeimage");
  1956. }
  1957. Laya3D._onTextureCubeImagesLoaded=function(loader,urls,processHandler){
  1958. var images=new Array(6);
  1959. for (var i=0;i < 6;i++)
  1960. images[i]=Loader.getRes(urls[i]);
  1961. loader._cache=loader._createCache;
  1962. var tex=TextureCube._parse(images,loader._propertyParams,loader._constructParams);
  1963. processHandler.recover();
  1964. for (i=0;i < 6;i++)
  1965. Loader.clearRes(urls[i]);
  1966. Laya3D._endLoad(loader,tex);
  1967. }
  1968. Laya3D._onProcessChange=function(loader,offset,weight,process){
  1969. process=offset+process *weight;
  1970. (process < 1.0)&& (loader.event(/*laya.events.Event.PROGRESS*/"progress",process));
  1971. }
  1972. Laya3D.init=function(width,height,config,compolete){
  1973. if (Laya3D._isInit)
  1974. return;
  1975. Laya3D._isInit=true;
  1976. config=config || Config3D._default;
  1977. config.cloneTo(Laya3D._config);
  1978. Laya3D._editerEnvironment=Laya3D._config._editerEnvironment;
  1979. var physics3D=window.Physics3D;
  1980. if (physics3D==null){
  1981. Laya3D._enbalePhysics=false;
  1982. Laya3D.__init__(width,height,Laya3D._config);
  1983. compolete && compolete.run();
  1984. }else {
  1985. Laya3D._enbalePhysics=true;
  1986. physics3D(Laya3D._config.defaultPhysicsMemory *1024 *1024).then(function(){
  1987. Laya3D.__init__(width,height,Laya3D._config);
  1988. compolete && compolete.run();
  1989. });
  1990. }
  1991. }
  1992. Laya3D.HIERARCHY="HIERARCHY";
  1993. Laya3D.MESH="MESH";
  1994. Laya3D.MATERIAL="MATERIAL";
  1995. Laya3D.TEXTURE2D="TEXTURE2D";
  1996. Laya3D.TEXTURECUBE="TEXTURECUBE";
  1997. Laya3D.ANIMATIONCLIP="ANIMATIONCLIP";
  1998. Laya3D.AVATAR="AVATAR";
  1999. Laya3D.TERRAINHEIGHTDATA="TERRAINHEIGHTDATA";
  2000. Laya3D.TERRAINRES="TERRAIN";
  2001. Laya3D._isInit=false;
  2002. Laya3D._enbalePhysics=false;
  2003. Laya3D._editerEnvironment=false;
  2004. __static(Laya3D,
  2005. ['_innerFirstLevelLoaderManager',function(){return this._innerFirstLevelLoaderManager=new LoaderManager();},'_innerSecondLevelLoaderManager',function(){return this._innerSecondLevelLoaderManager=new LoaderManager();},'_innerThirdLevelLoaderManager',function(){return this._innerThirdLevelLoaderManager=new LoaderManager();},'_innerFourthLevelLoaderManager',function(){return this._innerFourthLevelLoaderManager=new LoaderManager();},'_physics3D',function(){return this._physics3D=window.Physics3D;},'_config',function(){return this._config=new Config3D();},'physicsSettings',function(){return this.physicsSettings=new PhysicsSettings();}
  2006. ]);
  2007. return Laya3D;
  2008. })()
  2009. /**
  2010. *<code>FrameOverTime</code> 类用于创建时间帧。
  2011. */
  2012. //class laya.d3.core.particleShuriKen.module.FrameOverTime
  2013. var FrameOverTime=(function(){
  2014. function FrameOverTime(){
  2015. /**@private */
  2016. this._type=0;
  2017. /**@private */
  2018. this._constant=0;
  2019. /**@private */
  2020. this._overTime=null;
  2021. /**@private */
  2022. this._constantMin=0;
  2023. /**@private */
  2024. this._constantMax=0;
  2025. /**@private */
  2026. this._overTimeMin=null;
  2027. /**@private */
  2028. this._overTimeMax=null;
  2029. }
  2030. __class(FrameOverTime,'laya.d3.core.particleShuriKen.module.FrameOverTime');
  2031. var __proto=FrameOverTime.prototype;
  2032. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  2033. /**
  2034. *克隆。
  2035. *@param destObject 克隆源。
  2036. */
  2037. __proto.cloneTo=function(destObject){
  2038. var destFrameOverTime=destObject;
  2039. destFrameOverTime._type=this._type;
  2040. destFrameOverTime._constant=this._constant;
  2041. this._overTime.cloneTo(destFrameOverTime._overTime);
  2042. destFrameOverTime._constantMin=this._constantMin;
  2043. destFrameOverTime._constantMax=this._constantMax;
  2044. this._overTimeMin.cloneTo(destFrameOverTime._overTimeMin);
  2045. this._overTimeMax.cloneTo(destFrameOverTime._overTimeMax);
  2046. }
  2047. /**
  2048. *克隆。
  2049. *@return 克隆副本。
  2050. */
  2051. __proto.clone=function(){
  2052. var destFrameOverTime=/*__JS__ */new this.constructor();
  2053. this.cloneTo(destFrameOverTime);
  2054. return destFrameOverTime;
  2055. }
  2056. /**
  2057. *时间帧。
  2058. */
  2059. __getset(0,__proto,'frameOverTimeData',function(){
  2060. return this._overTime;
  2061. });
  2062. /**
  2063. *固定帧。
  2064. */
  2065. __getset(0,__proto,'constant',function(){
  2066. return this._constant;
  2067. });
  2068. /**
  2069. *生命周期旋转类型,0常量模式,1曲线模式,2随机双常量模式,3随机双曲线模式。
  2070. */
  2071. __getset(0,__proto,'type',function(){
  2072. return this._type;
  2073. });
  2074. /**
  2075. *最小时间帧。
  2076. */
  2077. __getset(0,__proto,'frameOverTimeDataMin',function(){
  2078. return this._overTimeMin;
  2079. });
  2080. /**
  2081. *最小固定帧。
  2082. */
  2083. __getset(0,__proto,'constantMin',function(){
  2084. return this._constantMin;
  2085. });
  2086. /**
  2087. *最大时间帧。
  2088. */
  2089. __getset(0,__proto,'frameOverTimeDataMax',function(){
  2090. return this._overTimeMax;
  2091. });
  2092. /**
  2093. *最大固定帧。
  2094. */
  2095. __getset(0,__proto,'constantMax',function(){
  2096. return this._constantMax;
  2097. });
  2098. FrameOverTime.createByConstant=function(constant){
  2099. var rotationOverLifetime=new FrameOverTime();
  2100. rotationOverLifetime._type=0;
  2101. rotationOverLifetime._constant=constant;
  2102. return rotationOverLifetime;
  2103. }
  2104. FrameOverTime.createByOverTime=function(overTime){
  2105. var rotationOverLifetime=new FrameOverTime();
  2106. rotationOverLifetime._type=1;
  2107. rotationOverLifetime._overTime=overTime;
  2108. return rotationOverLifetime;
  2109. }
  2110. FrameOverTime.createByRandomTwoConstant=function(constantMin,constantMax){
  2111. var rotationOverLifetime=new FrameOverTime();
  2112. rotationOverLifetime._type=2;
  2113. rotationOverLifetime._constantMin=constantMin;
  2114. rotationOverLifetime._constantMax=constantMax;
  2115. return rotationOverLifetime;
  2116. }
  2117. FrameOverTime.createByRandomTwoOverTime=function(gradientFrameMin,gradientFrameMax){
  2118. var rotationOverLifetime=new FrameOverTime();
  2119. rotationOverLifetime._type=3;
  2120. rotationOverLifetime._overTimeMin=gradientFrameMin;
  2121. rotationOverLifetime._overTimeMax=gradientFrameMax;
  2122. return rotationOverLifetime;
  2123. }
  2124. return FrameOverTime;
  2125. })()
  2126. /**
  2127. *<code>RenderState</code> 类用于控制渲染状态。
  2128. */
  2129. //class laya.d3.core.material.RenderState
  2130. var RenderState=(function(){
  2131. function RenderState(){
  2132. /**渲染剔除状态。*/
  2133. this.cull=0;
  2134. /**透明混合。*/
  2135. this.blend=0;
  2136. /**源混合参数,在blend为BLEND_ENABLE_ALL时生效。*/
  2137. this.srcBlend=0;
  2138. /**目标混合参数,在blend为BLEND_ENABLE_ALL时生效。*/
  2139. this.dstBlend=0;
  2140. /**RGB源混合参数,在blend为BLEND_ENABLE_SEPERATE时生效。*/
  2141. this.srcBlendRGB=0;
  2142. /**RGB目标混合参数,在blend为BLEND_ENABLE_SEPERATE时生效。*/
  2143. this.dstBlendRGB=0;
  2144. /**Alpha源混合参数,在blend为BLEND_ENABLE_SEPERATE时生效。*/
  2145. this.srcBlendAlpha=0;
  2146. /**Alpha目标混合参数,在blend为BLEND_ENABLE_SEPERATE时生效。*/
  2147. this.dstBlendAlpha=0;
  2148. /**混合常量颜色。*/
  2149. this.blendConstColor=null;
  2150. /**混合方程。*/
  2151. this.blendEquation=0;
  2152. /**RGB混合方程。*/
  2153. this.blendEquationRGB=0;
  2154. /**Alpha混合方程。*/
  2155. this.blendEquationAlpha=0;
  2156. /**深度测试函数。*/
  2157. this.depthTest=0;
  2158. /**是否深度写入。*/
  2159. this.depthWrite=false;
  2160. this.cull=2;
  2161. this.blend=0;
  2162. this.srcBlend=1;
  2163. this.dstBlend=0;
  2164. this.srcBlendRGB=1;
  2165. this.dstBlendRGB=0;
  2166. this.srcBlendAlpha=1;
  2167. this.dstBlendAlpha=0;
  2168. this.blendConstColor=new Vector4(1,1,1,1);
  2169. this.blendEquation=0;
  2170. this.blendEquationRGB=0;
  2171. this.blendEquationAlpha=0;
  2172. this.depthTest=0x0203;
  2173. this.depthWrite=true;
  2174. }
  2175. __class(RenderState,'laya.d3.core.material.RenderState');
  2176. var __proto=RenderState.prototype;
  2177. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  2178. /**
  2179. *克隆。
  2180. *@param destObject 克隆源。
  2181. */
  2182. __proto.cloneTo=function(dest){
  2183. var destState=dest;
  2184. destState.cull=this.cull;
  2185. destState.blend=this.blend;
  2186. destState.srcBlend=this.srcBlend;
  2187. destState.dstBlend=this.dstBlend;
  2188. destState.srcBlendRGB=this.srcBlendRGB;
  2189. destState.dstBlendRGB=this.dstBlendRGB;
  2190. destState.srcBlendAlpha=this.srcBlendAlpha;
  2191. destState.dstBlendAlpha=this.dstBlendAlpha;
  2192. this.blendConstColor.cloneTo(destState.blendConstColor);
  2193. destState.blendEquation=this.blendEquation;
  2194. destState.blendEquationRGB=this.blendEquationRGB;
  2195. destState.blendEquationAlpha=this.blendEquationAlpha;
  2196. destState.depthTest=this.depthTest;
  2197. destState.depthWrite=this.depthWrite;
  2198. }
  2199. /**
  2200. *克隆。
  2201. *@return 克隆副本。
  2202. */
  2203. __proto.clone=function(){
  2204. var dest=/*__JS__ */new this.constructor();
  2205. this.cloneTo(dest);
  2206. return dest;
  2207. }
  2208. RenderState.CULL_NONE=0;
  2209. RenderState.CULL_FRONT=1;
  2210. RenderState.CULL_BACK=2;
  2211. RenderState.BLEND_DISABLE=0;
  2212. RenderState.BLEND_ENABLE_ALL=1;
  2213. RenderState.BLEND_ENABLE_SEPERATE=2;
  2214. RenderState.BLENDPARAM_ZERO=0;
  2215. RenderState.BLENDPARAM_ONE=1;
  2216. RenderState.BLENDPARAM_SRC_COLOR=0x0300;
  2217. RenderState.BLENDPARAM_ONE_MINUS_SRC_COLOR=0x0301;
  2218. RenderState.BLENDPARAM_DST_COLOR=0x0306;
  2219. RenderState.BLENDPARAM_ONE_MINUS_DST_COLOR=0x0307;
  2220. RenderState.BLENDPARAM_SRC_ALPHA=0x0302;
  2221. RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA=0x0303;
  2222. RenderState.BLENDPARAM_DST_ALPHA=0x0304;
  2223. RenderState.BLENDPARAM_ONE_MINUS_DST_ALPHA=0x0305;
  2224. RenderState.BLENDPARAM_SRC_ALPHA_SATURATE=0x0308;
  2225. RenderState.BLENDEQUATION_ADD=0;
  2226. RenderState.BLENDEQUATION_SUBTRACT=1;
  2227. RenderState.BLENDEQUATION_REVERSE_SUBTRACT=2;
  2228. RenderState.DEPTHTEST_OFF=0;
  2229. RenderState.DEPTHTEST_NEVER=0x0200;
  2230. RenderState.DEPTHTEST_LESS=0x0201;
  2231. RenderState.DEPTHTEST_EQUAL=0x0202;
  2232. RenderState.DEPTHTEST_LEQUAL=0x0203;
  2233. RenderState.DEPTHTEST_GREATER=0x0204;
  2234. RenderState.DEPTHTEST_NOTEQUAL=0x0205;
  2235. RenderState.DEPTHTEST_GEQUAL=0x0206;
  2236. RenderState.DEPTHTEST_ALWAYS=0x0207;
  2237. return RenderState;
  2238. })()
  2239. /**
  2240. *<code>Ray</code> 类用于创建射线。
  2241. */
  2242. //class laya.d3.math.Ray
  2243. var Ray=(function(){
  2244. function Ray(origin,direction){
  2245. /**原点*/
  2246. this.origin=null;
  2247. /**方向*/
  2248. this.direction=null;
  2249. this.origin=origin;
  2250. this.direction=direction;
  2251. }
  2252. __class(Ray,'laya.d3.math.Ray');
  2253. return Ray;
  2254. })()
  2255. /**
  2256. *<code>ContactPoint</code> 类用于创建物理碰撞信息。
  2257. */
  2258. //class laya.d3.physics.ContactPoint
  2259. var ContactPoint=(function(){
  2260. function ContactPoint(){
  2261. /**@private */
  2262. this._idCounter=0;
  2263. /**@private */
  2264. //this._id=0;
  2265. /**碰撞器A。*/
  2266. this.colliderA=null;
  2267. /**碰撞器B。*/
  2268. this.colliderB=null;
  2269. /**距离。*/
  2270. this.distance=0;
  2271. this.normal=new Vector3();
  2272. this.positionOnA=new Vector3();
  2273. this.positionOnB=new Vector3();
  2274. this._id=++this._idCounter;
  2275. }
  2276. __class(ContactPoint,'laya.d3.physics.ContactPoint');
  2277. return ContactPoint;
  2278. })()
  2279. /**
  2280. *<code>StaticBatchManager</code> 类用于静态批处理管理的父类。
  2281. */
  2282. //class laya.d3.graphics.StaticBatchManager
  2283. var StaticBatchManager=(function(){
  2284. function StaticBatchManager(){
  2285. /**@private */
  2286. //this._batchRenderElementPool=null;
  2287. /**@private */
  2288. //this._batchRenderElementPoolIndex=0;
  2289. /**@private */
  2290. //this._initBatchSprites=null;
  2291. /**@private */
  2292. //this._staticBatches=null;
  2293. this._initBatchSprites=[];
  2294. this._staticBatches={};
  2295. this._batchRenderElementPoolIndex=0;
  2296. this._batchRenderElementPool=[];
  2297. }
  2298. __class(StaticBatchManager,'laya.d3.graphics.StaticBatchManager');
  2299. var __proto=StaticBatchManager.prototype;
  2300. /**
  2301. *@private
  2302. */
  2303. __proto._partition=function(items,left,right){
  2304. var pivot=items[Math.floor((right+left)/ 2)];
  2305. while (left <=right){
  2306. while (this._compare(items[left],pivot)< 0)
  2307. left++;
  2308. while (this._compare(items[right],pivot)> 0)
  2309. right--;
  2310. if (left < right){
  2311. var temp=items[left];
  2312. items[left]=items[right];
  2313. items[right]=temp;
  2314. left++;
  2315. right--;
  2316. }else if (left===right){
  2317. left++;
  2318. break ;
  2319. }
  2320. }
  2321. return left;
  2322. }
  2323. /**
  2324. *@private
  2325. */
  2326. __proto._quickSort=function(items,left,right){
  2327. if (items.length > 1){
  2328. var index=this._partition(items,left,right);
  2329. var leftIndex=index-1;
  2330. if (left < leftIndex)
  2331. this._quickSort(items,left,leftIndex);
  2332. if (index < right)
  2333. this._quickSort(items,index,right);
  2334. }
  2335. }
  2336. /**
  2337. *@private
  2338. */
  2339. __proto._compare=function(left,right){
  2340. throw "StaticBatch:must override this function.";
  2341. }
  2342. /**
  2343. *@private
  2344. */
  2345. __proto._initStaticBatchs=function(rootSprite){
  2346. throw "StaticBatch:must override this function.";
  2347. }
  2348. /**
  2349. *@private
  2350. */
  2351. __proto._getBatchRenderElementFromPool=function(){
  2352. throw "StaticBatch:must override this function.";
  2353. }
  2354. /**
  2355. *@private
  2356. */
  2357. __proto._addBatchSprite=function(renderableSprite3D){
  2358. this._initBatchSprites.push(renderableSprite3D);
  2359. }
  2360. /**
  2361. *@private
  2362. */
  2363. __proto._clear=function(){
  2364. this._batchRenderElementPoolIndex=0;
  2365. }
  2366. /**
  2367. *@private
  2368. */
  2369. __proto._garbageCollection=function(){
  2370. throw "StaticBatchManager: must override it.";
  2371. }
  2372. /**
  2373. *@private
  2374. */
  2375. __proto.dispose=function(){
  2376. this._staticBatches=null;
  2377. }
  2378. StaticBatchManager._registerManager=function(manager){
  2379. StaticBatchManager._managers.push(manager);
  2380. }
  2381. StaticBatchManager._addToStaticBatchQueue=function(sprite3D,renderableSprite3D){
  2382. if ((sprite3D instanceof laya.d3.core.RenderableSprite3D )&& sprite3D.isStatic)
  2383. renderableSprite3D.push(sprite3D);
  2384. for (var i=0,n=sprite3D.numChildren;i < n;i++)
  2385. StaticBatchManager._addToStaticBatchQueue(sprite3D._children [i],renderableSprite3D);
  2386. }
  2387. StaticBatchManager.combine=function(staticBatchRoot,renderableSprite3Ds){
  2388. if (!renderableSprite3Ds){
  2389. renderableSprite3Ds=[];
  2390. if (staticBatchRoot)
  2391. StaticBatchManager._addToStaticBatchQueue(staticBatchRoot,renderableSprite3Ds);
  2392. };
  2393. var batchSpritesCount=renderableSprite3Ds.length;
  2394. if (batchSpritesCount > 0){
  2395. for (var i=0;i < batchSpritesCount;i++){
  2396. var renderableSprite3D=renderableSprite3Ds[i];
  2397. (renderableSprite3D.isStatic)&& (renderableSprite3D._addToInitStaticBatchManager());
  2398. }
  2399. for (var k=0,m=StaticBatchManager._managers.length;k < m;k++){
  2400. var manager=StaticBatchManager._managers[k];
  2401. manager._initStaticBatchs(staticBatchRoot);
  2402. }
  2403. }
  2404. }
  2405. StaticBatchManager._managers=[];
  2406. return StaticBatchManager;
  2407. })()
  2408. /**
  2409. *@private
  2410. *<code>Command</code> 类用于创建指令。
  2411. */
  2412. //class laya.d3.core.render.command.Command
  2413. var Command=(function(){
  2414. /**
  2415. *创建一个 <code>Command</code> 实例。
  2416. */
  2417. function Command(){}
  2418. __class(Command,'laya.d3.core.render.command.Command');
  2419. var __proto=Command.prototype;
  2420. /**
  2421. *@private
  2422. */
  2423. __proto.run=function(){}
  2424. /**
  2425. *@private
  2426. */
  2427. __proto.recover=function(){}
  2428. return Command;
  2429. })()
  2430. /**
  2431. *<code>RenderContext3D</code> 类用于实现渲染状态。
  2432. */
  2433. //class laya.d3.core.render.RenderContext3D
  2434. var RenderContext3D=(function(){
  2435. function RenderContext3D(){
  2436. /**@private */
  2437. //this._batchIndexStart=0;
  2438. /**@private */
  2439. //this._batchIndexEnd=0;
  2440. /**@private */
  2441. //this.viewMatrix=null;
  2442. /**@private */
  2443. //this.projectionMatrix=null;
  2444. /**@private */
  2445. //this.projectionViewMatrix=null;
  2446. /**@private */
  2447. //this.viewport=null;
  2448. /**@private */
  2449. //this.scene=null;
  2450. /**@private */
  2451. //this.camera=null;
  2452. /**@private */
  2453. //this.renderElement=null;
  2454. /**@private */
  2455. //this.shader=null;
  2456. }
  2457. __class(RenderContext3D,'laya.d3.core.render.RenderContext3D');
  2458. RenderContext3D.clientWidth=0;
  2459. RenderContext3D.clientHeight=0;
  2460. __static(RenderContext3D,
  2461. ['_instance',function(){return this._instance=new RenderContext3D();}
  2462. ]);
  2463. return RenderContext3D;
  2464. })()
  2465. /**
  2466. *...
  2467. *@author ...
  2468. */
  2469. //class laya.d3.core.GradientMode
  2470. var GradientMode=(function(){
  2471. function GradientMode(){}
  2472. __class(GradientMode,'laya.d3.core.GradientMode');
  2473. GradientMode.Blend=0;
  2474. GradientMode.Fixed=1;
  2475. return GradientMode;
  2476. })()
  2477. /**
  2478. *<code>SingletonList</code> 类用于实现单例队列。
  2479. */
  2480. //class laya.d3.component.SingletonList
  2481. var SingletonList=(function(){
  2482. function SingletonList(){
  2483. /**@private [只读]*/
  2484. this.length=0;
  2485. this.elements=[];
  2486. }
  2487. __class(SingletonList,'laya.d3.component.SingletonList');
  2488. var __proto=SingletonList.prototype;
  2489. /**
  2490. *@private
  2491. */
  2492. __proto._add=function(element){
  2493. if (this.length===this.elements.length)
  2494. this.elements.push(element);
  2495. else
  2496. this.elements[this.length]=element;
  2497. }
  2498. return SingletonList;
  2499. })()
  2500. /**
  2501. *@private
  2502. *<code>DynamicBatchManager</code> 类用于管理动态批处理。
  2503. */
  2504. //class laya.d3.graphics.DynamicBatchManager
  2505. var DynamicBatchManager=(function(){
  2506. function DynamicBatchManager(){
  2507. /**@private */
  2508. //this._batchRenderElementPool=null;
  2509. /**@private */
  2510. //this._batchRenderElementPoolIndex=0;
  2511. this._batchRenderElementPool=[];
  2512. }
  2513. __class(DynamicBatchManager,'laya.d3.graphics.DynamicBatchManager');
  2514. var __proto=DynamicBatchManager.prototype;
  2515. /**
  2516. *@private
  2517. */
  2518. __proto._clear=function(){
  2519. this._batchRenderElementPoolIndex=0;
  2520. }
  2521. /**
  2522. *@private
  2523. */
  2524. __proto._getBatchRenderElementFromPool=function(){
  2525. throw "StaticBatch:must override this function.";
  2526. }
  2527. /**
  2528. *@private
  2529. */
  2530. __proto.dispose=function(){}
  2531. DynamicBatchManager._registerManager=function(manager){
  2532. DynamicBatchManager._managers.push(manager);
  2533. }
  2534. DynamicBatchManager._managers=[];
  2535. return DynamicBatchManager;
  2536. })()
  2537. /**
  2538. *<code>Point2PointConstraint</code> 类用于创建物理组件的父类。
  2539. */
  2540. //class laya.d3.physics.constraints.Point2PointConstraint
  2541. var Point2PointConstraint=(function(){
  2542. function Point2PointConstraint(){
  2543. /**@private */
  2544. this._damping=NaN;
  2545. /**@private */
  2546. this._impulseClamp=NaN;
  2547. /**@private */
  2548. this._tau=NaN;
  2549. this._pivotInA=new Vector3();
  2550. this._pivotInB=new Vector3();
  2551. }
  2552. __class(Point2PointConstraint,'laya.d3.physics.constraints.Point2PointConstraint');
  2553. var __proto=Point2PointConstraint.prototype;
  2554. __getset(0,__proto,'pivotInA',function(){
  2555. return this._pivotInA;
  2556. },function(value){
  2557. this._pivotInA=value;
  2558. });
  2559. __getset(0,__proto,'pivotInB',function(){
  2560. return this._pivotInB;
  2561. },function(value){
  2562. this._pivotInB=value;
  2563. });
  2564. __getset(0,__proto,'damping',function(){
  2565. return this._damping;
  2566. },function(value){
  2567. this._damping=value;
  2568. });
  2569. __getset(0,__proto,'impulseClamp',function(){
  2570. return this._impulseClamp;
  2571. },function(value){
  2572. this._impulseClamp=value;
  2573. });
  2574. __getset(0,__proto,'tau',function(){
  2575. return this._tau;
  2576. },function(value){
  2577. this._tau=value;
  2578. });
  2579. return Point2PointConstraint;
  2580. })()
  2581. /**
  2582. *@private
  2583. *<code>GeometryElement</code> 类用于实现几何体元素,该类为抽象类。
  2584. */
  2585. //class laya.d3.core.GeometryElement
  2586. var GeometryElement=(function(){
  2587. function GeometryElement(){
  2588. /**@private */
  2589. //this._destroyed=false;
  2590. this._destroyed=false;
  2591. }
  2592. __class(GeometryElement,'laya.d3.core.GeometryElement');
  2593. var __proto=GeometryElement.prototype;
  2594. Laya.imps(__proto,{"laya.resource.IDestroy":true})
  2595. /**
  2596. *获取几何体类型。
  2597. */
  2598. __proto._getType=function(){
  2599. throw "GeometryElement:must override it.";
  2600. }
  2601. /**
  2602. *@private
  2603. *@return 是否需要渲染。
  2604. */
  2605. __proto._prepareRender=function(state){
  2606. return true;
  2607. }
  2608. /**
  2609. *@private
  2610. */
  2611. __proto._render=function(state){
  2612. throw "GeometryElement:must override it.";
  2613. }
  2614. /**
  2615. *销毁。
  2616. */
  2617. __proto.destroy=function(){
  2618. if (this._destroyed)
  2619. return;
  2620. this._destroyed=true;
  2621. }
  2622. /**
  2623. *获取是否销毁。
  2624. *@return 是否销毁。
  2625. */
  2626. __getset(0,__proto,'destroyed',function(){
  2627. return this._destroyed;
  2628. });
  2629. GeometryElement._typeCounter=0;
  2630. return GeometryElement;
  2631. })()
  2632. /**
  2633. *<code>VertexPositionNormalTexture</code> 类用于创建位置、纹理顶点结构。
  2634. */
  2635. //class laya.d3.graphics.Vertex.VertexPositionTexture0
  2636. var VertexPositionTexture0=(function(){
  2637. function VertexPositionTexture0(position,textureCoordinate0){
  2638. this._position=null;
  2639. this._textureCoordinate0=null;
  2640. this._position=position;
  2641. this._textureCoordinate0=textureCoordinate0;
  2642. }
  2643. __class(VertexPositionTexture0,'laya.d3.graphics.Vertex.VertexPositionTexture0');
  2644. var __proto=VertexPositionTexture0.prototype;
  2645. Laya.imps(__proto,{"laya.d3.graphics.IVertex":true})
  2646. __getset(0,__proto,'position',function(){
  2647. return this._position;
  2648. });
  2649. __getset(0,__proto,'textureCoordinate0',function(){
  2650. return this._textureCoordinate0;
  2651. });
  2652. __getset(0,__proto,'vertexDeclaration',function(){
  2653. return VertexPositionTexture0._vertexDeclaration;
  2654. });
  2655. __getset(1,VertexPositionTexture0,'vertexDeclaration',function(){
  2656. return VertexPositionTexture0._vertexDeclaration;
  2657. });
  2658. __static(VertexPositionTexture0,
  2659. ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(20,[
  2660. new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0),
  2661. new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE0*/2)]);}
  2662. ]);
  2663. return VertexPositionTexture0;
  2664. })()
  2665. /**
  2666. *<code>MathUtils</code> 类用于创建数学工具。
  2667. */
  2668. //class laya.d3.math.MathUtils3D
  2669. var MathUtils3D=(function(){
  2670. /**
  2671. *创建一个 <code>MathUtils</code> 实例。
  2672. */
  2673. function MathUtils3D(){}
  2674. __class(MathUtils3D,'laya.d3.math.MathUtils3D');
  2675. MathUtils3D.isZero=function(v){
  2676. return Math.abs(v)< MathUtils3D.zeroTolerance;
  2677. }
  2678. MathUtils3D.nearEqual=function(n1,n2){
  2679. if (MathUtils3D.isZero(n1-n2))
  2680. return true;
  2681. return false;
  2682. }
  2683. MathUtils3D.fastInvSqrt=function(value){
  2684. if (MathUtils3D.isZero(value))
  2685. return value;
  2686. return 1.0 / Math.sqrt(value);
  2687. }
  2688. __static(MathUtils3D,
  2689. ['zeroTolerance',function(){return this.zeroTolerance=1e-6;},'MaxValue',function(){return this.MaxValue=3.40282347e+38;},'MinValue',function(){return this.MinValue=-3.40282347e+38;}
  2690. ]);
  2691. return MathUtils3D;
  2692. })()
  2693. /**
  2694. *<code>GradientColor</code> 类用于创建渐变颜色。
  2695. */
  2696. //class laya.d3.core.particleShuriKen.module.GradientColor
  2697. var GradientColor=(function(){
  2698. function GradientColor(){
  2699. /**@private */
  2700. this._type=0;
  2701. /**@private */
  2702. this._constant=null;
  2703. /**@private */
  2704. this._constantMin=null;
  2705. /**@private */
  2706. this._constantMax=null;
  2707. /**@private */
  2708. this._gradient=null;
  2709. /**@private */
  2710. this._gradientMin=null;
  2711. /**@private */
  2712. this._gradientMax=null;
  2713. }
  2714. __class(GradientColor,'laya.d3.core.particleShuriKen.module.GradientColor');
  2715. var __proto=GradientColor.prototype;
  2716. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  2717. /**
  2718. *克隆。
  2719. *@param destObject 克隆源。
  2720. */
  2721. __proto.cloneTo=function(destObject){
  2722. var destGradientColor=destObject;
  2723. destGradientColor._type=this._type;
  2724. this._constant.cloneTo(destGradientColor._constant);
  2725. this._constantMin.cloneTo(destGradientColor._constantMin);
  2726. this._constantMax.cloneTo(destGradientColor._constantMax);
  2727. this._gradient.cloneTo(destGradientColor._gradient);
  2728. this._gradientMin.cloneTo(destGradientColor._gradientMin);
  2729. this._gradientMax.cloneTo(destGradientColor._gradientMax);
  2730. }
  2731. /**
  2732. *克隆。
  2733. *@return 克隆副本。
  2734. */
  2735. __proto.clone=function(){
  2736. var destGradientColor=/*__JS__ */new this.constructor();
  2737. this.cloneTo(destGradientColor);
  2738. return destGradientColor;
  2739. }
  2740. /**
  2741. *渐变颜色。
  2742. */
  2743. __getset(0,__proto,'gradient',function(){
  2744. return this._gradient;
  2745. });
  2746. /**
  2747. *固定颜色。
  2748. */
  2749. __getset(0,__proto,'constant',function(){
  2750. return this._constant;
  2751. });
  2752. /**
  2753. *生命周期颜色类型,0为固定颜色模式,1渐变模式,2为随机双固定颜色模式,3随机双渐变模式。
  2754. */
  2755. __getset(0,__proto,'type',function(){
  2756. return this._type;
  2757. });
  2758. /**
  2759. *最小渐变颜色。
  2760. */
  2761. __getset(0,__proto,'gradientMin',function(){
  2762. return this._gradientMin;
  2763. });
  2764. /**
  2765. *最小固定颜色。
  2766. */
  2767. __getset(0,__proto,'constantMin',function(){
  2768. return this._constantMin;
  2769. });
  2770. /**
  2771. *最大渐变颜色。
  2772. */
  2773. __getset(0,__proto,'gradientMax',function(){
  2774. return this._gradientMax;
  2775. });
  2776. /**
  2777. *最大固定颜色。
  2778. */
  2779. __getset(0,__proto,'constantMax',function(){
  2780. return this._constantMax;
  2781. });
  2782. GradientColor.createByConstant=function(constant){
  2783. var gradientColor=new GradientColor();
  2784. gradientColor._type=0;
  2785. gradientColor._constant=constant;
  2786. return gradientColor;
  2787. }
  2788. GradientColor.createByGradient=function(gradient){
  2789. var gradientColor=new GradientColor();
  2790. gradientColor._type=1;
  2791. gradientColor._gradient=gradient;
  2792. return gradientColor;
  2793. }
  2794. GradientColor.createByRandomTwoConstant=function(minConstant,maxConstant){
  2795. var gradientColor=new GradientColor();
  2796. gradientColor._type=2;
  2797. gradientColor._constantMin=minConstant;
  2798. gradientColor._constantMax=maxConstant;
  2799. return gradientColor;
  2800. }
  2801. GradientColor.createByRandomTwoGradient=function(minGradient,maxGradient){
  2802. var gradientColor=new GradientColor();
  2803. gradientColor._type=3;
  2804. gradientColor._gradientMin=minGradient;
  2805. gradientColor._gradientMax=maxGradient;
  2806. return gradientColor;
  2807. }
  2808. return GradientColor;
  2809. })()
  2810. //class laya.d3.utils.Size
  2811. var Size=(function(){
  2812. function Size(width,height){
  2813. this._width=0;
  2814. this._height=0;
  2815. this._width=width;
  2816. this._height=height;
  2817. }
  2818. __class(Size,'laya.d3.utils.Size');
  2819. var __proto=Size.prototype;
  2820. __getset(0,__proto,'width',function(){
  2821. if (this._width===-1)
  2822. return RenderContext3D.clientWidth;
  2823. return this._width;
  2824. });
  2825. __getset(0,__proto,'height',function(){
  2826. if (this._height===-1)
  2827. return RenderContext3D.clientHeight;
  2828. return this._height;
  2829. });
  2830. __getset(1,Size,'fullScreen',function(){
  2831. return new Size(-1,-1);
  2832. });
  2833. return Size;
  2834. })()
  2835. /**
  2836. *<code>PhysicsSettings</code> 类用于创建物理配置信息。
  2837. */
  2838. //class laya.d3.physics.PhysicsSettings
  2839. var PhysicsSettings=(function(){
  2840. function PhysicsSettings(){
  2841. /**标志集合。*/
  2842. this.flags=0;
  2843. /**物理引擎在一帧中用于补偿减速的最大次数。*/
  2844. this.maxSubSteps=1;
  2845. /**物理模拟器帧的间隔时间。*/
  2846. this.fixedTimeStep=1.0 / 60.0;
  2847. }
  2848. __class(PhysicsSettings,'laya.d3.physics.PhysicsSettings');
  2849. return PhysicsSettings;
  2850. })()
  2851. /**
  2852. *<code>Plane</code> 类用于创建平面。
  2853. */
  2854. //class laya.d3.math.Plane
  2855. var Plane=(function(){
  2856. function Plane(normal,d){
  2857. /**平面的向量*/
  2858. this.normal=null;
  2859. /**平面到坐标系原点的距离*/
  2860. this.distance=NaN;
  2861. (d===void 0)&& (d=0);
  2862. this.normal=normal;
  2863. this.distance=d;
  2864. }
  2865. __class(Plane,'laya.d3.math.Plane');
  2866. var __proto=Plane.prototype;
  2867. /**
  2868. *更改平面法线向量的系数,使之成单位长度。
  2869. */
  2870. __proto.normalize=function(){
  2871. var normalEX=this.normal.x;
  2872. var normalEY=this.normal.y;
  2873. var normalEZ=this.normal.z;
  2874. var magnitude=1 / Math.sqrt(normalEX *normalEX+normalEY *normalEY+normalEZ *normalEZ);
  2875. this.normal.x=normalEX *magnitude;
  2876. this.normal.y=normalEY *magnitude;
  2877. this.normal.z=normalEZ *magnitude;
  2878. this.distance *=magnitude;
  2879. }
  2880. Plane.createPlaneBy3P=function(point1,point2,point3){
  2881. var x1=point2.x-point1.x;
  2882. var y1=point2.y-point1.y;
  2883. var z1=point2.z-point1.z;
  2884. var x2=point3.x-point1.x;
  2885. var y2=point3.y-point1.y;
  2886. var z2=point3.z-point1.z;
  2887. var yz=(y1 *z2)-(z1 *y2);
  2888. var xz=(z1 *x2)-(x1 *z2);
  2889. var xy=(x1 *y2)-(y1 *x2);
  2890. var invPyth=1 / (Math.sqrt((yz *yz)+(xz *xz)+(xy *xy)));
  2891. var x=yz *invPyth;
  2892. var y=xz *invPyth;
  2893. var z=xy *invPyth;
  2894. Plane._TEMPVec3.x=x;
  2895. Plane._TEMPVec3.y=y;
  2896. Plane._TEMPVec3.z=z;
  2897. var d=-((x *point1.x)+(y *point1.y)+(z *point1.z));
  2898. var plane=new Plane(Plane._TEMPVec3,d);
  2899. return plane;
  2900. }
  2901. Plane.PlaneIntersectionType_Back=0;
  2902. Plane.PlaneIntersectionType_Front=1;
  2903. Plane.PlaneIntersectionType_Intersecting=2;
  2904. __static(Plane,
  2905. ['_TEMPVec3',function(){return this._TEMPVec3=new Vector3();}
  2906. ]);
  2907. return Plane;
  2908. })()
  2909. /**
  2910. *<code>MaterialInfo</code> 类用于描述地形材质信息。
  2911. */
  2912. //class laya.d3.terrain.unit.MaterialInfo
  2913. var MaterialInfo=(function(){
  2914. function MaterialInfo(){
  2915. this.ambientColor=null;
  2916. this.diffuseColor=null;
  2917. this.specularColor=null;
  2918. }
  2919. __class(MaterialInfo,'laya.d3.terrain.unit.MaterialInfo');
  2920. return MaterialInfo;
  2921. })()
  2922. /**
  2923. *<code>Gradient</code> 类用于创建颜色渐变。
  2924. */
  2925. //class laya.d3.core.Gradient
  2926. var Gradient=(function(){
  2927. function Gradient(maxColorRGBKeyCount,maxColorAlphaKeyCount){
  2928. /**@private */
  2929. this._mode=0;
  2930. /**@private */
  2931. this._maxColorRGBKeysCount=0;
  2932. /**@private */
  2933. this._maxColorAlphaKeysCount=0;
  2934. /**@private */
  2935. this._colorRGBKeysCount=0;
  2936. /**@private */
  2937. this._colorAlphaKeysCount=0;
  2938. /**@private */
  2939. this._alphaElements=null;
  2940. /**@private */
  2941. this._rgbElements=null;
  2942. this._maxColorRGBKeysCount=maxColorRGBKeyCount;
  2943. this._maxColorAlphaKeysCount=maxColorAlphaKeyCount;
  2944. this._rgbElements=new Float32Array(maxColorRGBKeyCount *4);
  2945. this._alphaElements=new Float32Array(maxColorAlphaKeyCount *2);
  2946. }
  2947. __class(Gradient,'laya.d3.core.Gradient');
  2948. var __proto=Gradient.prototype;
  2949. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  2950. /**
  2951. *增加颜色RGB帧。
  2952. *@param key 生命周期,范围为0到1。
  2953. *@param value RGB值。
  2954. */
  2955. __proto.addColorRGB=function(key,value){
  2956. if (this._colorRGBKeysCount < this._maxColorRGBKeysCount){
  2957. var offset=this._colorRGBKeysCount *4;
  2958. this._rgbElements[offset]=key;
  2959. this._rgbElements[offset+1]=value.r;
  2960. this._rgbElements[offset+2]=value.g;
  2961. this._rgbElements[offset+3]=value.b;
  2962. this._colorRGBKeysCount++;
  2963. }else {
  2964. console.warn("Gradient:warning:data count must lessEqual than "+this._maxColorRGBKeysCount);
  2965. }
  2966. }
  2967. /**
  2968. *增加颜色Alpha帧。
  2969. *@param key 生命周期,范围为0到1。
  2970. *@param value Alpha值。
  2971. */
  2972. __proto.addColorAlpha=function(key,value){
  2973. if (this._colorAlphaKeysCount < this._maxColorAlphaKeysCount){
  2974. var offset=this._colorAlphaKeysCount *2;
  2975. this._alphaElements[offset]=key;
  2976. this._alphaElements[offset+1]=value;
  2977. this._colorAlphaKeysCount++;
  2978. }else {
  2979. console.warn("Gradient:warning:data count must lessEqual than "+this._maxColorAlphaKeysCount);
  2980. }
  2981. }
  2982. /**
  2983. *更新颜色RGB帧。
  2984. *@param index 索引。
  2985. *@param key 生命周期,范围为0到1。
  2986. *@param value RGB值。
  2987. */
  2988. __proto.updateColorRGB=function(index,key,value){
  2989. if (index < this._colorRGBKeysCount){
  2990. var offset=index *4;
  2991. this._rgbElements[offset]=key;
  2992. this._rgbElements[offset+1]=value.r;
  2993. this._rgbElements[offset+2]=value.g;
  2994. this._rgbElements[offset+3]=value.b;
  2995. }else {
  2996. console.warn("Gradient:warning:index must lessEqual than colorRGBKeysCount:"+this._colorRGBKeysCount);
  2997. }
  2998. }
  2999. /**
  3000. *更新颜色Alpha帧。
  3001. *@param index 索引。
  3002. *@param key 生命周期,范围为0到1。
  3003. *@param value Alpha值。
  3004. */
  3005. __proto.updateColorAlpha=function(index,key,value){
  3006. if (index < this._colorAlphaKeysCount){
  3007. var offset=index *2;
  3008. this._alphaElements[offset]=key;
  3009. this._alphaElements[offset+1]=value;
  3010. }else {
  3011. console.warn("Gradient:warning:index must lessEqual than colorAlphaKeysCount:"+this._colorAlphaKeysCount);
  3012. }
  3013. }
  3014. /**
  3015. *克隆。
  3016. *@param destObject 克隆源。
  3017. */
  3018. __proto.cloneTo=function(destObject){
  3019. var destGradientDataColor=destObject;
  3020. var i=0,n=0;
  3021. destGradientDataColor._colorAlphaKeysCount=this._colorAlphaKeysCount;
  3022. var destAlphaElements=destGradientDataColor._alphaElements;
  3023. destAlphaElements.length=this._alphaElements.length;
  3024. for (i=0,n=this._alphaElements.length;i < n;i++)
  3025. destAlphaElements[i]=this._alphaElements[i];
  3026. destGradientDataColor._colorRGBKeysCount=this._colorRGBKeysCount;
  3027. var destRGBElements=destGradientDataColor._rgbElements;
  3028. destRGBElements.length=this._rgbElements.length;
  3029. for (i=0,n=this._rgbElements.length;i < n;i++)
  3030. destRGBElements[i]=this._rgbElements[i];
  3031. }
  3032. /**
  3033. *克隆。
  3034. *@return 克隆副本。
  3035. */
  3036. __proto.clone=function(){
  3037. var destGradientDataColor=new Gradient(this._maxColorRGBKeysCount,this._maxColorAlphaKeysCount);
  3038. this.cloneTo(destGradientDataColor);
  3039. return destGradientDataColor;
  3040. }
  3041. /**
  3042. *获取颜色RGB数量。
  3043. *@return 颜色RGB数量。
  3044. */
  3045. __getset(0,__proto,'colorRGBKeysCount',function(){
  3046. return this._colorRGBKeysCount / 4;
  3047. });
  3048. /**
  3049. *设置梯度模式。
  3050. *@param value 梯度模式。
  3051. */
  3052. /**
  3053. *获取梯度模式。
  3054. *@return 梯度模式。
  3055. */
  3056. __getset(0,__proto,'mode',function(){
  3057. return this._mode;
  3058. },function(value){
  3059. this._mode=value;
  3060. });
  3061. /**
  3062. *获取颜色Alpha数量。
  3063. *@return 颜色Alpha数量。
  3064. */
  3065. __getset(0,__proto,'colorAlphaKeysCount',function(){
  3066. return this._colorAlphaKeysCount / 2;
  3067. });
  3068. /**
  3069. *获取最大颜色RGB帧数量。
  3070. *@return 最大RGB帧数量。
  3071. */
  3072. __getset(0,__proto,'maxColorRGBKeysCount',function(){
  3073. return this._maxColorRGBKeysCount;
  3074. });
  3075. /**
  3076. *获取最大颜色Alpha帧数量。
  3077. *@return 最大Alpha帧数量。
  3078. */
  3079. __getset(0,__proto,'maxColorAlphaKeysCount',function(){
  3080. return this._maxColorAlphaKeysCount;
  3081. });
  3082. return Gradient;
  3083. })()
  3084. /**
  3085. *<code>Quaternion</code> 类用于创建四元数。
  3086. */
  3087. //class laya.d3.math.Quaternion
  3088. var Quaternion=(function(){
  3089. function Quaternion(x,y,z,w,nativeElements){
  3090. /**X轴坐标*/
  3091. //this.x=NaN;
  3092. /**Y轴坐标*/
  3093. //this.y=NaN;
  3094. /**Z轴坐标*/
  3095. //this.z=NaN;
  3096. /**W轴坐标*/
  3097. //this.w=NaN;
  3098. (x===void 0)&& (x=0);
  3099. (y===void 0)&& (y=0);
  3100. (z===void 0)&& (z=0);
  3101. (w===void 0)&& (w=1);
  3102. this.x=x;
  3103. this.y=y;
  3104. this.z=z;
  3105. this.w=w;
  3106. }
  3107. __class(Quaternion,'laya.d3.math.Quaternion');
  3108. var __proto=Quaternion.prototype;
  3109. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  3110. /**
  3111. *根据缩放值缩放四元数
  3112. *@param scale 缩放值
  3113. *@param out 输出四元数
  3114. */
  3115. __proto.scaling=function(scaling,out){
  3116. out.x=this.x *scaling;
  3117. out.y=this.y *scaling;
  3118. out.z=this.z *scaling;
  3119. out.w=this.w *scaling;
  3120. }
  3121. /**
  3122. *归一化四元数
  3123. *@param out 输出四元数
  3124. */
  3125. __proto.normalize=function(out){
  3126. var len=this.x *this.x+this.y *this.y+this.z *this.z+this.w *this.w;
  3127. if (len > 0){
  3128. len=1 / Math.sqrt(len);
  3129. out.x=this.x *len;
  3130. out.y=this.y *len;
  3131. out.z=this.z *len;
  3132. out.w=this.w *len;
  3133. }
  3134. }
  3135. /**
  3136. *计算四元数的长度
  3137. *@return 长度
  3138. */
  3139. __proto.length=function(){
  3140. return Math.sqrt(this.x *this.x+this.y *this.y+this.z *this.z+this.w *this.w);
  3141. }
  3142. /**
  3143. *根据绕X轴的角度旋转四元数
  3144. *@param rad 角度
  3145. *@param out 输出四元数
  3146. */
  3147. __proto.rotateX=function(rad,out){
  3148. rad *=0.5;
  3149. var bx=Math.sin(rad),bw=Math.cos(rad);
  3150. out.x=this.x *bw+this.w *bx;
  3151. out.y=this.y *bw+this.z *bx;
  3152. out.z=this.z *bw-this.y *bx;
  3153. out.w=this.w *bw-this.x *bx;
  3154. }
  3155. /**
  3156. *根据绕Y轴的制定角度旋转四元数
  3157. *@param rad 角度
  3158. *@param out 输出四元数
  3159. */
  3160. __proto.rotateY=function(rad,out){
  3161. rad *=0.5;
  3162. var by=Math.sin(rad),bw=Math.cos(rad);
  3163. out.x=this.x *bw-this.z *by;
  3164. out.y=this.y *bw+this.w *by;
  3165. out.z=this.z *bw+this.x *by;
  3166. out.w=this.w *bw-this.y *by;
  3167. }
  3168. /**
  3169. *根据绕Z轴的制定角度旋转四元数
  3170. *@param rad 角度
  3171. *@param out 输出四元数
  3172. */
  3173. __proto.rotateZ=function(rad,out){
  3174. rad *=0.5;
  3175. var bz=Math.sin(rad),bw=Math.cos(rad);
  3176. out.x=this.x *bw+this.y *bz;
  3177. out.y=this.y *bw-this.x *bz;
  3178. out.z=this.z *bw+this.w *bz;
  3179. out.w=this.w *bw-this.z *bz;
  3180. }
  3181. /**
  3182. *分解四元数到欧拉角(顺序为Yaw、Pitch、Roll),参考自http://xboxforums.create.msdn.com/forums/p/4574/23988.aspx#23988,问题绕X轴翻转超过±90度时有,会产生瞬间反转
  3183. *@param quaternion 源四元数
  3184. *@param out 欧拉角值
  3185. */
  3186. __proto.getYawPitchRoll=function(out){
  3187. Vector3.transformQuat(Vector3._ForwardRH,this,Quaternion.TEMPVector31);
  3188. Vector3.transformQuat(Vector3._Up,this,Quaternion.TEMPVector32);
  3189. var upe=Quaternion.TEMPVector32;
  3190. Quaternion.angleTo(Vector3._ZERO,Quaternion.TEMPVector31,Quaternion.TEMPVector33);
  3191. var angle=Quaternion.TEMPVector33;
  3192. if (angle.x==Math.PI / 2){
  3193. angle.y=Quaternion.arcTanAngle(upe.z,upe.x);
  3194. angle.z=0;
  3195. }else if (angle.x==-Math.PI / 2){
  3196. angle.y=Quaternion.arcTanAngle(-upe.z,-upe.x);
  3197. angle.z=0;
  3198. }else {
  3199. Matrix4x4.createRotationY(-angle.y,Quaternion.TEMPMatrix0);
  3200. Matrix4x4.createRotationX(-angle.x,Quaternion.TEMPMatrix1);
  3201. Vector3.transformCoordinate(Quaternion.TEMPVector32,Quaternion.TEMPMatrix0,Quaternion.TEMPVector32);
  3202. Vector3.transformCoordinate(Quaternion.TEMPVector32,Quaternion.TEMPMatrix1,Quaternion.TEMPVector32);
  3203. angle.z=Quaternion.arcTanAngle(upe.y,-upe.x);
  3204. }
  3205. if (angle.y <=-Math.PI)
  3206. angle.y=Math.PI;
  3207. if (angle.z <=-Math.PI)
  3208. angle.z=Math.PI;
  3209. if (angle.y >=Math.PI && angle.z >=Math.PI){
  3210. angle.y=0;
  3211. angle.z=0;
  3212. angle.x=Math.PI-angle.x;
  3213. };
  3214. var oe=out;
  3215. oe.x=angle.y;
  3216. oe.y=angle.x;
  3217. oe.z=angle.z;
  3218. }
  3219. /**
  3220. *求四元数的逆
  3221. *@param out 输出四元数
  3222. */
  3223. __proto.invert=function(out){
  3224. var a0=this.x,a1=this.y,a2=this.z,a3=this.w;
  3225. var dot=a0 *a0+a1 *a1+a2 *a2+a3 *a3;
  3226. var invDot=dot ? 1.0 / dot :0;
  3227. out.x=-a0 *invDot;
  3228. out.y=-a1 *invDot;
  3229. out.z=-a2 *invDot;
  3230. out.w=a3 *invDot;
  3231. }
  3232. /**
  3233. *设置四元数为单位算数
  3234. *@param out 输出四元数
  3235. */
  3236. __proto.identity=function(){
  3237. this.x=0;
  3238. this.y=0;
  3239. this.z=0;
  3240. this.w=1;
  3241. }
  3242. /**
  3243. *从Array数组拷贝值。
  3244. *@param array 数组。
  3245. *@param offset 数组偏移。
  3246. */
  3247. __proto.fromArray=function(array,offset){
  3248. (offset===void 0)&& (offset=0);
  3249. this.x=array[offset+0];
  3250. this.y=array[offset+1];
  3251. this.z=array[offset+2];
  3252. this.w=array[offset+3];
  3253. }
  3254. /**
  3255. *克隆。
  3256. *@param destObject 克隆源。
  3257. */
  3258. __proto.cloneTo=function(destObject){
  3259. if (this===destObject){
  3260. return;
  3261. }
  3262. destObject.x=this.x;
  3263. destObject.y=this.y;
  3264. destObject.z=this.z;
  3265. destObject.w=this.w;
  3266. }
  3267. /**
  3268. *克隆。
  3269. *@return 克隆副本。
  3270. */
  3271. __proto.clone=function(){
  3272. var dest=/*__JS__ */new this.constructor();
  3273. this.cloneTo(dest);
  3274. return dest;
  3275. }
  3276. __proto.equals=function(b){
  3277. return MathUtils3D.nearEqual(this.x,b.x)&& MathUtils3D.nearEqual(this.y,b.y)&& MathUtils3D.nearEqual(this.z,b.z)&& MathUtils3D.nearEqual(this.w,b.w);
  3278. }
  3279. /**
  3280. *计算长度的平方。
  3281. *@return 长度的平方。
  3282. */
  3283. __proto.lengthSquared=function(){
  3284. return (this.x *this.x)+(this.y *this.y)+(this.z *this.z)+(this.w *this.w);
  3285. }
  3286. __proto.forNativeElement=function(nativeElements){
  3287. if (nativeElements){
  3288. /*__JS__ */this.elements=nativeElements;
  3289. /*__JS__ */this.elements[0]=this.x;
  3290. /*__JS__ */this.elements[1]=this.y;
  3291. /*__JS__ */this.elements[2]=this.z;
  3292. /*__JS__ */this.elements[3]=this.w;
  3293. }
  3294. else{
  3295. /*__JS__ */this.elements=new Float32Array([this.x,this.y,this.z,this.w]);
  3296. }
  3297. Vector2.rewriteNumProperty(this,"x",0);
  3298. Vector2.rewriteNumProperty(this,"y",1);
  3299. Vector2.rewriteNumProperty(this,"z",2);
  3300. Vector2.rewriteNumProperty(this,"w",3);
  3301. }
  3302. Quaternion.createFromYawPitchRoll=function(yaw,pitch,roll,out){
  3303. var halfRoll=roll *0.5;
  3304. var halfPitch=pitch *0.5;
  3305. var halfYaw=yaw *0.5;
  3306. var sinRoll=Math.sin(halfRoll);
  3307. var cosRoll=Math.cos(halfRoll);
  3308. var sinPitch=Math.sin(halfPitch);
  3309. var cosPitch=Math.cos(halfPitch);
  3310. var sinYaw=Math.sin(halfYaw);
  3311. var cosYaw=Math.cos(halfYaw);
  3312. out.x=(cosYaw *sinPitch *cosRoll)+(sinYaw *cosPitch *sinRoll);
  3313. out.y=(sinYaw *cosPitch *cosRoll)-(cosYaw *sinPitch *sinRoll);
  3314. out.z=(cosYaw *cosPitch *sinRoll)-(sinYaw *sinPitch *cosRoll);
  3315. out.w=(cosYaw *cosPitch *cosRoll)+(sinYaw *sinPitch *sinRoll);
  3316. }
  3317. Quaternion.multiply=function(left,right,out){
  3318. var lx=left.x;
  3319. var ly=left.y;
  3320. var lz=left.z;
  3321. var lw=left.w;
  3322. var rx=right.x;
  3323. var ry=right.y;
  3324. var rz=right.z;
  3325. var rw=right.w;
  3326. var a=(ly *rz-lz *ry);
  3327. var b=(lz *rx-lx *rz);
  3328. var c=(lx *ry-ly *rx);
  3329. var d=(lx *rx+ly *ry+lz *rz);
  3330. out.x=(lx *rw+rx *lw)+a;
  3331. out.y=(ly *rw+ry *lw)+b;
  3332. out.z=(lz *rw+rz *lw)+c;
  3333. out.w=lw *rw-d;
  3334. }
  3335. Quaternion.arcTanAngle=function(x,y){
  3336. if (x==0){
  3337. if (y==1)
  3338. return Math.PI / 2;
  3339. return-Math.PI / 2;
  3340. }
  3341. if (x > 0)
  3342. return Math.atan(y / x);
  3343. if (x < 0){
  3344. if (y > 0)
  3345. return Math.atan(y / x)+Math.PI;
  3346. return Math.atan(y / x)-Math.PI;
  3347. }
  3348. return 0;
  3349. }
  3350. Quaternion.angleTo=function(from,location,angle){
  3351. Vector3.subtract(location,from,Quaternion.TEMPVector30);
  3352. Vector3.normalize(Quaternion.TEMPVector30,Quaternion.TEMPVector30);
  3353. angle.x=Math.asin(Quaternion.TEMPVector30.y);
  3354. angle.y=Quaternion.arcTanAngle(-Quaternion.TEMPVector30.z,-Quaternion.TEMPVector30.x);
  3355. }
  3356. Quaternion.createFromAxisAngle=function(axis,rad,out){
  3357. rad=rad *0.5;
  3358. var s=Math.sin(rad);
  3359. out.x=s *axis.x;
  3360. out.y=s *axis.y;
  3361. out.z=s *axis.z;
  3362. out.w=Math.cos(rad);
  3363. }
  3364. Quaternion.createFromMatrix4x4=function(mat,out){
  3365. var me=mat.elements;
  3366. var sqrt;
  3367. var half;
  3368. var scale=me[0]+me[5]+me[10];
  3369. if (scale > 0.0){
  3370. sqrt=Math.sqrt(scale+1.0);
  3371. out.w=sqrt *0.5;
  3372. sqrt=0.5 / sqrt;
  3373. out.x=(me[6]-me[9])*sqrt;
  3374. out.y=(me[8]-me[2])*sqrt;
  3375. out.z=(me[1]-me[4])*sqrt;
  3376. }else if ((me[0] >=me[5])&& (me[0] >=me[10])){
  3377. sqrt=Math.sqrt(1.0+me[0]-me[5]-me[10]);
  3378. half=0.5 / sqrt;
  3379. out.x=0.5 *sqrt;
  3380. out.y=(me[1]+me[4])*half;
  3381. out.z=(me[2]+me[8])*half;
  3382. out.w=(me[6]-me[9])*half;
  3383. }else if (me[5] > me[10]){
  3384. sqrt=Math.sqrt(1.0+me[5]-me[0]-me[10]);
  3385. half=0.5 / sqrt;
  3386. out.x=(me[4]+me[1])*half;
  3387. out.y=0.5 *sqrt;
  3388. out.z=(me[9]+me[6])*half;
  3389. out.w=(me[8]-me[2])*half;
  3390. }else {
  3391. sqrt=Math.sqrt(1.0+me[10]-me[0]-me[5]);
  3392. half=0.5 / sqrt;
  3393. out.x=(me[8]+me[2])*half;
  3394. out.y=(me[9]+me[6])*half;
  3395. out.z=0.5 *sqrt;
  3396. out.w=(me[1]-me[4])*half;
  3397. }
  3398. }
  3399. Quaternion.slerp=function(left,right,t,out){
  3400. var ax=left.x,ay=left.y,az=left.z,aw=left.w,bx=right.x,by=right.y,bz=right.z,bw=right.w;
  3401. var omega,cosom,sinom,scale0,scale1;
  3402. cosom=ax *bx+ay *by+az *bz+aw *bw;
  3403. if (cosom < 0.0){
  3404. cosom=-cosom;
  3405. bx=-bx;
  3406. by=-by;
  3407. bz=-bz;
  3408. bw=-bw;
  3409. }
  3410. if ((1.0-cosom)> 0.000001){
  3411. omega=Math.acos(cosom);
  3412. sinom=Math.sin(omega);
  3413. scale0=Math.sin((1.0-t)*omega)/ sinom;
  3414. scale1=Math.sin(t *omega)/ sinom;
  3415. }else {
  3416. scale0=1.0-t;
  3417. scale1=t;
  3418. }
  3419. out.x=scale0 *ax+scale1 *bx;
  3420. out.y=scale0 *ay+scale1 *by;
  3421. out.z=scale0 *az+scale1 *bz;
  3422. out.w=scale0 *aw+scale1 *bw;
  3423. return out;
  3424. }
  3425. Quaternion.lerp=function(left,right,amount,out){
  3426. var inverse=1.0-amount;
  3427. if (Quaternion.dot(left,right)>=0){
  3428. out.x=(inverse *left.x)+(amount *right.x);
  3429. out.y=(inverse *left.y)+(amount *right.y);
  3430. out.z=(inverse *left.z)+(amount *right.z);
  3431. out.w=(inverse *left.w)+(amount *right.w);
  3432. }else {
  3433. out.x=(inverse *left.x)-(amount *right.x);
  3434. out.y=(inverse *left.y)-(amount *right.y);
  3435. out.z=(inverse *left.z)-(amount *right.z);
  3436. out.w=(inverse *left.w)-(amount *right.w);
  3437. }
  3438. out.normalize(out);
  3439. }
  3440. Quaternion.add=function(left,right,out){
  3441. out.x=left.x+right.x;
  3442. out.y=left.y+right.y;
  3443. out.z=left.z+right.z;
  3444. out.w=left.w+right.w;
  3445. }
  3446. Quaternion.dot=function(left,right){
  3447. return left.x *right.x+left.y *right.y+left.z *right.z+left.w *right.w;
  3448. }
  3449. Quaternion.rotationLookAt=function(forward,up,out){
  3450. Quaternion.lookAt(Vector3._ZERO,forward,up,out);
  3451. }
  3452. Quaternion.lookAt=function(eye,target,up,out){
  3453. Matrix3x3.lookAt(eye,target,up,Quaternion._tempMatrix3x3);
  3454. Quaternion.rotationMatrix(Quaternion._tempMatrix3x3,out);
  3455. }
  3456. Quaternion.invert=function(value,out){
  3457. var lengthSq=value.lengthSquared();
  3458. if (!MathUtils3D.isZero(lengthSq)){
  3459. lengthSq=1.0 / lengthSq;
  3460. out.x=-value.x *lengthSq;
  3461. out.y=-value.y *lengthSq;
  3462. out.z=-value.z *lengthSq;
  3463. out.w=value.w *lengthSq;
  3464. }
  3465. }
  3466. Quaternion.rotationMatrix=function(matrix3x3,out){
  3467. var me=matrix3x3.elements;
  3468. var m11=me[0];
  3469. var m12=me[1];
  3470. var m13=me[2];
  3471. var m21=me[3];
  3472. var m22=me[4];
  3473. var m23=me[5];
  3474. var m31=me[6];
  3475. var m32=me[7];
  3476. var m33=me[8];
  3477. var sqrt=NaN,half=NaN;
  3478. var scale=m11+m22+m33;
  3479. if (scale > 0){
  3480. sqrt=Math.sqrt(scale+1);
  3481. out.w=sqrt *0.5;
  3482. sqrt=0.5 / sqrt;
  3483. out.x=(m23-m32)*sqrt;
  3484. out.y=(m31-m13)*sqrt;
  3485. out.z=(m12-m21)*sqrt;
  3486. }else if ((m11 >=m22)&& (m11 >=m33)){
  3487. sqrt=Math.sqrt(1+m11-m22-m33);
  3488. half=0.5 / sqrt;
  3489. out.x=0.5 *sqrt;
  3490. out.y=(m12+m21)*half;
  3491. out.z=(m13+m31)*half;
  3492. out.w=(m23-m32)*half;
  3493. }else if (m22 > m33){
  3494. sqrt=Math.sqrt(1+m22-m11-m33);
  3495. half=0.5 / sqrt;
  3496. out.x=(m21+m12)*half;
  3497. out.y=0.5 *sqrt;
  3498. out.z=(m32+m23)*half;
  3499. out.w=(m31-m13)*half;
  3500. }else {
  3501. sqrt=Math.sqrt(1+m33-m11-m22);
  3502. half=0.5 / sqrt;
  3503. out.x=(m31+m13)*half;
  3504. out.y=(m32+m23)*half;
  3505. out.z=0.5 *sqrt;
  3506. out.w=(m12-m21)*half;
  3507. }
  3508. }
  3509. Quaternion.DEFAULT=new Quaternion();
  3510. __static(Quaternion,
  3511. ['TEMPVector30',function(){return this.TEMPVector30=new Vector3();},'TEMPVector31',function(){return this.TEMPVector31=new Vector3();},'TEMPVector32',function(){return this.TEMPVector32=new Vector3();},'TEMPVector33',function(){return this.TEMPVector33=new Vector3();},'TEMPMatrix0',function(){return this.TEMPMatrix0=new Matrix4x4();},'TEMPMatrix1',function(){return this.TEMPMatrix1=new Matrix4x4();},'_tempMatrix3x3',function(){return this._tempMatrix3x3=new Matrix3x3();},'NAN',function(){return this.NAN=new Quaternion(NaN,NaN,NaN,NaN);}
  3512. ]);
  3513. return Quaternion;
  3514. })()
  3515. /**
  3516. *@private
  3517. */
  3518. //class laya.d3.shader.ShaderData
  3519. var ShaderData=(function(){
  3520. function ShaderData(ownerResource){
  3521. /**@private */
  3522. this._ownerResource=null;
  3523. /**@private */
  3524. this._data=null;
  3525. /**@private [NATIVE]*/
  3526. this._int32Data=null;
  3527. /**@private [NATIVE]*/
  3528. this._float32Data=null;
  3529. /**@private [NATIVE]*/
  3530. this._nativeArray=null;
  3531. /**@private [NATIVE]*/
  3532. this._frameCount=0;
  3533. /**@private [NATIVE]*/
  3534. this._runtimeCopyValues=[];
  3535. this._ownerResource=ownerResource;
  3536. this._initData();
  3537. }
  3538. __class(ShaderData,'laya.d3.shader.ShaderData');
  3539. var __proto=ShaderData.prototype;
  3540. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  3541. /**
  3542. *@private
  3543. */
  3544. __proto._initData=function(){
  3545. this._data=new Object();
  3546. }
  3547. /**
  3548. *@private
  3549. */
  3550. __proto.getData=function(){
  3551. return this._data;
  3552. }
  3553. /**
  3554. *获取布尔。
  3555. *@param index shader索引。
  3556. *@return 布尔。
  3557. */
  3558. __proto.getBool=function(index){
  3559. return this._data[index];
  3560. }
  3561. /**
  3562. *设置布尔。
  3563. *@param index shader索引。
  3564. *@param value 布尔。
  3565. */
  3566. __proto.setBool=function(index,value){
  3567. this._data[index]=value;
  3568. }
  3569. /**
  3570. *获取整形。
  3571. *@param index shader索引。
  3572. *@return 整形。
  3573. */
  3574. __proto.getInt=function(index){
  3575. return this._data[index];
  3576. }
  3577. /**
  3578. *设置整型。
  3579. *@param index shader索引。
  3580. *@param value 整形。
  3581. */
  3582. __proto.setInt=function(index,value){
  3583. this._data[index]=value;
  3584. }
  3585. /**
  3586. *获取浮点。
  3587. *@param index shader索引。
  3588. *@return 浮点。
  3589. */
  3590. __proto.getNumber=function(index){
  3591. return this._data[index];
  3592. }
  3593. /**
  3594. *设置浮点。
  3595. *@param index shader索引。
  3596. *@param value 浮点。
  3597. */
  3598. __proto.setNumber=function(index,value){
  3599. this._data[index]=value;
  3600. }
  3601. /**
  3602. *获取Vector2向量。
  3603. *@param index shader索引。
  3604. *@return Vector2向量。
  3605. */
  3606. __proto.getVector2=function(index){
  3607. return this._data[index];
  3608. }
  3609. /**
  3610. *设置Vector2向量。
  3611. *@param index shader索引。
  3612. *@param value Vector2向量。
  3613. */
  3614. __proto.setVector2=function(index,value){
  3615. this._data[index]=value;
  3616. }
  3617. /**
  3618. *获取Vector3向量。
  3619. *@param index shader索引。
  3620. *@return Vector3向量。
  3621. */
  3622. __proto.getVector3=function(index){
  3623. return this._data[index];
  3624. }
  3625. /**
  3626. *设置Vector3向量。
  3627. *@param index shader索引。
  3628. *@param value Vector3向量。
  3629. */
  3630. __proto.setVector3=function(index,value){
  3631. this._data[index]=value;
  3632. }
  3633. /**
  3634. *获取颜色。
  3635. *@param index shader索引。
  3636. *@return 颜色向量。
  3637. */
  3638. __proto.getVector=function(index){
  3639. return this._data[index];
  3640. }
  3641. /**
  3642. *设置向量。
  3643. *@param index shader索引。
  3644. *@param value 向量。
  3645. */
  3646. __proto.setVector=function(index,value){
  3647. this._data[index]=value;
  3648. }
  3649. /**
  3650. *获取四元数。
  3651. *@param index shader索引。
  3652. *@return 四元。
  3653. */
  3654. __proto.getQuaternion=function(index){
  3655. return this._data[index];
  3656. }
  3657. /**
  3658. *设置四元数。
  3659. *@param index shader索引。
  3660. *@param value 四元数。
  3661. */
  3662. __proto.setQuaternion=function(index,value){
  3663. this._data[index]=value;
  3664. }
  3665. /**
  3666. *获取矩阵。
  3667. *@param index shader索引。
  3668. *@return 矩阵。
  3669. */
  3670. __proto.getMatrix4x4=function(index){
  3671. return this._data[index];
  3672. }
  3673. /**
  3674. *设置矩阵。
  3675. *@param index shader索引。
  3676. *@param value 矩阵。
  3677. */
  3678. __proto.setMatrix4x4=function(index,value){
  3679. this._data[index]=value;
  3680. }
  3681. /**
  3682. *获取Buffer。
  3683. *@param index shader索引。
  3684. *@return
  3685. */
  3686. __proto.getBuffer=function(shaderIndex){
  3687. return this._data[shaderIndex];
  3688. }
  3689. /**
  3690. *设置Buffer。
  3691. *@param index shader索引。
  3692. *@param value buffer数据。
  3693. */
  3694. __proto.setBuffer=function(index,value){
  3695. this._data[index]=value;
  3696. }
  3697. /**
  3698. *设置纹理。
  3699. *@param index shader索引。
  3700. *@param value 纹理。
  3701. */
  3702. __proto.setTexture=function(index,value){
  3703. var lastValue=this._data[index];
  3704. this._data[index]=value;
  3705. if (this._ownerResource && this._ownerResource.referenceCount > 0){
  3706. (lastValue)&& (lastValue._removeReference());
  3707. (value)&& (value._addReference());
  3708. }
  3709. }
  3710. /**
  3711. *获取纹理。
  3712. *@param index shader索引。
  3713. *@return 纹理。
  3714. */
  3715. __proto.getTexture=function(index){
  3716. return this._data[index];
  3717. }
  3718. /**
  3719. *设置Attribute。
  3720. *@param index shader索引。
  3721. *@param value 纹理。
  3722. */
  3723. __proto.setAttribute=function(index,value){
  3724. this._data[index]=value;
  3725. }
  3726. /**
  3727. *获取Attribute。
  3728. *@param index shader索引。
  3729. *@return 纹理。
  3730. */
  3731. __proto.getAttribute=function(index){
  3732. return this._data[index];
  3733. }
  3734. /**
  3735. *获取长度。
  3736. *@return 长度。
  3737. */
  3738. __proto.getLength=function(){
  3739. return this._data.length;
  3740. }
  3741. /**
  3742. *设置长度。
  3743. *@param 长度。
  3744. */
  3745. __proto.setLength=function(value){
  3746. this._data.length=value;
  3747. }
  3748. /**
  3749. *克隆。
  3750. *@param destObject 克隆源。
  3751. */
  3752. __proto.cloneTo=function(destObject){
  3753. var dest=destObject;
  3754. var destData=dest._data;
  3755. for (var k in this._data){
  3756. var value=this._data[k];
  3757. if (value !=null){
  3758. if ((typeof value=='number')){
  3759. destData[k]=value;
  3760. }else if (((typeof value=='number')&& Math.floor(value)==value)){
  3761. destData[k]=value;
  3762. }else if ((typeof value=='boolean')){
  3763. destData[k]=value;
  3764. }else if ((value instanceof laya.d3.math.Vector2 )){
  3765. var v2=(destData[k])|| (destData[k]=new Vector2());
  3766. (value).cloneTo(v2);
  3767. destData[k]=v2;
  3768. }else if ((value instanceof laya.d3.math.Vector3 )){
  3769. var v3=(destData[k])|| (destData[k]=new Vector3());
  3770. (value).cloneTo(v3);
  3771. destData[k]=v3;
  3772. }else if ((value instanceof laya.d3.math.Vector4 )){
  3773. var v4=(destData[k])|| (destData[k]=new Vector4());
  3774. (value).cloneTo(v4);
  3775. destData[k]=v4;
  3776. }else if ((value instanceof laya.d3.math.Matrix4x4 )){
  3777. var mat=(destData[k])|| (destData[k]=new Matrix4x4());
  3778. (value).cloneTo(mat);
  3779. destData[k]=mat;
  3780. }else if ((value instanceof laya.resource.BaseTexture )){
  3781. destData[k]=value;
  3782. }
  3783. }
  3784. }
  3785. }
  3786. /**
  3787. *克隆。
  3788. *@return 克隆副本。
  3789. */
  3790. __proto.clone=function(){
  3791. var dest=/*__JS__ */new this.constructor();
  3792. this.cloneTo(dest);
  3793. return dest;
  3794. }
  3795. /**
  3796. *克隆。
  3797. *@param destObject 克隆源。
  3798. */
  3799. __proto.cloneToForNative=function(destObject){
  3800. var dest=destObject;
  3801. var diffSize=this._int32Data.length-dest._int32Data.length;
  3802. if (diffSize > 0){
  3803. dest.needRenewArrayBufferForNative(this._int32Data.length);
  3804. }
  3805. dest._int32Data.set(this._int32Data,0);
  3806. var destData=dest._nativeArray;
  3807. var dataCount=this._nativeArray.length;
  3808. destData.length=dataCount;
  3809. for (var i=0;i < dataCount;i++){
  3810. var value=this._nativeArray[i];
  3811. if (value){
  3812. if ((typeof value=='number')){
  3813. destData[i]=value;
  3814. dest.setNumber(i,value);
  3815. }else if (((typeof value=='number')&& Math.floor(value)==value)){
  3816. destData[i]=value;
  3817. dest.setInt(i,value);
  3818. }else if ((typeof value=='boolean')){
  3819. destData[i]=value;
  3820. dest.setBool(i,value);
  3821. }else if ((value instanceof laya.d3.math.Vector2 )){
  3822. var v2=(destData[i])|| (destData[i]=new Vector2());
  3823. (value).cloneTo(v2);
  3824. destData[i]=v2;
  3825. dest.setVector2(i,v2);
  3826. }else if ((value instanceof laya.d3.math.Vector3 )){
  3827. var v3=(destData[i])|| (destData[i]=new Vector3());
  3828. (value).cloneTo(v3);
  3829. destData[i]=v3;
  3830. dest.setVector3(i,v3);
  3831. }else if ((value instanceof laya.d3.math.Vector4 )){
  3832. var v4=(destData[i])|| (destData[i]=new Vector4());
  3833. (value).cloneTo(v4);
  3834. destData[i]=v4;
  3835. dest.setVector(i,v4);
  3836. }else if ((value instanceof laya.d3.math.Matrix4x4 )){
  3837. var mat=(destData[i])|| (destData[i]=new Matrix4x4());
  3838. (value).cloneTo(mat);
  3839. destData[i]=mat;
  3840. dest.setMatrix4x4(i,mat);
  3841. }else if ((value instanceof laya.resource.BaseTexture )){
  3842. destData[i]=value;
  3843. dest.setTexture(i,value);
  3844. }
  3845. }
  3846. }
  3847. }
  3848. /**
  3849. *@private [NATIVE]
  3850. */
  3851. __proto._initDataForNative=function(){
  3852. var length=8;
  3853. if (!length){
  3854. alert("ShaderData _initDataForNative error length=0");
  3855. }
  3856. this._frameCount=-1;
  3857. this._runtimeCopyValues.length=0;
  3858. this._nativeArray=[];
  3859. this._data=new ArrayBuffer(length *4);
  3860. this._int32Data=new Int32Array(this._data);
  3861. this._float32Data=new Float32Array(this._data);
  3862. LayaGL.createArrayBufferRef(this._data,/*laya.layagl.LayaGL.ARRAY_BUFFER_TYPE_DATA*/0,true);
  3863. }
  3864. __proto.needRenewArrayBufferForNative=function(index){
  3865. if (index >=this._int32Data.length){
  3866. var nByteLen=(index+1)*4;
  3867. var pre=this._int32Data;
  3868. var preConchRef=this._data["conchRef"];
  3869. var prePtrID=this._data["_ptrID"];
  3870. this._data=new ArrayBuffer(nByteLen);
  3871. this._int32Data=new Int32Array(this._data);
  3872. this._float32Data=new Float32Array(this._data);
  3873. this._data["conchRef"]=preConchRef;
  3874. this._data["_ptrID"]=prePtrID;
  3875. pre && this._int32Data.set(pre,0);
  3876. /*__JS__ */conch.updateArrayBufferRef(this._data['_ptrID'],preConchRef.isSyncToRender(),this._data);
  3877. }
  3878. }
  3879. __proto.getDataForNative=function(){
  3880. return this._nativeArray;
  3881. }
  3882. /**
  3883. *@private [NATIVE]
  3884. */
  3885. __proto.getIntForNative=function(index){
  3886. return this._int32Data[index];
  3887. }
  3888. /**
  3889. *@private [NATIVE]
  3890. */
  3891. __proto.setIntForNative=function(index,value){
  3892. this.needRenewArrayBufferForNative(index);
  3893. this._int32Data[index]=value;
  3894. this._nativeArray[index]=value;
  3895. }
  3896. /**
  3897. *@private [NATIVE]
  3898. */
  3899. __proto.getBoolForNative=function(index){
  3900. return this._int32Data[index]==1;
  3901. }
  3902. /**
  3903. *@private [NATIVE]
  3904. */
  3905. __proto.setBoolForNative=function(index,value){
  3906. this.needRenewArrayBufferForNative(index);
  3907. this._int32Data[index]=value;
  3908. this._nativeArray[index]=value;
  3909. }
  3910. /**
  3911. *@private [NATIVE]
  3912. */
  3913. __proto.getNumberForNative=function(index){
  3914. return this._float32Data[index];
  3915. }
  3916. /**
  3917. *@private [NATIVE]
  3918. */
  3919. __proto.setNumberForNative=function(index,value){
  3920. this.needRenewArrayBufferForNative(index);
  3921. this._float32Data[index]=value;
  3922. this._nativeArray[index]=value;
  3923. }
  3924. /**
  3925. *@private [NATIVE]
  3926. */
  3927. __proto.getMatrix4x4ForNative=function(index){
  3928. return this._nativeArray[index];
  3929. }
  3930. /**
  3931. *@private [NATIVE]
  3932. */
  3933. __proto.setMatrix4x4ForNative=function(index,value){
  3934. this.needRenewArrayBufferForNative(index);
  3935. this._nativeArray[index]=value;
  3936. var nPtrID=this.setReferenceForNative(value.elements);
  3937. this._int32Data[index]=nPtrID;
  3938. }
  3939. /**
  3940. *@private [NATIVE]
  3941. */
  3942. __proto.getVectorForNative=function(index){
  3943. return this._nativeArray[index];
  3944. }
  3945. /**
  3946. *@private [NATIVE]
  3947. */
  3948. __proto.setVectorForNative=function(index,value){
  3949. this.needRenewArrayBufferForNative(index);
  3950. this._nativeArray[index]=value;
  3951. if (!value.elements){
  3952. value.forNativeElement();
  3953. };
  3954. var nPtrID=this.setReferenceForNative(value.elements);
  3955. this._int32Data[index]=nPtrID;
  3956. }
  3957. /**
  3958. *@private [NATIVE]
  3959. */
  3960. __proto.getVector2ForNative=function(index){
  3961. return this._nativeArray[index];
  3962. }
  3963. /**
  3964. *@private [NATIVE]
  3965. */
  3966. __proto.setVector2ForNative=function(index,value){
  3967. this.needRenewArrayBufferForNative(index);
  3968. this._nativeArray[index]=value;
  3969. if (!value.elements){
  3970. value.forNativeElement();
  3971. };
  3972. var nPtrID=this.setReferenceForNative(value.elements);
  3973. this._int32Data[index]=nPtrID;
  3974. }
  3975. /**
  3976. *@private [NATIVE]
  3977. */
  3978. __proto.getVector3ForNative=function(index){
  3979. return this._nativeArray[index];
  3980. }
  3981. /**
  3982. *@private [NATIVE]
  3983. */
  3984. __proto.setVector3ForNative=function(index,value){
  3985. this.needRenewArrayBufferForNative(index);
  3986. this._nativeArray[index]=value;
  3987. if (!value.elements){
  3988. value.forNativeElement();
  3989. };
  3990. var nPtrID=this.setReferenceForNative(value.elements);
  3991. this._int32Data[index]=nPtrID;
  3992. }
  3993. /**
  3994. *@private [NATIVE]
  3995. */
  3996. __proto.getQuaternionForNative=function(index){
  3997. return this._nativeArray[index];
  3998. }
  3999. /**
  4000. *@private [NATIVE]
  4001. */
  4002. __proto.setQuaternionForNative=function(index,value){
  4003. this.needRenewArrayBufferForNative(index);
  4004. this._nativeArray[index]=value;
  4005. if (!value.elements){
  4006. value.forNativeElement();
  4007. };
  4008. var nPtrID=this.setReferenceForNative(value.elements);
  4009. this._int32Data[index]=nPtrID;
  4010. }
  4011. /**
  4012. *@private [NATIVE]
  4013. */
  4014. __proto.getBufferForNative=function(shaderIndex){
  4015. return this._nativeArray[shaderIndex];
  4016. }
  4017. /**
  4018. *@private [NATIVE]
  4019. */
  4020. __proto.setBufferForNative=function(index,value){
  4021. this.needRenewArrayBufferForNative(index);
  4022. this._nativeArray[index]=value;
  4023. var nPtrID=this.setReferenceForNative(value);
  4024. this._int32Data[index]=nPtrID;
  4025. }
  4026. /**
  4027. *@private [NATIVE]
  4028. */
  4029. __proto.getAttributeForNative=function(index){
  4030. return this._nativeArray[index];
  4031. }
  4032. /**
  4033. *@private [NATIVE]
  4034. */
  4035. __proto.setAttributeForNative=function(index,value){
  4036. this._nativeArray[index]=value;
  4037. if (!value["_ptrID"]){
  4038. LayaGL.createArrayBufferRef(value,/*laya.layagl.LayaGL.ARRAY_BUFFER_TYPE_DATA*/0,true);
  4039. }
  4040. LayaGL.syncBufferToRenderThread(value);
  4041. this._int32Data[index]=value["_ptrID"];
  4042. }
  4043. /**
  4044. *@private [NATIVE]
  4045. */
  4046. __proto.getTextureForNative=function(index){
  4047. return this._nativeArray[index];
  4048. }
  4049. /**
  4050. *@private [NATIVE]
  4051. */
  4052. __proto.setTextureForNative=function(index,value){
  4053. if (!value)return;
  4054. this.needRenewArrayBufferForNative(index);
  4055. var lastValue=this._nativeArray[index];
  4056. this._nativeArray[index]=value;
  4057. this._int32Data[index]=(value)._glTexture.id;
  4058. if (this._ownerResource && this._ownerResource.referenceCount > 0){
  4059. (lastValue)&& (lastValue._removeReference());
  4060. (value)&& (value._addReference());
  4061. }
  4062. }
  4063. __proto.setReferenceForNative=function(value){
  4064. this.clearRuntimeCopyArray();
  4065. var nRefID=0;
  4066. var nPtrID=0;
  4067. if (ShaderData._SET_RUNTIME_VALUE_MODE_REFERENCE_){
  4068. LayaGL.createArrayBufferRefs(value,/*laya.layagl.LayaGL.ARRAY_BUFFER_TYPE_DATA*/0,true,/*laya.layagl.LayaGL.ARRAY_BUFFER_REF_REFERENCE*/0);
  4069. nRefID=0;
  4070. nPtrID=value.getPtrID(nRefID);
  4071. }else {
  4072. LayaGL.createArrayBufferRefs(value,/*laya.layagl.LayaGL.ARRAY_BUFFER_TYPE_DATA*/0,true,/*laya.layagl.LayaGL.ARRAY_BUFFER_REF_COPY*/1);
  4073. nRefID=value.getRefNum()-1;
  4074. nPtrID=value.getPtrID(nRefID);
  4075. this._runtimeCopyValues.push({"obj":value,"refID":nRefID,"ptrID":nPtrID});
  4076. }
  4077. LayaGL.syncBufferToRenderThread(value,nRefID);
  4078. return nPtrID;
  4079. }
  4080. __proto.clearRuntimeCopyArray=function(){
  4081. var currentFrame=LayaGL.getFrameCount();
  4082. if (this._frameCount !=currentFrame){
  4083. this._frameCount=currentFrame;
  4084. for (var i=0,n=this._runtimeCopyValues.length;i < n;i++){
  4085. var obj=this._runtimeCopyValues[i];
  4086. obj.obj.clearRefNum();
  4087. }
  4088. this._runtimeCopyValues.length=0;
  4089. }
  4090. }
  4091. ShaderData.setRuntimeValueMode=function(bReference){
  4092. ShaderData._SET_RUNTIME_VALUE_MODE_REFERENCE_=bReference;
  4093. }
  4094. ShaderData._SET_RUNTIME_VALUE_MODE_REFERENCE_=true;
  4095. return ShaderData;
  4096. })()
  4097. /**
  4098. *<code>TerrainLeaf</code> Terrain的叶子节点
  4099. */
  4100. //class laya.d3.terrain.TerrainLeaf
  4101. var TerrainLeaf=(function(){
  4102. function TerrainLeaf(){
  4103. this._boundingSphere=null;
  4104. this._boundingBox=null;
  4105. this._sizeOfY=null;
  4106. this._currentLODLevel=0;
  4107. this._lastDistanceToEye=NaN;
  4108. this._originalBoundingSphere=null;
  4109. this._originalBoundingBox=null;
  4110. this._originalBoundingBoxCorners=null;
  4111. this._bUseStrip=false;
  4112. this._gridSize=NaN;
  4113. this._beginGridX=0;
  4114. //针对整个大地形的偏移
  4115. this._beginGridZ=0;
  4116. //针对整个大地形的偏移
  4117. this._LODError=null;
  4118. TerrainLeaf.__init__();
  4119. this._currentLODLevel=0;
  4120. }
  4121. __class(TerrainLeaf,'laya.d3.terrain.TerrainLeaf');
  4122. var __proto=TerrainLeaf.prototype;
  4123. __proto.calcVertextNorml=function(x,z,terrainHeightData,heighDataWidth,heightDataHeight,normal){
  4124. var dZ=0,dX=0;
  4125. dX=TerrainLeaf.getHeightFromTerrainHeightData(x-1,z-1,terrainHeightData,heighDataWidth,heightDataHeight)*-1.0;
  4126. dX+=TerrainLeaf.getHeightFromTerrainHeightData(x-1,z,terrainHeightData,heighDataWidth,heightDataHeight)*-1.0;
  4127. dX+=TerrainLeaf.getHeightFromTerrainHeightData(x-1,z+1,terrainHeightData,heighDataWidth,heightDataHeight)*-1.0;
  4128. dX+=TerrainLeaf.getHeightFromTerrainHeightData(x+1,z-1,terrainHeightData,heighDataWidth,heightDataHeight)*1.0;
  4129. dX+=TerrainLeaf.getHeightFromTerrainHeightData(x+1,z,terrainHeightData,heighDataWidth,heightDataHeight)*1.0;
  4130. dX+=TerrainLeaf.getHeightFromTerrainHeightData(x+1,z+1,terrainHeightData,heighDataWidth,heightDataHeight)*1.0;
  4131. dZ=TerrainLeaf.getHeightFromTerrainHeightData(x-1,z-1,terrainHeightData,heighDataWidth,heightDataHeight)*-1.0;
  4132. dZ+=TerrainLeaf.getHeightFromTerrainHeightData(x,z-1,terrainHeightData,heighDataWidth,heightDataHeight)*-1.0;
  4133. dZ+=TerrainLeaf.getHeightFromTerrainHeightData(x+1,z-1,terrainHeightData,heighDataWidth,heightDataHeight)*-1.0;
  4134. dZ+=TerrainLeaf.getHeightFromTerrainHeightData(x-1,z+1,terrainHeightData,heighDataWidth,heightDataHeight)*1.0;
  4135. dZ+=TerrainLeaf.getHeightFromTerrainHeightData(x,z+1,terrainHeightData,heighDataWidth,heightDataHeight)*1.0;
  4136. dZ+=TerrainLeaf.getHeightFromTerrainHeightData(x+1,z+1,terrainHeightData,heighDataWidth,heightDataHeight)*1.0;
  4137. normal.x=-dX;
  4138. normal.y=6;
  4139. normal.z=-dZ;
  4140. Vector3.normalize(normal,normal);
  4141. }
  4142. __proto.calcVertextNormlUV=function(x,z,terrainWidth,terrainHeight,normal){
  4143. normal.x=x / terrainWidth;
  4144. normal.y=z / terrainHeight;
  4145. normal.z=z / terrainHeight;
  4146. }
  4147. __proto.calcVertextBuffer=function(offsetChunkX,offsetChunkZ,beginX,beginZ,girdSize,vertextBuffer,offset,strideSize,terrainHeightData,heighDataWidth,heightDataHeight,cameraCoordinateInverse){
  4148. if (cameraCoordinateInverse==true && !TerrainLeaf.__ADAPT_MATRIX__){
  4149. TerrainLeaf.__ADAPT_MATRIX__=new Matrix4x4();
  4150. var mat=new Matrix4x4();
  4151. Matrix4x4.createRotationY(Math.PI,TerrainLeaf.__ADAPT_MATRIX__);
  4152. Matrix4x4.createTranslate(new Vector3(0,0,(heightDataHeight-1)*girdSize),mat);
  4153. Matrix4x4.multiply(mat,TerrainLeaf.__ADAPT_MATRIX__,TerrainLeaf.__ADAPT_MATRIX__);
  4154. TerrainLeaf.__ADAPT_MATRIX_INV__=new Matrix4x4();
  4155. TerrainLeaf.__ADAPT_MATRIX__.invert(TerrainLeaf.__ADAPT_MATRIX_INV__);
  4156. }
  4157. this._gridSize=girdSize;
  4158. this._beginGridX=offsetChunkX *TerrainLeaf.CHUNK_GRID_NUM+beginX;
  4159. this._beginGridZ=offsetChunkZ *TerrainLeaf.CHUNK_GRID_NUM+beginZ;
  4160. var nNum=offset *strideSize;
  4161. var minY=2147483647;
  4162. var maxY=-2147483648;
  4163. var normal=new Vector3();
  4164. for (var i=0,s=TerrainLeaf.LEAF_GRID_NUM+1;i < s;i++){
  4165. for (var j=0,s1=TerrainLeaf.LEAF_GRID_NUM+1;j < s1;j++){
  4166. TerrainLeaf.__VECTOR3__.x=(this._beginGridX+j)*this._gridSize;
  4167. TerrainLeaf.__VECTOR3__.z=(this._beginGridZ+i)*this._gridSize;
  4168. TerrainLeaf.__VECTOR3__.y=terrainHeightData[(this._beginGridZ+i)*(heighDataWidth)+(this._beginGridX+j)];
  4169. minY=TerrainLeaf.__VECTOR3__.y < minY ? TerrainLeaf.__VECTOR3__.y :minY;
  4170. maxY=TerrainLeaf.__VECTOR3__.y > maxY ? TerrainLeaf.__VECTOR3__.y :maxY;
  4171. if (TerrainLeaf.__ADAPT_MATRIX__){
  4172. Vector3.transformV3ToV3(TerrainLeaf.__VECTOR3__,TerrainLeaf.__ADAPT_MATRIX__,TerrainLeaf.__VECTOR3__);
  4173. }
  4174. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.x;
  4175. nNum++;
  4176. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.y;
  4177. nNum++;
  4178. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.z;
  4179. nNum++;
  4180. this.calcVertextNormlUV(this._beginGridX+j,this._beginGridZ+i,heighDataWidth,heightDataHeight,normal);
  4181. vertextBuffer[nNum]=normal.x;
  4182. nNum++;
  4183. vertextBuffer[nNum]=normal.y;
  4184. nNum++;
  4185. vertextBuffer[nNum]=normal.z;
  4186. nNum++;
  4187. vertextBuffer[nNum]=(beginX+j)/ TerrainLeaf.CHUNK_GRID_NUM;
  4188. nNum++;
  4189. vertextBuffer[nNum]=(beginZ+i)/ TerrainLeaf.CHUNK_GRID_NUM;
  4190. nNum++;
  4191. vertextBuffer[nNum]=this._beginGridX+j;
  4192. nNum++;
  4193. vertextBuffer[nNum]=this._beginGridZ+i;
  4194. nNum++;
  4195. }
  4196. }
  4197. this._sizeOfY=new Vector2(minY-1,maxY+1);
  4198. this.calcLODErrors(terrainHeightData,heighDataWidth,heightDataHeight);
  4199. this.calcOriginalBoudingBoxAndSphere();
  4200. }
  4201. __proto.calcSkirtVertextBuffer=function(offsetChunkX,offsetChunkZ,beginX,beginZ,girdSize,vertextBuffer,offset,strideSize,terrainHeightData,heighDataWidth,heightDataHeight){
  4202. this._gridSize=girdSize;
  4203. this._beginGridX=offsetChunkX *TerrainLeaf.CHUNK_GRID_NUM+beginX;
  4204. this._beginGridZ=offsetChunkZ *TerrainLeaf.CHUNK_GRID_NUM+beginZ;
  4205. var nNum=offset *strideSize;
  4206. var i=0,j=0,s=TerrainLeaf.LEAF_GRID_NUM+1;
  4207. var normal=new Vector3();
  4208. var hZIndex=0;
  4209. var hXIndex=0;
  4210. var h=0;
  4211. var zh=0;
  4212. var xh=0;
  4213. for (i=0;i < 2;i++){
  4214. for (j=0;j < s;j++){
  4215. TerrainLeaf.__VECTOR3__.x=(this._beginGridX+j)*this._gridSize;
  4216. TerrainLeaf.__VECTOR3__.y=(i==1 ? terrainHeightData[this._beginGridZ *heighDataWidth+(this._beginGridX+j)] :-this._gridSize);
  4217. TerrainLeaf.__VECTOR3__.z=(this._beginGridZ+0)*this._gridSize;
  4218. if (TerrainLeaf.__ADAPT_MATRIX__){
  4219. Vector3.transformV3ToV3(TerrainLeaf.__VECTOR3__,TerrainLeaf.__ADAPT_MATRIX__,TerrainLeaf.__VECTOR3__);
  4220. }
  4221. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.x;
  4222. nNum++;
  4223. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.y;
  4224. nNum++;
  4225. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.z;
  4226. nNum++;
  4227. if (i==0){
  4228. hZIndex=(this._beginGridZ-1);
  4229. }else {
  4230. hZIndex=this._beginGridZ;
  4231. }
  4232. this.calcVertextNormlUV(this._beginGridX+j,hZIndex,heighDataWidth,heightDataHeight,normal);
  4233. vertextBuffer[nNum]=normal.x;
  4234. nNum++;
  4235. vertextBuffer[nNum]=normal.y;
  4236. nNum++;
  4237. vertextBuffer[nNum]=normal.z;
  4238. nNum++;
  4239. vertextBuffer[nNum]=(beginX+j)/ TerrainLeaf.CHUNK_GRID_NUM;
  4240. nNum++;
  4241. vertextBuffer[nNum]=(beginZ+0)/ TerrainLeaf.CHUNK_GRID_NUM;
  4242. nNum++;
  4243. vertextBuffer[nNum]=this._beginGridX+j;
  4244. nNum++;
  4245. vertextBuffer[nNum]=hZIndex;
  4246. nNum++;
  4247. }
  4248. }
  4249. for (i=0;i < 2;i++){
  4250. for (j=0;j < s;j++){
  4251. TerrainLeaf.__VECTOR3__.x=(this._beginGridX+j)*this._gridSize;
  4252. TerrainLeaf.__VECTOR3__.y=(i==0 ? terrainHeightData[(this._beginGridZ+TerrainLeaf.LEAF_GRID_NUM)*(heighDataWidth)+(this._beginGridX+j)] :-this._gridSize);
  4253. TerrainLeaf.__VECTOR3__.z=(this._beginGridZ+TerrainLeaf.LEAF_GRID_NUM)*this._gridSize;
  4254. if (TerrainLeaf.__ADAPT_MATRIX__){
  4255. Vector3.transformV3ToV3(TerrainLeaf.__VECTOR3__,TerrainLeaf.__ADAPT_MATRIX__,TerrainLeaf.__VECTOR3__);
  4256. }
  4257. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.x;
  4258. nNum++;
  4259. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.y;
  4260. nNum++;
  4261. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.z;
  4262. nNum++;
  4263. if (i==0){
  4264. hZIndex=this._beginGridZ+TerrainLeaf.LEAF_GRID_NUM;
  4265. }else {
  4266. hZIndex=(this._beginGridZ+TerrainLeaf.LEAF_GRID_NUM+1);
  4267. }
  4268. this.calcVertextNormlUV(this._beginGridX+j,hZIndex,heighDataWidth,heightDataHeight,normal);
  4269. vertextBuffer[nNum]=normal.x;
  4270. nNum++;
  4271. vertextBuffer[nNum]=normal.y;
  4272. nNum++;
  4273. vertextBuffer[nNum]=normal.z;
  4274. nNum++;
  4275. vertextBuffer[nNum]=(beginX+j)/ TerrainLeaf.CHUNK_GRID_NUM;
  4276. nNum++;
  4277. vertextBuffer[nNum]=(beginZ+TerrainLeaf.LEAF_GRID_NUM)/ TerrainLeaf.CHUNK_GRID_NUM;
  4278. nNum++;
  4279. vertextBuffer[nNum]=this._beginGridX+j;
  4280. nNum++;
  4281. vertextBuffer[nNum]=hZIndex;
  4282. nNum++;
  4283. }
  4284. }
  4285. for (i=0;i < 2;i++){
  4286. for (j=0;j < s;j++){
  4287. TerrainLeaf.__VECTOR3__.x=(this._beginGridX+0)*this._gridSize;
  4288. TerrainLeaf.__VECTOR3__.y=(i==0 ? terrainHeightData[(this._beginGridZ+j)*(heighDataWidth)+(this._beginGridX+0)] :-this._gridSize);
  4289. TerrainLeaf.__VECTOR3__.z=(this._beginGridZ+j)*this._gridSize;
  4290. if (TerrainLeaf.__ADAPT_MATRIX__){
  4291. Vector3.transformV3ToV3(TerrainLeaf.__VECTOR3__,TerrainLeaf.__ADAPT_MATRIX__,TerrainLeaf.__VECTOR3__);
  4292. }
  4293. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.x;
  4294. nNum++;
  4295. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.y;
  4296. nNum++;
  4297. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.z;
  4298. nNum++;
  4299. if (i==0){
  4300. hXIndex=this._beginGridX;
  4301. }else {
  4302. hXIndex=(this._beginGridX-1);
  4303. }
  4304. this.calcVertextNormlUV(hXIndex,this._beginGridZ+j,heighDataWidth,heightDataHeight,normal);
  4305. vertextBuffer[nNum]=normal.x;
  4306. nNum++;
  4307. vertextBuffer[nNum]=normal.y;
  4308. nNum++;
  4309. vertextBuffer[nNum]=normal.z;
  4310. nNum++;
  4311. vertextBuffer[nNum]=(beginX+0)/ TerrainLeaf.CHUNK_GRID_NUM;
  4312. nNum++;
  4313. vertextBuffer[nNum]=(beginZ+j)/ TerrainLeaf.CHUNK_GRID_NUM;
  4314. nNum++;
  4315. vertextBuffer[nNum]=hXIndex;
  4316. nNum++;
  4317. vertextBuffer[nNum]=this._beginGridZ+j;
  4318. nNum++;
  4319. }
  4320. }
  4321. for (i=0;i < 2;i++){
  4322. for (j=0;j < s;j++){
  4323. TerrainLeaf.__VECTOR3__.x=(this._beginGridX+TerrainLeaf.LEAF_GRID_NUM)*this._gridSize;
  4324. TerrainLeaf.__VECTOR3__.y=(i==1 ? terrainHeightData[(this._beginGridZ+j)*(heighDataWidth)+(this._beginGridX+TerrainLeaf.LEAF_GRID_NUM)] :-this._gridSize);
  4325. TerrainLeaf.__VECTOR3__.z=(this._beginGridZ+j)*this._gridSize;
  4326. if (TerrainLeaf.__ADAPT_MATRIX__){
  4327. Vector3.transformV3ToV3(TerrainLeaf.__VECTOR3__,TerrainLeaf.__ADAPT_MATRIX__,TerrainLeaf.__VECTOR3__);
  4328. }
  4329. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.x;
  4330. nNum++;
  4331. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.y;
  4332. nNum++;
  4333. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.z;
  4334. nNum++;
  4335. if (i==0){
  4336. hXIndex=this._beginGridX+TerrainLeaf.LEAF_GRID_NUM+1;
  4337. }else {
  4338. hXIndex=this._beginGridX+TerrainLeaf.LEAF_GRID_NUM;
  4339. }
  4340. this.calcVertextNormlUV(hXIndex,this._beginGridZ+j,heighDataWidth,heightDataHeight,normal);
  4341. vertextBuffer[nNum]=normal.x;
  4342. nNum++;
  4343. vertextBuffer[nNum]=normal.y;
  4344. nNum++;
  4345. vertextBuffer[nNum]=normal.z;
  4346. nNum++;
  4347. vertextBuffer[nNum]=(beginX+TerrainLeaf.LEAF_GRID_NUM)/ TerrainLeaf.CHUNK_GRID_NUM;
  4348. nNum++;
  4349. vertextBuffer[nNum]=(beginZ+j)/ TerrainLeaf.CHUNK_GRID_NUM;
  4350. nNum++;
  4351. vertextBuffer[nNum]=hXIndex;
  4352. nNum++;
  4353. vertextBuffer[nNum]=this._beginGridZ+j;
  4354. nNum++;
  4355. }
  4356. }
  4357. }
  4358. __proto.calcOriginalBoudingBoxAndSphere=function(){
  4359. var min=new Vector3(this._beginGridX *this._gridSize,this._sizeOfY.x,this._beginGridZ *this._gridSize);
  4360. var max=new Vector3((this._beginGridX+TerrainLeaf.LEAF_GRID_NUM)*this._gridSize,this._sizeOfY.y,(this._beginGridZ+TerrainLeaf.LEAF_GRID_NUM)*this._gridSize);
  4361. if (TerrainLeaf.__ADAPT_MATRIX__){
  4362. Vector3.transformV3ToV3(min,TerrainLeaf.__ADAPT_MATRIX__,min);
  4363. Vector3.transformV3ToV3(max,TerrainLeaf.__ADAPT_MATRIX__,max);
  4364. }
  4365. this._originalBoundingBox=new BoundBox(min,max);
  4366. var size=new Vector3();
  4367. Vector3.subtract(max,min,size);
  4368. Vector3.scale(size,0.5,size);
  4369. var center=new Vector3();
  4370. Vector3.add(min,size,center);
  4371. this._originalBoundingSphere=new BoundSphere(center,Vector3.scalarLength(size));
  4372. this._originalBoundingBoxCorners=__newvec(8,null);
  4373. this._originalBoundingBox.getCorners(this._originalBoundingBoxCorners);
  4374. this._boundingBox=new BoundBox(new Vector3(-0.5,-0.5,-0.5),new Vector3(0.5,0.5,0.5));
  4375. this._boundingSphere=new BoundSphere(new Vector3(0,0,0),1);
  4376. }
  4377. __proto.calcLeafBoudingBox=function(worldMatrix){
  4378. for (var i=0;i < 8;i++){
  4379. Vector3.transformCoordinate(this._originalBoundingBoxCorners[i],worldMatrix,BaseRender._tempBoundBoxCorners[i]);
  4380. }
  4381. BoundBox.createfromPoints(BaseRender._tempBoundBoxCorners,this._boundingBox);
  4382. }
  4383. __proto.calcLeafBoudingSphere=function(worldMatrix,maxScale){
  4384. Vector3.transformCoordinate(this._originalBoundingSphere.center,worldMatrix,this._boundingSphere.center);
  4385. this._boundingSphere.radius=this._originalBoundingSphere.radius *maxScale;
  4386. }
  4387. __proto.calcLODErrors=function(terrainHeightData,heighDataWidth,heightDataHeight){
  4388. this._LODError=new Float32Array(TerrainLeaf._maxLODLevel+1);
  4389. var step=1;
  4390. for (var i=0,n=TerrainLeaf._maxLODLevel+1;i < n;i++){
  4391. var maxError=0;
  4392. for (var y=0,n1=TerrainLeaf.LEAF_GRID_NUM;y < n1;y+=step){
  4393. for (var x=0,n2=TerrainLeaf.LEAF_GRID_NUM;x < n2;x+=step){
  4394. var z00=terrainHeightData[(this._beginGridZ+y)*heighDataWidth+(this._beginGridX+x)];
  4395. var z10=terrainHeightData[(this._beginGridZ+y)*heighDataWidth+(this._beginGridX+x)+step];
  4396. var z01=terrainHeightData[(this._beginGridZ+y+step)*heighDataWidth+(this._beginGridX+x)];
  4397. var z11=terrainHeightData[(this._beginGridZ+y+step)*heighDataWidth+(this._beginGridX+x)+step];
  4398. for (var j=0;j < step;j++){
  4399. var ys=j / step;
  4400. for (var k=0;k < step;k++){
  4401. var xs=k / step;
  4402. var z=terrainHeightData[(this._beginGridZ+y+j)*heighDataWidth+(this._beginGridX+x)+k];
  4403. var iz=(xs+ys <=1)? (z00+(z10-z00)*xs+(z01-z00)*ys):(z11+(z01-z11)*(1-xs)+(z10-z11)*(1-ys));
  4404. var error=Math.abs(iz-z);
  4405. maxError=Math.max(maxError,error);
  4406. }
  4407. }
  4408. }
  4409. }
  4410. step *=2;
  4411. this._LODError[i]=maxError;
  4412. }
  4413. }
  4414. __proto.determineLod=function(eyePos,perspectiveFactor,tolerance,tolerAndPerspectiveChanged){
  4415. var nDistanceToEye=Vector3.distance(eyePos,this._boundingSphere.center);
  4416. var n=TerrainLeaf._maxLODLevel;
  4417. if (!tolerAndPerspectiveChanged){
  4418. if (this._lastDistanceToEye==nDistanceToEye){
  4419. return this._currentLODLevel;
  4420. }else if (this._lastDistanceToEye > nDistanceToEye){
  4421. n=this._currentLODLevel;
  4422. }
  4423. }
  4424. for (var i=n;i >=1;i--){
  4425. if (Terrain.LOD_DISTANCE_FACTOR *this._LODError[i] / nDistanceToEye *perspectiveFactor < tolerance){
  4426. this._currentLODLevel=i;
  4427. break ;
  4428. }
  4429. }
  4430. this._lastDistanceToEye=nDistanceToEye;
  4431. return this._currentLODLevel;
  4432. }
  4433. TerrainLeaf.__init__=function(){
  4434. if (!TerrainLeaf._bInit){
  4435. var nLeafNum=(TerrainLeaf.CHUNK_GRID_NUM / TerrainLeaf.LEAF_GRID_NUM)*(TerrainLeaf.CHUNK_GRID_NUM / TerrainLeaf.LEAF_GRID_NUM);
  4436. TerrainLeaf._planeLODIndex=__newvec(nLeafNum);
  4437. var i=0,j=0,k=0,n=0,n1=0,nOffset=0;
  4438. var nOriginIndexArray=null,nTempIndex=null;
  4439. for (i=0;i < nLeafNum;i++){
  4440. TerrainLeaf._planeLODIndex[i]=new Array(TerrainLeaf._maxLODLevel+1);
  4441. }
  4442. for (i=0,n=TerrainLeaf._maxLODLevel+1;i < n;i++){
  4443. TerrainLeaf._planeLODIndex[0][i]=TerrainLeaf.calcPlaneLODIndex(i);
  4444. }
  4445. for (i=1;i < nLeafNum;i++){
  4446. nOffset=i *TerrainLeaf.LEAF_PLANE_VERTEXT_COUNT;
  4447. for (j=0,n1=TerrainLeaf._maxLODLevel+1;j < n1;j++){
  4448. nOriginIndexArray=TerrainLeaf._planeLODIndex[0][j];
  4449. nTempIndex=new Uint16Array(nOriginIndexArray.length);
  4450. for (k=0;k < nOriginIndexArray.length;k++){
  4451. nTempIndex[k]=nOriginIndexArray[k]+nOffset;
  4452. }
  4453. TerrainLeaf._planeLODIndex[i][j]=nTempIndex;
  4454. }
  4455. }
  4456. TerrainLeaf._skirtLODIndex=__newvec(nLeafNum);
  4457. for (i=0;i < nLeafNum;i++){
  4458. TerrainLeaf._skirtLODIndex[i]=new Array(TerrainLeaf._maxLODLevel+1);
  4459. }
  4460. for (i=0,n=TerrainLeaf._maxLODLevel+1;i < n;i++){
  4461. TerrainLeaf._skirtLODIndex[0][i]=TerrainLeaf.calcSkirtLODIndex(i);
  4462. }
  4463. for (i=1;i < nLeafNum;i++){
  4464. nOffset=i *TerrainLeaf.LEAF_SKIRT_VERTEXT_COUNT;
  4465. for (j=0,n1=TerrainLeaf._maxLODLevel+1;j < n1;j++){
  4466. nOriginIndexArray=TerrainLeaf._skirtLODIndex[0][j];
  4467. nTempIndex=new Uint16Array(nOriginIndexArray.length);
  4468. for (k=0;k < nOriginIndexArray.length;k++){
  4469. nTempIndex[k]=nOriginIndexArray[k]+nOffset;
  4470. }
  4471. TerrainLeaf._skirtLODIndex[i][j]=nTempIndex;
  4472. }
  4473. }
  4474. TerrainLeaf._bInit=true;
  4475. }
  4476. }
  4477. TerrainLeaf.getPlaneLODIndex=function(leafIndex,LODLevel){
  4478. return TerrainLeaf._planeLODIndex[leafIndex][LODLevel];
  4479. }
  4480. TerrainLeaf.getSkirtLODIndex=function(leafIndex,LODLevel){
  4481. return TerrainLeaf._skirtLODIndex[leafIndex][LODLevel];
  4482. }
  4483. TerrainLeaf.calcPlaneLODIndex=function(level){
  4484. if (level > TerrainLeaf._maxLODLevel)level=TerrainLeaf._maxLODLevel;
  4485. var nGridNumAddOne=TerrainLeaf.LEAF_GRID_NUM+1;
  4486. var nNum=0;
  4487. var indexBuffer=null;
  4488. var nLODGridNum=laya.d3.terrain.TerrainLeaf.LEAF_GRID_NUM / Math.pow(2,level);
  4489. indexBuffer=new Uint16Array(nLODGridNum *nLODGridNum *6);
  4490. var nGridSpace=laya.d3.terrain.TerrainLeaf.LEAF_GRID_NUM / nLODGridNum;
  4491. for (var i=0;i < TerrainLeaf.LEAF_GRID_NUM;i+=nGridSpace){
  4492. for (var j=0;j < TerrainLeaf.LEAF_GRID_NUM;j+=nGridSpace){
  4493. indexBuffer[nNum]=(i+nGridSpace)*nGridNumAddOne+j;
  4494. nNum++;
  4495. indexBuffer[nNum]=i *nGridNumAddOne+j;
  4496. nNum++;
  4497. indexBuffer[nNum]=i *nGridNumAddOne+j+nGridSpace;
  4498. nNum++;
  4499. indexBuffer[nNum]=i *nGridNumAddOne+j+nGridSpace;
  4500. nNum++;
  4501. indexBuffer[nNum]=(i+nGridSpace)*nGridNumAddOne+j+nGridSpace;
  4502. nNum++;
  4503. indexBuffer[nNum]=(i+nGridSpace)*nGridNumAddOne+j;
  4504. nNum++;
  4505. }
  4506. }
  4507. return indexBuffer;
  4508. }
  4509. TerrainLeaf.calcSkirtLODIndex=function(level){
  4510. if (level > TerrainLeaf._maxLODLevel)level=TerrainLeaf._maxLODLevel;
  4511. var nSkirtIndexOffset=(TerrainLeaf.CHUNK_GRID_NUM / TerrainLeaf.LEAF_GRID_NUM)*(TerrainLeaf.CHUNK_GRID_NUM / TerrainLeaf.LEAF_GRID_NUM)*TerrainLeaf.LEAF_PLANE_VERTEXT_COUNT;
  4512. var nGridNumAddOne=TerrainLeaf.LEAF_GRID_NUM+1;
  4513. var nNum=0;
  4514. var indexBuffer=null;
  4515. var nLODGridNum=laya.d3.terrain.TerrainLeaf.LEAF_GRID_NUM / Math.pow(2,level);
  4516. indexBuffer=new Uint16Array(nLODGridNum *4 *6);
  4517. var nGridSpace=laya.d3.terrain.TerrainLeaf.LEAF_GRID_NUM / nLODGridNum;
  4518. for (var j=0;j < 4;j++){
  4519. for (var i=0;i < TerrainLeaf.LEAF_GRID_NUM;i+=nGridSpace){
  4520. indexBuffer[nNum]=nSkirtIndexOffset+nGridNumAddOne+i;
  4521. nNum++;
  4522. indexBuffer[nNum]=nSkirtIndexOffset+i;
  4523. nNum++;
  4524. indexBuffer[nNum]=nSkirtIndexOffset+i+nGridSpace;
  4525. nNum++;
  4526. indexBuffer[nNum]=nSkirtIndexOffset+i+nGridSpace;
  4527. nNum++;
  4528. indexBuffer[nNum]=nSkirtIndexOffset+nGridNumAddOne+i+nGridSpace;
  4529. nNum++;
  4530. indexBuffer[nNum]=nSkirtIndexOffset+nGridNumAddOne+i;
  4531. nNum++;
  4532. }
  4533. nSkirtIndexOffset+=nGridNumAddOne *2;
  4534. }
  4535. return indexBuffer;
  4536. }
  4537. TerrainLeaf.getHeightFromTerrainHeightData=function(x,z,terrainHeightData,heighDataWidth,heightDataHeight){
  4538. x=x < 0 ? 0 :x;
  4539. x=(x >=heighDataWidth)? heighDataWidth-1 :x;
  4540. z=z < 0 ? 0 :z;
  4541. z=(z >=heightDataHeight)? heightDataHeight-1 :z;
  4542. return terrainHeightData[z *heighDataWidth+x];
  4543. }
  4544. TerrainLeaf.CHUNK_GRID_NUM=64;
  4545. TerrainLeaf.LEAF_GRID_NUM=32;
  4546. TerrainLeaf.__ADAPT_MATRIX__=null;
  4547. TerrainLeaf.__ADAPT_MATRIX_INV__=null;
  4548. TerrainLeaf._planeLODIndex=null;
  4549. TerrainLeaf._skirtLODIndex=null;
  4550. TerrainLeaf._bInit=false;
  4551. __static(TerrainLeaf,
  4552. ['LEAF_PLANE_VERTEXT_COUNT',function(){return this.LEAF_PLANE_VERTEXT_COUNT=(TerrainLeaf.LEAF_GRID_NUM+1)*(TerrainLeaf.LEAF_GRID_NUM+1);},'LEAF_SKIRT_VERTEXT_COUNT',function(){return this.LEAF_SKIRT_VERTEXT_COUNT=(TerrainLeaf.LEAF_GRID_NUM+1)*2 *4;},'LEAF_VERTEXT_COUNT',function(){return this.LEAF_VERTEXT_COUNT=TerrainLeaf.LEAF_PLANE_VERTEXT_COUNT+TerrainLeaf.LEAF_SKIRT_VERTEXT_COUNT;},'LEAF_PLANE_MAX_INDEX_COUNT',function(){return this.LEAF_PLANE_MAX_INDEX_COUNT=TerrainLeaf.LEAF_GRID_NUM *TerrainLeaf.LEAF_GRID_NUM *6;},'LEAF_SKIRT_MAX_INDEX_COUNT',function(){return this.LEAF_SKIRT_MAX_INDEX_COUNT=TerrainLeaf.LEAF_GRID_NUM *4 *6;},'LEAF_MAX_INDEX_COUNT',function(){return this.LEAF_MAX_INDEX_COUNT=TerrainLeaf.LEAF_PLANE_MAX_INDEX_COUNT+TerrainLeaf.LEAF_SKIRT_MAX_INDEX_COUNT;},'__VECTOR3__',function(){return this.__VECTOR3__=new Vector3();},'_maxLODLevel',function(){return this._maxLODLevel=/*__JS__ */Math.log2(TerrainLeaf.LEAF_GRID_NUM);}
  4553. ]);
  4554. return TerrainLeaf;
  4555. })()
  4556. /**
  4557. *...
  4558. *@author ...
  4559. */
  4560. //class laya.d3.graphics.Vertex.VertexShuriKenParticle
  4561. var VertexShuriKenParticle=(function(){
  4562. function VertexShuriKenParticle(){}
  4563. __class(VertexShuriKenParticle,'laya.d3.graphics.Vertex.VertexShuriKenParticle');
  4564. VertexShuriKenParticle.PARTICLE_CORNERTEXTURECOORDINATE0=0;
  4565. VertexShuriKenParticle.PARTICLE_POSITION0=1;
  4566. VertexShuriKenParticle.PARTICLE_COLOR0=2;
  4567. VertexShuriKenParticle.PARTICLE_TEXTURECOORDINATE0=3;
  4568. VertexShuriKenParticle.PARTICLE_SHAPEPOSITIONSTARTLIFETIME=4;
  4569. VertexShuriKenParticle.PARTICLE_DIRECTIONTIME=5;
  4570. VertexShuriKenParticle.PARTICLE_STARTCOLOR0=6;
  4571. VertexShuriKenParticle.PARTICLE_ENDCOLOR0=7;
  4572. VertexShuriKenParticle.PARTICLE_STARTSIZE=8;
  4573. VertexShuriKenParticle.PARTICLE_STARTROTATION=9;
  4574. VertexShuriKenParticle.PARTICLE_STARTSPEED=10;
  4575. VertexShuriKenParticle.PARTICLE_RANDOM0=11;
  4576. VertexShuriKenParticle.PARTICLE_RANDOM1=12;
  4577. VertexShuriKenParticle.PARTICLE_SIMULATIONWORLDPOSTION=13;
  4578. VertexShuriKenParticle.PARTICLE_SIMULATIONWORLDROTATION=14;
  4579. return VertexShuriKenParticle;
  4580. })()
  4581. /**
  4582. *<code>SizeOverLifetime</code> 类用于粒子的生命周期尺寸。
  4583. */
  4584. //class laya.d3.core.particleShuriKen.module.SizeOverLifetime
  4585. var SizeOverLifetime=(function(){
  4586. function SizeOverLifetime(size){
  4587. /**@private */
  4588. this._size=null;
  4589. /**是否启用*/
  4590. this.enbale=false;
  4591. this._size=size;
  4592. }
  4593. __class(SizeOverLifetime,'laya.d3.core.particleShuriKen.module.SizeOverLifetime');
  4594. var __proto=SizeOverLifetime.prototype;
  4595. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  4596. /**
  4597. *克隆。
  4598. *@param destObject 克隆源。
  4599. */
  4600. __proto.cloneTo=function(destObject){
  4601. var destSizeOverLifetime=destObject;
  4602. this._size.cloneTo(destSizeOverLifetime._size);
  4603. destSizeOverLifetime.enbale=this.enbale;
  4604. }
  4605. /**
  4606. *克隆。
  4607. *@return 克隆副本。
  4608. */
  4609. __proto.clone=function(){
  4610. var destSize;
  4611. switch (this._size.type){
  4612. case 0:
  4613. if (this._size.separateAxes)
  4614. destSize=GradientSize.createByGradientSeparate(this._size.gradientX.clone(),this._size.gradientY.clone(),this._size.gradientZ.clone());
  4615. else
  4616. destSize=GradientSize.createByGradient(this._size.gradient.clone());
  4617. break ;
  4618. case 1:
  4619. if (this._size.separateAxes)
  4620. destSize=GradientSize.createByRandomTwoConstantSeparate(this._size.constantMinSeparate.clone(),this._size.constantMaxSeparate.clone());
  4621. else
  4622. destSize=GradientSize.createByRandomTwoConstant(this._size.constantMin,this._size.constantMax);
  4623. break ;
  4624. case 2:
  4625. if (this._size.separateAxes)
  4626. destSize=GradientSize.createByRandomTwoGradientSeparate(this._size.gradientXMin.clone(),this._size.gradientYMin.clone(),this._size.gradientZMin.clone(),this._size.gradientXMax.clone(),this._size.gradientYMax.clone(),this._size.gradientZMax.clone());
  4627. else
  4628. destSize=GradientSize.createByRandomTwoGradient(this._size.gradientMin.clone(),this._size.gradientMax.clone());
  4629. break ;
  4630. };
  4631. var destSizeOverLifetime=/*__JS__ */new this.constructor(destSize);
  4632. destSizeOverLifetime.enbale=this.enbale;
  4633. return destSizeOverLifetime;
  4634. }
  4635. /**
  4636. *获取尺寸。
  4637. */
  4638. __getset(0,__proto,'size',function(){
  4639. return this._size;
  4640. });
  4641. return SizeOverLifetime;
  4642. })()
  4643. /**
  4644. *<code>KeyFrame</code> 类用于创建关键帧实例。
  4645. */
  4646. //class laya.d3.core.Keyframe
  4647. var Keyframe=(function(){
  4648. function Keyframe(){
  4649. /**时间。*/
  4650. this.time=NaN;
  4651. }
  4652. __class(Keyframe,'laya.d3.core.Keyframe');
  4653. var __proto=Keyframe.prototype;
  4654. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  4655. /**
  4656. *克隆。
  4657. *@param destObject 克隆源。
  4658. */
  4659. __proto.cloneTo=function(destObject){
  4660. var destKeyFrame=destObject;
  4661. destKeyFrame.time=this.time;
  4662. }
  4663. /**
  4664. *克隆。
  4665. *@return 克隆副本。
  4666. */
  4667. __proto.clone=function(){
  4668. var dest=/*__JS__ */new this.constructor();
  4669. this.cloneTo(dest);
  4670. return dest;
  4671. }
  4672. return Keyframe;
  4673. })()
  4674. /**
  4675. *<code>Vector4</code> 类用于创建四维向量。
  4676. */
  4677. //class laya.d3.math.Vector4
  4678. var Vector4=(function(){
  4679. function Vector4(x,y,z,w){
  4680. /**X轴坐标*/
  4681. this.x=NaN;
  4682. /**Y轴坐标*/
  4683. this.y=NaN;
  4684. /**Z轴坐标*/
  4685. this.z=NaN;
  4686. /**W轴坐标*/
  4687. this.w=NaN;
  4688. (x===void 0)&& (x=0);
  4689. (y===void 0)&& (y=0);
  4690. (z===void 0)&& (z=0);
  4691. (w===void 0)&& (w=0);
  4692. this.x=x;
  4693. this.y=y;
  4694. this.z=z;
  4695. this.w=w;
  4696. }
  4697. __class(Vector4,'laya.d3.math.Vector4');
  4698. var __proto=Vector4.prototype;
  4699. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  4700. /**
  4701. *设置xyzw值。
  4702. *@param x X值。
  4703. *@param y Y值。
  4704. *@param z Z值。
  4705. *@param w W值。
  4706. */
  4707. __proto.setValue=function(x,y,z,w){
  4708. this.x=x;
  4709. this.y=y;
  4710. this.z=z;
  4711. this.w=w;
  4712. }
  4713. /**
  4714. *从Array数组拷贝值。
  4715. *@param array 数组。
  4716. *@param offset 数组偏移。
  4717. */
  4718. __proto.fromArray=function(array,offset){
  4719. (offset===void 0)&& (offset=0);
  4720. this.x=array[offset+0];
  4721. this.y=array[offset+1];
  4722. this.z=array[offset+2];
  4723. this.w=array[offset+3];
  4724. }
  4725. /**
  4726. *克隆。
  4727. *@param destObject 克隆源。
  4728. */
  4729. __proto.cloneTo=function(destObject){
  4730. var destVector4=destObject;
  4731. destVector4.x=this.x;
  4732. destVector4.y=this.y;
  4733. destVector4.z=this.z;
  4734. destVector4.w=this.w;
  4735. }
  4736. /**
  4737. *克隆。
  4738. *@return 克隆副本。
  4739. */
  4740. __proto.clone=function(){
  4741. var destVector4=/*__JS__ */new this.constructor();
  4742. this.cloneTo(destVector4);
  4743. return destVector4;
  4744. }
  4745. /**
  4746. *求四维向量的长度。
  4747. *@return 长度。
  4748. */
  4749. __proto.length=function(){
  4750. return Math.sqrt(this.x *this.x+this.y *this.y+this.z *this.z+this.w *this.w);
  4751. }
  4752. /**
  4753. *求四维向量长度的平方。
  4754. *@return 长度的平方。
  4755. */
  4756. __proto.lengthSquared=function(){
  4757. return this.x *this.x+this.y *this.y+this.z *this.z+this.w *this.w;
  4758. }
  4759. __proto.forNativeElement=function(nativeElements){
  4760. if (nativeElements){
  4761. /*__JS__ */this.elements=nativeElements;
  4762. /*__JS__ */this.elements[0]=this.x;
  4763. /*__JS__ */this.elements[1]=this.y;
  4764. /*__JS__ */this.elements[2]=this.z;
  4765. /*__JS__ */this.elements[3]=this.w;
  4766. }
  4767. else{
  4768. /*__JS__ */this.elements=new Float32Array([this.x,this.y,this.z,this.w]);
  4769. }
  4770. Vector2.rewriteNumProperty(this,"x",0);
  4771. Vector2.rewriteNumProperty(this,"y",1);
  4772. Vector2.rewriteNumProperty(this,"z",2);
  4773. Vector2.rewriteNumProperty(this,"w",3);
  4774. }
  4775. Vector4.lerp=function(a,b,t,out){
  4776. var ax=a.x,ay=a.y,az=a.z,aw=a.w;
  4777. out.x=ax+t *(b.x-ax);
  4778. out.y=ay+t *(b.y-ay);
  4779. out.z=az+t *(b.z-az);
  4780. out.w=aw+t *(b.w-aw);
  4781. }
  4782. Vector4.transformByM4x4=function(vector4,m4x4,out){
  4783. var vx=vector4.x;
  4784. var vy=vector4.y;
  4785. var vz=vector4.z;
  4786. var vw=vector4.w;
  4787. var me=m4x4.elements;
  4788. out.x=vx *me[0]+vy *me[4]+vz *me[8]+vw *me[12];
  4789. out.y=vx *me[1]+vy *me[5]+vz *me[9]+vw *me[13];
  4790. out.z=vx *me[2]+vy *me[6]+vz *me[10]+vw *me[14];
  4791. out.w=vx *me[3]+vy *me[7]+vz *me[11]+vw *me[15];
  4792. }
  4793. Vector4.equals=function(a,b){
  4794. return MathUtils3D.nearEqual(Math.abs(a.x),Math.abs(b.x))&& MathUtils3D.nearEqual(Math.abs(a.y),Math.abs(b.y))&& MathUtils3D.nearEqual(Math.abs(a.z),Math.abs(b.z))&& MathUtils3D.nearEqual(Math.abs(a.w),Math.abs(b.w));
  4795. }
  4796. Vector4.normalize=function(s,out){
  4797. var len=/*if err,please use iflash.method.xmlLength()*/s.length();
  4798. if (len > 0){
  4799. out.x=s.x *len;
  4800. out.y=s.y *len;
  4801. out.z=s.z *len;
  4802. out.w=s.w *len;
  4803. }
  4804. }
  4805. Vector4.add=function(a,b,out){
  4806. out.x=a.x+b.x;
  4807. out.y=a.y+b.y;
  4808. out.z=a.z+b.z;
  4809. out.w=a.w+b.w;
  4810. }
  4811. Vector4.subtract=function(a,b,out){
  4812. out.x=a.x-b.x;
  4813. out.y=a.y-b.y;
  4814. out.z=a.z-b.z;
  4815. out.w=a.w-b.w;
  4816. }
  4817. Vector4.multiply=function(a,b,out){
  4818. out.x=a.x *b.x;
  4819. out.y=a.y *b.y;
  4820. out.z=a.z *b.z;
  4821. out.w=a.w *b.w;
  4822. }
  4823. Vector4.scale=function(a,b,out){
  4824. out.x=a.x *b;
  4825. out.y=a.y *b;
  4826. out.z=a.z *b;
  4827. out.w=a.w *b;
  4828. }
  4829. Vector4.Clamp=function(value,min,max,out){
  4830. var x=value.x;
  4831. var y=value.y;
  4832. var z=value.z;
  4833. var w=value.w;
  4834. var mineX=min.x;
  4835. var mineY=min.y;
  4836. var mineZ=min.z;
  4837. var mineW=min.w;
  4838. var maxeX=max.x;
  4839. var maxeY=max.y;
  4840. var maxeZ=max.z;
  4841. var maxeW=max.w;
  4842. x=(x > maxeX)? maxeX :x;
  4843. x=(x < mineX)? mineX :x;
  4844. y=(y > maxeY)? maxeY :y;
  4845. y=(y < mineY)? mineY :y;
  4846. z=(z > maxeZ)? maxeZ :z;
  4847. z=(z < mineZ)? mineZ :z;
  4848. w=(w > maxeW)? maxeW :w;
  4849. w=(w < mineW)? mineW :w;
  4850. out.x=x;
  4851. out.y=y;
  4852. out.z=z;
  4853. out.w=w;
  4854. }
  4855. Vector4.distanceSquared=function(value1,value2){
  4856. var x=value1.x-value2.x;
  4857. var y=value1.y-value2.y;
  4858. var z=value1.z-value2.z;
  4859. var w=value1.w-value2.w;
  4860. return (x *x)+(y *y)+(z *z)+(w *w);
  4861. }
  4862. Vector4.distance=function(value1,value2){
  4863. var x=value1.x-value2.x;
  4864. var y=value1.y-value2.y;
  4865. var z=value1.z-value2.z;
  4866. var w=value1.w-value2.w;
  4867. return Math.sqrt((x *x)+(y *y)+(z *z)+(w *w));
  4868. }
  4869. Vector4.dot=function(a,b){
  4870. return (a.x *b.x)+(a.y *b.y)+(a.z *b.z)+(a.w *b.w);
  4871. }
  4872. Vector4.min=function(a,b,out){
  4873. out.x=Math.min(a.x,b.x);
  4874. out.y=Math.min(a.y,b.y);
  4875. out.z=Math.min(a.z,b.z);
  4876. out.w=Math.min(a.w,b.w);
  4877. }
  4878. Vector4.max=function(a,b,out){
  4879. out.x=Math.max(a.x,b.x);
  4880. out.y=Math.max(a.y,b.y);
  4881. out.z=Math.max(a.z,b.z);
  4882. out.w=Math.max(a.w,b.w);
  4883. }
  4884. __static(Vector4,
  4885. ['ZERO',function(){return this.ZERO=new Vector4();},'ONE',function(){return this.ONE=new Vector4(1.0,1.0,1.0,1.0);},'UnitX',function(){return this.UnitX=new Vector4(1.0,0.0,0.0,0.0);},'UnitY',function(){return this.UnitY=new Vector4(0.0,1.0,0.0,0.0);},'UnitZ',function(){return this.UnitZ=new Vector4(0.0,0.0,1.0,0.0);},'UnitW',function(){return this.UnitW=new Vector4(0.0,0.0,0.0,1.0);}
  4886. ]);
  4887. return Vector4;
  4888. })()
  4889. /**
  4890. *@private
  4891. */
  4892. //class laya.d3.shader.ShaderDefines
  4893. var ShaderDefines=(function(){
  4894. function ShaderDefines(superDefines){
  4895. /**@private */
  4896. this._counter=0;
  4897. /**@private [只读]*/
  4898. this.defines={};
  4899. if (superDefines){
  4900. this._counter=superDefines._counter;
  4901. for (var k in superDefines.defines)
  4902. this.defines[k]=superDefines.defines[k];
  4903. }
  4904. }
  4905. __class(ShaderDefines,'laya.d3.shader.ShaderDefines');
  4906. var __proto=ShaderDefines.prototype;
  4907. /**
  4908. *@private
  4909. */
  4910. __proto.registerDefine=function(name){
  4911. var value=Math.pow(2,this._counter++);
  4912. this.defines[value]=name;
  4913. return value;
  4914. }
  4915. return ShaderDefines;
  4916. })()
  4917. /**
  4918. *<code>Vector3</code> 类用于创建三维向量。
  4919. */
  4920. //class laya.d3.math.Vector3
  4921. var Vector3=(function(){
  4922. function Vector3(x,y,z,nativeElements){
  4923. /**X轴坐标*/
  4924. this.x=NaN;
  4925. /**Y轴坐标*/
  4926. this.y=NaN;
  4927. /**Z轴坐标*/
  4928. this.z=NaN;
  4929. (x===void 0)&& (x=0);
  4930. (y===void 0)&& (y=0);
  4931. (z===void 0)&& (z=0);
  4932. this.x=x;
  4933. this.y=y;
  4934. this.z=z;
  4935. }
  4936. __class(Vector3,'laya.d3.math.Vector3');
  4937. var __proto=Vector3.prototype;
  4938. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  4939. /**
  4940. *设置xyz值。
  4941. *@param x X值。
  4942. *@param y Y值。
  4943. *@param z Z值。
  4944. */
  4945. __proto.setValue=function(x,y,z){
  4946. this.x=x;
  4947. this.y=y;
  4948. this.z=z;
  4949. }
  4950. /**
  4951. *从Array数组拷贝值。
  4952. *@param array 数组。
  4953. *@param offset 数组偏移。
  4954. */
  4955. __proto.fromArray=function(array,offset){
  4956. (offset===void 0)&& (offset=0);
  4957. this.x=array[offset+0];
  4958. this.y=array[offset+1];
  4959. this.z=array[offset+2];
  4960. }
  4961. /**
  4962. *克隆。
  4963. *@param destObject 克隆源。
  4964. */
  4965. __proto.cloneTo=function(destObject){
  4966. var destVector3=destObject;
  4967. destVector3.x=this.x;
  4968. destVector3.y=this.y;
  4969. destVector3.z=this.z;
  4970. }
  4971. /**
  4972. *克隆。
  4973. *@return 克隆副本。
  4974. */
  4975. __proto.clone=function(){
  4976. var destVector3=/*__JS__ */new this.constructor();
  4977. this.cloneTo(destVector3);
  4978. return destVector3;
  4979. }
  4980. __proto.toDefault=function(){
  4981. this.x=0;
  4982. this.y=0;
  4983. this.z=0;
  4984. }
  4985. __proto.forNativeElement=function(nativeElements){
  4986. if (nativeElements){
  4987. /*__JS__ */this.elements=nativeElements;
  4988. /*__JS__ */this.elements[0]=this.x;
  4989. /*__JS__ */this.elements[1]=this.y;
  4990. /*__JS__ */this.elements[2]=this.z;
  4991. }
  4992. else{
  4993. /*__JS__ */this.elements=new Float32Array([this.x,this.y,this.z]);
  4994. }
  4995. Vector2.rewriteNumProperty(this,"x",0);
  4996. Vector2.rewriteNumProperty(this,"y",1);
  4997. Vector2.rewriteNumProperty(this,"z",2);
  4998. }
  4999. Vector3.distanceSquared=function(value1,value2){
  5000. var x=value1.x-value2.x;
  5001. var y=value1.y-value2.y;
  5002. var z=value1.z-value2.z;
  5003. return (x *x)+(y *y)+(z *z);
  5004. }
  5005. Vector3.distance=function(value1,value2){
  5006. var x=value1.x-value2.x;
  5007. var y=value1.y-value2.y;
  5008. var z=value1.z-value2.z;
  5009. return Math.sqrt((x *x)+(y *y)+(z *z));
  5010. }
  5011. Vector3.min=function(a,b,out){
  5012. out.x=Math.min(a.x,b.x);
  5013. out.y=Math.min(a.y,b.y);
  5014. out.z=Math.min(a.z,b.z);
  5015. }
  5016. Vector3.max=function(a,b,out){
  5017. out.x=Math.max(a.x,b.x);
  5018. out.y=Math.max(a.y,b.y);
  5019. out.z=Math.max(a.z,b.z);
  5020. }
  5021. Vector3.transformQuat=function(source,rotation,out){
  5022. var x=source.x,y=source.y,z=source.z,qx=rotation.x,qy=rotation.y,qz=rotation.z,qw=rotation.w,
  5023. ix=qw *x+qy *z-qz *y,iy=qw *y+qz *x-qx *z,iz=qw *z+qx *y-qy *x,iw=-qx *x-qy *y-qz *z;
  5024. out.x=ix *qw+iw *-qx+iy *-qz-iz *-qy;
  5025. out.y=iy *qw+iw *-qy+iz *-qx-ix *-qz;
  5026. out.z=iz *qw+iw *-qz+ix *-qy-iy *-qx;
  5027. }
  5028. Vector3.scalarLength=function(a){
  5029. var x=a.x,y=a.y,z=a.z;
  5030. return Math.sqrt(x *x+y *y+z *z);
  5031. }
  5032. Vector3.scalarLengthSquared=function(a){
  5033. var x=a.x,y=a.y,z=a.z;
  5034. return x *x+y *y+z *z;
  5035. }
  5036. Vector3.normalize=function(s,out){
  5037. var x=s.x,y=s.y,z=s.z;
  5038. var len=x *x+y *y+z *z;
  5039. if (len > 0){
  5040. len=1 / Math.sqrt(len);
  5041. out.x=s.x *len;
  5042. out.y=s.y *len;
  5043. out.z=s.z *len;
  5044. }
  5045. }
  5046. Vector3.multiply=function(a,b,out){
  5047. out.x=a.x *b.x;
  5048. out.y=a.y *b.y;
  5049. out.z=a.z *b.z;
  5050. }
  5051. Vector3.scale=function(a,b,out){
  5052. out.x=a.x *b;
  5053. out.y=a.y *b;
  5054. out.z=a.z *b;
  5055. }
  5056. Vector3.lerp=function(a,b,t,out){
  5057. var ax=a.x,ay=a.y,az=a.z;
  5058. out.x=ax+t *(b.x-ax);
  5059. out.y=ay+t *(b.y-ay);
  5060. out.z=az+t *(b.z-az);
  5061. }
  5062. Vector3.transformV3ToV3=function(vector,transform,result){
  5063. var intermediate=Vector3._tempVector4;
  5064. Vector3.transformV3ToV4(vector,transform,intermediate);
  5065. result.x=intermediate.x;
  5066. result.y=intermediate.y;
  5067. result.z=intermediate.z;
  5068. }
  5069. Vector3.transformV3ToV4=function(vector,transform,result){
  5070. var vectorX=vector.x;
  5071. var vectorY=vector.y;
  5072. var vectorZ=vector.z;
  5073. var transformElem=transform.elements;
  5074. result.x=(vectorX *transformElem[0])+(vectorY *transformElem[4])+(vectorZ *transformElem[8])+transformElem[12];
  5075. result.y=(vectorX *transformElem[1])+(vectorY *transformElem[5])+(vectorZ *transformElem[9])+transformElem[13];
  5076. result.z=(vectorX *transformElem[2])+(vectorY *transformElem[6])+(vectorZ *transformElem[10])+transformElem[14];
  5077. result.w=(vectorX *transformElem[3])+(vectorY *transformElem[7])+(vectorZ *transformElem[11])+transformElem[15];
  5078. }
  5079. Vector3.TransformNormal=function(normal,transform,result){
  5080. var normalX=normal.x;
  5081. var normalY=normal.y;
  5082. var normalZ=normal.z;
  5083. var transformElem=transform.elements;
  5084. result.x=(normalX *transformElem[0])+(normalY *transformElem[4])+(normalZ *transformElem[8]);
  5085. result.y=(normalX *transformElem[1])+(normalY *transformElem[5])+(normalZ *transformElem[9]);
  5086. result.z=(normalX *transformElem[2])+(normalY *transformElem[6])+(normalZ *transformElem[10]);
  5087. }
  5088. Vector3.transformCoordinate=function(coordinate,transform,result){
  5089. var coordinateX=coordinate.x;
  5090. var coordinateY=coordinate.y;
  5091. var coordinateZ=coordinate.z;
  5092. var transformElem=transform.elements;
  5093. var w=((coordinateX *transformElem[3])+(coordinateY *transformElem[7])+(coordinateZ *transformElem[11])+transformElem[15]);
  5094. result.x=(coordinateX *transformElem[0])+(coordinateY *transformElem[4])+(coordinateZ *transformElem[8])+transformElem[12] / w;
  5095. result.y=(coordinateX *transformElem[1])+(coordinateY *transformElem[5])+(coordinateZ *transformElem[9])+transformElem[13] / w;
  5096. result.z=(coordinateX *transformElem[2])+(coordinateY *transformElem[6])+(coordinateZ *transformElem[10])+transformElem[14] / w;
  5097. }
  5098. Vector3.Clamp=function(value,min,max,out){
  5099. var x=value.x;
  5100. var y=value.y;
  5101. var z=value.z;
  5102. var mineX=min.x;
  5103. var mineY=min.y;
  5104. var mineZ=min.z;
  5105. var maxeX=max.x;
  5106. var maxeY=max.y;
  5107. var maxeZ=max.z;
  5108. x=(x > maxeX)? maxeX :x;
  5109. x=(x < mineX)? mineX :x;
  5110. y=(y > maxeY)? maxeY :y;
  5111. y=(y < mineY)? mineY :y;
  5112. z=(z > maxeZ)? maxeZ :z;
  5113. z=(z < mineZ)? mineZ :z;
  5114. out.x=x;
  5115. out.y=y;
  5116. out.z=z;
  5117. }
  5118. Vector3.add=function(a,b,out){
  5119. out.x=a.x+b.x;
  5120. out.y=a.y+b.y;
  5121. out.z=a.z+b.z;
  5122. }
  5123. Vector3.subtract=function(a,b,o){
  5124. o.x=a.x-b.x;
  5125. o.y=a.y-b.y;
  5126. o.z=a.z-b.z;
  5127. }
  5128. Vector3.cross=function(a,b,o){
  5129. var ax=a.x,ay=a.y,az=a.z,bx=b.x,by=b.y,bz=b.z;
  5130. o.x=ay *bz-az *by;
  5131. o.y=az *bx-ax *bz;
  5132. o.z=ax *by-ay *bx;
  5133. }
  5134. Vector3.dot=function(a,b){
  5135. return (a.x *b.x)+(a.y *b.y)+(a.z *b.z);
  5136. }
  5137. Vector3.equals=function(a,b){
  5138. return MathUtils3D.nearEqual(a.x,b.x)&& MathUtils3D.nearEqual(a.y,b.y)&& MathUtils3D.nearEqual(a.z,b.z);
  5139. }
  5140. Vector3._ZERO=new Vector3(0.0,0.0,0.0);
  5141. Vector3._ONE=new Vector3(1.0,1.0,1.0);
  5142. Vector3._NegativeUnitX=new Vector3(-1,0,0);
  5143. Vector3._UnitX=new Vector3(1,0,0);
  5144. Vector3._UnitY=new Vector3(0,1,0);
  5145. Vector3._UnitZ=new Vector3(0,0,1);
  5146. Vector3._ForwardRH=new Vector3(0,0,-1);
  5147. Vector3._ForwardLH=new Vector3(0,0,1);
  5148. Vector3._Up=new Vector3(0,1,0);
  5149. __static(Vector3,
  5150. ['_tempVector4',function(){return this._tempVector4=new Vector4();}
  5151. ]);
  5152. return Vector3;
  5153. })()
  5154. /**
  5155. *<code>Vector2</code> 类用于创建二维向量。
  5156. */
  5157. //class laya.d3.math.Vector2
  5158. var Vector2=(function(){
  5159. function Vector2(x,y){
  5160. /**X轴坐标*/
  5161. this.x=NaN;
  5162. /**Y轴坐标*/
  5163. this.y=NaN;
  5164. (x===void 0)&& (x=0);
  5165. (y===void 0)&& (y=0);
  5166. this.x=x;
  5167. this.y=y;
  5168. }
  5169. __class(Vector2,'laya.d3.math.Vector2');
  5170. var __proto=Vector2.prototype;
  5171. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  5172. /**
  5173. *设置xy值。
  5174. *@param x X值。
  5175. *@param y Y值。
  5176. */
  5177. __proto.setValue=function(x,y){
  5178. this.x=x;
  5179. this.y=y;
  5180. }
  5181. /**
  5182. *从Array数组拷贝值。
  5183. *@param array 数组。
  5184. *@param offset 数组偏移。
  5185. */
  5186. __proto.fromArray=function(array,offset){
  5187. (offset===void 0)&& (offset=0);
  5188. this.x=array[offset+0];
  5189. this.y=array[offset+1];
  5190. }
  5191. /**
  5192. *克隆。
  5193. *@param destObject 克隆源。
  5194. */
  5195. __proto.cloneTo=function(destObject){
  5196. var destVector2=destObject;
  5197. destVector2.x=this.x;
  5198. destVector2.y=this.y;
  5199. }
  5200. /**
  5201. *克隆。
  5202. *@return 克隆副本。
  5203. */
  5204. __proto.clone=function(){
  5205. var destVector2=/*__JS__ */new this.constructor();
  5206. this.cloneTo(destVector2);
  5207. return destVector2;
  5208. }
  5209. __proto.forNativeElement=function(nativeElements){
  5210. if (nativeElements){
  5211. /*__JS__ */this.elements=nativeElements;
  5212. /*__JS__ */this.elements[0]=this.x;
  5213. /*__JS__ */this.elements[1]=this.y;
  5214. }
  5215. else{
  5216. /*__JS__ */this.elements=new Float32Array([this.x,this.y]);
  5217. }
  5218. Vector2.rewriteNumProperty(this,"x",0);
  5219. Vector2.rewriteNumProperty(this,"y",1);
  5220. }
  5221. Vector2.scale=function(a,b,out){
  5222. out.x=a.x *b;
  5223. out.y=a.y *b;
  5224. }
  5225. Vector2.dot=function(a,b){
  5226. return (a.x *b.x)+(a.y *b.y);
  5227. }
  5228. Vector2.normalize=function(s,out){
  5229. var x=s.x,y=s.y;
  5230. var len=x *x+y *y;
  5231. if (len > 0){
  5232. len=1 / Math.sqrt(len);
  5233. out.x=x *len;
  5234. out.y=y *len;
  5235. }
  5236. }
  5237. Vector2.scalarLength=function(a){
  5238. var x=a.x,y=a.y;
  5239. return Math.sqrt(x *x+y *y);
  5240. }
  5241. Vector2.rewriteNumProperty=function(proto,name,index){
  5242. Object["defineProperty"](proto,name,{
  5243. "get":function (){
  5244. return /*__JS__ */this.elements[index];
  5245. },
  5246. "set":function (v){
  5247. /*__JS__ */this.elements[index]=v;
  5248. }
  5249. });
  5250. }
  5251. __static(Vector2,
  5252. ['ZERO',function(){return this.ZERO=new Vector2(0.0,0.0);},'ONE',function(){return this.ONE=new Vector2(1.0,1.0);}
  5253. ]);
  5254. return Vector2;
  5255. })()
  5256. /**
  5257. *<code>AnimatorPlayState</code> 类用于创建动画播放状态信息。
  5258. */
  5259. //class laya.d3.component.AnimatorPlayState
  5260. var AnimatorPlayState=(function(){
  5261. function AnimatorPlayState(){
  5262. /**@private */
  5263. //this._finish=false;
  5264. /**@private */
  5265. //this._startPlayTime=NaN;
  5266. /**@private */
  5267. //this._lastElapsedTime=NaN;
  5268. /**@private */
  5269. //this._elapsedTime=NaN;
  5270. /**@private */
  5271. //this._normalizedTime=NaN;
  5272. /**@private */
  5273. //this._normalizedPlayTime=NaN;
  5274. /**@private */
  5275. //this._duration=NaN;
  5276. /**@private */
  5277. //this._playEventIndex=0;
  5278. /**@private */
  5279. //this._lastIsFront=false;
  5280. }
  5281. __class(AnimatorPlayState,'laya.d3.component.AnimatorPlayState');
  5282. var __proto=AnimatorPlayState.prototype;
  5283. /**
  5284. *@private
  5285. */
  5286. __proto._resetPlayState=function(startTime){
  5287. this._finish=false;
  5288. this._startPlayTime=startTime;
  5289. this._elapsedTime=startTime;
  5290. this._playEventIndex=0;
  5291. this._lastIsFront=true;
  5292. }
  5293. /**
  5294. *@private
  5295. */
  5296. __proto._cloneTo=function(dest){
  5297. dest._finish=this._finish;
  5298. dest._startPlayTime=this._startPlayTime;
  5299. dest._elapsedTime=this._elapsedTime;
  5300. dest._playEventIndex=this._playEventIndex;
  5301. dest._lastIsFront=this._lastIsFront;
  5302. }
  5303. /**
  5304. *获取播放状态的归一化时间,整数为循环次数,小数为单次播放时间。
  5305. */
  5306. __getset(0,__proto,'normalizedTime',function(){
  5307. return this._normalizedTime;
  5308. });
  5309. /**
  5310. *获取当前动画的持续时间,以秒为单位。
  5311. */
  5312. __getset(0,__proto,'duration',function(){
  5313. return this._duration;
  5314. });
  5315. return AnimatorPlayState;
  5316. })()
  5317. /**
  5318. *<code>VelocityOverLifetime</code> 类用于粒子的生命周期速度。
  5319. */
  5320. //class laya.d3.core.particleShuriKen.module.VelocityOverLifetime
  5321. var VelocityOverLifetime=(function(){
  5322. function VelocityOverLifetime(velocity){
  5323. /**@private */
  5324. this._velocity=null;
  5325. /**是否启用*/
  5326. this.enbale=false;
  5327. /**速度空间,0为local,1为world。*/
  5328. this.space=0;
  5329. this._velocity=velocity;
  5330. }
  5331. __class(VelocityOverLifetime,'laya.d3.core.particleShuriKen.module.VelocityOverLifetime');
  5332. var __proto=VelocityOverLifetime.prototype;
  5333. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  5334. /**
  5335. *克隆。
  5336. *@param destObject 克隆源。
  5337. */
  5338. __proto.cloneTo=function(destObject){
  5339. var destVelocityOverLifetime=destObject;
  5340. this._velocity.cloneTo(destVelocityOverLifetime._velocity);
  5341. destVelocityOverLifetime.enbale=this.enbale;
  5342. destVelocityOverLifetime.space=this.space;
  5343. }
  5344. /**
  5345. *克隆。
  5346. *@return 克隆副本。
  5347. */
  5348. __proto.clone=function(){
  5349. var destVelocity;
  5350. switch(this._velocity.type){
  5351. case 0:
  5352. destVelocity=GradientVelocity.createByConstant(this._velocity.constant.clone());
  5353. break ;
  5354. case 1:
  5355. destVelocity=GradientVelocity.createByGradient(this._velocity.gradientX.clone(),this._velocity.gradientY.clone(),this._velocity.gradientZ.clone());
  5356. break ;
  5357. case 2:
  5358. destVelocity=GradientVelocity.createByRandomTwoConstant(this._velocity.constantMin.clone(),this._velocity.constantMax.clone());
  5359. break ;
  5360. case 3:
  5361. destVelocity=GradientVelocity.createByRandomTwoGradient(this._velocity.gradientXMin.clone(),this._velocity.gradientYMin.clone(),this._velocity.gradientZMin.clone(),this._velocity.gradientXMax.clone(),this._velocity.gradientYMax.clone(),this._velocity.gradientZMax.clone());
  5362. break ;
  5363. };
  5364. var destVelocityOverLifetime=/*__JS__ */new this.constructor(destVelocity);
  5365. destVelocityOverLifetime.enbale=this.enbale;
  5366. destVelocityOverLifetime.space=this.space;
  5367. return destVelocityOverLifetime;
  5368. }
  5369. /**
  5370. *获取尺寸。
  5371. */
  5372. __getset(0,__proto,'velocity',function(){
  5373. return this._velocity;
  5374. });
  5375. return VelocityOverLifetime;
  5376. })()
  5377. /**
  5378. *...
  5379. *@author ...
  5380. */
  5381. //class laya.d3.loaders.MeshReader
  5382. var MeshReader=(function(){
  5383. function MeshReader(){}
  5384. __class(MeshReader,'laya.d3.loaders.MeshReader');
  5385. MeshReader.read=function(data,mesh,subMeshes){
  5386. var readData=new Byte(data);
  5387. readData.pos=0;
  5388. var version=readData.readUTFString();
  5389. switch (version){
  5390. case "LAYAMODEL:0301":
  5391. case "LAYAMODEL:0400":
  5392. case "LAYAMODEL:0401":
  5393. LoadModelV04.parse(readData,version,mesh,subMeshes);
  5394. break ;
  5395. case "LAYAMODEL:05":
  5396. case "LAYAMODEL:COMPRESSION_05":
  5397. LoadModelV05.parse(readData,version,mesh,subMeshes);
  5398. break ;
  5399. default :
  5400. throw new Error("MeshReader: unknown mesh version.");
  5401. }
  5402. mesh._setSubMeshes(subMeshes);
  5403. }
  5404. return MeshReader;
  5405. })()
  5406. /**
  5407. *...
  5408. *@author ...
  5409. */
  5410. //class laya.d3.core.scene.SceneManager
  5411. var SceneManager=(function(){
  5412. function SceneManager(){}
  5413. __class(SceneManager,'laya.d3.core.scene.SceneManager');
  5414. return SceneManager;
  5415. })()
  5416. /**
  5417. *<code>ContainmentType</code> 类用于定义空间物体位置关系。
  5418. */
  5419. //class laya.d3.math.ContainmentType
  5420. var ContainmentType=(function(){
  5421. function ContainmentType(){}
  5422. __class(ContainmentType,'laya.d3.math.ContainmentType');
  5423. ContainmentType.Disjoint=0;
  5424. ContainmentType.Contains=1;
  5425. ContainmentType.Intersects=2;
  5426. return ContainmentType;
  5427. })()
  5428. /**
  5429. *@private
  5430. *<code>LoadModelV05</code> 类用于模型加载。
  5431. */
  5432. //class laya.d3.loaders.LoadModelV05
  5433. var LoadModelV05=(function(){
  5434. function LoadModelV05(){}
  5435. __class(LoadModelV05,'laya.d3.loaders.LoadModelV05');
  5436. LoadModelV05.parse=function(readData,version,mesh,subMeshes){
  5437. LoadModelV05._mesh=mesh;
  5438. LoadModelV05._subMeshes=subMeshes;
  5439. LoadModelV05._version=version;
  5440. LoadModelV05._readData=readData;
  5441. LoadModelV05.READ_DATA();
  5442. LoadModelV05.READ_BLOCK();
  5443. LoadModelV05.READ_STRINGS();
  5444. for (var i=0,n=LoadModelV05._BLOCK.count;i < n;i++){
  5445. LoadModelV05._readData.pos=LoadModelV05._BLOCK.blockStarts[i];
  5446. var index=LoadModelV05._readData.getUint16();
  5447. var blockName=LoadModelV05._strings[index];
  5448. var fn=LoadModelV05["READ_"+blockName];
  5449. if (fn==null)
  5450. throw new Error("model file err,no this function:"+index+" "+blockName);
  5451. else
  5452. fn.call(null);
  5453. }
  5454. LoadModelV05._mesh._bindPoseIndices=new Uint16Array(LoadModelV05._bindPoseIndices);
  5455. LoadModelV05._bindPoseIndices.length=0;
  5456. LoadModelV05._strings.length=0;
  5457. LoadModelV05._readData=null;
  5458. LoadModelV05._version=null;
  5459. LoadModelV05._mesh=null;
  5460. LoadModelV05._subMeshes=null;
  5461. }
  5462. LoadModelV05._readString=function(){
  5463. return LoadModelV05._strings[LoadModelV05._readData.getUint16()];
  5464. }
  5465. LoadModelV05.READ_DATA=function(){
  5466. LoadModelV05._DATA.offset=LoadModelV05._readData.getUint32();
  5467. LoadModelV05._DATA.size=LoadModelV05._readData.getUint32();
  5468. }
  5469. LoadModelV05.READ_BLOCK=function(){
  5470. var count=LoadModelV05._BLOCK.count=LoadModelV05._readData.getUint16();
  5471. var blockStarts=LoadModelV05._BLOCK.blockStarts=[];
  5472. var blockLengths=LoadModelV05._BLOCK.blockLengths=[];
  5473. for (var i=0;i < count;i++){
  5474. blockStarts.push(LoadModelV05._readData.getUint32());
  5475. blockLengths.push(LoadModelV05._readData.getUint32());
  5476. }
  5477. }
  5478. LoadModelV05.READ_STRINGS=function(){
  5479. var offset=LoadModelV05._readData.getUint32();
  5480. var count=LoadModelV05._readData.getUint16();
  5481. var prePos=LoadModelV05._readData.pos;
  5482. LoadModelV05._readData.pos=offset+LoadModelV05._DATA.offset;
  5483. for (var i=0;i < count;i++)
  5484. LoadModelV05._strings[i]=LoadModelV05._readData.readUTFString();
  5485. LoadModelV05._readData.pos=prePos;
  5486. }
  5487. LoadModelV05.READ_MESH=function(){
  5488. var i=0,n=0;
  5489. var memorySize=0;
  5490. var name=LoadModelV05._readString();
  5491. var arrayBuffer=LoadModelV05._readData.__getBuffer();
  5492. var vertexBufferCount=LoadModelV05._readData.getInt16();
  5493. var offset=LoadModelV05._DATA.offset;
  5494. for (i=0;i < vertexBufferCount;i++){
  5495. var vbStart=offset+LoadModelV05._readData.getUint32();
  5496. var vertexCount=LoadModelV05._readData.getUint32();
  5497. var vertexFlag=LoadModelV05._readString();
  5498. var vertexDeclaration=VertexMesh.getVertexDeclaration(vertexFlag,false);
  5499. var vertexStride=vertexDeclaration.vertexStride;
  5500. var vertexData=new ArrayBuffer(vertexStride *vertexCount);
  5501. var floatData=new Float32Array(vertexData);
  5502. var subVertexFlags=vertexFlag.split(",");
  5503. var subVertexCount=subVertexFlags.length;
  5504. switch (LoadModelV05._version){
  5505. case "LAYAMODEL:05":
  5506. floatData=new Float32Array(arrayBuffer.slice(vbStart,vbStart+vertexCount *vertexStride));
  5507. break ;
  5508. case "LAYAMODEL:COMPRESSION_05":;
  5509. var lastPosition=LoadModelV05._readData.pos;
  5510. floatData=new Float32Array(vertexData);
  5511. var uint8Data=new Uint8Array(vertexData);
  5512. LoadModelV05._readData.pos=vbStart;
  5513. for (var j=0;j < vertexCount;j++){
  5514. var subOffset=0;
  5515. var verOffset=j *vertexStride;
  5516. for (var k=0;k < subVertexCount;k++){
  5517. switch (subVertexFlags[k]){
  5518. case "POSITION":
  5519. subOffset=verOffset / 4;
  5520. floatData[subOffset]=HalfFloatUtils.convertToNumber(LoadModelV05._readData.getUint16());
  5521. floatData[subOffset+1]=HalfFloatUtils.convertToNumber(LoadModelV05._readData.getUint16());
  5522. floatData[subOffset+2]=HalfFloatUtils.convertToNumber(LoadModelV05._readData.getUint16());
  5523. verOffset+=12;
  5524. break ;
  5525. case "NORMAL":
  5526. subOffset=verOffset / 4;
  5527. floatData[subOffset]=LoadModelV05._readData.getUint8()/ 127.5-1;
  5528. floatData[subOffset+1]=LoadModelV05._readData.getUint8()/ 127.5-1;
  5529. floatData[subOffset+2]=LoadModelV05._readData.getUint8()/ 127.5-1;
  5530. verOffset+=12;
  5531. break ;
  5532. case "COLOR":
  5533. subOffset=verOffset / 4;
  5534. floatData[subOffset]=LoadModelV05._readData.getUint8()/ 255;
  5535. floatData[subOffset+1]=LoadModelV05._readData.getUint8()/ 255;
  5536. floatData[subOffset+2]=LoadModelV05._readData.getUint8()/ 255;
  5537. floatData[subOffset+3]=LoadModelV05._readData.getUint8()/ 255;
  5538. verOffset+=16;
  5539. break ;
  5540. case "UV":
  5541. subOffset=verOffset / 4;
  5542. floatData[subOffset]=HalfFloatUtils.convertToNumber(LoadModelV05._readData.getUint16());
  5543. floatData[subOffset+1]=HalfFloatUtils.convertToNumber(LoadModelV05._readData.getUint16());
  5544. verOffset+=8;
  5545. break ;
  5546. case "UV1":
  5547. subOffset=verOffset / 4;
  5548. floatData[subOffset]=HalfFloatUtils.convertToNumber(LoadModelV05._readData.getUint16());
  5549. floatData[subOffset+1]=HalfFloatUtils.convertToNumber(LoadModelV05._readData.getUint16());
  5550. verOffset+=8;
  5551. break ;
  5552. case "BLENDWEIGHT":
  5553. subOffset=verOffset / 4;
  5554. floatData[subOffset]=LoadModelV05._readData.getUint8()/ 255;
  5555. floatData[subOffset+1]=LoadModelV05._readData.getUint8()/ 255;
  5556. floatData[subOffset+2]=LoadModelV05._readData.getUint8()/ 255;
  5557. floatData[subOffset+3]=LoadModelV05._readData.getUint8()/ 255;
  5558. verOffset+=16;
  5559. break ;
  5560. case "BLENDINDICES":
  5561. uint8Data[verOffset]=LoadModelV05._readData.getUint8();
  5562. uint8Data[verOffset+1]=LoadModelV05._readData.getUint8();
  5563. uint8Data[verOffset+2]=LoadModelV05._readData.getUint8();
  5564. uint8Data[verOffset+3]=LoadModelV05._readData.getUint8();
  5565. verOffset+=4;
  5566. break ;
  5567. case "TANGENT":
  5568. subOffset=verOffset / 4;
  5569. floatData[subOffset]=LoadModelV05._readData.getUint8()/ 127.5-1;
  5570. floatData[subOffset+1]=LoadModelV05._readData.getUint8()/ 127.5-1;
  5571. floatData[subOffset+2]=LoadModelV05._readData.getUint8()/ 127.5-1;
  5572. floatData[subOffset+3]=LoadModelV05._readData.getUint8()/ 127.5-1;
  5573. verOffset+=16;
  5574. break ;
  5575. }
  5576. }
  5577. }
  5578. LoadModelV05._readData.pos=lastPosition;
  5579. break ;
  5580. };
  5581. var vertexBuffer=new VertexBuffer3D(vertexData.byteLength,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,true);
  5582. vertexBuffer.vertexDeclaration=vertexDeclaration;
  5583. vertexBuffer.setData(floatData);
  5584. LoadModelV05._mesh._vertexBuffers.push(vertexBuffer);
  5585. LoadModelV05._mesh._vertexCount+=vertexBuffer.vertexCount;
  5586. memorySize+=floatData.length *4;
  5587. };
  5588. var ibStart=offset+LoadModelV05._readData.getUint32();
  5589. var ibLength=LoadModelV05._readData.getUint32();
  5590. var ibDatas=new Uint16Array(arrayBuffer.slice(ibStart,ibStart+ibLength));
  5591. var indexBuffer=new IndexBuffer3D(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",ibLength / 2,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,true);
  5592. indexBuffer.setData(ibDatas);
  5593. LoadModelV05._mesh._indexBuffer=indexBuffer;
  5594. LoadModelV05._mesh._setBuffer(LoadModelV05._mesh._vertexBuffers,indexBuffer);
  5595. memorySize+=indexBuffer.indexCount *2;
  5596. LoadModelV05._mesh._setCPUMemory(memorySize);
  5597. LoadModelV05._mesh._setGPUMemory(memorySize);
  5598. var boneNames=LoadModelV05._mesh._boneNames=[];
  5599. var boneCount=LoadModelV05._readData.getUint16();
  5600. boneNames.length=boneCount;
  5601. for (i=0;i < boneCount;i++)
  5602. boneNames[i]=LoadModelV05._strings[LoadModelV05._readData.getUint16()];
  5603. var bindPoseDataStart=LoadModelV05._readData.getUint32();
  5604. var bindPoseDataLength=LoadModelV05._readData.getUint32();
  5605. var bindPoseDatas=new Float32Array(arrayBuffer.slice(offset+bindPoseDataStart,offset+bindPoseDataStart+bindPoseDataLength));
  5606. var bindPoseFloatCount=bindPoseDatas.length;
  5607. var bindPoseCount=bindPoseFloatCount / 16;
  5608. var bindPoseBuffer=LoadModelV05._mesh._inverseBindPosesBuffer=new ArrayBuffer(bindPoseFloatCount *4);
  5609. LoadModelV05._mesh._inverseBindPoses=__newvec(bindPoseCount);
  5610. for (i=0;i < bindPoseFloatCount;i+=16){
  5611. var inverseGlobalBindPose=new Matrix4x4(bindPoseDatas[i+0],bindPoseDatas[i+1],bindPoseDatas[i+2],bindPoseDatas[i+3],bindPoseDatas[i+4],bindPoseDatas[i+5],bindPoseDatas[i+6],bindPoseDatas[i+7],bindPoseDatas[i+8],bindPoseDatas[i+9],bindPoseDatas[i+10],bindPoseDatas[i+11],bindPoseDatas[i+12],bindPoseDatas[i+13],bindPoseDatas[i+14],bindPoseDatas[i+15],new Float32Array(bindPoseBuffer,i *4,16));
  5612. LoadModelV05._mesh._inverseBindPoses[i / 16]=inverseGlobalBindPose;
  5613. }
  5614. return true;
  5615. }
  5616. LoadModelV05.READ_SUBMESH=function(){
  5617. var arrayBuffer=LoadModelV05._readData.__getBuffer();
  5618. var submesh=new SubMesh(LoadModelV05._mesh);
  5619. var vbIndex=LoadModelV05._readData.getInt16();
  5620. var ibStart=LoadModelV05._readData.getUint32();
  5621. var ibCount=LoadModelV05._readData.getUint32();
  5622. var indexBuffer=LoadModelV05._mesh._indexBuffer;
  5623. submesh._indexBuffer=indexBuffer;
  5624. submesh._indexStart=ibStart;
  5625. submesh._indexCount=ibCount;
  5626. submesh._indices=new Uint16Array(indexBuffer.getData().buffer,ibStart *2,ibCount);
  5627. var vertexBuffer=LoadModelV05._mesh._vertexBuffers[vbIndex];
  5628. submesh._vertexBuffer=vertexBuffer;
  5629. var offset=LoadModelV05._DATA.offset;
  5630. var subIndexBufferStart=submesh._subIndexBufferStart;
  5631. var subIndexBufferCount=submesh._subIndexBufferCount;
  5632. var boneIndicesList=submesh._boneIndicesList;
  5633. var drawCount=LoadModelV05._readData.getUint16();
  5634. subIndexBufferStart.length=drawCount;
  5635. subIndexBufferCount.length=drawCount;
  5636. boneIndicesList.length=drawCount;
  5637. var pathMarks=LoadModelV05._mesh._skinDataPathMarks;
  5638. var bindPoseIndices=LoadModelV05._bindPoseIndices;
  5639. var subMeshIndex=LoadModelV05._subMeshes.length;
  5640. for (var i=0;i < drawCount;i++){
  5641. subIndexBufferStart[i]=LoadModelV05._readData.getUint32();
  5642. subIndexBufferCount[i]=LoadModelV05._readData.getUint32();
  5643. var boneDicofs=LoadModelV05._readData.getUint32();
  5644. var boneDicCount=LoadModelV05._readData.getUint32();
  5645. var boneIndices=boneIndicesList[i]=new Uint16Array(arrayBuffer.slice(offset+boneDicofs,offset+boneDicofs+boneDicCount));
  5646. for (var j=0,m=boneIndices.length;j < m;j++){
  5647. var index=boneIndices[j];
  5648. var combineIndex=bindPoseIndices.indexOf(index);
  5649. if (combineIndex===-1){
  5650. boneIndices[j]=bindPoseIndices.length;
  5651. bindPoseIndices.push(index);
  5652. pathMarks.push([subMeshIndex,i,j]);
  5653. }else {
  5654. boneIndices[j]=combineIndex;
  5655. }
  5656. }
  5657. }
  5658. LoadModelV05._subMeshes.push(submesh);
  5659. return true;
  5660. }
  5661. LoadModelV05._strings=[];
  5662. LoadModelV05._readData=null;
  5663. LoadModelV05._version=null;
  5664. LoadModelV05._mesh=null;
  5665. LoadModelV05._subMeshes=null;
  5666. LoadModelV05._bindPoseIndices=[];
  5667. __static(LoadModelV05,
  5668. ['_BLOCK',function(){return this._BLOCK={count:0};},'_DATA',function(){return this._DATA={offset:0,size:0};}
  5669. ]);
  5670. return LoadModelV05;
  5671. })()
  5672. /**
  5673. *<code>Color</code> 类用于创建颜色实例。
  5674. */
  5675. //class laya.d3.math.Color
  5676. var Color=(function(){
  5677. function Color(r,g,b,a){
  5678. /**red分量*/
  5679. this.r=NaN;
  5680. /**green分量*/
  5681. this.g=NaN;
  5682. /**blue分量*/
  5683. this.b=NaN;
  5684. /**alpha分量*/
  5685. this.a=NaN;
  5686. (r===void 0)&& (r=1);
  5687. (g===void 0)&& (g=1);
  5688. (b===void 0)&& (b=1);
  5689. (a===void 0)&& (a=1);
  5690. this.r=r;
  5691. this.g=g;
  5692. this.b=b;
  5693. this.a=a;
  5694. }
  5695. __class(Color,'laya.d3.math.Color');
  5696. var __proto=Color.prototype;
  5697. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  5698. /**
  5699. *Gamma空间转换到线性空间。
  5700. *@param linear 线性空间颜色。
  5701. */
  5702. __proto.toLinear=function(out){
  5703. out.r=Utils3D.gammaToLinearSpace(this.r);
  5704. out.g=Utils3D.gammaToLinearSpace(this.g);
  5705. out.b=Utils3D.gammaToLinearSpace(this.b);
  5706. }
  5707. /**
  5708. *线性空间转换到Gamma空间。
  5709. *@param gamma Gamma空间颜色。
  5710. */
  5711. __proto.toGamma=function(out){
  5712. out.r=Utils3D.linearToGammaSpace(this.r);
  5713. out.g=Utils3D.linearToGammaSpace(this.g);
  5714. out.b=Utils3D.linearToGammaSpace(this.b);
  5715. }
  5716. /**
  5717. *克隆。
  5718. *@param destObject 克隆源。
  5719. */
  5720. __proto.cloneTo=function(destObject){
  5721. var destColor=destObject;
  5722. destColor.r=this.r;
  5723. destColor.g=this.g;
  5724. destColor.b=this.b;
  5725. destColor.a=this.a;
  5726. }
  5727. /**
  5728. *克隆。
  5729. *@return 克隆副本。
  5730. */
  5731. __proto.clone=function(){
  5732. var dest=/*__JS__ */new this.constructor();
  5733. this.cloneTo(dest);
  5734. return dest;
  5735. }
  5736. __proto.forNativeElement=function(nativeElements){
  5737. if (nativeElements){
  5738. /*__JS__ */this.elements=nativeElements;
  5739. /*__JS__ */this.elements[0]=this.r;
  5740. /*__JS__ */this.elements[1]=this.g;
  5741. /*__JS__ */this.elements[2]=this.b;
  5742. /*__JS__ */this.elements[3]=this.a;
  5743. }else {
  5744. /*__JS__ */this.elements=new Float32Array([this.r,this.g,this.b,this.a]);
  5745. }
  5746. Vector2.rewriteNumProperty(this,"r",0);
  5747. Vector2.rewriteNumProperty(this,"g",1);
  5748. Vector2.rewriteNumProperty(this,"b",2);
  5749. Vector2.rewriteNumProperty(this,"a",3);
  5750. }
  5751. __static(Color,
  5752. ['RED',function(){return this.RED=new Color(1,0,0,1);},'GREEN',function(){return this.GREEN=new Color(0,1,0,1);},'BLUE',function(){return this.BLUE=new Color(0,0,1,1);},'CYAN',function(){return this.CYAN=new Color(0,1,1,1);},'YELLOW',function(){return this.YELLOW=new Color(1,0.92,0.016,1);},'MAGENTA',function(){return this.MAGENTA=new Color(1,0,1,1);},'GRAY',function(){return this.GRAY=new Color(0.5,0.5,0.5,1);},'WHITE',function(){return this.WHITE=new Color(1,1,1,1);},'BLACK',function(){return this.BLACK=new Color(0,0,0,1);}
  5753. ]);
  5754. return Color;
  5755. })()
  5756. /**
  5757. *@private
  5758. *<code>LoadModel</code> 类用于模型加载。
  5759. */
  5760. //class laya.d3.loaders.LoadModelV04
  5761. var LoadModelV04=(function(){
  5762. function LoadModelV04(){}
  5763. __class(LoadModelV04,'laya.d3.loaders.LoadModelV04');
  5764. LoadModelV04.parse=function(readData,version,mesh,subMeshes){
  5765. LoadModelV04._mesh=mesh;
  5766. LoadModelV04._subMeshes=subMeshes;
  5767. LoadModelV04._version=version;
  5768. LoadModelV04._readData=readData;
  5769. LoadModelV04.READ_DATA();
  5770. LoadModelV04.READ_BLOCK();
  5771. LoadModelV04.READ_STRINGS();
  5772. for (var i=0,n=LoadModelV04._BLOCK.count;i < n;i++){
  5773. LoadModelV04._readData.pos=LoadModelV04._BLOCK.blockStarts[i];
  5774. var index=LoadModelV04._readData.getUint16();
  5775. var blockName=LoadModelV04._strings[index];
  5776. var fn=LoadModelV04["READ_"+blockName];
  5777. if (fn==null)
  5778. throw new Error("model file err,no this function:"+index+" "+blockName);
  5779. else
  5780. fn.call(null);
  5781. }
  5782. LoadModelV04._mesh._bindPoseIndices=new Uint16Array(LoadModelV04._bindPoseIndices);
  5783. LoadModelV04._bindPoseIndices.length=0;
  5784. LoadModelV04._strings.length=0;
  5785. LoadModelV04._readData=null;
  5786. LoadModelV04._version=null;
  5787. LoadModelV04._mesh=null;
  5788. LoadModelV04._subMeshes=null;
  5789. }
  5790. LoadModelV04._readString=function(){
  5791. return LoadModelV04._strings[LoadModelV04._readData.getUint16()];
  5792. }
  5793. LoadModelV04.READ_DATA=function(){
  5794. LoadModelV04._DATA.offset=LoadModelV04._readData.getUint32();
  5795. LoadModelV04._DATA.size=LoadModelV04._readData.getUint32();
  5796. }
  5797. LoadModelV04.READ_BLOCK=function(){
  5798. var count=LoadModelV04._BLOCK.count=LoadModelV04._readData.getUint16();
  5799. var blockStarts=LoadModelV04._BLOCK.blockStarts=[];
  5800. var blockLengths=LoadModelV04._BLOCK.blockLengths=[];
  5801. for (var i=0;i < count;i++){
  5802. blockStarts.push(LoadModelV04._readData.getUint32());
  5803. blockLengths.push(LoadModelV04._readData.getUint32());
  5804. }
  5805. }
  5806. LoadModelV04.READ_STRINGS=function(){
  5807. var offset=LoadModelV04._readData.getUint32();
  5808. var count=LoadModelV04._readData.getUint16();
  5809. var prePos=LoadModelV04._readData.pos;
  5810. LoadModelV04._readData.pos=offset+LoadModelV04._DATA.offset;
  5811. for (var i=0;i < count;i++)
  5812. LoadModelV04._strings[i]=LoadModelV04._readData.readUTFString();
  5813. LoadModelV04._readData.pos=prePos;
  5814. }
  5815. LoadModelV04.READ_MESH=function(){
  5816. var name=LoadModelV04._readString();
  5817. var arrayBuffer=LoadModelV04._readData.__getBuffer();
  5818. var i=0,n=0;
  5819. var memorySize=0;
  5820. var vertexBufferCount=LoadModelV04._readData.getInt16();
  5821. var offset=LoadModelV04._DATA.offset;
  5822. for (i=0;i < vertexBufferCount;i++){
  5823. var vbStart=offset+LoadModelV04._readData.getUint32();
  5824. var vbLength=LoadModelV04._readData.getUint32();
  5825. var vbDatas=new Float32Array(arrayBuffer.slice(vbStart,vbStart+vbLength));
  5826. var bufferAttribute=LoadModelV04._readString();
  5827. var vertexDeclaration;
  5828. switch (LoadModelV04._version){
  5829. case "LAYAMODEL:0301":
  5830. case "LAYAMODEL:0400":
  5831. vertexDeclaration=VertexMesh.getVertexDeclaration(bufferAttribute);
  5832. break ;
  5833. case "LAYAMODEL:0401":
  5834. vertexDeclaration=VertexMesh.getVertexDeclaration(bufferAttribute,false);
  5835. break ;
  5836. default :
  5837. throw new Error("LoadModelV03: unknown version.");
  5838. }
  5839. if (!vertexDeclaration)
  5840. throw new Error("LoadModelV03: unknown vertexDeclaration.");
  5841. var vertexBuffer=new VertexBuffer3D(vbDatas.length *4,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,true);
  5842. vertexBuffer.vertexDeclaration=vertexDeclaration;
  5843. vertexBuffer.setData(vbDatas);
  5844. LoadModelV04._mesh._vertexBuffers.push(vertexBuffer);
  5845. LoadModelV04._mesh._vertexCount+=vertexBuffer.vertexCount;
  5846. memorySize+=vbDatas.length *4;
  5847. };
  5848. var ibStart=offset+LoadModelV04._readData.getUint32();
  5849. var ibLength=LoadModelV04._readData.getUint32();
  5850. var ibDatas=new Uint16Array(arrayBuffer.slice(ibStart,ibStart+ibLength));
  5851. var indexBuffer=new IndexBuffer3D(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",ibLength / 2,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,true);
  5852. indexBuffer.setData(ibDatas);
  5853. LoadModelV04._mesh._indexBuffer=indexBuffer;
  5854. memorySize+=indexBuffer.indexCount *2;
  5855. LoadModelV04._mesh._setBuffer(LoadModelV04._mesh._vertexBuffers,indexBuffer);
  5856. LoadModelV04._mesh._setCPUMemory(memorySize);
  5857. LoadModelV04._mesh._setGPUMemory(memorySize);
  5858. var boneNames=LoadModelV04._mesh._boneNames=[];
  5859. var boneCount=LoadModelV04._readData.getUint16();
  5860. boneNames.length=boneCount;
  5861. for (i=0;i < boneCount;i++)
  5862. boneNames[i]=LoadModelV04._strings[LoadModelV04._readData.getUint16()];
  5863. LoadModelV04._readData.pos+=8;
  5864. var bindPoseDataStart=LoadModelV04._readData.getUint32();
  5865. var bindPoseDataLength=LoadModelV04._readData.getUint32();
  5866. var bindPoseDatas=new Float32Array(arrayBuffer.slice(offset+bindPoseDataStart,offset+bindPoseDataStart+bindPoseDataLength));
  5867. var bindPoseFloatCount=bindPoseDatas.length;
  5868. var bindPoseCount=bindPoseFloatCount / 16;
  5869. var bindPoseBuffer=LoadModelV04._mesh._inverseBindPosesBuffer=new ArrayBuffer(bindPoseFloatCount *4);
  5870. LoadModelV04._mesh._inverseBindPoses=__newvec(bindPoseCount);
  5871. for (i=0;i < bindPoseFloatCount;i+=16){
  5872. var inverseGlobalBindPose=new Matrix4x4(bindPoseDatas[i+0],bindPoseDatas[i+1],bindPoseDatas[i+2],bindPoseDatas[i+3],bindPoseDatas[i+4],bindPoseDatas[i+5],bindPoseDatas[i+6],bindPoseDatas[i+7],bindPoseDatas[i+8],bindPoseDatas[i+9],bindPoseDatas[i+10],bindPoseDatas[i+11],bindPoseDatas[i+12],bindPoseDatas[i+13],bindPoseDatas[i+14],bindPoseDatas[i+15],new Float32Array(bindPoseBuffer,i *4,16));
  5873. LoadModelV04._mesh._inverseBindPoses[i / 16]=inverseGlobalBindPose;
  5874. }
  5875. return true;
  5876. }
  5877. LoadModelV04.READ_SUBMESH=function(){
  5878. var arrayBuffer=LoadModelV04._readData.__getBuffer();
  5879. var submesh=new SubMesh(LoadModelV04._mesh);
  5880. var vbIndex=LoadModelV04._readData.getInt16();
  5881. LoadModelV04._readData.getUint32();
  5882. LoadModelV04._readData.getUint32();
  5883. var ibStart=LoadModelV04._readData.getUint32();
  5884. var ibCount=LoadModelV04._readData.getUint32();
  5885. var indexBuffer=LoadModelV04._mesh._indexBuffer;
  5886. submesh._indexBuffer=indexBuffer;
  5887. submesh._indexStart=ibStart;
  5888. submesh._indexCount=ibCount;
  5889. submesh._indices=new Uint16Array(indexBuffer.getData().buffer,ibStart *2,ibCount);
  5890. var vertexBuffer=LoadModelV04._mesh._vertexBuffers[vbIndex];
  5891. submesh._vertexBuffer=vertexBuffer;
  5892. var offset=LoadModelV04._DATA.offset;
  5893. var subIndexBufferStart=submesh._subIndexBufferStart;
  5894. var subIndexBufferCount=submesh._subIndexBufferCount;
  5895. var boneIndicesList=submesh._boneIndicesList;
  5896. var drawCount=LoadModelV04._readData.getUint16();
  5897. subIndexBufferStart.length=drawCount;
  5898. subIndexBufferCount.length=drawCount;
  5899. boneIndicesList.length=drawCount;
  5900. var pathMarks=LoadModelV04._mesh._skinDataPathMarks;
  5901. var bindPoseIndices=LoadModelV04._bindPoseIndices;
  5902. var subMeshIndex=LoadModelV04._subMeshes.length;
  5903. for (var i=0;i < drawCount;i++){
  5904. subIndexBufferStart[i]=LoadModelV04._readData.getUint32();
  5905. subIndexBufferCount[i]=LoadModelV04._readData.getUint32();
  5906. var boneDicofs=LoadModelV04._readData.getUint32();
  5907. var boneDicCount=LoadModelV04._readData.getUint32();
  5908. var boneIndices=boneIndicesList[i]=new Uint16Array(arrayBuffer.slice(offset+boneDicofs,offset+boneDicofs+boneDicCount));
  5909. for (var j=0,m=boneIndices.length;j < m;j++){
  5910. var index=boneIndices[j];
  5911. var combineIndex=bindPoseIndices.indexOf(index);
  5912. if (combineIndex===-1){
  5913. boneIndices[j]=bindPoseIndices.length;
  5914. bindPoseIndices.push(index);
  5915. pathMarks.push([subMeshIndex,i,j]);
  5916. }else {
  5917. boneIndices[j]=combineIndex;
  5918. }
  5919. }
  5920. }
  5921. LoadModelV04._subMeshes.push(submesh);
  5922. return true;
  5923. }
  5924. LoadModelV04._strings=[];
  5925. LoadModelV04._readData=null;
  5926. LoadModelV04._version=null;
  5927. LoadModelV04._mesh=null;
  5928. LoadModelV04._subMeshes=null;
  5929. LoadModelV04._bindPoseIndices=[];
  5930. __static(LoadModelV04,
  5931. ['_BLOCK',function(){return this._BLOCK={count:0};},'_DATA',function(){return this._DATA={offset:0,size:0};}
  5932. ]);
  5933. return LoadModelV04;
  5934. })()
  5935. /**
  5936. *...
  5937. *@author ...
  5938. */
  5939. //class laya.d3.graphics.Vertex.VertexMesh
  5940. var VertexMesh=(function(){
  5941. function VertexMesh(){}
  5942. __class(VertexMesh,'laya.d3.graphics.Vertex.VertexMesh');
  5943. VertexMesh.getVertexDeclaration=function(vertexFlag,compatible){
  5944. (compatible===void 0)&& (compatible=true);
  5945. var verDec=VertexMesh._vertexDeclarationMap[vertexFlag+(compatible?"_0":"_1")];
  5946. if (!verDec){
  5947. var subFlags=vertexFlag.split(",");
  5948. var offset=0;
  5949. var elements=[];
  5950. for (var i=0,n=subFlags.length;i < n;i++){
  5951. var element;
  5952. switch (subFlags[i]){
  5953. case "POSITION":
  5954. element=new VertexElement(offset,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0);
  5955. offset+=12;
  5956. break ;
  5957. case "NORMAL":
  5958. element=new VertexElement(offset,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_NORMAL0*/3);
  5959. offset+=12;
  5960. break ;
  5961. case "COLOR":
  5962. element=new VertexElement(offset,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_COLOR0*/1);
  5963. offset+=16;
  5964. break ;
  5965. case "UV":
  5966. element=new VertexElement(offset,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE0*/2);
  5967. offset+=8;
  5968. break ;
  5969. case "UV1":
  5970. element=new VertexElement(offset,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE1*/7);
  5971. offset+=8;
  5972. break ;
  5973. case "BLENDWEIGHT":
  5974. element=new VertexElement(offset,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_BLENDWEIGHT0*/6);
  5975. offset+=16;
  5976. break ;
  5977. case "BLENDINDICES":
  5978. if (compatible){
  5979. element=new VertexElement(offset,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_BLENDINDICES0*/5);
  5980. offset+=16;
  5981. }else {
  5982. element=new VertexElement(offset,/*laya.d3.graphics.VertexElementFormat.Byte4*/"byte4",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_BLENDINDICES0*/5);
  5983. offset+=4;
  5984. }
  5985. break ;
  5986. case "TANGENT":
  5987. element=new VertexElement(offset,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_TANGENT0*/4);
  5988. offset+=16;
  5989. break ;
  5990. default :
  5991. throw "VertexMesh: unknown vertex flag.";
  5992. }
  5993. elements.push(element);
  5994. }
  5995. verDec=new VertexDeclaration(offset,elements);
  5996. VertexMesh._vertexDeclarationMap[vertexFlag+(compatible?"_0":"_1")]=verDec;
  5997. }
  5998. return verDec;
  5999. }
  6000. VertexMesh.MESH_POSITION0=0;
  6001. VertexMesh.MESH_COLOR0=1;
  6002. VertexMesh.MESH_TEXTURECOORDINATE0=2;
  6003. VertexMesh.MESH_NORMAL0=3;
  6004. VertexMesh.MESH_TANGENT0=4;
  6005. VertexMesh.MESH_BLENDINDICES0=5;
  6006. VertexMesh.MESH_BLENDWEIGHT0=6;
  6007. VertexMesh.MESH_TEXTURECOORDINATE1=7;
  6008. VertexMesh.MESH_WORLDMATRIX_ROW0=8;
  6009. VertexMesh.MESH_WORLDMATRIX_ROW1=9;
  6010. VertexMesh.MESH_WORLDMATRIX_ROW2=10;
  6011. VertexMesh.MESH_WORLDMATRIX_ROW3=11;
  6012. VertexMesh.MESH_MVPMATRIX_ROW0=12;
  6013. VertexMesh.MESH_MVPMATRIX_ROW1=13;
  6014. VertexMesh.MESH_MVPMATRIX_ROW2=14;
  6015. VertexMesh.MESH_MVPMATRIX_ROW3=15;
  6016. VertexMesh._vertexDeclarationMap={};
  6017. __static(VertexMesh,
  6018. ['instanceWorldMatrixDeclaration',function(){return this.instanceWorldMatrixDeclaration=new VertexDeclaration(64,
  6019. [new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_WORLDMATRIX_ROW0*/8),
  6020. new VertexElement(16,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_WORLDMATRIX_ROW1*/9),
  6021. new VertexElement(32,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_WORLDMATRIX_ROW2*/10),
  6022. new VertexElement(48,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_WORLDMATRIX_ROW3*/11)]);},'instanceMVPMatrixDeclaration',function(){return this.instanceMVPMatrixDeclaration=new VertexDeclaration(64,
  6023. [new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_MVPMATRIX_ROW0*/12),
  6024. new VertexElement(16,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_MVPMATRIX_ROW1*/13),
  6025. new VertexElement(32,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_MVPMATRIX_ROW2*/14),
  6026. new VertexElement(48,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_MVPMATRIX_ROW3*/15)]);}
  6027. ]);
  6028. return VertexMesh;
  6029. })()
  6030. /**
  6031. *<code>Emission</code> 类用于粒子发射器。
  6032. */
  6033. //class laya.d3.core.particleShuriKen.module.Emission
  6034. var Emission=(function(){
  6035. function Emission(){
  6036. /**@private */
  6037. this._destroyed=false;
  6038. /**@private 粒子发射速率,每秒发射的个数。*/
  6039. this._emissionRate=0;
  6040. /**@private 粒子的爆裂,不允许修改。*/
  6041. this._bursts=null;
  6042. /**是否启用。*/
  6043. this.enbale=false;
  6044. this._destroyed=false;
  6045. this.emissionRate=10;
  6046. this._bursts=[];
  6047. }
  6048. __class(Emission,'laya.d3.core.particleShuriKen.module.Emission');
  6049. var __proto=Emission.prototype;
  6050. Laya.imps(__proto,{"laya.d3.core.IClone":true,"laya.resource.IDestroy":true})
  6051. /**
  6052. *@private
  6053. */
  6054. __proto.destroy=function(){
  6055. this._bursts=null;
  6056. this._destroyed=true;
  6057. }
  6058. /**
  6059. *获取粒子爆裂个数。
  6060. *@return 粒子爆裂个数。
  6061. */
  6062. __proto.getBurstsCount=function(){
  6063. return this._bursts.length;
  6064. }
  6065. /**
  6066. *通过索引获取粒子爆裂。
  6067. *@param index 爆裂索引。
  6068. *@return 粒子爆裂。
  6069. */
  6070. __proto.getBurstByIndex=function(index){
  6071. return this._bursts[index];
  6072. }
  6073. /**
  6074. *增加粒子爆裂。
  6075. *@param burst 爆裂。
  6076. */
  6077. __proto.addBurst=function(burst){
  6078. var burstsCount=this._bursts.length;
  6079. if (burstsCount > 0)
  6080. for (var i=0;i < burstsCount;i++){
  6081. if (this._bursts[i].time > burst.time)
  6082. this._bursts.splice(i,0,burst);
  6083. }
  6084. this._bursts.push(burst);
  6085. }
  6086. /**
  6087. *移除粒子爆裂。
  6088. *@param burst 爆裂。
  6089. */
  6090. __proto.removeBurst=function(burst){
  6091. var index=this._bursts.indexOf(burst);
  6092. if (index!==-1){
  6093. this._bursts.splice(index,1);
  6094. }
  6095. }
  6096. /**
  6097. *通过索引移除粒子爆裂。
  6098. *@param index 爆裂索引。
  6099. */
  6100. __proto.removeBurstByIndex=function(index){
  6101. this._bursts.splice(index,1);
  6102. }
  6103. /**
  6104. *清空粒子爆裂。
  6105. */
  6106. __proto.clearBurst=function(){
  6107. this._bursts.length=0;
  6108. }
  6109. /**
  6110. *克隆。
  6111. *@param destObject 克隆源。
  6112. */
  6113. __proto.cloneTo=function(destObject){
  6114. var destEmission=destObject;
  6115. var destBursts=destEmission._bursts;
  6116. destBursts.length=this._bursts.length;
  6117. for (var i=0,n=this._bursts.length;i < n;i++){
  6118. var destBurst=destBursts[i];
  6119. if (destBurst)
  6120. this._bursts[i].cloneTo(destBurst);
  6121. else
  6122. destBursts[i]=this._bursts[i].clone();
  6123. }
  6124. destEmission._emissionRate=this._emissionRate;
  6125. destEmission.enbale=this.enbale;
  6126. }
  6127. /**
  6128. *克隆。
  6129. *@return 克隆副本。
  6130. */
  6131. __proto.clone=function(){
  6132. var destEmission=/*__JS__ */new this.constructor();
  6133. this.cloneTo(destEmission);
  6134. return destEmission;
  6135. }
  6136. /**
  6137. *获取是否已销毁。
  6138. *@return 是否已销毁。
  6139. */
  6140. __getset(0,__proto,'destroyed',function(){
  6141. return this._destroyed;
  6142. });
  6143. /**
  6144. *设置粒子发射速率。
  6145. *@param emissionRate 粒子发射速率 (个/秒)。
  6146. */
  6147. /**
  6148. *获取粒子发射速率。
  6149. *@return 粒子发射速率 (个/秒)。
  6150. */
  6151. __getset(0,__proto,'emissionRate',function(){
  6152. return this._emissionRate;
  6153. },function(value){
  6154. if (value < 0)
  6155. throw new Error("ParticleBaseShape:emissionRate value must large or equal than 0.");
  6156. this._emissionRate=value;
  6157. });
  6158. return Emission;
  6159. })()
  6160. /**
  6161. *<code>BoundSphere</code> 类用于创建包围球。
  6162. */
  6163. //class laya.d3.math.BoundSphere
  6164. var BoundSphere=(function(){
  6165. function BoundSphere(center,radius){
  6166. /**包围球的中心。*/
  6167. this.center=null;
  6168. /**包围球的半径。*/
  6169. this.radius=NaN;
  6170. this.center=center;
  6171. this.radius=radius;
  6172. }
  6173. __class(BoundSphere,'laya.d3.math.BoundSphere');
  6174. var __proto=BoundSphere.prototype;
  6175. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  6176. __proto.toDefault=function(){
  6177. this.center.toDefault();
  6178. this.radius=0;
  6179. }
  6180. /**
  6181. *判断射线是否与碰撞球交叉,并返回交叉距离。
  6182. *@param ray 射线。
  6183. *@return 距离交叉点的距离,-1表示不交叉。
  6184. */
  6185. __proto.intersectsRayDistance=function(ray){
  6186. return CollisionUtils.intersectsRayAndSphereRD(ray,this);
  6187. }
  6188. /**
  6189. *判断射线是否与碰撞球交叉,并返回交叉点。
  6190. *@param ray 射线。
  6191. *@param outPoint 交叉点。
  6192. *@return 距离交叉点的距离,-1表示不交叉。
  6193. */
  6194. __proto.intersectsRayPoint=function(ray,outPoint){
  6195. return CollisionUtils.intersectsRayAndSphereRP(ray,this,outPoint);
  6196. }
  6197. /**
  6198. *克隆。
  6199. *@param destObject 克隆源。
  6200. */
  6201. __proto.cloneTo=function(destObject){
  6202. var dest=destObject;
  6203. this.center.cloneTo(dest.center);
  6204. dest.radius=this.radius;
  6205. }
  6206. /**
  6207. *克隆。
  6208. *@return 克隆副本。
  6209. */
  6210. __proto.clone=function(){
  6211. var dest=/*__JS__ */new this.constructor(new Vector3(),new Vector3());
  6212. this.cloneTo(dest);
  6213. return dest;
  6214. }
  6215. BoundSphere.createFromSubPoints=function(points,start,count,out){
  6216. if (points==null){
  6217. throw new Error("points");
  6218. }
  6219. if (start < 0 || start >=points.length){
  6220. throw new Error("start"+start+"Must be in the range [0, "+(points.length-1)+"]");
  6221. }
  6222. if (count < 0 || (start+count)> points.length){
  6223. throw new Error("count"+count+"Must be in the range <= "+points.length+"}");
  6224. };
  6225. var upperEnd=start+count;
  6226. var center=BoundSphere._tempVector3;
  6227. center.x=0;
  6228. center.y=0;
  6229. center.z=0;
  6230. for (var i=start;i < upperEnd;++i){
  6231. Vector3.add(points[i],center,center);
  6232. };
  6233. var outCenter=out.center;
  6234. Vector3.scale(center,1 / count,outCenter);
  6235. var radius=0.0;
  6236. for (i=start;i < upperEnd;++i){
  6237. var distance=Vector3.distanceSquared(outCenter,points[i]);
  6238. if (distance > radius)
  6239. radius=distance;
  6240. }
  6241. out.radius=Math.sqrt(radius);
  6242. }
  6243. BoundSphere.createfromPoints=function(points,out){
  6244. if (points==null){
  6245. throw new Error("points");
  6246. }
  6247. BoundSphere.createFromSubPoints(points,0,points.length,out);
  6248. }
  6249. __static(BoundSphere,
  6250. ['_tempVector3',function(){return this._tempVector3=new Vector3();}
  6251. ]);
  6252. return BoundSphere;
  6253. })()
  6254. /**
  6255. *@private
  6256. *<code>RenderElement</code> 类用于实现渲染元素。
  6257. */
  6258. //class laya.d3.core.render.RenderElement
  6259. var RenderElement=(function(){
  6260. function RenderElement(){
  6261. /**@private */
  6262. //this._transform=null;
  6263. /**@private */
  6264. //this._geometry=null;
  6265. /**@private */
  6266. //this.material=null;
  6267. /**@private */
  6268. //this.render=null;
  6269. /**@private */
  6270. //this.staticBatch=null;
  6271. this.renderType=/*CLASS CONST:laya.d3.core.render.RenderElement.RENDERTYPE_NORMAL*/0;
  6272. }
  6273. __class(RenderElement,'laya.d3.core.render.RenderElement');
  6274. var __proto=RenderElement.prototype;
  6275. /**
  6276. *@private
  6277. */
  6278. __proto.setTransform=function(transform){
  6279. this._transform=transform;
  6280. }
  6281. /**
  6282. *@private
  6283. */
  6284. __proto.setGeometry=function(geometry){
  6285. this._geometry=geometry;
  6286. }
  6287. /**
  6288. *@private
  6289. */
  6290. __proto.addToOpaqueRenderQueue=function(context,queue){
  6291. queue.elements.push(this);
  6292. }
  6293. /**
  6294. *@private
  6295. */
  6296. __proto.addToTransparentRenderQueue=function(context,queue){
  6297. queue.elements.push(this);
  6298. queue.lastTransparentBatched=false;
  6299. queue.lastTransparentRenderElement=this;
  6300. }
  6301. /**
  6302. *@private
  6303. */
  6304. __proto._render=function(context,isTarget,customShader,replacementTag){
  6305. var lastStateMaterial,lastStateShaderInstance,lastStateRender;
  6306. var updateMark=Camera._updateMark;
  6307. var scene=context.scene;
  6308. var camera=context.camera;
  6309. var transform=this._transform;
  6310. var geometry=this._geometry;
  6311. context.renderElement=this;
  6312. var updateRender=updateMark!==this.render._updateMark || this.renderType!==this.render._updateRenderType;
  6313. if (updateRender){
  6314. this.render._renderUpdate(context,transform);
  6315. this.render._renderUpdateWithCamera(context,transform);
  6316. this.render._updateMark=updateMark;
  6317. this.render._updateRenderType=this.renderType;
  6318. }
  6319. if (geometry._prepareRender(context)){
  6320. var subShader=this.material._shader.getSubShaderAt(0);
  6321. var passes;
  6322. if (customShader){
  6323. if (replacementTag){
  6324. var oriTag=subShader.getFlag(replacementTag);
  6325. if (oriTag){
  6326. var customSubShaders=customShader._subShaders;
  6327. for (var k=0,p=customSubShaders.length;k < p;k++){
  6328. var customSubShader=customSubShaders[k];
  6329. if (oriTag===customSubShader.getFlag(replacementTag)){
  6330. passes=customSubShader._passes;
  6331. break ;
  6332. }
  6333. }
  6334. if (!passes)
  6335. return;
  6336. }else {
  6337. return;
  6338. }
  6339. }else {
  6340. passes=customShader.getSubShaderAt(0)._passes;
  6341. }
  6342. }else {
  6343. passes=subShader._passes;
  6344. }
  6345. for (var j=0,m=passes.length;j < m;j++){
  6346. var shaderPass=context.shader=passes[j].withCompile((scene._defineDatas.value)& (~this.material._disablePublicDefineDatas.value),this.render._defineDatas.value,this.material._defineDatas.value);
  6347. var switchShader=shaderPass.bind();
  6348. var switchUpdateMark=(updateMark!==shaderPass._uploadMark);
  6349. var uploadScene=(shaderPass._uploadScene!==scene)|| switchUpdateMark;
  6350. if (uploadScene || switchShader){
  6351. shaderPass.uploadUniforms(shaderPass._sceneUniformParamsMap,scene._shaderValues,uploadScene);
  6352. shaderPass._uploadScene=scene;
  6353. };
  6354. var uploadSprite3D=(shaderPass._uploadRender!==this.render || shaderPass._uploadRenderType!==this.renderType)|| switchUpdateMark;
  6355. if (uploadSprite3D || switchShader){
  6356. shaderPass.uploadUniforms(shaderPass._spriteUniformParamsMap,this.render._shaderValues,uploadSprite3D);
  6357. shaderPass._uploadRender=this.render;
  6358. shaderPass._uploadRenderType=this.renderType;
  6359. };
  6360. var uploadCamera=shaderPass._uploadCamera!==camera || switchUpdateMark;
  6361. if (uploadCamera || switchShader){
  6362. shaderPass.uploadUniforms(shaderPass._cameraUniformParamsMap,camera._shaderValues,uploadCamera);
  6363. shaderPass._uploadCamera=camera;
  6364. };
  6365. var uploadMaterial=(shaderPass._uploadMaterial!==this.material)|| switchUpdateMark;
  6366. if (uploadMaterial || switchShader){
  6367. shaderPass.uploadUniforms(shaderPass._materialUniformParamsMap,this.material._shaderValues,uploadMaterial);
  6368. shaderPass._uploadMaterial=this.material;
  6369. };
  6370. var matValues=this.material._shaderValues;
  6371. if (lastStateMaterial!==this.material||lastStateShaderInstance!==shaderPass){
  6372. shaderPass.uploadRenderStateBlendDepth(matValues);
  6373. shaderPass.uploadRenderStateFrontFace(matValues,isTarget,transform);
  6374. lastStateMaterial=this.material;
  6375. lastStateShaderInstance=shaderPass;
  6376. lastStateRender=this.render;
  6377. }else {
  6378. if (lastStateRender!==this.render){
  6379. shaderPass.uploadRenderStateFrontFace(matValues,isTarget,transform);
  6380. lastStateRender=this.render;
  6381. }
  6382. }
  6383. geometry._render(context);
  6384. shaderPass._uploadMark=updateMark;
  6385. }
  6386. }
  6387. if (updateRender && this.renderType!==/*CLASS CONST:laya.d3.core.render.RenderElement.RENDERTYPE_NORMAL*/0)
  6388. this.render._revertBatchRenderUpdate(context);
  6389. Camera._updateMark++;
  6390. }
  6391. /**
  6392. *@private
  6393. */
  6394. __proto.destroy=function(){
  6395. this._transform=null;
  6396. this._geometry=null;
  6397. this.material=null;
  6398. this.render=null;
  6399. }
  6400. RenderElement.RENDERTYPE_NORMAL=0;
  6401. RenderElement.RENDERTYPE_STATICBATCH=1;
  6402. RenderElement.RENDERTYPE_INSTANCEBATCH=2;
  6403. RenderElement.RENDERTYPE_VERTEXBATCH=3;
  6404. return RenderElement;
  6405. })()
  6406. /**
  6407. *<code>HalfFloatUtils</code> 类用于创建HalfFloat工具。
  6408. */
  6409. //class laya.d3.math.HalfFloatUtils
  6410. var HalfFloatUtils=(function(){
  6411. function HalfFloatUtils(){}
  6412. __class(HalfFloatUtils,'laya.d3.math.HalfFloatUtils');
  6413. HalfFloatUtils.__init__=function(){
  6414. for (var i=0;i < 256;++i){
  6415. var e=i-127;
  6416. if (e <-27){
  6417. HalfFloatUtils._baseTable[i | 0x000]=0x0000;
  6418. HalfFloatUtils._baseTable[i | 0x100]=0x8000;
  6419. HalfFloatUtils._shiftTable[i | 0x000]=24;
  6420. HalfFloatUtils._shiftTable[i | 0x100]=24;
  6421. }else if (e <-14){
  6422. HalfFloatUtils._baseTable[i | 0x000]=0x0400 >> (-e-14);
  6423. HalfFloatUtils._baseTable[i | 0x100]=(0x0400 >> (-e-14))| 0x8000;
  6424. HalfFloatUtils._shiftTable[i | 0x000]=-e-1;
  6425. HalfFloatUtils._shiftTable[i | 0x100]=-e-1;
  6426. }else if (e <=15){
  6427. HalfFloatUtils._baseTable[i | 0x000]=(e+15)<< 10;
  6428. HalfFloatUtils._baseTable[i | 0x100]=((e+15)<< 10)| 0x8000;
  6429. HalfFloatUtils._shiftTable[i | 0x000]=13;
  6430. HalfFloatUtils._shiftTable[i | 0x100]=13;
  6431. }else if (e < 128){
  6432. HalfFloatUtils._baseTable[i | 0x000]=0x7c00;
  6433. HalfFloatUtils._baseTable[i | 0x100]=0xfc00;
  6434. HalfFloatUtils._shiftTable[i | 0x000]=24;
  6435. HalfFloatUtils._shiftTable[i | 0x100]=24;
  6436. }else {
  6437. HalfFloatUtils._baseTable[i | 0x000]=0x7c00;
  6438. HalfFloatUtils._baseTable[i | 0x100]=0xfc00;
  6439. HalfFloatUtils._shiftTable[i | 0x000]=13;
  6440. HalfFloatUtils._shiftTable[i | 0x100]=13;
  6441. }
  6442. }
  6443. HalfFloatUtils._mantissaTable[0]=0;
  6444. for (i=1;i < 1024;++i){
  6445. var m=i << 13;
  6446. e=0;
  6447. while ((m & 0x00800000)===0){
  6448. e-=0x00800000;
  6449. m <<=1;
  6450. }
  6451. m &=~0x00800000;
  6452. e+=0x38800000;
  6453. HalfFloatUtils._mantissaTable[i]=m | e;
  6454. }
  6455. for (i=1024;i < 2048;++i){
  6456. HalfFloatUtils._mantissaTable[i]=0x38000000+((i-1024)<< 13);
  6457. }
  6458. HalfFloatUtils._exponentTable[0]=0;
  6459. for (i=1;i < 31;++i){
  6460. HalfFloatUtils._exponentTable[i]=i << 23;
  6461. }
  6462. HalfFloatUtils._exponentTable[31]=0x47800000;
  6463. HalfFloatUtils._exponentTable[32]=0x80000000;
  6464. for (i=33;i < 63;++i){
  6465. HalfFloatUtils._exponentTable[i]=0x80000000+((i-32)<< 23);
  6466. }
  6467. HalfFloatUtils._exponentTable[63]=0xc7800000;
  6468. HalfFloatUtils._offsetTable[0]=0;
  6469. for (i=1;i < 64;++i){
  6470. if (i===32){
  6471. HalfFloatUtils._offsetTable[i]=0;
  6472. }else {
  6473. HalfFloatUtils._offsetTable[i]=1024;
  6474. }
  6475. }
  6476. }
  6477. HalfFloatUtils.roundToFloat16Bits=function(num){
  6478. HalfFloatUtils._floatView[0]=num;
  6479. var f=HalfFloatUtils._uint32View[0];
  6480. var e=(f >> 23)& 0x1ff;
  6481. return HalfFloatUtils._baseTable[e]+((f & 0x007fffff)>> HalfFloatUtils._shiftTable[e]);
  6482. }
  6483. HalfFloatUtils.convertToNumber=function(float16bits){
  6484. var m=float16bits >> 10;
  6485. HalfFloatUtils._uint32View[0]=HalfFloatUtils._mantissaTable[HalfFloatUtils._offsetTable[m]+(float16bits & 0x3ff)]+HalfFloatUtils._exponentTable[m];
  6486. return HalfFloatUtils._floatView[0];
  6487. }
  6488. __static(HalfFloatUtils,
  6489. ['_buffer',function(){return this._buffer=new ArrayBuffer(4);},'_floatView',function(){return this._floatView=new Float32Array(HalfFloatUtils._buffer);},'_uint32View',function(){return this._uint32View=new Uint32Array(HalfFloatUtils._buffer);},'_baseTable',function(){return this._baseTable=new Uint32Array(512);},'_shiftTable',function(){return this._shiftTable=new Uint32Array(512);},'_mantissaTable',function(){return this._mantissaTable=new Uint32Array(2048);},'_exponentTable',function(){return this._exponentTable=new Uint32Array(64);},'_offsetTable',function(){return this._offsetTable=new Uint32Array(64);}
  6490. ]);
  6491. return HalfFloatUtils;
  6492. })()
  6493. /**
  6494. *<code>SkyMesh</code> 类用于实现天空网格。
  6495. */
  6496. //class laya.d3.resource.models.SkyMesh
  6497. var SkyMesh=(function(){
  6498. function SkyMesh(){
  6499. /**@private */
  6500. this._vertexBuffer=null;
  6501. /**@private */
  6502. this._indexBuffer=null;
  6503. /**@private */
  6504. this._bufferState=null;
  6505. }
  6506. __class(SkyMesh,'laya.d3.resource.models.SkyMesh');
  6507. var __proto=SkyMesh.prototype;
  6508. /**
  6509. *@private
  6510. */
  6511. __proto._render=function(state){}
  6512. return SkyMesh;
  6513. })()
  6514. /**
  6515. *<code>TextureSheetAnimation</code> 类用于创建粒子帧动画。
  6516. */
  6517. //class laya.d3.core.particleShuriKen.module.TextureSheetAnimation
  6518. var TextureSheetAnimation=(function(){
  6519. function TextureSheetAnimation(frame,startFrame){
  6520. /**@private */
  6521. this._frame=null;
  6522. /**@private */
  6523. this._startFrame=null;
  6524. /**纹理平铺。*/
  6525. this.tiles=null;
  6526. /**类型,0为whole sheet、1为singal row。*/
  6527. this.type=0;
  6528. /**是否随机行,type为1时有效。*/
  6529. this.randomRow=false;
  6530. /**行索引,type为1时有效。*/
  6531. this.rowIndex=0;
  6532. /**循环次数。*/
  6533. this.cycles=0;
  6534. /**UV通道类型,0为Noting,1为Everything,待补充,暂不支持。*/
  6535. this.enableUVChannels=0;
  6536. /**是否启用*/
  6537. this.enable=false;
  6538. this.tiles=new Vector2(1,1);
  6539. this.type=0;
  6540. this.randomRow=true;
  6541. this.rowIndex=0;
  6542. this.cycles=1;
  6543. this.enableUVChannels=1;
  6544. this._frame=frame;
  6545. this._startFrame=startFrame;
  6546. }
  6547. __class(TextureSheetAnimation,'laya.d3.core.particleShuriKen.module.TextureSheetAnimation');
  6548. var __proto=TextureSheetAnimation.prototype;
  6549. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  6550. /**
  6551. *克隆。
  6552. *@param destObject 克隆源。
  6553. */
  6554. __proto.cloneTo=function(destObject){
  6555. var destTextureSheetAnimation=destObject;
  6556. this.tiles.cloneTo(destTextureSheetAnimation.tiles);
  6557. destTextureSheetAnimation.type=this.type;
  6558. destTextureSheetAnimation.randomRow=this.randomRow;
  6559. this._frame.cloneTo(destTextureSheetAnimation._frame);
  6560. this._startFrame.cloneTo(destTextureSheetAnimation._startFrame);
  6561. destTextureSheetAnimation.cycles=this.cycles;
  6562. destTextureSheetAnimation.enableUVChannels=this.enableUVChannels;
  6563. destTextureSheetAnimation.enable=this.enable;
  6564. }
  6565. /**
  6566. *克隆。
  6567. *@return 克隆副本。
  6568. */
  6569. __proto.clone=function(){
  6570. var destFrame;
  6571. switch (this._frame.type){
  6572. case 0:
  6573. destFrame=FrameOverTime.createByConstant(this._frame.constant);
  6574. break ;
  6575. case 1:
  6576. destFrame=FrameOverTime.createByOverTime(this._frame.frameOverTimeData.clone());
  6577. break ;
  6578. case 2:
  6579. destFrame=FrameOverTime.createByRandomTwoConstant(this._frame.constantMin,this._frame.constantMax);
  6580. break ;
  6581. case 3:
  6582. destFrame=FrameOverTime.createByRandomTwoOverTime(this._frame.frameOverTimeDataMin.clone(),this._frame.frameOverTimeDataMax.clone());
  6583. break ;
  6584. };
  6585. var destStartFrame;
  6586. switch (this._startFrame.type){
  6587. case 0:
  6588. destStartFrame=StartFrame.createByConstant(this._startFrame.constant);
  6589. break ;
  6590. case 1:
  6591. destStartFrame=StartFrame.createByRandomTwoConstant(this._startFrame.constantMin,this._startFrame.constantMax);
  6592. break ;
  6593. };
  6594. var destTextureSheetAnimation=/*__JS__ */new this.constructor(destFrame,destStartFrame);
  6595. this.tiles.cloneTo(destTextureSheetAnimation.tiles);
  6596. destTextureSheetAnimation.type=this.type;
  6597. destTextureSheetAnimation.randomRow=this.randomRow;
  6598. destTextureSheetAnimation.cycles=this.cycles;
  6599. destTextureSheetAnimation.enableUVChannels=this.enableUVChannels;
  6600. destTextureSheetAnimation.enable=this.enable;
  6601. return destTextureSheetAnimation;
  6602. }
  6603. /**获取时间帧率。*/
  6604. __getset(0,__proto,'frame',function(){
  6605. return this._frame;
  6606. });
  6607. /**获取开始帧率。*/
  6608. __getset(0,__proto,'startFrame',function(){
  6609. return this._startFrame;
  6610. });
  6611. return TextureSheetAnimation;
  6612. })()
  6613. /**
  6614. *...
  6615. *@author
  6616. */
  6617. //class laya.d3.resource.TextureGenerator
  6618. var TextureGenerator=(function(){
  6619. function TextureGenerator(){}
  6620. __class(TextureGenerator,'laya.d3.resource.TextureGenerator');
  6621. TextureGenerator.lightAttenTexture=function(x,y,maxX,maxY,index,data){
  6622. var sqrRange=x / maxX;
  6623. var atten=1.0 / (1.0+25.0 *sqrRange);
  6624. if (sqrRange >=0.64){
  6625. if (sqrRange > 1.0){
  6626. atten=0;
  6627. }else {
  6628. atten *=1-(sqrRange-0.64)/ (1-0.64);
  6629. }
  6630. }
  6631. data[index]=Math.floor(atten *255.0+0.5);
  6632. }
  6633. TextureGenerator.haloTexture=function(x,y,maxX,maxY,index,data){
  6634. maxX >>=1;
  6635. maxY >>=1;
  6636. var xFac=(x-maxX)/ maxX;
  6637. var yFac=(y-maxY)/ maxY;
  6638. var sqrRange=xFac *xFac+yFac *yFac;
  6639. if (sqrRange > 1.0){
  6640. sqrRange=1.0;
  6641. }
  6642. data[index]=Math.floor((1.0-sqrRange)*255.0+0.5);
  6643. }
  6644. TextureGenerator._generateTexture2D=function(texture,textureWidth,textureHeight,func){
  6645. var index=0;
  6646. var size=0;
  6647. switch (texture.format){
  6648. case /*laya.resource.BaseTexture.FORMAT_R8G8B8*/0:
  6649. size=3;
  6650. break ;
  6651. case /*laya.resource.BaseTexture.FORMAT_R8G8B8A8*/1:
  6652. size=4;
  6653. break ;
  6654. case /*laya.resource.BaseTexture.FORMAT_ALPHA8*/2:
  6655. size=1;
  6656. break ;
  6657. default :
  6658. throw "GeneratedTexture._generateTexture: unkonw texture format.";
  6659. };
  6660. var data=new Uint8Array(textureWidth *textureHeight *size);
  6661. for (var y=0;y < textureHeight;y++){
  6662. for (var x=0;x < textureWidth;x++){
  6663. func(x,y,textureWidth,textureHeight,index,data);
  6664. index+=size;
  6665. }
  6666. }
  6667. texture.setPixels(data);
  6668. }
  6669. return TextureGenerator;
  6670. })()
  6671. /**
  6672. *<code>Shader3D</code> 类用于创建Shader3D。
  6673. */
  6674. //class laya.d3.shader.Shader3D
  6675. var Shader3D=(function(){
  6676. function Shader3D(name,attributeMap,uniformMap,enableInstancing){
  6677. /**@private */
  6678. this._attributeMap=null;
  6679. /**@private */
  6680. this._uniformMap=null;
  6681. /**@private */
  6682. //this._name=null;
  6683. /**@private */
  6684. this._enableInstancing=false;
  6685. this._subShaders=[];
  6686. this._name=name;
  6687. this._attributeMap=attributeMap;
  6688. this._uniformMap=uniformMap;
  6689. this._enableInstancing=enableInstancing;
  6690. }
  6691. __class(Shader3D,'laya.d3.shader.Shader3D');
  6692. var __proto=Shader3D.prototype;
  6693. /**
  6694. *添加子着色器。
  6695. *@param 子着色器。
  6696. */
  6697. __proto.addSubShader=function(subShader){
  6698. this._subShaders.push(subShader);
  6699. subShader._owner=this;
  6700. }
  6701. /**
  6702. *在特定索引获取子着色器。
  6703. *@param index 索引。
  6704. *@return 子着色器。
  6705. */
  6706. __proto.getSubShaderAt=function(index){
  6707. return this._subShaders[index];
  6708. }
  6709. Shader3D.propertyNameToID=function(name){
  6710. if (Shader3D._propertyNameMap[name] !=null){
  6711. return Shader3D._propertyNameMap[name];
  6712. }else {
  6713. var id=Shader3D._propertyNameCounter++;
  6714. Shader3D._propertyNameMap[name]=id;
  6715. return id;
  6716. }
  6717. }
  6718. Shader3D.addInclude=function(fileName,txt){
  6719. ShaderCompile.addInclude(fileName,txt);
  6720. }
  6721. Shader3D.registerPublicDefine=function(name){
  6722. var value=Math.pow(2,Shader3D._publicCounter++);
  6723. Shader3D._globleDefines[value]=name;
  6724. return value;
  6725. }
  6726. Shader3D.compileShader=function(name,subShaderIndex,passIndex,publicDefine,spriteDefine,materialDefine){
  6727. var shader=laya.d3.shader.Shader3D.find(name);
  6728. if (shader){
  6729. var subShader=shader.getSubShaderAt(subShaderIndex);
  6730. if (subShader){
  6731. var pass=subShader._passes[passIndex];
  6732. if (pass){
  6733. if (WebGL.shaderHighPrecision)
  6734. pass.withCompile(publicDefine,spriteDefine,materialDefine);
  6735. else
  6736. pass.withCompile(publicDefine-laya.d3.shader.Shader3D.SHADERDEFINE_HIGHPRECISION,spriteDefine,materialDefine);
  6737. }else {
  6738. console.warn("Shader3D: unknown passIndex.");
  6739. }
  6740. }else {
  6741. console.warn("Shader3D: unknown subShaderIndex.");
  6742. }
  6743. }else {
  6744. console.warn("Shader3D: unknown shader name.");
  6745. }
  6746. }
  6747. Shader3D.add=function(name,attributeMap,uniformMap,enableInstancing){
  6748. (enableInstancing===void 0)&& (enableInstancing=false);
  6749. return laya.d3.shader.Shader3D._preCompileShader[name]=new Shader3D(name,attributeMap,uniformMap,enableInstancing);
  6750. }
  6751. Shader3D.find=function(name){
  6752. return laya.d3.shader.Shader3D._preCompileShader[name];
  6753. }
  6754. Shader3D.RENDER_STATE_CULL=0;
  6755. Shader3D.RENDER_STATE_BLEND=1;
  6756. Shader3D.RENDER_STATE_BLEND_SRC=2;
  6757. Shader3D.RENDER_STATE_BLEND_DST=3;
  6758. Shader3D.RENDER_STATE_BLEND_SRC_RGB=4;
  6759. Shader3D.RENDER_STATE_BLEND_DST_RGB=5;
  6760. Shader3D.RENDER_STATE_BLEND_SRC_ALPHA=6;
  6761. Shader3D.RENDER_STATE_BLEND_DST_ALPHA=7;
  6762. Shader3D.RENDER_STATE_BLEND_CONST_COLOR=8;
  6763. Shader3D.RENDER_STATE_BLEND_EQUATION=9;
  6764. Shader3D.RENDER_STATE_BLEND_EQUATION_RGB=10;
  6765. Shader3D.RENDER_STATE_BLEND_EQUATION_ALPHA=11;
  6766. Shader3D.RENDER_STATE_DEPTH_TEST=12;
  6767. Shader3D.RENDER_STATE_DEPTH_WRITE=13;
  6768. Shader3D.PERIOD_CUSTOM=0;
  6769. Shader3D.PERIOD_MATERIAL=1;
  6770. Shader3D.PERIOD_SPRITE=2;
  6771. Shader3D.PERIOD_CAMERA=3;
  6772. Shader3D.PERIOD_SCENE=4;
  6773. Shader3D.SHADERDEFINE_HIGHPRECISION=0;
  6774. Shader3D._propertyNameCounter=0;
  6775. Shader3D._propertyNameMap={};
  6776. Shader3D._publicCounter=0;
  6777. Shader3D._globleDefines=[];
  6778. Shader3D._preCompileShader={};
  6779. Shader3D.debugMode=false;
  6780. return Shader3D;
  6781. })()
  6782. /**
  6783. *<code>Rand</code> 类用于通过32位无符号整型随机种子创建随机数。
  6784. */
  6785. //class laya.d3.math.Rand
  6786. var Rand=(function(){
  6787. function Rand(seed){
  6788. this._temp=new Uint32Array(1);
  6789. this.seeds=new Uint32Array(4);
  6790. this.seeds[0]=seed;
  6791. this.seeds[1]=this.seeds[0] *0x6C078965+1;
  6792. this.seeds[2]=this.seeds[1] *0x6C078965+1;
  6793. this.seeds[3]=this.seeds[2] *0x6C078965+1;
  6794. }
  6795. __class(Rand,'laya.d3.math.Rand');
  6796. var __proto=Rand.prototype;
  6797. /**
  6798. *获取无符号32位整形随机数。
  6799. *@return 无符号32位整形随机数。
  6800. */
  6801. __proto.getUint=function(){
  6802. this._temp[0]=this.seeds[0] ^ (this.seeds[0] << 11);
  6803. this.seeds[0]=this.seeds[1];
  6804. this.seeds[1]=this.seeds[2];
  6805. this.seeds[2]=this.seeds[3];
  6806. this.seeds[3]=(this.seeds[3] ^ (this.seeds[3] >>> 19))^ (this._temp[0] ^ (this._temp[0] >>> 8));
  6807. return this.seeds[3];
  6808. }
  6809. /**
  6810. *获取0到1之间的浮点随机数。
  6811. *@return 0到1之间的浮点随机数。
  6812. */
  6813. __proto.getFloat=function(){
  6814. this.getUint();
  6815. return (this.seeds[3] & 0x007FFFFF)*(1.0 / 8388607.0);
  6816. }
  6817. /**
  6818. *获取-1到1之间的浮点随机数。
  6819. *@return-1到1之间的浮点随机数。
  6820. */
  6821. __proto.getSignedFloat=function(){
  6822. return this.getFloat()*2.0-1.0;
  6823. }
  6824. /**
  6825. *设置随机种子。
  6826. *@param seed 随机种子。
  6827. */
  6828. /**
  6829. *获取随机种子。
  6830. *@return 随机种子。
  6831. */
  6832. __getset(0,__proto,'seed',function(){
  6833. return this.seeds[0];
  6834. },function(seed){
  6835. this.seeds[0]=seed;
  6836. this.seeds[1]=this.seeds[0] *0x6C078965+1;
  6837. this.seeds[2]=this.seeds[1] *0x6C078965+1;
  6838. this.seeds[3]=this.seeds[2] *0x6C078965+1;
  6839. });
  6840. Rand.getFloatFromInt=function(v){
  6841. return (v & 0x007FFFFF)*(1.0 / 8388607.0)
  6842. }
  6843. Rand.getByteFromInt=function(v){
  6844. return (v & 0x007FFFFF)>>> 15;
  6845. }
  6846. return Rand;
  6847. })()
  6848. /**
  6849. *...
  6850. *@author ...
  6851. */
  6852. //class laya.d3.shadowMap.ParallelSplitShadowMap
  6853. var ParallelSplitShadowMap=(function(){
  6854. function ParallelSplitShadowMap(){
  6855. /**@private */
  6856. //this.lastNearPlane=NaN;
  6857. /**@private */
  6858. //this.lastFieldOfView=NaN;
  6859. /**@private */
  6860. //this.lastAspectRatio=NaN;
  6861. /**@private */
  6862. this._currentPSSM=-1;
  6863. /**@private */
  6864. this._shadowMapCount=3;
  6865. /**@private */
  6866. this._maxDistance=200.0;
  6867. /**@private */
  6868. this._ratioOfDistance=1.0 / this._shadowMapCount;
  6869. /**@private */
  6870. this._statesDirty=true;
  6871. /**@private */
  6872. //this.cameras=null;
  6873. /**@private */
  6874. this._shadowMapTextureSize=1024;
  6875. /**@private */
  6876. this._scene=null;
  6877. /**@private */
  6878. this._PCFType=0;
  6879. /**@private */
  6880. this._shaderValueLightVP=null;
  6881. /**@private */
  6882. //this._shaderValueVPs=null;
  6883. this._spiltDistance=new Array(/*CLASS CONST:laya.d3.shadowMap.ParallelSplitShadowMap.MAX_PSSM_COUNT*/3+1);
  6884. this._globalParallelLightDir=new Vector3(0,-1,0);
  6885. this._boundingSphere=new Array(/*CLASS CONST:laya.d3.shadowMap.ParallelSplitShadowMap.MAX_PSSM_COUNT*/3+1);
  6886. this._boundingBox=new Array(/*CLASS CONST:laya.d3.shadowMap.ParallelSplitShadowMap.MAX_PSSM_COUNT*/3+1);
  6887. this._frustumPos=new Array((/*CLASS CONST:laya.d3.shadowMap.ParallelSplitShadowMap.MAX_PSSM_COUNT*/3+1)*4);
  6888. this._uniformDistance=new Array(/*CLASS CONST:laya.d3.shadowMap.ParallelSplitShadowMap.MAX_PSSM_COUNT*/3+1);
  6889. this._logDistance=new Array(/*CLASS CONST:laya.d3.shadowMap.ParallelSplitShadowMap.MAX_PSSM_COUNT*/3+1);
  6890. this._dimension=new Array(/*CLASS CONST:laya.d3.shadowMap.ParallelSplitShadowMap.MAX_PSSM_COUNT*/3+1);
  6891. this._tempLookAt3=new Vector3();
  6892. this._tempLookAt4=new Vector4();
  6893. this._tempValue=new Vector4();
  6894. this._tempPos=new Vector3();
  6895. this._tempLightUp=new Vector3();
  6896. this._tempMin=new Vector4();
  6897. this._tempMax=new Vector4();
  6898. this._tempMatrix44=new Matrix4x4;
  6899. this._splitFrustumCulling=new BoundFrustum(Matrix4x4.DEFAULT);
  6900. this._tempScaleMatrix44=new Matrix4x4();
  6901. this._shadowPCFOffset=new Vector2(1.0 / 1024.0,1.0 / 1024.0);
  6902. this._shaderValueDistance=new Vector4();
  6903. this.cameras=[];
  6904. this._shaderValueVPs=[];
  6905. var i=0;
  6906. for (i=0;i < this._spiltDistance.length;i++){
  6907. this._spiltDistance[i]=0.0;
  6908. }
  6909. for (i=0;i < this._dimension.length;i++){
  6910. this._dimension[i]=new Vector2();
  6911. }
  6912. for (i=0;i < this._frustumPos.length;i++){
  6913. this._frustumPos[i]=new Vector3();
  6914. }
  6915. for (i=0;i < this._boundingBox.length;i++){
  6916. this._boundingBox[i]=new BoundBox(new Vector3(),new Vector3());
  6917. }
  6918. for (i=0;i < this._boundingSphere.length;i++){
  6919. this._boundingSphere[i]=new BoundSphere(new Vector3(),0.0);
  6920. }
  6921. Matrix4x4.createScaling(new Vector3(0.5,0.5,1.0),this._tempScaleMatrix44);
  6922. this._tempScaleMatrix44.elements[12]=0.5;
  6923. this._tempScaleMatrix44.elements[13]=0.5;
  6924. }
  6925. __class(ParallelSplitShadowMap,'laya.d3.shadowMap.ParallelSplitShadowMap');
  6926. var __proto=ParallelSplitShadowMap.prototype;
  6927. __proto.setInfo=function(scene,maxDistance,globalParallelDir,shadowMapTextureSize,numberOfPSSM,PCFType){
  6928. if (numberOfPSSM > /*CLASS CONST:laya.d3.shadowMap.ParallelSplitShadowMap.MAX_PSSM_COUNT*/3){
  6929. this._shadowMapCount=/*CLASS CONST:laya.d3.shadowMap.ParallelSplitShadowMap.MAX_PSSM_COUNT*/3;
  6930. }
  6931. this._scene=scene;
  6932. this._maxDistance=maxDistance;
  6933. this.shadowMapCount=numberOfPSSM;
  6934. this._globalParallelLightDir=globalParallelDir;
  6935. this._ratioOfDistance=1.0 / this._shadowMapCount;
  6936. for (var i=0;i < this._spiltDistance.length;i++){
  6937. this._spiltDistance[i]=0.0;
  6938. }
  6939. this._shadowMapTextureSize=shadowMapTextureSize;
  6940. this._shadowPCFOffset.x=1.0 / this._shadowMapTextureSize;
  6941. this._shadowPCFOffset.y=1.0 / this._shadowMapTextureSize;
  6942. this.setPCFType(PCFType);
  6943. this._statesDirty=true;
  6944. }
  6945. __proto.setPCFType=function(PCFtype){
  6946. this._PCFType=PCFtype;
  6947. var defineData=this._scene._defineDatas;
  6948. switch (this._PCFType){
  6949. case 0:
  6950. defineData.add(Scene3D.SHADERDEFINE_SHADOW_PCF_NO);
  6951. defineData.remove(Scene3D.SHADERDEFINE_SHADOW_PCF1);
  6952. defineData.remove(Scene3D.SHADERDEFINE_SHADOW_PCF2);
  6953. defineData.remove(Scene3D.SHADERDEFINE_SHADOW_PCF3);
  6954. break ;
  6955. case 1:
  6956. defineData.add(Scene3D.SHADERDEFINE_SHADOW_PCF1);
  6957. defineData.remove(Scene3D.SHADERDEFINE_SHADOW_PCF_NO);
  6958. defineData.remove(Scene3D.SHADERDEFINE_SHADOW_PCF2);
  6959. defineData.remove(Scene3D.SHADERDEFINE_SHADOW_PCF3);
  6960. break ;
  6961. case 2:
  6962. defineData.add(Scene3D.SHADERDEFINE_SHADOW_PCF2);
  6963. defineData.remove(Scene3D.SHADERDEFINE_SHADOW_PCF_NO);
  6964. defineData.remove(Scene3D.SHADERDEFINE_SHADOW_PCF1);
  6965. defineData.remove(Scene3D.SHADERDEFINE_SHADOW_PCF3);
  6966. break ;
  6967. case 3:
  6968. defineData.add(Scene3D.SHADERDEFINE_SHADOW_PCF3);
  6969. defineData.remove(Scene3D.SHADERDEFINE_SHADOW_PCF_NO);
  6970. defineData.remove(Scene3D.SHADERDEFINE_SHADOW_PCF1);
  6971. defineData.remove(Scene3D.SHADERDEFINE_SHADOW_PCF2);
  6972. break ;
  6973. }
  6974. }
  6975. __proto.getPCFType=function(){
  6976. return this._PCFType;
  6977. }
  6978. __proto.setFarDistance=function(value){
  6979. if (this._maxDistance !=value){
  6980. this._maxDistance=value;
  6981. this._statesDirty=true;
  6982. }
  6983. }
  6984. __proto.getFarDistance=function(){
  6985. return this._maxDistance;
  6986. }
  6987. /**
  6988. *@private
  6989. */
  6990. __proto._beginSampler=function(index,sceneCamera){
  6991. if (index < 0 || index > this._shadowMapCount)
  6992. throw new Error("ParallelSplitShadowMap: beginSample invalid index");
  6993. this._currentPSSM=index;
  6994. this._update(sceneCamera);
  6995. }
  6996. /**
  6997. *@private
  6998. */
  6999. __proto.endSampler=function(sceneCamera){
  7000. this._currentPSSM=-1;
  7001. }
  7002. /**
  7003. *@private
  7004. */
  7005. __proto._calcAllLightCameraInfo=function(sceneCamera){
  7006. if (this._shadowMapCount===1){
  7007. this._beginSampler(0,sceneCamera);
  7008. this.endSampler(sceneCamera);
  7009. }else {
  7010. for (var i=0,n=this._shadowMapCount+1;i < n;i++){
  7011. this._beginSampler(i,sceneCamera);
  7012. this.endSampler(sceneCamera);
  7013. }
  7014. }
  7015. }
  7016. /**
  7017. *@private
  7018. */
  7019. __proto._recalculate=function(nearPlane,fieldOfView,aspectRatio){
  7020. this._calcSplitDistance(nearPlane);
  7021. this._calcBoundingBox(fieldOfView,aspectRatio);
  7022. this._rebuildRenderInfo();
  7023. }
  7024. /**
  7025. *@private
  7026. */
  7027. __proto._update=function(sceneCamera){
  7028. var nearPlane=sceneCamera.nearPlane;
  7029. var fieldOfView=sceneCamera.fieldOfView;
  7030. var aspectRatio=(sceneCamera).aspectRatio;
  7031. if (this._statesDirty || this.lastNearPlane!==nearPlane || this.lastFieldOfView!==fieldOfView || this.lastAspectRatio!==aspectRatio){
  7032. this._recalculate(nearPlane,fieldOfView,aspectRatio);
  7033. this._uploadShaderValue();
  7034. this._statesDirty=false;
  7035. this.lastNearPlane=nearPlane;
  7036. this.lastFieldOfView=fieldOfView;
  7037. this.lastAspectRatio=aspectRatio;
  7038. }
  7039. this._calcLightViewProject(sceneCamera);
  7040. }
  7041. /**
  7042. *@private
  7043. */
  7044. __proto._uploadShaderValue=function(){
  7045. var defDatas=this._scene._defineDatas;
  7046. switch (this._shadowMapCount){
  7047. case 1:
  7048. defDatas.add(Scene3D.SHADERDEFINE_SHADOW_PSSM1);
  7049. defDatas.remove(Scene3D.SHADERDEFINE_SHADOW_PSSM2);
  7050. defDatas.remove(Scene3D.SHADERDEFINE_SHADOW_PSSM3);
  7051. break ;
  7052. case 2:
  7053. defDatas.add(Scene3D.SHADERDEFINE_SHADOW_PSSM2);
  7054. defDatas.remove(Scene3D.SHADERDEFINE_SHADOW_PSSM1);
  7055. defDatas.remove(Scene3D.SHADERDEFINE_SHADOW_PSSM3);
  7056. break ;
  7057. case 3:
  7058. defDatas.add(Scene3D.SHADERDEFINE_SHADOW_PSSM3);
  7059. defDatas.remove(Scene3D.SHADERDEFINE_SHADOW_PSSM1);
  7060. defDatas.remove(Scene3D.SHADERDEFINE_SHADOW_PSSM2);
  7061. break ;
  7062. };
  7063. var sceneSV=this._scene._shaderValues;
  7064. sceneSV.setVector(Scene3D.SHADOWDISTANCE,this._shaderValueDistance);
  7065. sceneSV.setBuffer(Scene3D.SHADOWLIGHTVIEWPROJECT,this._shaderValueLightVP);
  7066. sceneSV.setVector2(Scene3D.SHADOWMAPPCFOFFSET,this._shadowPCFOffset);
  7067. switch (this._shadowMapCount){
  7068. case 3:
  7069. sceneSV.setTexture(Scene3D.SHADOWMAPTEXTURE1,this.cameras[1].renderTarget);
  7070. sceneSV.setTexture(Scene3D.SHADOWMAPTEXTURE2,this.cameras[2].renderTarget)
  7071. sceneSV.setTexture(Scene3D.SHADOWMAPTEXTURE3,this.cameras[3].renderTarget);
  7072. break ;
  7073. case 2:
  7074. sceneSV.setTexture(Scene3D.SHADOWMAPTEXTURE1,this.cameras[1].renderTarget);
  7075. sceneSV.setTexture(Scene3D.SHADOWMAPTEXTURE2,this.cameras[2].renderTarget);
  7076. break ;
  7077. case 1:
  7078. sceneSV.setTexture(Scene3D.SHADOWMAPTEXTURE1,this.cameras[1].renderTarget);
  7079. break ;
  7080. }
  7081. }
  7082. /**
  7083. *@private
  7084. */
  7085. __proto._calcSplitDistance=function(nearPlane){
  7086. var far=this._maxDistance;
  7087. var invNumberOfPSSM=1.0 / this._shadowMapCount;
  7088. var i=0;
  7089. for (i=0;i <=this._shadowMapCount;i++){
  7090. this._uniformDistance[i]=nearPlane+(far-nearPlane)*i *invNumberOfPSSM;
  7091. };
  7092. var farDivNear=far / nearPlane;
  7093. for (i=0;i <=this._shadowMapCount;i++){
  7094. var n=Math.pow(farDivNear,i *invNumberOfPSSM);
  7095. this._logDistance[i]=nearPlane *n;
  7096. }
  7097. for (i=0;i <=this._shadowMapCount;i++){
  7098. this._spiltDistance[i]=this._uniformDistance[i] *this._ratioOfDistance+this._logDistance[i] *(1.0-this._ratioOfDistance);
  7099. }
  7100. this._shaderValueDistance.x=this._spiltDistance[1];
  7101. this._shaderValueDistance.y=this._spiltDistance[2];
  7102. this._shaderValueDistance.z=this._spiltDistance[3];
  7103. this._shaderValueDistance.w=0.0;
  7104. }
  7105. /**
  7106. *@private
  7107. */
  7108. __proto._calcBoundingBox=function(fieldOfView,aspectRatio){
  7109. var fov=3.1415926 *fieldOfView / 180.0;
  7110. var halfTanValue=Math.tan(fov / 2.0);
  7111. var height=NaN;
  7112. var width=NaN;
  7113. var distance=NaN;
  7114. var i=0;
  7115. for (i=0;i <=this._shadowMapCount;i++){
  7116. distance=this._spiltDistance[i];
  7117. height=distance *halfTanValue;
  7118. width=height *aspectRatio;
  7119. var temp=this._frustumPos[i *4+0];
  7120. temp.x=-width;
  7121. temp.y=-height;
  7122. temp.z=-distance;
  7123. temp=this._frustumPos[i *4+1];
  7124. temp.x=width;
  7125. temp.y=-height;
  7126. temp.z=-distance;
  7127. temp=this._frustumPos[i *4+2];
  7128. temp.x=-width;
  7129. temp.y=height;
  7130. temp.z=-distance;
  7131. temp=this._frustumPos[i *4+3];
  7132. temp.x=width;
  7133. temp.y=height;
  7134. temp.z=-distance;
  7135. temp=this._dimension[i];
  7136. temp.x=width;
  7137. temp.y=height;
  7138. };
  7139. var d;
  7140. var min;
  7141. var max;
  7142. var center;
  7143. for (i=1;i <=this._shadowMapCount;i++){
  7144. d=this._dimension[i];
  7145. min=this._boundingBox[i].min;
  7146. min.x=-d.x;
  7147. min.y=-d.y;
  7148. min.z=-this._spiltDistance[i];
  7149. max=this._boundingBox[i].max;
  7150. max.x=d.x;
  7151. max.y=d.y;
  7152. max.z=-this._spiltDistance[i-1];
  7153. center=this._boundingSphere[i].center;
  7154. center.x=(min.x+max.x)*0.5;
  7155. center.y=(min.y+max.y)*0.5;
  7156. center.z=(min.z+max.z)*0.5;
  7157. this._boundingSphere[i].radius=Math.sqrt(Math.pow(max.x-min.x,2)+Math.pow(max.y-min.y,2)+Math.pow(max.z-min.z,2))*0.5;
  7158. }
  7159. min=this._boundingBox[0].min;
  7160. d=this._dimension[this._shadowMapCount];
  7161. min.x=-d.x;
  7162. min.y=-d.y;
  7163. min.z=-this._spiltDistance[this._shadowMapCount];
  7164. max=this._boundingBox[0].max;
  7165. max.x=d.x;
  7166. max.y=d.y;
  7167. max.z=-this._spiltDistance[0];
  7168. center=this._boundingSphere[0].center;
  7169. center.x=(min.x+max.x)*0.5;
  7170. center.y=(min.y+max.y)*0.5;
  7171. center.z=(min.z+max.z)*0.5;
  7172. this._boundingSphere[0].radius=Math.sqrt(Math.pow(max.x-min.x,2)+Math.pow(max.y-min.y,2)+Math.pow(max.z-min.z,2))*0.5;
  7173. }
  7174. __proto.calcSplitFrustum=function(sceneCamera){
  7175. if (this._currentPSSM > 0){
  7176. Matrix4x4.createPerspective(3.1416 *sceneCamera.fieldOfView / 180.0,(sceneCamera).aspectRatio,this._spiltDistance[this._currentPSSM-1],this._spiltDistance[this._currentPSSM],this._tempMatrix44);
  7177. }else {
  7178. Matrix4x4.createPerspective(3.1416 *sceneCamera.fieldOfView / 180.0,(sceneCamera).aspectRatio,this._spiltDistance[0],this._spiltDistance[this._shadowMapCount],this._tempMatrix44);
  7179. }
  7180. Matrix4x4.multiply(this._tempMatrix44,(sceneCamera).viewMatrix,this._tempMatrix44);
  7181. this._splitFrustumCulling.matrix=this._tempMatrix44;
  7182. }
  7183. /**
  7184. *@private
  7185. */
  7186. __proto._rebuildRenderInfo=function(){
  7187. var nNum=this._shadowMapCount+1;
  7188. var i=0;
  7189. this.cameras.length=nNum;
  7190. for (i=0;i < nNum;i++){
  7191. if (!this.cameras[i]){
  7192. var camera=new Camera();
  7193. camera.name="lightCamera"+i;
  7194. camera.clearColor=new Vector4(1.0,1.0,1.0,1.0);
  7195. this.cameras[i]=camera;
  7196. };
  7197. var shadowMap=this.cameras[i].renderTarget;
  7198. if (shadowMap==null || shadowMap.width !=this._shadowMapTextureSize || shadowMap.height !=this._shadowMapTextureSize){
  7199. (shadowMap)&& (shadowMap.destroy());
  7200. shadowMap=new RenderTexture(this._shadowMapTextureSize,this._shadowMapTextureSize,/*laya.resource.BaseTexture.FORMAT_R8G8B8A8*/1,/*laya.resource.BaseTexture.FORMAT_DEPTH_16*/0);
  7201. shadowMap.filterMode=/*laya.resource.BaseTexture.FILTERMODE_POINT*/0;
  7202. this.cameras[i].renderTarget=shadowMap;
  7203. }
  7204. }
  7205. }
  7206. /**
  7207. *@private
  7208. */
  7209. __proto._calcLightViewProject=function(sceneCamera){
  7210. var boundSphere=this._boundingSphere[this._currentPSSM];
  7211. var cameraMatViewInv=sceneCamera.transform.worldMatrix;
  7212. var radius=boundSphere.radius;
  7213. boundSphere.center.cloneTo(this._tempLookAt3);
  7214. Vector3.transformV3ToV4(this._tempLookAt3,cameraMatViewInv,this._tempLookAt4);
  7215. var lookAt3Element=this._tempLookAt3;
  7216. var lookAt4Element=this._tempLookAt4;
  7217. lookAt3Element.x=lookAt4Element.x;
  7218. lookAt3Element.y=lookAt4Element.y;
  7219. lookAt3Element.z=lookAt4Element.z;
  7220. var lightUpElement=this._tempLightUp;
  7221. sceneCamera.transform.worldMatrix.getForward(ParallelSplitShadowMap._tempVector30);
  7222. var sceneCameraDir=ParallelSplitShadowMap._tempVector30;
  7223. lightUpElement.x=sceneCameraDir.x;
  7224. lightUpElement.y=1.0;
  7225. lightUpElement.z=sceneCameraDir.z;
  7226. Vector3.normalize(this._tempLightUp,this._tempLightUp);
  7227. Vector3.scale(this._globalParallelLightDir,boundSphere.radius *4,this._tempPos);
  7228. Vector3.subtract(this._tempLookAt3,this._tempPos,this._tempPos);
  7229. var curLightCamera=this.cameras[this._currentPSSM];
  7230. curLightCamera.transform.position=this._tempPos;
  7231. curLightCamera.transform.lookAt(this._tempLookAt3,this._tempLightUp,false);
  7232. var tempMax=this._tempMax;
  7233. var tempMin=this._tempMin;
  7234. tempMax.x=tempMax.y=tempMax.z=-100000.0;
  7235. tempMax.w=1.0;
  7236. tempMin.x=tempMin.y=tempMin.z=100000.0;
  7237. tempMin.w=1.0;
  7238. Matrix4x4.multiply(curLightCamera.viewMatrix,cameraMatViewInv,this._tempMatrix44);
  7239. var tempValueElement=this._tempValue;
  7240. var corners=[];
  7241. corners.length=8;
  7242. this._boundingBox[this._currentPSSM].getCorners(corners);
  7243. for (var i=0;i < 8;i++){
  7244. var frustumPosElements=corners[i];
  7245. tempValueElement.x=frustumPosElements.x;
  7246. tempValueElement.y=frustumPosElements.y;
  7247. tempValueElement.z=frustumPosElements.z;
  7248. tempValueElement.w=1.0;
  7249. Vector4.transformByM4x4(this._tempValue,this._tempMatrix44,this._tempValue);
  7250. tempMin.x=(tempValueElement.x < tempMin.x)? tempValueElement.x :tempMin.x;
  7251. tempMin.y=(tempValueElement.y < tempMin.y)? tempValueElement.y :tempMin.y;
  7252. tempMin.z=(tempValueElement.z < tempMin.z)? tempValueElement.z :tempMin.z;
  7253. tempMax.x=(tempValueElement.x > tempMax.x)? tempValueElement.x :tempMax.x;
  7254. tempMax.y=(tempValueElement.y > tempMax.y)? tempValueElement.y :tempMax.y;
  7255. tempMax.z=(tempValueElement.z > tempMax.z)? tempValueElement.z :tempMax.z;
  7256. }
  7257. Vector4.add(this._tempMax,this._tempMin,this._tempValue);
  7258. tempValueElement.x *=0.5;
  7259. tempValueElement.y *=0.5;
  7260. tempValueElement.z *=0.5;
  7261. tempValueElement.w=1;
  7262. Vector4.transformByM4x4(this._tempValue,curLightCamera.transform.worldMatrix,this._tempValue);
  7263. var distance=Math.abs(-this._tempMax.z);
  7264. var farPlane=distance > this._maxDistance ? distance :this._maxDistance;
  7265. Vector3.scale(this._globalParallelLightDir,farPlane,this._tempPos);
  7266. var tempPosElement=this._tempPos;
  7267. tempPosElement.x=tempValueElement.x-tempPosElement.x;
  7268. tempPosElement.y=tempValueElement.y-tempPosElement.y;
  7269. tempPosElement.z=tempValueElement.z-tempPosElement.z;
  7270. curLightCamera.transform.position=this._tempPos;
  7271. curLightCamera.transform.lookAt(this._tempLookAt3,this._tempLightUp,false);
  7272. Matrix4x4.createOrthoOffCenter(tempMin.x,tempMax.x,tempMin.y,tempMax.y,1.0,farPlane+0.5 *(tempMax.z-tempMin.z),curLightCamera.projectionMatrix);
  7273. var projectView=curLightCamera.projectionViewMatrix;
  7274. ParallelSplitShadowMap.multiplyMatrixOutFloat32Array(this._tempScaleMatrix44,projectView,this._shaderValueVPs[this._currentPSSM]);
  7275. this._scene._shaderValues.setBuffer(Scene3D.SHADOWLIGHTVIEWPROJECT,this._shaderValueLightVP);
  7276. }
  7277. __proto.setShadowMapTextureSize=function(size){
  7278. if (size!==this._shadowMapTextureSize){
  7279. this._shadowMapTextureSize=size;
  7280. this._shadowPCFOffset.x=1 / this._shadowMapTextureSize;
  7281. this._shadowPCFOffset.y=1 / this._shadowMapTextureSize;
  7282. this._statesDirty=true;
  7283. }
  7284. }
  7285. __proto.disposeAllRenderTarget=function(){
  7286. for (var i=0,n=this._shadowMapCount+1;i < n;i++){
  7287. if (this.cameras[i].renderTarget){
  7288. this.cameras[i].renderTarget.destroy();
  7289. this.cameras[i].renderTarget=null;
  7290. }
  7291. }
  7292. }
  7293. __getset(0,__proto,'shadowMapCount',function(){
  7294. return this._shadowMapCount;
  7295. },function(value){
  7296. value=value > 0 ? value :1;
  7297. value=value <=3 ? value :3;
  7298. if (this._shadowMapCount !=value){
  7299. this._shadowMapCount=value;
  7300. this._ratioOfDistance=1.0 / this._shadowMapCount;
  7301. this._statesDirty=true;
  7302. this._shaderValueLightVP=new Float32Array(value *16);
  7303. this._shaderValueVPs.length=value;
  7304. for (var i=0;i < value;i++)
  7305. this._shaderValueVPs[i]=new Float32Array(this._shaderValueLightVP.buffer,i *64);
  7306. }
  7307. });
  7308. ParallelSplitShadowMap.multiplyMatrixOutFloat32Array=function(left,right,out){
  7309. var i,a,b,ai0,ai1,ai2,ai3;
  7310. a=left.elements;
  7311. b=right.elements;
  7312. for (i=0;i < 4;i++){
  7313. ai0=a[i];
  7314. ai1=a[i+4];
  7315. ai2=a[i+8];
  7316. ai3=a[i+12];
  7317. out[i]=ai0 *b[0]+ai1 *b[1]+ai2 *b[2]+ai3 *b[3];
  7318. out[i+4]=ai0 *b[4]+ai1 *b[5]+ai2 *b[6]+ai3 *b[7];
  7319. out[i+8]=ai0 *b[8]+ai1 *b[9]+ai2 *b[10]+ai3 *b[11];
  7320. out[i+12]=ai0 *b[12]+ai1 *b[13]+ai2 *b[14]+ai3 *b[15];
  7321. }
  7322. }
  7323. ParallelSplitShadowMap.MAX_PSSM_COUNT=3;
  7324. __static(ParallelSplitShadowMap,
  7325. ['_tempVector30',function(){return this._tempVector30=new Vector3();}
  7326. ]);
  7327. return ParallelSplitShadowMap;
  7328. })()
  7329. /**
  7330. *<code>PrimitiveMesh</code> 类用于创建简单网格。
  7331. */
  7332. //class laya.d3.resource.models.PrimitiveMesh
  7333. var PrimitiveMesh=(function(){
  7334. function PrimitiveMesh(){}
  7335. __class(PrimitiveMesh,'laya.d3.resource.models.PrimitiveMesh');
  7336. PrimitiveMesh._createMesh=function(vertexDeclaration,vertices,indices){
  7337. var mesh=new Mesh();
  7338. var subMesh=new SubMesh(mesh);
  7339. var vertexBuffer=new VertexBuffer3D(vertices.length *4,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,true);
  7340. vertexBuffer.vertexDeclaration=vertexDeclaration;
  7341. vertexBuffer.setData(vertices);
  7342. mesh._vertexBuffers.push(vertexBuffer);
  7343. mesh._vertexCount+=vertexBuffer.vertexCount;
  7344. var indexBuffer=new IndexBuffer3D(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",indices.length,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,true);
  7345. indexBuffer.setData(indices);
  7346. mesh._indexBuffer=indexBuffer;
  7347. var vertexBuffers=__newvec(1,null);
  7348. vertexBuffers[0]=vertexBuffer;
  7349. mesh._setBuffer(vertexBuffers,indexBuffer);
  7350. subMesh._vertexBuffer=vertexBuffer;
  7351. subMesh._indexBuffer=indexBuffer;
  7352. subMesh._indexStart=0;
  7353. subMesh._indexCount=indexBuffer.indexCount;
  7354. var subIndexBufferStart=subMesh._subIndexBufferStart;
  7355. var subIndexBufferCount=subMesh._subIndexBufferCount;
  7356. var boneIndicesList=subMesh._boneIndicesList;
  7357. subIndexBufferStart.length=1;
  7358. subIndexBufferCount.length=1;
  7359. boneIndicesList.length=1;
  7360. subIndexBufferStart[0]=0;
  7361. subIndexBufferCount[0]=indexBuffer.indexCount;
  7362. var subMeshes=[];
  7363. subMeshes.push(subMesh);
  7364. mesh._setSubMeshes(subMeshes);
  7365. var memorySize=vertexBuffer._byteLength+indexBuffer._byteLength;
  7366. mesh._setCPUMemory(memorySize);
  7367. mesh._setGPUMemory(memorySize);
  7368. return mesh;
  7369. }
  7370. PrimitiveMesh.createBox=function(long,height,width){
  7371. (long===void 0)&& (long=1);
  7372. (height===void 0)&& (height=1);
  7373. (width===void 0)&& (width=1);
  7374. var vertexCount=24;
  7375. var indexCount=36;
  7376. var vertexDeclaration=VertexMesh.getVertexDeclaration("POSITION,NORMAL,UV");
  7377. var halfLong=long / 2;
  7378. var halfHeight=height / 2;
  7379. var halfWidth=width / 2;
  7380. var vertices=new Float32Array([
  7381. -halfLong,halfHeight,-halfWidth,0,1,0,0,0,halfLong,halfHeight,-halfWidth,0,1,0,1,0,halfLong,halfHeight,halfWidth,0,1,0,1,1,-halfLong,halfHeight,halfWidth,0,1,0,0,1,
  7382. -halfLong,-halfHeight,-halfWidth,0,-1,0,0,1,halfLong,-halfHeight,-halfWidth,0,-1,0,1,1,halfLong,-halfHeight,halfWidth,0,-1,0,1,0,-halfLong,-halfHeight,halfWidth,0,-1,0,0,0,
  7383. -halfLong,halfHeight,-halfWidth,-1,0,0,0,0,-halfLong,halfHeight,halfWidth,-1,0,0,1,0,-halfLong,-halfHeight,halfWidth,-1,0,0,1,1,-halfLong,-halfHeight,-halfWidth,-1,0,0,0,1,
  7384. halfLong,halfHeight,-halfWidth,1,0,0,1,0,halfLong,halfHeight,halfWidth,1,0,0,0,0,halfLong,-halfHeight,halfWidth,1,0,0,0,1,halfLong,-halfHeight,-halfWidth,1,0,0,1,1,
  7385. -halfLong,halfHeight,halfWidth,0,0,1,0,0,halfLong,halfHeight,halfWidth,0,0,1,1,0,halfLong,-halfHeight,halfWidth,0,0,1,1,1,-halfLong,-halfHeight,halfWidth,0,0,1,0,1,
  7386. -halfLong,halfHeight,-halfWidth,0,0,-1,1,0,halfLong,halfHeight,-halfWidth,0,0,-1,0,0,halfLong,-halfHeight,-halfWidth,0,0,-1,0,1,-halfLong,-halfHeight,-halfWidth,0,0,-1,1,1]);
  7387. var indices=new Uint16Array([
  7388. 0,1,2,2,3,0,
  7389. 4,7,6,6,5,4,
  7390. 8,9,10,10,11,8,
  7391. 12,15,14,14,13,12,
  7392. 16,17,18,18,19,16,
  7393. 20,23,22,22,21,20]);
  7394. return PrimitiveMesh._createMesh(vertexDeclaration,vertices,indices);
  7395. }
  7396. PrimitiveMesh.createCapsule=function(radius,height,stacks,slices){
  7397. (radius===void 0)&& (radius=0.5);
  7398. (height===void 0)&& (height=2);
  7399. (stacks===void 0)&& (stacks=16);
  7400. (slices===void 0)&& (slices=32);
  7401. var vertexCount=(stacks+1)*(slices+1)*2+(slices+1)*2;
  7402. var indexCount=(3 *stacks *(slices+1))*2 *2+2 *slices *3;
  7403. var vertexDeclaration=VertexMesh.getVertexDeclaration("POSITION,NORMAL,UV");
  7404. var vertexFloatStride=vertexDeclaration.vertexStride / 4;
  7405. var vertices=new Float32Array(vertexCount *vertexFloatStride);
  7406. var indices=new Uint16Array(indexCount);
  7407. var stackAngle=(Math.PI / 2.0)/ stacks;
  7408. var sliceAngle=(Math.PI *2.0)/ slices;
  7409. var hcHeight=height / 2-radius;
  7410. var posX=0;
  7411. var posY=0;
  7412. var posZ=0;
  7413. var vc=0;
  7414. var ic=0;
  7415. var verticeCount=0;
  7416. var stack=0,slice=0;
  7417. for (stack=0;stack <=stacks;stack++){
  7418. for (slice=0;slice <=slices;slice++){
  7419. posX=radius *Math.cos(stack *stackAngle)*Math.cos(slice *sliceAngle+Math.PI);
  7420. posY=radius *Math.sin(stack *stackAngle);
  7421. posZ=radius *Math.cos(stack *stackAngle)*Math.sin(slice *sliceAngle+Math.PI);
  7422. vertices[vc++]=posX;
  7423. vertices[vc++]=posY+hcHeight;
  7424. vertices[vc++]=posZ;
  7425. vertices[vc++]=posX;
  7426. vertices[vc++]=posY;
  7427. vertices[vc++]=posZ;
  7428. vertices[vc++]=1-slice / slices;
  7429. vertices[vc++]=(1-stack / stacks)*((Math.PI *radius / 2)/ (height+Math.PI *radius));
  7430. if (stack < stacks){
  7431. indices[ic++]=(stack *(slices+1))+slice+(slices+1);
  7432. indices[ic++]=(stack *(slices+1))+slice;
  7433. indices[ic++]=(stack *(slices+1))+slice+1;
  7434. indices[ic++]=(stack *(slices+1))+slice+(slices);
  7435. indices[ic++]=(stack *(slices+1))+slice;
  7436. indices[ic++]=(stack *(slices+1))+slice+(slices+1);
  7437. }
  7438. }
  7439. }
  7440. verticeCount+=(stacks+1)*(slices+1);
  7441. for (stack=0;stack <=stacks;stack++){
  7442. for (slice=0;slice <=slices;slice++){
  7443. posX=radius *Math.cos(stack *stackAngle)*Math.cos(slice *sliceAngle+Math.PI);
  7444. posY=radius *Math.sin(-stack *stackAngle);
  7445. posZ=radius *Math.cos(stack *stackAngle)*Math.sin(slice *sliceAngle+Math.PI);
  7446. vertices[vc++]=posX;
  7447. vertices[vc++]=posY-hcHeight;
  7448. vertices[vc++]=posZ;
  7449. vertices[vc++]=posX;
  7450. vertices[vc++]=posY;
  7451. vertices[vc++]=posZ;
  7452. vertices[vc++]=1-slice / slices;
  7453. vertices[vc++]=((stack / stacks)*(Math.PI *radius / 2)+(height+Math.PI *radius / 2))/ (height+Math.PI *radius);
  7454. if (stack < stacks){
  7455. indices[ic++]=verticeCount+(stack *(slices+1))+slice;
  7456. indices[ic++]=verticeCount+(stack *(slices+1))+slice+(slices+1);
  7457. indices[ic++]=verticeCount+(stack *(slices+1))+slice+1;
  7458. indices[ic++]=verticeCount+(stack *(slices+1))+slice;
  7459. indices[ic++]=verticeCount+(stack *(slices+1))+slice+(slices);
  7460. indices[ic++]=verticeCount+(stack *(slices+1))+slice+(slices+1);
  7461. }
  7462. }
  7463. }
  7464. verticeCount+=(stacks+1)*(slices+1);
  7465. for (slice=0;slice <=slices;slice++){
  7466. posX=radius *Math.cos(slice *sliceAngle+Math.PI);
  7467. posY=hcHeight;
  7468. posZ=radius *Math.sin(slice *sliceAngle+Math.PI);
  7469. vertices[vc++]=posX;
  7470. vertices[vc+(slices+1)*8-1]=posX;
  7471. vertices[vc++]=posY;
  7472. vertices[vc+(slices+1)*8-1]=-posY;
  7473. vertices[vc++]=posZ;
  7474. vertices[vc+(slices+1)*8-1]=posZ;
  7475. vertices[vc++]=posX;
  7476. vertices[vc+(slices+1)*8-1]=posX;
  7477. vertices[vc++]=0;
  7478. vertices[vc+(slices+1)*8-1]=0;
  7479. vertices[vc++]=posZ;
  7480. vertices[vc+(slices+1)*8-1]=posZ;
  7481. vertices[vc++]=1-slice *1 / slices;
  7482. vertices[vc+(slices+1)*8-1]=1-slice *1 / slices;
  7483. vertices[vc++]=(Math.PI *radius / 2)/ (height+Math.PI *radius);
  7484. vertices[vc+(slices+1)*8-1]=(Math.PI *radius / 2+height)/ (height+Math.PI *radius);
  7485. }
  7486. for (slice=0;slice < slices;slice++){
  7487. indices[ic++]=slice+verticeCount+(slices+1);
  7488. indices[ic++]=slice+verticeCount+1;
  7489. indices[ic++]=slice+verticeCount;
  7490. indices[ic++]=slice+verticeCount+(slices+1);
  7491. indices[ic++]=slice+verticeCount+(slices+1)+1;
  7492. indices[ic++]=slice+verticeCount+1;
  7493. }
  7494. verticeCount+=2 *(slices+1);
  7495. return PrimitiveMesh._createMesh(vertexDeclaration,vertices,indices);
  7496. }
  7497. PrimitiveMesh.createCone=function(radius,height,slices){
  7498. (radius===void 0)&& (radius=0.5);
  7499. (height===void 0)&& (height=1);
  7500. (slices===void 0)&& (slices=32);
  7501. var vertexCount=(slices+1+1)+(slices+1)*2;
  7502. var indexCount=6 *slices+3 *slices;
  7503. var vertexDeclaration=VertexMesh.getVertexDeclaration("POSITION,NORMAL,UV");
  7504. var vertexFloatStride=vertexDeclaration.vertexStride / 4;
  7505. var vertices=new Float32Array(vertexCount *vertexFloatStride);
  7506. var indices=new Uint16Array(indexCount);
  7507. var sliceAngle=(Math.PI *2.0)/ slices;
  7508. var halfHeight=height / 2;
  7509. var curAngle=0;
  7510. var verticeCount=0;
  7511. var posX=0;
  7512. var posY=0;
  7513. var posZ=0;
  7514. var normal=new Vector3();
  7515. var downV3=new Vector3(0,-1,0);
  7516. var upPoint=new Vector3(0,halfHeight,0);
  7517. var downPoint=new Vector3();
  7518. var v3=new Vector3();
  7519. var q4=new Quaternion();
  7520. var rotateAxis=new Vector3();
  7521. var rotateRadius=NaN;
  7522. var vc=0;
  7523. var ic=0;
  7524. for (var rv=0;rv <=slices;rv++){
  7525. curAngle=rv *sliceAngle;
  7526. posX=Math.cos(curAngle+Math.PI)*radius;
  7527. posY=halfHeight;
  7528. posZ=Math.sin(curAngle+Math.PI)*radius;
  7529. vertices[vc++]=0;
  7530. vertices[vc+(slices+1)*8-1]=posX;
  7531. vertices[vc++]=posY;
  7532. vertices[vc+(slices+1)*8-1]=-posY;
  7533. vertices[vc++]=0;
  7534. vertices[vc+(slices+1)*8-1]=posZ;
  7535. normal.x=posX;
  7536. normal.y=0;
  7537. normal.z=posZ;
  7538. downPoint.x=posX;
  7539. downPoint.y=-posY;
  7540. downPoint.z=posZ;
  7541. Vector3.subtract(downPoint,upPoint,v3);
  7542. Vector3.normalize(v3,v3);
  7543. rotateRadius=Math.acos(Vector3.dot(downV3,v3));
  7544. Vector3.cross(downV3,v3,rotateAxis);
  7545. Vector3.normalize(rotateAxis,rotateAxis);
  7546. Quaternion.createFromAxisAngle(rotateAxis,rotateRadius,q4);
  7547. Vector3.normalize(normal,normal);
  7548. Vector3.transformQuat(normal,q4,normal);
  7549. Vector3.normalize(normal,normal);
  7550. vertices[vc++]=normal.x;
  7551. vertices[vc+(slices+1)*8-1]=normal.x;
  7552. vertices[vc++]=normal.y;
  7553. vertices[vc+(slices+1)*8-1]=normal.y;
  7554. vertices[vc++]=normal.z;
  7555. vertices[vc+(slices+1)*8-1]=normal.z;
  7556. vertices[vc++]=1-rv *1 / slices;
  7557. vertices[vc+(slices+1)*8-1]=1-rv *1 / slices;
  7558. vertices[vc++]=0;
  7559. vertices[vc+(slices+1)*8-1]=1;
  7560. }
  7561. vc+=(slices+1)*8;
  7562. for (var ri=0;ri < slices;ri++){
  7563. indices[ic++]=ri+verticeCount+(slices+1);
  7564. indices[ic++]=ri+verticeCount+1;
  7565. indices[ic++]=ri+verticeCount;
  7566. indices[ic++]=ri+verticeCount+(slices+1);
  7567. indices[ic++]=ri+verticeCount+(slices+1)+1;
  7568. indices[ic++]=ri+verticeCount+1;
  7569. }
  7570. verticeCount+=2 *(slices+1);
  7571. for (var bv=0;bv <=slices;bv++){
  7572. if (bv===0){
  7573. vertices[vc++]=0;
  7574. vertices[vc++]=-halfHeight;
  7575. vertices[vc++]=0;
  7576. vertices[vc++]=0;
  7577. vertices[vc++]=-1;
  7578. vertices[vc++]=0;
  7579. vertices[vc++]=0.5;
  7580. vertices[vc++]=0.5;
  7581. }
  7582. curAngle=bv *sliceAngle;
  7583. posX=Math.cos(curAngle+Math.PI)*radius;
  7584. posY=-halfHeight;
  7585. posZ=Math.sin(curAngle+Math.PI)*radius;
  7586. vertices[vc++]=posX;
  7587. vertices[vc++]=posY;
  7588. vertices[vc++]=posZ;
  7589. vertices[vc++]=0;
  7590. vertices[vc++]=-1;
  7591. vertices[vc++]=0;
  7592. vertices[vc++]=0.5+Math.cos(curAngle)*0.5;
  7593. vertices[vc++]=0.5+Math.sin(curAngle)*0.5;
  7594. }
  7595. for (var bi=0;bi < slices;bi++){
  7596. indices[ic++]=0+verticeCount;
  7597. indices[ic++]=bi+2+verticeCount;
  7598. indices[ic++]=bi+1+verticeCount;
  7599. }
  7600. verticeCount+=slices+1+1;
  7601. return PrimitiveMesh._createMesh(vertexDeclaration,vertices,indices);
  7602. }
  7603. PrimitiveMesh.createCylinder=function(radius,height,slices){
  7604. (radius===void 0)&& (radius=0.5);
  7605. (height===void 0)&& (height=2);
  7606. (slices===void 0)&& (slices=32);
  7607. var vertexCount=(slices+1+1)+(slices+1)*2+(slices+1+1);
  7608. var indexCount=3 *slices+6 *slices+3 *slices;
  7609. var vertexDeclaration=VertexMesh.getVertexDeclaration("POSITION,NORMAL,UV");
  7610. var vertexFloatStride=vertexDeclaration.vertexStride / 4;
  7611. var vertices=new Float32Array(vertexCount *vertexFloatStride);
  7612. var indices=new Uint16Array(indexCount);
  7613. var sliceAngle=(Math.PI *2.0)/ slices;
  7614. var halfHeight=height / 2;
  7615. var curAngle=0;
  7616. var verticeCount=0;
  7617. var posX=0;
  7618. var posY=0;
  7619. var posZ=0;
  7620. var vc=0;
  7621. var ic=0;
  7622. for (var tv=0;tv <=slices;tv++){
  7623. if (tv===0){
  7624. vertices[vc++]=0;
  7625. vertices[vc++]=halfHeight;
  7626. vertices[vc++]=0;
  7627. vertices[vc++]=0;
  7628. vertices[vc++]=1;
  7629. vertices[vc++]=0;
  7630. vertices[vc++]=0.5;
  7631. vertices[vc++]=0.5;
  7632. }
  7633. curAngle=tv *sliceAngle;
  7634. posX=Math.cos(curAngle)*radius;
  7635. posY=halfHeight;
  7636. posZ=Math.sin(curAngle)*radius;
  7637. vertices[vc++]=posX;
  7638. vertices[vc++]=posY;
  7639. vertices[vc++]=posZ;
  7640. vertices[vc++]=0;
  7641. vertices[vc++]=1;
  7642. vertices[vc++]=0;
  7643. vertices[vc++]=0.5+Math.cos(curAngle)*0.5;
  7644. vertices[vc++]=0.5+Math.sin(curAngle)*0.5;
  7645. }
  7646. for (var ti=0;ti < slices;ti++){
  7647. indices[ic++]=0;
  7648. indices[ic++]=ti+1;
  7649. indices[ic++]=ti+2;
  7650. }
  7651. verticeCount+=slices+1+1;
  7652. for (var rv=0;rv <=slices;rv++){
  7653. curAngle=rv *sliceAngle;
  7654. posX=Math.cos(curAngle+Math.PI)*radius;
  7655. posY=halfHeight;
  7656. posZ=Math.sin(curAngle+Math.PI)*radius;
  7657. vertices[vc++]=posX;
  7658. vertices[vc+(slices+1)*8-1]=posX;
  7659. vertices[vc++]=posY;
  7660. vertices[vc+(slices+1)*8-1]=-posY;
  7661. vertices[vc++]=posZ;
  7662. vertices[vc+(slices+1)*8-1]=posZ;
  7663. vertices[vc++]=posX;
  7664. vertices[vc+(slices+1)*8-1]=posX;
  7665. vertices[vc++]=0;
  7666. vertices[vc+(slices+1)*8-1]=0;
  7667. vertices[vc++]=posZ;
  7668. vertices[vc+(slices+1)*8-1]=posZ;
  7669. vertices[vc++]=1-rv *1 / slices;
  7670. vertices[vc+(slices+1)*8-1]=1-rv *1 / slices;
  7671. vertices[vc++]=0;
  7672. vertices[vc+(slices+1)*8-1]=1;
  7673. }
  7674. vc+=(slices+1)*8;
  7675. for (var ri=0;ri < slices;ri++){
  7676. indices[ic++]=ri+verticeCount+(slices+1);
  7677. indices[ic++]=ri+verticeCount+1;
  7678. indices[ic++]=ri+verticeCount;
  7679. indices[ic++]=ri+verticeCount+(slices+1);
  7680. indices[ic++]=ri+verticeCount+(slices+1)+1;
  7681. indices[ic++]=ri+verticeCount+1;
  7682. }
  7683. verticeCount+=2 *(slices+1);
  7684. for (var bv=0;bv <=slices;bv++){
  7685. if (bv===0){
  7686. vertices[vc++]=0;
  7687. vertices[vc++]=-halfHeight;
  7688. vertices[vc++]=0;
  7689. vertices[vc++]=0;
  7690. vertices[vc++]=-1;
  7691. vertices[vc++]=0;
  7692. vertices[vc++]=0.5;
  7693. vertices[vc++]=0.5;
  7694. }
  7695. curAngle=bv *sliceAngle;
  7696. posX=Math.cos(curAngle+Math.PI)*radius;
  7697. posY=-halfHeight;
  7698. posZ=Math.sin(curAngle+Math.PI)*radius;
  7699. vertices[vc++]=posX;
  7700. vertices[vc++]=posY;
  7701. vertices[vc++]=posZ;
  7702. vertices[vc++]=0;
  7703. vertices[vc++]=-1;
  7704. vertices[vc++]=0;
  7705. vertices[vc++]=0.5+Math.cos(curAngle)*0.5;
  7706. vertices[vc++]=0.5+Math.sin(curAngle)*0.5;
  7707. }
  7708. for (var bi=0;bi < slices;bi++){
  7709. indices[ic++]=0+verticeCount;
  7710. indices[ic++]=bi+2+verticeCount;
  7711. indices[ic++]=bi+1+verticeCount;
  7712. }
  7713. verticeCount+=slices+1+1;
  7714. return PrimitiveMesh._createMesh(vertexDeclaration,vertices,indices);
  7715. }
  7716. PrimitiveMesh.createPlane=function(long,width,stacks,slices){
  7717. (long===void 0)&& (long=10);
  7718. (width===void 0)&& (width=10);
  7719. (stacks===void 0)&& (stacks=10);
  7720. (slices===void 0)&& (slices=10);
  7721. var vertexCount=(stacks+1)*(slices+1);
  7722. var indexCount=stacks *slices *2 *3;
  7723. var indices=new Uint16Array(indexCount);
  7724. var vertexDeclaration=VertexMesh.getVertexDeclaration("POSITION,NORMAL,UV");
  7725. var vertexFloatStride=vertexDeclaration.vertexStride / 4;
  7726. var vertices=new Float32Array(vertexCount *vertexFloatStride);
  7727. var halfLong=long / 2;
  7728. var halfWidth=width / 2;
  7729. var stacksLong=long / stacks;
  7730. var slicesWidth=width / slices;
  7731. var verticeCount=0;
  7732. for (var i=0;i <=slices;i++){
  7733. for (var j=0;j <=stacks;j++){
  7734. vertices[verticeCount++]=j *stacksLong-halfLong;
  7735. vertices[verticeCount++]=0;
  7736. vertices[verticeCount++]=i *slicesWidth-halfWidth;
  7737. vertices[verticeCount++]=0;
  7738. vertices[verticeCount++]=1;
  7739. vertices[verticeCount++]=0;
  7740. vertices[verticeCount++]=j *1 / stacks;
  7741. vertices[verticeCount++]=i *1 / slices;
  7742. }
  7743. };
  7744. var indiceIndex=0;
  7745. for (i=0;i < slices;i++){
  7746. for (j=0;j < stacks;j++){
  7747. indices[indiceIndex++]=(i+1)*(stacks+1)+j;
  7748. indices[indiceIndex++]=i *(stacks+1)+j;
  7749. indices[indiceIndex++]=(i+1)*(stacks+1)+j+1;
  7750. indices[indiceIndex++]=i *(stacks+1)+j;
  7751. indices[indiceIndex++]=i *(stacks+1)+j+1;
  7752. indices[indiceIndex++]=(i+1)*(stacks+1)+j+1;
  7753. }
  7754. }
  7755. return PrimitiveMesh._createMesh(vertexDeclaration,vertices,indices);
  7756. }
  7757. PrimitiveMesh.createQuad=function(long,width){
  7758. (long===void 0)&& (long=1);
  7759. (width===void 0)&& (width=1);
  7760. var vertexCount=4;
  7761. var indexCount=6;
  7762. var vertexDeclaration=VertexMesh.getVertexDeclaration("POSITION,NORMAL,UV");
  7763. var vertexFloatStride=vertexDeclaration.vertexStride / 4;
  7764. var halfLong=long / 2;
  7765. var halfWidth=width / 2;
  7766. var vertices=new Float32Array([
  7767. -halfLong,halfWidth,0,0,0,1,0,0,halfLong,halfWidth,0,0,0,1,1,0,-halfLong,-halfWidth,0,0,0,1,0,1,halfLong,-halfWidth,0,0,0,1,1,1,]);
  7768. var indices=new Uint16Array([
  7769. 0,1,2,3,2,1,]);
  7770. return PrimitiveMesh._createMesh(vertexDeclaration,vertices,indices);
  7771. }
  7772. PrimitiveMesh.createSphere=function(radius,stacks,slices){
  7773. (radius===void 0)&& (radius=0.5);
  7774. (stacks===void 0)&& (stacks=32);
  7775. (slices===void 0)&& (slices=32);
  7776. var vertexCount=(stacks+1)*(slices+1);
  7777. var indexCount=(3 *stacks *(slices+1))*2;
  7778. var indices=new Uint16Array(indexCount);
  7779. var vertexDeclaration=VertexMesh.getVertexDeclaration("POSITION,NORMAL,UV");
  7780. var vertexFloatStride=vertexDeclaration.vertexStride / 4;
  7781. var vertices=new Float32Array(vertexCount *vertexFloatStride);
  7782. var stackAngle=Math.PI / stacks;
  7783. var sliceAngle=(Math.PI *2.0)/ slices;
  7784. var vertexIndex=0;
  7785. vertexCount=0;
  7786. indexCount=0;
  7787. for (var stack=0;stack < (stacks+1);stack++){
  7788. var r=Math.sin(stack *stackAngle);
  7789. var y=Math.cos(stack *stackAngle);
  7790. for (var slice=0;slice < (slices+1);slice++){
  7791. var x=r *Math.sin(slice *sliceAngle+Math.PI *1 / 2);
  7792. var z=r *Math.cos(slice *sliceAngle+Math.PI *1 / 2);
  7793. vertices[vertexCount+0]=x *radius;
  7794. vertices[vertexCount+1]=y *radius;
  7795. vertices[vertexCount+2]=z *radius;
  7796. vertices[vertexCount+3]=x;
  7797. vertices[vertexCount+4]=y;
  7798. vertices[vertexCount+5]=z;
  7799. vertices[vertexCount+6]=slice / slices;
  7800. vertices[vertexCount+7]=stack / stacks;
  7801. vertexCount+=vertexFloatStride;
  7802. if (stack !=(stacks-1)){
  7803. indices[indexCount++]=vertexIndex+(slices+1);
  7804. indices[indexCount++]=vertexIndex;
  7805. indices[indexCount++]=vertexIndex+1;
  7806. indices[indexCount++]=vertexIndex+(slices);
  7807. indices[indexCount++]=vertexIndex;
  7808. indices[indexCount++]=vertexIndex+(slices+1);
  7809. vertexIndex++;
  7810. }
  7811. }
  7812. }
  7813. return PrimitiveMesh._createMesh(vertexDeclaration,vertices,indices);
  7814. }
  7815. return PrimitiveMesh;
  7816. })()
  7817. /**
  7818. *<code>PostProcessEffect</code> 类用于创建后期处理渲染效果。
  7819. */
  7820. //class laya.d3.core.render.PostProcessEffect
  7821. var PostProcessEffect=(function(){
  7822. /**
  7823. *创建一个 <code>PostProcessEffect</code> 实例。
  7824. */
  7825. function PostProcessEffect(){}
  7826. __class(PostProcessEffect,'laya.d3.core.render.PostProcessEffect');
  7827. var __proto=PostProcessEffect.prototype;
  7828. /**
  7829. *@private
  7830. */
  7831. __proto.render=function(context){}
  7832. return PostProcessEffect;
  7833. })()
  7834. /**
  7835. *@private
  7836. */
  7837. //class laya.d3.animation.AnimationClipParser04
  7838. var AnimationClipParser04=(function(){
  7839. function AnimationClipParser04(){}
  7840. __class(AnimationClipParser04,'laya.d3.animation.AnimationClipParser04');
  7841. AnimationClipParser04.READ_DATA=function(){
  7842. AnimationClipParser04._DATA.offset=AnimationClipParser04._reader.getUint32();
  7843. AnimationClipParser04._DATA.size=AnimationClipParser04._reader.getUint32();
  7844. }
  7845. AnimationClipParser04.READ_BLOCK=function(){
  7846. var count=AnimationClipParser04._BLOCK.count=AnimationClipParser04._reader.getUint16();
  7847. var blockStarts=AnimationClipParser04._BLOCK.blockStarts=[];
  7848. var blockLengths=AnimationClipParser04._BLOCK.blockLengths=[];
  7849. for (var i=0;i < count;i++){
  7850. blockStarts.push(AnimationClipParser04._reader.getUint32());
  7851. blockLengths.push(AnimationClipParser04._reader.getUint32());
  7852. }
  7853. }
  7854. AnimationClipParser04.READ_STRINGS=function(){
  7855. var offset=AnimationClipParser04._reader.getUint32();
  7856. var count=AnimationClipParser04._reader.getUint16();
  7857. var prePos=AnimationClipParser04._reader.pos;
  7858. AnimationClipParser04._reader.pos=offset+AnimationClipParser04._DATA.offset;
  7859. for (var i=0;i < count;i++)
  7860. AnimationClipParser04._strings[i]=AnimationClipParser04._reader.readUTFString();
  7861. AnimationClipParser04._reader.pos=prePos;
  7862. }
  7863. AnimationClipParser04.parse=function(clip,reader,version){
  7864. AnimationClipParser04._animationClip=clip;
  7865. AnimationClipParser04._reader=reader;
  7866. AnimationClipParser04._version=version;
  7867. AnimationClipParser04.READ_DATA();
  7868. AnimationClipParser04.READ_BLOCK();
  7869. AnimationClipParser04.READ_STRINGS();
  7870. for (var i=0,n=AnimationClipParser04._BLOCK.count;i < n;i++){
  7871. var index=reader.getUint16();
  7872. var blockName=AnimationClipParser04._strings[index];
  7873. var fn=AnimationClipParser04["READ_"+blockName];
  7874. if (fn==null)
  7875. throw new Error("model file err,no this function:"+index+" "+blockName);
  7876. else
  7877. fn.call(null);
  7878. }
  7879. AnimationClipParser04._version=null;
  7880. AnimationClipParser04._reader=null;
  7881. AnimationClipParser04._animationClip=null;
  7882. }
  7883. AnimationClipParser04.READ_ANIMATIONS=function(){
  7884. var i=0,j=0;
  7885. var node;
  7886. var reader=AnimationClipParser04._reader;
  7887. var buffer=reader.__getBuffer();
  7888. var startTimeTypes=[];
  7889. var startTimeTypeCount=reader.getUint16();
  7890. startTimeTypes.length=startTimeTypeCount;
  7891. for (i=0;i < startTimeTypeCount;i++)
  7892. startTimeTypes[i]=reader.getFloat32();
  7893. var clip=AnimationClipParser04._animationClip;
  7894. clip.name=AnimationClipParser04._strings[reader.getUint16()];
  7895. var clipDur=clip._duration=reader.getFloat32();
  7896. clip.islooping=!!reader.getByte();
  7897. clip._frameRate=reader.getInt16();
  7898. var nodeCount=reader.getInt16();
  7899. var nodes=clip._nodes;
  7900. nodes.count=nodeCount;
  7901. var nodesMap=clip._nodesMap={};
  7902. var nodesDic=clip._nodesDic={};
  7903. for (i=0;i < nodeCount;i++){
  7904. node=new KeyframeNode();
  7905. nodes.setNodeByIndex(i,node);
  7906. node._indexInList=i;
  7907. var type=node.type=reader.getUint8();
  7908. var pathLength=reader.getUint16();
  7909. node._setOwnerPathCount(pathLength);
  7910. for (j=0;j < pathLength;j++)
  7911. node._setOwnerPathByIndex(j,AnimationClipParser04._strings[reader.getUint16()]);
  7912. var nodePath=node._joinOwnerPath("/");
  7913. var mapArray=nodesMap[nodePath];
  7914. (mapArray)|| (nodesMap[nodePath]=mapArray=[]);
  7915. mapArray.push(node);
  7916. node.propertyOwner=AnimationClipParser04._strings[reader.getUint16()];
  7917. var propertyLength=reader.getUint16();
  7918. node._setPropertyCount(propertyLength);
  7919. for (j=0;j < propertyLength;j++)
  7920. node._setPropertyByIndex(j,AnimationClipParser04._strings[reader.getUint16()]);
  7921. var fullPath=nodePath+"."+node.propertyOwner+"."+node._joinProperty(".");
  7922. nodesDic[fullPath]=node;
  7923. node.fullPath=fullPath;
  7924. var keyframeCount=reader.getUint16();
  7925. node._setKeyframeCount(keyframeCount);
  7926. var startTime=NaN;
  7927. switch (type){
  7928. case 0:
  7929. break ;
  7930. case 1:
  7931. case 3:
  7932. case 4:
  7933. node.data=Render.supportWebGLPlusAnimation ? new ConchVector3 :new Vector3();
  7934. break ;
  7935. case 2:
  7936. node.data=Render.supportWebGLPlusAnimation ? new ConchQuaternion :new Quaternion();
  7937. break ;
  7938. default :
  7939. throw "AnimationClipParser04:unknown type.";
  7940. }
  7941. switch (AnimationClipParser04._version){
  7942. case "LAYAANIMATION:04":
  7943. for (j=0;j < keyframeCount;j++){
  7944. switch (type){
  7945. case 0:;
  7946. var floatKeyframe=new FloatKeyframe();
  7947. node._setKeyframeByIndex(j,floatKeyframe);
  7948. startTime=floatKeyframe.time=startTimeTypes[reader.getUint16()];
  7949. floatKeyframe.inTangent=reader.getFloat32();
  7950. floatKeyframe.outTangent=reader.getFloat32();
  7951. floatKeyframe.value=reader.getFloat32();
  7952. break ;
  7953. case 1:
  7954. case 3:
  7955. case 4:;
  7956. var floatArrayKeyframe=new Vector3Keyframe();
  7957. node._setKeyframeByIndex(j,floatArrayKeyframe);
  7958. startTime=floatArrayKeyframe.time=startTimeTypes[reader.getUint16()];
  7959. if (Render.supportWebGLPlusAnimation){
  7960. var data=(floatArrayKeyframe).data=new Float32Array(3 *3);
  7961. for (var k=0;k < 3;k++)
  7962. data[k]=reader.getFloat32();
  7963. for (k=0;k < 3;k++)
  7964. data[3+k]=reader.getFloat32();
  7965. for (k=0;k < 3;k++)
  7966. data[6+k]=reader.getFloat32();
  7967. }
  7968. else {
  7969. var inTangent=floatArrayKeyframe.inTangent;
  7970. var outTangent=floatArrayKeyframe.outTangent;
  7971. var value=floatArrayKeyframe.value;
  7972. inTangent.x=reader.getFloat32();
  7973. inTangent.y=reader.getFloat32();
  7974. inTangent.z=reader.getFloat32();
  7975. outTangent.x=reader.getFloat32();
  7976. outTangent.y=reader.getFloat32();
  7977. outTangent.z=reader.getFloat32();
  7978. value.x=reader.getFloat32();
  7979. value.y=reader.getFloat32();
  7980. value.z=reader.getFloat32();
  7981. }
  7982. break ;
  7983. case 2:;
  7984. var quaternionKeyframe=new QuaternionKeyframe();
  7985. node._setKeyframeByIndex(j,quaternionKeyframe);
  7986. startTime=quaternionKeyframe.time=startTimeTypes[reader.getUint16()];
  7987. if (Render.supportWebGLPlusAnimation){
  7988. data=(quaternionKeyframe).data=new Float32Array(3 *4);
  7989. for (k=0;k < 4;k++)
  7990. data[k]=reader.getFloat32();
  7991. for (k=0;k < 4;k++)
  7992. data[4+k]=reader.getFloat32();
  7993. for (k=0;k < 4;k++)
  7994. data[8+k]=reader.getFloat32();
  7995. }
  7996. else {
  7997. var inTangentQua=quaternionKeyframe.inTangent;
  7998. var outTangentQua=quaternionKeyframe.outTangent;
  7999. var valueQua=quaternionKeyframe.value;
  8000. inTangentQua.x=reader.getFloat32();
  8001. inTangentQua.y=reader.getFloat32();
  8002. inTangentQua.z=reader.getFloat32();
  8003. inTangentQua.w=reader.getFloat32();
  8004. outTangentQua.x=reader.getFloat32();
  8005. outTangentQua.y=reader.getFloat32();
  8006. outTangentQua.z=reader.getFloat32();
  8007. outTangentQua.w=reader.getFloat32();
  8008. valueQua.x=reader.getFloat32();
  8009. valueQua.y=reader.getFloat32();
  8010. valueQua.z=reader.getFloat32();
  8011. valueQua.w=reader.getFloat32();
  8012. }
  8013. break ;
  8014. default :
  8015. throw "AnimationClipParser04:unknown type.";
  8016. }
  8017. }
  8018. break ;
  8019. case "LAYAANIMATION:COMPRESSION_04":
  8020. for (j=0;j < keyframeCount;j++){
  8021. switch (type){
  8022. case 0:
  8023. floatKeyframe=new FloatKeyframe();
  8024. node._setKeyframeByIndex(j,floatKeyframe);
  8025. startTime=floatKeyframe.time=startTimeTypes[reader.getUint16()];
  8026. floatKeyframe.inTangent=HalfFloatUtils.convertToNumber(reader.getUint16());
  8027. floatKeyframe.outTangent=HalfFloatUtils.convertToNumber(reader.getUint16());
  8028. floatKeyframe.value=HalfFloatUtils.convertToNumber(reader.getUint16());
  8029. break ;
  8030. case 1:
  8031. case 3:
  8032. case 4:
  8033. floatArrayKeyframe=new Vector3Keyframe();
  8034. node._setKeyframeByIndex(j,floatArrayKeyframe);
  8035. startTime=floatArrayKeyframe.time=startTimeTypes[reader.getUint16()];
  8036. if (Render.supportWebGLPlusAnimation){
  8037. data=(floatArrayKeyframe).data=new Float32Array(3 *3);
  8038. for (k=0;k < 3;k++)
  8039. data[k]=HalfFloatUtils.convertToNumber(reader.getUint16());
  8040. for (k=0;k < 3;k++)
  8041. data[3+k]=HalfFloatUtils.convertToNumber(reader.getUint16());
  8042. for (k=0;k < 3;k++)
  8043. data[6+k]=HalfFloatUtils.convertToNumber(reader.getUint16());
  8044. }
  8045. else {
  8046. inTangent=floatArrayKeyframe.inTangent;
  8047. outTangent=floatArrayKeyframe.outTangent;
  8048. value=floatArrayKeyframe.value;
  8049. inTangent.x=HalfFloatUtils.convertToNumber(reader.getUint16());
  8050. inTangent.y=HalfFloatUtils.convertToNumber(reader.getUint16());
  8051. inTangent.z=HalfFloatUtils.convertToNumber(reader.getUint16());
  8052. outTangent.x=HalfFloatUtils.convertToNumber(reader.getUint16());
  8053. outTangent.y=HalfFloatUtils.convertToNumber(reader.getUint16());
  8054. outTangent.z=HalfFloatUtils.convertToNumber(reader.getUint16());
  8055. value.x=HalfFloatUtils.convertToNumber(reader.getUint16());
  8056. value.y=HalfFloatUtils.convertToNumber(reader.getUint16());
  8057. value.z=HalfFloatUtils.convertToNumber(reader.getUint16());
  8058. }
  8059. break ;
  8060. case 2:
  8061. quaternionKeyframe=new QuaternionKeyframe();
  8062. node._setKeyframeByIndex(j,quaternionKeyframe);
  8063. startTime=quaternionKeyframe.time=startTimeTypes[reader.getUint16()];
  8064. if (Render.supportWebGLPlusAnimation){
  8065. data=(quaternionKeyframe).data=new Float32Array(3 *4);
  8066. for (k=0;k < 4;k++)
  8067. data[k]=HalfFloatUtils.convertToNumber(reader.getUint16());
  8068. for (k=0;k < 4;k++)
  8069. data[4+k]=HalfFloatUtils.convertToNumber(reader.getUint16());
  8070. for (k=0;k < 4;k++)
  8071. data[8+k]=HalfFloatUtils.convertToNumber(reader.getUint16());
  8072. }
  8073. else {
  8074. inTangentQua=quaternionKeyframe.inTangent;
  8075. outTangentQua=quaternionKeyframe.outTangent;
  8076. valueQua=quaternionKeyframe.value;
  8077. inTangentQua.x=HalfFloatUtils.convertToNumber(reader.getUint16());
  8078. inTangentQua.y=HalfFloatUtils.convertToNumber(reader.getUint16());
  8079. inTangentQua.z=HalfFloatUtils.convertToNumber(reader.getUint16());
  8080. inTangentQua.w=HalfFloatUtils.convertToNumber(reader.getUint16());
  8081. outTangentQua.x=HalfFloatUtils.convertToNumber(reader.getUint16());
  8082. outTangentQua.y=HalfFloatUtils.convertToNumber(reader.getUint16());
  8083. outTangentQua.z=HalfFloatUtils.convertToNumber(reader.getUint16());
  8084. outTangentQua.w=HalfFloatUtils.convertToNumber(reader.getUint16());
  8085. valueQua.x=HalfFloatUtils.convertToNumber(reader.getUint16());
  8086. valueQua.y=HalfFloatUtils.convertToNumber(reader.getUint16());
  8087. valueQua.z=HalfFloatUtils.convertToNumber(reader.getUint16());
  8088. valueQua.w=HalfFloatUtils.convertToNumber(reader.getUint16());
  8089. }
  8090. break ;
  8091. default :
  8092. throw "AnimationClipParser04:unknown type.";
  8093. }
  8094. }
  8095. break ;
  8096. }
  8097. };
  8098. var eventCount=reader.getUint16();
  8099. for (i=0;i < eventCount;i++){
  8100. var event=new AnimationEvent();
  8101. event.time=Math.min(clipDur,reader.getFloat32());
  8102. event.eventName=AnimationClipParser04._strings[reader.getUint16()];
  8103. var params;
  8104. var paramCount=reader.getUint16();
  8105. (paramCount > 0)&& (event.params=params=[]);
  8106. for (j=0;j < paramCount;j++){
  8107. var eventType=reader.getByte();
  8108. switch (eventType){
  8109. case 0:
  8110. params.push(!!reader.getByte());
  8111. break ;
  8112. case 1:
  8113. params.push(reader.getInt32());
  8114. break ;
  8115. case 2:
  8116. params.push(reader.getFloat32());
  8117. break ;
  8118. case 3:
  8119. params.push(AnimationClipParser04._strings[reader.getUint16()]);
  8120. break ;
  8121. default :
  8122. throw new Error("unknown type.");
  8123. }
  8124. }
  8125. clip.addEvent(event);
  8126. }
  8127. }
  8128. AnimationClipParser04._animationClip=null;
  8129. AnimationClipParser04._reader=null;
  8130. AnimationClipParser04._strings=[];
  8131. AnimationClipParser04._version=null;
  8132. __static(AnimationClipParser04,
  8133. ['_BLOCK',function(){return this._BLOCK={count:0};},'_DATA',function(){return this._DATA={offset:0,size:0};}
  8134. ]);
  8135. return AnimationClipParser04;
  8136. })()
  8137. /**
  8138. *@private
  8139. */
  8140. //class laya.d3.animation.AnimationClipParser03
  8141. var AnimationClipParser03=(function(){
  8142. function AnimationClipParser03(){}
  8143. __class(AnimationClipParser03,'laya.d3.animation.AnimationClipParser03');
  8144. AnimationClipParser03.READ_DATA=function(){
  8145. AnimationClipParser03._DATA.offset=AnimationClipParser03._reader.getUint32();
  8146. AnimationClipParser03._DATA.size=AnimationClipParser03._reader.getUint32();
  8147. }
  8148. AnimationClipParser03.READ_BLOCK=function(){
  8149. var count=AnimationClipParser03._BLOCK.count=AnimationClipParser03._reader.getUint16();
  8150. var blockStarts=AnimationClipParser03._BLOCK.blockStarts=[];
  8151. var blockLengths=AnimationClipParser03._BLOCK.blockLengths=[];
  8152. for (var i=0;i < count;i++){
  8153. blockStarts.push(AnimationClipParser03._reader.getUint32());
  8154. blockLengths.push(AnimationClipParser03._reader.getUint32());
  8155. }
  8156. }
  8157. AnimationClipParser03.READ_STRINGS=function(){
  8158. var offset=AnimationClipParser03._reader.getUint32();
  8159. var count=AnimationClipParser03._reader.getUint16();
  8160. var prePos=AnimationClipParser03._reader.pos;
  8161. AnimationClipParser03._reader.pos=offset+AnimationClipParser03._DATA.offset;
  8162. for (var i=0;i < count;i++)
  8163. AnimationClipParser03._strings[i]=AnimationClipParser03._reader.readUTFString();
  8164. AnimationClipParser03._reader.pos=prePos;
  8165. }
  8166. AnimationClipParser03.parse=function(clip,reader){
  8167. AnimationClipParser03._animationClip=clip;
  8168. AnimationClipParser03._reader=reader;
  8169. var arrayBuffer=reader.__getBuffer();
  8170. AnimationClipParser03.READ_DATA();
  8171. AnimationClipParser03.READ_BLOCK();
  8172. AnimationClipParser03.READ_STRINGS();
  8173. for (var i=0,n=AnimationClipParser03._BLOCK.count;i < n;i++){
  8174. var index=reader.getUint16();
  8175. var blockName=AnimationClipParser03._strings[index];
  8176. var fn=AnimationClipParser03["READ_"+blockName];
  8177. if (fn==null)
  8178. throw new Error("model file err,no this function:"+index+" "+blockName);
  8179. else
  8180. fn.call(null);
  8181. }
  8182. }
  8183. AnimationClipParser03.READ_ANIMATIONS=function(){
  8184. var i=0,j=0;
  8185. var node;
  8186. var reader=AnimationClipParser03._reader;
  8187. var buffer=reader.__getBuffer();
  8188. var startTimeTypes=[];
  8189. var startTimeTypeCount=reader.getUint16();
  8190. startTimeTypes.length=startTimeTypeCount;
  8191. for (i=0;i < startTimeTypeCount;i++)
  8192. startTimeTypes[i]=reader.getFloat32();
  8193. var clip=AnimationClipParser03._animationClip;
  8194. clip.name=AnimationClipParser03._strings[reader.getUint16()];
  8195. var clipDur=clip._duration=reader.getFloat32();
  8196. clip.islooping=!!reader.getByte();
  8197. clip._frameRate=reader.getInt16();
  8198. var nodeCount=reader.getInt16();
  8199. var nodes=clip._nodes;
  8200. nodes.count=nodeCount;
  8201. var nodesMap=clip._nodesMap={};
  8202. var nodesDic=clip._nodesDic={};
  8203. for (i=0;i < nodeCount;i++){
  8204. node=new KeyframeNode();
  8205. nodes.setNodeByIndex(i,node);
  8206. node._indexInList=i;
  8207. var type=node.type=reader.getUint8();
  8208. var pathLength=reader.getUint16();
  8209. node._setOwnerPathCount(pathLength);
  8210. for (j=0;j < pathLength;j++)
  8211. node._setOwnerPathByIndex(j,AnimationClipParser03._strings[reader.getUint16()]);
  8212. var nodePath=node._joinOwnerPath("/");
  8213. var mapArray=nodesMap[nodePath];
  8214. (mapArray)|| (nodesMap[nodePath]=mapArray=[]);
  8215. mapArray.push(node);
  8216. node.propertyOwner=AnimationClipParser03._strings[reader.getUint16()];
  8217. var propertyLength=reader.getUint16();
  8218. node._setPropertyCount(propertyLength);
  8219. for (j=0;j < propertyLength;j++)
  8220. node._setPropertyByIndex(j,AnimationClipParser03._strings[reader.getUint16()]);
  8221. var fullPath=nodePath+"."+node.propertyOwner+"."+node._joinProperty(".");
  8222. nodesDic[fullPath]=node;
  8223. node.fullPath=fullPath;
  8224. var keyframeCount=reader.getUint16();
  8225. node._setKeyframeCount(keyframeCount);
  8226. var startTime=NaN;
  8227. switch (type){
  8228. case 0:
  8229. break ;
  8230. case 1:
  8231. case 3:
  8232. case 4:
  8233. node.data=Render.supportWebGLPlusAnimation ? new ConchVector3 :new Vector3();
  8234. break ;
  8235. case 2:
  8236. node.data=Render.supportWebGLPlusAnimation ? new ConchQuaternion :new Quaternion();
  8237. break ;
  8238. default :
  8239. throw "AnimationClipParser03:unknown type.";
  8240. }
  8241. for (j=0;j < keyframeCount;j++){
  8242. switch (type){
  8243. case 0:;
  8244. var floatKeyframe=new FloatKeyframe();
  8245. node._setKeyframeByIndex(j,floatKeyframe);
  8246. startTime=floatKeyframe.time=startTimeTypes[reader.getUint16()];
  8247. floatKeyframe.inTangent=reader.getFloat32();
  8248. floatKeyframe.outTangent=reader.getFloat32();
  8249. floatKeyframe.value=reader.getFloat32();
  8250. break ;
  8251. case 1:
  8252. case 3:
  8253. case 4:;
  8254. var floatArrayKeyframe=new Vector3Keyframe();
  8255. node._setKeyframeByIndex(j,floatArrayKeyframe);
  8256. startTime=floatArrayKeyframe.time=startTimeTypes[reader.getUint16()];
  8257. if (Render.supportWebGLPlusAnimation){
  8258. var data=(floatArrayKeyframe).data=new Float32Array(3 *3);
  8259. for (var k=0;k < 3;k++)
  8260. data[k]=reader.getFloat32();
  8261. for (k=0;k < 3;k++)
  8262. data[3+k]=reader.getFloat32();
  8263. for (k=0;k < 3;k++)
  8264. data[6+k]=reader.getFloat32();
  8265. }
  8266. else {
  8267. var inTangent=floatArrayKeyframe.inTangent;
  8268. var outTangent=floatArrayKeyframe.outTangent;
  8269. var value=floatArrayKeyframe.value;
  8270. inTangent.x=reader.getFloat32();
  8271. inTangent.y=reader.getFloat32();
  8272. inTangent.z=reader.getFloat32();
  8273. outTangent.x=reader.getFloat32();
  8274. outTangent.y=reader.getFloat32();
  8275. outTangent.z=reader.getFloat32();
  8276. value.x=reader.getFloat32();
  8277. value.y=reader.getFloat32();
  8278. value.z=reader.getFloat32();
  8279. }
  8280. break ;
  8281. case 2:;
  8282. var quaArrayKeyframe=new QuaternionKeyframe();
  8283. node._setKeyframeByIndex(j,quaArrayKeyframe);
  8284. startTime=quaArrayKeyframe.time=startTimeTypes[reader.getUint16()];
  8285. if (Render.supportWebGLPlusAnimation){
  8286. data=(quaArrayKeyframe).data=new Float32Array(3 *4);
  8287. for (k=0;k < 4;k++)
  8288. data[k]=reader.getFloat32();
  8289. for (k=0;k < 4;k++)
  8290. data[4+k]=reader.getFloat32();
  8291. for (k=0;k < 4;k++)
  8292. data[8+k]=reader.getFloat32();
  8293. }
  8294. else {
  8295. var inTangentQua=quaArrayKeyframe.inTangent;
  8296. var outTangentQua=quaArrayKeyframe.outTangent;
  8297. var valueQua=quaArrayKeyframe.value;
  8298. inTangentQua.x=reader.getFloat32();
  8299. inTangentQua.y=reader.getFloat32();
  8300. inTangentQua.z=reader.getFloat32();
  8301. inTangentQua.w=reader.getFloat32();
  8302. outTangentQua.x=reader.getFloat32();
  8303. outTangentQua.y=reader.getFloat32();
  8304. outTangentQua.z=reader.getFloat32();
  8305. outTangentQua.w=reader.getFloat32();
  8306. valueQua.x=reader.getFloat32();
  8307. valueQua.y=reader.getFloat32();
  8308. valueQua.z=reader.getFloat32();
  8309. valueQua.w=reader.getFloat32();
  8310. }
  8311. break ;
  8312. default :
  8313. throw "AnimationClipParser03:unknown type.";
  8314. }
  8315. }
  8316. };
  8317. var eventCount=reader.getUint16();
  8318. for (i=0;i < eventCount;i++){
  8319. var event=new AnimationEvent();
  8320. event.time=Math.min(clipDur,reader.getFloat32());
  8321. event.eventName=AnimationClipParser03._strings[reader.getUint16()];
  8322. var params;
  8323. var paramCount=reader.getUint16();
  8324. (paramCount > 0)&& (event.params=params=[]);
  8325. for (j=0;j < paramCount;j++){
  8326. var eventType=reader.getByte();
  8327. switch (eventType){
  8328. case 0:
  8329. params.push(!!reader.getByte());
  8330. break ;
  8331. case 1:
  8332. params.push(reader.getInt32());
  8333. break ;
  8334. case 2:
  8335. params.push(reader.getFloat32());
  8336. break ;
  8337. case 3:
  8338. params.push(AnimationClipParser03._strings[reader.getUint16()]);
  8339. break ;
  8340. default :
  8341. throw new Error("unknown type.");
  8342. }
  8343. }
  8344. clip.addEvent(event);
  8345. }
  8346. }
  8347. AnimationClipParser03._animationClip=null;
  8348. AnimationClipParser03._reader=null;
  8349. AnimationClipParser03._strings=[];
  8350. __static(AnimationClipParser03,
  8351. ['_BLOCK',function(){return this._BLOCK={count:0};},'_DATA',function(){return this._DATA={offset:0,size:0};}
  8352. ]);
  8353. return AnimationClipParser03;
  8354. })()
  8355. /**
  8356. *<code>DefineDatas</code> 类用于创建宏定义数据。
  8357. */
  8358. //class laya.d3.shader.DefineDatas
  8359. var DefineDatas=(function(){
  8360. function DefineDatas(){
  8361. /**@private */
  8362. //this.value=0;
  8363. this.value=0;
  8364. }
  8365. __class(DefineDatas,'laya.d3.shader.DefineDatas');
  8366. var __proto=DefineDatas.prototype;
  8367. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  8368. /**
  8369. *增加Shader宏定义。
  8370. *@param value 宏定义。
  8371. */
  8372. __proto.add=function(define){
  8373. this.value |=define;
  8374. }
  8375. /**
  8376. *移除Shader宏定义。
  8377. *@param value 宏定义。
  8378. */
  8379. __proto.remove=function(define){
  8380. this.value &=~define;
  8381. }
  8382. /**
  8383. *是否包含Shader宏定义。
  8384. *@param value 宏定义。
  8385. */
  8386. __proto.has=function(define){
  8387. return (this.value & define)> 0;
  8388. }
  8389. /**
  8390. *克隆。
  8391. *@param destObject 克隆源。
  8392. */
  8393. __proto.cloneTo=function(destObject){
  8394. var destDefineData=destObject;
  8395. destDefineData.value=this.value;
  8396. }
  8397. /**
  8398. *克隆。
  8399. *@return 克隆副本。
  8400. */
  8401. __proto.clone=function(){
  8402. var dest=/*__JS__ */new this.constructor();
  8403. this.cloneTo(dest);
  8404. return dest;
  8405. }
  8406. return DefineDatas;
  8407. })()
  8408. /**
  8409. *<code>VertexElement</code> 类用于创建顶点结构分配。
  8410. */
  8411. //class laya.d3.graphics.VertexElement
  8412. var VertexElement=(function(){
  8413. function VertexElement(offset,elementFormat,elementUsage){
  8414. this.offset=0;
  8415. this.elementFormat=null;
  8416. this.elementUsage=0;
  8417. this.offset=offset;
  8418. this.elementFormat=elementFormat;
  8419. this.elementUsage=elementUsage;
  8420. }
  8421. __class(VertexElement,'laya.d3.graphics.VertexElement');
  8422. return VertexElement;
  8423. })()
  8424. /**
  8425. *<code>HeightMap</code> 类用于实现高度图数据。
  8426. */
  8427. //class laya.d3.core.HeightMap
  8428. var HeightMap=(function(){
  8429. function HeightMap(width,height,minHeight,maxHeight){
  8430. /**@private */
  8431. this._datas=null;
  8432. /**@private */
  8433. this._w=0;
  8434. /**@private */
  8435. this._h=0;
  8436. /**@private */
  8437. this._minHeight=NaN;
  8438. /**@private */
  8439. this._maxHeight=NaN;
  8440. this._datas=[];
  8441. this._w=width;
  8442. this._h=height;
  8443. this._minHeight=minHeight;
  8444. this._maxHeight=maxHeight;
  8445. }
  8446. __class(HeightMap,'laya.d3.core.HeightMap');
  8447. var __proto=HeightMap.prototype;
  8448. /**@private */
  8449. __proto._inBounds=function(row,col){
  8450. return row >=0 && row < this._h && col >=0 && col < this._w;
  8451. }
  8452. /**
  8453. *获取高度。
  8454. *@param row 列数。
  8455. *@param col 行数。
  8456. *@return 高度。
  8457. */
  8458. __proto.getHeight=function(row,col){
  8459. if (this._inBounds(row,col))
  8460. return this._datas[row][col];
  8461. else
  8462. return NaN;
  8463. }
  8464. /**
  8465. *获取宽度。
  8466. *@return value 宽度。
  8467. */
  8468. __getset(0,__proto,'width',function(){
  8469. return this._w;
  8470. });
  8471. /**
  8472. *获取高度。
  8473. *@return value 高度。
  8474. */
  8475. __getset(0,__proto,'height',function(){
  8476. return this._h;
  8477. });
  8478. /**
  8479. *最大高度。
  8480. *@return value 最大高度。
  8481. */
  8482. __getset(0,__proto,'maxHeight',function(){
  8483. return this._maxHeight;
  8484. });
  8485. /**
  8486. *最大高度。
  8487. *@return value 最大高度。
  8488. */
  8489. __getset(0,__proto,'minHeight',function(){
  8490. return this._minHeight;
  8491. });
  8492. HeightMap.creatFromMesh=function(mesh,width,height,outCellSize){
  8493. var vertices=[];
  8494. var indexs=[];
  8495. var submesheCount=mesh.subMeshCount;
  8496. for (var i=0;i < submesheCount;i++){
  8497. var subMesh=mesh._getSubMesh(i);
  8498. var vertexBuffer=subMesh._vertexBuffer;
  8499. var verts=vertexBuffer.getData();
  8500. var subMeshVertices=[];
  8501. for (var j=0;j < verts.length;j+=vertexBuffer.vertexDeclaration.vertexStride / 4){
  8502. var position=new Vector3(verts[j+0],verts[j+1],verts[j+2]);
  8503. subMeshVertices.push(position);
  8504. }
  8505. vertices.push(subMeshVertices);
  8506. var ib=subMesh._indexBuffer;
  8507. indexs.push(ib.getData());
  8508. };
  8509. var bounds=mesh.bounds;
  8510. var minX=bounds.getMin().x;
  8511. var minZ=bounds.getMin().z;
  8512. var maxX=bounds.getMax().x;
  8513. var maxZ=bounds.getMax().z;
  8514. var minY=bounds.getMin().y;
  8515. var maxY=bounds.getMax().y;
  8516. var widthSize=maxX-minX;
  8517. var heightSize=maxZ-minZ;
  8518. var cellWidth=outCellSize.x=widthSize / (width-1);
  8519. var cellHeight=outCellSize.y=heightSize / (height-1);
  8520. var heightMap=new HeightMap(width,height,minY,maxY);
  8521. var ray=HeightMap._tempRay;
  8522. var rayDir=ray.direction;
  8523. rayDir.x=0;
  8524. rayDir.y=-1;
  8525. rayDir.z=0;
  8526. var heightOffset=0.1;
  8527. var rayY=maxY+heightOffset;
  8528. ray.origin.y=rayY;
  8529. for (var h=0;h < height;h++){
  8530. var posZ=minZ+h *cellHeight;
  8531. heightMap._datas[h]=[];
  8532. for (var w=0;w < width;w++){
  8533. var posX=minX+w *cellWidth;
  8534. var rayOri=ray.origin;
  8535. rayOri.x=posX;
  8536. rayOri.z=posZ;
  8537. var closestIntersection=HeightMap._getPosition(ray,vertices,indexs);
  8538. heightMap._datas[h][w]=(closestIntersection===Number.MAX_VALUE)? NaN :rayY-closestIntersection;
  8539. }
  8540. }
  8541. return heightMap;
  8542. }
  8543. HeightMap.createFromImage=function(texture,minHeight,maxHeight){
  8544. var textureWidth=texture.width;
  8545. var textureHeight=texture.height;
  8546. var heightMap=new HeightMap(textureWidth,textureHeight,minHeight,maxHeight);
  8547. var compressionRatio=(maxHeight-minHeight)/ 254;
  8548. var pixelsInfo=texture.getPixels();
  8549. var index=0;
  8550. for (var h=0;h <textureHeight;h++){
  8551. var colDatas=heightMap._datas[h]=[];
  8552. for (var w=0;w < textureWidth;w++){
  8553. var r=pixelsInfo[index++];
  8554. var g=pixelsInfo[index++];
  8555. var b=pixelsInfo[index++];
  8556. var a=pixelsInfo[index++];
  8557. if (r==255 && g==255 && b==255 && a==255)
  8558. colDatas[w]=NaN;
  8559. else {
  8560. colDatas[w]=(r+g+b)/ 3 *compressionRatio+minHeight;
  8561. }
  8562. }
  8563. }
  8564. return heightMap;
  8565. }
  8566. HeightMap._getPosition=function(ray,vertices,indexs){
  8567. var closestIntersection=Number.MAX_VALUE;
  8568. for (var i=0;i < vertices.length;i++){
  8569. var subMeshVertices=vertices[i];
  8570. var subMeshIndexes=indexs[i];
  8571. for (var j=0;j < subMeshIndexes.length;j+=3){
  8572. var vertex1=subMeshVertices[subMeshIndexes[j+0]];
  8573. var vertex2=subMeshVertices[subMeshIndexes[j+1]];
  8574. var vertex3=subMeshVertices[subMeshIndexes[j+2]];
  8575. var intersection=Picker.rayIntersectsTriangle(ray,vertex1,vertex2,vertex3);
  8576. if (!isNaN(intersection)&& intersection < closestIntersection){
  8577. closestIntersection=intersection;
  8578. }
  8579. }
  8580. }
  8581. return closestIntersection;
  8582. }
  8583. __static(HeightMap,
  8584. ['_tempRay',function(){return this._tempRay=new Ray(new Vector3(),new Vector3());}
  8585. ]);
  8586. return HeightMap;
  8587. })()
  8588. /**
  8589. *@private
  8590. *<code>ShaderInit</code> 类用于初始化内置Shader。
  8591. */
  8592. //class laya.d3.shader.ShaderInit3D
  8593. var ShaderInit3D=(function(){
  8594. /**
  8595. *创建一个 <code>ShaderInit</code> 实例。
  8596. */
  8597. function ShaderInit3D(){}
  8598. __class(ShaderInit3D,'laya.d3.shader.ShaderInit3D');
  8599. ShaderInit3D.__init__=function(){
  8600. ShaderInit3D._rangeAttenTex=Utils3D._buildTexture2D(1024,1,/*laya.resource.BaseTexture.FORMAT_ALPHA8*/2,TextureGenerator.lightAttenTexture);
  8601. ShaderInit3D._rangeAttenTex.wrapModeU=/*laya.resource.BaseTexture.WARPMODE_CLAMP*/1;
  8602. ShaderInit3D._rangeAttenTex.wrapModeV=/*laya.resource.BaseTexture.WARPMODE_CLAMP*/1;
  8603. ShaderInit3D._rangeAttenTex.lock=true;
  8604. Shader3D.SHADERDEFINE_HIGHPRECISION=Shader3D.registerPublicDefine("HIGHPRECISION");
  8605. Scene3D.SHADERDEFINE_FOG=Shader3D.registerPublicDefine("FOG");
  8606. Scene3D.SHADERDEFINE_DIRECTIONLIGHT=Shader3D.registerPublicDefine("DIRECTIONLIGHT");
  8607. Scene3D.SHADERDEFINE_POINTLIGHT=Shader3D.registerPublicDefine("POINTLIGHT");
  8608. Scene3D.SHADERDEFINE_SPOTLIGHT=Shader3D.registerPublicDefine("SPOTLIGHT");
  8609. Scene3D.SHADERDEFINE_CAST_SHADOW=Shader3D.registerPublicDefine("CASTSHADOW");
  8610. Scene3D.SHADERDEFINE_SHADOW_PSSM1=Shader3D.registerPublicDefine("SHADOWMAP_PSSM1");
  8611. Scene3D.SHADERDEFINE_SHADOW_PSSM2=Shader3D.registerPublicDefine("SHADOWMAP_PSSM2");
  8612. Scene3D.SHADERDEFINE_SHADOW_PSSM3=Shader3D.registerPublicDefine("SHADOWMAP_PSSM3");
  8613. Scene3D.SHADERDEFINE_SHADOW_PCF_NO=Shader3D.registerPublicDefine("SHADOWMAP_PCF_NO");
  8614. Scene3D.SHADERDEFINE_SHADOW_PCF1=Shader3D.registerPublicDefine("SHADOWMAP_PCF1");
  8615. Scene3D.SHADERDEFINE_SHADOW_PCF2=Shader3D.registerPublicDefine("SHADOWMAP_PCF2");
  8616. Scene3D.SHADERDEFINE_SHADOW_PCF3=Shader3D.registerPublicDefine("SHADOWMAP_PCF3");
  8617. Scene3D.SHADERDEFINE_REFLECTMAP=Shader3D.registerPublicDefine("REFLECTMAP");
  8618. Shader3D.addInclude("Lighting.glsl","\nstruct DirectionLight {\n vec3 Color;\n vec3 Direction;\n};\n\nstruct PointLight {\n vec3 Color;\n vec3 Position;\n float Range;\n};\n\nstruct SpotLight {\n vec3 Color;\n vec3 Position;\n vec3 Direction;\n float Spot;\n float Range;\n};\n\n// Laya中使用衰减纹理\nfloat LayaAttenuation(in vec3 L,in float invLightRadius) {\n float fRatio = clamp(length(L) * invLightRadius,0.0,1.0);\n fRatio *= fRatio;\n return 1.0 / (1.0 + 25.0 * fRatio)* clamp(4.0*(1.0 - fRatio),0.0,1.0); //fade to black as if 4 pixel texture\n}\n\n// Same as Just Cause 2 and Crysis 2 (you can read GPU Pro 1 book for more information)\nfloat BasicAttenuation(in vec3 L,in float invLightRadius) {\n vec3 distance = L * invLightRadius;\n float attenuation = clamp(1.0 - dot(distance, distance),0.0,1.0); // Equals float attenuation = saturate(1.0f - dot(L, L) / (lightRadius * lightRadius));\n return attenuation * attenuation;\n}\n\n// Inspired on http://fools.slindev.com/viewtopic.php?f=11&t=21&view=unread#unread\nfloat NaturalAttenuation(in vec3 L,in float invLightRadius) {\n float attenuationFactor = 30.0;\n vec3 distance = L * invLightRadius;\n float attenuation = dot(distance, distance); // Equals float attenuation = dot(L, L) / (lightRadius * lightRadius);\n attenuation = 1.0 / (attenuation * attenuationFactor + 1.0);\n // Second we move down the function therewith it reaches zero at abscissa 1:\n attenuationFactor = 1.0 / (attenuationFactor + 1.0); //attenuationFactor contains now the value we have to subtract\n attenuation = max(attenuation - attenuationFactor, 0.0); // The max fixes a bug.\n // Finally we expand the equation along the y-axis so that it starts with a function value of 1 again.\n attenuation /= 1.0 - attenuationFactor;\n return attenuation;\n}\n\nvoid LayaAirBlinnPhongLight (in vec3 specColor,in float specColorIntensity,in vec3 normal,in vec3 gloss, in vec3 viewDir,in vec3 lightColor, in vec3 lightVec,out vec3 diffuseColor,out vec3 specularColor) {\n mediump vec3 h = normalize(viewDir-lightVec);\n lowp float ln = max (0.0, dot (-lightVec,normal));\n float nh = max (0.0, dot (h,normal));\n diffuseColor=lightColor * ln;\n specularColor=lightColor *specColor*pow (nh, specColorIntensity*128.0) * gloss;\n}\n\nvoid LayaAirBlinnPhongDiectionLight (in vec3 specColor,in float specColorIntensity,in vec3 normal,in vec3 gloss, in vec3 viewDir, in DirectionLight light,out vec3 diffuseColor,out vec3 specularColor) {\n vec3 lightVec=normalize(light.Direction);\n LayaAirBlinnPhongLight(specColor,specColorIntensity,normal,gloss,viewDir,light.Color,lightVec,diffuseColor,specularColor);\n}\n\nvoid LayaAirBlinnPhongPointLight (in vec3 pos,in vec3 specColor,in float specColorIntensity,in vec3 normal,in vec3 gloss, in vec3 viewDir, in PointLight light,out vec3 diffuseColor,out vec3 specularColor) {\n vec3 lightVec = pos-light.Position;\n //if( length(lightVec) > light.Range )\n // return;\n LayaAirBlinnPhongLight(specColor,specColorIntensity,normal,gloss,viewDir,light.Color,lightVec/length(lightVec),diffuseColor,specularColor);\n float attenuate = LayaAttenuation(lightVec, 1.0/light.Range);\n diffuseColor *= attenuate;\n specularColor*= attenuate;\n}\n\nvoid LayaAirBlinnPhongSpotLight (in vec3 pos,in vec3 specColor,in float specColorIntensity,in vec3 normal,in vec3 gloss, in vec3 viewDir, in SpotLight light,out vec3 diffuseColor,out vec3 specularColor) {\n vec3 lightVec = pos-light.Position;\n //if( length(lightVec) > light.Range)\n // return;\n\n vec3 normalLightVec=lightVec/length(lightVec);\n LayaAirBlinnPhongLight(specColor,specColorIntensity,normal,gloss,viewDir,light.Color,normalLightVec,diffuseColor,specularColor);\n vec2 cosAngles=cos(vec2(light.Spot,light.Spot*0.5)*0.5);//ConeAttenuation\n float dl=dot(normalize(light.Direction),normalLightVec);\n dl*=smoothstep(cosAngles[0],cosAngles[1],dl);\n float attenuate = LayaAttenuation(lightVec, 1.0/light.Range)*dl;\n diffuseColor *=attenuate;\n specularColor *=attenuate;\n}\n\nvec3 NormalSampleToWorldSpace(vec3 normalMapSample, vec3 unitNormal, vec3 tangent,vec3 binormal) {\n vec3 normalT =vec3(2.0*normalMapSample.x - 1.0,1.0-2.0*normalMapSample.y,2.0*normalMapSample.z - 1.0);\n\n // Build orthonormal basis.\n vec3 N = normalize(unitNormal);\n vec3 T = normalize(tangent);\n vec3 B = normalize(binormal);\n mat3 TBN = mat3(T, B, N);\n\n // Transform from tangent space to world space.\n vec3 bumpedNormal = TBN*normalT;\n\n return bumpedNormal;\n}\n\nvec3 NormalSampleToWorldSpace1(vec4 normalMapSample, vec3 tangent, vec3 binormal, vec3 unitNormal) {\n vec3 normalT;\n normalT.x = 2.0 * normalMapSample.x - 1.0;\n normalT.y = 1.0 - 2.0 * normalMapSample.y;\n normalT.z = sqrt(1.0 - clamp(dot(normalT.xy, normalT.xy), 0.0, 1.0));\n\n vec3 T = normalize(tangent);\n vec3 B = normalize(binormal);\n vec3 N = normalize(unitNormal);\n mat3 TBN = mat3(T, B, N);\n\n // Transform from tangent space to world space.\n vec3 bumpedNormal = TBN * normalize(normalT);\n\n return bumpedNormal;\n}\n\nvec3 DecodeLightmap(vec4 color) {\n return color.rgb*color.a*5.0;\n}\n\nvec2 TransformUV(vec2 texcoord,vec4 tilingOffset) {\n vec2 transTexcoord=vec2(texcoord.x,texcoord.y-1.0)*tilingOffset.xy+vec2(tilingOffset.z,-tilingOffset.w);\n transTexcoord.y+=1.0;\n return transTexcoord;\n}\n\nvec4 remapGLPositionZ(vec4 position) {\n position.z=position.z * 2.0 - position.w;\n return position;\n}\n\nmat3 inverse(mat3 m) {\n float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];\n float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];\n float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];\n\n float b01 = a22 * a11 - a12 * a21;\n float b11 = -a22 * a10 + a12 * a20;\n float b21 = a21 * a10 - a11 * a20;\n\n float det = a00 * b01 + a01 * b11 + a02 * b21;\n\n return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),\n b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),\n b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;\n}\n\n");
  8619. Shader3D.addInclude("ShadowHelper.glsl","uniform sampler2D u_shadowMap1;\nuniform sampler2D u_shadowMap2;\nuniform sampler2D u_shadowMap3;\nuniform vec2 u_shadowPCFoffset;\nuniform vec4 u_shadowPSSMDistance;\nvec4 packDepth(const in float depth)\n{\n const vec4 bitShift = vec4(256.0*256.0*256.0, 256.0*256.0, 256.0, 1.0);\n const vec4 bitMask = vec4(0.0, 1.0/256.0, 1.0/256.0, 1.0/256.0);\n vec4 res = mod(depth*bitShift*vec4(255), vec4(256))/vec4(255);\n res -= res.xxyz * bitMask;\n return res;\n}\nfloat unpackDepth(const in vec4 rgbaDepth)\n{\n const vec4 bitShift = vec4(1.0/(256.0*256.0*256.0), 1.0/(256.0*256.0), 1.0/256.0, 1.0);\n float depth = dot(rgbaDepth, bitShift);\n return depth;\n}\nfloat tex2DPCF( sampler2D shadowMap,vec2 texcoord,vec2 invsize,float zRef )\n{\n vec2 texelpos =texcoord / invsize;\n vec2 lerps = fract( texelpos );\n float sourcevals[4];\n sourcevals[0] = float( unpackDepth(texture2D(shadowMap,texcoord)) > zRef );\n sourcevals[1] = float( unpackDepth(texture2D(shadowMap,texcoord + vec2(invsize.x,0))) > zRef );\n sourcevals[2] = float( unpackDepth(texture2D(shadowMap,texcoord + vec2(0,invsize.y))) > zRef );\n sourcevals[3] = float( unpackDepth(texture2D(shadowMap,texcoord + vec2(invsize.x, invsize.y) )) > zRef );\n return mix( mix(sourcevals[0],sourcevals[2],lerps.y),mix(sourcevals[1],sourcevals[3],lerps.y),lerps.x );\n}\nfloat getShadowPSSM3( sampler2D shadowMap1,sampler2D shadowMap2,sampler2D shadowMap3,mat4 lightShadowVP[4],vec4 pssmDistance,vec2 shadowPCFOffset,vec3 worldPos,float posViewZ,float zBias )\n{\n float value = 1.0;\n int nPSNum = int(posViewZ>pssmDistance.x);\n nPSNum += int(posViewZ>pssmDistance.y);\n nPSNum += int(posViewZ>pssmDistance.z);\n //真SB,webgl不支持在PS中直接访问数组\n mat4 lightVP;\n if( nPSNum == 0 )\n {\n lightVP = lightShadowVP[1];\n }\n else if( nPSNum == 1 )\n {\n lightVP = lightShadowVP[2];\n }\n else if( nPSNum == 2 )\n {\n lightVP = lightShadowVP[3];\n }\n vec4 vLightMVPPos = lightVP * vec4(worldPos,1.0);\n //为了效率,在CPU计算/2.0 + 0.5\n //vec3 vText = (vLightMVPPos.xyz / vLightMVPPos.w)/2.0 + 0.5;\n vec3 vText = vLightMVPPos.xyz / vLightMVPPos.w;\n float fMyZ = vText.z - zBias;\n /*\n bvec4 bInFrustumVec = bvec4 ( vText.x >= 0.0, vText.x <= 1.0, vText.y >= 0.0, vText.y <= 1.0 );\n bool bInFrustum = all( bInFrustumVec );\n bvec2 bFrustumTestVec = bvec2( bInFrustum, fMyZ <= 1.0 );\n bool bFrustumTest = all( bFrustumTestVec );\n if ( bFrustumTest ) \n */\n if( fMyZ <= 1.0 )\n {\n float zdepth=0.0;\n#ifdef SHADOWMAP_PCF3\n if ( nPSNum == 0 )\n {\n value = tex2DPCF( shadowMap1, vText.xy,shadowPCFOffset,fMyZ );\n value += tex2DPCF( shadowMap1, vText.xy+vec2(shadowPCFOffset.xy),shadowPCFOffset, fMyZ );\n value += tex2DPCF( shadowMap1, vText.xy+vec2(shadowPCFOffset.x,0),shadowPCFOffset, fMyZ );\n value += tex2DPCF( shadowMap1, vText.xy+vec2(0,shadowPCFOffset.y),shadowPCFOffset, fMyZ );\n value = value/4.0;\n } \n else if( nPSNum == 1 )\n {\n value = tex2DPCF( shadowMap2,vText.xy,shadowPCFOffset,fMyZ);\n }\n else if( nPSNum == 2 )\n {\n vec4 color = texture2D( shadowMap3,vText.xy );\n zdepth = unpackDepth(color);\n value = float(fMyZ < zdepth);\n }\n#endif\n#ifdef SHADOWMAP_PCF2\n if ( nPSNum == 0 )\n {\n value = tex2DPCF( shadowMap1,vText.xy,shadowPCFOffset,fMyZ);\n }\n else if( nPSNum == 1 )\n {\n value = tex2DPCF( shadowMap2,vText.xy,shadowPCFOffset,fMyZ);\n }\n else if( nPSNum == 2 )\n {\n vec4 color = texture2D( shadowMap3,vText.xy );\n zdepth = unpackDepth(color);\n value = float(fMyZ < zdepth);\n }\n\n#endif\n#ifdef SHADOWMAP_PCF1\n if ( nPSNum == 0 )\n {\n value = tex2DPCF( shadowMap1,vText.xy,shadowPCFOffset,fMyZ);\n }\n else if( nPSNum == 1 )\n {\n vec4 color = texture2D( shadowMap2,vText.xy );\n zdepth = unpackDepth(color);\n value = float(fMyZ < zdepth);\n }\n else if( nPSNum == 2 )\n {\n vec4 color = texture2D( shadowMap3,vText.xy );\n zdepth = unpackDepth(color);\n value = float(fMyZ < zdepth);\n }\n#endif\n#ifdef SHADOWMAP_PCF_NO\n vec4 color;\n if ( nPSNum == 0 )\n {\n color = texture2D( shadowMap1,vText.xy );\n }\n else if( nPSNum == 1 )\n {\n color = texture2D( shadowMap2,vText.xy );\n }\n else if( nPSNum == 2 )\n {\n color = texture2D( shadowMap3,vText.xy );\n }\n zdepth = unpackDepth(color);\n value = float(fMyZ < zdepth);\n#endif\n }\n return value;\n}\nfloat getShadowPSSM2( sampler2D shadowMap1,sampler2D shadowMap2,mat4 lightShadowVP[4],vec4 pssmDistance,vec2 shadowPCFOffset,vec3 worldPos,float posViewZ,float zBias )\n{\n float value = 1.0;\n int nPSNum = int(posViewZ>pssmDistance.x);\n nPSNum += int(posViewZ>pssmDistance.y);\n //真SB,webgl不支持在PS中直接访问数组\n mat4 lightVP;\n if( nPSNum == 0 )\n {\n lightVP = lightShadowVP[1];\n }\n else if( nPSNum == 1 )\n {\n lightVP = lightShadowVP[2];\n }\n vec4 vLightMVPPos = lightVP * vec4(worldPos,1.0);\n //为了效率,在CPU计算/2.0 + 0.5\n //vec3 vText = (vLightMVPPos.xyz / vLightMVPPos.w)/2.0 + 0.5;\n vec3 vText = vLightMVPPos.xyz / vLightMVPPos.w;\n float fMyZ = vText.z - zBias;\n /*\n bvec4 bInFrustumVec = bvec4 ( vText.x >= 0.0, vText.x <= 1.0, vText.y >= 0.0, vText.y <= 1.0 );\n bool bInFrustum = all( bInFrustumVec );\n bvec2 bFrustumTestVec = bvec2( bInFrustum, fMyZ <= 1.0 );\n bool bFrustumTest = all( bFrustumTestVec );\n if ( bFrustumTest ) \n */\n if( fMyZ <= 1.0 )\n {\n float zdepth=0.0;\n#ifdef SHADOWMAP_PCF3\n if ( nPSNum == 0 )\n {\n value = tex2DPCF( shadowMap1, vText.xy,shadowPCFOffset,fMyZ );\n value += tex2DPCF( shadowMap1, vText.xy+vec2(shadowPCFOffset.xy),shadowPCFOffset, fMyZ );\n value += tex2DPCF( shadowMap1, vText.xy+vec2(shadowPCFOffset.x,0),shadowPCFOffset, fMyZ );\n value += tex2DPCF( shadowMap1, vText.xy+vec2(0,shadowPCFOffset.y),shadowPCFOffset, fMyZ );\n value = value/4.0;\n }\n else if( nPSNum == 1 )\n {\n value = tex2DPCF( shadowMap2,vText.xy,shadowPCFOffset,fMyZ);\n }\n#endif\n#ifdef SHADOWMAP_PCF2\n if ( nPSNum == 0 )\n {\n value = tex2DPCF( shadowMap1,vText.xy,shadowPCFOffset,fMyZ);\n }\n else if( nPSNum == 1 )\n {\n value = tex2DPCF( shadowMap2,vText.xy,shadowPCFOffset,fMyZ);\n }\n#endif\n#ifdef SHADOWMAP_PCF1\n if ( nPSNum == 0 )\n {\n value = tex2DPCF( shadowMap1,vText.xy,shadowPCFOffset,fMyZ);\n }\n else if( nPSNum == 1 )\n {\n vec4 color = texture2D( shadowMap2,vText.xy );\n zdepth = unpackDepth(color);\n value = float(fMyZ < zdepth);\n }\n#endif\n#ifdef SHADOWMAP_PCF_NO\n vec4 color;\n if ( nPSNum == 0 )\n {\n color = texture2D( shadowMap1,vText.xy );\n }\n else if( nPSNum == 1 )\n {\n color = texture2D( shadowMap2,vText.xy );\n }\n zdepth = unpackDepth(color);\n value = float(fMyZ < zdepth);\n#endif\n }\n return value;\n}\nfloat getShadowPSSM1( sampler2D shadowMap1,vec4 lightMVPPos,vec4 pssmDistance,vec2 shadowPCFOffset,float posViewZ,float zBias )\n{\n float value = 1.0;\n if( posViewZ < pssmDistance.x )\n {\n vec3 vText = lightMVPPos.xyz / lightMVPPos.w;\n float fMyZ = vText.z - zBias;\n /*\n bvec4 bInFrustumVec = bvec4 ( vText.x >= 0.0, vText.x <= 1.0, vText.y >= 0.0, vText.y <= 1.0 );\n bool bInFrustum = all( bInFrustumVec );\n bvec2 bFrustumTestVec = bvec2( bInFrustum, fMyZ <= 1.0 );\n bool bFrustumTest = all( bFrustumTestVec );\n */\n if ( fMyZ <= 1.0 ) \n {\n float zdepth=0.0;\n#ifdef SHADOWMAP_PCF3\n value = tex2DPCF( shadowMap1, vText.xy,shadowPCFOffset,fMyZ );\n value += tex2DPCF( shadowMap1, vText.xy+vec2(shadowPCFOffset.xy),shadowPCFOffset,fMyZ );\n value += tex2DPCF( shadowMap1, vText.xy+vec2(shadowPCFOffset.x,0),shadowPCFOffset,fMyZ );\n value += tex2DPCF( shadowMap1, vText.xy+vec2(0,shadowPCFOffset.y),shadowPCFOffset,fMyZ );\n value = value/4.0;\n#endif\n#ifdef SHADOWMAP_PCF2 \n value = tex2DPCF( shadowMap1,vText.xy,shadowPCFOffset,fMyZ);\n#endif\n#ifdef SHADOWMAP_PCF1\n value = tex2DPCF( shadowMap1,vText.xy,shadowPCFOffset,fMyZ);\n#endif\n#ifdef SHADOWMAP_PCF_NO \n vec4 color = texture2D( shadowMap1,vText.xy );\n zdepth = unpackDepth(color);\n value = float(fMyZ < zdepth);\n#endif\n }\n }\n return value;\n}");
  8620. Shader3D.addInclude("BRDF.glsl","struct LayaGI\n{\n vec3 diffuse;\n vec3 specular;\n};\n\nvec4 LayaAirBRDF(in vec3 diffuseColor, in vec3 specularColor, in float oneMinusReflectivity, in float smoothness, in vec3 normal, in vec3 viewDir, in vec3 lightDir, in vec3 lightColor, in LayaGI gi)\n{\n float perceptualRoughness = SmoothnessToPerceptualRoughness(smoothness);\n vec3 halfDir = SafeNormalize(viewDir - lightDir);\n \n float nv = abs(dot(normal, viewDir));\n \n float nl = clamp(dot(normal, -lightDir), 0.0, 1.0);\n float nh = clamp(dot(normal, halfDir), 0.0, 1.0);\n float lv = clamp(dot(lightDir, viewDir), 0.0, 1.0);\n float lh = clamp(dot(lightDir, -halfDir), 0.0, 1.0);\n \n float diffuseTerm = DisneyDiffuse(nv, nl, lh, perceptualRoughness) * nl;\n \n float roughness = PerceptualRoughnessToRoughness(perceptualRoughness);\n \n //#if UNITY_BRDF_GGX\n float V = SmithJointGGXVisibilityTerm(nl, nv, roughness);\n float D = GGXTerm(nh, roughness);\n \n float specularTerm = V * D * PI;\n \n specularTerm = sqrt(max(0.0001, specularTerm));\n specularTerm = max(0.0, specularTerm * nl);\n \n float surfaceReduction = 1.0 - 0.28 * roughness * perceptualRoughness;\n float grazingTerm = clamp(smoothness + (1.0 - oneMinusReflectivity), 0.0, 1.0);\n \n vec4 color;\n color.rgb = diffuseColor * (gi.diffuse + lightColor * diffuseTerm) \n + specularTerm * lightColor * FresnelTerm (specularColor, lh)\n + surfaceReduction * gi.specular * FresnelLerp(specularColor, vec3(grazingTerm), nv);\n \n return color;\n}");
  8621. Shader3D.addInclude("PBRUtils.glsl","struct DirectionLight\n{\n vec3 Color;\n vec3 Direction;\n};\n\nstruct PointLight\n{\n vec3 Color;\n vec3 Position;\n float Range;\n};\n\nstruct SpotLight\n{\n vec3 Color;\n vec3 Position;\n vec3 Direction;\n float SpotAngle;\n float Range;\n};\n\nvec3 UnpackScaleNormal(in vec2 uv0)\n{\n #ifdef NORMALTEXTURE\n vec3 normalT;\n vec4 normalMapSample = texture2D(u_NormalTexture, uv0);\n normalT.x = 2.0 * normalMapSample.x - 1.0;\n normalT.y = 1.0 - 2.0 * normalMapSample.y;\n normalT.xy *= u_normalScale;\n normalT.z = sqrt(1.0 - clamp(dot(normalT.xy, normalT.xy), 0.0, 1.0));\n \n vec3 T = normalize(v_Tangent);\n vec3 B = normalize(v_Binormal);\n vec3 N = normalize(v_Normal);\n mat3 TBN = mat3(T, B, N);\n \n vec3 bumpedNormal = TBN * normalize(normalT);\n return bumpedNormal;\n #else\n return normalize(v_Normal);\n #endif\n}\n\nvec4 DielectricSpecularColor = vec4(0.220916301, 0.220916301, 0.220916301, 1.0 - 0.220916301);\n\nfloat PI = 3.14159265359;\n\nvec3 FresnelTerm (in vec3 F0, in float cosA)\n{\n return F0 + (vec3(1.0) - F0) * pow(1.0 - cosA, 5.0);\n}\n\nvec3 FresnelLerp (in vec3 F0, in vec3 F90, float cosA)\n{\n float t = pow(1.0 - cosA, 5.0);\n return mix(F0, F90, t);\n}\n\nfloat PerceptualRoughnessToRoughness(in float perceptualRoughness)\n{\n return perceptualRoughness * perceptualRoughness;\n}\n\nfloat PerceptualRoughnessToSpecularPower(in float perceptualRoughness)\n{\n float m = PerceptualRoughnessToRoughness(perceptualRoughness);\n float sq = max(0.0001, m * m);\n float n = (2.0 / sq) - 2.0;\n n = max(n, 0.0001);\n return n;\n}\n\nfloat RoughnessToPerceptualRoughness(in float roughness)\n{\n return sqrt(roughness);\n}\n\nfloat SmoothnessToRoughness(in float smoothness)\n{\n return (1.0 - smoothness) * (1.0 - smoothness);\n}\n\nfloat SmoothnessToPerceptualRoughness(in float smoothness)\n{\n return (1.0 - smoothness);\n}\n\nvec3 SafeNormalize(in vec3 inVec)\n{\n float dp3 = max(0.001,dot(inVec,inVec));\n return inVec * (1.0 / sqrt(dp3));\n}\n\nfloat DisneyDiffuse(in float NdotV, in float NdotL, in float LdotH, in float perceptualRoughness)\n{\n float fd90 = 0.5 + 2.0 * LdotH * LdotH * perceptualRoughness;\n float lightScatter = (1.0 + (fd90 - 1.0) * pow(1.0 - NdotL,5.0));\n float viewScatter = (1.0 + (fd90 - 1.0) * pow(1.0 - NdotV,5.0));\n\n return lightScatter * viewScatter;\n}\n\nfloat SmithJointGGXVisibilityTerm (float NdotL, float NdotV, float roughness)\n{\n float a = roughness;\n float lambdaV = NdotL * (NdotV * (1.0 - a) + a);\n float lambdaL = NdotV * (NdotL * (1.0 - a) + a);\n\n return 0.5 / (lambdaV + lambdaL + 0.00001);\n}\n\nfloat GGXTerm (float NdotH, float roughness)\n{\n float a2 = roughness * roughness;\n float d = (NdotH * a2 - NdotH) * NdotH + 1.0;\n return 0.31830988618 * a2 / (d * d + 0.0000001);\n}\n\nfloat OneMinusReflectivityFromMetallic(in float metallic)\n{\n float oneMinusDielectricSpec = DielectricSpecularColor.a;\n return oneMinusDielectricSpec - metallic * oneMinusDielectricSpec;\n}\n\nfloat SpecularStrength(vec3 specular)\n{\n //(SHADER_TARGET < 30)return specular.r; \n return max (max (specular.r, specular.g), specular.b);\n}\n\nvec3 DiffuseAndSpecularFromMetallic(in vec3 diffuseColor, in float metallic, out vec3 specularColor, out float oneMinusReflectivity)\n{\n specularColor = mix(DielectricSpecularColor.rgb, diffuseColor, metallic);\n oneMinusReflectivity = OneMinusReflectivityFromMetallic(metallic);\n return diffuseColor * oneMinusReflectivity;\n}\n\nvec3 EnergyConservationBetweenDiffuseAndSpecular(in vec3 diffuseColor, in vec3 specularColor, out float oneMinusReflectivity)\n{\n oneMinusReflectivity = 1.0 - SpecularStrength(specularColor);\n return diffuseColor * oneMinusReflectivity;\n}\n\nvec4 Occlusion(in vec2 uv0){\n #ifdef OCCLUSIONTEXTURE\n vec4 occlusionTextureColor = texture2D(u_OcclusionTexture, uv0);\n float occ = occlusionTextureColor.g;\n float oneMinusT = 1.0 - u_occlusionStrength;\n float lerpOneTo = oneMinusT + occ * u_occlusionStrength;\n return occlusionTextureColor * lerpOneTo;\n #else\n return vec4(1.0);\n #endif\n}\n\nvec2 ParallaxOffset(in vec3 viewDir){\n #ifdef PARALLAXTEXTURE\n float h = texture2D(u_ParallaxTexture, v_Texcoord0).g;\n h = h * u_parallaxScale - u_parallaxScale / 2.0;\n vec3 v = viewDir;\n v.z += 0.42;\n vec2 offset = h * (v.xy / v.z);\n return v_Texcoord0 + offset;\n #else\n return v_Texcoord0;\n #endif\n}\n\nvec3 ReflectCubeMap(in vec3 viewDir, in vec3 normal){\n #ifdef REFLECTMAP\n vec3 incident = -viewDir;\n vec3 reflectionVector = reflect(incident, normal);\n vec3 reflectionColor = textureCube(u_ReflectTexture, vec3(-reflectionVector.x, reflectionVector.yz)).rgb;\n return reflectionColor * u_ReflectIntensity;\n #else\n return vec3(0.0);\n #endif\n}\n\nfloat LayaAttenuation(in vec3 L, in float invLightRadius)\n{\n float fRatio = clamp(length(L) * invLightRadius, 0.0, 1.0);\n fRatio *= fRatio;\n return 1.0 / (1.0 + 25.0 * fRatio) * clamp(4.0*(1.0 - fRatio), 0.0, 1.0); //fade to black as if 4 pixel texture\n}\n\nvec3 LayaPreMultiplyAlpha(vec3 diffColor, float alpha, float oneMinusReflectivity, out float outModifiedAlpha)\n{\n #ifdef ALPHAPREMULTIPLY\n diffColor *= alpha;\n outModifiedAlpha = 1.0 - oneMinusReflectivity + alpha * oneMinusReflectivity;\n #else\n outModifiedAlpha = alpha;\n #endif\n return diffColor;\n}\n\n");
  8622. Shader3D.addInclude("PBRStandardLighting.glsl","#include \"PBRUtils.glsl\"\n#include \"BRDF.glsl\"\n\nvec4 PBRStandardLight(in vec4 albedoColor, in float metallic, in float smoothness, in vec3 normal, in vec3 viewDir, in vec3 lightDir, in vec3 lightColor, in LayaGI gi)\n{\n float oneMinusReflectivity;\n vec3 diffuseColor;\n vec3 specularColor;\n float alpha;\n \n diffuseColor = DiffuseAndSpecularFromMetallic (albedoColor.rgb, metallic, specularColor, oneMinusReflectivity);\n \n diffuseColor = LayaPreMultiplyAlpha(diffuseColor, albedoColor.a, oneMinusReflectivity, alpha);\n \n vec4 color = LayaAirBRDF(diffuseColor, specularColor, oneMinusReflectivity, smoothness, normal, viewDir, lightDir, lightColor, gi);\n color.a = alpha;\n return color;\n}\n\nvec4 PBRStandardDiectionLight (in vec4 albedoColor, in float metallic, in float smoothness, in vec3 normal, in vec3 viewDir, in DirectionLight light, in LayaGI gi)\n{\n vec3 lightVec = normalize(light.Direction);\n return PBRStandardLight(albedoColor, metallic, smoothness, normal, viewDir, lightVec, light.Color, gi);\n}\n\nvec4 PBRStandardPointLight (in vec4 albedoColor, in float metallic, in float smoothness, in vec3 normal, in vec3 viewDir, in PointLight light, in vec3 pos, in LayaGI gi)\n{\n vec3 lightCoord = (u_PointLightMatrix * vec4(pos, 1.0)).xyz;\n float distance = dot(lightCoord, lightCoord);\n float attenuate = texture2D(u_RangeTexture, vec2(distance)).w;\n vec3 lightVec = normalize(pos - light.Position);\n return PBRStandardLight(albedoColor, metallic, smoothness, normal, viewDir, lightVec, light.Color, gi) * attenuate;\n}\n\nvec4 PBRStandardSpotLight (in vec4 albedoColor, in float metallic, in float smoothness, in vec3 normal, in vec3 viewDir, in SpotLight light, in vec3 pos, in LayaGI gi)\n{\n vec3 lightVec = pos - light.Position;\n vec3 normalLightVec = normalize(lightVec);\n vec2 cosAngles = cos(vec2(light.SpotAngle, light.SpotAngle*0.5) * 0.5);//ConeAttenuation\n float dl = dot(normalize(light.Direction), normalLightVec);\n dl *= smoothstep(cosAngles[0], cosAngles[1], dl);\n float attenuate = LayaAttenuation(lightVec, 1.0/light.Range) * dl;\n return PBRStandardLight(albedoColor, metallic, smoothness, normal, viewDir, lightVec, light.Color, gi) * attenuate;\n}\n\n//vec4 PBRStandardSpotLight1 (in vec4 albedoColor, in float metallic, in float smoothness, in vec3 normal, in vec3 viewDir, in SpotLight light, in vec3 pos, in LayaGI gi)\n//{\n// vec4 lightCoord = u_SpotLightMatrix * vec4(pos, 1.0);\n// \n// float distance = dot(lightCoord, lightCoord);\n// float attenuate = (lightCoord.z < 0.0) ? texture2D(u_RangeTexture, vec2(distance)).w : 0.0;\n// //float attenuate = (lightCoord.z < 0.0) ? texture2D(u_AngleTexture, vec2(lightCoord.x / lightCoord.w + 0.5, lightCoord.y / lightCoord.w + 0.5)).r * texture2D(u_RangeTexture, vec2(distance)).w : 0.0;\n// //vec2 _uv = vec2(pos.x * 180.0/(2.0 * pos.z) + 0.5, pos.y * 180.0/(2.0 * pos.z) + 0.5);\n// vec3 lightVec = normalize(pos - light.Position);\n// return PBRStandardLight(albedoColor, metallic, smoothness, normal, viewDir, lightVec, light.Color, gi) * attenuate;\n//}\n\nvec2 MetallicGloss(in float albedoTextureAlpha, in vec2 uv0)\n{\n vec2 mg;\n \n #ifdef METALLICGLOSSTEXTURE\n vec4 metallicGlossTextureColor = texture2D(u_MetallicGlossTexture, uv0);\n #ifdef SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA\n mg.r = metallicGlossTextureColor.r;\n mg.g = albedoTextureAlpha;\n #else\n mg = metallicGlossTextureColor.ra;\n #endif\n mg.g *= u_smoothnessScale;\n #else\n mg.r = u_metallic;\n #ifdef SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA\n mg.g = albedoTextureAlpha * u_smoothnessScale;\n #else\n mg.g = u_smoothness;\n #endif\n #endif\n \n return mg;\n}\n\n");
  8623. Shader3D.addInclude("PBRSpecularLighting.glsl","#include \"PBRUtils.glsl\"\n#include \"BRDF.glsl\"\n\nvec4 PBRSpecularLight(in vec4 albedoColor, in vec3 specularColor, in float smoothness, in vec3 normal, in vec3 viewDir, in vec3 lightDir, in vec3 lightColor, in LayaGI gi)\n{\n float oneMinusReflectivity;\n vec3 diffuseColor;\n float alpha;\n \n diffuseColor = EnergyConservationBetweenDiffuseAndSpecular (albedoColor.rgb, specularColor, oneMinusReflectivity);\n \n diffuseColor = LayaPreMultiplyAlpha(diffuseColor, albedoColor.a, oneMinusReflectivity, alpha);\n \n vec4 color = LayaAirBRDF(diffuseColor, specularColor, oneMinusReflectivity, smoothness, normal, viewDir, lightDir, lightColor, gi);\n color.a = alpha;\n return color;\n}\n\nvec4 PBRSpecularDiectionLight (in vec4 albedoColor, in vec3 specularColor, in float smoothness, in vec3 normal, in vec3 viewDir, in DirectionLight light, in LayaGI gi)\n{\n vec3 lightVec = normalize(light.Direction);\n return PBRSpecularLight(albedoColor, specularColor, smoothness, normal, viewDir, lightVec, light.Color, gi);\n}\n\nvec4 PBRSpecularPointLight (in vec4 albedoColor, in vec3 specularColor, in float smoothness, in vec3 normal, in vec3 viewDir, in PointLight light, in vec3 pos, in LayaGI gi)\n{\n vec3 lightCoord = (u_PointLightMatrix * vec4(pos, 1.0)).xyz;\n float distance = dot(lightCoord, lightCoord);\n float attenuate = texture2D(u_RangeTexture, vec2(distance)).w;\n vec3 lightVec = normalize(pos - light.Position);\n return PBRSpecularLight(albedoColor, specularColor, smoothness, normal, viewDir, lightVec, light.Color, gi) * attenuate;\n}\n\nvec4 PBRSpecularSpotLight (in vec4 albedoColor, in vec3 specularColor, in float smoothness, in vec3 normal, in vec3 viewDir, in SpotLight light, in vec3 pos, in LayaGI gi)\n{\n vec3 lightVec = pos - light.Position;\n vec3 normalLightVec = normalize(lightVec);\n vec2 cosAngles = cos(vec2(light.SpotAngle, light.SpotAngle*0.5) * 0.5);//ConeAttenuation\n float dl = dot(normalize(light.Direction), normalLightVec);\n dl *= smoothstep(cosAngles[0], cosAngles[1], dl);\n float attenuate = LayaAttenuation(lightVec, 1.0/light.Range) * dl;\n return PBRSpecularLight(albedoColor, specularColor, smoothness, normal, viewDir, lightVec, light.Color, gi) * attenuate;\n}\n\n//vec4 PBRStandardSpotLight1 (in vec4 albedoColor, in float metallic, in float smoothness, in vec3 normal, in vec3 viewDir, in SpotLight light, in vec3 pos, in LayaGI gi)\n//{\n// vec4 lightCoord = u_SpotLightMatrix * vec4(pos, 1.0);\n// \n// float distance = dot(lightCoord, lightCoord);\n// float attenuate = (lightCoord.z < 0.0) ? texture2D(u_RangeTexture, vec2(distance)).w : 0.0;\n// //float attenuate = (lightCoord.z < 0.0) ? texture2D(u_AngleTexture, vec2(lightCoord.x / lightCoord.w + 0.5, lightCoord.y / lightCoord.w + 0.5)).r * texture2D(u_RangeTexture, vec2(distance)).w : 0.0;\n// //vec2 _uv = vec2(pos.x * 180.0/(2.0 * pos.z) + 0.5, pos.y * 180.0/(2.0 * pos.z) + 0.5);\n// vec3 lightVec = normalize(pos - light.Position);\n// return PBRStandardLight(albedoColor, metallic, smoothness, normal, viewDir, lightVec, light.Color, gi) * attenuate;\n//}\n\nvec4 SpecularGloss(float albedoTextureAlpha, in vec2 uv0)\n{\n vec4 sg;\n \n #ifdef SPECULARTEXTURE\n vec4 specularTextureColor = texture2D(u_SpecularTexture, uv0);\n #ifdef SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA\n sg.rgb = specularTextureColor.rgb;\n sg.a = albedoTextureAlpha;\n #else\n sg = specularTextureColor;\n #endif\n sg.a *= u_smoothnessScale;\n #else\n sg.rgb = u_SpecularColor.rgb;\n #ifdef SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA\n sg.a = albedoTextureAlpha * u_smoothnessScale;\n #else\n sg.a = u_smoothness;\n #endif\n #endif\n \n return sg;\n}\n\n");
  8624. Shader3D.addInclude("Colors.glsl","#include \"StdLib.glsl\";\n\n#define EPSILON 1.0e-4\n\n// Quadratic color thresholding\n// curve = (threshold - knee, knee * 2, 0.25 / knee)\nmediump vec4 quadraticThreshold(mediump vec4 color, mediump float threshold, mediump vec3 curve) {\n // Pixel brightness\n mediump float br = max3(color.r, color.g, color.b);\n\n // Under-threshold part: quadratic curve\n mediump float rq = clamp(br - curve.x, 0.0, curve.y);\n rq = curve.z * rq * rq;\n\n // Combine and apply the brightness response curve.\n color *= max(rq, br - threshold) / max(br, EPSILON);\n\n return color;\n}\n\n//\n// sRGB transfer functions\n// Fast path ref: http://chilliant.blogspot.com.au/2012/08/srgb-approximations-for-hlsl.html?m=1\n//\nmediump vec3 SRGBToLinear(mediump vec3 c) {\n #ifdef USE_VERY_FAST_SRGB\n return c * c;\n #elif defined(USE_FAST_SRGB)\n return c * (c * (c * 0.305306011 + 0.682171111) + 0.012522878);\n #else\n mediump vec3 linearRGBLo = c / 12.92;\n mediump vec3 power=vec3(2.4, 2.4, 2.4);\n mediump vec3 linearRGBHi = positivePow((c + 0.055) / 1.055, power);\n mediump vec3 linearRGB =vec3((c.r<=0.04045) ? linearRGBLo.r : linearRGBHi.r,(c.g<=0.04045) ? linearRGBLo.g : linearRGBHi.g,(c.b<=0.04045) ? linearRGBLo.b : linearRGBHi.b);\n return linearRGB;\n #endif\n}\n\nmediump vec3 LinearToSRGB(mediump vec3 c) {\n #ifdef USE_VERY_FAST_SRGB\n return sqrt(c);\n #elif defined(USE_FAST_SRGB)\n return max(1.055 * PositivePow(c, 0.416666667) - 0.055, 0.0);\n #else\n mediump vec3 sRGBLo = c * 12.92;\n mediump vec3 power=vec3(1.0 / 2.4, 1.0 / 2.4, 1.0 / 2.4);\n mediump vec3 sRGBHi = (positivePow(c, power) * 1.055) - 0.055;\n mediump vec3 sRGB =vec3((c.r<=0.0031308) ? sRGBLo.r : sRGBHi.r,(c.g<=0.0031308) ? sRGBLo.g : sRGBHi.g,(c.b<=0.0031308) ? sRGBLo.b : sRGBHi.b);\n return sRGB;\n #endif\n}");
  8625. Shader3D.addInclude("Sampling.glsl","// Better, temporally stable box filtering\n// [Jimenez14] http://goo.gl/eomGso\n// . . . . . . .\n// . A . B . C .\n// . . D . E . .\n// . F . G . H .\n// . . I . J . .\n// . K . L . M .\n// . . . . . . .\nmediump vec4 downsampleBox13Tap(sampler2D tex, vec2 uv, vec2 texelSize)\n{\n mediump vec4 A = texture2D(tex, uv + texelSize * vec2(-1.0, -1.0));\n mediump vec4 B = texture2D(tex, uv + texelSize * vec2( 0.0, -1.0));\n mediump vec4 C = texture2D(tex, uv + texelSize * vec2( 1.0, -1.0));\n mediump vec4 D = texture2D(tex, uv + texelSize * vec2(-0.5, -0.5));\n mediump vec4 E = texture2D(tex, uv + texelSize * vec2( 0.5, -0.5));\n mediump vec4 F = texture2D(tex, uv + texelSize * vec2(-1.0, 0.0));\n mediump vec4 G = texture2D(tex, uv);\n mediump vec4 H = texture2D(tex, uv + texelSize * vec2( 1.0, 0.0));\n mediump vec4 I = texture2D(tex, uv + texelSize * vec2(-0.5, 0.5));\n mediump vec4 J = texture2D(tex, uv + texelSize * vec2( 0.5, 0.5));\n mediump vec4 K = texture2D(tex, uv + texelSize * vec2(-1.0, 1.0));\n mediump vec4 L = texture2D(tex, uv + texelSize * vec2( 0.0, 1.0));\n mediump vec4 M = texture2D(tex, uv + texelSize * vec2( 1.0, 1.0));\n\n mediump vec2 scale= vec2(0.5, 0.125);\n mediump vec2 div = (1.0 / 4.0) * scale;\n\n mediump vec4 o = (D + E + I + J) * div.x;\n o += (A + B + G + F) * div.y;\n o += (B + C + H + G) * div.y;\n o += (F + G + L + K) * div.y;\n o += (G + H + M + L) * div.y;\n\n return o;\n}\n\n// Standard box filtering\nmediump vec4 downsampleBox4Tap(sampler2D tex, vec2 uv, vec2 texelSize)\n{\n vec4 d = texelSize.xyxy * vec4(-1.0, -1.0, 1.0, 1.0);\n\n mediump vec4 s = texture2D(tex, uv + d.xy);\n s += texture2D(tex, uv + d.zy);\n s += texture2D(tex, uv + d.xw);\n s += texture2D(tex, uv + d.zw);\n\n return s * (1.0 / 4.0);\n}\n\n// 9-tap bilinear upsampler (tent filter)\n// . . . . . . .\n// . 1 . 2 . 1 .\n// . . . . . . .\n// . 2 . 4 . 2 .\n// . . . . . . .\n// . 1 . 2 . 1 .\n// . . . . . . .\nmediump vec4 upsampleTent(sampler2D tex, vec2 uv, vec2 texelSize, vec4 sampleScale)\n{\n vec4 d = texelSize.xyxy * vec4(1.0, 1.0, -1.0, 0.0) * sampleScale;\n\n mediump vec4 s = texture2D(tex, uv - d.xy);\n s += texture2D(tex, uv - d.wy) * 2.0;\n s += texture2D(tex, uv - d.zy);\n\n s += texture2D(tex, uv + d.zw) * 2.0;\n s += texture2D(tex, uv) * 4.0;\n s += texture2D(tex, uv + d.xw) * 2.0;\n\n s += texture2D(tex, uv + d.zy);\n s += texture2D(tex, uv + d.wy) * 2.0;\n s += texture2D(tex, uv + d.xy);\n\n return s * (1.0 / 16.0);\n}\n\n// Standard box filtering\nmediump vec4 upsampleBox(sampler2D tex, vec2 uv, vec2 texelSize, vec4 sampleScale)\n{\n vec4 d = texelSize.xyxy * vec4(-1.0, -1.0, 1.0, 1.0) * (sampleScale * 0.5);\n\n mediump vec4 s = texture2D(tex, uv + d.xy);\n s += texture2D(tex, uv + d.zy);\n s += texture2D(tex, uv + d.xw);\n s += texture2D(tex, uv + d.zw);\n\n return s * (1.0 / 4.0);\n}");
  8626. Shader3D.addInclude("StdLib.glsl","#define HALF_MAX 65504.0 // (2 - 2^-10) * 2^15\n\n#define FLT_EPSILON 1.192092896e-07 // Smallest positive number, such that 1.0 + FLT_EPSILON != 1.0\n\nmediump vec4 safeHDR(mediump vec4 c)\n{\n return min(c, HALF_MAX);\n}\n\nfloat max3(float a, float b, float c)\n{\n return max(max(a, b), c);\n}\n\nvec3 positivePow(vec3 base, vec3 power)\n{\n return pow(max(abs(base), vec3(FLT_EPSILON, FLT_EPSILON, FLT_EPSILON)), power);\n}");
  8627. var vs,ps;
  8628. var attributeMap={
  8629. 'a_Position':/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0,
  8630. 'a_Color':/*laya.d3.graphics.Vertex.VertexMesh.MESH_COLOR0*/1,
  8631. 'a_Normal':/*laya.d3.graphics.Vertex.VertexMesh.MESH_NORMAL0*/3,
  8632. 'a_Texcoord0':/*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE0*/2,
  8633. 'a_Texcoord1':/*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE1*/7,
  8634. 'a_BoneWeights':/*laya.d3.graphics.Vertex.VertexMesh.MESH_BLENDWEIGHT0*/6,
  8635. 'a_BoneIndices':/*laya.d3.graphics.Vertex.VertexMesh.MESH_BLENDINDICES0*/5,
  8636. 'a_Tangent0':/*laya.d3.graphics.Vertex.VertexMesh.MESH_TANGENT0*/4,
  8637. 'a_MvpMatrix':/*laya.d3.graphics.Vertex.VertexMesh.MESH_MVPMATRIX_ROW0*/12,
  8638. 'a_WorldMat':/*laya.d3.graphics.Vertex.VertexMesh.MESH_WORLDMATRIX_ROW0*/8
  8639. };
  8640. var uniformMap={
  8641. 'u_Bones':/*laya.d3.shader.Shader3D.PERIOD_CUSTOM*/0,
  8642. 'u_DiffuseTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8643. 'u_SpecularTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8644. 'u_NormalTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8645. 'u_AlphaTestValue':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8646. 'u_DiffuseColor':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8647. 'u_MaterialSpecular':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8648. 'u_Shininess':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8649. 'u_TilingOffset':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8650. 'u_WorldMat':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8651. 'u_MvpMatrix':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8652. 'u_LightmapScaleOffset':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8653. 'u_LightMap':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8654. 'u_CameraPos':/*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3,
  8655. 'u_ReflectTexture':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8656. 'u_ReflectIntensity':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8657. 'u_FogStart':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8658. 'u_FogRange':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8659. 'u_FogColor':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8660. 'u_DirectionLight.Color':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8661. 'u_DirectionLight.Direction':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8662. 'u_PointLight.Position':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8663. 'u_PointLight.Range':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8664. 'u_PointLight.Color':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8665. 'u_SpotLight.Position':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8666. 'u_SpotLight.Direction':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8667. 'u_SpotLight.Range':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8668. 'u_SpotLight.Spot':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8669. 'u_SpotLight.Color':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8670. 'u_AmbientColor':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8671. 'u_shadowMap1':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8672. 'u_shadowMap2':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8673. 'u_shadowMap3':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8674. 'u_shadowPSSMDistance':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8675. 'u_lightShadowVP':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8676. 'u_shadowPCFoffset':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4
  8677. };
  8678. var stateMap={
  8679. 's_Cull':/*laya.d3.shader.Shader3D.RENDER_STATE_CULL*/0,
  8680. 's_Blend':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND*/1,
  8681. 's_BlendSrc':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_SRC*/2,
  8682. 's_BlendDst':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_DST*/3,
  8683. 's_DepthTest':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_TEST*/12,
  8684. 's_DepthWrite':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_WRITE*/13
  8685. }
  8686. vs="#include \"Lighting.glsl\";\n\nattribute vec4 a_Position;\n\n#ifdef GPU_INSTANCE\n attribute mat4 a_MvpMatrix;\n#else\n uniform mat4 u_MvpMatrix;\n#endif\n\n\n#if defined(DIFFUSEMAP)||((defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&(defined(SPECULARMAP)||defined(NORMALMAP)))||(defined(LIGHTMAP)&&defined(UV))\n attribute vec2 a_Texcoord0;\n varying vec2 v_Texcoord0;\n#endif\n\n#if defined(LIGHTMAP)&&defined(UV1)\n attribute vec2 a_Texcoord1;\n#endif\n\n#ifdef LIGHTMAP\n uniform vec4 u_LightmapScaleOffset;\n varying vec2 v_LightMapUV;\n#endif\n\n#ifdef COLOR\n attribute vec4 a_Color;\n varying vec4 v_Color;\n#endif\n\n#ifdef BONE\n const int c_MaxBoneCount = 24;\n attribute vec4 a_BoneIndices;\n attribute vec4 a_BoneWeights;\n uniform mat4 u_Bones[c_MaxBoneCount];\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n attribute vec3 a_Normal;\n varying vec3 v_Normal; \n uniform vec3 u_CameraPos;\n varying vec3 v_ViewDir; \n#endif\n\n#if (defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&defined(NORMALMAP)\n attribute vec4 a_Tangent0;\n varying vec3 v_Tangent;\n varying vec3 v_Binormal;\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(RECEIVESHADOW)\n #ifdef GPU_INSTANCE\n attribute mat4 a_WorldMat;\n #else\n uniform mat4 u_WorldMat;\n #endif\n varying vec3 v_PositionWorld;\n#endif\n\nvarying float v_posViewZ;\n#ifdef RECEIVESHADOW\n #ifdef SHADOWMAP_PSSM1 \n varying vec4 v_lightMVPPos;\n uniform mat4 u_lightShadowVP[4];\n #endif\n#endif\n\n#ifdef TILINGOFFSET\n uniform vec4 u_TilingOffset;\n#endif\n\nvoid main_castShadow()\n{\n vec4 position;\n #ifdef BONE\n mat4 skinTransform = u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\n skinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\n skinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\n skinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\n position=skinTransform*a_Position;\n #else\n position=a_Position;\n #endif\n #ifdef GPU_INSTANCE\n gl_Position = a_MvpMatrix * position;\n #else\n gl_Position = u_MvpMatrix * position;\n #endif\n \n //TODO没考虑UV动画呢\n #if defined(DIFFUSEMAP)&&defined(ALPHATEST)\n v_Texcoord0=a_Texcoord0;\n #endif\n gl_Position=remapGLPositionZ(gl_Position);\n v_posViewZ = gl_Position.z;\n}\n\nvoid main_normal()\n{\n vec4 position;\n #ifdef BONE\n mat4 skinTransform = u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\n skinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\n skinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\n skinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\n position=skinTransform*a_Position;\n #else\n position=a_Position;\n #endif\n #ifdef GPU_INSTANCE\n gl_Position = a_MvpMatrix * position;\n #else\n gl_Position = u_MvpMatrix * position;\n #endif\n \n #if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(RECEIVESHADOW)\n mat4 worldMat;\n #ifdef GPU_INSTANCE\n worldMat = a_WorldMat;\n #else\n worldMat = u_WorldMat;\n #endif\n #endif\n \n\n #if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n mat3 worldInvMat;\n #ifdef BONE\n worldInvMat=inverse(mat3(worldMat*skinTransform));\n #else\n worldInvMat=inverse(mat3(worldMat));\n #endif \n v_Normal=a_Normal*worldInvMat;\n #if (defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&defined(NORMALMAP)\n v_Tangent=a_Tangent0.xyz*worldInvMat;\n v_Binormal=cross(v_Normal,v_Tangent)*a_Tangent0.w;\n #endif\n #endif\n\n #if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(RECEIVESHADOW)\n v_PositionWorld=(worldMat*position).xyz;\n #endif\n \n #if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n v_ViewDir=u_CameraPos-v_PositionWorld;\n #endif\n\n #if defined(DIFFUSEMAP)||((defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&(defined(SPECULARMAP)||defined(NORMALMAP)))\n #ifdef TILINGOFFSET\n v_Texcoord0=TransformUV(a_Texcoord0,u_TilingOffset);\n #else\n v_Texcoord0=a_Texcoord0;\n #endif\n #endif\n\n #ifdef LIGHTMAP\n #ifdef SCALEOFFSETLIGHTINGMAPUV\n #ifdef UV1\n v_LightMapUV=vec2(a_Texcoord1.x,1.0-a_Texcoord1.y)*u_LightmapScaleOffset.xy+u_LightmapScaleOffset.zw;\n #else\n v_LightMapUV=vec2(a_Texcoord0.x,1.0-a_Texcoord0.y)*u_LightmapScaleOffset.xy+u_LightmapScaleOffset.zw;\n #endif \n v_LightMapUV.y=1.0-v_LightMapUV.y;\n #else\n #ifdef UV1\n v_LightMapUV=a_Texcoord1;\n #else\n v_LightMapUV=a_Texcoord0;\n #endif \n #endif \n #endif\n\n #if defined(COLOR)&&defined(ENABLEVERTEXCOLOR)\n v_Color=a_Color;\n #endif\n\n #ifdef RECEIVESHADOW\n v_posViewZ = gl_Position.w;\n #ifdef SHADOWMAP_PSSM1 \n v_lightMVPPos = u_lightShadowVP[0] * vec4(v_PositionWorld,1.0);\n #endif\n #endif\n gl_Position=remapGLPositionZ(gl_Position);\n}\n\nvoid main()\n{\n #ifdef CASTSHADOW\n main_castShadow();\n #else\n main_normal();\n #endif\n}";
  8687. ps="#ifdef HIGHPRECISION\n precision highp float;\n#else\n precision mediump float;\n#endif\n\n#include \"Lighting.glsl\";\n\nuniform vec4 u_DiffuseColor;\n\n#if defined(COLOR)&&defined(ENABLEVERTEXCOLOR)\n varying vec4 v_Color;\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n varying vec3 v_ViewDir; \n#endif\n\n#ifdef ALPHATEST\n uniform float u_AlphaTestValue;\n#endif\n\n#ifdef DIFFUSEMAP\n uniform sampler2D u_DiffuseTexture;\n#endif\n\n\n\n#if defined(DIFFUSEMAP)||((defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&(defined(SPECULARMAP)||defined(NORMALMAP)))\n varying vec2 v_Texcoord0;\n#endif\n\n#ifdef LIGHTMAP\n varying vec2 v_LightMapUV;\n uniform sampler2D u_LightMap;\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n uniform vec3 u_MaterialSpecular;\n uniform float u_Shininess;\n #ifdef SPECULARMAP \n uniform sampler2D u_SpecularTexture;\n #endif\n#endif\n\n#ifdef FOG\n uniform float u_FogStart;\n uniform float u_FogRange;\n uniform vec3 u_FogColor;\n#endif\n\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n varying vec3 v_Normal;\n#endif\n\n#if (defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&defined(NORMALMAP)\n uniform sampler2D u_NormalTexture;\n varying vec3 v_Tangent;\n varying vec3 v_Binormal;\n#endif\n\n#ifdef DIRECTIONLIGHT\n uniform DirectionLight u_DirectionLight;\n#endif\n\n#ifdef POINTLIGHT\n uniform PointLight u_PointLight;\n#endif\n\n#ifdef SPOTLIGHT\n uniform SpotLight u_SpotLight;\n#endif\n\nuniform vec3 u_AmbientColor;\n\n\n#if defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(RECEIVESHADOW)\n varying vec3 v_PositionWorld;\n#endif\n\n#include \"ShadowHelper.glsl\"\nvarying float v_posViewZ;\n#ifdef RECEIVESHADOW\n #if defined(SHADOWMAP_PSSM2)||defined(SHADOWMAP_PSSM3)\n uniform mat4 u_lightShadowVP[4];\n #endif\n #ifdef SHADOWMAP_PSSM1 \n varying vec4 v_lightMVPPos;\n #endif\n#endif\n\nvoid main_castShadow()\n{\n //gl_FragColor=vec4(v_posViewZ,0.0,0.0,1.0);\n gl_FragColor=packDepth(v_posViewZ);\n #if defined(DIFFUSEMAP)&&defined(ALPHATEST)\n float alpha = texture2D(u_DiffuseTexture,v_Texcoord0).w;\n if( alpha < u_AlphaTestValue )\n {\n discard;\n }\n #endif\n}\nvoid main_normal()\n{\n vec3 globalDiffuse=u_AmbientColor;\n #ifdef LIGHTMAP \n globalDiffuse += DecodeLightmap(texture2D(u_LightMap, v_LightMapUV));\n #endif\n \n #if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n vec3 normal;\n #if (defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))&&defined(NORMALMAP)\n vec3 normalMapSample = texture2D(u_NormalTexture, v_Texcoord0).rgb;\n normal = normalize(NormalSampleToWorldSpace(normalMapSample, v_Normal, v_Tangent,v_Binormal));\n #else\n normal = normalize(v_Normal);\n #endif\n vec3 viewDir= normalize(v_ViewDir);\n #endif\n \n vec4 mainColor=u_DiffuseColor;\n #ifdef DIFFUSEMAP\n vec4 difTexColor=texture2D(u_DiffuseTexture, v_Texcoord0);\n mainColor=mainColor*difTexColor;\n #endif \n #if defined(COLOR)&&defined(ENABLEVERTEXCOLOR)\n mainColor=mainColor*v_Color;\n #endif \n \n #ifdef ALPHATEST\n if(mainColor.a<u_AlphaTestValue)\n discard;\n #endif\n \n \n vec3 diffuse = vec3(0.0);\n vec3 specular= vec3(0.0);\n #if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n vec3 dif,spe;\n #ifdef SPECULARMAP\n vec3 gloss=texture2D(u_SpecularTexture, v_Texcoord0).rgb;\n #else\n #ifdef DIFFUSEMAP\n vec3 gloss=vec3(difTexColor.a);\n #else\n vec3 gloss=vec3(1.0);\n #endif\n #endif\n #endif\n\n \n #ifdef DIRECTIONLIGHT\n LayaAirBlinnPhongDiectionLight(u_MaterialSpecular,u_Shininess,normal,gloss,viewDir,u_DirectionLight,dif,spe);\n diffuse+=dif;\n specular+=spe;\n #endif\n \n #ifdef POINTLIGHT\n LayaAirBlinnPhongPointLight(v_PositionWorld,u_MaterialSpecular,u_Shininess,normal,gloss,viewDir,u_PointLight,dif,spe);\n diffuse+=dif;\n specular+=spe;\n #endif\n\n #ifdef SPOTLIGHT\n LayaAirBlinnPhongSpotLight(v_PositionWorld,u_MaterialSpecular,u_Shininess,normal,gloss,viewDir,u_SpotLight,dif,spe);\n diffuse+=dif;\n specular+=spe;\n #endif\n\n #ifdef RECEIVESHADOW\n float shadowValue = 1.0;\n #ifdef SHADOWMAP_PSSM3\n shadowValue = getShadowPSSM3(u_shadowMap1,u_shadowMap2,u_shadowMap3,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n #endif\n #ifdef SHADOWMAP_PSSM2\n shadowValue = getShadowPSSM2(u_shadowMap1,u_shadowMap2,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n #endif \n #ifdef SHADOWMAP_PSSM1\n shadowValue = getShadowPSSM1(u_shadowMap1,v_lightMVPPos,u_shadowPSSMDistance,u_shadowPCFoffset,v_posViewZ,0.001);\n #endif\n gl_FragColor =vec4(mainColor.rgb*(globalDiffuse + diffuse*shadowValue),mainColor.a);\n #else\n gl_FragColor =vec4(mainColor.rgb*(globalDiffuse + diffuse),mainColor.a);\n #endif\n\n #if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n #ifdef RECEIVESHADOW\n gl_FragColor.rgb+=specular*shadowValue;\n #else\n gl_FragColor.rgb+=specular;\n #endif\n #endif\n \n #ifdef FOG\n float lerpFact=clamp((1.0/gl_FragCoord.w-u_FogStart)/u_FogRange,0.0,1.0);\n gl_FragColor.rgb=mix(gl_FragColor.rgb,u_FogColor,lerpFact);\n #endif\n}\n\nvoid main()\n{\n #ifdef CASTSHADOW \n main_castShadow();\n #else\n main_normal();\n #endif \n}\n\n";
  8688. var shader=Shader3D.add("BLINNPHONG",true);
  8689. var subShader=new SubShader(attributeMap,uniformMap,SkinnedMeshSprite3D.shaderDefines,BlinnPhongMaterial.shaderDefines);
  8690. shader.addSubShader(subShader);
  8691. subShader.addShaderPass(vs,ps,stateMap);
  8692. attributeMap={
  8693. 'a_Position':/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0,
  8694. 'a_Color':/*laya.d3.graphics.Vertex.VertexMesh.MESH_COLOR0*/1};
  8695. uniformMap={
  8696. 'u_MvpMatrix':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8697. 'u_Color':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1
  8698. };
  8699. stateMap={
  8700. 's_Cull':/*laya.d3.shader.Shader3D.RENDER_STATE_CULL*/0,
  8701. 's_Blend':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND*/1,
  8702. 's_BlendSrc':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_SRC*/2,
  8703. 's_BlendDst':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_DST*/3,
  8704. 's_DepthTest':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_TEST*/12,
  8705. 's_DepthWrite':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_WRITE*/13
  8706. }
  8707. vs="#include \"Lighting.glsl\";\n\nattribute vec4 a_Position;\nuniform mat4 u_MvpMatrix;\nuniform vec4 u_Color;\nattribute vec4 a_Color;\nvarying vec4 v_Color;\n\n\nvoid main()\n{\n gl_Position = u_MvpMatrix * a_Position;\n v_Color=a_Color*u_Color;\n gl_Position=remapGLPositionZ(gl_Position);\n}";
  8708. ps="#ifdef HIGHPRECISION\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nvarying vec4 v_Color;\nuniform vec4 u_Color;\n\nvoid main()\n{\n gl_FragColor = v_Color * u_Color; \n}\n\n";
  8709. shader=Shader3D.add("LineShader");
  8710. subShader=new SubShader(attributeMap,uniformMap);
  8711. shader.addSubShader(subShader);
  8712. subShader.addShaderPass(vs,ps,stateMap);
  8713. attributeMap={
  8714. 'a_Position':/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0,
  8715. 'a_Normal':/*laya.d3.graphics.Vertex.VertexMesh.MESH_NORMAL0*/3,
  8716. 'a_Tangent0':/*laya.d3.graphics.Vertex.VertexMesh.MESH_TANGENT0*/4,
  8717. 'a_Texcoord0':/*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE0*/2,
  8718. 'a_BoneWeights':/*laya.d3.graphics.Vertex.VertexMesh.MESH_BLENDWEIGHT0*/6,
  8719. 'a_BoneIndices':/*laya.d3.graphics.Vertex.VertexMesh.MESH_BLENDINDICES0*/5,
  8720. 'a_MvpMatrix':/*laya.d3.graphics.Vertex.VertexMesh.MESH_MVPMATRIX_ROW0*/12,
  8721. 'a_WorldMat':/*laya.d3.graphics.Vertex.VertexMesh.MESH_WORLDMATRIX_ROW0*/8
  8722. };
  8723. uniformMap={
  8724. 'u_Bones':/*laya.d3.shader.Shader3D.PERIOD_CUSTOM*/0,
  8725. 'u_MvpMatrix':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8726. 'u_WorldMat':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8727. 'u_CameraPos':/*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3,
  8728. 'u_AlphaTestValue':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8729. 'u_AlbedoColor':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8730. 'u_EmissionColor':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8731. 'u_AlbedoTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8732. 'u_NormalTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8733. 'u_ParallaxTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8734. 'u_MetallicGlossTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8735. 'u_OcclusionTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8736. 'u_EmissionTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8737. 'u_metallic':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8738. 'u_smoothness':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8739. 'u_smoothnessScale':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8740. 'u_occlusionStrength':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8741. 'u_normalScale':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8742. 'u_parallaxScale':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8743. 'u_TilingOffset':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8744. 'u_DirectionLight.Direction':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8745. 'u_DirectionLight.Color':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8746. 'u_PointLightMatrix':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8747. 'u_PointLight.Position':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8748. 'u_PointLight.Range':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8749. 'u_PointLight.Color':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8750. 'u_SpotLight.Position':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8751. 'u_SpotLight.Direction':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8752. 'u_SpotLight.Range':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8753. 'u_SpotLight.SpotAngle':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8754. 'u_SpotLight.Color':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8755. 'u_RangeTexture':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8756. 'u_ReflectTexture':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8757. 'u_ReflectIntensity':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8758. 'u_AmbientColor':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8759. 'u_shadowMap1':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8760. 'u_shadowMap2':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8761. 'u_shadowMap3':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8762. 'u_shadowPSSMDistance':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8763. 'u_lightShadowVP':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8764. 'u_shadowPCFoffset':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8765. 'u_FogStart':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8766. 'u_FogRange':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8767. 'u_FogColor':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4
  8768. };
  8769. stateMap={
  8770. 's_Cull':/*laya.d3.shader.Shader3D.RENDER_STATE_CULL*/0,
  8771. 's_Blend':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND*/1,
  8772. 's_BlendSrc':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_SRC*/2,
  8773. 's_BlendDst':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_DST*/3,
  8774. 's_DepthTest':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_TEST*/12,
  8775. 's_DepthWrite':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_WRITE*/13
  8776. }
  8777. vs="#include \"Lighting.glsl\";\n\nattribute vec4 a_Position;\nattribute vec3 a_Normal;\nattribute vec4 a_Tangent0;\nattribute vec2 a_Texcoord0;\n\n#ifdef GPU_INSTANCE\n attribute mat4 a_MvpMatrix;\n#else\n uniform mat4 u_MvpMatrix;\n#endif\n\n#ifdef GPU_INSTANCE\n attribute mat4 a_WorldMat;\n#else\n uniform mat4 u_WorldMat;\n#endif\n\nuniform vec3 u_CameraPos;\n\nvarying vec2 v_Texcoord0;\nvarying vec3 v_Normal;\nvarying vec3 v_Tangent;\nvarying vec3 v_Binormal;\nvarying vec3 v_ViewDir;\nvarying vec3 v_PositionWorld;\n\n#ifdef TILINGOFFSET\n uniform vec4 u_TilingOffset;\n#endif\n\nvarying float v_posViewZ;\n#ifdef RECEIVESHADOW\n #ifdef SHADOWMAP_PSSM1 \n varying vec4 v_lightMVPPos;\n uniform mat4 u_lightShadowVP[4];\n #endif\n#endif\n\n#ifdef BONE\n const int c_MaxBoneCount = 24;\n attribute vec4 a_BoneIndices;\n attribute vec4 a_BoneWeights;\n uniform mat4 u_Bones[c_MaxBoneCount];\n#endif\n\nvoid main_castShadow()\n{\n vec4 position;\n #ifdef BONE\n mat4 skinTransform = u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\n skinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\n skinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\n skinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\n position=skinTransform*a_Position;\n #else\n position=a_Position;\n #endif\n #ifdef GPU_INSTANCE\n gl_Position = a_MvpMatrix * position;\n #else\n gl_Position = u_MvpMatrix * position;\n #endif\n \n //TODO没考虑UV动画呢\n #if defined(DIFFUSEMAP)&&defined(ALPHATEST)\n v_Texcoord0 = a_Texcoord0;\n #endif\n gl_Position=remapGLPositionZ(gl_Position);\n v_posViewZ = gl_Position.z;\n}\n\nvoid main_normal()\n{\n vec4 position;\n #ifdef BONE\n mat4 skinTransform = u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\n skinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\n skinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\n skinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\n position=skinTransform*a_Position;\n #else\n position=a_Position;\n #endif\n #ifdef GPU_INSTANCE\n gl_Position = a_MvpMatrix * position;\n #else\n gl_Position = u_MvpMatrix * position;\n #endif\n \n #if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(RECEIVESHADOW)\n mat4 worldMat;\n #ifdef GPU_INSTANCE\n worldMat = a_WorldMat;\n #else\n worldMat = u_WorldMat;\n #endif\n #endif\n \n #if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n mat3 worldInvMat;\n #ifdef BONE\n worldInvMat=inverse(mat3(worldMat*skinTransform));\n #else\n worldInvMat=inverse(mat3(worldMat));\n #endif \n v_Normal=a_Normal*worldInvMat;\n #if (defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))\n v_Tangent=a_Tangent0.xyz*worldInvMat;\n v_Binormal=cross(v_Normal,v_Tangent)*a_Tangent0.w;\n #endif\n #endif\n \n \n #if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(RECEIVESHADOW)\n v_PositionWorld=(worldMat*position).xyz;\n #endif\n \n \n #if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n v_ViewDir=u_CameraPos-v_PositionWorld;\n #endif\n\n #ifdef TILINGOFFSET\n v_Texcoord0=TransformUV(a_Texcoord0,u_TilingOffset);\n #else\n v_Texcoord0=a_Texcoord0;\n #endif\n \n #ifdef RECEIVESHADOW\n v_posViewZ = gl_Position.w;\n #ifdef SHADOWMAP_PSSM1 \n v_lightMVPPos = u_lightShadowVP[0] * vec4(v_PositionWorld,1.0);\n #endif\n #endif\n gl_Position=remapGLPositionZ(gl_Position);\n}\n\nvoid main()\n{\n #ifdef CASTSHADOW\n main_castShadow();\n #else\n main_normal();\n #endif\n}";
  8778. ps="#ifdef FSHIGHPRECISION\n precision highp float;\n#else\n precision mediump float;\n#endif\n\nvarying vec2 v_Texcoord0;\nvarying vec3 v_Normal;\nvarying vec3 v_Tangent;\nvarying vec3 v_Binormal;\nvarying vec3 v_ViewDir;\nvarying vec3 v_PositionWorld;\n\nuniform vec3 u_AmbientColor;\nuniform vec4 u_AlbedoColor;\n\n#ifdef ALBEDOTEXTURE\n uniform sampler2D u_AlbedoTexture;\n#endif\n#ifdef METALLICGLOSSTEXTURE\n uniform sampler2D u_MetallicGlossTexture;\n#endif\n#ifdef NORMALTEXTURE\n uniform sampler2D u_NormalTexture;\n uniform float u_normalScale;\n#endif\n#ifdef PARALLAXTEXTURE\n uniform sampler2D u_ParallaxTexture;\n uniform float u_parallaxScale;\n#endif\n#ifdef OCCLUSIONTEXTURE\n uniform sampler2D u_OcclusionTexture;\n uniform float u_occlusionStrength;\n#endif\n#ifdef EMISSION\n #ifdef EMISSIONTEXTURE\n uniform sampler2D u_EmissionTexture;\n #endif\n uniform vec4 u_EmissionColor;\n#endif\n#ifdef REFLECTMAP\n uniform samplerCube u_ReflectTexture;\n uniform float u_ReflectIntensity;\n#endif\n\nuniform float u_AlphaTestValue;\nuniform float u_metallic;\nuniform float u_smoothness;\nuniform float u_smoothnessScale;\n\nuniform sampler2D u_RangeTexture;\n//uniform sampler2D u_AngleTexture;\nuniform mat4 u_PointLightMatrix;\n//uniform mat4 u_SpotLightMatrix;\n\n#include \"PBRStandardLighting.glsl\"\n#include \"ShadowHelper.glsl\"\n\nvarying float v_posViewZ;\n#ifdef RECEIVESHADOW\n #if defined(SHADOWMAP_PSSM2)||defined(SHADOWMAP_PSSM3)\n uniform mat4 u_lightShadowVP[4];\n #endif\n #ifdef SHADOWMAP_PSSM1 \n varying vec4 v_lightMVPPos;\n #endif\n#endif\n\n#ifdef DIRECTIONLIGHT\n uniform DirectionLight u_DirectionLight;\n#endif\n#ifdef POINTLIGHT\n uniform PointLight u_PointLight;\n#endif\n#ifdef SPOTLIGHT\n uniform SpotLight u_SpotLight;\n#endif\n\n#ifdef FOG\n uniform float u_FogStart;\n uniform float u_FogRange;\n uniform vec3 u_FogColor;\n#endif\n\nvoid main_castShadow()\n{\n gl_FragColor=packDepth(v_posViewZ);\n #if defined(DIFFUSEMAP)&&defined(ALPHATEST)\n float alpha = texture2D(u_AlbedoTexture,v_Texcoord0).w;\n if( alpha < u_AlphaTestValue )\n {\n discard;\n }\n #endif\n}\n\nvoid main_normal()\n{ \n vec3 viewDir = normalize(v_ViewDir);\n \n vec2 uv0 = ParallaxOffset(viewDir);\n \n vec2 mg;\n vec4 albedoColor;\n #ifdef ALBEDOTEXTURE\n vec4 abledoTextureColor = texture2D(u_AlbedoTexture, uv0);\n albedoColor = abledoTextureColor * u_AlbedoColor;\n mg = MetallicGloss(abledoTextureColor.a, uv0);\n #else\n albedoColor = u_AlbedoColor;\n mg = MetallicGloss(1.0, uv0);\n #endif\n \n #ifdef ALPHATEST\n if(albedoColor.a < u_AlphaTestValue)\n discard;\n #endif\n \n vec3 normal = UnpackScaleNormal(uv0);\n \n LayaGI gi;\n gi.diffuse = u_AmbientColor * Occlusion(uv0).rgb;\n gi.specular = ReflectCubeMap(viewDir, normal);\n \n vec4 color = vec4(0.0);\n \n #ifdef DIRECTIONLIGHT\n color += PBRStandardDiectionLight(albedoColor, mg.r, mg.g, normal, viewDir, u_DirectionLight, gi);\n #endif\n \n #ifdef POINTLIGHT\n color.a = 0.0;\n color += PBRStandardPointLight(albedoColor, mg.r, mg.g, normal, viewDir, u_PointLight, v_PositionWorld, gi);\n #endif\n \n #ifdef SPOTLIGHT\n color.a = 0.0;\n color += PBRStandardSpotLight(albedoColor, mg.r, mg.g, normal, viewDir, u_SpotLight, v_PositionWorld, gi);\n #endif\n \n #ifdef EMISSION\n vec4 emissionColor = u_EmissionColor;\n #ifdef EMISSIONTEXTURE\n emissionColor *= texture2D(u_EmissionTexture, uv0);\n #endif\n color.rgb += emissionColor.rgb;\n #endif\n \n #ifdef RECEIVESHADOW\n float shadowValue = 1.0;\n #ifdef SHADOWMAP_PSSM3\n shadowValue = getShadowPSSM3( u_shadowMap1,u_shadowMap2,u_shadowMap3,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n #endif\n #ifdef SHADOWMAP_PSSM2\n shadowValue = getShadowPSSM2( u_shadowMap1,u_shadowMap2,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n #endif \n #ifdef SHADOWMAP_PSSM1\n shadowValue = getShadowPSSM1( u_shadowMap1,v_lightMVPPos,u_shadowPSSMDistance,u_shadowPCFoffset,v_posViewZ,0.001);\n #endif\n gl_FragColor = vec4(color.rgb * shadowValue, color.a);\n #else\n gl_FragColor = color;\n #endif\n \n #ifdef FOG\n float lerpFact = clamp((1.0 / gl_FragCoord.w - u_FogStart) / u_FogRange, 0.0, 1.0);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, u_FogColor, lerpFact);\n #endif\n}\n\nvoid main()\n{\n #ifdef CASTSHADOW \n main_castShadow();\n #else\n main_normal();\n #endif \n}";
  8779. shader=Shader3D.add("PBRStandard",true);
  8780. subShader=new SubShader(attributeMap,uniformMap,SkinnedMeshSprite3D.shaderDefines,PBRStandardMaterial.shaderDefines);
  8781. shader.addSubShader(subShader);
  8782. subShader.addShaderPass(vs,ps,stateMap);
  8783. attributeMap={
  8784. 'a_Position':/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0,
  8785. 'a_Normal':/*laya.d3.graphics.Vertex.VertexMesh.MESH_NORMAL0*/3,
  8786. 'a_Tangent0':/*laya.d3.graphics.Vertex.VertexMesh.MESH_TANGENT0*/4,
  8787. 'a_Texcoord0':/*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE0*/2,
  8788. 'a_BoneWeights':/*laya.d3.graphics.Vertex.VertexMesh.MESH_BLENDWEIGHT0*/6,
  8789. 'a_BoneIndices':/*laya.d3.graphics.Vertex.VertexMesh.MESH_BLENDINDICES0*/5,
  8790. 'a_MvpMatrix':/*laya.d3.graphics.Vertex.VertexMesh.MESH_MVPMATRIX_ROW0*/12,
  8791. 'a_WorldMat':/*laya.d3.graphics.Vertex.VertexMesh.MESH_WORLDMATRIX_ROW0*/8
  8792. };
  8793. uniformMap={
  8794. 'u_Bones':/*laya.d3.shader.Shader3D.PERIOD_CUSTOM*/0,
  8795. 'u_MvpMatrix':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8796. 'u_WorldMat':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8797. 'u_CameraPos':/*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3,
  8798. 'u_AlphaTestValue':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8799. 'u_AlbedoColor':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8800. 'u_SpecularColor':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8801. 'u_EmissionColor':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8802. 'u_AlbedoTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8803. 'u_NormalTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8804. 'u_ParallaxTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8805. 'u_SpecularTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8806. 'u_OcclusionTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8807. 'u_EmissionTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8808. 'u_smoothness':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8809. 'u_smoothnessScale':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8810. 'u_occlusionStrength':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8811. 'u_normalScale':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8812. 'u_parallaxScale':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8813. 'u_TilingOffset':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8814. 'u_DirectionLight.Direction':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8815. 'u_DirectionLight.Color':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8816. 'u_PointLightMatrix':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8817. 'u_PointLight.Position':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8818. 'u_PointLight.Range':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8819. 'u_PointLight.Color':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8820. 'u_SpotLight.Position':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8821. 'u_SpotLight.Direction':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8822. 'u_SpotLight.Range':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8823. 'u_SpotLight.SpotAngle':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8824. 'u_SpotLight.Color':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8825. 'u_RangeTexture':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8826. 'u_ReflectTexture':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8827. 'u_ReflectIntensity':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8828. 'u_AmbientColor':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8829. 'u_shadowMap1':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8830. 'u_shadowMap2':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8831. 'u_shadowMap3':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8832. 'u_shadowPSSMDistance':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8833. 'u_lightShadowVP':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8834. 'u_shadowPCFoffset':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8835. 'u_FogStart':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8836. 'u_FogRange':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8837. 'u_FogColor':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4
  8838. };
  8839. stateMap={
  8840. 's_Cull':/*laya.d3.shader.Shader3D.RENDER_STATE_CULL*/0,
  8841. 's_Blend':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND*/1,
  8842. 's_BlendSrc':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_SRC*/2,
  8843. 's_BlendDst':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_DST*/3,
  8844. 's_DepthTest':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_TEST*/12,
  8845. 's_DepthWrite':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_WRITE*/13
  8846. }
  8847. vs="#include \"Lighting.glsl\";\n\nattribute vec4 a_Position;\nattribute vec3 a_Normal;\nattribute vec4 a_Tangent0;\nattribute vec2 a_Texcoord0;\n\n#ifdef GPU_INSTANCE\n attribute mat4 a_MvpMatrix;\n#else\n uniform mat4 u_MvpMatrix;\n#endif\n\n#ifdef GPU_INSTANCE\n attribute mat4 a_WorldMat;\n#else\n uniform mat4 u_WorldMat;\n#endif\nuniform vec3 u_CameraPos;\n\nvarying vec2 v_Texcoord0;\nvarying vec3 v_Normal;\nvarying vec3 v_Tangent;\nvarying vec3 v_Binormal;\nvarying vec3 v_ViewDir;\nvarying vec3 v_PositionWorld;\n\n#ifdef TILINGOFFSET\n uniform vec4 u_TilingOffset;\n#endif\n\nvarying float v_posViewZ;\n#ifdef RECEIVESHADOW\n #ifdef SHADOWMAP_PSSM1 \n varying vec4 v_lightMVPPos;\n uniform mat4 u_lightShadowVP[4];\n #endif\n#endif\n\n#ifdef BONE\n const int c_MaxBoneCount = 24;\n attribute vec4 a_BoneIndices;\n attribute vec4 a_BoneWeights;\n uniform mat4 u_Bones[c_MaxBoneCount];\n#endif\n\nvoid main_castShadow()\n{\n vec4 position;\n #ifdef BONE\n mat4 skinTransform = u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\n skinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\n skinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\n skinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\n position=skinTransform*a_Position;\n #else\n position=a_Position;\n #endif\n #ifdef GPU_INSTANCE\n gl_Position = a_MvpMatrix * position;\n #else\n gl_Position = u_MvpMatrix * position;\n #endif\n \n //TODO没考虑UV动画呢\n #if defined(DIFFUSEMAP)&&defined(ALPHATEST)\n v_Texcoord0 = a_Texcoord0;\n #endif\n gl_Position=remapGLPositionZ(gl_Position);\n v_posViewZ = gl_Position.z;\n}\n\nvoid main_normal()\n{\n vec4 position;\n #ifdef BONE\n mat4 skinTransform = u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\n skinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\n skinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\n skinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\n position=skinTransform*a_Position;\n #else\n position=a_Position;\n #endif\n #ifdef GPU_INSTANCE\n gl_Position = a_MvpMatrix * position;\n #else\n gl_Position = u_MvpMatrix * position;\n #endif\n \n #if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(RECEIVESHADOW)\n mat4 worldMat;\n #ifdef GPU_INSTANCE\n worldMat = a_WorldMat;\n #else\n worldMat = u_WorldMat;\n #endif\n #endif\n \n #if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n mat3 worldInvMat;\n #ifdef BONE\n worldInvMat=inverse(mat3(worldMat*skinTransform));\n #else\n worldInvMat=inverse(mat3(worldMat));\n #endif \n v_Normal=a_Normal*worldInvMat;\n #if (defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT))\n v_Tangent=a_Tangent0.xyz*worldInvMat;\n v_Binormal=cross(v_Normal,v_Tangent)*a_Tangent0.w;\n #endif\n #endif\n \n \n #if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(RECEIVESHADOW)\n v_PositionWorld=(worldMat*position).xyz;\n #endif\n \n \n #if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n v_ViewDir=u_CameraPos-v_PositionWorld;\n #endif\n\n #ifdef TILINGOFFSET\n v_Texcoord0=TransformUV(a_Texcoord0,u_TilingOffset);\n #else\n v_Texcoord0=a_Texcoord0;\n #endif\n \n #ifdef RECEIVESHADOW\n v_posViewZ = gl_Position.w;\n #ifdef SHADOWMAP_PSSM1 \n v_lightMVPPos = u_lightShadowVP[0] * vec4(v_PositionWorld,1.0);\n #endif\n #endif\n gl_Position=remapGLPositionZ(gl_Position);\n}\n\nvoid main()\n{\n #ifdef CASTSHADOW\n main_castShadow();\n #else\n main_normal();\n #endif\n}";
  8848. ps="#ifdef FSHIGHPRECISION\n precision highp float;\n#else\n precision mediump float;\n#endif\n\nvarying vec2 v_Texcoord0;\nvarying vec3 v_Normal;\nvarying vec3 v_Tangent;\nvarying vec3 v_Binormal;\nvarying vec3 v_ViewDir;\nvarying vec3 v_PositionWorld;\n\nuniform vec3 u_AmbientColor;\nuniform vec4 u_AlbedoColor;\nuniform vec4 u_SpecularColor;\n\n#ifdef ALBEDOTEXTURE\n uniform sampler2D u_AlbedoTexture;\n#endif\n#ifdef SPECULARTEXTURE\n uniform sampler2D u_SpecularTexture;\n#endif\n#ifdef NORMALTEXTURE\n uniform sampler2D u_NormalTexture;\n uniform float u_normalScale;\n#endif\n#ifdef PARALLAXTEXTURE\n uniform sampler2D u_ParallaxTexture;\n uniform float u_parallaxScale;\n#endif\n#ifdef OCCLUSIONTEXTURE\n uniform sampler2D u_OcclusionTexture;\n uniform float u_occlusionStrength;\n#endif\n#ifdef EMISSION\n #ifdef EMISSIONTEXTURE\n uniform sampler2D u_EmissionTexture;\n #endif\n uniform vec4 u_EmissionColor;\n#endif\n#ifdef REFLECTMAP\n uniform samplerCube u_ReflectTexture;\n uniform float u_ReflectIntensity;\n#endif\n\nuniform float u_AlphaTestValue;\nuniform float u_metallic;\nuniform float u_smoothness;\nuniform float u_smoothnessScale;\n\nuniform sampler2D u_RangeTexture;\n//uniform sampler2D u_AngleTexture;\nuniform mat4 u_PointLightMatrix;\n//uniform mat4 u_SpotLightMatrix;\n\n#include \"PBRSpecularLighting.glsl\"\n#include \"ShadowHelper.glsl\"\n\nvarying float v_posViewZ;\n#ifdef RECEIVESHADOW\n #if defined(SHADOWMAP_PSSM2)||defined(SHADOWMAP_PSSM3)\n uniform mat4 u_lightShadowVP[4];\n #endif\n #ifdef SHADOWMAP_PSSM1 \n varying vec4 v_lightMVPPos;\n #endif\n#endif\n\n#ifdef DIRECTIONLIGHT\n uniform DirectionLight u_DirectionLight;\n#endif\n#ifdef POINTLIGHT\n uniform PointLight u_PointLight;\n#endif\n#ifdef SPOTLIGHT\n uniform SpotLight u_SpotLight;\n#endif\n\n#ifdef FOG\n uniform float u_FogStart;\n uniform float u_FogRange;\n uniform vec3 u_FogColor;\n#endif\n\nvoid main_castShadow()\n{\n gl_FragColor=packDepth(v_posViewZ);\n #if defined(DIFFUSEMAP)&&defined(ALPHATEST)\n float alpha = texture2D(u_AlbedoTexture,v_Texcoord0).w;\n if( alpha < u_AlphaTestValue )\n {\n discard;\n }\n #endif\n}\n\nvoid main_normal()\n{ \n vec3 viewDir = normalize(v_ViewDir);\n \n vec2 uv0 = ParallaxOffset(viewDir);\n \n vec4 sg;\n vec4 albedoColor;\n #ifdef ALBEDOTEXTURE\n vec4 albedoTextureColor = texture2D(u_AlbedoTexture, uv0);\n albedoColor = albedoTextureColor * u_AlbedoColor;\n sg = SpecularGloss(albedoTextureColor.a, uv0);\n #else\n albedoColor = u_AlbedoColor;\n sg = SpecularGloss(1.0, uv0);\n #endif\n \n #ifdef ALPHATEST\n if(albedoColor.a < u_AlphaTestValue)\n discard;\n #endif\n \n vec3 normal = UnpackScaleNormal(uv0);\n \n LayaGI gi;\n gi.diffuse = u_AmbientColor * Occlusion(uv0).rgb;\n gi.specular = ReflectCubeMap(viewDir, normal);\n \n //float a = (sg.r+sg.g+sg.b) / 3.0;\n \n vec4 color = vec4(0.0);\n \n #ifdef DIRECTIONLIGHT\n color += PBRSpecularDiectionLight(albedoColor, sg.rgb, sg.a, normal, viewDir, u_DirectionLight, gi);\n #endif\n \n #ifdef POINTLIGHT\n color.a = 0.0;\n color += PBRSpecularPointLight(albedoColor, sg.rgb, sg.a, normal, viewDir, u_PointLight, v_PositionWorld, gi);\n #endif\n \n #ifdef SPOTLIGHT\n color.a = 0.0;\n color += PBRSpecularSpotLight(albedoColor, sg.rgb, sg.a, normal, viewDir, u_SpotLight, v_PositionWorld, gi);\n #endif\n \n #ifdef EMISSION\n vec4 emissionColor = u_EmissionColor;\n #ifdef EMISSIONTEXTURE\n emissionColor *= texture2D(u_EmissionTexture, uv0);\n #endif\n color.rgb += emissionColor.rgb;\n #endif\n \n #ifdef RECEIVESHADOW\n float shadowValue = 1.0;\n #ifdef SHADOWMAP_PSSM3\n shadowValue = getShadowPSSM3( u_shadowMap1,u_shadowMap2,u_shadowMap3,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n #endif\n #ifdef SHADOWMAP_PSSM2\n shadowValue = getShadowPSSM2( u_shadowMap1,u_shadowMap2,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n #endif \n #ifdef SHADOWMAP_PSSM1\n shadowValue = getShadowPSSM1( u_shadowMap1,v_lightMVPPos,u_shadowPSSMDistance,u_shadowPCFoffset,v_posViewZ,0.001);\n #endif\n gl_FragColor = vec4(color.rgb * shadowValue, color.a);\n #else\n gl_FragColor = color;\n #endif\n \n #ifdef FOG\n float lerpFact = clamp((1.0 / gl_FragCoord.w - u_FogStart) / u_FogRange, 0.0, 1.0);\n gl_FragColor.rgb = mix(gl_FragColor.rgb, u_FogColor, lerpFact);\n #endif\n}\n\nvoid main()\n{\n #ifdef CASTSHADOW \n main_castShadow();\n #else\n main_normal();\n #endif \n}\n\n";
  8849. shader=Shader3D.add("PBRSpecular",true);
  8850. subShader=new SubShader(attributeMap,uniformMap,SkinnedMeshSprite3D.shaderDefines,PBRSpecularMaterial.shaderDefines);
  8851. shader.addSubShader(subShader);
  8852. subShader.addShaderPass(vs,ps,stateMap);
  8853. attributeMap={
  8854. 'a_Position':/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0,
  8855. 'a_Color':/*laya.d3.graphics.Vertex.VertexMesh.MESH_COLOR0*/1,
  8856. 'a_Texcoord0':/*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE0*/2,
  8857. 'a_BoneWeights':/*laya.d3.graphics.Vertex.VertexMesh.MESH_BLENDWEIGHT0*/6,
  8858. 'a_BoneIndices':/*laya.d3.graphics.Vertex.VertexMesh.MESH_BLENDINDICES0*/5,
  8859. 'a_MvpMatrix':/*laya.d3.graphics.Vertex.VertexMesh.MESH_MVPMATRIX_ROW0*/12
  8860. };
  8861. uniformMap={
  8862. 'u_Bones':/*laya.d3.shader.Shader3D.PERIOD_CUSTOM*/0,
  8863. 'u_AlbedoTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8864. 'u_AlbedoColor':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8865. 'u_TilingOffset':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8866. 'u_AlphaTestValue':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8867. 'u_MvpMatrix':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8868. 'u_FogStart':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8869. 'u_FogRange':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8870. 'u_FogColor':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4
  8871. };
  8872. stateMap={
  8873. 's_Cull':/*laya.d3.shader.Shader3D.RENDER_STATE_CULL*/0,
  8874. 's_Blend':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND*/1,
  8875. 's_BlendSrc':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_SRC*/2,
  8876. 's_BlendDst':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_DST*/3,
  8877. 's_DepthTest':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_TEST*/12,
  8878. 's_DepthWrite':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_WRITE*/13
  8879. }
  8880. vs="#include \"Lighting.glsl\";\n\nattribute vec4 a_Position;\n\nattribute vec2 a_Texcoord0;\n\n#ifdef GPU_INSTANCE\n attribute mat4 a_MvpMatrix;\n#else\n uniform mat4 u_MvpMatrix;\n#endif\n\nattribute vec4 a_Color;\nvarying vec4 v_Color;\nvarying vec2 v_Texcoord0;\n\n#ifdef TILINGOFFSET\n uniform vec4 u_TilingOffset;\n#endif\n\n#ifdef BONE\n const int c_MaxBoneCount = 24;\n attribute vec4 a_BoneIndices;\n attribute vec4 a_BoneWeights;\n uniform mat4 u_Bones[c_MaxBoneCount];\n#endif\n\nvoid main() {\n vec4 position;\n #ifdef BONE\n mat4 skinTransform = u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\n skinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\n skinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\n skinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\n position=skinTransform*a_Position;\n #else\n position=a_Position;\n #endif\n #ifdef GPU_INSTANCE\n gl_Position = a_MvpMatrix * position;\n #else\n gl_Position = u_MvpMatrix * position;\n #endif\n\n #ifdef TILINGOFFSET\n v_Texcoord0=TransformUV(a_Texcoord0,u_TilingOffset);\n #else\n v_Texcoord0=a_Texcoord0;\n #endif\n\n #if defined(COLOR)&&defined(ENABLEVERTEXCOLOR)\n v_Color = a_Color;\n #endif\n gl_Position=remapGLPositionZ(gl_Position);\n}";
  8881. ps="#ifdef FSHIGHPRECISION\n precision highp float;\n#else\n precision mediump float;\n#endif\n\n#if defined(COLOR)&&defined(ENABLEVERTEXCOLOR)\n varying vec4 v_Color;\n#endif\n\n#ifdef ALBEDOTEXTURE\n uniform sampler2D u_AlbedoTexture;\n varying vec2 v_Texcoord0;\n#endif\n\nuniform vec4 u_AlbedoColor;\n\n#ifdef ALPHATEST\n uniform float u_AlphaTestValue;\n#endif\n\n#ifdef FOG\n uniform float u_FogStart;\n uniform float u_FogRange;\n #ifdef ADDTIVEFOG\n #else\n uniform vec3 u_FogColor;\n #endif\n#endif\n\nvoid main()\n{\n vec4 color = u_AlbedoColor;\n #ifdef ALBEDOTEXTURE\n color *= texture2D(u_AlbedoTexture, v_Texcoord0);\n #endif\n #if defined(COLOR)&&defined(ENABLEVERTEXCOLOR)\n color *= v_Color;\n #endif\n \n #ifdef ALPHATEST\n if(color.a < u_AlphaTestValue)\n discard;\n #endif\n \n gl_FragColor = color;\n \n #ifdef FOG\n float lerpFact = clamp((1.0 / gl_FragCoord.w - u_FogStart) / u_FogRange, 0.0, 1.0);\n #ifdef ADDTIVEFOG\n gl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(0.0), lerpFact);\n #else\n gl_FragColor.rgb = mix(gl_FragColor.rgb, u_FogColor, lerpFact);\n #endif\n #endif\n \n}\n\n";
  8882. shader=Shader3D.add("Unlit",true);
  8883. subShader=new SubShader(attributeMap,uniformMap,SkinnedMeshSprite3D.shaderDefines,UnlitMaterial.shaderDefines);
  8884. shader.addSubShader(subShader);
  8885. subShader.addShaderPass(vs,ps,stateMap);
  8886. attributeMap={
  8887. 'a_Position':/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0,
  8888. 'a_Texcoord0':/*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE0*/2,
  8889. 'a_BoneWeights':/*laya.d3.graphics.Vertex.VertexMesh.MESH_BLENDWEIGHT0*/6,
  8890. 'a_BoneIndices':/*laya.d3.graphics.Vertex.VertexMesh.MESH_BLENDINDICES0*/5,
  8891. 'a_MvpMatrix':/*laya.d3.graphics.Vertex.VertexMesh.MESH_MVPMATRIX_ROW0*/12
  8892. };
  8893. uniformMap={
  8894. 'u_Bones':/*laya.d3.shader.Shader3D.PERIOD_CUSTOM*/0,
  8895. 'u_AlbedoTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8896. 'u_AlbedoColor':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8897. 'u_TilingOffset':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8898. 'u_AlphaTestValue':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8899. 'u_MvpMatrix':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8900. 'u_FogStart':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8901. 'u_FogRange':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8902. 'u_FogColor':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4
  8903. };
  8904. stateMap={
  8905. 's_Cull':/*laya.d3.shader.Shader3D.RENDER_STATE_CULL*/0,
  8906. 's_Blend':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND*/1,
  8907. 's_BlendSrc':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_SRC*/2,
  8908. 's_BlendDst':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_DST*/3,
  8909. 's_DepthTest':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_TEST*/12,
  8910. 's_DepthWrite':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_WRITE*/13
  8911. }
  8912. vs="#include \"Lighting.glsl\";\n\nattribute vec4 a_Position;\nattribute vec4 a_Color;\nattribute vec2 a_Texcoord0;\n\n#ifdef GPU_INSTANCE\n attribute mat4 a_MvpMatrix;\n#else\n uniform mat4 u_MvpMatrix;\n#endif\n\nvarying vec4 v_Color;\nvarying vec2 v_Texcoord0;\n\n#ifdef TILINGOFFSET\n uniform vec4 u_TilingOffset;\n#endif\n\n#ifdef BONE\n const int c_MaxBoneCount = 24;\n attribute vec4 a_BoneIndices;\n attribute vec4 a_BoneWeights;\n uniform mat4 u_Bones[c_MaxBoneCount];\n#endif\n\nvoid main()\n{\n vec4 position;\n #ifdef BONE\n mat4 skinTransform = u_Bones[int(a_BoneIndices.x)] * a_BoneWeights.x;\n skinTransform += u_Bones[int(a_BoneIndices.y)] * a_BoneWeights.y;\n skinTransform += u_Bones[int(a_BoneIndices.z)] * a_BoneWeights.z;\n skinTransform += u_Bones[int(a_BoneIndices.w)] * a_BoneWeights.w;\n position=skinTransform*a_Position;\n #else\n position=a_Position;\n #endif\n #ifdef GPU_INSTANCE\n gl_Position = a_MvpMatrix * position;\n #else\n gl_Position = u_MvpMatrix * position;\n #endif\n \n #ifdef TILINGOFFSET\n v_Texcoord0=TransformUV(a_Texcoord0,u_TilingOffset);\n #else\n v_Texcoord0=a_Texcoord0;\n #endif\n \n v_Color = a_Color;\n gl_Position=remapGLPositionZ(gl_Position);\n}";
  8913. ps="#ifdef FSHIGHPRECISION\n precision highp float;\n#else\n precision mediump float;\n#endif\n\n#ifdef COLOR\n varying vec4 v_Color;\n#endif\nvarying vec2 v_Texcoord0;\n\n#ifdef MAINTEXTURE\n uniform sampler2D u_AlbedoTexture;\n#endif\n\nuniform vec4 u_AlbedoColor;\n\n#ifdef FOG\n uniform float u_FogStart;\n uniform float u_FogRange;\n #ifdef ADDTIVEFOG\n #else\n uniform vec3 u_FogColor;\n #endif\n#endif\n\nvoid main()\n{\n vec4 color = 2.0 * u_AlbedoColor;\n #ifdef COLOR\n color *= v_Color;\n #endif\n #ifdef MAINTEXTURE\n color *= texture2D(u_AlbedoTexture, v_Texcoord0);\n #endif\n \n gl_FragColor = color;\n \n #ifdef FOG\n float lerpFact = clamp((1.0 / gl_FragCoord.w - u_FogStart) / u_FogRange, 0.0, 1.0);\n #ifdef ADDTIVEFOG\n gl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(0.0), lerpFact);\n #else\n gl_FragColor.rgb = mix(gl_FragColor.rgb, u_FogColor, lerpFact);\n #endif\n #endif\n}\n\n";
  8914. shader=Shader3D.add("Effect",true);
  8915. subShader=new SubShader(attributeMap,uniformMap,SkinnedMeshSprite3D.shaderDefines,EffectMaterial.shaderDefines);
  8916. shader.addSubShader(subShader);
  8917. subShader.addShaderPass(vs,ps,stateMap);
  8918. attributeMap={
  8919. 'a_CornerTextureCoordinate':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_CORNERTEXTURECOORDINATE0*/0,
  8920. 'a_MeshPosition':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_POSITION0*/1,
  8921. 'a_MeshColor':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_COLOR0*/2,
  8922. 'a_MeshTextureCoordinate':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_TEXTURECOORDINATE0*/3,
  8923. 'a_ShapePositionStartLifeTime':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_SHAPEPOSITIONSTARTLIFETIME*/4,
  8924. 'a_DirectionTime':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_DIRECTIONTIME*/5,
  8925. 'a_StartColor':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_STARTCOLOR0*/6,
  8926. 'a_EndColor':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_ENDCOLOR0*/7,
  8927. 'a_StartSize':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_STARTSIZE*/8,
  8928. 'a_StartRotation0':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_STARTROTATION*/9,
  8929. 'a_StartSpeed':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_STARTSPEED*/10,
  8930. 'a_Random0':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_RANDOM0*/11,
  8931. 'a_Random1':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_RANDOM1*/12,
  8932. 'a_SimulationWorldPostion':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_SIMULATIONWORLDPOSTION*/13,
  8933. 'a_SimulationWorldRotation':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_SIMULATIONWORLDROTATION*/14};
  8934. uniformMap={
  8935. 'u_Tintcolor':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8936. 'u_TilingOffset':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8937. 'u_texture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  8938. 'u_WorldPosition':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8939. 'u_WorldRotation':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8940. 'u_PositionScale':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8941. 'u_SizeScale':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8942. 'u_ScalingMode':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8943. 'u_Gravity':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8944. 'u_ThreeDStartRotation':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8945. 'u_StretchedBillboardLengthScale':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8946. 'u_StretchedBillboardSpeedScale':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8947. 'u_SimulationSpace':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8948. 'u_CurrentTime':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8949. 'u_ColorOverLifeGradientAlphas':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8950. 'u_ColorOverLifeGradientColors':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8951. 'u_MaxColorOverLifeGradientAlphas':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8952. 'u_MaxColorOverLifeGradientColors':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8953. 'u_VOLVelocityConst':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8954. 'u_VOLVelocityGradientX':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8955. 'u_VOLVelocityGradientY':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8956. 'u_VOLVelocityGradientZ':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8957. 'u_VOLVelocityConstMax':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8958. 'u_VOLVelocityGradientMaxX':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8959. 'u_VOLVelocityGradientMaxY':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8960. 'u_VOLVelocityGradientMaxZ':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8961. 'u_VOLSpaceType':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8962. 'u_SOLSizeGradient':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8963. 'u_SOLSizeGradientX':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8964. 'u_SOLSizeGradientY':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8965. 'u_SOLSizeGradientZ':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8966. 'u_SOLSizeGradientMax':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8967. 'u_SOLSizeGradientMaxX':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8968. 'u_SOLSizeGradientMaxY':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8969. 'u_SOLSizeGradientMaxZ':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8970. 'u_ROLAngularVelocityConst':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8971. 'u_ROLAngularVelocityConstSeprarate':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8972. 'u_ROLAngularVelocityGradient':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8973. 'u_ROLAngularVelocityGradientX':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8974. 'u_ROLAngularVelocityGradientY':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8975. 'u_ROLAngularVelocityGradientZ':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8976. 'u_ROLAngularVelocityConstMax':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8977. 'u_ROLAngularVelocityConstMaxSeprarate':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8978. 'u_ROLAngularVelocityGradientMax':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8979. 'u_ROLAngularVelocityGradientMaxX':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8980. 'u_ROLAngularVelocityGradientMaxY':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8981. 'u_ROLAngularVelocityGradientMaxZ':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8982. 'u_ROLAngularVelocityGradientMaxW':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8983. 'u_TSACycles':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8984. 'u_TSASubUVLength':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8985. 'u_TSAGradientUVs':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8986. 'u_TSAMaxGradientUVs':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  8987. 'u_CameraPos':/*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3,
  8988. 'u_CameraDirection':/*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3,
  8989. 'u_CameraUp':/*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3,
  8990. 'u_View':/*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3,
  8991. 'u_Projection':/*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3,
  8992. 'u_FogStart':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8993. 'u_FogRange':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  8994. 'u_FogColor':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4
  8995. };
  8996. stateMap={
  8997. 's_Cull':/*laya.d3.shader.Shader3D.RENDER_STATE_CULL*/0,
  8998. 's_Blend':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND*/1,
  8999. 's_BlendSrc':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_SRC*/2,
  9000. 's_BlendDst':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_DST*/3,
  9001. 's_DepthTest':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_TEST*/12,
  9002. 's_DepthWrite':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_WRITE*/13
  9003. };
  9004. vs="#include \"Lighting.glsl\";\n\n#ifdef HIGHPRECISION\n precision highp float;\n#else\n precision mediump float;\n#endif\n\n#if defined(SPHERHBILLBOARD)||defined(STRETCHEDBILLBOARD)||defined(HORIZONTALBILLBOARD)||defined(VERTICALBILLBOARD)\n attribute vec4 a_CornerTextureCoordinate;\n#endif\n#ifdef RENDERMODE_MESH\n attribute vec3 a_MeshPosition;\n attribute vec4 a_MeshColor;\n attribute vec2 a_MeshTextureCoordinate;\n varying vec4 v_MeshColor;\n#endif\n\nattribute vec4 a_ShapePositionStartLifeTime;\nattribute vec4 a_DirectionTime;\nattribute vec4 a_StartColor;\nattribute vec3 a_StartSize;\nattribute vec3 a_StartRotation0;\nattribute float a_StartSpeed;\n#if defined(COLOROVERLIFETIME)||defined(RANDOMCOLOROVERLIFETIME)||defined(SIZEOVERLIFETIMERANDOMCURVES)||defined(SIZEOVERLIFETIMERANDOMCURVESSEPERATE)||defined(ROTATIONOVERLIFETIMERANDOMCONSTANTS)||defined(ROTATIONOVERLIFETIMERANDOMCURVES)\n attribute vec4 a_Random0;\n#endif\n#if defined(TEXTURESHEETANIMATIONRANDOMCURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\n attribute vec4 a_Random1;\n#endif\nattribute vec3 a_SimulationWorldPostion;\nattribute vec4 a_SimulationWorldRotation;\n\nvarying float v_Discard;\nvarying vec4 v_Color;\n#ifdef DIFFUSEMAP\n varying vec2 v_TextureCoordinate;\n#endif\n\nuniform float u_CurrentTime;\nuniform vec3 u_Gravity;\n\nuniform vec3 u_WorldPosition;\nuniform vec4 u_WorldRotation;\nuniform bool u_ThreeDStartRotation;\nuniform int u_ScalingMode;\nuniform vec3 u_PositionScale;\nuniform vec3 u_SizeScale;\nuniform mat4 u_View;\nuniform mat4 u_Projection;\n\n#ifdef STRETCHEDBILLBOARD\n uniform vec3 u_CameraPosition;\n#endif\nuniform vec3 u_CameraDirection;//TODO:只有几种广告牌模式需要用\nuniform vec3 u_CameraUp;\n\nuniform float u_StretchedBillboardLengthScale;\nuniform float u_StretchedBillboardSpeedScale;\nuniform int u_SimulationSpace;\n\n#if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\n uniform int u_VOLSpaceType;\n#endif\n#if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)\n uniform vec3 u_VOLVelocityConst;\n#endif\n#if defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\n uniform vec2 u_VOLVelocityGradientX[4];//x为key,y为速度\n uniform vec2 u_VOLVelocityGradientY[4];//x为key,y为速度\n uniform vec2 u_VOLVelocityGradientZ[4];//x为key,y为速度\n#endif\n#ifdef VELOCITYOVERLIFETIMERANDOMCONSTANT\n uniform vec3 u_VOLVelocityConstMax;\n#endif\n#ifdef VELOCITYOVERLIFETIMERANDOMCURVE\n uniform vec2 u_VOLVelocityGradientMaxX[4];//x为key,y为速度\n uniform vec2 u_VOLVelocityGradientMaxY[4];//x为key,y为速度\n uniform vec2 u_VOLVelocityGradientMaxZ[4];//x为key,y为速度\n#endif\n\n#ifdef COLOROVERLIFETIME\n uniform vec4 u_ColorOverLifeGradientColors[4];//x为key,yzw为Color\n uniform vec2 u_ColorOverLifeGradientAlphas[4];//x为key,y为Alpha\n#endif\n#ifdef RANDOMCOLOROVERLIFETIME\n uniform vec4 u_ColorOverLifeGradientColors[4];//x为key,yzw为Color\n uniform vec2 u_ColorOverLifeGradientAlphas[4];//x为key,y为Alpha\n uniform vec4 u_MaxColorOverLifeGradientColors[4];//x为key,yzw为Color\n uniform vec2 u_MaxColorOverLifeGradientAlphas[4];//x为key,y为Alpha\n#endif\n\n\n#if defined(SIZEOVERLIFETIMECURVE)||defined(SIZEOVERLIFETIMERANDOMCURVES)\n uniform vec2 u_SOLSizeGradient[4];//x为key,y为尺寸\n#endif\n#ifdef SIZEOVERLIFETIMERANDOMCURVES\n uniform vec2 u_SOLSizeGradientMax[4];//x为key,y为尺寸\n#endif\n#if defined(SIZEOVERLIFETIMECURVESEPERATE)||defined(SIZEOVERLIFETIMERANDOMCURVESSEPERATE)\n uniform vec2 u_SOLSizeGradientX[4];//x为key,y为尺寸\n uniform vec2 u_SOLSizeGradientY[4];//x为key,y为尺寸\n uniform vec2 u_SOLSizeGradientZ[4];//x为key,y为尺寸\n#endif\n#ifdef SIZEOVERLIFETIMERANDOMCURVESSEPERATE\n uniform vec2 u_SOLSizeGradientMaxX[4];//x为key,y为尺寸\n uniform vec2 u_SOLSizeGradientMaxY[4];//x为key,y为尺寸\n uniform vec2 u_SOLSizeGradientMaxZ[4];//x为key,y为尺寸\n#endif\n\n\n#ifdef ROTATIONOVERLIFETIME\n #if defined(ROTATIONOVERLIFETIMECONSTANT)||defined(ROTATIONOVERLIFETIMERANDOMCONSTANTS)\n uniform float u_ROLAngularVelocityConst;\n #endif\n #ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\n uniform float u_ROLAngularVelocityConstMax;\n #endif\n #if defined(ROTATIONOVERLIFETIMECURVE)||defined(ROTATIONOVERLIFETIMERANDOMCURVES)\n uniform vec2 u_ROLAngularVelocityGradient[4];//x为key,y为旋转\n #endif\n #ifdef ROTATIONOVERLIFETIMERANDOMCURVES\n uniform vec2 u_ROLAngularVelocityGradientMax[4];//x为key,y为旋转\n #endif\n#endif\n#ifdef ROTATIONOVERLIFETIMESEPERATE\n #if defined(ROTATIONOVERLIFETIMECONSTANT)||defined(ROTATIONOVERLIFETIMERANDOMCONSTANTS)\n uniform vec3 u_ROLAngularVelocityConstSeprarate;\n #endif\n #ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\n uniform vec3 u_ROLAngularVelocityConstMaxSeprarate;\n #endif\n #if defined(ROTATIONOVERLIFETIMECURVE)||defined(ROTATIONOVERLIFETIMERANDOMCURVES)\n uniform vec2 u_ROLAngularVelocityGradientX[4];\n uniform vec2 u_ROLAngularVelocityGradientY[4];\n uniform vec2 u_ROLAngularVelocityGradientZ[4];\n #endif\n #ifdef ROTATIONOVERLIFETIMERANDOMCURVES\n uniform vec2 u_ROLAngularVelocityGradientMaxX[4];\n uniform vec2 u_ROLAngularVelocityGradientMaxY[4];\n uniform vec2 u_ROLAngularVelocityGradientMaxZ[4];\n uniform vec2 u_ROLAngularVelocityGradientMaxW[4];\n #endif\n#endif\n\n#if defined(TEXTURESHEETANIMATIONCURVE)||defined(TEXTURESHEETANIMATIONRANDOMCURVE)\n uniform float u_TSACycles;\n uniform vec2 u_TSASubUVLength;\n uniform vec2 u_TSAGradientUVs[4];//x为key,y为frame\n#endif\n#ifdef TEXTURESHEETANIMATIONRANDOMCURVE\n uniform vec2 u_TSAMaxGradientUVs[4];//x为key,y为frame\n#endif\n\n#ifdef FOG\n varying vec3 v_PositionWorld;\n#endif\n\n#ifdef TILINGOFFSET\n uniform vec4 u_TilingOffset;\n#endif\n\nvec3 rotationByEuler(in vec3 vector,in vec3 rot)\n{\n float halfRoll = rot.z * 0.5;\n float halfPitch = rot.x * 0.5;\n float halfYaw = rot.y * 0.5;\n\n float sinRoll = sin(halfRoll);\n float cosRoll = cos(halfRoll);\n float sinPitch = sin(halfPitch);\n float cosPitch = cos(halfPitch);\n float sinYaw = sin(halfYaw);\n float cosYaw = cos(halfYaw);\n\n float quaX = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);\n float quaY = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);\n float quaZ = (cosYaw * cosPitch * sinRoll) - (sinYaw * sinPitch * cosRoll);\n float quaW = (cosYaw * cosPitch * cosRoll) + (sinYaw * sinPitch * sinRoll);\n \n //vec4 q=vec4(quaX,quaY,quaZ,quaW);\n //vec3 temp = cross(q.xyz, vector) + q.w * vector;\n //return (cross(temp, -q.xyz) + dot(q.xyz,vector) * q.xyz + q.w * temp);\n \n float x = quaX + quaX;\n float y = quaY + quaY;\n float z = quaZ + quaZ;\n float wx = quaW * x;\n float wy = quaW * y;\n float wz = quaW * z;\n float xx = quaX * x;\n float xy = quaX * y;\n float xz = quaX * z;\n float yy = quaY * y;\n float yz = quaY * z;\n float zz = quaZ * z;\n\n return vec3(((vector.x * ((1.0 - yy) - zz)) + (vector.y * (xy - wz))) + (vector.z * (xz + wy)),\n ((vector.x * (xy + wz)) + (vector.y * ((1.0 - xx) - zz))) + (vector.z * (yz - wx)),\n ((vector.x * (xz - wy)) + (vector.y * (yz + wx))) + (vector.z * ((1.0 - xx) - yy)));\n \n}\n\n//假定axis已经归一化\nvec3 rotationByAxis(in vec3 vector,in vec3 axis, in float angle)\n{\n float halfAngle = angle * 0.5;\n float sin = sin(halfAngle);\n \n float quaX = axis.x * sin;\n float quaY = axis.y * sin;\n float quaZ = axis.z * sin;\n float quaW = cos(halfAngle);\n \n //vec4 q=vec4(quaX,quaY,quaZ,quaW);\n //vec3 temp = cross(q.xyz, vector) + q.w * vector;\n //return (cross(temp, -q.xyz) + dot(q.xyz,vector) * q.xyz + q.w * temp);\n \n float x = quaX + quaX;\n float y = quaY + quaY;\n float z = quaZ + quaZ;\n float wx = quaW * x;\n float wy = quaW * y;\n float wz = quaW * z;\n float xx = quaX * x;\n float xy = quaX * y;\n float xz = quaX * z;\n float yy = quaY * y;\n float yz = quaY * z;\n float zz = quaZ * z;\n\n return vec3(((vector.x * ((1.0 - yy) - zz)) + (vector.y * (xy - wz))) + (vector.z * (xz + wy)),\n ((vector.x * (xy + wz)) + (vector.y * ((1.0 - xx) - zz))) + (vector.z * (yz - wx)),\n ((vector.x * (xz - wy)) + (vector.y * (yz + wx))) + (vector.z * ((1.0 - xx) - yy)));\n \n}\n\nvec3 rotationByQuaternions(in vec3 v,in vec4 q) \n{\n return v + 2.0 * cross(q.xyz, cross(q.xyz, v) + q.w * v);\n}\n\n \n#if defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)||defined(SIZEOVERLIFETIMECURVE)||defined(SIZEOVERLIFETIMECURVESEPERATE)||defined(SIZEOVERLIFETIMERANDOMCURVES)||defined(SIZEOVERLIFETIMERANDOMCURVESSEPERATE)\nfloat getCurValueFromGradientFloat(in vec2 gradientNumbers[4],in float normalizedAge)\n{\n float curValue;\n for(int i=1;i<4;i++)\n {\n vec2 gradientNumber=gradientNumbers[i];\n float key=gradientNumber.x;\n if(key>=normalizedAge)\n {\n vec2 lastGradientNumber=gradientNumbers[i-1];\n float lastKey=lastGradientNumber.x;\n float age=(normalizedAge-lastKey)/(key-lastKey);\n curValue=mix(lastGradientNumber.y,gradientNumber.y,age);\n break;\n }\n }\n return curValue;\n}\n#endif\n\n#if defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)||defined(ROTATIONOVERLIFETIMECURVE)||defined(ROTATIONOVERLIFETIMERANDOMCURVES)\nfloat getTotalValueFromGradientFloat(in vec2 gradientNumbers[4],in float normalizedAge)\n{\n float totalValue=0.0;\n for(int i=1;i<4;i++)\n {\n vec2 gradientNumber=gradientNumbers[i];\n float key=gradientNumber.x;\n vec2 lastGradientNumber=gradientNumbers[i-1];\n float lastValue=lastGradientNumber.y;\n \n if(key>=normalizedAge){\n float lastKey=lastGradientNumber.x;\n float age=(normalizedAge-lastKey)/(key-lastKey);\n totalValue+=(lastValue+mix(lastValue,gradientNumber.y,age))/2.0*a_ShapePositionStartLifeTime.w*(normalizedAge-lastKey);\n break;\n }\n else{\n totalValue+=(lastValue+gradientNumber.y)/2.0*a_ShapePositionStartLifeTime.w*(key-lastGradientNumber.x);\n }\n }\n return totalValue;\n}\n#endif\n\n#if defined(COLOROVERLIFETIME)||defined(RANDOMCOLOROVERLIFETIME)\nvec4 getColorFromGradient(in vec2 gradientAlphas[4],in vec4 gradientColors[4],in float normalizedAge)\n{\n vec4 overTimeColor;\n for(int i=1;i<4;i++)\n {\n vec2 gradientAlpha=gradientAlphas[i];\n float alphaKey=gradientAlpha.x;\n if(alphaKey>=normalizedAge)\n {\n vec2 lastGradientAlpha=gradientAlphas[i-1];\n float lastAlphaKey=lastGradientAlpha.x;\n float age=(normalizedAge-lastAlphaKey)/(alphaKey-lastAlphaKey);\n overTimeColor.a=mix(lastGradientAlpha.y,gradientAlpha.y,age);\n break;\n }\n }\n \n for(int i=1;i<4;i++)\n {\n vec4 gradientColor=gradientColors[i];\n float colorKey=gradientColor.x;\n if(colorKey>=normalizedAge)\n {\n vec4 lastGradientColor=gradientColors[i-1];\n float lastColorKey=lastGradientColor.x;\n float age=(normalizedAge-lastColorKey)/(colorKey-lastColorKey);\n overTimeColor.rgb=mix(gradientColors[i-1].yzw,gradientColor.yzw,age);\n break;\n }\n }\n return overTimeColor;\n}\n#endif\n\n\n#if defined(TEXTURESHEETANIMATIONCURVE)||defined(TEXTURESHEETANIMATIONRANDOMCURVE)\nfloat getFrameFromGradient(in vec2 gradientFrames[4],in float normalizedAge)\n{\n float overTimeFrame;\n for(int i=1;i<4;i++)\n {\n vec2 gradientFrame=gradientFrames[i];\n float key=gradientFrame.x;\n if(key>=normalizedAge)\n {\n vec2 lastGradientFrame=gradientFrames[i-1];\n float lastKey=lastGradientFrame.x;\n float age=(normalizedAge-lastKey)/(key-lastKey);\n overTimeFrame=mix(lastGradientFrame.y,gradientFrame.y,age);\n break;\n }\n }\n return floor(overTimeFrame);\n}\n#endif\n\n#if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\nvec3 computeParticleLifeVelocity(in float normalizedAge)\n{\n vec3 outLifeVelocity;\n #ifdef VELOCITYOVERLIFETIMECONSTANT\n outLifeVelocity=u_VOLVelocityConst; \n #endif\n #ifdef VELOCITYOVERLIFETIMECURVE\n outLifeVelocity= vec3(getCurValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge));\n #endif\n #ifdef VELOCITYOVERLIFETIMERANDOMCONSTANT\n outLifeVelocity=mix(u_VOLVelocityConst,u_VOLVelocityConstMax,vec3(a_Random1.y,a_Random1.z,a_Random1.w)); \n #endif\n #ifdef VELOCITYOVERLIFETIMERANDOMCURVE\n outLifeVelocity=vec3(mix(getCurValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxX,normalizedAge),a_Random1.y),\n mix(getCurValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxY,normalizedAge),a_Random1.z),\n mix(getCurValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge),getCurValueFromGradientFloat(u_VOLVelocityGradientMaxZ,normalizedAge),a_Random1.w));\n #endif\n \n return outLifeVelocity;\n} \n#endif\n\nvec3 computeParticlePosition(in vec3 startVelocity, in vec3 lifeVelocity,in float age,in float normalizedAge,vec3 gravityVelocity,vec4 worldRotation)\n{\n vec3 startPosition;\n vec3 lifePosition;\n #if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\n #ifdef VELOCITYOVERLIFETIMECONSTANT\n startPosition=startVelocity*age;\n lifePosition=lifeVelocity*age;\n #endif\n #ifdef VELOCITYOVERLIFETIMECURVE\n startPosition=startVelocity*age;\n lifePosition=vec3(getTotalValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge));\n #endif\n #ifdef VELOCITYOVERLIFETIMERANDOMCONSTANT\n startPosition=startVelocity*age;\n lifePosition=lifeVelocity*age;\n #endif\n #ifdef VELOCITYOVERLIFETIMERANDOMCURVE\n startPosition=startVelocity*age;\n lifePosition=vec3(mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxX,normalizedAge),a_Random1.y)\n ,mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxY,normalizedAge),a_Random1.z)\n ,mix(getTotalValueFromGradientFloat(u_VOLVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(u_VOLVelocityGradientMaxZ,normalizedAge),a_Random1.w));\n #endif\n \n vec3 finalPosition;\n if(u_VOLSpaceType==0){\n if(u_ScalingMode!=2)\n finalPosition =rotationByQuaternions(u_PositionScale*(a_ShapePositionStartLifeTime.xyz+startPosition+lifePosition),worldRotation);\n else\n finalPosition =rotationByQuaternions(u_PositionScale*a_ShapePositionStartLifeTime.xyz+startPosition+lifePosition,worldRotation);\n }\n else{\n if(u_ScalingMode!=2)\n finalPosition = rotationByQuaternions(u_PositionScale*(a_ShapePositionStartLifeTime.xyz+startPosition),worldRotation)+lifePosition;\n else\n finalPosition = rotationByQuaternions(u_PositionScale*a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation)+lifePosition;\n }\n #else\n startPosition=startVelocity*age;\n vec3 finalPosition;\n if(u_ScalingMode!=2)\n finalPosition = rotationByQuaternions(u_PositionScale*(a_ShapePositionStartLifeTime.xyz+startPosition),worldRotation);\n else\n finalPosition = rotationByQuaternions(u_PositionScale*a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation);\n #endif\n \n if(u_SimulationSpace==0)\n finalPosition=finalPosition+a_SimulationWorldPostion;\n else if(u_SimulationSpace==1) \n finalPosition=finalPosition+u_WorldPosition;\n \n finalPosition+=0.5*gravityVelocity*age;\n \n return finalPosition;\n}\n\n\nvec4 computeParticleColor(in vec4 color,in float normalizedAge)\n{\n #ifdef COLOROVERLIFETIME\n color*=getColorFromGradient(u_ColorOverLifeGradientAlphas,u_ColorOverLifeGradientColors,normalizedAge);\n #endif\n \n #ifdef RANDOMCOLOROVERLIFETIME\n color*=mix(getColorFromGradient(u_ColorOverLifeGradientAlphas,u_ColorOverLifeGradientColors,normalizedAge),getColorFromGradient(u_MaxColorOverLifeGradientAlphas,u_MaxColorOverLifeGradientColors,normalizedAge),a_Random0.y);\n #endif\n\n return color;\n}\n\nvec2 computeParticleSizeBillbard(in vec2 size,in float normalizedAge)\n{\n #ifdef SIZEOVERLIFETIMECURVE\n size*=getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge);\n #endif\n #ifdef SIZEOVERLIFETIMERANDOMCURVES\n size*=mix(getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMax,normalizedAge),a_Random0.z); \n #endif\n #ifdef SIZEOVERLIFETIMECURVESEPERATE\n size*=vec2(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge));\n #endif\n #ifdef SIZEOVERLIFETIMERANDOMCURVESSEPERATE\n size*=vec2(mix(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxX,normalizedAge),a_Random0.z)\n ,mix(getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxY,normalizedAge),a_Random0.z));\n #endif\n return size;\n}\n\n#ifdef RENDERMODE_MESH\nvec3 computeParticleSizeMesh(in vec3 size,in float normalizedAge)\n{\n #ifdef SIZEOVERLIFETIMECURVE\n size*=getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge);\n #endif\n #ifdef SIZEOVERLIFETIMERANDOMCURVES\n size*=mix(getCurValueFromGradientFloat(u_SOLSizeGradient,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMax,normalizedAge),a_Random0.z); \n #endif\n #ifdef SIZEOVERLIFETIMECURVESEPERATE\n size*=vec3(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientZ,normalizedAge));\n #endif\n #ifdef SIZEOVERLIFETIMERANDOMCURVESSEPERATE\n size*=vec3(mix(getCurValueFromGradientFloat(u_SOLSizeGradientX,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxX,normalizedAge),a_Random0.z)\n ,mix(getCurValueFromGradientFloat(u_SOLSizeGradientY,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxY,normalizedAge),a_Random0.z)\n ,mix(getCurValueFromGradientFloat(u_SOLSizeGradientZ,normalizedAge),getCurValueFromGradientFloat(u_SOLSizeGradientMaxZ,normalizedAge),a_Random0.z));\n #endif\n return size;\n}\n#endif\n\nfloat computeParticleRotationFloat(in float rotation,in float age,in float normalizedAge)\n{ \n #ifdef ROTATIONOVERLIFETIME\n #ifdef ROTATIONOVERLIFETIMECONSTANT\n float ageRot=u_ROLAngularVelocityConst*age;\n rotation+=ageRot;\n #endif\n #ifdef ROTATIONOVERLIFETIMECURVE\n rotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge);\n #endif\n #ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\n float ageRot=mix(u_ROLAngularVelocityConst,u_ROLAngularVelocityConstMax,a_Random0.w)*age;\n rotation+=ageRot;\n #endif\n #ifdef ROTATIONOVERLIFETIMERANDOMCURVES\n rotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMax,normalizedAge),a_Random0.w);\n #endif\n #endif\n #ifdef ROTATIONOVERLIFETIMESEPERATE\n #ifdef ROTATIONOVERLIFETIMECONSTANT\n float ageRot=u_ROLAngularVelocityConstSeprarate.z*age;\n rotation+=ageRot;\n #endif\n #ifdef ROTATIONOVERLIFETIMECURVE\n rotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge);\n #endif\n #ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\n float ageRot=mix(u_ROLAngularVelocityConstSeprarate.z,u_ROLAngularVelocityConstMaxSeprarate.z,a_Random0.w)*age;\n rotation+=ageRot;\n #endif\n #ifdef ROTATIONOVERLIFETIMERANDOMCURVES\n rotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxZ,normalizedAge),a_Random0.w));\n #endif\n #endif\n return rotation;\n}\n\n#if defined(RENDERMODE_MESH)&&(defined(ROTATIONOVERLIFETIME)||defined(ROTATIONOVERLIFETIMESEPERATE))\nvec3 computeParticleRotationVec3(in vec3 rotation,in float age,in float normalizedAge)\n{ \n #ifdef ROTATIONOVERLIFETIME\n #ifdef ROTATIONOVERLIFETIMECONSTANT\n float ageRot=u_ROLAngularVelocityConst*age;\n rotation+=ageRot;\n #endif\n #ifdef ROTATIONOVERLIFETIMECURVE\n rotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge);\n #endif\n #ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\n float ageRot=mix(u_ROLAngularVelocityConst,u_ROLAngularVelocityConstMax,a_Random0.w)*age;\n rotation+=ageRot;\n #endif\n #ifdef ROTATIONOVERLIFETIMERANDOMCURVES\n rotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMax,normalizedAge),a_Random0.w);\n #endif\n #endif\n #ifdef ROTATIONOVERLIFETIMESEPERATE\n #ifdef ROTATIONOVERLIFETIMECONSTANT\n vec3 ageRot=u_ROLAngularVelocityConstSeprarate*age;\n rotation+=ageRot;\n #endif\n #ifdef ROTATIONOVERLIFETIMECURVE\n rotation+=vec3(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge));\n #endif\n #ifdef ROTATIONOVERLIFETIMERANDOMCONSTANTS\n vec3 ageRot=mix(u_ROLAngularVelocityConstSeprarate,u_ROLAngularVelocityConstMaxSeprarate,a_Random0.w)*age;\n rotation+=ageRot;\n #endif\n #ifdef ROTATIONOVERLIFETIMERANDOMCURVES\n rotation+=vec3(mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxX,normalizedAge),a_Random0.w)\n ,mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxY,normalizedAge),a_Random0.w)\n ,mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMaxZ,normalizedAge),a_Random0.w));\n #endif\n #endif\n return rotation;\n}\n#endif\n\nvec2 computeParticleUV(in vec2 uv,in float normalizedAge)\n{ \n #ifdef TEXTURESHEETANIMATIONCURVE\n float cycleNormalizedAge=normalizedAge*u_TSACycles;\n float frame=getFrameFromGradient(u_TSAGradientUVs,cycleNormalizedAge-floor(cycleNormalizedAge));\n float totalULength=frame*u_TSASubUVLength.x;\n float floorTotalULength=floor(totalULength);\n uv.x+=totalULength-floorTotalULength;\n uv.y+=floorTotalULength*u_TSASubUVLength.y;\n #endif\n #ifdef TEXTURESHEETANIMATIONRANDOMCURVE\n float cycleNormalizedAge=normalizedAge*u_TSACycles;\n float uvNormalizedAge=cycleNormalizedAge-floor(cycleNormalizedAge);\n float frame=floor(mix(getFrameFromGradient(u_TSAGradientUVs,uvNormalizedAge),getFrameFromGradient(u_TSAMaxGradientUVs,uvNormalizedAge),a_Random1.x));\n float totalULength=frame*u_TSASubUVLength.x;\n float floorTotalULength=floor(totalULength);\n uv.x+=totalULength-floorTotalULength;\n uv.y+=floorTotalULength*u_TSASubUVLength.y;\n #endif\n return uv;\n}\n\nvoid main()\n{\n float age = u_CurrentTime - a_DirectionTime.w;\n float normalizedAge = age/a_ShapePositionStartLifeTime.w;\n vec3 lifeVelocity;\n if(normalizedAge<1.0){ \n vec3 startVelocity=a_DirectionTime.xyz*a_StartSpeed;\n #if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\n lifeVelocity= computeParticleLifeVelocity(normalizedAge);//计算粒子生命周期速度\n #endif \n vec3 gravityVelocity=u_Gravity*age;\n \n vec4 worldRotation;\n if(u_SimulationSpace==0)\n worldRotation=a_SimulationWorldRotation;\n else\n worldRotation=u_WorldRotation;\n \n vec3 center=computeParticlePosition(startVelocity, lifeVelocity, age, normalizedAge,gravityVelocity,worldRotation);//计算粒子位置\n \n \n #ifdef SPHERHBILLBOARD\n vec2 corner=a_CornerTextureCoordinate.xy;//Billboard模式z轴无效\n vec3 cameraUpVector =normalize(u_CameraUp);//TODO:是否外面归一化\n vec3 sideVector = normalize(cross(u_CameraDirection,cameraUpVector));\n vec3 upVector = normalize(cross(sideVector,u_CameraDirection));\n corner*=computeParticleSizeBillbard(a_StartSize.xy,normalizedAge);\n #if defined(ROTATIONOVERLIFETIME)||defined(ROTATIONOVERLIFETIMESEPERATE)\n if(u_ThreeDStartRotation){\n vec3 rotation=vec3(a_StartRotation0.xy,computeParticleRotationFloat(a_StartRotation0.z,age,normalizedAge));\n center += u_SizeScale.xzy*rotationByEuler(corner.x*sideVector+corner.y*upVector,rotation);\n }\n else{\n float rot = computeParticleRotationFloat(a_StartRotation0.x, age,normalizedAge);\n float c = cos(rot);\n float s = sin(rot);\n mat2 rotation= mat2(c, -s, s, c);\n corner=rotation*corner;\n center += u_SizeScale.xzy*(corner.x*sideVector+corner.y*upVector);\n }\n #else\n if(u_ThreeDStartRotation){\n center += u_SizeScale.xzy*rotationByEuler(corner.x*sideVector+corner.y*upVector,a_StartRotation0);\n }\n else{\n float c = cos(a_StartRotation0.x);\n float s = sin(a_StartRotation0.x);\n mat2 rotation= mat2(c, -s, s, c);\n corner=rotation*corner;\n center += u_SizeScale.xzy*(corner.x*sideVector+corner.y*upVector);\n }\n #endif\n #endif\n \n #ifdef STRETCHEDBILLBOARD\n vec2 corner=a_CornerTextureCoordinate.xy;//Billboard模式z轴无效\n vec3 velocity;\n #if defined(VELOCITYOVERLIFETIMECONSTANT)||defined(VELOCITYOVERLIFETIMECURVE)||defined(VELOCITYOVERLIFETIMERANDOMCONSTANT)||defined(VELOCITYOVERLIFETIMERANDOMCURVE)\n if(u_VOLSpaceType==0)\n velocity=rotationByQuaternions(u_SizeScale*(startVelocity+lifeVelocity),worldRotation)+gravityVelocity;\n else\n velocity=rotationByQuaternions(u_SizeScale*startVelocity,worldRotation)+lifeVelocity+gravityVelocity;\n #else\n velocity= rotationByQuaternions(u_SizeScale*startVelocity,worldRotation)+gravityVelocity;\n #endif \n vec3 cameraUpVector = normalize(velocity);\n vec3 direction = normalize(center-u_CameraPosition);\n vec3 sideVector = normalize(cross(direction,normalize(velocity)));\n \n sideVector=u_SizeScale.xzy*sideVector;\n cameraUpVector=length(vec3(u_SizeScale.x,0.0,0.0))*cameraUpVector;\n \n vec2 size=computeParticleSizeBillbard(a_StartSize.xy,normalizedAge);\n \n const mat2 rotaionZHalfPI=mat2(0.0, -1.0, 1.0, 0.0);\n corner=rotaionZHalfPI*corner;\n corner.y=corner.y-abs(corner.y);\n \n float speed=length(velocity);//TODO:\n center +=sign(u_SizeScale.x)*(sign(u_StretchedBillboardLengthScale)*size.x*corner.x*sideVector+(speed*u_StretchedBillboardSpeedScale+size.y*u_StretchedBillboardLengthScale)*corner.y*cameraUpVector);\n #endif\n \n #ifdef HORIZONTALBILLBOARD\n vec2 corner=a_CornerTextureCoordinate.xy;//Billboard模式z轴无效\n const vec3 cameraUpVector=vec3(0.0,0.0,1.0);\n const vec3 sideVector = vec3(-1.0,0.0,0.0);\n \n float rot = computeParticleRotationFloat(a_StartRotation0.x, age,normalizedAge);\n float c = cos(rot);\n float s = sin(rot);\n mat2 rotation= mat2(c, -s, s, c);\n corner=rotation*corner*cos(0.78539816339744830961566084581988);//TODO:临时缩小cos45,不确定U3D原因\n corner*=computeParticleSizeBillbard(a_StartSize.xy,normalizedAge);\n center +=u_SizeScale.xzy*(corner.x*sideVector+ corner.y*cameraUpVector);\n #endif\n \n #ifdef VERTICALBILLBOARD\n vec2 corner=a_CornerTextureCoordinate.xy;//Billboard模式z轴无效\n const vec3 cameraUpVector =vec3(0.0,1.0,0.0);\n vec3 sideVector = normalize(cross(u_CameraDirection,cameraUpVector));\n \n float rot = computeParticleRotationFloat(a_StartRotation0.x, age,normalizedAge);\n float c = cos(rot);\n float s = sin(rot);\n mat2 rotation= mat2(c, -s, s, c);\n corner=rotation*corner*cos(0.78539816339744830961566084581988);//TODO:临时缩小cos45,不确定U3D原因\n corner*=computeParticleSizeBillbard(a_StartSize.xy,normalizedAge);\n center +=u_SizeScale.xzy*(corner.x*sideVector+ corner.y*cameraUpVector);\n #endif\n \n #ifdef RENDERMODE_MESH\n vec3 size=computeParticleSizeMesh(a_StartSize,normalizedAge);\n #if defined(ROTATIONOVERLIFETIME)||defined(ROTATIONOVERLIFETIMESEPERATE)\n if(u_ThreeDStartRotation){\n vec3 rotation=vec3(a_StartRotation0.xy,computeParticleRotationFloat(a_StartRotation0.z, age,normalizedAge));\n center+= rotationByQuaternions(u_SizeScale*rotationByEuler(a_MeshPosition*size,rotation),worldRotation);\n }\n else{\n #ifdef ROTATIONOVERLIFETIME\n float angle=computeParticleRotationFloat(a_StartRotation0.x, age,normalizedAge);\n if(a_ShapePositionStartLifeTime.x!=0.0||a_ShapePositionStartLifeTime.y!=0.0){\n center+= (rotationByQuaternions(rotationByAxis(u_SizeScale*a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),angle),worldRotation));//已验证\n }\n else{\n #ifdef SHAPE\n center+= u_SizeScale.xzy*(rotationByQuaternions(rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),angle),worldRotation));\n #else\n if(u_SimulationSpace==0)\n center+=rotationByAxis(u_SizeScale*a_MeshPosition*size,vec3(0.0,0.0,-1.0),angle);//已验证\n else if(u_SimulationSpace==1)\n center+=rotationByQuaternions(u_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,0.0,-1.0),angle),worldRotation);//已验证\n #endif\n }\n #endif\n #ifdef ROTATIONOVERLIFETIMESEPERATE\n //TODO:是否应合并if(u_ThreeDStartRotation)分支代码,待测试\n vec3 angle=computeParticleRotationVec3(vec3(0.0,0.0,-a_StartRotation0.x), age,normalizedAge);\n center+= (rotationByQuaternions(rotationByEuler(u_SizeScale*a_MeshPosition*size,vec3(angle.x,angle.y,angle.z)),worldRotation));//已验证\n #endif \n }\n #else\n if(u_ThreeDStartRotation){\n center+= rotationByQuaternions(u_SizeScale*rotationByEuler(a_MeshPosition*size,a_StartRotation0),worldRotation);//已验证\n }\n else{\n if(a_ShapePositionStartLifeTime.x!=0.0||a_ShapePositionStartLifeTime.y!=0.0){\n if(u_SimulationSpace==0)\n center+= rotationByAxis(u_SizeScale*a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),a_StartRotation0.x);\n else if(u_SimulationSpace==1)\n center+= (rotationByQuaternions(u_SizeScale*rotationByAxis(a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),a_StartRotation0.x),worldRotation));//已验证\n }\n else{\n #ifdef SHAPE\n if(u_SimulationSpace==0)\n center+= u_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),a_StartRotation0.x);\n else if(u_SimulationSpace==1)\n center+= rotationByQuaternions(u_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),a_StartRotation0.x),worldRotation); \n #else\n if(u_SimulationSpace==0)\n center+= rotationByAxis(u_SizeScale*a_MeshPosition*size,vec3(0.0,0.0,-1.0),a_StartRotation0.x);\n else if(u_SimulationSpace==1)\n center+= rotationByQuaternions(u_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,0.0,-1.0),a_StartRotation0.x),worldRotation);//已验证\n #endif\n }\n }\n #endif\n v_MeshColor=a_MeshColor;\n #endif\n \n gl_Position=u_Projection*u_View*vec4(center,1.0);\n v_Color = computeParticleColor(a_StartColor, normalizedAge);\n #ifdef DIFFUSEMAP\n #if defined(SPHERHBILLBOARD)||defined(STRETCHEDBILLBOARD)||defined(HORIZONTALBILLBOARD)||defined(VERTICALBILLBOARD)\n v_TextureCoordinate =computeParticleUV(a_CornerTextureCoordinate.zw, normalizedAge);\n #endif\n #ifdef RENDERMODE_MESH\n v_TextureCoordinate =computeParticleUV(a_MeshTextureCoordinate, normalizedAge);\n #endif\n \n #ifdef TILINGOFFSET\n v_TextureCoordinate=vec2(v_TextureCoordinate.x,1.0-v_TextureCoordinate.y)*u_TilingOffset.xy+vec2(u_TilingOffset.z,-u_TilingOffset.w);//需要特殊处理\n v_TextureCoordinate=vec2(v_TextureCoordinate.x,1.0-v_TextureCoordinate.y);//需要特殊处理\n #endif\n #endif\n v_Discard=0.0;\n \n #ifdef FOG\n v_PositionWorld=center;\n #endif\n }\n else\n {\n v_Discard=1.0;\n }\n gl_Position=remapGLPositionZ(gl_Position);\n}\n\n";
  9005. ps="#ifdef HIGHPRECISION\n precision highp float;\n#else\n precision mediump float;\n#endif\n\nvarying float v_Discard;\nvarying vec4 v_Color;\nvarying vec2 v_TextureCoordinate;\nuniform sampler2D u_texture;\nuniform vec4 u_Tintcolor;\n\n#ifdef RENDERMODE_MESH\n varying vec4 v_MeshColor;\n#endif\n\n#ifdef FOG\n varying vec3 v_PositionWorld;\n uniform vec3 u_CameraPosition;\n uniform float u_FogStart;\n uniform float u_FogRange;\n #ifdef ADDTIVEFOG\n #else\n uniform vec3 u_FogColor;\n #endif\n#endif\n\n\nvoid main()\n{ \n #ifdef RENDERMODE_MESH\n gl_FragColor=v_MeshColor;\n #else\n gl_FragColor=vec4(1.0); \n #endif\n \n #ifdef DIFFUSEMAP\n if(v_Discard!=0.0)\n discard;\n #ifdef TINTCOLOR\n gl_FragColor*=texture2D(u_texture,v_TextureCoordinate)*u_Tintcolor*2.0*v_Color;\n #else\n gl_FragColor*=texture2D(u_texture,v_TextureCoordinate)*v_Color;\n #endif\n #else\n #ifdef TINTCOLOR\n gl_FragColor*=u_Tintcolor*2.0*v_Color;\n #else\n gl_FragColor*=v_Color;\n #endif\n #endif\n \n #ifdef FOG\n vec3 toEye=u_CameraPosition-v_PositionWorld;\n float toEyeLength=length(toEye);\n toEye/=toEyeLength;\n \n float lerpFact=clamp((toEyeLength-u_FogStart)/u_FogRange,0.0,1.0);\n #ifdef ADDTIVEFOG\n gl_FragColor.rgb=mix(gl_FragColor.rgb,vec3(0.0,0.0,0.0),lerpFact);\n #else\n gl_FragColor.rgb=mix(gl_FragColor.rgb,u_FogColor,lerpFact);\n #endif\n #endif\n}";
  9006. shader=Shader3D.add("PARTICLESHURIKEN");
  9007. subShader=new SubShader(attributeMap,uniformMap,ShuriKenParticle3D.shaderDefines,ShurikenParticleMaterial.shaderDefines);
  9008. shader.addSubShader(subShader);
  9009. subShader.addShaderPass(vs,ps,stateMap);
  9010. attributeMap={
  9011. 'a_Position':/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0};
  9012. uniformMap={
  9013. 'u_TintColor':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9014. 'u_Exposure':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9015. 'u_Rotation':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9016. 'u_CubeTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9017. 'u_MvpMatrix':/*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3};
  9018. vs="#include \"Lighting.glsl\";\n\nattribute vec4 a_Position;\nuniform mat4 u_MvpMatrix;\nuniform float u_Rotation;\nvarying vec3 v_Texcoord;\n\n\nvec4 rotateAroundYInDegrees (vec4 vertex, float degrees)\n{\n float angle = degrees * 3.141593 / 180.0;\n float sina=sin(angle);\n float cosa=cos(angle);\n mat2 m = mat2(cosa, -sina, sina, cosa);\n return vec4(m*vertex.xz, vertex.yw).xzyw;\n}\n \nvoid main()\n{\n vec4 position=rotateAroundYInDegrees(a_Position,u_Rotation);\n gl_Position = (u_MvpMatrix*position).xyww;\n v_Texcoord=vec3(-a_Position.x,a_Position.yz);//转换坐标系\n gl_Position=remapGLPositionZ(gl_Position);\n}\n";
  9019. ps="#ifdef HIGHPRECISION\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nvarying vec3 v_Texcoord;\n\nuniform samplerCube u_CubeTexture;\nuniform float u_Exposure;\nuniform vec4 u_TintColor;\n\n\nvoid main()\n{ \n vec3 color=textureCube(u_CubeTexture, v_Texcoord).rgb*u_TintColor.rgb*u_Exposure*2.0;\n gl_FragColor=vec4(color,1.0);\n}\n\n";
  9020. shader=Shader3D.add("SkyBox");
  9021. subShader=new SubShader(attributeMap,uniformMap);
  9022. shader.addSubShader(subShader);
  9023. subShader.addShaderPass(vs,ps);
  9024. attributeMap={
  9025. 'a_Position':/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0};
  9026. uniformMap={
  9027. 'u_SunSize':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9028. 'u_SunSizeConvergence':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9029. 'u_AtmosphereThickness':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9030. 'u_SkyTint':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9031. 'u_GroundTint':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9032. 'u_Exposure':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9033. 'u_MvpMatrix':/*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3,
  9034. 'u_DirectionLight.Direction':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  9035. 'u_DirectionLight.Color':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4
  9036. };
  9037. vs="#ifdef HIGHPRECISION\n precision highp float;\n#else\n precision mediump float;\n#endif\n\n#include \"Lighting.glsl\";\n\n#define OUTER_RADIUS 1.025\n#define RAYLEIGH (mix(0.0, 0.0025, pow(u_AtmosphereThickness,2.5)))// Rayleigh constant Rayleigh为夜空光和极光亮度单位\n#define MIE 0.0010 // Mie constant 米氏散射\n#define SUN_BRIGHTNESS 20.0 // Sun brightness\n#define MAX_SCATTER 50.0 // Maximum scattering value, to prevent math overflows on Adrenos\n\nconst float SKY_GROUND_THRESHOLD = 0.02;\nconst float outerRadius = OUTER_RADIUS;\nconst float outerRadius2 = OUTER_RADIUS*OUTER_RADIUS;\nconst float innerRadius = 1.0;\nconst float innerRadius2 = 1.0;\nconst float cameraHeight = 0.0001;\n\nconst float HDSundiskIntensityFactor = 15.0;\nconst float simpleSundiskIntensityFactor = 27.0;\n\nconst float sunScale = 400.0 * SUN_BRIGHTNESS;\nconst float kmESun = MIE * SUN_BRIGHTNESS;\nconst float km4PI = MIE * 4.0 * 3.14159265;\nconst float scale = 1.0 / (OUTER_RADIUS - 1.0);\nconst float scaleDepth = 0.25;\nconst float scaleOverScaleDepth = (1.0 / (OUTER_RADIUS - 1.0)) / 0.25;\nconst float samples = 2.0; // THIS IS UNROLLED MANUALLY, DON'T TOUCH\n\n// RGB wavelengths .35 (.62=158), .43 (.68=174), .525 (.75=190)\nconst vec3 c_DefaultScatteringWavelength = vec3(0.65, 0.57, 0.475);//默认散射波长\nconst vec3 c_VariableRangeForScatteringWavelength = vec3(0.15, 0.15, 0.15);//散射播放的可变范围\n\nattribute vec4 a_Position;\n\nuniform mat4 u_MvpMatrix;\nuniform vec3 u_SkyTint;\nuniform vec3 u_GroundTint;\nuniform float u_Exposure;\nuniform float u_AtmosphereThickness;\nuniform DirectionLight u_DirectionLight;\n\nvarying vec3 v_GroundColor;\nvarying vec3 v_SkyColor;\n\n#ifdef SUN_HIGH_QUALITY\n varying vec3 v_Vertex;\n#elif defined(SUN_SIMPLE)\n varying vec3 v_RayDir;\n#else\n varying float v_SkyGroundFactor;\n#endif\n\n#if defined(SUN_HIGH_QUALITY)||defined(SUN_SIMPLE)\n varying vec3 v_SunColor;\n#endif\n\n// Calculates the Rayleigh phase function\nfloat getRayleighPhase(vec3 light, vec3 ray) \n{\n float eyeCos = dot(light, ray);\n return 0.75 + 0.75*eyeCos*eyeCos;\n}\n\nfloat scaleAngle(float inCos)\n{\n float x = 1.0 - inCos;\n return 0.25 * exp(-0.00287 + x*(0.459 + x*(3.83 + x*(-6.80 + x*5.25))));\n}\n\n\nvoid main () {\n gl_Position = (u_MvpMatrix*a_Position).xyww;\n\n vec3 skyTintInGammaSpace = u_SkyTint;//支持非GAMMA空间后要调整\n vec3 scatteringWavelength = mix(c_DefaultScatteringWavelength-c_VariableRangeForScatteringWavelength,c_DefaultScatteringWavelength+c_VariableRangeForScatteringWavelength,vec3(1.0) - skyTintInGammaSpace); // using Tint in sRGB+ gamma allows for more visually linear interpolation and to keep (0.5) at (128, gray in sRGB) point\n vec3 invWavelength = 1.0 / pow(scatteringWavelength, vec3(4.0));\n\n float krESun = RAYLEIGH * SUN_BRIGHTNESS;\n float kr4PI = RAYLEIGH * 4.0 * 3.14159265;\n\n vec3 cameraPos = vec3(0.0,innerRadius + cameraHeight,0.0); // The camera's current position\n\n // Get the ray from the camera to the vertex and its length (which is the far point of the ray passing through the atmosphere)\n vec3 eyeRay = normalize(a_Position.xyz);\n\n float far = 0.0;\n vec3 cIn, cOut;\n if (eyeRay.y >= 0.0) {// Sky\n // Calculate the length of the \"atmosphere\"\n far = sqrt(outerRadius2 + innerRadius2 * eyeRay.y * eyeRay.y - innerRadius2) - innerRadius * eyeRay.y;\n\n // Calculate the ray's starting position, then calculate its scattering offset\n float height = innerRadius + cameraHeight;\n float depth = exp(scaleOverScaleDepth * -cameraHeight);\n float startAngle = dot(eyeRay, cameraPos) / height;\n float startOffset = depth*scaleAngle(startAngle);\n\n // Initialize the scattering loop variables\n float sampleLength = far / samples;\n float scaledLength = sampleLength * scale;\n vec3 sampleRay = eyeRay * sampleLength;\n vec3 samplePoint = cameraPos + sampleRay * 0.5;\n\n vec3 frontColor = vec3(0.0);\n //unrolling this manually to avoid some platform for loop slow\n {\n float height = length(samplePoint);\n float depth = exp(scaleOverScaleDepth * (innerRadius - height));\n float lightAngle = dot(-u_DirectionLight.Direction, samplePoint) / height;\n float cameraAngle = dot(eyeRay, samplePoint) / height;\n float scatter = (startOffset + depth*(scaleAngle(lightAngle) - scaleAngle(cameraAngle)));\n vec3 attenuate = exp(-clamp(scatter, 0.0, MAX_SCATTER) * (invWavelength * kr4PI + km4PI));\n\n frontColor += attenuate * (depth * scaledLength);\n samplePoint += sampleRay;\n }\n {\n float height = length(samplePoint);\n float depth = exp(scaleOverScaleDepth * (innerRadius - height));\n float lightAngle = dot(-u_DirectionLight.Direction, samplePoint) / height;\n float cameraAngle = dot(eyeRay, samplePoint) / height;\n float scatter = (startOffset + depth*(scaleAngle(lightAngle) - scaleAngle(cameraAngle)));\n vec3 attenuate = exp(-clamp(scatter, 0.0, MAX_SCATTER) * (invWavelength * kr4PI + km4PI));\n\n frontColor += attenuate * (depth * scaledLength);\n samplePoint += sampleRay;\n }\n\n // Finally, scale the Mie and Rayleigh colors and set up the varying variables for the pixel shader\n cIn = frontColor * (invWavelength * krESun);\n cOut = frontColor * kmESun;\n } else {// Ground\n far = (-cameraHeight) / (min(-0.001, eyeRay.y));\n vec3 pos = cameraPos + far * eyeRay;\n\n // Calculate the ray's starting position, then calculate its scattering offset\n float depth = exp((-cameraHeight) * (1.0/scaleDepth));\n float cameraAngle = dot(-eyeRay, pos);\n float lightAngle = dot(-u_DirectionLight.Direction, pos);\n float cameraScale = scaleAngle(cameraAngle);\n float lightScale = scaleAngle(lightAngle);\n float cameraOffset = depth*cameraScale;\n float temp = lightScale + cameraScale;\n\n // Initialize the scattering loop variables\n float sampleLength = far / samples;\n float scaledLength = sampleLength * scale;\n vec3 sampleRay = eyeRay * sampleLength;\n vec3 samplePoint = cameraPos + sampleRay * 0.5;\n\n // Now loop through the sample rays\n vec3 frontColor = vec3(0.0, 0.0, 0.0);\n vec3 attenuate;\n\n // Loop removed because we kept hitting SM2.0 temp variable limits. Doesn't affect the image too much.\n {\n float height = length(samplePoint);\n float depth = exp(scaleOverScaleDepth * (innerRadius - height));\n float scatter = depth*temp - cameraOffset;\n attenuate = exp(-clamp(scatter, 0.0, MAX_SCATTER) * (invWavelength * kr4PI + km4PI));\n frontColor += attenuate * (depth * scaledLength);\n samplePoint += sampleRay;\n }\n\n cIn = frontColor * (invWavelength * krESun + kmESun);\n cOut = clamp(attenuate, 0.0, 1.0);\n }\n\n #ifdef SUN_HIGH_QUALITY\n v_Vertex = -a_Position.xyz;\n #elif defined(SUN_SIMPLE) \n v_RayDir = -eyeRay;\n #else\n v_SkyGroundFactor = -eyeRay.y / SKY_GROUND_THRESHOLD;\n #endif\n\n // if we want to calculate color in vprog:\n // in case of linear: multiply by _Exposure in here (even in case of lerp it will be common multiplier, so we can skip mul in fshader)\n v_GroundColor = u_Exposure * (cIn + u_GroundTint*u_GroundTint * cOut);//u_GroundColor*u_GroundColor is gamma space convert to linear space\n v_SkyColor = u_Exposure * (cIn * getRayleighPhase(-u_DirectionLight.Direction, -eyeRay));\n\n \n // The sun should have a stable intensity in its course in the sky. Moreover it should match the highlight of a purely specular material.\n // This matching was done using the Unity3D standard shader BRDF1 on the 5/31/2017\n // Finally we want the sun to be always bright even in LDR thus the normalization of the lightColor for low intensity.\n float lightColorIntensity = clamp(length(u_DirectionLight.Color), 0.25, 1.0);\n\n #ifdef SUN_HIGH_QUALITY \n v_SunColor = HDSundiskIntensityFactor * clamp(cOut,0.0,1.0) * u_DirectionLight.Color / lightColorIntensity;\n #elif defined(SUN_SIMPLE) \n v_SunColor = simpleSundiskIntensityFactor * clamp(cOut * sunScale,0.0,1.0) * u_DirectionLight.Color / lightColorIntensity;\n #endif\n gl_Position=remapGLPositionZ(gl_Position);\n}\n";
  9038. ps="#ifdef HIGHPRECISION\n precision highp float;\n#else\n precision mediump float;\n#endif\n\n#include \"Lighting.glsl\";\n\nconst float MIE_G = -0.990;\nconst float MIE_G2 = 0.9801;\nconst float SKY_GROUND_THRESHOLD = 0.02;\n\nuniform float u_SunSize;\nuniform float u_SunSizeConvergence;\nuniform DirectionLight u_DirectionLight;\n\n\nvarying vec3 v_GroundColor;\nvarying vec3 v_SkyColor;\n\n\n#ifdef SUN_HIGH_QUALITY\n varying vec3 v_Vertex;\n#elif defined(SUN_SIMPLE)\n varying vec3 v_RayDir;\n#else\n varying float v_SkyGroundFactor;\n#endif\n\n#if defined(SUN_HIGH_QUALITY)||defined(SUN_SIMPLE)\n varying vec3 v_SunColor;\n#endif\n\n// Calculates the Mie phase function\nfloat getMiePhase(float eyeCos, float eyeCos2) {\n float temp = 1.0 + MIE_G2 - 2.0 * MIE_G * eyeCos;\n temp = pow(temp, pow(u_SunSize,0.65) * 10.0);\n temp = max(temp,1.0e-4); // prevent division by zero, esp. in half precision\n temp = 1.5 * ((1.0 - MIE_G2) / (2.0 + MIE_G2)) * (1.0 + eyeCos2) / temp;\n return temp;\n}\n\n// Calculates the sun shape\nfloat calcSunAttenuation(vec3 lightPos, vec3 ray) {\n #ifdef SUN_HIGH_QUALITY\n float focusedEyeCos = pow(clamp(dot(lightPos, ray),0.0,1.0), u_SunSizeConvergence);\n return getMiePhase(-focusedEyeCos, focusedEyeCos * focusedEyeCos);\n #else //SUN_SIMPLE\n vec3 delta = lightPos - ray;\n float dist = length(delta);\n float spot = 1.0 - smoothstep(0.0, u_SunSize, dist);\n return spot * spot;\n #endif\n}\n\nvoid main() {\n // if y > 1 [eyeRay.y < -SKY_GROUND_THRESHOLD] - ground\n // if y >= 0 and < 1 [eyeRay.y <= 0 and > -SKY_GROUND_THRESHOLD] - horizon\n // if y < 0 [eyeRay.y > 0] - sky\n vec3 col = vec3(0.0, 0.0, 0.0);\n\n #ifdef SUN_HIGH_QUALITY\n vec3 ray = normalize(v_Vertex);\n float y = ray.y / SKY_GROUND_THRESHOLD;\n #elif defined(SUN_SIMPLE) \n vec3 ray = v_RayDir;\n float y = ray.y / SKY_GROUND_THRESHOLD; \n #else\n float y = v_SkyGroundFactor;\n #endif\n\n // if we did precalculate color in vprog: just do lerp between them\n col = mix(v_SkyColor, v_GroundColor, clamp(y,0.0,1.0));\n\n #if defined(SUN_HIGH_QUALITY)||defined(SUN_SIMPLE)\n if (y < 0.0)\n col += v_SunColor * calcSunAttenuation(-u_DirectionLight.Direction, -ray);\n #endif\n\n col = sqrt(col);//linear space convert to gamma space\n gl_FragColor=vec4(col,1.0);\n}\n\n";
  9039. shader=Shader3D.add("SkyBoxProcedural");
  9040. subShader=new SubShader(attributeMap,uniformMap,null,SkyProceduralMaterial.shaderDefines);
  9041. shader.addSubShader(subShader);
  9042. subShader.addShaderPass(vs,ps);
  9043. attributeMap={
  9044. 'a_Position':/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0,
  9045. 'a_Normal':/*laya.d3.graphics.Vertex.VertexMesh.MESH_NORMAL0*/3,
  9046. 'a_Texcoord0':/*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE0*/2
  9047. };
  9048. uniformMap={
  9049. 'u_MvpMatrix':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  9050. 'u_WorldMat':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  9051. 'u_CameraPos':/*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3,
  9052. 'u_LightmapScaleOffset':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  9053. 'u_LightMap':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  9054. 'u_SplatAlphaTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9055. 'u_DiffuseTexture1':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9056. 'u_DiffuseTexture2':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9057. 'u_DiffuseTexture3':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9058. 'u_DiffuseTexture4':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9059. 'u_DiffuseTexture5':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9060. 'u_DiffuseScaleOffset1':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9061. 'u_DiffuseScaleOffset2':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9062. 'u_DiffuseScaleOffset3':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9063. 'u_DiffuseScaleOffset4':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9064. 'u_DiffuseScaleOffset5':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9065. 'u_FogStart':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  9066. 'u_FogRange':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  9067. 'u_FogColor':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  9068. 'u_DirectionLight.Direction':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  9069. 'u_DirectionLight.Color':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  9070. 'u_PointLight.Position':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  9071. 'u_PointLight.Range':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  9072. 'u_PointLight.Attenuation':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  9073. 'u_PointLight.Color':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  9074. 'u_SpotLight.Position':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  9075. 'u_SpotLight.Direction':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  9076. 'u_SpotLight.Range':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  9077. 'u_SpotLight.Spot':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  9078. 'u_SpotLight.Color':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  9079. 'u_AmbientColor':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  9080. 'u_shadowMap1':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  9081. 'u_shadowMap2':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  9082. 'u_shadowMap3':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  9083. 'u_shadowPSSMDistance':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  9084. 'u_lightShadowVP':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  9085. 'u_shadowPCFoffset':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4
  9086. };
  9087. stateMap={
  9088. 's_Cull':/*laya.d3.shader.Shader3D.RENDER_STATE_CULL*/0,
  9089. 's_Blend':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND*/1,
  9090. 's_BlendSrc':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_SRC*/2,
  9091. 's_BlendDst':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_DST*/3,
  9092. 's_DepthTest':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_TEST*/12,
  9093. 's_DepthWrite':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_WRITE*/13
  9094. };
  9095. vs="#include \"Lighting.glsl\";\n\nattribute vec4 a_Position;\nattribute vec2 a_Texcoord0;\n\nuniform mat4 u_MvpMatrix;\n\nvarying vec2 v_Texcoord0;\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(LIGHTMAP)\n attribute vec3 a_Normal;\n varying vec3 v_Normal;\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)||(defined(RECEIVESHADOW)&&defined(SHADOWMAP_PSSM1))\n uniform mat4 u_WorldMat;\n varying vec3 v_PositionWorld;\n#endif\n\n#ifdef LIGHTMAP\n varying vec2 v_LightMapUV;\n uniform vec4 u_LightmapScaleOffset;\n#endif\n\n#ifdef RECEIVESHADOW\n varying float v_posViewZ;\n #ifdef SHADOWMAP_PSSM1 \n varying vec4 v_lightMVPPos;\n uniform mat4 u_lightShadowVP[4];\n #endif\n#endif\n\nvoid main()\n{\n gl_Position = u_MvpMatrix * a_Position;\n \n v_Texcoord0 = a_Texcoord0;\n \n #ifdef LIGHTMAP\n v_LightMapUV = vec2(a_Texcoord0.x, 1.0 - a_Texcoord0.y) * u_LightmapScaleOffset.xy + u_LightmapScaleOffset.zw;\n v_LightMapUV.y = 1.0 - v_LightMapUV.y;\n #endif\n \n #if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n v_Normal = a_Normal;\n #endif\n\n #if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)||(defined(RECEIVESHADOW)&&defined(SHADOWMAP_PSSM1))\n v_PositionWorld=(u_WorldMat*a_Position).xyz;\n #endif\n\n #ifdef RECEIVESHADOW\n v_posViewZ = gl_Position.w;\n #ifdef SHADOWMAP_PSSM1\n v_lightMVPPos = u_lightShadowVP[0] * vec4(v_PositionWorld,1.0);\n #endif\n #endif\n gl_Position=remapGLPositionZ(gl_Position);\n}";
  9096. ps="#ifdef HIGHPRECISION\n precision highp float;\n#else\n precision mediump float;\n#endif\n\n#include \"Lighting.glsl\";\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)\n uniform vec3 u_CameraPos;\n varying vec3 v_Normal;\n varying vec3 v_PositionWorld;\n#endif\n\n#ifdef FOG\n uniform float u_FogStart;\n uniform float u_FogRange;\n uniform vec3 u_FogColor;\n#endif\n\n\n#ifdef DIRECTIONLIGHT\n uniform DirectionLight u_DirectionLight;\n#endif\n\n#ifdef POINTLIGHT\n uniform PointLight u_PointLight;\n#endif\n\n#ifdef SPOTLIGHT\n uniform SpotLight u_SpotLight;\n#endif\n\n#include \"ShadowHelper.glsl\"\n#ifdef RECEIVESHADOW\n #if defined(SHADOWMAP_PSSM2)||defined(SHADOWMAP_PSSM3)\n uniform mat4 u_lightShadowVP[4];\n #endif\n #ifdef SHADOWMAP_PSSM1 \n varying vec4 v_lightMVPPos;\n #endif\n#endif\nvarying float v_posViewZ;\n\nuniform vec3 u_AmbientColor;\n\nuniform sampler2D u_SplatAlphaTexture;\n\nuniform sampler2D u_DiffuseTexture1;\nuniform sampler2D u_DiffuseTexture2;\nuniform sampler2D u_DiffuseTexture3;\nuniform sampler2D u_DiffuseTexture4;\nuniform sampler2D u_DiffuseTexture5;\n\nuniform vec4 u_DiffuseScaleOffset1;\nuniform vec4 u_DiffuseScaleOffset2;\nuniform vec4 u_DiffuseScaleOffset3;\nuniform vec4 u_DiffuseScaleOffset4;\nuniform vec4 u_DiffuseScaleOffset5;\n\nvarying vec2 v_Texcoord0;\n\n#ifdef LIGHTMAP\n uniform sampler2D u_LightMap;\n varying vec2 v_LightMapUV;\n#endif\n\nvoid main()\n{\n vec4 splatAlpha = vec4(1.0);\n #ifdef ExtendTerrain_DETAIL_NUM1\n splatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\n vec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\n gl_FragColor.xyz = color1.xyz * splatAlpha.r;\n #endif\n #ifdef ExtendTerrain_DETAIL_NUM2\n splatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\n vec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\n vec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord0 * u_DiffuseScaleOffset2.xy);\n gl_FragColor.xyz = color1.xyz * splatAlpha.r + color2.xyz * (1.0 - splatAlpha.r);\n #endif\n #ifdef ExtendTerrain_DETAIL_NUM3\n splatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\n vec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\n vec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord0 * u_DiffuseScaleOffset2.xy);\n vec4 color3 = texture2D(u_DiffuseTexture3, v_Texcoord0 * u_DiffuseScaleOffset3.xy);\n gl_FragColor.xyz = color1.xyz * splatAlpha.r + color2.xyz * splatAlpha.g + color3.xyz * (1.0 - splatAlpha.r - splatAlpha.g);\n #endif\n #ifdef ExtendTerrain_DETAIL_NUM4\n splatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\n vec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\n vec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord0 * u_DiffuseScaleOffset2.xy);\n vec4 color3 = texture2D(u_DiffuseTexture3, v_Texcoord0 * u_DiffuseScaleOffset3.xy);\n vec4 color4 = texture2D(u_DiffuseTexture4, v_Texcoord0 * u_DiffuseScaleOffset4.xy);\n gl_FragColor.xyz = color1.xyz * splatAlpha.r + color2.xyz * splatAlpha.g + color3.xyz * splatAlpha.b + color4.xyz * (1.0 - splatAlpha.r - splatAlpha.g - splatAlpha.b);\n #endif\n #ifdef ExtendTerrain_DETAIL_NUM5\n splatAlpha = texture2D(u_SplatAlphaTexture, v_Texcoord0);\n vec4 color1 = texture2D(u_DiffuseTexture1, v_Texcoord0 * u_DiffuseScaleOffset1.xy);\n vec4 color2 = texture2D(u_DiffuseTexture2, v_Texcoord0 * u_DiffuseScaleOffset2.xy);\n vec4 color3 = texture2D(u_DiffuseTexture3, v_Texcoord0 * u_DiffuseScaleOffset3.xy);\n vec4 color4 = texture2D(u_DiffuseTexture4, v_Texcoord0 * u_DiffuseScaleOffset4.xy);\n vec4 color5 = texture2D(u_DiffuseTexture5, v_Texcoord0 * u_DiffuseScaleOffset5.xy);\n gl_FragColor.xyz = color1.xyz * splatAlpha.r + color2.xyz * splatAlpha.g + color3.xyz * splatAlpha.b + color4.xyz * splatAlpha.a + color5.xyz * (1.0 - splatAlpha.r - splatAlpha.g - splatAlpha.b - splatAlpha.a);\n #endif\n gl_FragColor.w = splatAlpha.a;\n \n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n vec3 normal = v_Normal;\n vec3 dif, spe;\n#endif\n\nvec3 diffuse = vec3(0.0);\nvec3 specular= vec3(0.0);\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)||defined(FOG)\n vec3 toEye;\n #ifdef FOG\n toEye=u_CameraPos-v_PositionWorld;\n float toEyeLength=length(toEye);\n toEye/=toEyeLength;\n #else\n toEye=normalize(u_CameraPos-v_PositionWorld);\n #endif\n#endif\n\n#ifdef DIRECTIONLIGHT\n LayaAirBlinnPhongDiectionLight(vec3(0.0), 1.0, normal, vec3(1.0), toEye,u_DirectionLight, dif, spe);\n diffuse+=dif;\n specular+=spe;\n#endif\n \n#ifdef POINTLIGHT\n LayaAirBlinnPhongPointLight(v_PositionWorld, vec3(0.0), 1.0, normal, vec3(1.0), toEye, u_PointLight, dif, spe);\n diffuse+=dif;\n specular+=spe;\n#endif\n\n#ifdef SPOTLIGHT\n LayaAirBlinnPhongSpotLight(v_PositionWorld, vec3(0.0), 1.0, normal, vec3(1.0), toEye, u_SpotLight, dif, spe);\n diffuse+=dif;\n specular+=spe;\n#endif\n\nvec3 globalDiffuse = u_AmbientColor;\n#ifdef LIGHTMAP\n globalDiffuse += DecodeLightmap(texture2D(u_LightMap, v_LightMapUV));\n#endif\n\n#ifdef RECEIVESHADOW\n float shadowValue = 1.0;\n #ifdef SHADOWMAP_PSSM3\n shadowValue = getShadowPSSM3( u_shadowMap1,u_shadowMap2,u_shadowMap3,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n #endif\n #ifdef SHADOWMAP_PSSM2\n shadowValue = getShadowPSSM2( u_shadowMap1,u_shadowMap2,u_lightShadowVP,u_shadowPSSMDistance,u_shadowPCFoffset,v_PositionWorld,v_posViewZ,0.001);\n #endif \n #ifdef SHADOWMAP_PSSM1\n shadowValue = getShadowPSSM1( u_shadowMap1,v_lightMVPPos,u_shadowPSSMDistance,u_shadowPCFoffset,v_posViewZ,0.001);\n #endif\n gl_FragColor = vec4(gl_FragColor.rgb * (globalDiffuse + diffuse) * shadowValue, gl_FragColor.a);\n#else\n gl_FragColor = vec4(gl_FragColor.rgb * (globalDiffuse + diffuse), gl_FragColor.a);\n#endif\n\n#if defined(DIRECTIONLIGHT)||defined(POINTLIGHT)||defined(SPOTLIGHT)\n #ifdef RECEIVESHADOW\n gl_FragColor.rgb += specular * shadowValue;\n #else\n gl_FragColor.rgb += specular;\n #endif\n#endif\n\n#ifdef FOG\n float lerpFact=clamp((toEyeLength-u_FogStart)/u_FogRange,0.0,1.0);\n gl_FragColor.rgb=mix(gl_FragColor.rgb,u_FogColor,lerpFact);\n#endif\n}\n\n\n\n\n\n";
  9097. shader=Shader3D.add("ExtendTerrain");
  9098. subShader=new SubShader(attributeMap,uniformMap,RenderableSprite3D.shaderDefines,ExtendTerrainMaterial.shaderDefines);
  9099. shader.addSubShader(subShader);
  9100. subShader.addShaderPass(vs,ps,stateMap);
  9101. attributeMap={
  9102. 'a_Position' :/*laya.d3.core.trail.VertexTrail.TRAIL_POSITION0*/0,
  9103. 'a_OffsetVector':/*laya.d3.core.trail.VertexTrail.TRAIL_OFFSETVECTOR*/1,
  9104. 'a_Texcoord0X' :/*laya.d3.core.trail.VertexTrail.TRAIL_TEXTURECOORDINATE0X*/4,
  9105. 'a_Texcoord0Y' :/*laya.d3.core.trail.VertexTrail.TRAIL_TEXTURECOORDINATE0Y*/3,
  9106. 'a_BirthTime' :/*laya.d3.core.trail.VertexTrail.TRAIL_TIME0*/2
  9107. };
  9108. uniformMap={
  9109. 'u_MvpMatrix':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  9110. 'u_View':/*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3,
  9111. 'u_Projection':/*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3,
  9112. 'u_TilingOffset':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9113. 'u_MainTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9114. 'u_MainColor':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9115. 'u_CurTime' :/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  9116. 'u_LifeTime' :/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  9117. 'u_WidthCurve' :/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  9118. 'u_WidthCurveKeyLength' :/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  9119. 'u_GradientColorkey' :/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  9120. 'u_GradientAlphakey' :/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2
  9121. };
  9122. stateMap={
  9123. 's_Cull':/*laya.d3.shader.Shader3D.RENDER_STATE_CULL*/0,
  9124. 's_Blend':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND*/1,
  9125. 's_BlendSrc':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_SRC*/2,
  9126. 's_BlendDst':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_DST*/3,
  9127. 's_DepthTest':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_TEST*/12,
  9128. 's_DepthWrite':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_WRITE*/13
  9129. };
  9130. vs="#include \"Lighting.glsl\";\n\nattribute vec3 a_Position;\nattribute vec3 a_OffsetVector;\nattribute vec4 a_Color;\nattribute float a_Texcoord0X;\nattribute float a_Texcoord0Y;\nattribute float a_BirthTime;\n\nuniform mat4 u_View;\nuniform mat4 u_Projection;\n\nuniform vec4 u_TilingOffset;\n\nuniform float u_CurTime;\nuniform float u_LifeTime;\nuniform vec4 u_WidthCurve[10];\nuniform int u_WidthCurveKeyLength;\n\nuniform vec4 u_GradientColorkey[10];\nuniform vec2 u_GradientAlphakey[10];\n\nvarying vec2 v_Texcoord0;\nvarying vec4 v_Color;\n\nfloat hermiteInterpolate(float t, float outTangent, float inTangent, float duration, float value1, float value2)\n{\n float t2 = t * t;\n float t3 = t2 * t;\n float a = 2.0 * t3 - 3.0 * t2 + 1.0;\n float b = t3 - 2.0 * t2 + t;\n float c = t3 - t2;\n float d = -2.0 * t3 + 3.0 * t2;\n return a * value1 + b * outTangent * duration + c * inTangent * duration + d * value2;\n}\n\nfloat getCurWidth(in float normalizeTime)\n{\n float width;\n if(normalizeTime == 0.0){\n width=u_WidthCurve[0].w;\n }\n else if(normalizeTime >= 1.0){\n width=u_WidthCurve[u_WidthCurveKeyLength - 1].w;\n }\n else{\n for(int i = 0; i < 10; i ++ )\n {\n if(normalizeTime == u_WidthCurve[i].x){\n width=u_WidthCurve[i].w;\n break;\n }\n \n vec4 lastFrame = u_WidthCurve[i];\n vec4 nextFrame = u_WidthCurve[i + 1];\n if(normalizeTime > lastFrame.x && normalizeTime < nextFrame.x)\n {\n float duration = nextFrame.x - lastFrame.x;\n float t = (normalizeTime - lastFrame.x) / duration;\n float outTangent = lastFrame.z;\n float inTangent = nextFrame.y;\n float value1 = lastFrame.w;\n float value2 = nextFrame.w;\n width=hermiteInterpolate(t, outTangent, inTangent, duration, value1, value2);\n break;\n }\n }\n }\n return width;\n} \n\nvec4 getColorFromGradientByBlend(in vec4 gradientColors[10], in vec2 gradientAlphas[10], in float normalizeTime)\n{\n vec4 color;\n for(int i = 1; i < 10; i++)\n {\n vec4 gradientColor = gradientColors[i];\n float colorKey = gradientColor.x;\n if(colorKey >= normalizeTime)\n {\n vec4 lastGradientColor = gradientColors[i-1];\n float lastColorKey = lastGradientColor.x;\n float age = (normalizeTime - lastColorKey) / (colorKey - lastColorKey);\n color.rgb = mix(gradientColors[i-1].yzw, gradientColor.yzw, age);\n break;\n }\n }\n for(int i = 1; i < 10; i++)\n {\n vec2 gradientAlpha = gradientAlphas[i];\n float alphaKey = gradientAlpha.x;\n if(alphaKey >= normalizeTime)\n {\n vec2 lastGradientAlpha = gradientAlphas[i-1];\n float lastAlphaKey = lastGradientAlpha.x;\n float age = (normalizeTime - lastAlphaKey) / (alphaKey - lastAlphaKey);\n color.a = mix(lastGradientAlpha.y, gradientAlpha.y, age);\n break;\n }\n }\n return color;\n}\n\nvec4 getColorFromGradientByFixed(in vec4 gradientColors[10], in vec2 gradientAlphas[10], in float normalizeTime)\n{\n vec4 color;\n for(int i = 1; i < 10; i++)\n {\n vec4 gradientColor = gradientColors[i];\n if(gradientColor.w >= normalizeTime)\n {\n color.rgb = gradientColor.xyz;\n break;\n }\n }\n for(int i = 1; i < 10; i++)\n {\n vec2 gradientAlpha = gradientAlphas[i];\n if(gradientAlpha.y >= normalizeTime)\n {\n color.a = gradientAlpha.x;\n break;\n }\n }\n return color;\n}\n\nvoid main()\n{\n float normalizeTime = (u_CurTime - a_BirthTime) / u_LifeTime;\n \n #ifdef TILINGOFFSET\n v_Texcoord0 = vec2(a_Texcoord0X, 1.0 - a_Texcoord0Y) * u_TilingOffset.xy + u_TilingOffset.zw;\n #else\n v_Texcoord0 = vec2(a_Texcoord0X, a_Texcoord0Y);\n #endif\n \n #ifdef GRADIENTMODE_BLEND\n v_Color = getColorFromGradientByBlend(u_GradientColorkey, u_GradientAlphakey, normalizeTime);\n #else\n v_Color = getColorFromGradientByFixed(u_GradientColorkey, u_GradientAlphakey, normalizeTime);\n #endif\n \n gl_Position = u_Projection * u_View * vec4(a_Position + a_OffsetVector * getCurWidth(normalizeTime),1.0);\n gl_Position=remapGLPositionZ(gl_Position);\n}\n";
  9131. ps="#ifdef HIGHPRECISION\n precision highp float;\n#else\n precision mediump float;\n#endif\n\nuniform sampler2D u_MainTexture;\nuniform vec4 u_MainColor;\n\nvarying vec2 v_Texcoord0;\nvarying vec4 v_Color;\n\nvoid main()\n{ \n vec4 color = 2.0 * u_MainColor * v_Color;\n #ifdef MAINTEXTURE\n vec4 mainTextureColor = texture2D(u_MainTexture, v_Texcoord0);\n color *= mainTextureColor;\n #endif\n gl_FragColor = color;\n}\n\n";
  9132. shader=Shader3D.add("Trail");
  9133. subShader=new SubShader(attributeMap,uniformMap,TrailSprite3D.shaderDefines,TrailMaterial.shaderDefines);
  9134. shader.addSubShader(subShader);
  9135. subShader.addShaderPass(vs,ps,stateMap);
  9136. attributeMap={
  9137. 'a_Position':/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0,
  9138. 'a_Normal':/*laya.d3.graphics.Vertex.VertexMesh.MESH_NORMAL0*/3,
  9139. 'a_Tangent0':/*laya.d3.graphics.Vertex.VertexMesh.MESH_TANGENT0*/4
  9140. };
  9141. uniformMap={
  9142. 'u_MvpMatrix':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  9143. 'u_WorldMat':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  9144. 'u_CameraPos':/*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3,
  9145. 'u_Time':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  9146. 'u_MainTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9147. 'u_NormalTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9148. 'u_HorizonColor':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9149. 'u_WaveScale' :/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9150. 'u_WaveSpeed' :/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1
  9151. };
  9152. vs="#include \"Lighting.glsl\";\n\nattribute vec4 a_Position;\nattribute vec3 a_Normal;\nattribute vec4 a_Tangent0;\n\nuniform mat4 u_MvpMatrix;\nuniform mat4 u_WorldMat;\nuniform vec3 u_CameraPos;\nuniform float u_WaveScale;\nuniform vec4 u_WaveSpeed;\nuniform float u_Time;\n\nvarying vec3 v_Normal;\nvarying vec3 v_Tangent;\nvarying vec3 v_Binormal;\nvarying vec3 v_ViewDir;\nvarying vec2 v_Texcoord0;\nvarying vec2 v_Texcoord1;\n\nvoid main()\n{\n vec4 positionWorld = u_WorldMat * a_Position;\n vec4 position = u_MvpMatrix * a_Position;\n \n vec4 temp = vec4(positionWorld.x, positionWorld.z, positionWorld.x, positionWorld.z) * u_WaveScale + u_WaveSpeed * u_WaveScale * u_Time;\n \n v_Texcoord0 = temp.xy * vec2(0.4, 0.45);\n v_Texcoord1 = temp.wz;\n \n mat3 worldMat = mat3(u_WorldMat);\n v_Normal = worldMat * a_Normal;\n v_Tangent = worldMat * a_Tangent0.xyz;\n v_Binormal = cross(v_Normal, v_Tangent) * a_Tangent0.w;\n \n v_ViewDir = u_CameraPos - positionWorld.xyz;\n gl_Position = position;\n gl_Position=remapGLPositionZ(gl_Position);\n}";
  9153. ps="#ifdef FSHIGHPRECISION\n precision highp float;\n#else\n precision mediump float;\n#endif\n\n#ifdef MAINTEXTURE\n uniform sampler2D u_MainTexture;\n#endif\n\n#ifdef NORMALTEXTURE\n uniform sampler2D u_NormalTexture;\n#endif\n\nuniform vec4 u_HorizonColor;\n\nvarying vec3 v_Normal;\nvarying vec3 v_Tangent;\nvarying vec3 v_Binormal;\nvarying vec3 v_ViewDir;\nvarying vec2 v_Texcoord0;\nvarying vec2 v_Texcoord1;\n\n#include \"Lighting.glsl\"\n\nvoid main()\n{\n vec4 bumpColor1 = texture2D(u_NormalTexture, v_Texcoord0);\n vec4 bumpColor2 = texture2D(u_NormalTexture, v_Texcoord1);\n \n vec3 normal1 = NormalSampleToWorldSpace1(bumpColor1, v_Tangent, v_Binormal, v_Normal);\n vec3 normal2 = NormalSampleToWorldSpace1(bumpColor2, v_Tangent, v_Binormal, v_Normal);\n \n vec3 normal = normalize((normal1 + normal2) * 0.5);\n vec3 viewDir = normalize(v_ViewDir);\n float fresnel = dot(viewDir, normal);\n \n vec4 waterColor = texture2D(u_MainTexture, vec2(fresnel, fresnel));\n \n vec4 color;\n color.rgb = mix(waterColor.rgb, u_HorizonColor.rgb, vec3(waterColor.a));\n color.a = u_HorizonColor.a;\n \n gl_FragColor = color;\n}\n\n";
  9154. shader=Shader3D.add("WaterPrimary");
  9155. subShader=new SubShader(attributeMap,uniformMap,null,WaterPrimaryMaterial.shaderDefines);
  9156. shader.addSubShader(subShader);
  9157. subShader.addShaderPass(vs,ps);
  9158. attributeMap={
  9159. 'a_PositionTexcoord':/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0
  9160. };
  9161. uniformMap={
  9162. 'u_ScreenTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1
  9163. };
  9164. vs="#include \"Lighting.glsl\";\n\nattribute vec4 a_PositionTexcoord;\nvarying vec2 v_Texcoord0;\n\nvoid main() {\n gl_Position = vec4(a_PositionTexcoord.xy, 0.0, 1.0);\n v_Texcoord0 = a_PositionTexcoord.zw;\n gl_Position = remapGLPositionZ(gl_Position);\n}";
  9165. ps="#ifdef FSHIGHPRECISION\n precision highp float;\n#else\n precision mediump float;\n#endif\n\nuniform sampler2D u_ScreenTexture;\nvarying vec2 v_Texcoord0;\n\nvoid main() {\n gl_FragColor = texture2D(u_ScreenTexture, v_Texcoord0);\n}\n\n";
  9166. shader=Shader3D.add("ScreenQuad");
  9167. subShader=new SubShader(attributeMap,uniformMap,null,null);
  9168. shader.addSubShader(subShader);
  9169. var shaderPass=subShader.addShaderPass(vs,ps);
  9170. var renderState=shaderPass.renderState;
  9171. renderState.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_ALWAYS*/0x0207;
  9172. renderState.depthWrite=false;
  9173. renderState.cull=/*laya.d3.core.material.RenderState.CULL_NONE*/0;
  9174. renderState.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  9175. attributeMap={
  9176. 'a_PositionTexcoord':/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0
  9177. };
  9178. uniformMap={
  9179. 'u_MainTex':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9180. 'u_BloomTex':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9181. 'u_AutoExposureTex':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9182. 'u_MainTex_TexelSize':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9183. 'u_SampleScale':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9184. 'u_Threshold':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9185. 'u_Params' :/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1
  9186. };
  9187. shader=Shader3D.add("PostProcessBloom",attributeMap,uniformMap);
  9188. subShader=new SubShader(null,null,null,null);
  9189. shader.addSubShader(subShader);
  9190. shaderPass=subShader.addShaderPass("#include \"Lighting.glsl\";\n\nattribute vec4 a_PositionTexcoord;\nvarying vec2 v_Texcoord0;\n\nvoid main() {\n gl_Position = vec4(a_PositionTexcoord.xy, 0.0, 1.0);\n v_Texcoord0 = a_PositionTexcoord.zw;\n gl_Position = remapGLPositionZ(gl_Position);\n}","#ifdef HIGHPRECISION\n precision highp float;\n#else\n precision mediump float;\n#endif\n\n#include \"Colors.glsl\";\n#include \"Sampling.glsl\";\n\nvarying vec2 v_Texcoord0;\n\nuniform sampler2D u_MainTex;\nuniform sampler2D u_AutoExposureTex;\nuniform vec4 u_MainTex_TexelSize;\nuniform vec4 u_Threshold; // x: threshold value (linear), y: threshold - knee, z: knee * 2, w: 0.25 / knee\nuniform vec4 u_Params; // x: clamp, yzw: unused\n\nmediump vec4 prefilter(mediump vec4 color, vec2 uv) {\n mediump float autoExposure = texture2D(u_AutoExposureTex, uv).r;\n color *= autoExposure;\n color = min(vec4(u_Params.x), color); // clamp to max\n color = quadraticThreshold(color, u_Threshold.x, u_Threshold.yzw);\n return color;\n}\n\nvoid fragPrefilter13() {\n mediump vec4 color = downsampleBox13Tap(u_MainTex, v_Texcoord0, u_MainTex_TexelSize.xy);\n gl_FragColor = prefilter(safeHDR(color), v_Texcoord0);\n}\n\nvoid main() {\n fragPrefilter13();\n}");
  9191. renderState=shaderPass.renderState;
  9192. renderState.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_ALWAYS*/0x0207;
  9193. renderState.depthWrite=false;
  9194. renderState.cull=/*laya.d3.core.material.RenderState.CULL_NONE*/0;
  9195. renderState.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  9196. subShader=new SubShader(null,null,null,null);
  9197. shader.addSubShader(subShader);
  9198. shaderPass=subShader.addShaderPass("#include \"Lighting.glsl\";\n\nattribute vec4 a_PositionTexcoord;\nvarying vec2 v_Texcoord0;\n\nvoid main() {\n gl_Position = vec4(a_PositionTexcoord.xy, 0.0, 1.0);\n v_Texcoord0 = a_PositionTexcoord.zw;\n gl_Position = remapGLPositionZ(gl_Position);\n}","#ifdef HIGHPRECISION\n precision highp float;\n#else\n precision mediump float;\n#endif\n\n#include \"Colors.glsl\";\n#include \"Sampling.glsl\";\n\nvarying vec2 v_Texcoord0;\n\nuniform sampler2D u_MainTex;\nuniform sampler2D u_AutoExposureTex;\nuniform vec4 u_MainTex_TexelSize;\nuniform vec4 u_Threshold; // x: threshold value (linear), y: threshold - knee, z: knee * 2, w: 0.25 / knee\nuniform vec4 u_Params; // x: clamp, yzw: unused\n\nmediump vec4 prefilter(mediump vec4 color, vec2 uv) {\n mediump float autoExposure = texture2D(u_AutoExposureTex, uv).r;\n color *= autoExposure;\n color = min(vec4(u_Params.x), color); // clamp to max\n color = quadraticThreshold(color, u_Threshold.x, u_Threshold.yzw);\n return color;\n}\n\nvoid fragPrefilter4() {\n mediump vec4 color = downsampleBox4Tap(u_MainTex, v_Texcoord0, u_MainTex_TexelSize.xy);\n gl_FragColor = prefilter(safeHDR(color), v_Texcoord0);\n}\n\nvoid main() {\n fragPrefilter4();\n}");
  9199. renderState=shaderPass.renderState;
  9200. renderState.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_ALWAYS*/0x0207;
  9201. renderState.depthWrite=false;
  9202. renderState.cull=/*laya.d3.core.material.RenderState.CULL_NONE*/0;
  9203. renderState.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  9204. subShader=new SubShader(null,null,null,null);
  9205. shader.addSubShader(subShader);
  9206. shaderPass=subShader.addShaderPass("#include \"Lighting.glsl\";\n\nattribute vec4 a_PositionTexcoord;\nvarying vec2 v_Texcoord0;\n\nvoid main() {\n gl_Position = vec4(a_PositionTexcoord.xy, 0.0, 1.0);\n v_Texcoord0 = a_PositionTexcoord.zw;\n gl_Position = remapGLPositionZ(gl_Position);\n}","#ifdef HIGHPRECISION\n precision highp float;\n#else\n precision mediump float;\n#endif\n\n#include \"Colors.glsl\";\n#include \"Sampling.glsl\";\n\nvarying vec2 v_Texcoord0;\n\nuniform sampler2D u_MainTex;\nuniform vec4 u_MainTex_TexelSize;\n\nvoid fragDownsample13() {\n mediump vec4 color = downsampleBox13Tap(u_MainTex, v_Texcoord0, u_MainTex_TexelSize.xy);\n gl_FragColor = color;\n}\n\nvoid main() {\n fragDownsample13();\n}");
  9207. renderState=shaderPass.renderState;
  9208. renderState.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_ALWAYS*/0x0207;
  9209. renderState.depthWrite=false;
  9210. renderState.cull=/*laya.d3.core.material.RenderState.CULL_NONE*/0;
  9211. renderState.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  9212. subShader=new SubShader(null,null,null,null);
  9213. shader.addSubShader(subShader);
  9214. shaderPass=subShader.addShaderPass("#include \"Lighting.glsl\";\n\nattribute vec4 a_PositionTexcoord;\nvarying vec2 v_Texcoord0;\n\nvoid main() {\n gl_Position = vec4(a_PositionTexcoord.xy, 0.0, 1.0);\n v_Texcoord0 = a_PositionTexcoord.zw;\n gl_Position = remapGLPositionZ(gl_Position);\n}","#ifdef HIGHPRECISION\n precision highp float;\n#else\n precision mediump float;\n#endif\n\n#include \"Colors.glsl\";\n#include \"Sampling.glsl\";\n\nvarying vec2 v_Texcoord0;\n\nuniform sampler2D u_MainTex;\nuniform sampler2D u_BloomTex;\n\nuniform vec4 u_MainTex_TexelSize;\nuniform float u_SampleScale;\n\nmediump vec4 combine(mediump vec4 bloom, vec2 uv) {\n mediump vec4 color = texture2D(u_BloomTex, uv);\n return bloom + color;\n}\n\nvoid fragUpsampleTent() {\n mediump vec4 bloom = UpsampleTent(u_MainTex, v_Texcoord0, u_MainTex_TexelSize.xy, u_SampleScale);\n gl_FragColor = combine(bloom, v_Texcoord0);\n}\n\nvoid main() {\n fragUpsampleTent();\n}");
  9215. renderState=shaderPass.renderState;
  9216. renderState.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_ALWAYS*/0x0207;
  9217. renderState.depthWrite=false;
  9218. renderState.cull=/*laya.d3.core.material.RenderState.CULL_NONE*/0;
  9219. renderState.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  9220. subShader=new SubShader(null,null,null,null);
  9221. shader.addSubShader(subShader);
  9222. shaderPass=subShader.addShaderPass("#include \"Lighting.glsl\";\n\nattribute vec4 a_PositionTexcoord;\nvarying vec2 v_Texcoord0;\n\nvoid main() {\n gl_Position = vec4(a_PositionTexcoord.xy, 0.0, 1.0);\n v_Texcoord0 = a_PositionTexcoord.zw;\n gl_Position = remapGLPositionZ(gl_Position);\n}","#ifdef HIGHPRECISION\n precision highp float;\n#else\n precision mediump float;\n#endif\n\n#include \"Colors.glsl\";\n#include \"Sampling.glsl\";\n\nvarying vec2 v_Texcoord0;\n\nuniform sampler2D u_MainTex;\nuniform sampler2D u_BloomTex;\n\nuniform vec4 u_MainTex_TexelSize;\nuniform float u_SampleScale;\n\nmediump vec4 combine(mediump vec4 bloom, vec2 uv) {\n mediump vec4 color = texture2D(u_BloomTex, uv);\n return bloom + color;\n}\n\nvoid fragUpsampleBox() {\n mediump vec4 bloom = upsampleBox(u_MainTex, v_Texcoord0, u_MainTex_TexelSize.xy, vec4(u_SampleScale));\n gl_FragColor = combine(bloom, v_Texcoord0);\n}\n\nvoid main() {\n fragUpsampleBox();\n}");
  9223. renderState=shaderPass.renderState;
  9224. renderState.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_ALWAYS*/0x0207;
  9225. renderState.depthWrite=false;
  9226. renderState.cull=/*laya.d3.core.material.RenderState.CULL_NONE*/0;
  9227. renderState.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  9228. subShader=new SubShader(null,null,null,null);
  9229. shader.addSubShader(subShader);
  9230. shaderPass=subShader.addShaderPass("#include \"Lighting.glsl\";\n\nattribute vec4 a_PositionTexcoord;\nvarying vec2 v_Texcoord0;\n\nvoid main() {\n gl_Position = vec4(a_PositionTexcoord.xy, 0.0, 1.0);\n v_Texcoord0 = a_PositionTexcoord.zw;\n gl_Position = remapGLPositionZ(gl_Position);\n}","#ifdef HIGHPRECISION\n precision highp float;\n#else\n precision mediump float;\n#endif\n\n#include \"Colors.glsl\";\n#include \"Sampling.glsl\";\n\nvarying vec2 v_Texcoord0;\n\nuniform sampler2D u_MainTex;\nuniform sampler2D u_AutoExposureTex;\nuniform vec4 u_MainTex_TexelSize;\nuniform vec4 u_Threshold; // x: threshold value (linear), y: threshold - knee, z: knee * 2, w: 0.25 / knee\nuniform vec4 u_Params; // x: clamp, yzw: unused\n\nmediump vec4 prefilter(mediump vec4 color, vec2 uv) {\n mediump float autoExposure = texture2D(u_AutoExposureTex, uv).r;\n color *= autoExposure;\n color = min(vec4(u_Params.x), color); // clamp to max\n color = quadraticThreshold(color, u_Threshold.x, u_Threshold.yzw);\n return color;\n}\n\nvoid fragPrefilter13() {\n mediump vec4 color = downsampleBox13Tap(u_MainTex, v_Texcoord0, u_MainTex_TexelSize.xy);\n gl_FragColor = prefilter(safeHDR(color), v_Texcoord0);\n}\n\nvoid main() {\n fragPrefilter13();\n}");
  9231. renderState=shaderPass.renderState;
  9232. renderState.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_ALWAYS*/0x0207;
  9233. renderState.depthWrite=false;
  9234. renderState.cull=/*laya.d3.core.material.RenderState.CULL_NONE*/0;
  9235. renderState.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  9236. attributeMap={
  9237. 'a_PositionTexcoord':/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0
  9238. };
  9239. uniformMap={
  9240. 'u_MainTex':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9241. 'u_BloomTex':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9242. 'u_AutoExposureTex':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9243. 'u_Bloom_DirtTex':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9244. 'u_BloomTex_TexelSize':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9245. 'u_Bloom_Settings':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  9246. 'u_Bloom_Color' :/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1
  9247. };
  9248. shader=Shader3D.add("PostProcessComposite",attributeMap,uniformMap);
  9249. subShader=new SubShader(null,null,null,PostProcess.shaderDefines);
  9250. shader.addSubShader(subShader);
  9251. shaderPass=subShader.addShaderPass("attribute vec4 a_Position;\nvarying vec2 v_Texcoord0;\n\nvec2 TransformTriangleVertexToUV(vec2 vertex)\n{\n vec2 uv = (vertex + 1.0) * 0.5;\n return uv;\n}\n\nvoid main() {\n gl_Position =vec4(a_Position.xy, 0.0, 1.0);\n v_Texcoord0=TransformTriangleVertexToUV(a_Position.xy);\n gl_Position=remapGLPositionZ(gl_Position);\n}","#include \"Colors.glsl\";\n#include \"Sampling.glsl\";\n\nvarying vec2 v_Texcoord0;\n\nuniform sampler2D u_MainTex;\nuniform sampler2D u_BloomTex;\n\nuniform sampler2D u_AutoExposureTex;\nuniform sampler2D u_Bloom_DirtTex;\nuniform vec4 u_BloomTex_TexelSize;\nuniform vec4 u_Bloom_DirtTileOffset; // xy: tiling, zw: offset\nuniform mediump vec3 u_Bloom_Settings;// x: sampleScale, y: intensity, z: dirt intensity\nuniform mediump vec3 u_Bloom_Color;\n\nvoid main() {\n mediump float autoExposure = texture2D(u_AutoExposureTex, v_Texcoord0).r;\n mediump vec4 color=vec4(0.0)\n color = texture2D(u_MainTex, v_Texcoord0);\n \n color = SRGBToLinear(color);\n color.rgb *= autoExposure;\n \n #if BLOOM || BLOOM_LOW\n {\n #if BLOOM\n mediump vec4 bloom = UpsampleTent(_BloomTex, uvDistorted, _BloomTex_TexelSize.xy, _Bloom_Settings.x);\n #else\n mediump vec4 bloom = UpsampleBox(_BloomTex, uvDistorted, _BloomTex_TexelSize.xy, _Bloom_Settings.x);\n #endif\n\n // UVs should be Distort(uv * _Bloom_DirtTileOffset.xy + _Bloom_DirtTileOffset.zw)\n // but considering we use a cover-style scale on the dirt texture the difference\n // isn't massive so we chose to save a few ALUs here instead in case lens distortion\n // is active\n mediump vec4 dirt = mediump vec4(SAMPLE_TEXTURE2D(_Bloom_DirtTex, sampler_Bloom_DirtTex, uvDistorted * _Bloom_DirtTileOffset.xy + _Bloom_DirtTileOffset.zw).rgb, 0.0);\n\n // Additive bloom (artist friendly)\n bloom *= _Bloom_Settings.y;\n dirt *= _Bloom_Settings.z;\n color += bloom * half4(_Bloom_Color, 1.0);\n color += dirt * bloom;\n }\n #endif\n \n half4 output = color;\n output = LinearToSRGB(output);\n //output.rgb = Dither(output.rgb, v_Texcoord0);//TODO:\n}");
  9252. renderState=shaderPass.renderState;
  9253. renderState.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_ALWAYS*/0x0207;
  9254. renderState.depthWrite=false;
  9255. renderState.cull=/*laya.d3.core.material.RenderState.CULL_NONE*/0;
  9256. renderState.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  9257. }
  9258. ShaderInit3D._rangeAttenTex=null;
  9259. return ShaderInit3D;
  9260. })()
  9261. /**
  9262. *<code>Utils3D</code> 类用于创建3D工具。
  9263. */
  9264. //class laya.d3.utils.Utils3D
  9265. var Utils3D=(function(){
  9266. function Utils3D(){}
  9267. __class(Utils3D,'laya.d3.utils.Utils3D');
  9268. Utils3D._convertToLayaVec3=function(bVector,out,inverseX){
  9269. out.x=inverseX ?-bVector.x():bVector.x();
  9270. out.y=bVector.y();
  9271. out.z=bVector.z();
  9272. }
  9273. Utils3D._convertToBulletVec3=function(lVector,out,inverseX){
  9274. out.setValue(inverseX ?-lVector.x :lVector.x,lVector.y,lVector.z);
  9275. }
  9276. Utils3D._rotationTransformScaleSkinAnimation=function(tx,ty,tz,qx,qy,qz,qw,sx,sy,sz,outArray,outOffset){
  9277. var re=Utils3D._tempArray16_0;
  9278. var se=Utils3D._tempArray16_1;
  9279. var tse=Utils3D._tempArray16_2;
  9280. var x2=qx+qx;
  9281. var y2=qy+qy;
  9282. var z2=qz+qz;
  9283. var xx=qx *x2;
  9284. var yx=qy *x2;
  9285. var yy=qy *y2;
  9286. var zx=qz *x2;
  9287. var zy=qz *y2;
  9288. var zz=qz *z2;
  9289. var wx=qw *x2;
  9290. var wy=qw *y2;
  9291. var wz=qw *z2;
  9292. re[15]=1;
  9293. re[0]=1-yy-zz;
  9294. re[1]=yx+wz;
  9295. re[2]=zx-wy;
  9296. re[4]=yx-wz;
  9297. re[5]=1-xx-zz;
  9298. re[6]=zy+wx;
  9299. re[8]=zx+wy;
  9300. re[9]=zy-wx;
  9301. re[10]=1-xx-yy;
  9302. se[15]=1;
  9303. se[0]=sx;
  9304. se[5]=sy;
  9305. se[10]=sz;
  9306. var i,a,b,e,ai0,ai1,ai2,ai3;
  9307. for (i=0;i < 4;i++){
  9308. ai0=re[i];
  9309. ai1=re[i+4];
  9310. ai2=re[i+8];
  9311. ai3=re[i+12];
  9312. tse[i]=ai0;
  9313. tse[i+4]=ai1;
  9314. tse[i+8]=ai2;
  9315. tse[i+12]=ai0 *tx+ai1 *ty+ai2 *tz+ai3;
  9316. }
  9317. for (i=0;i < 4;i++){
  9318. ai0=tse[i];
  9319. ai1=tse[i+4];
  9320. ai2=tse[i+8];
  9321. ai3=tse[i+12];
  9322. outArray[i+outOffset]=ai0 *se[0]+ai1 *se[1]+ai2 *se[2]+ai3 *se[3];
  9323. outArray[i+outOffset+4]=ai0 *se[4]+ai1 *se[5]+ai2 *se[6]+ai3 *se[7];
  9324. outArray[i+outOffset+8]=ai0 *se[8]+ai1 *se[9]+ai2 *se[10]+ai3 *se[11];
  9325. outArray[i+outOffset+12]=ai0 *se[12]+ai1 *se[13]+ai2 *se[14]+ai3 *se[15];
  9326. }
  9327. }
  9328. Utils3D._createSceneByJsonForMaker=function(nodeData,outBatchSprites,initTool){
  9329. var scene3d=Utils3D._createNodeByJsonForMaker(nodeData,outBatchSprites,initTool);
  9330. Utils3D._addComponentByJsonForMaker(nodeData,outBatchSprites,initTool);
  9331. return scene3d;
  9332. }
  9333. Utils3D._createNodeByJsonForMaker=function(nodeData,outBatchSprites,initTool){
  9334. var node;
  9335. switch (nodeData.type){
  9336. case "Scene3D":
  9337. node=new Scene3D();
  9338. break ;
  9339. case "Sprite3D":
  9340. node=new Sprite3D();
  9341. break ;
  9342. case "MeshSprite3D":
  9343. node=new MeshSprite3D();
  9344. (outBatchSprites)&& (outBatchSprites.push(node));
  9345. break ;
  9346. case "SkinnedMeshSprite3D":
  9347. node=new SkinnedMeshSprite3D();
  9348. break ;
  9349. case "ShuriKenParticle3D":
  9350. node=new ShuriKenParticle3D();
  9351. break ;
  9352. case "Terrain":
  9353. node=new Terrain();
  9354. break ;
  9355. case "Camera":
  9356. node=new Camera();
  9357. break ;
  9358. case "DirectionLight":
  9359. node=new DirectionLight();
  9360. break ;
  9361. case "PointLight":
  9362. node=new PointLight();
  9363. break ;
  9364. case "SpotLight":
  9365. node=new SpotLight();
  9366. break ;
  9367. case "TrailSprite3D":
  9368. node=new TrailSprite3D();
  9369. break ;
  9370. default :;
  9371. var clas=ClassUtils.getClass(nodeData.props.runtime);
  9372. node=new clas();
  9373. break ;
  9374. };
  9375. var childData=nodeData.child;
  9376. if (childData){
  9377. for (var i=0,n=childData.length;i < n;i++){
  9378. var child=Utils3D._createNodeByJsonForMaker(childData[i],outBatchSprites,initTool);
  9379. node.addChild(child);
  9380. }
  9381. };
  9382. var compId=nodeData.compId;
  9383. (node).compId=compId;
  9384. node._parse(nodeData.props,null);
  9385. if (initTool){
  9386. initTool._idMap[compId]=node;
  9387. }
  9388. Utils3D._compIdToNode[compId]=node;
  9389. var componentsData=nodeData.components;
  9390. if (componentsData){
  9391. for (var j=0,m=componentsData.length;j < m;j++){
  9392. var data=componentsData[j];
  9393. clas=Browser.window.Laya[data.type];
  9394. if (!clas){
  9395. clas=Browser.window;
  9396. var clasPaths=data.type.split('.');
  9397. clasPaths.forEach(function(cls){
  9398. clas=clas[cls];
  9399. });
  9400. }
  9401. if (typeof(clas)=='function'){
  9402. var comp=new clas();
  9403. if (initTool){
  9404. initTool._idMap[data.compId]=comp;
  9405. console.log(data.compId);
  9406. }
  9407. }else {
  9408. console.warn("Utils3D:Unkown component type.");
  9409. }
  9410. }
  9411. }
  9412. return node;
  9413. }
  9414. Utils3D._addComponentByJsonForMaker=function(nodeData,outBatchSprites,initTool){
  9415. var compId=nodeData.compId;
  9416. var node=Utils3D._compIdToNode[compId];
  9417. var childData=nodeData.child;
  9418. if (childData){
  9419. for (var i=0,n=childData.length;i < n;i++){
  9420. var child=Utils3D._addComponentByJsonForMaker(childData[i],outBatchSprites,initTool);
  9421. }
  9422. };
  9423. var componentsData=nodeData.components;
  9424. if (componentsData){
  9425. for (var j=0,m=componentsData.length;j < m;j++){
  9426. var data=componentsData[j];
  9427. clas=Browser.window.Laya[data.type];
  9428. if (!clas){
  9429. var clasPaths=data.type.split('.');
  9430. var clas=Browser.window;
  9431. clasPaths.forEach(function(cls){
  9432. clas=clas[cls];
  9433. });
  9434. }
  9435. if (typeof(clas)=='function'){
  9436. var component=initTool._idMap[data.compId];
  9437. node.addComponentIntance(component);
  9438. component._parse(data);
  9439. }else {
  9440. console.warn("Utils3D:Unkown component type.");
  9441. }
  9442. }
  9443. }
  9444. }
  9445. Utils3D._createSprite3DInstance=function(nodeData,spriteMap,outBatchSprites){
  9446. var node;
  9447. switch (nodeData.type){
  9448. case "Scene3D":
  9449. node=new Scene3D();
  9450. break ;
  9451. case "Sprite3D":
  9452. node=new Sprite3D();
  9453. break ;
  9454. case "MeshSprite3D":
  9455. node=new MeshSprite3D();
  9456. (outBatchSprites)&& (outBatchSprites.push(node));
  9457. break ;
  9458. case "SkinnedMeshSprite3D":
  9459. node=new SkinnedMeshSprite3D();
  9460. break ;
  9461. case "ShuriKenParticle3D":
  9462. node=new ShuriKenParticle3D();
  9463. break ;
  9464. case "Terrain":
  9465. node=new Terrain();
  9466. break ;
  9467. case "Camera":
  9468. node=new Camera();
  9469. break ;
  9470. case "DirectionLight":
  9471. node=new DirectionLight();
  9472. break ;
  9473. case "PointLight":
  9474. node=new PointLight();
  9475. break ;
  9476. case "SpotLight":
  9477. node=new SpotLight();
  9478. break ;
  9479. case "TrailSprite3D":
  9480. node=new TrailSprite3D();
  9481. break ;
  9482. default :
  9483. throw new Error("Utils3D:unidentified class type in (.lh) file.");
  9484. };
  9485. var childData=nodeData.child;
  9486. if (childData){
  9487. for (var i=0,n=childData.length;i < n;i++){
  9488. var child=Utils3D._createSprite3DInstance(childData[i],spriteMap,outBatchSprites)
  9489. node.addChild(child);
  9490. }
  9491. }
  9492. spriteMap[nodeData.instanceID]=node;
  9493. return node;
  9494. }
  9495. Utils3D._createComponentInstance=function(nodeData,spriteMap){
  9496. var node=spriteMap[nodeData.instanceID];
  9497. node._parse(nodeData.props,spriteMap);
  9498. var childData=nodeData.child;
  9499. if (childData){
  9500. for (var i=0,n=childData.length;i < n;i++)
  9501. Utils3D._createComponentInstance(childData[i],spriteMap)
  9502. };
  9503. var componentsData=nodeData.components;
  9504. if (componentsData){
  9505. for (var j=0,m=componentsData.length;j < m;j++){
  9506. var data=componentsData[j];
  9507. var clas=Browser.window.Laya[data.type];
  9508. if (!clas){
  9509. var clasPaths=data.type.split('.');
  9510. clas=Browser.window;
  9511. clasPaths.forEach(function(cls){
  9512. clas=clas[cls];
  9513. });
  9514. }
  9515. if (typeof(clas)=='function'){
  9516. var component=node.addComponent(clas);
  9517. component._parse(data);
  9518. }else {
  9519. console.warn("Unkown component type.");
  9520. }
  9521. }
  9522. }
  9523. }
  9524. Utils3D._createNodeByJson02=function(nodeData,outBatchSprites){
  9525. var spriteMap={};
  9526. var node=Utils3D._createSprite3DInstance(nodeData,spriteMap,outBatchSprites);
  9527. Utils3D._createComponentInstance(nodeData,spriteMap);
  9528. return node;
  9529. }
  9530. Utils3D._computeBoneAndAnimationDatasByBindPoseMatrxix=function(bones,curData,inverGlobalBindPose,outBonesDatas,outAnimationDatas,boneIndexToMesh){
  9531. var offset=0;
  9532. var matOffset=0;
  9533. var i;
  9534. var parentOffset;
  9535. var boneLength=bones.length;
  9536. for (i=0;i < boneLength;offset+=bones[i].keyframeWidth,matOffset+=16,i++){
  9537. laya.d3.utils.Utils3D._rotationTransformScaleSkinAnimation(curData[offset+0],curData[offset+1],curData[offset+2],curData[offset+3],curData[offset+4],curData[offset+5],curData[offset+6],curData[offset+7],curData[offset+8],curData[offset+9],outBonesDatas,matOffset);
  9538. if (i !=0){
  9539. parentOffset=bones[i].parentIndex *16;
  9540. laya.d3.utils.Utils3D.mulMatrixByArray(outBonesDatas,parentOffset,outBonesDatas,matOffset,outBonesDatas,matOffset);
  9541. }
  9542. };
  9543. var n=inverGlobalBindPose.length;
  9544. for (i=0;i < n;i++){
  9545. laya.d3.utils.Utils3D.mulMatrixByArrayAndMatrixFast(outBonesDatas,boneIndexToMesh[i] *16,inverGlobalBindPose[i],outAnimationDatas,i *16);
  9546. }
  9547. }
  9548. Utils3D._computeAnimationDatasByArrayAndMatrixFast=function(inverGlobalBindPose,bonesDatas,outAnimationDatas,boneIndexToMesh){
  9549. for (var i=0,n=inverGlobalBindPose.length;i < n;i++)
  9550. laya.d3.utils.Utils3D.mulMatrixByArrayAndMatrixFast(bonesDatas,boneIndexToMesh[i] *16,inverGlobalBindPose[i],outAnimationDatas,i *16);
  9551. }
  9552. Utils3D._computeBoneAndAnimationDatasByBindPoseMatrxixOld=function(bones,curData,inverGlobalBindPose,outBonesDatas,outAnimationDatas){
  9553. var offset=0;
  9554. var matOffset=0;
  9555. var i;
  9556. var parentOffset;
  9557. var boneLength=bones.length;
  9558. for (i=0;i < boneLength;offset+=bones[i].keyframeWidth,matOffset+=16,i++){
  9559. laya.d3.utils.Utils3D._rotationTransformScaleSkinAnimation(curData[offset+7],curData[offset+8],curData[offset+9],curData[offset+3],curData[offset+4],curData[offset+5],curData[offset+6],curData[offset+0],curData[offset+1],curData[offset+2],outBonesDatas,matOffset);
  9560. if (i !=0){
  9561. parentOffset=bones[i].parentIndex *16;
  9562. laya.d3.utils.Utils3D.mulMatrixByArray(outBonesDatas,parentOffset,outBonesDatas,matOffset,outBonesDatas,matOffset);
  9563. }
  9564. };
  9565. var n=inverGlobalBindPose.length;
  9566. for (i=0;i < n;i++){
  9567. var arrayOffset=i *16;
  9568. laya.d3.utils.Utils3D.mulMatrixByArrayAndMatrixFast(outBonesDatas,arrayOffset,inverGlobalBindPose[i],outAnimationDatas,arrayOffset);
  9569. }
  9570. }
  9571. Utils3D._computeAnimationDatasByArrayAndMatrixFastOld=function(inverGlobalBindPose,bonesDatas,outAnimationDatas){
  9572. var n=inverGlobalBindPose.length;
  9573. for (var i=0;i < n;i++){
  9574. var arrayOffset=i *16;
  9575. laya.d3.utils.Utils3D.mulMatrixByArrayAndMatrixFast(bonesDatas,arrayOffset,inverGlobalBindPose[i],outAnimationDatas,arrayOffset);
  9576. }
  9577. }
  9578. Utils3D._computeRootAnimationData=function(bones,curData,animationDatas){
  9579. for (var i=0,offset=0,matOffset=0,boneLength=bones.length;i < boneLength;offset+=bones[i].keyframeWidth,matOffset+=16,i++)
  9580. laya.d3.utils.Utils3D.createAffineTransformationArray(curData[offset+0],curData[offset+1],curData[offset+2],curData[offset+3],curData[offset+4],curData[offset+5],curData[offset+6],curData[offset+7],curData[offset+8],curData[offset+9],animationDatas,matOffset);
  9581. }
  9582. Utils3D.transformVector3ArrayByQuat=function(sourceArray,sourceOffset,rotation,outArray,outOffset){
  9583. var x=sourceArray[sourceOffset],y=sourceArray[sourceOffset+1],z=sourceArray[sourceOffset+2],qx=rotation.x,qy=rotation.y,qz=rotation.z,qw=rotation.w,ix=qw *x+qy *z-qz *y,iy=qw *y+qz *x-qx *z,iz=qw *z+qx *y-qy *x,iw=-qx *x-qy *y-qz *z;
  9584. outArray[outOffset]=ix *qw+iw *-qx+iy *-qz-iz *-qy;
  9585. outArray[outOffset+1]=iy *qw+iw *-qy+iz *-qx-ix *-qz;
  9586. outArray[outOffset+2]=iz *qw+iw *-qz+ix *-qy-iy *-qx;
  9587. }
  9588. Utils3D.mulMatrixByArray=function(leftArray,leftOffset,rightArray,rightOffset,outArray,outOffset){
  9589. var i,ai0,ai1,ai2,ai3;
  9590. if (outArray===rightArray){
  9591. rightArray=Utils3D._tempArray16_3;
  9592. for (i=0;i < 16;++i){
  9593. rightArray[i]=outArray[outOffset+i];
  9594. }
  9595. rightOffset=0;
  9596. }
  9597. for (i=0;i < 4;i++){
  9598. ai0=leftArray[leftOffset+i];
  9599. ai1=leftArray[leftOffset+i+4];
  9600. ai2=leftArray[leftOffset+i+8];
  9601. ai3=leftArray[leftOffset+i+12];
  9602. outArray[outOffset+i]=ai0 *rightArray[rightOffset+0]+ai1 *rightArray[rightOffset+1]+ai2 *rightArray[rightOffset+2]+ai3 *rightArray[rightOffset+3];
  9603. outArray[outOffset+i+4]=ai0 *rightArray[rightOffset+4]+ai1 *rightArray[rightOffset+5]+ai2 *rightArray[rightOffset+6]+ai3 *rightArray[rightOffset+7];
  9604. outArray[outOffset+i+8]=ai0 *rightArray[rightOffset+8]+ai1 *rightArray[rightOffset+9]+ai2 *rightArray[rightOffset+10]+ai3 *rightArray[rightOffset+11];
  9605. outArray[outOffset+i+12]=ai0 *rightArray[rightOffset+12]+ai1 *rightArray[rightOffset+13]+ai2 *rightArray[rightOffset+14]+ai3 *rightArray[rightOffset+15];
  9606. }
  9607. }
  9608. Utils3D.mulMatrixByArrayFast=function(leftArray,leftOffset,rightArray,rightOffset,outArray,outOffset){
  9609. var i,ai0,ai1,ai2,ai3;
  9610. for (i=0;i < 4;i++){
  9611. ai0=leftArray[leftOffset+i];
  9612. ai1=leftArray[leftOffset+i+4];
  9613. ai2=leftArray[leftOffset+i+8];
  9614. ai3=leftArray[leftOffset+i+12];
  9615. outArray[outOffset+i]=ai0 *rightArray[rightOffset+0]+ai1 *rightArray[rightOffset+1]+ai2 *rightArray[rightOffset+2]+ai3 *rightArray[rightOffset+3];
  9616. outArray[outOffset+i+4]=ai0 *rightArray[rightOffset+4]+ai1 *rightArray[rightOffset+5]+ai2 *rightArray[rightOffset+6]+ai3 *rightArray[rightOffset+7];
  9617. outArray[outOffset+i+8]=ai0 *rightArray[rightOffset+8]+ai1 *rightArray[rightOffset+9]+ai2 *rightArray[rightOffset+10]+ai3 *rightArray[rightOffset+11];
  9618. outArray[outOffset+i+12]=ai0 *rightArray[rightOffset+12]+ai1 *rightArray[rightOffset+13]+ai2 *rightArray[rightOffset+14]+ai3 *rightArray[rightOffset+15];
  9619. }
  9620. }
  9621. Utils3D.mulMatrixByArrayAndMatrixFast=function(leftArray,leftOffset,rightMatrix,outArray,outOffset){
  9622. var i,ai0,ai1,ai2,ai3;
  9623. var rightMatrixE=rightMatrix.elements;
  9624. var m11=rightMatrixE[0],m12=rightMatrixE[1],m13=rightMatrixE[2],m14=rightMatrixE[3];
  9625. var m21=rightMatrixE[4],m22=rightMatrixE[5],m23=rightMatrixE[6],m24=rightMatrixE[7];
  9626. var m31=rightMatrixE[8],m32=rightMatrixE[9],m33=rightMatrixE[10],m34=rightMatrixE[11];
  9627. var m41=rightMatrixE[12],m42=rightMatrixE[13],m43=rightMatrixE[14],m44=rightMatrixE[15];
  9628. var ai0LeftOffset=leftOffset;
  9629. var ai1LeftOffset=leftOffset+4;
  9630. var ai2LeftOffset=leftOffset+8;
  9631. var ai3LeftOffset=leftOffset+12;
  9632. var ai0OutOffset=outOffset;
  9633. var ai1OutOffset=outOffset+4;
  9634. var ai2OutOffset=outOffset+8;
  9635. var ai3OutOffset=outOffset+12;
  9636. for (i=0;i < 4;i++){
  9637. ai0=leftArray[ai0LeftOffset+i];
  9638. ai1=leftArray[ai1LeftOffset+i];
  9639. ai2=leftArray[ai2LeftOffset+i];
  9640. ai3=leftArray[ai3LeftOffset+i];
  9641. outArray[ai0OutOffset+i]=ai0 *m11+ai1 *m12+ai2 *m13+ai3 *m14;
  9642. outArray[ai1OutOffset+i]=ai0 *m21+ai1 *m22+ai2 *m23+ai3 *m24;
  9643. outArray[ai2OutOffset+i]=ai0 *m31+ai1 *m32+ai2 *m33+ai3 *m34;
  9644. outArray[ai3OutOffset+i]=ai0 *m41+ai1 *m42+ai2 *m43+ai3 *m44;
  9645. }
  9646. }
  9647. Utils3D.createAffineTransformationArray=function(tX,tY,tZ,rX,rY,rZ,rW,sX,sY,sZ,outArray,outOffset){
  9648. var x2=rX+rX,y2=rY+rY,z2=rZ+rZ;
  9649. var xx=rX *x2,xy=rX *y2,xz=rX *z2,yy=rY *y2,yz=rY *z2,zz=rZ *z2;
  9650. var wx=rW *x2,wy=rW *y2,wz=rW *z2;
  9651. outArray[outOffset+0]=(1-(yy+zz))*sX;
  9652. outArray[outOffset+1]=(xy+wz)*sX;
  9653. outArray[outOffset+2]=(xz-wy)*sX;
  9654. outArray[outOffset+3]=0;
  9655. outArray[outOffset+4]=(xy-wz)*sY;
  9656. outArray[outOffset+5]=(1-(xx+zz))*sY;
  9657. outArray[outOffset+6]=(yz+wx)*sY;
  9658. outArray[outOffset+7]=0;
  9659. outArray[outOffset+8]=(xz+wy)*sZ;
  9660. outArray[outOffset+9]=(yz-wx)*sZ;
  9661. outArray[outOffset+10]=(1-(xx+yy))*sZ;
  9662. outArray[outOffset+11]=0;
  9663. outArray[outOffset+12]=tX;
  9664. outArray[outOffset+13]=tY;
  9665. outArray[outOffset+14]=tZ;
  9666. outArray[outOffset+15]=1;
  9667. }
  9668. Utils3D.transformVector3ArrayToVector3ArrayCoordinate=function(source,sourceOffset,transform,result,resultOffset){
  9669. var coordinateX=source[sourceOffset+0];
  9670. var coordinateY=source[sourceOffset+1];
  9671. var coordinateZ=source[sourceOffset+2];
  9672. var transformElem=transform.elements;
  9673. var w=((coordinateX *transformElem[3])+(coordinateY *transformElem[7])+(coordinateZ *transformElem[11])+transformElem[15]);
  9674. result[resultOffset]=(coordinateX *transformElem[0])+(coordinateY *transformElem[4])+(coordinateZ *transformElem[8])+transformElem[12] / w;
  9675. result[resultOffset+1]=(coordinateX *transformElem[1])+(coordinateY *transformElem[5])+(coordinateZ *transformElem[9])+transformElem[13] / w;
  9676. result[resultOffset+2]=(coordinateX *transformElem[2])+(coordinateY *transformElem[6])+(coordinateZ *transformElem[10])+transformElem[14] / w;
  9677. }
  9678. Utils3D.transformLightingMapTexcoordArray=function(source,sourceOffset,lightingMapScaleOffset,result,resultOffset){
  9679. result[resultOffset+0]=source[sourceOffset+0] *lightingMapScaleOffset.x+lightingMapScaleOffset.z;
  9680. result[resultOffset+1]=1.0-((1.0-source[sourceOffset+1])*lightingMapScaleOffset.y+lightingMapScaleOffset.w);
  9681. }
  9682. Utils3D.getURLVerion=function(url){
  9683. var index=url.indexOf("?");
  9684. return index >=0 ? url.substr(index):null;
  9685. }
  9686. Utils3D._createAffineTransformationArray=function(trans,rot,scale,outE){
  9687. var x=rot.x,y=rot.y,z=rot.z,w=rot.w,x2=x+x,y2=y+y,z2=z+z;
  9688. var xx=x *x2,xy=x *y2,xz=x *z2,yy=y *y2,yz=y *z2,zz=z *z2;
  9689. var wx=w *x2,wy=w *y2,wz=w *z2,sx=scale.x,sy=scale.y,sz=scale.z;
  9690. outE[0]=(1-(yy+zz))*sx;
  9691. outE[1]=(xy+wz)*sx;
  9692. outE[2]=(xz-wy)*sx;
  9693. outE[3]=0;
  9694. outE[4]=(xy-wz)*sy;
  9695. outE[5]=(1-(xx+zz))*sy;
  9696. outE[6]=(yz+wx)*sy;
  9697. outE[7]=0;
  9698. outE[8]=(xz+wy)*sz;
  9699. outE[9]=(yz-wx)*sz;
  9700. outE[10]=(1-(xx+yy))*sz;
  9701. outE[11]=0;
  9702. outE[12]=trans.x;
  9703. outE[13]=trans.y;
  9704. outE[14]=trans.z;
  9705. outE[15]=1;
  9706. }
  9707. Utils3D._mulMatrixArray=function(leftMatrixE,rightMatrix,outArray,outOffset){
  9708. var i,ai0,ai1,ai2,ai3;
  9709. var rightMatrixE=rightMatrix.elements;
  9710. var m11=rightMatrixE[0],m12=rightMatrixE[1],m13=rightMatrixE[2],m14=rightMatrixE[3];
  9711. var m21=rightMatrixE[4],m22=rightMatrixE[5],m23=rightMatrixE[6],m24=rightMatrixE[7];
  9712. var m31=rightMatrixE[8],m32=rightMatrixE[9],m33=rightMatrixE[10],m34=rightMatrixE[11];
  9713. var m41=rightMatrixE[12],m42=rightMatrixE[13],m43=rightMatrixE[14],m44=rightMatrixE[15];
  9714. var ai0OutOffset=outOffset;
  9715. var ai1OutOffset=outOffset+4;
  9716. var ai2OutOffset=outOffset+8;
  9717. var ai3OutOffset=outOffset+12;
  9718. for (i=0;i < 4;i++){
  9719. ai0=leftMatrixE[i];
  9720. ai1=leftMatrixE[i+4];
  9721. ai2=leftMatrixE[i+8];
  9722. ai3=leftMatrixE[i+12];
  9723. outArray[ai0OutOffset+i]=ai0 *m11+ai1 *m12+ai2 *m13+ai3 *m14;
  9724. outArray[ai1OutOffset+i]=ai0 *m21+ai1 *m22+ai2 *m23+ai3 *m24;
  9725. outArray[ai2OutOffset+i]=ai0 *m31+ai1 *m32+ai2 *m33+ai3 *m34;
  9726. outArray[ai3OutOffset+i]=ai0 *m41+ai1 *m42+ai2 *m43+ai3 *m44;
  9727. }
  9728. }
  9729. Utils3D.arcTanAngle=function(x,y){
  9730. if (x==0){
  9731. if (y==1)
  9732. return Math.PI / 2;
  9733. return-Math.PI / 2;
  9734. }
  9735. if (x > 0)
  9736. return Math.atan(y / x);
  9737. if (x < 0){
  9738. if (y > 0)
  9739. return Math.atan(y / x)+Math.PI;
  9740. return Math.atan(y / x)-Math.PI;
  9741. }
  9742. return 0;
  9743. }
  9744. Utils3D.angleTo=function(from,location,angle){
  9745. Vector3.subtract(location,from,Quaternion.TEMPVector30);
  9746. Vector3.normalize(Quaternion.TEMPVector30,Quaternion.TEMPVector30);
  9747. angle.x=Math.asin(Quaternion.TEMPVector30.y);
  9748. angle.y=Utils3D.arcTanAngle(-Quaternion.TEMPVector30.z,-Quaternion.TEMPVector30.x);
  9749. }
  9750. Utils3D.transformQuat=function(source,rotation,out){
  9751. var re=rotation;
  9752. var x=source.x,y=source.y,z=source.z,qx=re[0],qy=re[1],qz=re[2],qw=re[3],
  9753. ix=qw *x+qy *z-qz *y,iy=qw *y+qz *x-qx *z,iz=qw *z+qx *y-qy *x,iw=-qx *x-qy *y-qz *z;
  9754. out.x=ix *qw+iw *-qx+iy *-qz-iz *-qy;
  9755. out.y=iy *qw+iw *-qy+iz *-qx-ix *-qz;
  9756. out.z=iz *qw+iw *-qz+ix *-qy-iy *-qx;
  9757. }
  9758. Utils3D.quaternionWeight=function(f,weight,e){
  9759. e.x=f.x *weight;
  9760. e.y=f.y *weight;
  9761. e.z=f.z *weight;
  9762. e.w=f.w;
  9763. }
  9764. Utils3D.quaternionConjugate=function(value,result){
  9765. result.x=-value.x;
  9766. result.y=-value.y;
  9767. result.z=-value.z;
  9768. result.w=value.w;
  9769. }
  9770. Utils3D.scaleWeight=function(s,w,out){
  9771. var sX=s.x,sY=s.y,sZ=s.z;
  9772. out.x=sX > 0 ? Math.pow(Math.abs(sX),w):-Math.pow(Math.abs(sX),w);
  9773. out.y=sY > 0 ? Math.pow(Math.abs(sY),w):-Math.pow(Math.abs(sY),w);
  9774. out.z=sZ > 0 ? Math.pow(Math.abs(sZ),w):-Math.pow(Math.abs(sZ),w);
  9775. }
  9776. Utils3D.scaleBlend=function(sa,sb,w,out){
  9777. var saw=Utils3D._tempVector3_0;
  9778. var sbw=Utils3D._tempVector3_1;
  9779. Utils3D.scaleWeight(sa,1.0-w,saw);
  9780. Utils3D.scaleWeight(sb,w,sbw);
  9781. var sng=w > 0.5 ? sb :sa;
  9782. out.x=sng.x > 0 ? Math.abs(saw.x *sbw.x):-Math.abs(saw.x *sbw.x);
  9783. out.y=sng.y > 0 ? Math.abs(saw.y *sbw.y):-Math.abs(saw.y *sbw.y);
  9784. out.z=sng.z > 0 ? Math.abs(saw.z *sbw.z):-Math.abs(saw.z *sbw.z);
  9785. }
  9786. Utils3D.gammaToLinearSpace=function(value){
  9787. if (value <=0.04045)
  9788. return value / 12.92;
  9789. else if (value < 1.0)
  9790. return Math.pow((value+0.055)/ 1.055,2.4);
  9791. else
  9792. return Math.pow(value,2.4);
  9793. }
  9794. Utils3D.linearToGammaSpace=function(value){
  9795. if (value <=0.0)
  9796. return 0.0;
  9797. else if (value <=0.0031308)
  9798. return 12.92 *value;
  9799. else if (value <=1.0)
  9800. return 1.055 *Math.pow(value,0.41666)-0.055;
  9801. else
  9802. return Math.pow(value,0.41666);
  9803. }
  9804. Utils3D.matrix4x4MultiplyFFF=function(a,b,e){
  9805. var i,ai0,ai1,ai2,ai3;
  9806. if (e===b){
  9807. b=new Float32Array(16);
  9808. for (i=0;i < 16;++i){
  9809. b[i]=e[i];
  9810. }
  9811. };
  9812. var b0=b[0],b1=b[1],b2=b[2],b3=b[3];
  9813. var b4=b[4],b5=b[5],b6=b[6],b7=b[7];
  9814. var b8=b[8],b9=b[9],b10=b[10],b11=b[11];
  9815. var b12=b[12],b13=b[13],b14=b[14],b15=b[15];
  9816. for (i=0;i < 4;i++){
  9817. ai0=a[i];
  9818. ai1=a[i+4];
  9819. ai2=a[i+8];
  9820. ai3=a[i+12];
  9821. e[i]=ai0 *b0+ai1 *b1+ai2 *b2+ai3 *b3;
  9822. e[i+4]=ai0 *b4+ai1 *b5+ai2 *b6+ai3 *b7;
  9823. e[i+8]=ai0 *b8+ai1 *b9+ai2 *b10+ai3 *b11;
  9824. e[i+12]=ai0 *b12+ai1 *b13+ai2 *b14+ai3 *b15;
  9825. }
  9826. }
  9827. Utils3D.matrix4x4MultiplyFFFForNative=function(a,b,e){
  9828. LayaGL.instance.matrix4x4Multiply(a,b,e);
  9829. }
  9830. Utils3D.matrix4x4MultiplyMFM=function(left,right,out){
  9831. Utils3D.matrix4x4MultiplyFFF(left.elements,right,out.elements);
  9832. }
  9833. Utils3D._buildTexture2D=function(width,height,format,colorFunc,mipmaps){
  9834. (mipmaps===void 0)&& (mipmaps=false);
  9835. var texture=new Texture2D(width,height,format,mipmaps,true);
  9836. texture.anisoLevel=1;
  9837. texture.filterMode=/*laya.resource.BaseTexture.FILTERMODE_POINT*/0;
  9838. TextureGenerator._generateTexture2D(texture,width,height,colorFunc);
  9839. return texture;
  9840. }
  9841. Utils3D._drawBound=function(debugLine,boundBox,color){
  9842. if (debugLine.lineCount+12 > debugLine.maxLineCount)
  9843. debugLine.maxLineCount+=12;
  9844. var start=Utils3D._tempVector3_0;
  9845. var end=Utils3D._tempVector3_1;
  9846. var min=boundBox.min;
  9847. var max=boundBox.max;
  9848. start.setValue(min.x,min.y,min.z);
  9849. end.setValue(max.x,min.y,min.z);
  9850. debugLine.addLine(start,end,color,color);
  9851. start.setValue(min.x,min.y,min.z);
  9852. end.setValue(min.x,min.y,max.z);
  9853. debugLine.addLine(start,end,color,color);
  9854. start.setValue(max.x,min.y,min.z);
  9855. end.setValue(max.x,min.y,max.z);
  9856. debugLine.addLine(start,end,color,color);
  9857. start.setValue(min.x,min.y,max.z);
  9858. end.setValue(max.x,min.y,max.z);
  9859. debugLine.addLine(start,end,color,color);
  9860. start.setValue(min.x,min.y,min.z);
  9861. end.setValue(min.x,max.y,min.z);
  9862. debugLine.addLine(start,end,color,color);
  9863. start.setValue(min.x,min.y,max.z);
  9864. end.setValue(min.x,max.y,max.z);
  9865. debugLine.addLine(start,end,color,color);
  9866. start.setValue(max.x,min.y,min.z);
  9867. end.setValue(max.x,max.y,min.z);
  9868. debugLine.addLine(start,end,color,color);
  9869. start.setValue(max.x,min.y,max.z);
  9870. end.setValue(max.x,max.y,max.z);
  9871. debugLine.addLine(start,end,color,color);
  9872. start.setValue(min.x,max.y,min.z);
  9873. end.setValue(max.x,max.y,min.z);
  9874. debugLine.addLine(start,end,color,color);
  9875. start.setValue(min.x,max.y,min.z);
  9876. end.setValue(min.x,max.y,max.z);
  9877. debugLine.addLine(start,end,color,color);
  9878. start.setValue(max.x,max.y,min.z);
  9879. end.setValue(max.x,max.y,max.z);
  9880. debugLine.addLine(start,end,color,color);
  9881. start.setValue(min.x,max.y,max.z);
  9882. end.setValue(max.x,max.y,max.z);
  9883. debugLine.addLine(start,end,color,color);
  9884. }
  9885. Utils3D._getHierarchyPath=function(rootSprite,checkSprite,path){
  9886. path.length=0;
  9887. var sprite=checkSprite;
  9888. while (sprite!==rootSprite){
  9889. var parent=sprite._parent;
  9890. if (parent)
  9891. path.push(parent.getChildIndex(sprite));
  9892. else
  9893. return null;
  9894. sprite=parent;
  9895. }
  9896. return path;
  9897. }
  9898. Utils3D._getNodeByHierarchyPath=function(rootSprite,invPath){
  9899. var sprite=rootSprite;
  9900. for (var i=invPath.length-1;i >=0;i--){
  9901. sprite=sprite.getChildAt(invPath[i]);
  9902. }
  9903. return sprite;
  9904. }
  9905. Utils3D._createNodeByJson=function(nodeData,outBatchSprites){
  9906. var node;
  9907. switch (nodeData.type){
  9908. case "Scene3D":
  9909. node=new Scene3D();
  9910. break ;
  9911. case "Sprite3D":
  9912. node=new Sprite3D();
  9913. break ;
  9914. case "MeshSprite3D":
  9915. node=new MeshSprite3D();
  9916. (outBatchSprites)&& (outBatchSprites.push(node));
  9917. break ;
  9918. case "SkinnedMeshSprite3D":
  9919. node=new SkinnedMeshSprite3D();
  9920. break ;
  9921. case "ShuriKenParticle3D":
  9922. node=new ShuriKenParticle3D();
  9923. break ;
  9924. case "Terrain":
  9925. node=new Terrain();
  9926. break ;
  9927. case "Camera":
  9928. node=new Camera();
  9929. break ;
  9930. case "DirectionLight":
  9931. node=new DirectionLight();
  9932. break ;
  9933. case "PointLight":
  9934. node=new PointLight();
  9935. break ;
  9936. case "SpotLight":
  9937. node=new SpotLight();
  9938. break ;
  9939. case "TrailSprite3D":
  9940. node=new TrailSprite3D();
  9941. break ;
  9942. default :
  9943. throw new Error("Utils3D:unidentified class type in (.lh) file.");
  9944. };
  9945. var childData=nodeData.child;
  9946. if (childData){
  9947. for (var i=0,n=childData.length;i < n;i++){
  9948. var child=Utils3D._createNodeByJson(childData[i],outBatchSprites)
  9949. node.addChild(child);
  9950. }
  9951. };
  9952. var componentsData=nodeData.components;
  9953. if (componentsData){
  9954. for (var j=0,m=componentsData.length;j < m;j++){
  9955. var data=componentsData[j];
  9956. clas=Browser.window.Laya[data.type];
  9957. if (!clas){
  9958. var clasPaths=data.type.split('.');
  9959. var clas=Browser.window;
  9960. clasPaths.forEach(function(cls){
  9961. clas=clas[cls];
  9962. });
  9963. }
  9964. if (typeof(clas)=='function'){
  9965. var component=node.addComponent(clas);
  9966. component._parse(data);
  9967. }else {
  9968. console.warn("Unkown component type.");
  9969. }
  9970. }
  9971. }
  9972. node._parse(nodeData.props,null);
  9973. return node;
  9974. }
  9975. Utils3D._tempArray16_0=new Float32Array(16);
  9976. Utils3D._tempArray16_1=new Float32Array(16);
  9977. Utils3D._tempArray16_2=new Float32Array(16);
  9978. Utils3D._tempArray16_3=new Float32Array(16);
  9979. __static(Utils3D,
  9980. ['_tempVector3_0',function(){return this._tempVector3_0=new Vector3();},'_tempVector3_1',function(){return this._tempVector3_1=new Vector3();},'_tempVector3_2',function(){return this._tempVector3_2=new Vector3();},'_tempColor0',function(){return this._tempColor0=new Color();},'_compIdToNode',function(){return this._compIdToNode=new Object();}
  9981. ]);
  9982. return Utils3D;
  9983. })()
  9984. /**
  9985. *<code>GradientDataNumber</code> 类用于创建浮点渐变。
  9986. */
  9987. //class laya.d3.core.particleShuriKen.module.GradientDataNumber
  9988. var GradientDataNumber=(function(){
  9989. function GradientDataNumber(){
  9990. /**@private */
  9991. this._currentLength=0;
  9992. /**@private 开发者禁止修改。*/
  9993. this._elements=null;
  9994. this._elements=new Float32Array(8);
  9995. }
  9996. __class(GradientDataNumber,'laya.d3.core.particleShuriKen.module.GradientDataNumber');
  9997. var __proto=GradientDataNumber.prototype;
  9998. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  9999. /**
  10000. *增加浮点渐变。
  10001. *@param key 生命周期,范围为0到1。
  10002. *@param value 浮点值。
  10003. */
  10004. __proto.add=function(key,value){
  10005. if (this._currentLength < 8){
  10006. if ((this._currentLength===6)&& ((key!==1))){
  10007. key=1;
  10008. console.log("GradientDataNumber warning:the forth key is be force set to 1.");
  10009. }
  10010. this._elements[this._currentLength++]=key;
  10011. this._elements[this._currentLength++]=value;
  10012. }else {
  10013. console.log("GradientDataNumber warning:data count must lessEqual than 4");
  10014. }
  10015. }
  10016. /**
  10017. *通过索引获取键。
  10018. *@param index 索引。
  10019. *@return value 键。
  10020. */
  10021. __proto.getKeyByIndex=function(index){
  10022. return this._elements[index *2];
  10023. }
  10024. /**
  10025. *通过索引获取值。
  10026. *@param index 索引。
  10027. *@return value 值。
  10028. */
  10029. __proto.getValueByIndex=function(index){
  10030. return this._elements[index *2+1];
  10031. }
  10032. /**
  10033. *获取平均值。
  10034. */
  10035. __proto.getAverageValue=function(){
  10036. var total=0;
  10037. for (var i=0,n=this._currentLength-2;i < n;i+=2){
  10038. var subValue=this._elements[i+1];
  10039. subValue+=this._elements[i+3];
  10040. subValue=subValue *(this._elements[i+2]-this._elements[i]);
  10041. }
  10042. return total / 2;
  10043. }
  10044. /**
  10045. *克隆。
  10046. *@param destObject 克隆源。
  10047. */
  10048. __proto.cloneTo=function(destObject){
  10049. var destGradientDataNumber=destObject;
  10050. destGradientDataNumber._currentLength=this._currentLength;
  10051. var destElements=destGradientDataNumber._elements;
  10052. destElements.length=this._elements.length;
  10053. for (var i=0,n=this._elements.length;i < n;i++)
  10054. destElements[i]=this._elements[i];
  10055. }
  10056. /**
  10057. *克隆。
  10058. *@return 克隆副本。
  10059. */
  10060. __proto.clone=function(){
  10061. var destGradientDataNumber=/*__JS__ */new this.constructor();
  10062. this.cloneTo(destGradientDataNumber);
  10063. return destGradientDataNumber;
  10064. }
  10065. /**渐变浮点数量。*/
  10066. __getset(0,__proto,'gradientCount',function(){
  10067. return this._currentLength / 2;
  10068. });
  10069. return GradientDataNumber;
  10070. })()
  10071. /**
  10072. *...
  10073. *@author
  10074. */
  10075. //class laya.d3.core.pixelLine.PixelLineVertex
  10076. var PixelLineVertex=(function(){
  10077. function PixelLineVertex(){}
  10078. __class(PixelLineVertex,'laya.d3.core.pixelLine.PixelLineVertex');
  10079. var __proto=PixelLineVertex.prototype;
  10080. __getset(0,__proto,'vertexDeclaration',function(){
  10081. return PixelLineVertex._vertexDeclaration;
  10082. });
  10083. __getset(1,PixelLineVertex,'vertexDeclaration',function(){
  10084. return PixelLineVertex._vertexDeclaration;
  10085. });
  10086. __static(PixelLineVertex,
  10087. ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(28,
  10088. [new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0),
  10089. new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexMesh.MESH_COLOR0*/1)]);}
  10090. ]);
  10091. return PixelLineVertex;
  10092. })()
  10093. /**
  10094. *<code>CollisionMap</code> 类用于实现碰撞组合实例图。
  10095. */
  10096. //class laya.d3.physics.CollisionTool
  10097. var CollisionTool=(function(){
  10098. function CollisionTool(){
  10099. /**@private */
  10100. this._hitResultsPoolIndex=0;
  10101. /**@private */
  10102. this._contactPonintsPoolIndex=0;
  10103. /**@private */
  10104. this._collisions={};
  10105. this._hitResultsPool=[];
  10106. this._contactPointsPool=[];
  10107. this._collisionsPool=[];
  10108. }
  10109. __class(CollisionTool,'laya.d3.physics.CollisionTool');
  10110. var __proto=CollisionTool.prototype;
  10111. /**
  10112. *@private
  10113. */
  10114. __proto.getHitResult=function(){
  10115. var hitResult=this._hitResultsPool[this._hitResultsPoolIndex++];
  10116. if (!hitResult){
  10117. hitResult=new HitResult();
  10118. this._hitResultsPool.push(hitResult);
  10119. }
  10120. return hitResult;
  10121. }
  10122. /**
  10123. *@private
  10124. */
  10125. __proto.recoverAllHitResultsPool=function(){
  10126. this._hitResultsPoolIndex=0;
  10127. }
  10128. /**
  10129. *@private
  10130. */
  10131. __proto.getContactPoints=function(){
  10132. var contactPoint=this._contactPointsPool[this._contactPonintsPoolIndex++];
  10133. if (!contactPoint){
  10134. contactPoint=new ContactPoint();
  10135. this._contactPointsPool.push(contactPoint);
  10136. }
  10137. return contactPoint;
  10138. }
  10139. /**
  10140. *@private
  10141. */
  10142. __proto.recoverAllContactPointsPool=function(){
  10143. this._contactPonintsPoolIndex=0;
  10144. }
  10145. /**
  10146. *@private
  10147. */
  10148. __proto.getCollision=function(physicComponentA,physicComponentB){
  10149. var collision;
  10150. var idA=physicComponentA.id;
  10151. var idB=physicComponentB.id;
  10152. var subCollisionFirst=this._collisions[idA];
  10153. if (subCollisionFirst)
  10154. collision=subCollisionFirst[idB];
  10155. if (!collision){
  10156. if (!subCollisionFirst){
  10157. subCollisionFirst={};
  10158. this._collisions[idA]=subCollisionFirst;
  10159. }
  10160. collision=this._collisionsPool.length===0 ? new Collision():this._collisionsPool.pop();
  10161. collision._colliderA=physicComponentA;
  10162. collision._colliderB=physicComponentB;
  10163. subCollisionFirst[idB]=collision;
  10164. }
  10165. return collision;
  10166. }
  10167. /**
  10168. *@private
  10169. */
  10170. __proto.recoverCollision=function(collision){
  10171. var idA=collision._colliderA.id;
  10172. var idB=collision._colliderB.id;
  10173. this._collisions[idA][idB]=null;
  10174. this._collisionsPool.push(collision);
  10175. }
  10176. /**
  10177. *@private
  10178. */
  10179. __proto.garbageCollection=function(){
  10180. this._hitResultsPoolIndex=0;
  10181. this._hitResultsPool.length=0;
  10182. this._contactPonintsPoolIndex=0;
  10183. this._contactPointsPool.length=0;
  10184. this._collisionsPool.length=0;
  10185. for (var subCollisionsKey in this._collisionsPool){
  10186. var subCollisions=this._collisionsPool[subCollisionsKey];
  10187. var wholeDelete=true;
  10188. for (var collisionKey in subCollisions){
  10189. if (subCollisions[collisionKey])
  10190. wholeDelete=false;
  10191. else
  10192. delete subCollisions[collisionKey];
  10193. }
  10194. if (wholeDelete)
  10195. delete this._collisionsPool[subCollisionsKey];
  10196. }
  10197. }
  10198. return CollisionTool;
  10199. })()
  10200. /**
  10201. *<code>Input3D</code> 类用于实现3D输入。
  10202. */
  10203. //class laya.d3.Input3D
  10204. var Input3D=(function(){
  10205. function Input3D(){
  10206. /**@private */
  10207. this._scene=null;
  10208. /**@private */
  10209. this._eventList=[];
  10210. /**@private */
  10211. this._multiTouchEnabled=true;
  10212. this._mouseTouch=new MouseTouch();
  10213. this._touchPool=[];
  10214. this._touches=new SimpleSingletonList();
  10215. }
  10216. __class(Input3D,'laya.d3.Input3D');
  10217. var __proto=Input3D.prototype;
  10218. /**
  10219. *@private
  10220. */
  10221. __proto.__init__=function(canvas,scene){
  10222. this._scene=scene;
  10223. var list=this._eventList;
  10224. canvas.oncontextmenu=function (e){
  10225. return false;
  10226. }
  10227. canvas.addEventListener('mousedown',function(e){
  10228. e.preventDefault();
  10229. list.push(e);
  10230. });
  10231. canvas.addEventListener('mouseup',function(e){
  10232. e.preventDefault();
  10233. list.push(e);
  10234. },true);
  10235. canvas.addEventListener('mousemove',function(e){
  10236. e.preventDefault();
  10237. list.push(e);
  10238. },true);
  10239. canvas.addEventListener("touchstart",function(e){
  10240. e.preventDefault();
  10241. list.push(e);
  10242. });
  10243. canvas.addEventListener("touchend",function(e){
  10244. e.preventDefault();
  10245. list.push(e);
  10246. },true);
  10247. canvas.addEventListener("touchmove",function(e){
  10248. e.preventDefault();
  10249. list.push(e);
  10250. },true);
  10251. canvas.addEventListener("touchcancel",function(e){
  10252. list.push(e);
  10253. },true);
  10254. }
  10255. /**
  10256. *获取触摸点个数。
  10257. *@return 触摸点个数。
  10258. */
  10259. __proto.touchCount=function(){
  10260. return this._touches.length;
  10261. }
  10262. /**
  10263. *@private
  10264. */
  10265. __proto._getTouch=function(touchID){
  10266. var touch=this._touchPool[touchID];
  10267. if (!touch){
  10268. touch=new Touch();
  10269. this._touchPool[touchID]=touch;
  10270. touch._identifier=touchID;
  10271. }
  10272. return touch;
  10273. }
  10274. /**
  10275. *@private
  10276. */
  10277. __proto._mouseTouchDown=function(){
  10278. var touch=this._mouseTouch;
  10279. var sprite=touch.sprite;
  10280. touch._pressedSprite=sprite;
  10281. touch._pressedLoopCount=Stat.loopCount;
  10282. if (sprite){
  10283. var scripts=sprite._scripts;
  10284. if (scripts){
  10285. for (var i=0,n=scripts.length;i < n;i++)
  10286. scripts[i].onMouseDown();
  10287. }
  10288. }
  10289. }
  10290. /**
  10291. *@private
  10292. */
  10293. __proto._mouseTouchUp=function(){
  10294. var i=0,n=0;
  10295. var touch=this._mouseTouch;
  10296. var lastPressedSprite=touch._pressedSprite;
  10297. touch._pressedSprite=null;
  10298. touch._pressedLoopCount=-1;
  10299. var sprite=touch.sprite;
  10300. if (sprite){
  10301. if (sprite===lastPressedSprite){
  10302. var scripts=sprite._scripts;
  10303. if (scripts){
  10304. for (i=0,n=scripts.length;i < n;i++)
  10305. scripts[i].onMouseClick();
  10306. }
  10307. }
  10308. }
  10309. if (lastPressedSprite){
  10310. var lastScripts=lastPressedSprite._scripts;
  10311. if (lastScripts){
  10312. for (i=0,n=lastScripts.length;i < n;i++)
  10313. lastScripts[i].onMouseUp();
  10314. }
  10315. }
  10316. }
  10317. /**
  10318. *@private
  10319. */
  10320. __proto._mouseTouchRayCast=function(cameras){
  10321. var touchHitResult=Input3D._tempHitResult0;
  10322. var touchPos=Input3D._tempVector20;
  10323. var touchRay=Input3D._tempRay0;
  10324. touchHitResult.succeeded=false;
  10325. var x=this._mouseTouch.mousePositionX;
  10326. var y=this._mouseTouch.mousePositionY;
  10327. touchPos.x=x;
  10328. touchPos.y=y;
  10329. for (var i=cameras.length-1;i >=0;i--){
  10330. var camera=cameras [i];
  10331. var viewport=camera.viewport;
  10332. if (touchPos.x >=viewport.x && touchPos.y >=viewport.y && touchPos.x <=viewport.width && touchPos.y <=viewport.height){
  10333. camera.viewportPointToRay(touchPos,touchRay);
  10334. var sucess=this._scene._physicsSimulation.rayCast(touchRay,touchHitResult);
  10335. if (sucess || (camera.clearFlag===/*laya.d3.core.BaseCamera.CLEARFLAG_SOLIDCOLOR*/0 || camera.clearFlag===/*laya.d3.core.BaseCamera.CLEARFLAG_SKY*/1))
  10336. break ;
  10337. }
  10338. };
  10339. var touch=this._mouseTouch;
  10340. var lastSprite=touch.sprite;
  10341. if (touchHitResult.succeeded){
  10342. var touchSprite=touchHitResult.collider.owner;
  10343. touch.sprite=touchSprite;
  10344. var scripts=touchSprite._scripts;
  10345. if (lastSprite!==touchSprite){
  10346. if (scripts){
  10347. for (var j=0,m=scripts.length;j < m;j++)
  10348. scripts[j].onMouseEnter();
  10349. }
  10350. }
  10351. }else {
  10352. touch.sprite=null;
  10353. }
  10354. if (lastSprite && (lastSprite!==touchSprite)){
  10355. var outScripts=lastSprite._scripts;
  10356. if (outScripts){
  10357. for (j=0,m=outScripts.length;j < m;j++)
  10358. outScripts[j].onMouseOut();
  10359. }
  10360. }
  10361. }
  10362. /**
  10363. *@private
  10364. *@param flag 0:add、1:remove、2:change
  10365. */
  10366. __proto._changeTouches=function(changedTouches,flag){
  10367. var offsetX=0,offsetY=0;
  10368. var lastCount=this._touches.length;
  10369. for (var j=0,m=changedTouches.length;j < m;j++){
  10370. var nativeTouch=changedTouches[j];
  10371. var identifier=nativeTouch.identifier;
  10372. if (!this._multiTouchEnabled && identifier!==0)
  10373. continue ;
  10374. var touch=this._getTouch(identifier);
  10375. var pos=touch._position;
  10376. var mousePoint=Input3D._tempPoint;
  10377. mousePoint.setTo(nativeTouch.pageX,nativeTouch.pageY);
  10378. Laya.stage._canvasTransform.invertTransformPoint(mousePoint);
  10379. var posX=mousePoint.x;
  10380. var posY=mousePoint.y;
  10381. switch (flag){
  10382. case 0:
  10383. this._touches.add(touch);
  10384. offsetX+=posX;
  10385. offsetY+=posY;
  10386. break ;
  10387. case 1:
  10388. this._touches.remove(touch);
  10389. offsetX-=posX;
  10390. offsetY-=posY;
  10391. break ;
  10392. case 2:
  10393. offsetX=posX-pos.x;
  10394. offsetY=posY-pos.y;
  10395. break ;
  10396. }
  10397. pos.x=posX;
  10398. pos.y=posY;
  10399. };
  10400. var touchCount=this._touches.length;
  10401. if (touchCount===0){
  10402. this._mouseTouch.mousePositionX=0;
  10403. this._mouseTouch.mousePositionY=0;
  10404. }else {
  10405. this._mouseTouch.mousePositionX=(this._mouseTouch.mousePositionX *lastCount+offsetX)/ touchCount;
  10406. this._mouseTouch.mousePositionY=(this._mouseTouch.mousePositionY *lastCount+offsetY)/ touchCount;
  10407. }
  10408. }
  10409. /**
  10410. *@private
  10411. */
  10412. __proto._update=function(){
  10413. var i=0,n=0,j=0,m=0;
  10414. n=this._eventList.length;
  10415. var cameras=this._scene._cameraPool;
  10416. if (n > 0){
  10417. for (i=0;i < n;i++){
  10418. var e=this._eventList[i];
  10419. switch (e.type){
  10420. case "mousedown":
  10421. this._mouseTouchDown();
  10422. break ;
  10423. case "mouseup":
  10424. this._mouseTouchUp();
  10425. break ;
  10426. case "mousemove":;
  10427. var mousePoint=Input3D._tempPoint;
  10428. mousePoint.setTo(e.pageX,e.pageY);
  10429. Laya.stage._canvasTransform.invertTransformPoint(mousePoint);
  10430. this._mouseTouch.mousePositionX=mousePoint.x;
  10431. this._mouseTouch.mousePositionY=mousePoint.y;
  10432. this._mouseTouchRayCast(cameras);
  10433. break ;
  10434. case "touchstart":;
  10435. var lastLength=this._touches.length;
  10436. this._changeTouches(e.changedTouches,0);
  10437. this._mouseTouchRayCast(cameras);
  10438. (lastLength===0)&& (this._mouseTouchDown());
  10439. break ;
  10440. case "touchend":
  10441. case "touchcancel":
  10442. this._changeTouches(e.changedTouches,1);
  10443. (this._touches.length===0)&& (this._mouseTouchUp());
  10444. break ;
  10445. case "touchmove":
  10446. this._changeTouches(e.changedTouches,2);
  10447. this._mouseTouchRayCast(cameras);
  10448. break ;
  10449. default :
  10450. throw "Input3D:unkonwn event type.";
  10451. }
  10452. }
  10453. this._eventList.length=0;
  10454. };
  10455. var mouseTouch=this._mouseTouch;
  10456. var pressedSprite=mouseTouch._pressedSprite;
  10457. if (pressedSprite && (Stat.loopCount > mouseTouch._pressedLoopCount)){
  10458. var pressedScripts=pressedSprite._scripts;
  10459. if (pressedScripts){
  10460. for (j=0,m=pressedScripts.length;j < m;j++)
  10461. pressedScripts[j].onMouseDrag();
  10462. }
  10463. };
  10464. var touchSprite=mouseTouch.sprite;
  10465. if (touchSprite){
  10466. var scripts=touchSprite._scripts;
  10467. if (scripts){
  10468. for (j=0,m=scripts.length;j < m;j++)
  10469. scripts[j].onMouseOver();
  10470. }
  10471. }
  10472. }
  10473. /**
  10474. *获取触摸点。
  10475. *@param index 索引。
  10476. *@return 触摸点。
  10477. */
  10478. __proto.getTouch=function(index){
  10479. if (index < this._touches.length){
  10480. return this._touches.elements [index];
  10481. }else {
  10482. return null;
  10483. }
  10484. }
  10485. /**
  10486. *设置是否可以使用多点触摸。
  10487. *@param 是否可以使用多点触摸。
  10488. */
  10489. /**
  10490. *获取是否可以使用多点触摸。
  10491. *@return 是否可以使用多点触摸。
  10492. */
  10493. __getset(0,__proto,'multiTouchEnabled',function(){
  10494. return this._multiTouchEnabled;
  10495. },function(value){
  10496. this._multiTouchEnabled=value;
  10497. });
  10498. __static(Input3D,
  10499. ['_tempPoint',function(){return this._tempPoint=new Point();},'_tempVector20',function(){return this._tempVector20=new Vector2();},'_tempRay0',function(){return this._tempRay0=new Ray(new Vector3(),new Vector3());},'_tempHitResult0',function(){return this._tempHitResult0=new HitResult();}
  10500. ]);
  10501. return Input3D;
  10502. })()
  10503. /**
  10504. *@private
  10505. */
  10506. //class laya.d3.core.particleShuriKen.ShurikenParticleData
  10507. var ShurikenParticleData=(function(){
  10508. function ShurikenParticleData(){}
  10509. __class(ShurikenParticleData,'laya.d3.core.particleShuriKen.ShurikenParticleData');
  10510. ShurikenParticleData._getStartLifetimeFromGradient=function(startLifeTimeGradient,emissionTime){
  10511. for (var i=1,n=startLifeTimeGradient.gradientCount;i < n;i++){
  10512. var key=startLifeTimeGradient.getKeyByIndex(i);
  10513. if (key >=emissionTime){
  10514. var lastKey=startLifeTimeGradient.getKeyByIndex(i-1);
  10515. var age=(emissionTime-lastKey)/ (key-lastKey);
  10516. return MathUtil.lerp(startLifeTimeGradient.getValueByIndex(i-1),startLifeTimeGradient.getValueByIndex(i),age)
  10517. }
  10518. }
  10519. throw new Error("ShurikenParticleData: can't get value foam startLifeTimeGradient.");
  10520. }
  10521. ShurikenParticleData._randomInvertRoationArray=function(rotatonE,outE,randomizeRotationDirection,rand,randomSeeds){
  10522. var randDic=NaN;
  10523. if (rand){
  10524. rand.seed=randomSeeds[6];
  10525. randDic=rand.getFloat();
  10526. randomSeeds[6]=rand.seed;
  10527. }else {
  10528. randDic=Math.random();
  10529. }
  10530. if (randDic < randomizeRotationDirection){
  10531. outE.x=-rotatonE.x;
  10532. outE.y=-rotatonE.y;
  10533. outE.z=-rotatonE.z;
  10534. }else {
  10535. outE.x=rotatonE.x;
  10536. outE.y=rotatonE.y;
  10537. outE.z=rotatonE.z;
  10538. }
  10539. }
  10540. ShurikenParticleData._randomInvertRoation=function(rotaton,randomizeRotationDirection,rand,randomSeeds){
  10541. var randDic=NaN;
  10542. if (rand){
  10543. rand.seed=randomSeeds[6];
  10544. randDic=rand.getFloat();
  10545. randomSeeds[6]=rand.seed;
  10546. }else {
  10547. randDic=Math.random();
  10548. }
  10549. if (randDic < randomizeRotationDirection)
  10550. rotaton=-rotaton;
  10551. return rotaton;
  10552. }
  10553. ShurikenParticleData.create=function(particleSystem,particleRender,transform){
  10554. var autoRandomSeed=particleSystem.autoRandomSeed;
  10555. var rand=particleSystem._rand;
  10556. var randomSeeds=particleSystem._randomSeeds;
  10557. switch (particleSystem.startColorType){
  10558. case 0:;
  10559. var constantStartColor=particleSystem.startColorConstant;
  10560. ShurikenParticleData.startColor.x=constantStartColor.x;
  10561. ShurikenParticleData.startColor.y=constantStartColor.y;
  10562. ShurikenParticleData.startColor.z=constantStartColor.z;
  10563. ShurikenParticleData.startColor.w=constantStartColor.w;
  10564. break ;
  10565. case 2:
  10566. if (autoRandomSeed){
  10567. Vector4.lerp(particleSystem.startColorConstantMin,particleSystem.startColorConstantMax,Math.random(),ShurikenParticleData.startColor);
  10568. }else {
  10569. rand.seed=randomSeeds[3];
  10570. Vector4.lerp(particleSystem.startColorConstantMin,particleSystem.startColorConstantMax,rand.getFloat(),ShurikenParticleData.startColor);
  10571. randomSeeds[3]=rand.seed;
  10572. }
  10573. break ;
  10574. };
  10575. var colorOverLifetime=particleSystem.colorOverLifetime;
  10576. if (colorOverLifetime && colorOverLifetime.enbale){
  10577. var color=colorOverLifetime.color;
  10578. switch (color.type){
  10579. case 0:
  10580. ShurikenParticleData.startColor.x=ShurikenParticleData.startColor.x *color.constant.x;
  10581. ShurikenParticleData.startColor.y=ShurikenParticleData.startColor.y *color.constant.y;
  10582. ShurikenParticleData.startColor.z=ShurikenParticleData.startColor.z *color.constant.z;
  10583. ShurikenParticleData.startColor.w=ShurikenParticleData.startColor.w *color.constant.w;
  10584. break ;
  10585. case 2:;
  10586. var colorRandom=NaN;
  10587. if (autoRandomSeed){
  10588. colorRandom=Math.random();
  10589. }else {
  10590. rand.seed=randomSeeds[10];
  10591. colorRandom=rand.getFloat();
  10592. randomSeeds[10]=rand.seed;
  10593. };
  10594. var minConstantColor=color.constantMin;
  10595. var maxConstantColor=color.constantMax;
  10596. ShurikenParticleData.startColor.x=ShurikenParticleData.startColor.x *MathUtil.lerp(minConstantColor.x,maxConstantColor.x,colorRandom);
  10597. ShurikenParticleData.startColor.y=ShurikenParticleData.startColor.y *MathUtil.lerp(minConstantColor.y,maxConstantColor.y,colorRandom);
  10598. ShurikenParticleData.startColor.z=ShurikenParticleData.startColor.z *MathUtil.lerp(minConstantColor.z,maxConstantColor.z,colorRandom);
  10599. ShurikenParticleData.startColor.w=ShurikenParticleData.startColor.w *MathUtil.lerp(minConstantColor.w,maxConstantColor.w,colorRandom);
  10600. break ;
  10601. }
  10602. };
  10603. var particleSize=ShurikenParticleData.startSize;
  10604. switch (particleSystem.startSizeType){
  10605. case 0:
  10606. if (particleSystem.threeDStartSize){
  10607. var startSizeConstantSeparate=particleSystem.startSizeConstantSeparate;
  10608. particleSize[0]=startSizeConstantSeparate.x;
  10609. particleSize[1]=startSizeConstantSeparate.y;
  10610. particleSize[2]=startSizeConstantSeparate.z;
  10611. }else {
  10612. particleSize[0]=particleSize[1]=particleSize[2]=particleSystem.startSizeConstant;
  10613. }
  10614. break ;
  10615. case 2:
  10616. if (particleSystem.threeDStartSize){
  10617. var startSizeConstantMinSeparate=particleSystem.startSizeConstantMinSeparate;
  10618. var startSizeConstantMaxSeparate=particleSystem.startSizeConstantMaxSeparate;
  10619. if (autoRandomSeed){
  10620. particleSize[0]=MathUtil.lerp(startSizeConstantMinSeparate.x,startSizeConstantMaxSeparate.x,Math.random());
  10621. particleSize[1]=MathUtil.lerp(startSizeConstantMinSeparate.y,startSizeConstantMaxSeparate.y,Math.random());
  10622. particleSize[2]=MathUtil.lerp(startSizeConstantMinSeparate.z,startSizeConstantMaxSeparate.z,Math.random());
  10623. }else {
  10624. rand.seed=randomSeeds[4];
  10625. particleSize[0]=MathUtil.lerp(startSizeConstantMinSeparate.x,startSizeConstantMaxSeparate.x,rand.getFloat());
  10626. particleSize[1]=MathUtil.lerp(startSizeConstantMinSeparate.y,startSizeConstantMaxSeparate.y,rand.getFloat());
  10627. particleSize[2]=MathUtil.lerp(startSizeConstantMinSeparate.z,startSizeConstantMaxSeparate.z,rand.getFloat());
  10628. randomSeeds[4]=rand.seed;
  10629. }
  10630. }else {
  10631. if (autoRandomSeed){
  10632. particleSize[0]=particleSize[1]=particleSize[2]=MathUtil.lerp(particleSystem.startSizeConstantMin,particleSystem.startSizeConstantMax,Math.random());
  10633. }else {
  10634. rand.seed=randomSeeds[4];
  10635. particleSize[0]=particleSize[1]=particleSize[2]=MathUtil.lerp(particleSystem.startSizeConstantMin,particleSystem.startSizeConstantMax,rand.getFloat());
  10636. randomSeeds[4]=rand.seed;
  10637. }
  10638. }
  10639. break ;
  10640. };
  10641. var sizeOverLifetime=particleSystem.sizeOverLifetime;
  10642. if (sizeOverLifetime && sizeOverLifetime.enbale && sizeOverLifetime.size.type===1){
  10643. var size=sizeOverLifetime.size;
  10644. if (size.separateAxes){
  10645. if (autoRandomSeed){
  10646. particleSize[0]=particleSize[0] *MathUtil.lerp(size.constantMinSeparate.x,size.constantMaxSeparate.x,Math.random());
  10647. particleSize[1]=particleSize[1] *MathUtil.lerp(size.constantMinSeparate.y,size.constantMaxSeparate.y,Math.random());
  10648. particleSize[2]=particleSize[2] *MathUtil.lerp(size.constantMinSeparate.z,size.constantMaxSeparate.z,Math.random());
  10649. }else {
  10650. rand.seed=randomSeeds[11];
  10651. particleSize[0]=particleSize[0] *MathUtil.lerp(size.constantMinSeparate.x,size.constantMaxSeparate.x,rand.getFloat());
  10652. particleSize[1]=particleSize[1] *MathUtil.lerp(size.constantMinSeparate.y,size.constantMaxSeparate.y,rand.getFloat());
  10653. particleSize[2]=particleSize[2] *MathUtil.lerp(size.constantMinSeparate.z,size.constantMaxSeparate.z,rand.getFloat());
  10654. randomSeeds[11]=rand.seed;
  10655. }
  10656. }else {
  10657. var randomSize=NaN;
  10658. if (autoRandomSeed){
  10659. randomSize=MathUtil.lerp(size.constantMin,size.constantMax,Math.random());
  10660. }else {
  10661. rand.seed=randomSeeds[11];
  10662. randomSize=MathUtil.lerp(size.constantMin,size.constantMax,rand.getFloat());
  10663. randomSeeds[11]=rand.seed;
  10664. }
  10665. particleSize[0]=particleSize[0] *randomSize;
  10666. particleSize[1]=particleSize[1] *randomSize;
  10667. particleSize[2]=particleSize[2] *randomSize;
  10668. }
  10669. };
  10670. var renderMode=particleRender.renderMode;
  10671. if (renderMode!==1){
  10672. switch (particleSystem.startRotationType){
  10673. case 0:
  10674. if (particleSystem.threeDStartRotation){
  10675. var startRotationConstantSeparate=particleSystem.startRotationConstantSeparate;
  10676. var randomRotationE=ShurikenParticleData._tempVector30;
  10677. ShurikenParticleData._randomInvertRoationArray(startRotationConstantSeparate,randomRotationE,particleSystem.randomizeRotationDirection,autoRandomSeed ? null :rand,randomSeeds);
  10678. ShurikenParticleData.startRotation[0]=randomRotationE.x;
  10679. ShurikenParticleData.startRotation[1]=randomRotationE.y;
  10680. if (renderMode!==4)
  10681. ShurikenParticleData.startRotation[2]=-randomRotationE.z;
  10682. else
  10683. ShurikenParticleData.startRotation[2]=randomRotationE.z;
  10684. }else {
  10685. ShurikenParticleData.startRotation[0]=ShurikenParticleData._randomInvertRoation(particleSystem.startRotationConstant,particleSystem.randomizeRotationDirection,autoRandomSeed ? null :rand,randomSeeds);
  10686. ShurikenParticleData.startRotation[1]=0;
  10687. ShurikenParticleData.startRotation[2]=0;
  10688. }
  10689. break ;
  10690. case 2:
  10691. if (particleSystem.threeDStartRotation){
  10692. var startRotationConstantMinSeparate=particleSystem.startRotationConstantMinSeparate;
  10693. var startRotationConstantMaxSeparate=particleSystem.startRotationConstantMaxSeparate;
  10694. var lerpRoationE=ShurikenParticleData._tempVector30;
  10695. if (autoRandomSeed){
  10696. lerpRoationE.x=MathUtil.lerp(startRotationConstantMinSeparate.x,startRotationConstantMaxSeparate.x,Math.random());
  10697. lerpRoationE.y=MathUtil.lerp(startRotationConstantMinSeparate.y,startRotationConstantMaxSeparate.y,Math.random());
  10698. lerpRoationE.z=MathUtil.lerp(startRotationConstantMinSeparate.z,startRotationConstantMaxSeparate.z,Math.random());
  10699. }else {
  10700. rand.seed=randomSeeds[5];
  10701. lerpRoationE.x=MathUtil.lerp(startRotationConstantMinSeparate.x,startRotationConstantMaxSeparate.x,rand.getFloat());
  10702. lerpRoationE.y=MathUtil.lerp(startRotationConstantMinSeparate.y,startRotationConstantMaxSeparate.y,rand.getFloat());
  10703. lerpRoationE.z=MathUtil.lerp(startRotationConstantMinSeparate.z,startRotationConstantMaxSeparate.z,rand.getFloat());
  10704. randomSeeds[5]=rand.seed;
  10705. }
  10706. ShurikenParticleData._randomInvertRoationArray(lerpRoationE,lerpRoationE,particleSystem.randomizeRotationDirection,autoRandomSeed ? null :rand,randomSeeds);
  10707. ShurikenParticleData.startRotation[0]=lerpRoationE.x;
  10708. ShurikenParticleData.startRotation[1]=lerpRoationE.y;
  10709. if (renderMode!==4)
  10710. ShurikenParticleData.startRotation[2]=-lerpRoationE.z;
  10711. else
  10712. ShurikenParticleData.startRotation[2]=lerpRoationE.z;
  10713. }else {
  10714. if (autoRandomSeed){
  10715. ShurikenParticleData.startRotation[0]=ShurikenParticleData._randomInvertRoation(MathUtil.lerp(particleSystem.startRotationConstantMin,particleSystem.startRotationConstantMax,Math.random()),particleSystem.randomizeRotationDirection,autoRandomSeed ? null :rand,randomSeeds);
  10716. }else {
  10717. rand.seed=randomSeeds[5];
  10718. ShurikenParticleData.startRotation[0]=ShurikenParticleData._randomInvertRoation(MathUtil.lerp(particleSystem.startRotationConstantMin,particleSystem.startRotationConstantMax,rand.getFloat()),particleSystem.randomizeRotationDirection,autoRandomSeed ? null :rand,randomSeeds);
  10719. randomSeeds[5]=rand.seed;
  10720. }
  10721. }
  10722. break ;
  10723. }
  10724. }
  10725. switch (particleSystem.startLifetimeType){
  10726. case 0:
  10727. ShurikenParticleData.startLifeTime=particleSystem.startLifetimeConstant;
  10728. break ;
  10729. case 1:
  10730. ShurikenParticleData.startLifeTime=ShurikenParticleData._getStartLifetimeFromGradient(particleSystem.startLifeTimeGradient,particleSystem.emissionTime);
  10731. break ;
  10732. case 2:
  10733. if (autoRandomSeed){
  10734. ShurikenParticleData.startLifeTime=MathUtil.lerp(particleSystem.startLifetimeConstantMin,particleSystem.startLifetimeConstantMax,Math.random());
  10735. }else {
  10736. rand.seed=randomSeeds[7];
  10737. ShurikenParticleData.startLifeTime=MathUtil.lerp(particleSystem.startLifetimeConstantMin,particleSystem.startLifetimeConstantMax,rand.getFloat());
  10738. randomSeeds[7]=rand.seed;
  10739. }
  10740. break ;
  10741. case 3:;
  10742. var emissionTime=particleSystem.emissionTime;
  10743. if (autoRandomSeed){
  10744. ShurikenParticleData.startLifeTime=MathUtil.lerp(ShurikenParticleData._getStartLifetimeFromGradient(particleSystem.startLifeTimeGradientMin,emissionTime),ShurikenParticleData._getStartLifetimeFromGradient(particleSystem.startLifeTimeGradientMax,emissionTime),Math.random());
  10745. }else {
  10746. rand.seed=randomSeeds[7];
  10747. ShurikenParticleData.startLifeTime=MathUtil.lerp(ShurikenParticleData._getStartLifetimeFromGradient(particleSystem.startLifeTimeGradientMin,emissionTime),ShurikenParticleData._getStartLifetimeFromGradient(particleSystem.startLifeTimeGradientMax,emissionTime),rand.getFloat());
  10748. randomSeeds[7]=rand.seed;
  10749. }
  10750. break ;
  10751. }
  10752. switch (particleSystem.startSpeedType){
  10753. case 0:
  10754. ShurikenParticleData.startSpeed=particleSystem.startSpeedConstant;
  10755. break ;
  10756. case 2:
  10757. if (autoRandomSeed){
  10758. ShurikenParticleData.startSpeed=MathUtil.lerp(particleSystem.startSpeedConstantMin,particleSystem.startSpeedConstantMax,Math.random());
  10759. }else {
  10760. rand.seed=randomSeeds[8];
  10761. ShurikenParticleData.startSpeed=MathUtil.lerp(particleSystem.startSpeedConstantMin,particleSystem.startSpeedConstantMax,rand.getFloat());
  10762. randomSeeds[8]=rand.seed;
  10763. }
  10764. break ;
  10765. };
  10766. var textureSheetAnimation=particleSystem.textureSheetAnimation;
  10767. var enableSheetAnimation=textureSheetAnimation && textureSheetAnimation.enable;
  10768. if (enableSheetAnimation){
  10769. var title=textureSheetAnimation.tiles;
  10770. var titleX=title.x,titleY=title.y;
  10771. var subU=1.0 / titleX,subV=1.0 / titleY;
  10772. var startFrameCount=0;
  10773. var startFrame=textureSheetAnimation.startFrame;
  10774. switch (startFrame.type){
  10775. case 0:
  10776. startFrameCount=startFrame.constant;
  10777. break ;
  10778. case 1:
  10779. if (autoRandomSeed){
  10780. startFrameCount=MathUtil.lerp(startFrame.constantMin,startFrame.constantMax,Math.random());
  10781. }else {
  10782. rand.seed=randomSeeds[14];
  10783. startFrameCount=MathUtil.lerp(startFrame.constantMin,startFrame.constantMax,rand.getFloat());
  10784. randomSeeds[14]=rand.seed;
  10785. }
  10786. break ;
  10787. };
  10788. var frame=textureSheetAnimation.frame;
  10789. switch (frame.type){
  10790. case 0:
  10791. startFrameCount+=frame.constant;
  10792. break ;
  10793. case 2:
  10794. if (autoRandomSeed){
  10795. startFrameCount+=MathUtil.lerp(frame.constantMin,frame.constantMax,Math.random());
  10796. }else {
  10797. rand.seed=randomSeeds[15];
  10798. startFrameCount+=MathUtil.lerp(frame.constantMin,frame.constantMax,rand.getFloat());
  10799. randomSeeds[15]=rand.seed;
  10800. }
  10801. break ;
  10802. };
  10803. var startRow=0;
  10804. switch (textureSheetAnimation.type){
  10805. case 0:
  10806. startRow=Math.floor(startFrameCount / titleX);
  10807. break ;
  10808. case 1:
  10809. if (textureSheetAnimation.randomRow){
  10810. if (autoRandomSeed){
  10811. startRow=Math.floor(Math.random()*titleY);
  10812. }else {
  10813. rand.seed=randomSeeds[13];
  10814. startRow=Math.floor(rand.getFloat()*titleY);
  10815. randomSeeds[13]=rand.seed;
  10816. }
  10817. }else {
  10818. startRow=textureSheetAnimation.rowIndex;
  10819. }
  10820. break ;
  10821. };
  10822. var startCol=Math.floor(startFrameCount % titleX);
  10823. ShurikenParticleData.startUVInfo=ShurikenParticleData.startUVInfo;
  10824. ShurikenParticleData.startUVInfo[0]=subU;
  10825. ShurikenParticleData.startUVInfo[1]=subV;
  10826. ShurikenParticleData.startUVInfo[2]=startCol *subU;
  10827. ShurikenParticleData.startUVInfo[3]=startRow *subV;
  10828. }else {
  10829. ShurikenParticleData.startUVInfo=ShurikenParticleData.startUVInfo;
  10830. ShurikenParticleData.startUVInfo[0]=1.0;
  10831. ShurikenParticleData.startUVInfo[1]=1.0;
  10832. ShurikenParticleData.startUVInfo[2]=0.0;
  10833. ShurikenParticleData.startUVInfo[3]=0.0;
  10834. }
  10835. switch (particleSystem.simulationSpace){
  10836. case 0:;
  10837. var position=transform.position;
  10838. ShurikenParticleData.simulationWorldPostion[0]=position.x;
  10839. ShurikenParticleData.simulationWorldPostion[1]=position.y;
  10840. ShurikenParticleData.simulationWorldPostion[2]=position.z;
  10841. var rotation=transform.rotation;
  10842. ShurikenParticleData.simulationWorldRotation[0]=rotation.x;
  10843. ShurikenParticleData.simulationWorldRotation[1]=rotation.y;
  10844. ShurikenParticleData.simulationWorldRotation[2]=rotation.z;
  10845. ShurikenParticleData.simulationWorldRotation[3]=rotation.w;
  10846. break ;
  10847. case 1:
  10848. break ;
  10849. default :
  10850. throw new Error("ShurikenParticleMaterial: SimulationSpace value is invalid.");
  10851. break ;
  10852. }
  10853. }
  10854. ShurikenParticleData.startLifeTime=NaN;
  10855. ShurikenParticleData.startSpeed=NaN;
  10856. __static(ShurikenParticleData,
  10857. ['_tempVector30',function(){return this._tempVector30=new Vector3();},'_tempQuaternion',function(){return this._tempQuaternion=new Quaternion();},'startColor',function(){return this.startColor=new Vector4();},'startSize',function(){return this.startSize=new Float32Array(3);},'startRotation',function(){return this.startRotation=new Float32Array(3);},'startUVInfo',function(){return this.startUVInfo=new Float32Array(4);},'simulationWorldPostion',function(){return this.simulationWorldPostion=new Float32Array(3);},'simulationWorldRotation',function(){return this.simulationWorldRotation=new Float32Array(4);}
  10858. ]);
  10859. return ShurikenParticleData;
  10860. })()
  10861. /**
  10862. *<code>BoundsOctreeNode</code> 类用于创建八叉树节点。
  10863. */
  10864. //class laya.d3.core.scene.BoundsOctreeNode
  10865. var BoundsOctreeNode=(function(){
  10866. function BoundsOctreeNode(octree,parent,baseLength,center){
  10867. /**@private */
  10868. this._octree=null;
  10869. /**@private */
  10870. this._parent=null;
  10871. /**@private */
  10872. this._children=null;
  10873. /**@private [Debug]*/
  10874. this._isContaion=false;
  10875. /**@private [只读]*/
  10876. this.baseLength=0.0;
  10877. this._bounds=new BoundBox(new Vector3(),new Vector3());
  10878. this._objects=[];
  10879. this.center=new Vector3();
  10880. this._setValues(octree,parent,baseLength,center);
  10881. }
  10882. __class(BoundsOctreeNode,'laya.d3.core.scene.BoundsOctreeNode');
  10883. var __proto=BoundsOctreeNode.prototype;
  10884. /**
  10885. *@private
  10886. */
  10887. __proto._setValues=function(octree,parent,baseLength,center){
  10888. this._octree=octree;
  10889. this._parent=parent;
  10890. this.baseLength=baseLength;
  10891. center.cloneTo(this.center);
  10892. var min=this._bounds.min;
  10893. var max=this._bounds.max;
  10894. var halfSize=(octree._looseness *baseLength)/ 2;
  10895. min.setValue(center.x-halfSize,center.y-halfSize,center.z-halfSize);
  10896. max.setValue(center.x+halfSize,center.y+halfSize,center.z+halfSize);
  10897. }
  10898. /**
  10899. *@private
  10900. */
  10901. __proto._getChildBound=function(index){
  10902. if (this._children !=null && this._children[index]){
  10903. return this._children[index]._bounds;
  10904. }else {
  10905. var quarter=this.baseLength / 4;
  10906. var halfChildSize=((this.baseLength / 2)*this._octree._looseness)/ 2;
  10907. var bounds=BoundsOctreeNode._tempBoundBox;
  10908. var min=bounds.min;
  10909. var max=bounds.max;
  10910. switch (index){
  10911. case 0:
  10912. min.x=this.center.x-quarter-halfChildSize;
  10913. min.y=this.center.y+quarter-halfChildSize;
  10914. min.z=this.center.z-quarter-halfChildSize;
  10915. max.x=this.center.x-quarter+halfChildSize;
  10916. max.y=this.center.y+quarter+halfChildSize;
  10917. max.z=this.center.z-quarter+halfChildSize;
  10918. break ;
  10919. case 1:
  10920. min.x=this.center.x+quarter-halfChildSize;
  10921. min.y=this.center.y+quarter-halfChildSize;
  10922. min.z=this.center.z-quarter-halfChildSize;
  10923. max.x=this.center.x+quarter+halfChildSize;
  10924. max.y=this.center.y+quarter+halfChildSize;
  10925. max.z=this.center.z-quarter+halfChildSize;
  10926. break ;
  10927. case 2:
  10928. min.x=this.center.x-quarter-halfChildSize;
  10929. min.y=this.center.y+quarter-halfChildSize;
  10930. min.z=this.center.z+quarter-halfChildSize;
  10931. max.x=this.center.x-quarter+halfChildSize;
  10932. max.y=this.center.y+quarter+halfChildSize;
  10933. max.z=this.center.z+quarter+halfChildSize;
  10934. break ;
  10935. case 3:
  10936. min.x=this.center.x+quarter-halfChildSize;
  10937. min.y=this.center.y+quarter-halfChildSize;
  10938. min.z=this.center.z+quarter-halfChildSize;
  10939. max.x=this.center.x+quarter+halfChildSize;
  10940. max.y=this.center.y+quarter+halfChildSize;
  10941. max.z=this.center.z+quarter+halfChildSize;
  10942. break ;
  10943. case 4:
  10944. min.x=this.center.x-quarter-halfChildSize;
  10945. min.y=this.center.y-quarter-halfChildSize;
  10946. min.z=this.center.z-quarter-halfChildSize;
  10947. max.x=this.center.x-quarter+halfChildSize;
  10948. max.y=this.center.y-quarter+halfChildSize;
  10949. max.z=this.center.z-quarter+halfChildSize;
  10950. break ;
  10951. case 5:
  10952. min.x=this.center.x+quarter-halfChildSize;
  10953. min.y=this.center.y-quarter-halfChildSize;
  10954. min.z=this.center.z-quarter-halfChildSize;
  10955. max.x=this.center.x+quarter+halfChildSize;
  10956. max.y=this.center.y-quarter+halfChildSize;
  10957. max.z=this.center.z-quarter+halfChildSize;
  10958. break ;
  10959. case 6:
  10960. min.x=this.center.x-quarter-halfChildSize;
  10961. min.y=this.center.y-quarter-halfChildSize;
  10962. min.z=this.center.z+quarter-halfChildSize;
  10963. max.x=this.center.x-quarter+halfChildSize;
  10964. max.y=this.center.y-quarter+halfChildSize;
  10965. max.z=this.center.z+quarter+halfChildSize;
  10966. break ;
  10967. case 7:
  10968. min.x=this.center.x+quarter-halfChildSize;
  10969. min.y=this.center.y-quarter-halfChildSize;
  10970. min.z=this.center.z+quarter-halfChildSize;
  10971. max.x=this.center.x+quarter+halfChildSize;
  10972. max.y=this.center.y-quarter+halfChildSize;
  10973. max.z=this.center.z+quarter+halfChildSize;
  10974. break ;
  10975. default :
  10976. }
  10977. return bounds;
  10978. }
  10979. }
  10980. /**
  10981. *@private
  10982. */
  10983. __proto._getChildCenter=function(index){
  10984. if (this._children !=null){
  10985. return this._children[index].center;
  10986. }else {
  10987. var quarter=this.baseLength / 4;
  10988. var childCenter=BoundsOctreeNode._tempVector30;
  10989. switch (index){
  10990. case 0:
  10991. childCenter.x=this.center.x-quarter;
  10992. childCenter.y=this.center.y+quarter;
  10993. childCenter.z=this.center.z-quarter;
  10994. break ;
  10995. case 1:
  10996. childCenter.x=this.center.x+quarter;
  10997. childCenter.y=this.center.y+quarter;
  10998. childCenter.z=this.center.z-quarter;
  10999. break ;
  11000. case 2:
  11001. childCenter.x=this.center.x-quarter;
  11002. childCenter.y=this.center.y+quarter;
  11003. childCenter.z=this.center.z+quarter;
  11004. break ;
  11005. case 3:
  11006. childCenter.x=this.center.x+quarter;
  11007. childCenter.y=this.center.y+quarter;
  11008. childCenter.z=this.center.z+quarter;
  11009. break ;
  11010. case 4:
  11011. childCenter.x=this.center.x-quarter;
  11012. childCenter.y=this.center.y-quarter;
  11013. childCenter.z=this.center.z-quarter;
  11014. break ;
  11015. case 5:
  11016. childCenter.x=this.center.x+quarter;
  11017. childCenter.y=this.center.y-quarter;
  11018. childCenter.z=this.center.z-quarter;
  11019. break ;
  11020. case 6:
  11021. childCenter.x=this.center.x-quarter;
  11022. childCenter.y=this.center.y-quarter;
  11023. childCenter.z=this.center.z+quarter;
  11024. break ;
  11025. case 7:
  11026. childCenter.x=this.center.x+quarter;
  11027. childCenter.y=this.center.y-quarter;
  11028. childCenter.z=this.center.z+quarter;
  11029. break ;
  11030. default :
  11031. }
  11032. return childCenter;
  11033. }
  11034. }
  11035. /**
  11036. *@private
  11037. */
  11038. __proto._getChild=function(index){
  11039. var quarter=this.baseLength / 4;
  11040. this._children || (this._children=__newvec(8,null));
  11041. switch (index){
  11042. case 0:
  11043. return this._children[0] || (this._children[0]=new BoundsOctreeNode(this._octree,this,this.baseLength / 2,new Vector3(this.center.x+-quarter,this.center.y+quarter,this.center.z-quarter)));
  11044. case 1:
  11045. return this._children[1] || (this._children[1]=new BoundsOctreeNode(this._octree,this,this.baseLength / 2,new Vector3(this.center.x+quarter,this.center.y+quarter,this.center.z-quarter)));
  11046. case 2:
  11047. return this._children[2] || (this._children[2]=new BoundsOctreeNode(this._octree,this,this.baseLength / 2,new Vector3(this.center.x-quarter,this.center.y+quarter,this.center.z+quarter)));
  11048. case 3:
  11049. return this._children[3] || (this._children[3]=new BoundsOctreeNode(this._octree,this,this.baseLength / 2,new Vector3(this.center.x+quarter,this.center.y+quarter,this.center.z+quarter)));
  11050. case 4:
  11051. return this._children[4] || (this._children[4]=new BoundsOctreeNode(this._octree,this,this.baseLength / 2,new Vector3(this.center.x-quarter,this.center.y-quarter,this.center.z-quarter)));
  11052. case 5:
  11053. return this._children[5] || (this._children[5]=new BoundsOctreeNode(this._octree,this,this.baseLength / 2,new Vector3(this.center.x+quarter,this.center.y-quarter,this.center.z-quarter)));
  11054. case 6:
  11055. return this._children[6] || (this._children[6]=new BoundsOctreeNode(this._octree,this,this.baseLength / 2,new Vector3(this.center.x-quarter,this.center.y-quarter,this.center.z+quarter)));
  11056. case 7:
  11057. return this._children[7] || (this._children[7]=new BoundsOctreeNode(this._octree,this,this.baseLength / 2,new Vector3(this.center.x+quarter,this.center.y-quarter,this.center.z+quarter)));
  11058. default :
  11059. throw "BoundsOctreeNode: unknown index.";
  11060. }
  11061. }
  11062. /**
  11063. *@private
  11064. *是否合并判断(如果该节点和子节点包含的物体小于_NUM_OBJECTS_ALLOWED则应将子节点合并到该节点)
  11065. */
  11066. __proto._shouldMerge=function(){
  11067. var objectCount=this._objects.length;
  11068. for (var i=0;i < 8;i++){
  11069. var child=this._children[i];
  11070. if (child){
  11071. if (child._children !=null)
  11072. return false;
  11073. objectCount+=child._objects.length;
  11074. }
  11075. }
  11076. return objectCount <=8;
  11077. }
  11078. /**
  11079. *@private
  11080. */
  11081. __proto._mergeChildren=function(){
  11082. for (var i=0;i < 8;i++){
  11083. var child=this._children[i];
  11084. if (child){
  11085. child._parent=null;
  11086. var childObjects=child._objects;
  11087. for (var j=childObjects.length-1;j >=0;j--){
  11088. var childObject=childObjects[j];
  11089. this._objects.push(childObject);
  11090. childObject._setOctreeNode(this);
  11091. }
  11092. }
  11093. }
  11094. this._children=null;
  11095. }
  11096. /**
  11097. *@private
  11098. */
  11099. __proto._merge=function(){
  11100. if (this._children===null){
  11101. var parent=this._parent;
  11102. if (parent && parent._shouldMerge()){
  11103. parent._mergeChildren();
  11104. parent._merge();
  11105. }
  11106. }
  11107. }
  11108. /**
  11109. *@private
  11110. */
  11111. __proto._checkAddNode=function(object){
  11112. if (this._children==null){
  11113. if (this._objects.length < 8 || (this.baseLength / 2)< this._octree._minSize){
  11114. return this;
  11115. }
  11116. for (var i=this._objects.length-1;i >=0;i--){
  11117. var existObject=this._objects[i];
  11118. var fitChildIndex=this._bestFitChild(existObject.bounds.getCenter());
  11119. if (BoundsOctreeNode._encapsulates(this._getChildBound(fitChildIndex),existObject.bounds._getBoundBox())){
  11120. this._objects.splice(this._objects.indexOf(existObject),1);
  11121. this._getChild(fitChildIndex)._add(existObject);
  11122. }
  11123. }
  11124. };
  11125. var newFitChildIndex=this._bestFitChild(object.bounds.getCenter());
  11126. if (BoundsOctreeNode._encapsulates(this._getChildBound(newFitChildIndex),object.bounds._getBoundBox()))
  11127. return this._getChild(newFitChildIndex)._checkAddNode(object);
  11128. else
  11129. return this;
  11130. }
  11131. /**
  11132. *@private
  11133. */
  11134. __proto._add=function(object){
  11135. var addNode=this._checkAddNode(object);
  11136. addNode._objects.push(object);
  11137. object._setOctreeNode(addNode);
  11138. }
  11139. /**
  11140. *@private
  11141. */
  11142. __proto._remove=function(object){
  11143. var index=this._objects.indexOf(object);
  11144. this._objects.splice(index,1);
  11145. object._setOctreeNode(null);
  11146. this._merge();
  11147. }
  11148. /**
  11149. *@private
  11150. */
  11151. __proto._addUp=function(object){
  11152. if ((CollisionUtils.boxContainsBox(this._bounds,object.bounds._getBoundBox())===/*laya.d3.math.ContainmentType.Contains*/1)){
  11153. this._add(object);
  11154. return true;
  11155. }else {
  11156. if (this._parent)
  11157. return this._parent._addUp(object);
  11158. else
  11159. return false;
  11160. }
  11161. }
  11162. /**
  11163. *@private
  11164. */
  11165. __proto._getCollidingWithFrustum=function(context,frustum,testVisible,camPos){
  11166. if (testVisible){
  11167. var type=frustum.containsBoundBox(this._bounds);
  11168. Stat.octreeNodeCulling++;
  11169. if (type===/*laya.d3.math.ContainmentType.Disjoint*/0)
  11170. return;
  11171. testVisible=(type===/*laya.d3.math.ContainmentType.Intersects*/2);
  11172. }
  11173. this._isContaion=!testVisible;
  11174. var camera=context.camera;
  11175. var scene=context.scene;
  11176. for (var i=0,n=this._objects.length;i < n;i++){
  11177. var render=this._objects [i];
  11178. if (camera._isLayerVisible(render._owner.layer)&& render._enable){
  11179. if (testVisible){
  11180. Stat.frustumCulling++;
  11181. if (!render._needRender(frustum))
  11182. continue ;
  11183. }
  11184. render._distanceForSort=Vector3.distance(render.bounds.getCenter(),camPos);
  11185. var elements=render._renderElements;
  11186. for (var j=0,m=elements.length;j < m;j++){
  11187. var element=elements[j];
  11188. var renderQueue=scene._getRenderQueue(element.material.renderQueue);
  11189. if (renderQueue.isTransparent)
  11190. element.addToTransparentRenderQueue(context,renderQueue);
  11191. else
  11192. element.addToOpaqueRenderQueue(context,renderQueue);
  11193. }
  11194. }
  11195. }
  11196. if (this._children !=null){
  11197. for (i=0;i < 8;i++){
  11198. var child=this._children[i];
  11199. child && child._getCollidingWithFrustum(context,frustum,testVisible,camPos);
  11200. }
  11201. }
  11202. }
  11203. /**
  11204. *@private
  11205. */
  11206. __proto._getCollidingWithBoundBox=function(checkBound,testVisible,result){
  11207. if (testVisible){
  11208. var type=CollisionUtils.boxContainsBox(this._bounds,checkBound);
  11209. if (type===/*laya.d3.math.ContainmentType.Disjoint*/0)
  11210. return;
  11211. testVisible=(type===/*laya.d3.math.ContainmentType.Intersects*/2);
  11212. }
  11213. if (testVisible){
  11214. for (var i=0,n=this._objects.length;i < n;i++){
  11215. var object=this._objects[i];
  11216. if (CollisionUtils.intersectsBoxAndBox(object.bounds._getBoundBox(),checkBound)){
  11217. result.push(object);
  11218. }
  11219. }
  11220. }
  11221. if (this._children !=null){
  11222. for (i=0;i < 8;i++){
  11223. var child=this._children[i];
  11224. child._getCollidingWithBoundBox(checkBound,testVisible,result);
  11225. }
  11226. }
  11227. }
  11228. /**
  11229. *@private
  11230. */
  11231. __proto._bestFitChild=function(boundCenter){
  11232. return (boundCenter.x <=this.center.x ? 0 :1)+(boundCenter.y >=this.center.y ? 0 :4)+(boundCenter.z <=this.center.z ? 0 :2);
  11233. }
  11234. /**
  11235. *@private
  11236. *@return 是否需要扩充根节点
  11237. */
  11238. __proto._update=function(object){
  11239. if (CollisionUtils.boxContainsBox(this._bounds,object.bounds._getBoundBox())===/*laya.d3.math.ContainmentType.Contains*/1){
  11240. var addNode=this._checkAddNode(object);
  11241. if (addNode!==object._getOctreeNode()){
  11242. addNode._objects.push(object);
  11243. object._setOctreeNode(addNode);
  11244. var index=this._objects.indexOf(object);
  11245. this._objects.splice(index,1);
  11246. this._merge();
  11247. }
  11248. return true;
  11249. }else {
  11250. if (this._parent){
  11251. var sucess=this._parent._addUp(object);
  11252. if (sucess){
  11253. index=this._objects.indexOf(object);
  11254. this._objects.splice(index,1);
  11255. this._merge();
  11256. }
  11257. return sucess;
  11258. }else {
  11259. return false;
  11260. }
  11261. }
  11262. }
  11263. /**
  11264. *添加指定物体。
  11265. *@param object 指定物体。
  11266. */
  11267. __proto.add=function(object){
  11268. if (!BoundsOctreeNode._encapsulates(this._bounds,object.bounds._getBoundBox()))
  11269. return false;
  11270. this._add(object);
  11271. return true;
  11272. }
  11273. /**
  11274. *移除指定物体。
  11275. *@param obejct 指定物体。
  11276. *@return 是否成功。
  11277. */
  11278. __proto.remove=function(object){
  11279. if (object._getOctreeNode()!==this)
  11280. return false;
  11281. this._remove(object);
  11282. return true;
  11283. }
  11284. /**
  11285. *更新制定物体,
  11286. *@param obejct 指定物体。
  11287. *@return 是否成功。
  11288. */
  11289. __proto.update=function(object){
  11290. if (object._getOctreeNode()!==this)
  11291. return false;
  11292. return this._update(object);
  11293. }
  11294. /**
  11295. *收缩八叉树节点。
  11296. *-所有物体都在根节点的八分之一区域
  11297. *-该节点无子节点或有子节点但1/8的子节点不包含物体
  11298. *@param minLength 最小尺寸。
  11299. *@return 新的根节点。
  11300. */
  11301. __proto.shrinkIfPossible=function(minLength){
  11302. if (this.baseLength < minLength *2)
  11303. return this;
  11304. var bestFit=-1;
  11305. for (var i=0,n=this._objects.length;i < n;i++){
  11306. var object=this._objects[i];
  11307. var newBestFit=this._bestFitChild(object.bounds.getCenter());
  11308. if (i==0 || newBestFit==bestFit){
  11309. var childBounds=this._getChildBound(newBestFit);
  11310. if (BoundsOctreeNode._encapsulates(childBounds,object.bounds._getBoundBox()))
  11311. (i==0)&& (bestFit=newBestFit);
  11312. else
  11313. return this;
  11314. }else {
  11315. return this;
  11316. }
  11317. }
  11318. if (this._children !=null){
  11319. var childHadContent=false;
  11320. for (i=0,n=this._children.length;i < n;i++){
  11321. var child=this._children[i];
  11322. if (child && child.hasAnyObjects()){
  11323. if (childHadContent)
  11324. return this;
  11325. if (bestFit >=0 && bestFit !=i)
  11326. return this;
  11327. childHadContent=true;
  11328. bestFit=i;
  11329. }
  11330. }
  11331. }else {
  11332. if (bestFit !=-1){
  11333. var childCenter=this._getChildCenter(bestFit);
  11334. this._setValues(this._octree,null,this.baseLength / 2,childCenter);
  11335. }
  11336. return this;
  11337. }
  11338. if (bestFit !=-1){
  11339. var newRoot=this._children[bestFit];
  11340. newRoot._parent=null;
  11341. return newRoot;
  11342. }else {
  11343. return this;
  11344. }
  11345. }
  11346. /**
  11347. *检查该节点和其子节点是否包含任意物体。
  11348. *@return 是否包含任意物体。
  11349. */
  11350. __proto.hasAnyObjects=function(){
  11351. if (this._objects.length > 0)
  11352. return true;
  11353. if (this._children !=null){
  11354. for (var i=0;i < 8;i++){
  11355. var child=this._children[i];
  11356. if (child && child.hasAnyObjects())
  11357. return true;
  11358. }
  11359. }
  11360. return false;
  11361. }
  11362. /**
  11363. *获取与指定包围盒相交的物体列表。
  11364. *@param checkBound AABB包围盒。
  11365. *@param result 相交物体列表
  11366. */
  11367. __proto.getCollidingWithBoundBox=function(checkBound,result){
  11368. this._getCollidingWithBoundBox(checkBound,true,result);
  11369. }
  11370. /**
  11371. *获取与指定射线相交的的物理列表。
  11372. *@param ray 射线。
  11373. *@param result 相交物体列表。
  11374. *@param maxDistance 射线的最大距离。
  11375. */
  11376. __proto.getCollidingWithRay=function(ray,result,maxDistance){
  11377. (maxDistance===void 0)&& (maxDistance=Number.MAX_VALUE);
  11378. var distance=CollisionUtils.intersectsRayAndBoxRD(ray,this._bounds);
  11379. if (distance==-1 || distance > maxDistance)
  11380. return;
  11381. for (var i=0,n=this._objects.length;i < n;i++){
  11382. var object=this._objects[i];
  11383. distance=CollisionUtils.intersectsRayAndBoxRD(ray,object.bounds._getBoundBox());
  11384. if (distance!==-1 && distance <=maxDistance)
  11385. result.push(object);
  11386. }
  11387. if (this._children !=null){
  11388. for (i=0;i < 8;i++){
  11389. var child=this._children[i];
  11390. child.getCollidingWithRay(ray,result,maxDistance);
  11391. }
  11392. }
  11393. }
  11394. /**
  11395. *获取与指定视锥相交的的物理列表。
  11396. *@param ray 射线。.
  11397. *@param result 相交物体列表。
  11398. */
  11399. __proto.getCollidingWithFrustum=function(context){
  11400. var cameraPos=context.camera.transform.position;
  11401. var boundFrustum=(context.camera).boundFrustum;
  11402. this._getCollidingWithFrustum(context,boundFrustum,true,cameraPos);
  11403. }
  11404. /**
  11405. *获取是否与指定包围盒相交。
  11406. *@param checkBound AABB包围盒。
  11407. *@return 是否相交。
  11408. */
  11409. __proto.isCollidingWithBoundBox=function(checkBound){
  11410. if (!(CollisionUtils.intersectsBoxAndBox(this._bounds,checkBound)))
  11411. return false;
  11412. for (var i=0,n=this._objects.length;i < n;i++){
  11413. var object=this._objects[i];
  11414. if (CollisionUtils.intersectsBoxAndBox(object.bounds._getBoundBox(),checkBound))
  11415. return true;
  11416. }
  11417. if (this._children !=null){
  11418. for (i=0;i < 8;i++){
  11419. var child=this._children[i];
  11420. if (child.isCollidingWithBoundBox(checkBound))
  11421. return true;
  11422. }
  11423. }
  11424. return false;
  11425. }
  11426. /**
  11427. *获取是否与指定射线相交。
  11428. *@param ray 射线。
  11429. *@param maxDistance 射线的最大距离。
  11430. *@return 是否相交。
  11431. */
  11432. __proto.isCollidingWithRay=function(ray,maxDistance){
  11433. (maxDistance===void 0)&& (maxDistance=Number.MAX_VALUE);
  11434. var distance=CollisionUtils.intersectsRayAndBoxRD(ray,this._bounds);
  11435. if (distance==-1 || distance > maxDistance)
  11436. return false;
  11437. for (var i=0,n=this._objects.length;i < n;i++){
  11438. var object=this._objects[i];
  11439. distance=CollisionUtils.intersectsRayAndBoxRD(ray,object.bounds._getBoundBox());
  11440. if (distance!==-1 && distance <=maxDistance)
  11441. return true;
  11442. }
  11443. if (this._children !=null){
  11444. for (i=0;i < 8;i++){
  11445. var child=this._children[i];
  11446. if (child.isCollidingWithRay(ray,maxDistance))
  11447. return true;
  11448. }
  11449. }
  11450. return false;
  11451. }
  11452. /**
  11453. *获取包围盒。
  11454. */
  11455. __proto.getBound=function(){
  11456. return this._bounds;
  11457. }
  11458. /**
  11459. *@private
  11460. *[Debug]
  11461. */
  11462. __proto.drawAllBounds=function(debugLine,currentDepth,maxDepth){
  11463. if (this._children===null && this._objects.length==0)
  11464. return;
  11465. currentDepth++;
  11466. var color=BoundsOctreeNode._tempColor0;
  11467. if (this._isContaion){
  11468. color.r=0.0;
  11469. color.g=0.0;
  11470. color.b=1.0;
  11471. }else {
  11472. var tint=maxDepth ? currentDepth / maxDepth :0;
  11473. color.r=1.0-tint;
  11474. color.g=tint;
  11475. color.b=0.0;
  11476. }
  11477. color.a=0.3;
  11478. Utils3D._drawBound(debugLine,this._bounds,color);
  11479. if (this._children !=null){
  11480. for (var i=0;i < 8;i++){
  11481. var child=this._children[i];
  11482. child && child.drawAllBounds(debugLine,currentDepth,maxDepth);
  11483. }
  11484. }
  11485. }
  11486. /**
  11487. *@private
  11488. *[Debug]
  11489. */
  11490. __proto.drawAllObjects=function(debugLine,currentDepth,maxDepth){
  11491. currentDepth++;
  11492. var color=BoundsOctreeNode._tempColor0;
  11493. if (this._isContaion){
  11494. color.r=0.0;
  11495. color.g=0.0;
  11496. color.b=1.0;
  11497. }else {
  11498. var tint=maxDepth ? currentDepth / maxDepth :0;
  11499. color.r=1.0-tint;
  11500. color.g=tint;
  11501. color.b=0.0;
  11502. }
  11503. color.a=1.0;
  11504. for (var i=0,n=this._objects.length;i < n;i++)
  11505. Utils3D._drawBound(debugLine,this._objects[i].bounds._getBoundBox(),color);
  11506. if (this._children !=null){
  11507. for (i=0;i < 8;i++){
  11508. var child=this._children[i];
  11509. child && child.drawAllObjects(debugLine,currentDepth,maxDepth);
  11510. }
  11511. }
  11512. }
  11513. BoundsOctreeNode._encapsulates=function(outerBound,innerBound){
  11514. return CollisionUtils.boxContainsBox(outerBound,innerBound)==/*laya.d3.math.ContainmentType.Contains*/1;
  11515. }
  11516. BoundsOctreeNode._NUM_OBJECTS_ALLOWED=8;
  11517. __static(BoundsOctreeNode,
  11518. ['_tempVector3',function(){return this._tempVector3=new Vector3();},'_tempVector30',function(){return this._tempVector30=new Vector3();},'_tempVector31',function(){return this._tempVector31=new Vector3();},'_tempColor0',function(){return this._tempColor0=new Color();},'_tempBoundBox',function(){return this._tempBoundBox=new BoundBox(new Vector3(),new Vector3());}
  11519. ]);
  11520. return BoundsOctreeNode;
  11521. })()
  11522. /**
  11523. *<code>GradientDataVector2</code> 类用于创建二维向量渐变。
  11524. */
  11525. //class laya.d3.core.particleShuriKen.module.GradientDataVector2
  11526. var GradientDataVector2=(function(){
  11527. function GradientDataVector2(){
  11528. /**@private */
  11529. this._currentLength=0;
  11530. /**@private 开发者禁止修改。*/
  11531. this._elements=null;
  11532. this._elements=new Float32Array(12);
  11533. }
  11534. __class(GradientDataVector2,'laya.d3.core.particleShuriKen.module.GradientDataVector2');
  11535. var __proto=GradientDataVector2.prototype;
  11536. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  11537. /**
  11538. *增加二维向量渐变。
  11539. *@param key 生命周期,范围为0到1。
  11540. *@param value 二维向量值。
  11541. */
  11542. __proto.add=function(key,value){
  11543. if (this._currentLength < 8){
  11544. if ((this._currentLength===6)&& ((key!==1))){
  11545. key=1;
  11546. console.log("GradientDataVector2 warning:the forth key is be force set to 1.");
  11547. }
  11548. this._elements[this._currentLength++]=key;
  11549. this._elements[this._currentLength++]=value.x;
  11550. this._elements[this._currentLength++]=value.y;
  11551. }else {
  11552. console.log("GradientDataVector2 warning:data count must lessEqual than 4");
  11553. }
  11554. }
  11555. /**
  11556. *克隆。
  11557. *@param destObject 克隆源。
  11558. */
  11559. __proto.cloneTo=function(destObject){
  11560. var destGradientDataVector2=destObject;
  11561. destGradientDataVector2._currentLength=this._currentLength;
  11562. var destElements=destGradientDataVector2._elements;
  11563. destElements.length=this._elements.length;
  11564. for (var i=0,n=this._elements.length;i < n;i++){
  11565. destElements[i]=this._elements[i];
  11566. }
  11567. }
  11568. /**
  11569. *克隆。
  11570. *@return 克隆副本。
  11571. */
  11572. __proto.clone=function(){
  11573. var destGradientDataVector2=/*__JS__ */new this.constructor();
  11574. this.cloneTo(destGradientDataVector2);
  11575. return destGradientDataVector2;
  11576. }
  11577. /**二维向量渐变数量。*/
  11578. __getset(0,__proto,'gradientCount',function(){
  11579. return this._currentLength / 3;
  11580. });
  11581. return GradientDataVector2;
  11582. })()
  11583. /**
  11584. *<code>VertexPositionTerrain</code> 类用于创建位置、法线、纹理1、纹理2顶点结构。
  11585. */
  11586. //class laya.d3.graphics.Vertex.VertexPositionTerrain
  11587. var VertexPositionTerrain=(function(){
  11588. function VertexPositionTerrain(position,normal,textureCoord0,textureCoord1){
  11589. this._position=null;
  11590. this._normal=null;
  11591. this._textureCoord0=null;
  11592. this._textureCoord1=null;
  11593. this._position=position;
  11594. this._normal=normal;
  11595. this._textureCoord0=textureCoord0;
  11596. this._textureCoord1=textureCoord1;
  11597. }
  11598. __class(VertexPositionTerrain,'laya.d3.graphics.Vertex.VertexPositionTerrain');
  11599. var __proto=VertexPositionTerrain.prototype;
  11600. Laya.imps(__proto,{"laya.d3.graphics.IVertex":true})
  11601. __getset(0,__proto,'normal',function(){
  11602. return this._normal;
  11603. });
  11604. __getset(0,__proto,'position',function(){
  11605. return this._position;
  11606. });
  11607. __getset(0,__proto,'textureCoord0',function(){
  11608. return this._textureCoord0;
  11609. });
  11610. __getset(0,__proto,'textureCoord1',function(){
  11611. return this._textureCoord1;
  11612. });
  11613. __getset(0,__proto,'vertexDeclaration',function(){
  11614. return VertexPositionTerrain._vertexDeclaration;
  11615. });
  11616. __getset(1,VertexPositionTerrain,'vertexDeclaration',function(){
  11617. return VertexPositionTerrain._vertexDeclaration;
  11618. });
  11619. VertexPositionTerrain.TERRAIN_POSITION0=0;
  11620. VertexPositionTerrain.TERRAIN_NORMAL0=1;
  11621. VertexPositionTerrain.TERRAIN_TEXTURECOORDINATE0=2;
  11622. VertexPositionTerrain.TERRAIN_TEXTURECOORDINATE1=3;
  11623. __static(VertexPositionTerrain,
  11624. ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(40,[
  11625. new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*CLASS CONST:laya.d3.graphics.Vertex.VertexPositionTerrain.TERRAIN_POSITION0*/0),
  11626. new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*CLASS CONST:laya.d3.graphics.Vertex.VertexPositionTerrain.TERRAIN_NORMAL0*/1),
  11627. new VertexElement(24,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*CLASS CONST:laya.d3.graphics.Vertex.VertexPositionTerrain.TERRAIN_TEXTURECOORDINATE0*/2),
  11628. new VertexElement(32,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*CLASS CONST:laya.d3.graphics.Vertex.VertexPositionTerrain.TERRAIN_TEXTURECOORDINATE1*/3)]);}
  11629. ]);
  11630. return VertexPositionTerrain;
  11631. })()
  11632. /**
  11633. *<code>KeyframeNodeList</code> 类用于创建KeyframeNode节点队列。
  11634. */
  11635. //class laya.d3.animation.KeyframeNodeList
  11636. var KeyframeNodeList=(function(){
  11637. function KeyframeNodeList(){
  11638. this._nodes=[];
  11639. }
  11640. __class(KeyframeNodeList,'laya.d3.animation.KeyframeNodeList');
  11641. var __proto=KeyframeNodeList.prototype;
  11642. /**
  11643. *通过索引获取节点。
  11644. *@param index 索引。
  11645. *@return 节点。
  11646. */
  11647. __proto.getNodeByIndex=function(index){
  11648. return this._nodes[index];
  11649. }
  11650. /**
  11651. *通过索引设置节点。
  11652. *@param index 索引。
  11653. *@param 节点。
  11654. */
  11655. __proto.setNodeByIndex=function(index,node){
  11656. this._nodes[index]=node;
  11657. }
  11658. /**
  11659. *设置节点个数。
  11660. *@param value 节点个数。
  11661. */
  11662. /**
  11663. *获取节点个数。
  11664. *@return 节点个数。
  11665. */
  11666. __getset(0,__proto,'count',function(){
  11667. return this._nodes.length;
  11668. },function(value){
  11669. this._nodes.length=value;
  11670. });
  11671. return KeyframeNodeList;
  11672. })()
  11673. /**
  11674. *<code>BoundsOctree</code> 类用于创建八叉树。
  11675. */
  11676. //class laya.d3.core.scene.BoundsOctree
  11677. var BoundsOctree=(function(){
  11678. function BoundsOctree(initialWorldSize,initialWorldPos,minNodeSize,looseness){
  11679. /**@private */
  11680. this._initialSize=NaN;
  11681. /**@private */
  11682. this._rootNode=null;
  11683. /**@private */
  11684. this._looseness=NaN;
  11685. /**@private */
  11686. this._minSize=NaN;
  11687. /**@private [只读]*/
  11688. this.count=0;
  11689. this._motionObjects=new OctreeMotionList();
  11690. if (minNodeSize > initialWorldSize){
  11691. console.warn("Minimum node size must be at least as big as the initial world size. Was: "+minNodeSize+" Adjusted to: "+initialWorldSize);
  11692. minNodeSize=initialWorldSize;
  11693. }
  11694. this._initialSize=initialWorldSize;
  11695. this._minSize=minNodeSize;
  11696. this._looseness=Math.min(Math.max(looseness,1.0),2.0);
  11697. this._rootNode=new BoundsOctreeNode(this,null,initialWorldSize,initialWorldPos);
  11698. }
  11699. __class(BoundsOctree,'laya.d3.core.scene.BoundsOctree');
  11700. var __proto=BoundsOctree.prototype;
  11701. /**
  11702. *@private
  11703. */
  11704. __proto._getMaxDepth=function(node,depth){
  11705. depth++;
  11706. var children=node._children;
  11707. if (children !=null){
  11708. var curDepth=depth;
  11709. for (var i=0,n=children.length;i < n;i++){
  11710. var child=children[i];
  11711. child && (depth=Math.max(this._getMaxDepth(child,curDepth),depth));
  11712. }
  11713. }
  11714. return depth;
  11715. }
  11716. /**
  11717. *@private
  11718. */
  11719. __proto._grow=function(growObjectCenter){
  11720. var xDirection=growObjectCenter.x >=0 ? 1 :-1;
  11721. var yDirection=growObjectCenter.y >=0 ? 1 :-1;
  11722. var zDirection=growObjectCenter.z >=0 ? 1 :-1;
  11723. var oldRoot=this._rootNode;
  11724. var half=this._rootNode.baseLength / 2;
  11725. var newLength=this._rootNode.baseLength *2;
  11726. var rootCenter=this._rootNode.center;
  11727. var newCenter=new Vector3(rootCenter.x+xDirection *half,rootCenter.y+yDirection *half,rootCenter.z+zDirection *half);
  11728. this._rootNode=new BoundsOctreeNode(this,null,newLength,newCenter);
  11729. if (oldRoot.hasAnyObjects()){
  11730. var rootPos=this._rootNode._bestFitChild(oldRoot.center);
  11731. var children=__newvec(8,null);
  11732. for (var i=0;i < 8;i++){
  11733. if (i==rootPos){
  11734. oldRoot._parent=this._rootNode;
  11735. children[i]=oldRoot;
  11736. }
  11737. }
  11738. this._rootNode._children=children;
  11739. }
  11740. }
  11741. /**
  11742. *添加物体
  11743. *@param object
  11744. */
  11745. __proto.add=function(object){
  11746. var count=0;
  11747. while (!this._rootNode.add(object)){
  11748. var growCenter=BoundsOctree._tempVector30;
  11749. Vector3.subtract(object.bounds.getCenter(),this._rootNode.center,growCenter);
  11750. this._grow(growCenter);
  11751. if (++count > 20){
  11752. throw "Aborted Add operation as it seemed to be going on forever ("+(count-1)+") attempts at growing the octree.";
  11753. }
  11754. }
  11755. this.count++;
  11756. }
  11757. /**
  11758. *移除物体
  11759. *@return 是否成功
  11760. */
  11761. __proto.remove=function(object){
  11762. var removed=object._getOctreeNode().remove(object);
  11763. if (removed){
  11764. this.count--;
  11765. }
  11766. return removed;
  11767. }
  11768. /**
  11769. *更新物体
  11770. */
  11771. __proto.update=function(object){
  11772. var count=0;
  11773. var octreeNode=object._getOctreeNode();
  11774. if (octreeNode){
  11775. while (!octreeNode._update(object)){
  11776. this._grow(object.bounds.getCenter());
  11777. if (++count > 20){
  11778. throw "Aborted Add operation as it seemed to be going on forever ("+(count-1)+") attempts at growing the octree.";
  11779. }
  11780. }
  11781. return true;
  11782. }else {
  11783. return false;
  11784. }
  11785. }
  11786. /**
  11787. *如果可能则收缩根节点。
  11788. */
  11789. __proto.shrinkRootIfPossible=function(){
  11790. this._rootNode=this._rootNode.shrinkIfPossible(this._initialSize);
  11791. }
  11792. /**
  11793. *添加运动物体。
  11794. *@param 运动物体。
  11795. */
  11796. __proto.addMotionObject=function(object){
  11797. this._motionObjects.add(object);
  11798. }
  11799. /**
  11800. *移除运动物体。
  11801. *@param 运动物体。
  11802. */
  11803. __proto.removeMotionObject=function(object){
  11804. this._motionObjects.remove(object);
  11805. }
  11806. /**
  11807. *更新所有运动物体。
  11808. */
  11809. __proto.updateMotionObjects=function(){
  11810. var elements=this._motionObjects.elements;
  11811. for (var i=0,n=this._motionObjects.length;i < n;i++){
  11812. var object=elements [i];
  11813. this.update(object);
  11814. object._setIndexInMotionList(-1);
  11815. }
  11816. this._motionObjects.length=0;
  11817. }
  11818. /**
  11819. *获取是否与指定包围盒相交。
  11820. *@param checkBound AABB包围盒。
  11821. *@return 是否相交。
  11822. */
  11823. __proto.isCollidingWithBoundBox=function(checkBounds){
  11824. return this._rootNode.isCollidingWithBoundBox(checkBounds);
  11825. }
  11826. /**
  11827. *获取是否与指定射线相交。
  11828. *@param ray 射线。
  11829. *@param maxDistance 射线的最大距离。
  11830. *@return 是否相交。
  11831. */
  11832. __proto.isCollidingWithRay=function(ray,maxDistance){
  11833. (maxDistance===void 0)&& (maxDistance=Number.MAX_VALUE);
  11834. return this._rootNode.isCollidingWithRay(ray,maxDistance);
  11835. }
  11836. /**
  11837. *获取与指定包围盒相交的物体列表。
  11838. *@param checkBound AABB包围盒。
  11839. *@param result 相交物体列表
  11840. */
  11841. __proto.getCollidingWithBoundBox=function(checkBound,result){
  11842. this._rootNode.getCollidingWithBoundBox(checkBound,result);
  11843. }
  11844. /**
  11845. *获取与指定射线相交的的物理列表。
  11846. *@param ray 射线。
  11847. *@param result 相交物体列表。
  11848. *@param maxDistance 射线的最大距离。
  11849. */
  11850. __proto.getCollidingWithRay=function(ray,result,maxDistance){
  11851. (maxDistance===void 0)&& (maxDistance=Number.MAX_VALUE);
  11852. this._rootNode.getCollidingWithRay(ray,result,maxDistance);
  11853. }
  11854. /**
  11855. *获取与指定视锥相交的的物理列表。
  11856. *@param 渲染上下文。
  11857. */
  11858. __proto.getCollidingWithFrustum=function(context){
  11859. this._rootNode.getCollidingWithFrustum(context);
  11860. }
  11861. /**
  11862. *获取最大包围盒
  11863. *@return 最大包围盒
  11864. */
  11865. __proto.getMaxBounds=function(){
  11866. return this._rootNode.getBound();
  11867. }
  11868. /**
  11869. *@private
  11870. *[Debug]
  11871. */
  11872. __proto.drawAllBounds=function(pixelLine){
  11873. var maxDepth=this._getMaxDepth(this._rootNode,-1);
  11874. this._rootNode.drawAllBounds(pixelLine,-1,maxDepth);
  11875. }
  11876. /**
  11877. *@private
  11878. *[Debug]
  11879. */
  11880. __proto.drawAllObjects=function(pixelLine){
  11881. var maxDepth=this._getMaxDepth(this._rootNode,-1);
  11882. this._rootNode.drawAllObjects(pixelLine,-1,maxDepth);
  11883. }
  11884. __static(BoundsOctree,
  11885. ['_tempVector30',function(){return this._tempVector30=new Vector3();}
  11886. ]);
  11887. return BoundsOctree;
  11888. })()
  11889. /**
  11890. *<code>MeshFilter</code> 类用于创建网格过滤器。
  11891. */
  11892. //class laya.d3.core.MeshFilter
  11893. var MeshFilter=(function(){
  11894. function MeshFilter(owner){
  11895. /**@private */
  11896. this._owner=null;
  11897. /**@private */
  11898. this._sharedMesh=null;
  11899. this._owner=owner;
  11900. }
  11901. __class(MeshFilter,'laya.d3.core.MeshFilter');
  11902. var __proto=MeshFilter.prototype;
  11903. /**
  11904. *@private
  11905. */
  11906. __proto._getMeshDefine=function(mesh){
  11907. var define=0;
  11908. for (var i=0,n=mesh._subMeshCount;i < n;i++){
  11909. var subMesh=mesh._getSubMesh(i);
  11910. var vertexElements=subMesh._vertexBuffer._vertexDeclaration.vertexElements;
  11911. for (var j=0,m=vertexElements.length;j < m;j++){
  11912. var vertexElement=vertexElements[j];
  11913. var name=vertexElement.elementUsage;
  11914. switch (name){
  11915. case /*laya.d3.graphics.Vertex.VertexMesh.MESH_COLOR0*/1:
  11916. define |=MeshSprite3D.SHADERDEFINE_COLOR;
  11917. break
  11918. case /*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE0*/2:
  11919. define |=MeshSprite3D.SHADERDEFINE_UV0;
  11920. break ;
  11921. case /*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE1*/7:
  11922. define |=MeshSprite3D.SHADERDEFINE_UV1;
  11923. break ;
  11924. }
  11925. }
  11926. }
  11927. return define;
  11928. }
  11929. /**
  11930. *@inheritDoc
  11931. */
  11932. __proto.destroy=function(){
  11933. this._owner=null;
  11934. (this._sharedMesh)&& (this._sharedMesh._removeReference(),this._sharedMesh=null);
  11935. }
  11936. /**
  11937. *设置共享网格。
  11938. *@return value 共享网格。
  11939. */
  11940. /**
  11941. *获取共享网格。
  11942. *@return 共享网格。
  11943. */
  11944. __getset(0,__proto,'sharedMesh',function(){
  11945. return this._sharedMesh;
  11946. },function(value){
  11947. if (this._sharedMesh!==value){
  11948. var defineDatas=this._owner._render._defineDatas;
  11949. var lastValue=this._sharedMesh;
  11950. if (lastValue){
  11951. lastValue._removeReference();
  11952. defineDatas.remove(this._getMeshDefine(lastValue));
  11953. }
  11954. value._addReference();
  11955. this._sharedMesh=value;
  11956. defineDatas.add(this._getMeshDefine(value));
  11957. (this._owner._render)._changeRenderObjectsByMesh(value);
  11958. }
  11959. (this._owner._render)._onMeshChange(value);
  11960. });
  11961. return MeshFilter;
  11962. })()
  11963. /**
  11964. *<code>TrailFilter</code> 类用于创建拖尾过滤器。
  11965. */
  11966. //class laya.d3.core.trail.TrailFilter
  11967. var TrailFilter=(function(){
  11968. function TrailFilter(owner){
  11969. /**@private */
  11970. this._minVertexDistance=NaN;
  11971. /**@private */
  11972. this._widthMultiplier=NaN;
  11973. /**@private */
  11974. this._time=NaN;
  11975. /**@private */
  11976. this._widthCurve=null;
  11977. /**@private */
  11978. this._colorGradient=null;
  11979. /**@private */
  11980. this._textureMode=0;
  11981. /**@private */
  11982. this._trialGeometry=null;
  11983. /**@private 拖尾总长度*/
  11984. this._totalLength=0;
  11985. this._owner=null;
  11986. this._curtime=0;
  11987. this._trailRenderElementIndex=0;
  11988. this._lastPosition=new Vector3();
  11989. this.alignment=0;
  11990. this._owner=owner;
  11991. this._initDefaultData();
  11992. this.addRenderElement();
  11993. }
  11994. __class(TrailFilter,'laya.d3.core.trail.TrailFilter');
  11995. var __proto=TrailFilter.prototype;
  11996. /**
  11997. *@private
  11998. */
  11999. __proto.addRenderElement=function(){
  12000. var render=this._owner._render;
  12001. var elements=render._renderElements;
  12002. var material=render.sharedMaterials [0];
  12003. (material)|| (material=TrailMaterial.defaultMaterial);
  12004. var element=new RenderElement();
  12005. element.setTransform(this._owner._transform);
  12006. element.render=render;
  12007. element.material=material;
  12008. this._trialGeometry=new TrailGeometry(this);
  12009. element.setGeometry(this._trialGeometry);
  12010. elements.push(element);
  12011. }
  12012. /**
  12013. *@private
  12014. */
  12015. __proto._update=function(state){
  12016. var render=this._owner._render;
  12017. this._curtime+=(state.scene).timer._delta / 1000;
  12018. render._shaderValues.setNumber(TrailSprite3D.CURTIME,this._curtime);
  12019. var curPos=this._owner.transform.position;
  12020. var element=render._renderElements[0] ._geometry;
  12021. element._updateDisappear();
  12022. element._updateTrail(state.camera,this._lastPosition,curPos);
  12023. element._updateVertexBufferUV();
  12024. curPos.cloneTo(this._lastPosition);
  12025. }
  12026. /**
  12027. *@private
  12028. */
  12029. __proto._initDefaultData=function(){
  12030. this.time=5.0;
  12031. this.minVertexDistance=0.1;
  12032. this.widthMultiplier=1;
  12033. this.textureMode=/*laya.d3.core.TextureMode.Stretch*/0;
  12034. var widthKeyFrames=[];
  12035. var widthKeyFrame1=new FloatKeyframe();
  12036. widthKeyFrame1.time=0;
  12037. widthKeyFrame1.inTangent=0;
  12038. widthKeyFrame1.outTangent=0;
  12039. widthKeyFrame1.value=1;
  12040. widthKeyFrames.push(widthKeyFrame1);
  12041. var widthKeyFrame2=new FloatKeyframe();
  12042. widthKeyFrame2.time=1;
  12043. widthKeyFrame2.inTangent=0;
  12044. widthKeyFrame2.outTangent=0;
  12045. widthKeyFrame2.value=1;
  12046. widthKeyFrames.push(widthKeyFrame2);
  12047. this.widthCurve=widthKeyFrames;
  12048. var gradient=new Gradient(2,2);
  12049. gradient.mode=/*laya.d3.core.GradientMode.Blend*/0;
  12050. gradient.addColorRGB(0,Color.WHITE);
  12051. gradient.addColorRGB(1,Color.WHITE);
  12052. gradient.addColorAlpha(0,1);
  12053. gradient.addColorAlpha(1,1);
  12054. this.colorGradient=gradient;
  12055. }
  12056. /**
  12057. *@private
  12058. */
  12059. __proto.destroy=function(){
  12060. this._trialGeometry.destroy();
  12061. this._trialGeometry=null;
  12062. this._widthCurve=null;
  12063. this._colorGradient=null;
  12064. }
  12065. /**
  12066. *设置宽度倍数。
  12067. *@param value 宽度倍数。
  12068. */
  12069. /**
  12070. *获取宽度倍数。
  12071. *@return 宽度倍数。
  12072. */
  12073. __getset(0,__proto,'widthMultiplier',function(){
  12074. return this._widthMultiplier;
  12075. },function(value){
  12076. this._widthMultiplier=value;
  12077. });
  12078. /**
  12079. *设置淡出时间。
  12080. *@param value 淡出时间。
  12081. */
  12082. /**
  12083. *获取淡出时间。
  12084. *@return 淡出时间。
  12085. */
  12086. __getset(0,__proto,'time',function(){
  12087. return this._time;
  12088. },function(value){
  12089. this._time=value;
  12090. this._owner._render._shaderValues.setNumber(TrailSprite3D.LIFETIME,value);
  12091. });
  12092. /**
  12093. *设置宽度曲线。
  12094. *@param value 宽度曲线。
  12095. */
  12096. /**
  12097. *获取宽度曲线。
  12098. *@return 宽度曲线。
  12099. */
  12100. __getset(0,__proto,'widthCurve',function(){
  12101. return this._widthCurve;
  12102. },function(value){
  12103. this._widthCurve=value;
  12104. var widthCurveFloatArray=new Float32Array(value.length *4);
  12105. var i=0,j=0,index=0;
  12106. for (i=0,j=value.length;i < j;i++){
  12107. widthCurveFloatArray[index++]=value[i].time;
  12108. widthCurveFloatArray[index++]=value[i].inTangent;
  12109. widthCurveFloatArray[index++]=value[i].outTangent;
  12110. widthCurveFloatArray[index++]=value[i].value;
  12111. }
  12112. this._owner._render._shaderValues.setBuffer(TrailSprite3D.WIDTHCURVE,widthCurveFloatArray);
  12113. this._owner._render._shaderValues.setInt(TrailSprite3D.WIDTHCURVEKEYLENGTH,value.length);
  12114. });
  12115. /**
  12116. *设置新旧顶点之间最小距离。
  12117. *@param value 新旧顶点之间最小距离。
  12118. */
  12119. /**
  12120. *获取新旧顶点之间最小距离。
  12121. *@return 新旧顶点之间最小距离。
  12122. */
  12123. __getset(0,__proto,'minVertexDistance',function(){
  12124. return this._minVertexDistance;
  12125. },function(value){
  12126. this._minVertexDistance=value;
  12127. });
  12128. /**
  12129. *设置颜色梯度。
  12130. *@param value 颜色梯度。
  12131. */
  12132. /**
  12133. *获取颜色梯度。
  12134. *@return 颜色梯度。
  12135. */
  12136. __getset(0,__proto,'colorGradient',function(){
  12137. return this._colorGradient;
  12138. },function(value){
  12139. this._colorGradient=value;
  12140. this._owner._render._shaderValues.setBuffer(TrailSprite3D.GRADIENTCOLORKEY,value._rgbElements);
  12141. this._owner._render._shaderValues.setBuffer(TrailSprite3D.GRADIENTALPHAKEY,value._alphaElements);
  12142. if (value.mode==/*laya.d3.core.GradientMode.Blend*/0){
  12143. this._owner._render._defineDatas.add(TrailSprite3D.SHADERDEFINE_GRADIENTMODE_BLEND);
  12144. }else {
  12145. this._owner._render._defineDatas.remove(TrailSprite3D.SHADERDEFINE_GRADIENTMODE_BLEND);
  12146. }
  12147. });
  12148. /**
  12149. *设置纹理模式。
  12150. *@param value 纹理模式。
  12151. */
  12152. /**
  12153. *获取纹理模式。
  12154. *@return 纹理模式。
  12155. */
  12156. __getset(0,__proto,'textureMode',function(){
  12157. return this._textureMode;
  12158. },function(value){
  12159. this._textureMode=value;
  12160. });
  12161. TrailFilter.ALIGNMENT_VIEW=0;
  12162. TrailFilter.ALIGNMENT_TRANSFORM_Z=1;
  12163. return TrailFilter;
  12164. })()
  12165. /**
  12166. *<code>VertexTrail</code> 类用于创建拖尾顶点结构。
  12167. */
  12168. //class laya.d3.core.trail.VertexTrail
  12169. var VertexTrail=(function(){
  12170. function VertexTrail(){}
  12171. __class(VertexTrail,'laya.d3.core.trail.VertexTrail');
  12172. var __proto=VertexTrail.prototype;
  12173. Laya.imps(__proto,{"laya.d3.graphics.IVertex":true})
  12174. __getset(0,__proto,'vertexDeclaration',function(){
  12175. return VertexTrail._vertexDeclaration1;
  12176. });
  12177. __getset(1,VertexTrail,'vertexDeclaration1',function(){
  12178. return VertexTrail._vertexDeclaration1;
  12179. });
  12180. __getset(1,VertexTrail,'vertexDeclaration2',function(){
  12181. return VertexTrail._vertexDeclaration2;
  12182. });
  12183. VertexTrail.TRAIL_POSITION0=0;
  12184. VertexTrail.TRAIL_OFFSETVECTOR=1;
  12185. VertexTrail.TRAIL_TIME0=2;
  12186. VertexTrail.TRAIL_TEXTURECOORDINATE0Y=3;
  12187. VertexTrail.TRAIL_TEXTURECOORDINATE0X=4;
  12188. __static(VertexTrail,
  12189. ['_vertexDeclaration1',function(){return this._vertexDeclaration1=new VertexDeclaration(32,
  12190. [new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*CLASS CONST:laya.d3.core.trail.VertexTrail.TRAIL_POSITION0*/0),
  12191. new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*CLASS CONST:laya.d3.core.trail.VertexTrail.TRAIL_OFFSETVECTOR*/1),
  12192. new VertexElement(24,/*laya.d3.graphics.VertexElementFormat.Single*/"single",/*CLASS CONST:laya.d3.core.trail.VertexTrail.TRAIL_TIME0*/2),
  12193. new VertexElement(28,/*laya.d3.graphics.VertexElementFormat.Single*/"single",/*CLASS CONST:laya.d3.core.trail.VertexTrail.TRAIL_TEXTURECOORDINATE0Y*/3)]);},'_vertexDeclaration2',function(){return this._vertexDeclaration2=new VertexDeclaration(4,
  12194. [new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Single*/"single",/*CLASS CONST:laya.d3.core.trail.VertexTrail.TRAIL_TEXTURECOORDINATE0X*/4)]);}
  12195. ]);
  12196. return VertexTrail;
  12197. })()
  12198. /**
  12199. *<code>Burst</code> 类用于粒子的爆裂描述。
  12200. */
  12201. //class laya.d3.core.particleShuriKen.module.Burst
  12202. var Burst=(function(){
  12203. function Burst(time,minCount,maxCount){
  12204. /**@private 爆裂时间,单位为秒。*/
  12205. this._time=NaN;
  12206. /**@private 爆裂的最小数量。*/
  12207. this._minCount=0;
  12208. /**@private 爆裂的最大数量。*/
  12209. this._maxCount=0;
  12210. this._time=time;
  12211. this._minCount=minCount;
  12212. this._maxCount=maxCount;
  12213. }
  12214. __class(Burst,'laya.d3.core.particleShuriKen.module.Burst');
  12215. var __proto=Burst.prototype;
  12216. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  12217. /**
  12218. *克隆。
  12219. *@param destObject 克隆源。
  12220. */
  12221. __proto.cloneTo=function(destObject){
  12222. var destBurst=destObject;
  12223. destBurst._time=this._time
  12224. destBurst._minCount=this._minCount;
  12225. destBurst._maxCount=this._maxCount;
  12226. }
  12227. /**
  12228. *克隆。
  12229. *@return 克隆副本。
  12230. */
  12231. __proto.clone=function(){
  12232. var destBurst=/*__JS__ */new this.constructor();
  12233. this.cloneTo(destBurst);
  12234. return destBurst;
  12235. }
  12236. /**
  12237. *获取爆裂时间,单位为秒。
  12238. *@return 爆裂时间,单位为秒。
  12239. */
  12240. __getset(0,__proto,'time',function(){
  12241. return this._time;
  12242. });
  12243. /**
  12244. *获取爆裂的最小数量。
  12245. *@return 爆裂的最小数量。
  12246. */
  12247. __getset(0,__proto,'minCount',function(){
  12248. return this._minCount;
  12249. });
  12250. /**
  12251. *获取爆裂的最大数量。
  12252. *@return 爆裂的最大数量。
  12253. */
  12254. __getset(0,__proto,'maxCount',function(){
  12255. return this._maxCount;
  12256. });
  12257. return Burst;
  12258. })()
  12259. /**
  12260. *<code>AnimationEvent</code> 类用于实现动画事件。
  12261. */
  12262. //class laya.d3.animation.AnimationEvent
  12263. var AnimationEvent=(function(){
  12264. function AnimationEvent(){
  12265. /**事件触发时间。*/
  12266. this.time=NaN;
  12267. /**事件触发名称。*/
  12268. this.eventName=null;
  12269. /**事件触发参数。*/
  12270. this.params=null;
  12271. }
  12272. __class(AnimationEvent,'laya.d3.animation.AnimationEvent');
  12273. return AnimationEvent;
  12274. })()
  12275. /**
  12276. *...
  12277. *@author ...
  12278. */
  12279. //class laya.d3.physics.Constraint3D
  12280. var Constraint3D=(function(){
  12281. function Constraint3D(){
  12282. /**@private */
  12283. this._nativeConstraint=null;
  12284. /**@private */
  12285. this._simulation=null;
  12286. /**获取刚体A。[只读]*/
  12287. this.rigidbodyA=null;
  12288. /**获取刚体A。[只读]*/
  12289. this.rigidbodyB=null;
  12290. }
  12291. __class(Constraint3D,'laya.d3.physics.Constraint3D');
  12292. return Constraint3D;
  12293. })()
  12294. /**
  12295. *@private
  12296. */
  12297. //class laya.d3.MouseTouch
  12298. var MouseTouch=(function(){
  12299. function MouseTouch(){
  12300. /**@private */
  12301. this._pressedSprite=null;
  12302. /**@private */
  12303. this._pressedLoopCount=-1;
  12304. /**@private */
  12305. this.sprite=null;
  12306. /**@private */
  12307. this.mousePositionX=0;
  12308. /**@private */
  12309. this.mousePositionY=0;
  12310. }
  12311. __class(MouseTouch,'laya.d3.MouseTouch');
  12312. return MouseTouch;
  12313. })()
  12314. /**
  12315. *<code>GradientDataInt</code> 类用于创建整形渐变。
  12316. */
  12317. //class laya.d3.core.particleShuriKen.module.GradientDataInt
  12318. var GradientDataInt=(function(){
  12319. function GradientDataInt(){
  12320. /**@private */
  12321. this._currentLength=0;
  12322. /**@private 开发者禁止修改。*/
  12323. this._elements=null;
  12324. this._elements=new Float32Array(8);
  12325. }
  12326. __class(GradientDataInt,'laya.d3.core.particleShuriKen.module.GradientDataInt');
  12327. var __proto=GradientDataInt.prototype;
  12328. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  12329. /**
  12330. *增加整形渐变。
  12331. *@param key 生命周期,范围为0到1。
  12332. *@param value 整形值。
  12333. */
  12334. __proto.add=function(key,value){
  12335. if (this._currentLength < 8){
  12336. if ((this._currentLength===6)&& ((key!==1))){
  12337. key=1;
  12338. console.log("Warning:the forth key is be force set to 1.");
  12339. }
  12340. this._elements[this._currentLength++]=key;
  12341. this._elements[this._currentLength++]=value;
  12342. }else {
  12343. console.log("Warning:data count must lessEqual than 4");
  12344. }
  12345. }
  12346. /**
  12347. *克隆。
  12348. *@param destObject 克隆源。
  12349. */
  12350. __proto.cloneTo=function(destObject){
  12351. var destGradientDataInt=destObject;
  12352. destGradientDataInt._currentLength=this._currentLength;
  12353. var destElements=destGradientDataInt._elements;
  12354. destElements.length=this._elements.length;
  12355. for (var i=0,n=this._elements.length;i < n;i++){
  12356. destElements[i]=this._elements[i];
  12357. }
  12358. }
  12359. /**
  12360. *克隆。
  12361. *@return 克隆副本。
  12362. */
  12363. __proto.clone=function(){
  12364. var destGradientDataInt=/*__JS__ */new this.constructor();
  12365. this.cloneTo(destGradientDataInt);
  12366. return destGradientDataInt;
  12367. }
  12368. /**整形渐变数量。*/
  12369. __getset(0,__proto,'gradientCount',function(){
  12370. return this._currentLength / 2;
  12371. });
  12372. return GradientDataInt;
  12373. })()
  12374. /**
  12375. *<code>SubShader</code> 类用于创建SubShader。
  12376. */
  12377. //class laya.d3.shader.SubShader
  12378. var SubShader=(function(){
  12379. function SubShader(attributeMap,uniformMap,spriteDefines,materialDefines){
  12380. /**@private */
  12381. this._attributeMap=null;
  12382. /**@private */
  12383. this._uniformMap=null;
  12384. /**@private */
  12385. this._publicDefines=null;
  12386. /**@private */
  12387. this._publicDefinesMap=null;
  12388. /**@private */
  12389. this._spriteDefines=null;
  12390. /**@private */
  12391. this._spriteDefinesMap=null;
  12392. /**@private */
  12393. this._materialDefines=null;
  12394. /**@private */
  12395. this._materialDefinesMap=null;
  12396. /**@private */
  12397. this._owner=null;
  12398. /**@private */
  12399. this._flags={};
  12400. this._passes=[];
  12401. this._publicDefines=[];
  12402. this._publicDefinesMap={};
  12403. this._spriteDefines=[];
  12404. this._spriteDefinesMap={};
  12405. this._materialDefines=[];
  12406. this._materialDefinesMap={};
  12407. this._addDefines(this._publicDefines,this._publicDefinesMap,Shader3D._globleDefines);
  12408. (spriteDefines)&& (this._addDefines(this._spriteDefines,this._spriteDefinesMap,spriteDefines.defines));
  12409. (materialDefines)&& (this._addDefines(this._materialDefines,this._materialDefinesMap,materialDefines.defines));
  12410. this._attributeMap=attributeMap;
  12411. this._uniformMap=uniformMap;
  12412. }
  12413. __class(SubShader,'laya.d3.shader.SubShader');
  12414. var __proto=SubShader.prototype;
  12415. /**
  12416. *@private
  12417. */
  12418. __proto._addDefines=function(defines,definesMap,supportDefines){
  12419. for (var k in supportDefines){
  12420. var name=supportDefines[k];
  12421. var i=parseInt(k);
  12422. defines[i]=name;
  12423. definesMap[name]=i;
  12424. }
  12425. }
  12426. /**
  12427. *通过名称获取宏定义值。
  12428. *@param name 名称。
  12429. *@return 宏定义值。
  12430. */
  12431. __proto.getMaterialDefineByName=function(name){
  12432. return this._materialDefinesMap[name];
  12433. }
  12434. /**
  12435. *添加标记。
  12436. *@param key 标记键。
  12437. *@param value 标记值。
  12438. */
  12439. __proto.setFlag=function(key,value){
  12440. if (value)
  12441. this._flags[key]=value;
  12442. else
  12443. delete this._flags[key];
  12444. }
  12445. /**
  12446. *获取标记值。
  12447. *@return key 标记键。
  12448. */
  12449. __proto.getFlag=function(key){
  12450. return this._flags[key];
  12451. }
  12452. /**
  12453. *@private
  12454. */
  12455. __proto.addShaderPass=function(vs,ps,stateMap){
  12456. var shaderPass=new ShaderPass(this,vs,ps,stateMap);
  12457. this._passes.push(shaderPass);
  12458. return shaderPass;
  12459. }
  12460. return SubShader;
  12461. })()
  12462. /**
  12463. **<code>PostProcessRenderContext</code> 类用于创建后期处理渲染上下文。
  12464. */
  12465. //class laya.d3.core.render.PostProcessRenderContext
  12466. var PostProcessRenderContext=(function(){
  12467. function PostProcessRenderContext(){
  12468. /**源纹理。*/
  12469. this.source=null;
  12470. /**输出纹理。*/
  12471. this.destination=null;
  12472. /**渲染相机。*/
  12473. this.camera=null;
  12474. /**合成着色器数据。*/
  12475. this.compositeShaderData=null;
  12476. /**合成着色器宏定义。*/
  12477. this.compositeDefineData=null;
  12478. /**后期处理指令流。*/
  12479. this.command=null;
  12480. this.tempRenderTextures=[];
  12481. }
  12482. __class(PostProcessRenderContext,'laya.d3.core.render.PostProcessRenderContext');
  12483. return PostProcessRenderContext;
  12484. })()
  12485. /**
  12486. *<code>CommandBuffer</code> 类用于创建命令流。
  12487. */
  12488. //class laya.d3.core.render.command.CommandBuffer
  12489. var CommandBuffer=(function(){
  12490. function CommandBuffer(){
  12491. this._commands=[];
  12492. }
  12493. __class(CommandBuffer,'laya.d3.core.render.command.CommandBuffer');
  12494. var __proto=CommandBuffer.prototype;
  12495. /**
  12496. *@private
  12497. */
  12498. __proto._apply=function(){
  12499. for (var i=0,n=this._commands.length;i < n;i++)
  12500. this._commands[i].run();
  12501. }
  12502. /**
  12503. *@private
  12504. */
  12505. __proto.setShaderDataTexture=function(shaderData,nameID,source){
  12506. this._commands.push(SetShaderDataTextureCMD.create(shaderData,nameID,source));
  12507. }
  12508. /**
  12509. *@private
  12510. */
  12511. __proto.blit=function(source,dest,shader,shaderData,subShader){
  12512. (subShader===void 0)&& (subShader=0);
  12513. this._commands.push(BlitCMD.create(source,dest,shader,shaderData,subShader));
  12514. }
  12515. /**
  12516. *@private
  12517. */
  12518. __proto.setRenderTarget=function(renderTexture){
  12519. this._commands.push(SetRenderTargetCMD.create(renderTexture));
  12520. }
  12521. /**
  12522. *@private
  12523. */
  12524. __proto.clear=function(){
  12525. for (var i=0,n=this._commands.length;i < n;i++)
  12526. this._commands[i].recover();
  12527. this._commands.length=0;
  12528. }
  12529. CommandBuffer.SCREENTEXTURE_NAME="u_ScreenTexture";
  12530. __static(CommandBuffer,
  12531. ['screenShader',function(){return this.screenShader=Shader3D.find("ScreenQuad");},'SCREENTEXTURE_ID',function(){return this.SCREENTEXTURE_ID=Shader3D.propertyNameToID("u_ScreenTexture");}
  12532. ]);
  12533. return CommandBuffer;
  12534. })()
  12535. /**
  12536. *<code>GradientRotation</code> 类用于创建渐变角速度。
  12537. */
  12538. //class laya.d3.core.particleShuriKen.module.GradientAngularVelocity
  12539. var GradientAngularVelocity=(function(){
  12540. function GradientAngularVelocity(){
  12541. /**@private */
  12542. this._type=0;
  12543. /**@private */
  12544. this._separateAxes=false;
  12545. /**@private */
  12546. this._constant=NaN;
  12547. /**@private */
  12548. this._constantSeparate=null;
  12549. /**@private */
  12550. this._gradient=null;
  12551. /**@private */
  12552. this._gradientX=null;
  12553. /**@private */
  12554. this._gradientY=null;
  12555. /**@private */
  12556. this._gradientZ=null;
  12557. /**@private */
  12558. this._gradientW=null;
  12559. /**@private */
  12560. this._constantMin=NaN;
  12561. /**@private */
  12562. this._constantMax=NaN;
  12563. /**@private */
  12564. this._constantMinSeparate=null;
  12565. /**@private */
  12566. this._constantMaxSeparate=null;
  12567. /**@private */
  12568. this._gradientMin=null;
  12569. /**@private */
  12570. this._gradientMax=null;
  12571. /**@private */
  12572. this._gradientXMin=null;
  12573. /**@private */
  12574. this._gradientXMax=null;
  12575. /**@private */
  12576. this._gradientYMin=null;
  12577. /**@private */
  12578. this._gradientYMax=null;
  12579. /**@private */
  12580. this._gradientZMin=null;
  12581. /**@private */
  12582. this._gradientZMax=null;
  12583. /**@private */
  12584. this._gradientWMin=null;
  12585. /**@private */
  12586. this._gradientWMax=null;
  12587. }
  12588. __class(GradientAngularVelocity,'laya.d3.core.particleShuriKen.module.GradientAngularVelocity');
  12589. var __proto=GradientAngularVelocity.prototype;
  12590. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  12591. /**
  12592. *克隆。
  12593. *@param destObject 克隆源。
  12594. */
  12595. __proto.cloneTo=function(destObject){
  12596. var destGradientAngularVelocity=destObject;
  12597. destGradientAngularVelocity._type=this._type;
  12598. destGradientAngularVelocity._separateAxes=this._separateAxes;
  12599. destGradientAngularVelocity._constant=this._constant;
  12600. this._constantSeparate.cloneTo(destGradientAngularVelocity._constantSeparate);
  12601. this._gradient.cloneTo(destGradientAngularVelocity._gradient);
  12602. this._gradientX.cloneTo(destGradientAngularVelocity._gradientX);
  12603. this._gradientY.cloneTo(destGradientAngularVelocity._gradientY);
  12604. this._gradientZ.cloneTo(destGradientAngularVelocity._gradientZ);
  12605. destGradientAngularVelocity._constantMin=this._constantMin;
  12606. destGradientAngularVelocity._constantMax=this._constantMax;
  12607. this._constantMinSeparate.cloneTo(destGradientAngularVelocity._constantMinSeparate);
  12608. this._constantMaxSeparate.cloneTo(destGradientAngularVelocity._constantMaxSeparate);
  12609. this._gradientMin.cloneTo(destGradientAngularVelocity._gradientMin);
  12610. this._gradientMax.cloneTo(destGradientAngularVelocity._gradientMax);
  12611. this._gradientXMin.cloneTo(destGradientAngularVelocity._gradientXMin);
  12612. this._gradientXMax.cloneTo(destGradientAngularVelocity._gradientXMax);
  12613. this._gradientYMin.cloneTo(destGradientAngularVelocity._gradientYMin);
  12614. this._gradientYMax.cloneTo(destGradientAngularVelocity._gradientYMax);
  12615. this._gradientZMin.cloneTo(destGradientAngularVelocity._gradientZMin);
  12616. this._gradientZMax.cloneTo(destGradientAngularVelocity._gradientZMax);
  12617. }
  12618. /**
  12619. *克隆。
  12620. *@return 克隆副本。
  12621. */
  12622. __proto.clone=function(){
  12623. var destGradientAngularVelocity=/*__JS__ */new this.constructor();
  12624. this.cloneTo(destGradientAngularVelocity);
  12625. return destGradientAngularVelocity;
  12626. }
  12627. /**
  12628. *渐变角速度Z。
  12629. */
  12630. __getset(0,__proto,'gradientZ',function(){
  12631. return this._gradientZ;
  12632. });
  12633. /**
  12634. *固定角速度。
  12635. */
  12636. __getset(0,__proto,'constant',function(){
  12637. return this._constant;
  12638. });
  12639. /**
  12640. *渐变角速度。
  12641. */
  12642. __getset(0,__proto,'gradient',function(){
  12643. return this._gradient;
  12644. });
  12645. /**
  12646. *是否分轴。
  12647. */
  12648. __getset(0,__proto,'separateAxes',function(){
  12649. return this._separateAxes;
  12650. });
  12651. /**
  12652. *生命周期角速度类型,0常量模式,1曲线模式,2随机双常量模式,3随机双曲线模式。
  12653. */
  12654. __getset(0,__proto,'type',function(){
  12655. return this._type;
  12656. });
  12657. /**
  12658. *分轴固定角速度。
  12659. */
  12660. __getset(0,__proto,'constantSeparate',function(){
  12661. return this._constantSeparate;
  12662. });
  12663. /**
  12664. *渐变角角速度X。
  12665. */
  12666. __getset(0,__proto,'gradientX',function(){
  12667. return this._gradientX;
  12668. });
  12669. /**
  12670. *渐变角速度Y。
  12671. */
  12672. __getset(0,__proto,'gradientY',function(){
  12673. return this._gradientY;
  12674. });
  12675. /**
  12676. *渐变角速度Z。
  12677. */
  12678. __getset(0,__proto,'gradientW',function(){
  12679. return this._gradientW;
  12680. });
  12681. /**
  12682. *最小渐变角速度。
  12683. */
  12684. __getset(0,__proto,'gradientMin',function(){
  12685. return this._gradientMin;
  12686. });
  12687. /**
  12688. *最小随机双固定角速度。
  12689. */
  12690. __getset(0,__proto,'constantMin',function(){
  12691. return this._constantMin;
  12692. });
  12693. /**
  12694. *最大渐变角速度。
  12695. */
  12696. __getset(0,__proto,'gradientMax',function(){
  12697. return this._gradientMax;
  12698. });
  12699. /**
  12700. *最大随机双固定角速度。
  12701. */
  12702. __getset(0,__proto,'constantMax',function(){
  12703. return this._constantMax;
  12704. });
  12705. /**
  12706. *最小渐变角速度Z。
  12707. */
  12708. __getset(0,__proto,'gradientWMin',function(){
  12709. return this._gradientWMin;
  12710. });
  12711. /**
  12712. *最小分轴随机双固定角速度。
  12713. */
  12714. __getset(0,__proto,'constantMinSeparate',function(){
  12715. return this._constantMinSeparate;
  12716. });
  12717. /**
  12718. *最大分轴随机双固定角速度。
  12719. */
  12720. __getset(0,__proto,'constantMaxSeparate',function(){
  12721. return this._constantMaxSeparate;
  12722. });
  12723. /**
  12724. *最小渐变角速度X。
  12725. */
  12726. __getset(0,__proto,'gradientXMin',function(){
  12727. return this._gradientXMin;
  12728. });
  12729. /**
  12730. *最大渐变角速度X。
  12731. */
  12732. __getset(0,__proto,'gradientXMax',function(){
  12733. return this._gradientXMax;
  12734. });
  12735. /**
  12736. *最大渐变角速度Z。
  12737. */
  12738. __getset(0,__proto,'gradientWMax',function(){
  12739. return this._gradientWMax;
  12740. });
  12741. /**
  12742. *最小渐变角速度Y。
  12743. */
  12744. __getset(0,__proto,'gradientYMin',function(){
  12745. return this._gradientYMin;
  12746. });
  12747. /**
  12748. *最大渐变角速度Y。
  12749. */
  12750. __getset(0,__proto,'gradientYMax',function(){
  12751. return this._gradientYMax;
  12752. });
  12753. /**
  12754. *最小渐变角速度Z。
  12755. */
  12756. __getset(0,__proto,'gradientZMin',function(){
  12757. return this._gradientZMin;
  12758. });
  12759. /**
  12760. *最大渐变角速度Z。
  12761. */
  12762. __getset(0,__proto,'gradientZMax',function(){
  12763. return this._gradientZMax;
  12764. });
  12765. GradientAngularVelocity.createByConstant=function(constant){
  12766. var gradientAngularVelocity=new GradientAngularVelocity();
  12767. gradientAngularVelocity._type=0;
  12768. gradientAngularVelocity._separateAxes=false;
  12769. gradientAngularVelocity._constant=constant;
  12770. return gradientAngularVelocity;
  12771. }
  12772. GradientAngularVelocity.createByConstantSeparate=function(separateConstant){
  12773. var gradientAngularVelocity=new GradientAngularVelocity();
  12774. gradientAngularVelocity._type=0;
  12775. gradientAngularVelocity._separateAxes=true;
  12776. gradientAngularVelocity._constantSeparate=separateConstant;
  12777. return gradientAngularVelocity;
  12778. }
  12779. GradientAngularVelocity.createByGradient=function(gradient){
  12780. var gradientAngularVelocity=new GradientAngularVelocity();
  12781. gradientAngularVelocity._type=1;
  12782. gradientAngularVelocity._separateAxes=false;
  12783. gradientAngularVelocity._gradient=gradient;
  12784. return gradientAngularVelocity;
  12785. }
  12786. GradientAngularVelocity.createByGradientSeparate=function(gradientX,gradientY,gradientZ){
  12787. var gradientAngularVelocity=new GradientAngularVelocity();
  12788. gradientAngularVelocity._type=1;
  12789. gradientAngularVelocity._separateAxes=true;
  12790. gradientAngularVelocity._gradientX=gradientX;
  12791. gradientAngularVelocity._gradientY=gradientY;
  12792. gradientAngularVelocity._gradientZ=gradientZ;
  12793. return gradientAngularVelocity;
  12794. }
  12795. GradientAngularVelocity.createByRandomTwoConstant=function(constantMin,constantMax){
  12796. var gradientAngularVelocity=new GradientAngularVelocity();
  12797. gradientAngularVelocity._type=2;
  12798. gradientAngularVelocity._separateAxes=false;
  12799. gradientAngularVelocity._constantMin=constantMin;
  12800. gradientAngularVelocity._constantMax=constantMax;
  12801. return gradientAngularVelocity;
  12802. }
  12803. GradientAngularVelocity.createByRandomTwoConstantSeparate=function(separateConstantMin,separateConstantMax){
  12804. var gradientAngularVelocity=new GradientAngularVelocity();
  12805. gradientAngularVelocity._type=2;
  12806. gradientAngularVelocity._separateAxes=true;
  12807. gradientAngularVelocity._constantMinSeparate=separateConstantMin;
  12808. gradientAngularVelocity._constantMaxSeparate=separateConstantMax;
  12809. return gradientAngularVelocity;
  12810. }
  12811. GradientAngularVelocity.createByRandomTwoGradient=function(gradientMin,gradientMax){
  12812. var gradientAngularVelocity=new GradientAngularVelocity();
  12813. gradientAngularVelocity._type=3;
  12814. gradientAngularVelocity._separateAxes=false;
  12815. gradientAngularVelocity._gradientMin=gradientMin;
  12816. gradientAngularVelocity._gradientMax=gradientMax;
  12817. return gradientAngularVelocity;
  12818. }
  12819. GradientAngularVelocity.createByRandomTwoGradientSeparate=function(gradientXMin,gradientXMax,gradientYMin,gradientYMax,gradientZMin,gradientZMax,gradientWMin,gradientWMax){
  12820. var gradientAngularVelocity=new GradientAngularVelocity();
  12821. gradientAngularVelocity._type=3;
  12822. gradientAngularVelocity._separateAxes=true;
  12823. gradientAngularVelocity._gradientXMin=gradientXMin;
  12824. gradientAngularVelocity._gradientXMax=gradientXMax;
  12825. gradientAngularVelocity._gradientYMin=gradientYMin;
  12826. gradientAngularVelocity._gradientYMax=gradientYMax;
  12827. gradientAngularVelocity._gradientZMin=gradientZMin;
  12828. gradientAngularVelocity._gradientZMax=gradientZMax;
  12829. gradientAngularVelocity._gradientWMin=gradientWMin;
  12830. gradientAngularVelocity._gradientWMax=gradientWMax;
  12831. return gradientAngularVelocity;
  12832. }
  12833. return GradientAngularVelocity;
  12834. })()
  12835. /**
  12836. *<code>Config3D</code> 类用于创建3D初始化配置。
  12837. */
  12838. //class Config3D
  12839. var Config3D=(function(){
  12840. function Config3D(){
  12841. /**@private */
  12842. this._defaultPhysicsMemory=16;
  12843. /**@private */
  12844. this._editerEnvironment=false;
  12845. /**是否开启抗锯齿。*/
  12846. this.isAntialias=true;
  12847. /**设置画布是否透明。*/
  12848. this.isAlpha=false;
  12849. /**设置画布是否预乘。*/
  12850. this.premultipliedAlpha=true;
  12851. /**设置画布的是否开启模板缓冲。*/
  12852. this.isStencil=true;
  12853. /**是否开启八叉树裁剪。*/
  12854. this.octreeCulling=false;
  12855. /**八叉树初始化尺寸。*/
  12856. this.octreeInitialSize=64.0;
  12857. /**八叉树最小尺寸。*/
  12858. this.octreeMinNodeSize=2.0;
  12859. /**八叉树松散值。*/
  12860. this.octreeLooseness=1.25;
  12861. /**
  12862. *是否开启视锥裁剪调试。
  12863. *如果开启八叉树裁剪,使用红色绘制高层次八叉树节点包围盒,使用蓝色绘制低层次八叉节点包围盒,精灵包围盒和八叉树节点包围盒颜色一致,但Alpha为半透明。如果视锥完全包含八叉树节点,八叉树节点包围盒和精灵包围盒变为蓝色,同样精灵包围盒的Alpha为半透明。
  12864. *如果不开启八叉树裁剪,使用绿色像素线绘制精灵包围盒。
  12865. */
  12866. this.debugFrustumCulling=false;
  12867. this.octreeInitialCenter=new Vector3(0,0,0);
  12868. }
  12869. __class(Config3D,'Config3D');
  12870. var __proto=Config3D.prototype;
  12871. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  12872. /**
  12873. *克隆。
  12874. *@param destObject 克隆源。
  12875. */
  12876. __proto.cloneTo=function(dest){
  12877. var destConfig3D=dest;
  12878. destConfig3D._defaultPhysicsMemory=this._defaultPhysicsMemory;
  12879. destConfig3D._editerEnvironment=this._editerEnvironment;
  12880. destConfig3D.isAntialias=this.isAntialias;
  12881. destConfig3D.isAlpha=this.isAlpha;
  12882. destConfig3D.premultipliedAlpha=this.premultipliedAlpha;
  12883. destConfig3D.isStencil=this.isStencil;
  12884. destConfig3D.octreeCulling=this.octreeCulling;
  12885. this.octreeInitialCenter.cloneTo(destConfig3D.octreeInitialCenter);
  12886. destConfig3D.octreeMinNodeSize=this.octreeMinNodeSize;
  12887. destConfig3D.octreeLooseness=this.octreeLooseness;
  12888. destConfig3D.debugFrustumCulling=this.debugFrustumCulling;
  12889. }
  12890. /**
  12891. *克隆。
  12892. *@return 克隆副本。
  12893. */
  12894. __proto.clone=function(){
  12895. var dest=new Config3D();
  12896. this.cloneTo(dest);
  12897. return dest;
  12898. }
  12899. /**
  12900. *设置默认物理功能初始化内存,单位为M。
  12901. *@param value 默认物理功能初始化内存。
  12902. */
  12903. /**
  12904. *获取默认物理功能初始化内存,单位为M。
  12905. *@return 默认物理功能初始化内存。
  12906. */
  12907. __getset(0,__proto,'defaultPhysicsMemory',function(){
  12908. return this._defaultPhysicsMemory;
  12909. },function(value){
  12910. if (value < 16)
  12911. throw "defaultPhysicsMemory must large than 16M";
  12912. this._defaultPhysicsMemory=value;
  12913. });
  12914. __static(Config3D,
  12915. ['_default',function(){return this._default=new Config3D();}
  12916. ]);
  12917. return Config3D;
  12918. })()
  12919. /**
  12920. *<code>Rand</code> 类用于通过128位整型种子创建随机数,算法来自:https://github.com/AndreasMadsen/xorshift。
  12921. */
  12922. //class laya.d3.math.RandX
  12923. var RandX=(function(){
  12924. function RandX(seed){
  12925. /**@private */
  12926. this._state0U=NaN;
  12927. /**@private */
  12928. this._state0L=NaN;
  12929. /**@private */
  12930. this._state1U=NaN;
  12931. /**@private */
  12932. this._state1L=NaN;
  12933. if (!((seed instanceof Array))|| seed.length!==4)
  12934. throw new Error('Rand:Seed must be an array with 4 numbers');
  12935. this._state0U=seed[0] | 0;
  12936. this._state0L=seed[1] | 0;
  12937. this._state1U=seed[2] | 0;
  12938. this._state1L=seed[3] | 0;
  12939. }
  12940. __class(RandX,'laya.d3.math.RandX');
  12941. var __proto=RandX.prototype;
  12942. /**
  12943. *通过2x32位的数组,返回64位的随机数。
  12944. *@return 64位的随机数。
  12945. */
  12946. __proto.randomint=function(){
  12947. var s1U=this._state0U,s1L=this._state0L;
  12948. var s0U=this._state1U,s0L=this._state1L;
  12949. var sumL=(s0L >>> 0)+(s1L >>> 0);
  12950. var resU=(s0U+s1U+(sumL / 2 >>> 31))>>> 0;
  12951. var resL=sumL >>> 0;
  12952. this._state0U=s0U;
  12953. this._state0L=s0L;
  12954. var t1U=0,t1L=0;
  12955. var t2U=0,t2L=0;
  12956. var a1=23;
  12957. var m1=0xFFFFFFFF << (32-a1);
  12958. t1U=(s1U << a1)| ((s1L & m1)>>> (32-a1));
  12959. t1L=s1L << a1;
  12960. s1U=s1U ^ t1U;
  12961. s1L=s1L ^ t1L;
  12962. t1U=s1U ^ s0U;
  12963. t1L=s1L ^ s0L;
  12964. var a2=18;
  12965. var m2=0xFFFFFFFF >>> (32-a2);
  12966. t2U=s1U >>> a2;
  12967. t2L=(s1L >>> a2)| ((s1U & m2)<< (32-a2));
  12968. t1U=t1U ^ t2U;
  12969. t1L=t1L ^ t2L;
  12970. var a3=5;
  12971. var m3=0xFFFFFFFF >>> (32-a3);
  12972. t2U=s0U >>> a3;
  12973. t2L=(s0L >>> a3)| ((s0U & m3)<< (32-a3));
  12974. t1U=t1U ^ t2U;
  12975. t1L=t1L ^ t2L;
  12976. this._state1U=t1U;
  12977. this._state1L=t1L;
  12978. return [resU,resL];
  12979. }
  12980. /**
  12981. *返回[0,1)之间的随机数。
  12982. *@return
  12983. */
  12984. __proto.random=function(){
  12985. var t2=this.randomint();
  12986. var t2U=t2[0];
  12987. var t2L=t2[1];
  12988. var eU=0x3FF << (52-32);
  12989. var eL=0;
  12990. var a1=12;
  12991. var m1=0xFFFFFFFF >>> (32-a1);
  12992. var sU=t2U >>> a1;
  12993. var sL=(t2L >>> a1)| ((t2U & m1)<< (32-a1));
  12994. var xU=eU | sU;
  12995. var xL=eL | sL;
  12996. RandX._CONVERTION_BUFFER.setUint32(0,xU,false);
  12997. RandX._CONVERTION_BUFFER.setUint32(4,xL,false);
  12998. var d=/*__JS__ */Rand._CONVERTION_BUFFER.getFloat64(0,false);
  12999. return d-1;
  13000. }
  13001. __static(RandX,
  13002. ['_CONVERTION_BUFFER',function(){return this._CONVERTION_BUFFER=new DataView(new ArrayBuffer(8));},'defaultRand',function(){return this.defaultRand=/*__JS__ */new Rand([0,Date.now()/ 65536,0,Date.now()% 65536]);}
  13003. ]);
  13004. return RandX;
  13005. })()
  13006. /**
  13007. *<code>Picker</code> 类用于创建拾取。
  13008. */
  13009. //class laya.d3.utils.Picker
  13010. var Picker=(function(){
  13011. /**
  13012. *创建一个 <code>Picker</code> 实例。
  13013. */
  13014. function Picker(){}
  13015. __class(Picker,'laya.d3.utils.Picker');
  13016. Picker.calculateCursorRay=function(point,viewPort,projectionMatrix,viewMatrix,world,out){
  13017. var x=point.x;
  13018. var y=point.y;
  13019. var nearSource=Picker._tempVector30;
  13020. var nerSourceE=nearSource;
  13021. nerSourceE.x=x;
  13022. nerSourceE.y=y;
  13023. nerSourceE.z=viewPort.minDepth;
  13024. var farSource=Picker._tempVector31;
  13025. var farSourceE=farSource;
  13026. farSourceE.x=x;
  13027. farSourceE.y=y;
  13028. farSourceE.z=viewPort.maxDepth;
  13029. var nearPoint=out.origin;
  13030. var farPoint=Picker._tempVector32;
  13031. viewPort.unprojectFromWVP(nearSource,projectionMatrix,viewMatrix,world,nearPoint);
  13032. viewPort.unprojectFromWVP(farSource,projectionMatrix,viewMatrix,world,farPoint);
  13033. var outDire=out.direction;
  13034. outDire.x=farPoint.x-nearPoint.x;
  13035. outDire.y=farPoint.y-nearPoint.y;
  13036. outDire.z=farPoint.z-nearPoint.z;
  13037. Vector3.normalize(out.direction,out.direction);
  13038. }
  13039. Picker.rayIntersectsTriangle=function(ray,vertex1,vertex2,vertex3){
  13040. var result;
  13041. var edge1=Picker._tempVector30,edge2=Picker._tempVector31;
  13042. Vector3.subtract(vertex2,vertex1,edge1);
  13043. Vector3.subtract(vertex3,vertex1,edge2);
  13044. var directionCrossEdge2=Picker._tempVector32;
  13045. Vector3.cross(ray.direction,edge2,directionCrossEdge2);
  13046. var determinant;
  13047. determinant=Vector3.dot(edge1,directionCrossEdge2);
  13048. if (determinant >-Number.MIN_VALUE && determinant < Number.MIN_VALUE){
  13049. result=Number.NaN;
  13050. return result;
  13051. };
  13052. var inverseDeterminant=1.0 / determinant;
  13053. var distanceVector=Picker._tempVector33;
  13054. Vector3.subtract(ray.origin,vertex1,distanceVector);
  13055. var triangleU;
  13056. triangleU=Vector3.dot(distanceVector,directionCrossEdge2);
  13057. triangleU *=inverseDeterminant;
  13058. if (triangleU < 0 || triangleU > 1){
  13059. result=Number.NaN;
  13060. return result;
  13061. };
  13062. var distanceCrossEdge1=Picker._tempVector34;
  13063. Vector3.cross(distanceVector,edge1,distanceCrossEdge1);
  13064. var triangleV;
  13065. triangleV=Vector3.dot(ray.direction,distanceCrossEdge1);
  13066. triangleV *=inverseDeterminant;
  13067. if (triangleV < 0 || triangleU+triangleV > 1){
  13068. result=Number.NaN;
  13069. return result;
  13070. };
  13071. var rayDistance;
  13072. rayDistance=Vector3.dot(edge2,distanceCrossEdge1);
  13073. rayDistance *=inverseDeterminant;
  13074. if (rayDistance < 0){
  13075. result=Number.NaN;
  13076. return result;
  13077. }
  13078. result=rayDistance;
  13079. return result;
  13080. }
  13081. __static(Picker,
  13082. ['_tempVector30',function(){return this._tempVector30=new Vector3();},'_tempVector31',function(){return this._tempVector31=new Vector3();},'_tempVector32',function(){return this._tempVector32=new Vector3();},'_tempVector33',function(){return this._tempVector33=new Vector3();},'_tempVector34',function(){return this._tempVector34=new Vector3();}
  13083. ]);
  13084. return Picker;
  13085. })()
  13086. /**
  13087. *<code>Touch</code> 类用于实现触摸描述。
  13088. */
  13089. //class laya.d3.Touch
  13090. var Touch=(function(){
  13091. function Touch(){
  13092. /**@private [实现IListPool接口]*/
  13093. this._indexInList=-1;
  13094. /**@private */
  13095. this._identifier=-1;
  13096. this._position=new Vector2();
  13097. }
  13098. __class(Touch,'laya.d3.Touch');
  13099. var __proto=Touch.prototype;
  13100. Laya.imps(__proto,{"laya.resource.ISingletonElement":true})
  13101. /**
  13102. *@private [实现ISingletonElement接口]
  13103. */
  13104. __proto._getIndexInList=function(){
  13105. return this._indexInList;
  13106. }
  13107. /**
  13108. *@private [实现ISingletonElement接口]
  13109. */
  13110. __proto._setIndexInList=function(index){
  13111. this._indexInList=index;
  13112. }
  13113. /**
  13114. *获取唯一识别ID。
  13115. *@return 唯一识别ID。
  13116. */
  13117. __getset(0,__proto,'identifier',function(){
  13118. return this._identifier;
  13119. });
  13120. /**
  13121. *获取触摸点的像素坐标。
  13122. *@return 触摸点的像素坐标 [只读]。
  13123. */
  13124. __getset(0,__proto,'position',function(){
  13125. return this._position;
  13126. });
  13127. return Touch;
  13128. })()
  13129. /**
  13130. *<code>PixelLineData</code> 类用于表示线数据。
  13131. */
  13132. //class laya.d3.core.pixelLine.PixelLineData
  13133. var PixelLineData=(function(){
  13134. function PixelLineData(){
  13135. this.startPosition=new Vector3();
  13136. this.endPosition=new Vector3();
  13137. this.startColor=new Color();
  13138. this.endColor=new Color();
  13139. }
  13140. __class(PixelLineData,'laya.d3.core.pixelLine.PixelLineData');
  13141. var __proto=PixelLineData.prototype;
  13142. /**
  13143. *克隆。
  13144. *@param destObject 克隆源。
  13145. */
  13146. __proto.cloneTo=function(destObject){
  13147. this.startPosition.cloneTo(destObject.startPosition);
  13148. this.endPosition.cloneTo(destObject.endPosition);
  13149. this.startColor.cloneTo(destObject.startColor);
  13150. this.endColor.cloneTo(destObject.endColor);
  13151. }
  13152. return PixelLineData;
  13153. })()
  13154. /**
  13155. *<code>Collision</code> 类用于创建物理碰撞信息。
  13156. */
  13157. //class laya.d3.physics.Collision
  13158. var Collision=(function(){
  13159. function Collision(){
  13160. /**@private */
  13161. this._lastUpdateFrame=-2147483648;
  13162. /**@private */
  13163. this._updateFrame=-2147483648;
  13164. /**@private */
  13165. this._isTrigger=false;
  13166. /**@private */
  13167. //this._colliderA=null;
  13168. /**@private */
  13169. //this._colliderB=null;
  13170. /**@private [只读]*/
  13171. //this.other=null;
  13172. this.contacts=[];
  13173. }
  13174. __class(Collision,'laya.d3.physics.Collision');
  13175. var __proto=Collision.prototype;
  13176. /**
  13177. *@private
  13178. */
  13179. __proto._setUpdateFrame=function(farme){
  13180. this._lastUpdateFrame=this._updateFrame;
  13181. this._updateFrame=farme;
  13182. }
  13183. return Collision;
  13184. })()
  13185. /**
  13186. *@private
  13187. *<code>VertexDeclaration</code> 类用于生成顶点声明。
  13188. */
  13189. //class laya.d3.graphics.VertexDeclaration
  13190. var VertexDeclaration=(function(){
  13191. function VertexDeclaration(vertexStride,vertexElements){
  13192. /**@private */
  13193. this._id=0;
  13194. /**@private */
  13195. this._vertexStride=0;
  13196. /**@private */
  13197. this._vertexElementsDic=null;
  13198. /**@private */
  13199. this._shaderValues=null;
  13200. /**@private */
  13201. this._defineDatas=null;
  13202. /**@private [只读]*/
  13203. this.vertexElements=null;
  13204. this._id=++VertexDeclaration._uniqueIDCounter;
  13205. this._defineDatas=new DefineDatas();
  13206. this._vertexElementsDic={};
  13207. this._vertexStride=vertexStride;
  13208. this.vertexElements=vertexElements;
  13209. var count=vertexElements.length;
  13210. this._shaderValues=new ShaderData(null);
  13211. for (var j=0;j < count;j++){
  13212. var vertexElement=vertexElements[j];
  13213. var name=vertexElement.elementUsage;
  13214. this._vertexElementsDic[name]=vertexElement;
  13215. var value=new Int32Array(5);
  13216. var elmentInfo=VertexElementFormat.getElementInfos(vertexElement.elementFormat);
  13217. value[0]=elmentInfo[0];
  13218. value[1]=elmentInfo[1];
  13219. value[2]=elmentInfo[2];
  13220. value[3]=this._vertexStride;
  13221. value[4]=vertexElement.offset;
  13222. this._shaderValues.setAttribute(name,value);
  13223. }
  13224. }
  13225. __class(VertexDeclaration,'laya.d3.graphics.VertexDeclaration');
  13226. var __proto=VertexDeclaration.prototype;
  13227. /**
  13228. *@private
  13229. */
  13230. __proto.getVertexElementByUsage=function(usage){
  13231. return this._vertexElementsDic[usage];
  13232. }
  13233. /**
  13234. *@private
  13235. */
  13236. __proto.unBinding=function(){}
  13237. /**
  13238. *获取唯一标识ID(通常用于优化或识别)。
  13239. *@return 唯一标识ID
  13240. */
  13241. __getset(0,__proto,'id',function(){
  13242. return this._id;
  13243. });
  13244. /**
  13245. *@private
  13246. */
  13247. __getset(0,__proto,'vertexStride',function(){
  13248. return this._vertexStride;
  13249. });
  13250. VertexDeclaration._uniqueIDCounter=1;
  13251. return VertexDeclaration;
  13252. })()
  13253. /**
  13254. *<code>SkyRenderer</code> 类用于实现天空渲染器。
  13255. */
  13256. //class laya.d3.resource.models.SkyRenderer
  13257. var SkyRenderer=(function(){
  13258. function SkyRenderer(){
  13259. /**@private */
  13260. this._material=null;
  13261. this._mesh=SkyBox.instance;
  13262. }
  13263. __class(SkyRenderer,'laya.d3.resource.models.SkyRenderer');
  13264. var __proto=SkyRenderer.prototype;
  13265. /**
  13266. *@private
  13267. *是否可用。
  13268. */
  13269. __proto._isAvailable=function(){
  13270. return this._material && this._mesh;
  13271. }
  13272. /**
  13273. *@private
  13274. */
  13275. __proto._render=function(state){
  13276. if (this._material && this._mesh){
  13277. var gl=LayaGL.instance;
  13278. var scene=state.scene;
  13279. var camera=state.camera;
  13280. WebGLContext.setCullFace(gl,false);
  13281. WebGLContext.setDepthFunc(gl,/*laya.webgl.WebGLContext.LEQUAL*/0x0203);
  13282. WebGLContext.setDepthMask(gl,false);
  13283. var shader=state.shader=this._material._shader.getSubShaderAt(0)._passes[0].withCompile(0,0,this._material._defineDatas.value);
  13284. var switchShader=shader.bind();
  13285. var switchShaderLoop=(Stat.loopCount!==shader._uploadMark);
  13286. var uploadScene=(shader._uploadScene!==scene)|| switchShaderLoop;
  13287. if (uploadScene || switchShader){
  13288. shader.uploadUniforms(shader._sceneUniformParamsMap,scene._shaderValues,uploadScene);
  13289. shader._uploadScene=scene;
  13290. };
  13291. var uploadCamera=(shader._uploadCamera!==camera)|| switchShaderLoop;
  13292. if (uploadCamera || switchShader){
  13293. shader.uploadUniforms(shader._cameraUniformParamsMap,camera._shaderValues,uploadCamera);
  13294. shader._uploadCamera=camera;
  13295. };
  13296. var uploadMaterial=(shader._uploadMaterial!==this._material)|| switchShaderLoop;
  13297. if (uploadMaterial || switchShader){
  13298. shader.uploadUniforms(shader._materialUniformParamsMap,this._material._shaderValues,uploadMaterial);
  13299. shader._uploadMaterial=this._material;
  13300. }
  13301. this._mesh._bufferState.bind();
  13302. this._mesh._render(state);
  13303. WebGLContext.setDepthFunc(gl,/*laya.webgl.WebGLContext.LESS*/0x0201);
  13304. WebGLContext.setDepthMask(gl,true);
  13305. }
  13306. }
  13307. /**
  13308. *@private
  13309. */
  13310. __proto.destroy=function(){
  13311. if (this._material){
  13312. this._material._removeReference();
  13313. this._material=null;
  13314. }
  13315. }
  13316. /**
  13317. *设置材质。
  13318. *@param 材质。
  13319. */
  13320. /**
  13321. *获取材质。
  13322. *@return 材质。
  13323. */
  13324. __getset(0,__proto,'material',function(){
  13325. return this._material;
  13326. },function(value){
  13327. if (this._material!==value){
  13328. (this._material)&& (this._material._removeReference());
  13329. (value)&& (value._addReference());
  13330. this._material=value;
  13331. }
  13332. });
  13333. /**
  13334. *设置网格。
  13335. *@param 网格。
  13336. */
  13337. /**
  13338. *获取网格。
  13339. *@return 网格。
  13340. */
  13341. __getset(0,__proto,'mesh',function(){
  13342. return this._mesh;
  13343. },function(value){
  13344. if (this._mesh!==value){
  13345. this._mesh=value;
  13346. }
  13347. });
  13348. return SkyRenderer;
  13349. })()
  13350. /**
  13351. *<code>AnimatorStateScript</code> 类用于动画状态脚本的父类,该类为抽象类,不允许实例。
  13352. */
  13353. //class laya.d3.animation.AnimatorStateScript
  13354. var AnimatorStateScript=(function(){
  13355. /**
  13356. *创建一个新的 <code>AnimatorStateScript</code> 实例。
  13357. */
  13358. function AnimatorStateScript(){}
  13359. __class(AnimatorStateScript,'laya.d3.animation.AnimatorStateScript');
  13360. var __proto=AnimatorStateScript.prototype;
  13361. /**
  13362. *动画状态开始时执行。
  13363. */
  13364. __proto.onStateEnter=function(){}
  13365. /**
  13366. *动画状态更新时执行。
  13367. */
  13368. __proto.onStateUpdate=function(){}
  13369. /**
  13370. *动画状态退出时执行。
  13371. */
  13372. __proto.onStateExit=function(){}
  13373. return AnimatorStateScript;
  13374. })()
  13375. /**
  13376. *@private
  13377. */
  13378. //class laya.d3.core.render.BatchMark
  13379. var BatchMark=(function(){
  13380. function BatchMark(){
  13381. /**@private */
  13382. this.updateMark=-1;
  13383. /**@private */
  13384. this.indexInList=-1;
  13385. /**@private */
  13386. this.batched=false;
  13387. }
  13388. __class(BatchMark,'laya.d3.core.render.BatchMark');
  13389. return BatchMark;
  13390. })()
  13391. /**
  13392. *<code>HitResult</code> 类用于实现射线检测或形状扫描的结果。
  13393. */
  13394. //class laya.d3.physics.HitResult
  13395. var HitResult=(function(){
  13396. function HitResult(){
  13397. /**是否成功。 */
  13398. this.succeeded=false;
  13399. /**发生碰撞的碰撞组件。*/
  13400. this.collider=null;
  13401. /**碰撞分数。 */
  13402. this.hitFraction=0;
  13403. this.point=new Vector3();
  13404. this.normal=new Vector3();
  13405. }
  13406. __class(HitResult,'laya.d3.physics.HitResult');
  13407. return HitResult;
  13408. })()
  13409. /**
  13410. *<code>GradientSize</code> 类用于创建渐变尺寸。
  13411. */
  13412. //class laya.d3.core.particleShuriKen.module.GradientSize
  13413. var GradientSize=(function(){
  13414. function GradientSize(){
  13415. /**@private */
  13416. this._type=0;
  13417. /**@private */
  13418. this._separateAxes=false;
  13419. /**@private */
  13420. this._gradient=null;
  13421. /**@private */
  13422. this._gradientX=null;
  13423. /**@private */
  13424. this._gradientY=null;
  13425. /**@private */
  13426. this._gradientZ=null;
  13427. /**@private */
  13428. this._constantMin=NaN;
  13429. /**@private */
  13430. this._constantMax=NaN;
  13431. /**@private */
  13432. this._constantMinSeparate=null;
  13433. /**@private */
  13434. this._constantMaxSeparate=null;
  13435. /**@private */
  13436. this._gradientMin=null;
  13437. /**@private */
  13438. this._gradientMax=null;
  13439. /**@private */
  13440. this._gradientXMin=null;
  13441. /**@private */
  13442. this._gradientXMax=null;
  13443. /**@private */
  13444. this._gradientYMin=null;
  13445. /**@private */
  13446. this._gradientYMax=null;
  13447. /**@private */
  13448. this._gradientZMin=null;
  13449. /**@private */
  13450. this._gradientZMax=null;
  13451. }
  13452. __class(GradientSize,'laya.d3.core.particleShuriKen.module.GradientSize');
  13453. var __proto=GradientSize.prototype;
  13454. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  13455. /**
  13456. *获取最大尺寸。
  13457. */
  13458. __proto.getMaxSizeInGradient=function(){
  13459. var i=0,n=0;
  13460. var maxSize=-Number.MAX_VALUE;
  13461. switch (this._type){
  13462. case 0:
  13463. if (this._separateAxes){
  13464. for (i=0,n=this._gradientX.gradientCount;i < n;i++)
  13465. maxSize=Math.max(maxSize,this._gradientX.getValueByIndex(i));
  13466. for (i=0,n=this._gradientY.gradientCount;i < n;i++)
  13467. maxSize=Math.max(maxSize,this._gradientY.getValueByIndex(i));
  13468. }else {
  13469. for (i=0,n=this._gradient.gradientCount;i < n;i++)
  13470. maxSize=Math.max(maxSize,this._gradient.getValueByIndex(i));
  13471. }
  13472. break ;
  13473. case 1:
  13474. if (this._separateAxes){
  13475. maxSize=Math.max(this._constantMinSeparate.x,this._constantMaxSeparate.x);
  13476. maxSize=Math.max(maxSize,this._constantMinSeparate.y);
  13477. maxSize=Math.max(maxSize,this._constantMaxSeparate.y);
  13478. }else {
  13479. maxSize=Math.max(this._constantMin,this._constantMax);
  13480. }
  13481. break ;
  13482. case 2:
  13483. if (this._separateAxes){
  13484. for (i=0,n=this._gradientXMin.gradientCount;i < n;i++)
  13485. maxSize=Math.max(maxSize,this._gradientXMin.getValueByIndex(i));
  13486. for (i=0,n=this._gradientXMax.gradientCount;i < n;i++)
  13487. maxSize=Math.max(maxSize,this._gradientXMax.getValueByIndex(i));
  13488. for (i=0,n=this._gradientYMin.gradientCount;i < n;i++)
  13489. maxSize=Math.max(maxSize,this._gradientYMin.getValueByIndex(i));
  13490. for (i=0,n=this._gradientZMax.gradientCount;i < n;i++)
  13491. maxSize=Math.max(maxSize,this._gradientZMax.getValueByIndex(i));
  13492. }else {
  13493. for (i=0,n=this._gradientMin.gradientCount;i < n;i++)
  13494. maxSize=Math.max(maxSize,this._gradientMin.getValueByIndex(i));
  13495. for (i=0,n=this._gradientMax.gradientCount;i < n;i++)
  13496. maxSize=Math.max(maxSize,this._gradientMax.getValueByIndex(i));
  13497. }
  13498. break ;
  13499. }
  13500. return maxSize;
  13501. }
  13502. /**
  13503. *克隆。
  13504. *@param destObject 克隆源。
  13505. */
  13506. __proto.cloneTo=function(destObject){
  13507. var destGradientSize=destObject;
  13508. destGradientSize._type=this._type;
  13509. destGradientSize._separateAxes=this._separateAxes;
  13510. this._gradient.cloneTo(destGradientSize._gradient);
  13511. this._gradientX.cloneTo(destGradientSize._gradientX);
  13512. this._gradientY.cloneTo(destGradientSize._gradientY);
  13513. this._gradientZ.cloneTo(destGradientSize._gradientZ);
  13514. destGradientSize._constantMin=this._constantMin;
  13515. destGradientSize._constantMax=this._constantMax;
  13516. this._constantMinSeparate.cloneTo(destGradientSize._constantMinSeparate);
  13517. this._constantMaxSeparate.cloneTo(destGradientSize._constantMaxSeparate);
  13518. this._gradientMin.cloneTo(destGradientSize._gradientMin);
  13519. this._gradientMax.cloneTo(destGradientSize._gradientMax);
  13520. this._gradientXMin.cloneTo(destGradientSize._gradientXMin);
  13521. this._gradientXMax.cloneTo(destGradientSize._gradientXMax);
  13522. this._gradientYMin.cloneTo(destGradientSize._gradientYMin);
  13523. this._gradientYMax.cloneTo(destGradientSize._gradientYMax);
  13524. this._gradientZMin.cloneTo(destGradientSize._gradientZMin);
  13525. this._gradientZMax.cloneTo(destGradientSize._gradientZMax);
  13526. }
  13527. /**
  13528. *克隆。
  13529. *@return 克隆副本。
  13530. */
  13531. __proto.clone=function(){
  13532. var destGradientSize=/*__JS__ */new this.constructor();
  13533. this.cloneTo(destGradientSize);
  13534. return destGradientSize;
  13535. }
  13536. /**
  13537. *渐变尺寸Z。
  13538. */
  13539. __getset(0,__proto,'gradientZ',function(){
  13540. return this._gradientZ;
  13541. });
  13542. /**
  13543. *渐变尺寸。
  13544. */
  13545. __getset(0,__proto,'gradient',function(){
  13546. return this._gradient;
  13547. });
  13548. /**
  13549. *是否分轴。
  13550. */
  13551. __getset(0,__proto,'separateAxes',function(){
  13552. return this._separateAxes;
  13553. });
  13554. /**
  13555. *生命周期尺寸类型,0曲线模式,1随机双常量模式,2随机双曲线模式。
  13556. */
  13557. __getset(0,__proto,'type',function(){
  13558. return this._type;
  13559. });
  13560. /**
  13561. *渐变最小尺寸。
  13562. */
  13563. __getset(0,__proto,'gradientMin',function(){
  13564. return this._gradientMin;
  13565. });
  13566. /**
  13567. *最小随机双固定尺寸。
  13568. */
  13569. __getset(0,__proto,'constantMin',function(){
  13570. return this._constantMin;
  13571. });
  13572. /**
  13573. *渐变尺寸X。
  13574. */
  13575. __getset(0,__proto,'gradientX',function(){
  13576. return this._gradientX;
  13577. });
  13578. /**
  13579. *渐变尺寸Y。
  13580. */
  13581. __getset(0,__proto,'gradientY',function(){
  13582. return this._gradientY;
  13583. });
  13584. /**
  13585. *渐变最大尺寸。
  13586. */
  13587. __getset(0,__proto,'gradientMax',function(){
  13588. return this._gradientMax;
  13589. });
  13590. /**
  13591. *最大随机双固定尺寸。
  13592. */
  13593. __getset(0,__proto,'constantMax',function(){
  13594. return this._constantMax;
  13595. });
  13596. /**
  13597. *最小分轴随机双固定尺寸。
  13598. */
  13599. __getset(0,__proto,'constantMinSeparate',function(){
  13600. return this._constantMinSeparate;
  13601. });
  13602. /**
  13603. *最小分轴随机双固定尺寸。
  13604. */
  13605. __getset(0,__proto,'constantMaxSeparate',function(){
  13606. return this._constantMaxSeparate;
  13607. });
  13608. /**
  13609. *渐变最小尺寸X。
  13610. */
  13611. __getset(0,__proto,'gradientXMin',function(){
  13612. return this._gradientXMin;
  13613. });
  13614. /**
  13615. *渐变最大尺寸X。
  13616. */
  13617. __getset(0,__proto,'gradientXMax',function(){
  13618. return this._gradientXMax;
  13619. });
  13620. /**
  13621. *渐变最小尺寸Y。
  13622. */
  13623. __getset(0,__proto,'gradientYMin',function(){
  13624. return this._gradientYMin;
  13625. });
  13626. /**
  13627. *渐变最大尺寸Y。
  13628. */
  13629. __getset(0,__proto,'gradientYMax',function(){
  13630. return this._gradientYMax;
  13631. });
  13632. /**
  13633. *渐变最小尺寸Z。
  13634. */
  13635. __getset(0,__proto,'gradientZMin',function(){
  13636. return this._gradientZMin;
  13637. });
  13638. /**
  13639. *渐变最大尺寸Z。
  13640. */
  13641. __getset(0,__proto,'gradientZMax',function(){
  13642. return this._gradientZMax;
  13643. });
  13644. GradientSize.createByGradient=function(gradient){
  13645. var gradientSize=new GradientSize();
  13646. gradientSize._type=0;
  13647. gradientSize._separateAxes=false;
  13648. gradientSize._gradient=gradient;
  13649. return gradientSize;
  13650. }
  13651. GradientSize.createByGradientSeparate=function(gradientX,gradientY,gradientZ){
  13652. var gradientSize=new GradientSize();
  13653. gradientSize._type=0;
  13654. gradientSize._separateAxes=true;
  13655. gradientSize._gradientX=gradientX;
  13656. gradientSize._gradientY=gradientY;
  13657. gradientSize._gradientZ=gradientZ;
  13658. return gradientSize;
  13659. }
  13660. GradientSize.createByRandomTwoConstant=function(constantMin,constantMax){
  13661. var gradientSize=new GradientSize();
  13662. gradientSize._type=1;
  13663. gradientSize._separateAxes=false;
  13664. gradientSize._constantMin=constantMin;
  13665. gradientSize._constantMax=constantMax;
  13666. return gradientSize;
  13667. }
  13668. GradientSize.createByRandomTwoConstantSeparate=function(constantMinSeparate,constantMaxSeparate){
  13669. var gradientSize=new GradientSize();
  13670. gradientSize._type=1;
  13671. gradientSize._separateAxes=true;
  13672. gradientSize._constantMinSeparate=constantMinSeparate;
  13673. gradientSize._constantMaxSeparate=constantMaxSeparate;
  13674. return gradientSize;
  13675. }
  13676. GradientSize.createByRandomTwoGradient=function(gradientMin,gradientMax){
  13677. var gradientSize=new GradientSize();
  13678. gradientSize._type=2;
  13679. gradientSize._separateAxes=false;
  13680. gradientSize._gradientMin=gradientMin;
  13681. gradientSize._gradientMax=gradientMax;
  13682. return gradientSize;
  13683. }
  13684. GradientSize.createByRandomTwoGradientSeparate=function(gradientXMin,gradientXMax,gradientYMin,gradientYMax,gradientZMin,gradientZMax){
  13685. var gradientSize=new GradientSize();
  13686. gradientSize._type=2;
  13687. gradientSize._separateAxes=true;
  13688. gradientSize._gradientXMin=gradientXMin;
  13689. gradientSize._gradientXMax=gradientXMax;
  13690. gradientSize._gradientYMin=gradientYMin;
  13691. gradientSize._gradientYMax=gradientYMax;
  13692. gradientSize._gradientZMin=gradientZMin;
  13693. gradientSize._gradientZMax=gradientZMax;
  13694. return gradientSize;
  13695. }
  13696. return GradientSize;
  13697. })()
  13698. /**
  13699. *<code>DetailTextureInfo</code> 类用于描述地形细节纹理。
  13700. */
  13701. //class laya.d3.terrain.unit.ChunkInfo
  13702. var ChunkInfo=(function(){
  13703. function ChunkInfo(){
  13704. this.alphaMap=null;
  13705. this.detailID=null;
  13706. this.normalMap=null;
  13707. }
  13708. __class(ChunkInfo,'laya.d3.terrain.unit.ChunkInfo');
  13709. return ChunkInfo;
  13710. })()
  13711. /**
  13712. *@private
  13713. *<code>shaderVariable</code> 类用于保存shader变量上传相关信息。
  13714. */
  13715. //class laya.d3.shader.ShaderVariable
  13716. var ShaderVariable=(function(){
  13717. function ShaderVariable(){
  13718. /**@private */
  13719. //this.name=null;
  13720. /**@private */
  13721. //this.type=0;
  13722. /**@private */
  13723. //this.location=0;
  13724. /**@private */
  13725. //this.isArray=false;
  13726. /**@private */
  13727. //this.textureID=0;
  13728. /**@private */
  13729. //this.dataOffset=0;
  13730. /**@private */
  13731. //this.caller=null;
  13732. /**@private */
  13733. //this.fun=null;
  13734. /**@private */
  13735. //this.uploadedValue=null;
  13736. this.textureID=-1;
  13737. }
  13738. __class(ShaderVariable,'laya.d3.shader.ShaderVariable');
  13739. return ShaderVariable;
  13740. })()
  13741. /**
  13742. *@private
  13743. */
  13744. //class laya.d3.animation.KeyframeNode
  13745. var KeyframeNode=(function(){
  13746. function KeyframeNode(){
  13747. /**@private */
  13748. this._indexInList=0;
  13749. /**@private */
  13750. this.type=0;
  13751. /**@private */
  13752. this.fullPath=null;
  13753. /**@private */
  13754. this.propertyOwner=null;
  13755. /**@private */
  13756. this.data=null;
  13757. this._ownerPath=[];
  13758. this._propertys=[];
  13759. this._keyFrames=[];
  13760. }
  13761. __class(KeyframeNode,'laya.d3.animation.KeyframeNode');
  13762. var __proto=KeyframeNode.prototype;
  13763. /**
  13764. *@private
  13765. */
  13766. __proto._setOwnerPathCount=function(value){
  13767. this._ownerPath.length=value;
  13768. }
  13769. /**
  13770. *@private
  13771. */
  13772. __proto._setOwnerPathByIndex=function(index,value){
  13773. this._ownerPath[index]=value;
  13774. }
  13775. /**
  13776. *@private
  13777. */
  13778. __proto._joinOwnerPath=function(sep){
  13779. return this._ownerPath.join(sep);
  13780. }
  13781. /**
  13782. *@private
  13783. */
  13784. __proto._setPropertyCount=function(value){
  13785. this._propertys.length=value;
  13786. }
  13787. /**
  13788. *@private
  13789. */
  13790. __proto._setPropertyByIndex=function(index,value){
  13791. this._propertys[index]=value;
  13792. }
  13793. /**
  13794. *@private
  13795. */
  13796. __proto._joinProperty=function(sep){
  13797. return this._propertys.join(sep);
  13798. }
  13799. /**
  13800. *@private
  13801. */
  13802. __proto._setKeyframeCount=function(value){
  13803. this._keyFrames.length=value;
  13804. }
  13805. /**
  13806. *@private
  13807. */
  13808. __proto._setKeyframeByIndex=function(index,value){
  13809. this._keyFrames[index]=value;
  13810. }
  13811. /**
  13812. *通过索引获取精灵路径。
  13813. *@param index 索引。
  13814. */
  13815. __proto.getOwnerPathByIndex=function(index){
  13816. return this._ownerPath[index];
  13817. }
  13818. /**
  13819. *通过索引获取属性路径。
  13820. *@param index 索引。
  13821. */
  13822. __proto.getPropertyByIndex=function(index){
  13823. return this._propertys[index];
  13824. }
  13825. /**
  13826. *通过索引获取帧。
  13827. *@param index 索引。
  13828. */
  13829. __proto.getKeyframeByIndex=function(index){
  13830. return this._keyFrames[index];
  13831. }
  13832. /**
  13833. *获取精灵路径个数。
  13834. *@return 精灵路径个数。
  13835. */
  13836. __getset(0,__proto,'ownerPathCount',function(){
  13837. return this._ownerPath.length;
  13838. });
  13839. /**
  13840. *获取属性路径个数。
  13841. *@return 数量路径个数。
  13842. */
  13843. __getset(0,__proto,'propertyCount',function(){
  13844. return this._propertys.length;
  13845. });
  13846. /**
  13847. *获取帧个数。
  13848. *帧个数。
  13849. */
  13850. __getset(0,__proto,'keyFramesCount',function(){
  13851. return this._keyFrames.length;
  13852. });
  13853. return KeyframeNode;
  13854. })()
  13855. /**
  13856. *<code>GradientVelocity</code> 类用于创建渐变速度。
  13857. */
  13858. //class laya.d3.core.particleShuriKen.module.GradientVelocity
  13859. var GradientVelocity=(function(){
  13860. function GradientVelocity(){
  13861. /**@private */
  13862. this._type=0;
  13863. /**@private */
  13864. this._constant=null;
  13865. /**@private */
  13866. this._gradientX=null;
  13867. /**@private */
  13868. this._gradientY=null;
  13869. /**@private */
  13870. this._gradientZ=null;
  13871. /**@private */
  13872. this._constantMin=null;
  13873. /**@private */
  13874. this._constantMax=null;
  13875. /**@private */
  13876. this._gradientXMin=null;
  13877. /**@private */
  13878. this._gradientXMax=null;
  13879. /**@private */
  13880. this._gradientYMin=null;
  13881. /**@private */
  13882. this._gradientYMax=null;
  13883. /**@private */
  13884. this._gradientZMin=null;
  13885. /**@private */
  13886. this._gradientZMax=null;
  13887. }
  13888. __class(GradientVelocity,'laya.d3.core.particleShuriKen.module.GradientVelocity');
  13889. var __proto=GradientVelocity.prototype;
  13890. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  13891. /**
  13892. *克隆。
  13893. *@param destObject 克隆源。
  13894. */
  13895. __proto.cloneTo=function(destObject){
  13896. var destGradientVelocity=destObject;
  13897. destGradientVelocity._type=this._type;
  13898. this._constant.cloneTo(destGradientVelocity._constant);
  13899. this._gradientX.cloneTo(destGradientVelocity._gradientX);
  13900. this._gradientY.cloneTo(destGradientVelocity._gradientY);
  13901. this._gradientZ.cloneTo(destGradientVelocity._gradientZ);
  13902. this._constantMin.cloneTo(destGradientVelocity._constantMin);
  13903. this._constantMax.cloneTo(destGradientVelocity._constantMax);
  13904. this._gradientXMin.cloneTo(destGradientVelocity._gradientXMin);
  13905. this._gradientXMax.cloneTo(destGradientVelocity._gradientXMax);
  13906. this._gradientYMin.cloneTo(destGradientVelocity._gradientYMin);
  13907. this._gradientYMax.cloneTo(destGradientVelocity._gradientYMax);
  13908. this._gradientZMin.cloneTo(destGradientVelocity._gradientZMin);
  13909. this._gradientZMax.cloneTo(destGradientVelocity._gradientZMax);
  13910. }
  13911. /**
  13912. *克隆。
  13913. *@return 克隆副本。
  13914. */
  13915. __proto.clone=function(){
  13916. var destGradientVelocity=/*__JS__ */new this.constructor();
  13917. this.cloneTo(destGradientVelocity);
  13918. return destGradientVelocity;
  13919. }
  13920. /**
  13921. *渐变速度Z。
  13922. */
  13923. __getset(0,__proto,'gradientZ',function(){
  13924. return this._gradientZ;
  13925. });
  13926. /**固定速度。*/
  13927. __getset(0,__proto,'constant',function(){
  13928. return this._constant;
  13929. });
  13930. /**
  13931. *生命周期速度类型,0常量模式,1曲线模式,2随机双常量模式,3随机双曲线模式。
  13932. */
  13933. __getset(0,__proto,'type',function(){
  13934. return this._type;
  13935. });
  13936. /**
  13937. *渐变最大速度X。
  13938. */
  13939. __getset(0,__proto,'gradientXMax',function(){
  13940. return this._gradientXMax;
  13941. });
  13942. /**最小固定速度。*/
  13943. __getset(0,__proto,'constantMin',function(){
  13944. return this._constantMin;
  13945. });
  13946. /**
  13947. *渐变速度X。
  13948. */
  13949. __getset(0,__proto,'gradientX',function(){
  13950. return this._gradientX;
  13951. });
  13952. /**
  13953. *渐变速度Y。
  13954. */
  13955. __getset(0,__proto,'gradientY',function(){
  13956. return this._gradientY;
  13957. });
  13958. /**
  13959. *渐变最小速度X。
  13960. */
  13961. __getset(0,__proto,'gradientXMin',function(){
  13962. return this._gradientXMin;
  13963. });
  13964. /**最大固定速度。*/
  13965. __getset(0,__proto,'constantMax',function(){
  13966. return this._constantMax;
  13967. });
  13968. /**
  13969. *渐变最小速度Y。
  13970. */
  13971. __getset(0,__proto,'gradientYMin',function(){
  13972. return this._gradientYMin;
  13973. });
  13974. /**
  13975. *渐变最大速度Y。
  13976. */
  13977. __getset(0,__proto,'gradientYMax',function(){
  13978. return this._gradientYMax;
  13979. });
  13980. /**
  13981. *渐变最小速度Z。
  13982. */
  13983. __getset(0,__proto,'gradientZMin',function(){
  13984. return this._gradientZMin;
  13985. });
  13986. /**
  13987. *渐变最大速度Z。
  13988. */
  13989. __getset(0,__proto,'gradientZMax',function(){
  13990. return this._gradientZMax;
  13991. });
  13992. GradientVelocity.createByConstant=function(constant){
  13993. var gradientVelocity=new GradientVelocity();
  13994. gradientVelocity._type=0;
  13995. gradientVelocity._constant=constant;
  13996. return gradientVelocity;
  13997. }
  13998. GradientVelocity.createByGradient=function(gradientX,gradientY,gradientZ){
  13999. var gradientVelocity=new GradientVelocity();
  14000. gradientVelocity._type=1;
  14001. gradientVelocity._gradientX=gradientX;
  14002. gradientVelocity._gradientY=gradientY;
  14003. gradientVelocity._gradientZ=gradientZ;
  14004. return gradientVelocity;
  14005. }
  14006. GradientVelocity.createByRandomTwoConstant=function(constantMin,constantMax){
  14007. var gradientVelocity=new GradientVelocity();
  14008. gradientVelocity._type=2;
  14009. gradientVelocity._constantMin=constantMin;
  14010. gradientVelocity._constantMax=constantMax;
  14011. return gradientVelocity;
  14012. }
  14013. GradientVelocity.createByRandomTwoGradient=function(gradientXMin,gradientXMax,gradientYMin,gradientYMax,gradientZMin,gradientZMax){
  14014. var gradientVelocity=new GradientVelocity();
  14015. gradientVelocity._type=3;
  14016. gradientVelocity._gradientXMin=gradientXMin;
  14017. gradientVelocity._gradientXMax=gradientXMax;
  14018. gradientVelocity._gradientYMin=gradientYMin;
  14019. gradientVelocity._gradientYMax=gradientYMax;
  14020. gradientVelocity._gradientZMin=gradientZMin;
  14021. gradientVelocity._gradientZMax=gradientZMax;
  14022. return gradientVelocity;
  14023. }
  14024. return GradientVelocity;
  14025. })()
  14026. /**
  14027. *<code>Bounds</code> 类用于创建包围体。
  14028. */
  14029. //class laya.d3.core.Bounds
  14030. var Bounds=(function(){
  14031. function Bounds(min,max){
  14032. /**@private */
  14033. this._updateFlag=0;
  14034. this._center=new Vector3();
  14035. this._extent=new Vector3();
  14036. this._boundBox=new BoundBox(new Vector3(),new Vector3());
  14037. min.cloneTo(this._boundBox.min);
  14038. max.cloneTo(this._boundBox.max);
  14039. this._setUpdateFlag(0x04 | 0x08,true);
  14040. }
  14041. __class(Bounds,'laya.d3.core.Bounds');
  14042. var __proto=Bounds.prototype;
  14043. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  14044. /**
  14045. *设置包围盒的最小点。
  14046. *@param value 包围盒的最小点。
  14047. */
  14048. __proto.setMin=function(value){
  14049. var min=this._boundBox.min;
  14050. if (value!==min)
  14051. value.cloneTo(min);
  14052. this._setUpdateFlag(0x04 | 0x08,true);
  14053. this._setUpdateFlag(0x01,false);
  14054. }
  14055. /**
  14056. *获取包围盒的最小点。
  14057. *@return 包围盒的最小点。
  14058. */
  14059. __proto.getMin=function(){
  14060. var min=this._boundBox.min;
  14061. if (this._getUpdateFlag(0x01)){
  14062. this._getMin(this.getCenter(),this.getExtent(),min);
  14063. this._setUpdateFlag(0x01,false);
  14064. }
  14065. return min;
  14066. }
  14067. /**
  14068. *设置包围盒的最大点。
  14069. *@param value 包围盒的最大点。
  14070. */
  14071. __proto.setMax=function(value){
  14072. var max=this._boundBox.max;
  14073. if (value!==max)
  14074. value.cloneTo(max);
  14075. this._setUpdateFlag(0x04 | 0x08,true);
  14076. this._setUpdateFlag(0x02,false);
  14077. }
  14078. /**
  14079. *获取包围盒的最大点。
  14080. *@return 包围盒的最大点。
  14081. */
  14082. __proto.getMax=function(){
  14083. var max=this._boundBox.max;
  14084. if (this._getUpdateFlag(0x02)){
  14085. this._getMax(this.getCenter(),this.getExtent(),max);
  14086. this._setUpdateFlag(0x02,false);
  14087. }
  14088. return max;
  14089. }
  14090. /**
  14091. *设置包围盒的中心点。
  14092. *@param value 包围盒的中心点。
  14093. */
  14094. __proto.setCenter=function(value){
  14095. if (value!==this._center)
  14096. value.cloneTo(this._center);
  14097. this._setUpdateFlag(0x01 | 0x02,true);
  14098. this._setUpdateFlag(0x04,false);
  14099. }
  14100. /**
  14101. *获取包围盒的中心点。
  14102. *@return 包围盒的中心点。
  14103. */
  14104. __proto.getCenter=function(){
  14105. if (this._getUpdateFlag(0x04)){
  14106. this._getCenter(this.getMin(),this.getMax(),this._center);
  14107. this._setUpdateFlag(0x04,false);
  14108. }
  14109. return this._center;
  14110. }
  14111. /**
  14112. *设置包围盒的范围。
  14113. *@param value 包围盒的范围。
  14114. */
  14115. __proto.setExtent=function(value){
  14116. if (value!==this._extent)
  14117. value.cloneTo(this._extent);
  14118. this._setUpdateFlag(0x01 | 0x02,true);
  14119. this._setUpdateFlag(0x08,false);
  14120. }
  14121. /**
  14122. *获取包围盒的范围。
  14123. *@return 包围盒的范围。
  14124. */
  14125. __proto.getExtent=function(){
  14126. if (this._getUpdateFlag(0x08)){
  14127. this._getExtent(this.getMin(),this.getMax(),this._extent);
  14128. this._setUpdateFlag(0x08,false);
  14129. }
  14130. return this._extent;
  14131. }
  14132. /**
  14133. *@private
  14134. */
  14135. __proto._getUpdateFlag=function(type){
  14136. return (this._updateFlag & type)!=0;
  14137. }
  14138. /**
  14139. *@private
  14140. */
  14141. __proto._setUpdateFlag=function(type,value){
  14142. if (value)
  14143. this._updateFlag |=type;
  14144. else
  14145. this._updateFlag &=~type;
  14146. }
  14147. /**
  14148. *@private
  14149. */
  14150. __proto._getCenter=function(min,max,out){
  14151. Vector3.add(min,max,out);
  14152. Vector3.scale(out,0.5,out);
  14153. }
  14154. /**
  14155. *@private
  14156. */
  14157. __proto._getExtent=function(min,max,out){
  14158. Vector3.subtract(max,min,out);
  14159. Vector3.scale(out,0.5,out);
  14160. }
  14161. /**
  14162. *@private
  14163. */
  14164. __proto._getMin=function(center,extent,out){
  14165. Vector3.subtract(center,extent,out);
  14166. }
  14167. /**
  14168. *@private
  14169. */
  14170. __proto._getMax=function(center,extent,out){
  14171. Vector3.add(center,extent,out);
  14172. }
  14173. /**
  14174. *@private
  14175. */
  14176. __proto._rotateExtents=function(extents,rotation,out){
  14177. var extentsX=extents.x;
  14178. var extentsY=extents.y;
  14179. var extentsZ=extents.z;
  14180. var matE=rotation.elements;
  14181. out.x=Math.abs(matE[0] *extentsX)+Math.abs(matE[4] *extentsY)+Math.abs(matE[8] *extentsZ);
  14182. out.y=Math.abs(matE[1] *extentsX)+Math.abs(matE[5] *extentsY)+Math.abs(matE[9] *extentsZ);
  14183. out.z=Math.abs(matE[2] *extentsX)+Math.abs(matE[6] *extentsY)+Math.abs(matE[10] *extentsZ);
  14184. }
  14185. /**
  14186. *@private
  14187. */
  14188. __proto._tranform=function(matrix,out){
  14189. var outCen=out._center;
  14190. var outExt=out._extent;
  14191. Vector3.transformCoordinate(this.getCenter(),matrix,outCen);
  14192. this._rotateExtents(this.getExtent(),matrix,outExt);
  14193. out._boundBox.setCenterAndExtent(outCen,outExt);
  14194. out._updateFlag=0;
  14195. }
  14196. /**
  14197. *@private
  14198. */
  14199. __proto._getBoundBox=function(){
  14200. var min=this._boundBox.min;
  14201. if (this._getUpdateFlag(0x01)){
  14202. this._getMin(this.getCenter(),this.getExtent(),min);
  14203. this._setUpdateFlag(0x01,false);
  14204. };
  14205. var max=this._boundBox.max;
  14206. if (this._getUpdateFlag(0x02)){
  14207. this._getMax(this.getCenter(),this.getExtent(),max);
  14208. this._setUpdateFlag(0x02,false);
  14209. }
  14210. return this._boundBox;
  14211. }
  14212. /**
  14213. *克隆。
  14214. *@param destObject 克隆源。
  14215. */
  14216. __proto.cloneTo=function(destObject){
  14217. var destBounds=destObject;
  14218. this.getMin().cloneTo(destBounds._boundBox.min);
  14219. this.getMax().cloneTo(destBounds._boundBox.max);
  14220. this.getCenter().cloneTo(destBounds._center);
  14221. this.getExtent().cloneTo(destBounds._extent);
  14222. destBounds._updateFlag=0;
  14223. }
  14224. /**
  14225. *克隆。
  14226. *@return 克隆副本。
  14227. */
  14228. __proto.clone=function(){
  14229. var dest=/*__JS__ */new this.constructor();
  14230. this.cloneTo(dest);
  14231. return dest;
  14232. }
  14233. Bounds._UPDATE_MIN=0x01;
  14234. Bounds._UPDATE_MAX=0x02;
  14235. Bounds._UPDATE_CENTER=0x04;
  14236. Bounds._UPDATE_EXTENT=0x08;
  14237. return Bounds;
  14238. })()
  14239. /**
  14240. *<code>StartFrame</code> 类用于创建开始帧。
  14241. */
  14242. //class laya.d3.core.particleShuriKen.module.StartFrame
  14243. var StartFrame=(function(){
  14244. function StartFrame(){
  14245. /**@private */
  14246. this._type=0;
  14247. /**@private */
  14248. this._constant=NaN;
  14249. /**@private */
  14250. this._constantMin=NaN;
  14251. /**@private */
  14252. this._constantMax=NaN;
  14253. }
  14254. __class(StartFrame,'laya.d3.core.particleShuriKen.module.StartFrame');
  14255. var __proto=StartFrame.prototype;
  14256. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  14257. /**
  14258. *克隆。
  14259. *@param destObject 克隆源。
  14260. */
  14261. __proto.cloneTo=function(destObject){
  14262. var destStartFrame=destObject;
  14263. destStartFrame._type=this._type;
  14264. destStartFrame._constant=this._constant;
  14265. destStartFrame._constantMin=this._constantMin;
  14266. destStartFrame._constantMax=this._constantMax;
  14267. }
  14268. /**
  14269. *克隆。
  14270. *@return 克隆副本。
  14271. */
  14272. __proto.clone=function(){
  14273. var destStartFrame=/*__JS__ */new this.constructor();
  14274. this.cloneTo(destStartFrame);
  14275. return destStartFrame;
  14276. }
  14277. /**
  14278. *固定帧。
  14279. */
  14280. __getset(0,__proto,'constant',function(){
  14281. return this._constant;
  14282. });
  14283. /**
  14284. *开始帧类型,0常量模式,1随机双常量模式。
  14285. */
  14286. __getset(0,__proto,'type',function(){
  14287. return this._type;
  14288. });
  14289. /**
  14290. *最小固定帧。
  14291. */
  14292. __getset(0,__proto,'constantMin',function(){
  14293. return this._constantMin;
  14294. });
  14295. /**
  14296. *最大固定帧。
  14297. */
  14298. __getset(0,__proto,'constantMax',function(){
  14299. return this._constantMax;
  14300. });
  14301. StartFrame.createByConstant=function(constant){
  14302. var rotationOverLifetime=new StartFrame();
  14303. rotationOverLifetime._type=0;
  14304. rotationOverLifetime._constant=constant;
  14305. return rotationOverLifetime;
  14306. }
  14307. StartFrame.createByRandomTwoConstant=function(constantMin,constantMax){
  14308. var rotationOverLifetime=new StartFrame();
  14309. rotationOverLifetime._type=1;
  14310. rotationOverLifetime._constantMin=constantMin;
  14311. rotationOverLifetime._constantMax=constantMax;
  14312. return rotationOverLifetime;
  14313. }
  14314. return StartFrame;
  14315. })()
  14316. /**
  14317. *<code>BoneNode</code> 类用于实现骨骼节点。
  14318. */
  14319. //class laya.d3.animation.AnimationNode
  14320. var AnimationNode=(function(){
  14321. function AnimationNode(localPosition,localRotation,localScale,worldMatrix){
  14322. /**@private */
  14323. //this._children=null;
  14324. /**@private */
  14325. //this._parent=null;
  14326. /**@private [只读]*/
  14327. //this.transform=null;
  14328. /**节点名称。 */
  14329. //this.name=null;
  14330. /**@private [NATIVE]*/
  14331. //this._worldMatrixIndex=0;
  14332. this._children=[];
  14333. this.transform=new AnimationTransform3D(this,localPosition,localRotation,localScale,worldMatrix);
  14334. }
  14335. __class(AnimationNode,'laya.d3.animation.AnimationNode');
  14336. var __proto=AnimationNode.prototype;
  14337. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  14338. /**
  14339. *添加子节点。
  14340. *@param child 子节点。
  14341. */
  14342. __proto.addChild=function(child){
  14343. child._parent=this;
  14344. child.transform.setParent(this.transform);
  14345. this._children.push(child);
  14346. }
  14347. /**
  14348. *移除子节点。
  14349. *@param child 子节点。
  14350. */
  14351. __proto.removeChild=function(child){
  14352. var index=this._children.indexOf(child);
  14353. (index!==-1)&& (this._children.splice(index,1));
  14354. }
  14355. /**
  14356. *根据名字获取子节点。
  14357. *@param name 名字。
  14358. */
  14359. __proto.getChildByName=function(name){
  14360. for (var i=0,n=this._children.length;i < n;i++){
  14361. var child=this._children[i];
  14362. if (child.name===name)
  14363. return child;
  14364. }
  14365. return null;
  14366. }
  14367. /**
  14368. *根据索引获取子节点。
  14369. *@param index 索引。
  14370. */
  14371. __proto.getChildByIndex=function(index){
  14372. return this._children[index];
  14373. }
  14374. /**
  14375. *获取子节点的个数。
  14376. */
  14377. __proto.getChildCount=function(){
  14378. return this._children.length;
  14379. }
  14380. /**
  14381. *克隆。
  14382. *@param destObject 克隆源。
  14383. */
  14384. __proto.cloneTo=function(destObject){
  14385. var destNode=destObject;
  14386. destNode.name=this.name;
  14387. for (var i=0,n=this._children.length;i < n;i++){
  14388. var child=this._children[i];
  14389. var destChild=child.clone();
  14390. destNode.addChild(destChild);
  14391. var transform=child.transform;
  14392. var destTransform=destChild.transform;
  14393. var destLocalPosition=destTransform.localPosition;
  14394. var destLocalRotation=destTransform.localRotation;
  14395. var destLocalScale=destTransform.localScale;
  14396. transform.localPosition.cloneTo(destLocalPosition);
  14397. transform.localRotation.cloneTo(destLocalRotation);
  14398. transform.localScale.cloneTo(destLocalScale);
  14399. destTransform.localPosition=destLocalPosition;
  14400. destTransform.localRotation=destLocalRotation;
  14401. destTransform.localScale=destLocalScale;
  14402. }
  14403. }
  14404. /**
  14405. *克隆。
  14406. *@return 克隆副本。
  14407. */
  14408. __proto.clone=function(){
  14409. var dest=new AnimationNode();
  14410. this.cloneTo(dest);
  14411. return dest;
  14412. }
  14413. /**
  14414. *@private [NATIVE]
  14415. */
  14416. __proto._cloneNative=function(localPositions,localRotations,localScales,animationNodeWorldMatrixs,animationNodeParentIndices,parentIndex,avatar){
  14417. var curID=avatar._nativeCurCloneCount;
  14418. animationNodeParentIndices[curID]=parentIndex;
  14419. var localPosition=new Float32Array(localPositions.buffer,curID *3 *4,3);
  14420. var localRotation=new Float32Array(localRotations.buffer,curID *4 *4,4);
  14421. var localScale=new Float32Array(localScales.buffer,curID *3 *4,3);
  14422. var worldMatrix=new Float32Array(animationNodeWorldMatrixs.buffer,curID *16 *4,16);
  14423. var dest=new AnimationNode(localPosition,localRotation,localScale,worldMatrix);
  14424. dest._worldMatrixIndex=curID;
  14425. this._cloneToNative(dest,localPositions,localRotations,localScales,animationNodeWorldMatrixs,animationNodeParentIndices,curID,avatar);
  14426. return dest;
  14427. }
  14428. /**
  14429. *@private [NATIVE]
  14430. */
  14431. __proto._cloneToNative=function(destObject,localPositions,localRotations,localScales,animationNodeWorldMatrixs,animationNodeParentIndices,parentIndex,avatar){
  14432. var destNode=destObject;
  14433. destNode.name=this.name;
  14434. for (var i=0,n=this._children.length;i < n;i++){
  14435. var child=this._children[i];
  14436. avatar._nativeCurCloneCount++;
  14437. var destChild=child._cloneNative(localPositions,localRotations,localScales,animationNodeWorldMatrixs,animationNodeParentIndices,parentIndex,avatar);
  14438. destNode.addChild(destChild);
  14439. var transform=child.transform;
  14440. var destTransform=destChild.transform;
  14441. var destLocalPosition=destTransform.localPosition;
  14442. var destLocalRotation=destTransform.localRotation;
  14443. var destLocalScale=destTransform.localScale;
  14444. transform.localPosition.cloneTo(destLocalPosition);
  14445. transform.localRotation.cloneTo(destLocalRotation);
  14446. transform.localScale.cloneTo(destLocalScale);
  14447. destTransform.localPosition=destLocalPosition;
  14448. destTransform.localRotation=destLocalRotation;
  14449. destTransform.localScale=destLocalScale;
  14450. }
  14451. }
  14452. return AnimationNode;
  14453. })()
  14454. /**
  14455. *<code>PostProcess</code> 类用于创建后期处理组件。
  14456. */
  14457. //class laya.d3.component.PostProcess
  14458. var PostProcess=(function(){
  14459. function PostProcess(){
  14460. /**@private */
  14461. this._context=null;
  14462. this._compositeShader=Shader3D.find("PostProcessComposite");
  14463. this._compositeShaderData=new ShaderData();
  14464. this._compositeDefineData=new DefineDatas();
  14465. this._effects=[];
  14466. this._context=new PostProcessRenderContext();
  14467. this._context.compositeShaderData=this._compositeShaderData;
  14468. this._context.compositeDefineData=this._compositeDefineData;
  14469. }
  14470. __class(PostProcess,'laya.d3.component.PostProcess');
  14471. var __proto=PostProcess.prototype;
  14472. /**
  14473. *@private
  14474. */
  14475. __proto._init=function(camera,command){
  14476. this._context.camera=camera;
  14477. this._context.command=command;
  14478. }
  14479. /**
  14480. *@private
  14481. */
  14482. __proto._render=function(){
  14483. var screenTexture=RenderTexture.getTemporary(RenderContext3D.clientWidth,RenderContext3D.clientHeight,/*laya.resource.BaseTexture.FORMAT_R8G8B8*/0,/*laya.resource.BaseTexture.FORMAT_DEPTHSTENCIL_NONE*/3);
  14484. var cameraTarget=this._context.camera.getRenderTexture();
  14485. this._context.command.clear();
  14486. this._context.source=screenTexture;
  14487. this._context.destination=cameraTarget;
  14488. for (var i=0,n=this._effects.length;i < n;i++)
  14489. this._effects[i].render(this._context);
  14490. RenderTexture.setReleaseTemporary(screenTexture);
  14491. var tempRenderTextures=this._context.tempRenderTextures;
  14492. for (i=0,n=tempRenderTextures.length;i < n;i++)
  14493. RenderTexture.setReleaseTemporary(tempRenderTextures[i]);
  14494. }
  14495. /**
  14496. *添加后期处理效果。
  14497. */
  14498. __proto.addEffect=function(effect){
  14499. this._effects.push(effect);
  14500. }
  14501. /**
  14502. *移除后期处理效果。
  14503. */
  14504. __proto.removeEffect=function(effect){
  14505. var index=this._effects.indexOf(effect);
  14506. if (index!==-1)
  14507. this._effects.splice(index,1);
  14508. }
  14509. PostProcess.__init__=function(){
  14510. PostProcess.SHADERDEFINE_BLOOM_LOW=PostProcess.shaderDefines.registerDefine("BLOOM_LOW");
  14511. PostProcess.SHADERDEFINE_BLOOM=PostProcess.shaderDefines.registerDefine("BLOOM");
  14512. }
  14513. PostProcess.SHADERDEFINE_BLOOM_LOW=0;
  14514. PostProcess.SHADERDEFINE_BLOOM=0;
  14515. __static(PostProcess,
  14516. ['SHADERVALUE_MAINTEX',function(){return this.SHADERVALUE_MAINTEX=Shader3D.propertyNameToID("u_MainTex");},'SHADERVALUE_BLOOMTEX',function(){return this.SHADERVALUE_BLOOMTEX=Shader3D.propertyNameToID("u_BloomTex");},'SHADERVALUE_AUTOEXPOSURETEX',function(){return this.SHADERVALUE_AUTOEXPOSURETEX=Shader3D.propertyNameToID("u_AutoExposureTex");},'SHADERVALUE_BLOOM_DIRTTEX',function(){return this.SHADERVALUE_BLOOM_DIRTTEX=Shader3D.propertyNameToID("u_Bloom_DirtTex");},'SHADERVALUE_BLOOMTEX_TEXELSIZE',function(){return this.SHADERVALUE_BLOOMTEX_TEXELSIZE=Shader3D.propertyNameToID("u_BloomTex_TexelSize");},'SHADERVALUE_BLOOM_DIRTTILEOFFSET',function(){return this.SHADERVALUE_BLOOM_DIRTTILEOFFSET=Shader3D.propertyNameToID("u_Bloom_DirtTileOffset");},'SHADERVALUE_BLOOM_SETTINGS',function(){return this.SHADERVALUE_BLOOM_SETTINGS=Shader3D.propertyNameToID("u_Bloom_Settings");},'SHADERVALUE_BLOOM_COLOR',function(){return this.SHADERVALUE_BLOOM_COLOR=Shader3D.propertyNameToID("u_Bloom_Color");},'shaderDefines',function(){return this.shaderDefines=new ShaderDefines();}
  14517. ]);
  14518. return PostProcess;
  14519. })()
  14520. /**
  14521. *<code>Viewport</code> 类用于创建视口。
  14522. */
  14523. //class laya.d3.math.Viewport
  14524. var Viewport=(function(){
  14525. function Viewport(x,y,width,height){
  14526. /**X轴坐标*/
  14527. //this.x=NaN;
  14528. /**Y轴坐标*/
  14529. //this.y=NaN;
  14530. /**宽度*/
  14531. //this.width=NaN;
  14532. /**高度*/
  14533. //this.height=NaN;
  14534. /**最小深度*/
  14535. //this.minDepth=NaN;
  14536. /**最大深度*/
  14537. //this.maxDepth=NaN;
  14538. this.minDepth=0.0;
  14539. this.maxDepth=1.0;
  14540. this.x=x;
  14541. this.y=y;
  14542. this.width=width;
  14543. this.height=height;
  14544. }
  14545. __class(Viewport,'laya.d3.math.Viewport');
  14546. var __proto=Viewport.prototype;
  14547. /**
  14548. *变换一个三维向量。
  14549. *@param source 源三维向量。
  14550. *@param matrix 变换矩阵。
  14551. *@param vector 输出三维向量。
  14552. */
  14553. __proto.project=function(source,matrix,out){
  14554. Vector3.transformV3ToV3(source,matrix,out);
  14555. var matrixEleme=matrix.elements;
  14556. var a=(((source.x *matrixEleme[3])+(source.y *matrixEleme[7]))+(source.z *matrixEleme[11]))+matrixEleme[15];
  14557. if (a!==1.0){
  14558. out.x=out.x / a;
  14559. out.y=out.y / a;
  14560. out.z=out.z / a;
  14561. }
  14562. out.x=(((out.x+1.0)*0.5)*this.width)+this.x;
  14563. out.y=(((-out.y+1.0)*0.5)*this.height)+this.y;
  14564. out.z=(out.z *(this.maxDepth-this.minDepth))+this.minDepth;
  14565. }
  14566. __proto.project1=function(source,matrix,out){
  14567. var v4=Vector3._tempVector4;
  14568. Vector3.transformV3ToV4(source,matrix,v4);
  14569. var dist=v4.w;
  14570. if (dist < 1e-1 && dist >-1e-6)dist=1e-6;
  14571. v4.x /=dist;
  14572. v4.y /=dist;
  14573. v4.z /=dist;
  14574. out.x=(v4.x+1)*this.width / 2+this.x;
  14575. out.y=(-v4.y+1)*this.height / 2+this.y;
  14576. out.z=v4.w;
  14577. return;
  14578. }
  14579. /**
  14580. *反变换一个三维向量。
  14581. *@param source 源三维向量。
  14582. *@param matrix 变换矩阵。
  14583. *@param vector 输出三维向量。
  14584. */
  14585. __proto.unprojectFromMat=function(source,matrix,out){
  14586. var matrixEleme=matrix.elements;
  14587. out.x=(((source.x-this.x)/ (this.width))*2.0)-1.0;
  14588. out.y=-((((source.y-this.y)/ (this.height))*2.0)-1.0);
  14589. var halfDepth=(this.maxDepth-this.minDepth)/ 2;
  14590. out.z=(source.z-this.minDepth-halfDepth)/ halfDepth;
  14591. var a=(((out.x *matrixEleme[3])+(out.y *matrixEleme[7]))+(out.z *matrixEleme[11]))+matrixEleme[15];
  14592. Vector3.transformV3ToV3(out,matrix,out);
  14593. if (a!==1.0){
  14594. out.x=out.x / a;
  14595. out.y=out.y / a;
  14596. out.z=out.z / a;
  14597. }
  14598. }
  14599. /**
  14600. *反变换一个三维向量。
  14601. *@param source 源三维向量。
  14602. *@param projection 透视投影矩阵。
  14603. *@param view 视图矩阵。
  14604. *@param world 世界矩阵,可设置为null。
  14605. *@param out 输出向量。
  14606. */
  14607. __proto.unprojectFromWVP=function(source,projection,view,world,out){
  14608. Matrix4x4.multiply(projection,view,Viewport._tempMatrix4x4);
  14609. (world)&& (Matrix4x4.multiply(Viewport._tempMatrix4x4,world,Viewport._tempMatrix4x4));
  14610. Viewport._tempMatrix4x4.invert(Viewport._tempMatrix4x4);
  14611. this.unprojectFromMat(source,Viewport._tempMatrix4x4,out);
  14612. }
  14613. /**
  14614. *克隆
  14615. *@param out
  14616. */
  14617. __proto.cloneTo=function(out){
  14618. out.x=this.x;
  14619. out.y=this.y;
  14620. out.width=this.width;
  14621. out.height=this.height;
  14622. out.minDepth=this.minDepth;
  14623. out.maxDepth=this.maxDepth;
  14624. }
  14625. __static(Viewport,
  14626. ['_tempMatrix4x4',function(){return this._tempMatrix4x4=new Matrix4x4();}
  14627. ]);
  14628. return Viewport;
  14629. })()
  14630. /**
  14631. *<code>DetailTextureInfo</code> 类用于描述地形细节纹理。
  14632. */
  14633. //class laya.d3.terrain.unit.DetailTextureInfo
  14634. var DetailTextureInfo=(function(){
  14635. function DetailTextureInfo(){
  14636. this.diffuseTexture=null;
  14637. this.normalTexture=null;
  14638. this.scale=null;
  14639. this.offset=null;
  14640. }
  14641. __class(DetailTextureInfo,'laya.d3.terrain.unit.DetailTextureInfo');
  14642. return DetailTextureInfo;
  14643. })()
  14644. /**
  14645. *<code>OrientedBoundBox</code> 类用于创建OBB包围盒。
  14646. */
  14647. //class laya.d3.math.OrientedBoundBox
  14648. var OrientedBoundBox=(function(){
  14649. function OrientedBoundBox(extents,transformation){
  14650. /**每个轴长度的一半*/
  14651. this.extents=null;
  14652. /**这个矩阵表示包围盒的位置和缩放,它的平移向量表示该包围盒的中心*/
  14653. this.transformation=null;
  14654. this.extents=extents;
  14655. this.transformation=transformation;
  14656. }
  14657. __class(OrientedBoundBox,'laya.d3.math.OrientedBoundBox');
  14658. var __proto=OrientedBoundBox.prototype;
  14659. /**
  14660. *获取OBB包围盒的8个顶点。
  14661. *@param corners 返回顶点的输出队列。
  14662. */
  14663. __proto.getCorners=function(corners){
  14664. OrientedBoundBox._tempV30.x=this.extents.x;
  14665. OrientedBoundBox._tempV30.y=OrientedBoundBox._tempV30.z=0;
  14666. OrientedBoundBox._tempV31.y=this.extents.y;
  14667. OrientedBoundBox._tempV31.x=OrientedBoundBox._tempV31.z=0;
  14668. OrientedBoundBox._tempV32.z=this.extents.z;
  14669. OrientedBoundBox._tempV32.x=OrientedBoundBox._tempV32.y=0;
  14670. Vector3.TransformNormal(OrientedBoundBox._tempV30,this.transformation,OrientedBoundBox._tempV30);
  14671. Vector3.TransformNormal(OrientedBoundBox._tempV31,this.transformation,OrientedBoundBox._tempV31);
  14672. Vector3.TransformNormal(OrientedBoundBox._tempV32,this.transformation,OrientedBoundBox._tempV32);
  14673. var center=OrientedBoundBox._tempV33;
  14674. this.transformation.getTranslationVector(center);
  14675. corners.length=8;
  14676. Vector3.add(center,OrientedBoundBox._tempV30,OrientedBoundBox._tempV34);
  14677. Vector3.add(OrientedBoundBox._tempV34,OrientedBoundBox._tempV31,OrientedBoundBox._tempV34);
  14678. Vector3.add(OrientedBoundBox._tempV34,OrientedBoundBox._tempV32,corners[0]);
  14679. Vector3.add(center,OrientedBoundBox._tempV30,OrientedBoundBox._tempV34);
  14680. Vector3.add(OrientedBoundBox._tempV34,OrientedBoundBox._tempV31,OrientedBoundBox._tempV34);
  14681. Vector3.subtract(OrientedBoundBox._tempV34,OrientedBoundBox._tempV32,corners[1]);
  14682. Vector3.subtract(center,OrientedBoundBox._tempV30,OrientedBoundBox._tempV34);
  14683. Vector3.add(OrientedBoundBox._tempV34,OrientedBoundBox._tempV31,OrientedBoundBox._tempV34);
  14684. Vector3.subtract(OrientedBoundBox._tempV34,OrientedBoundBox._tempV32,corners[2]);
  14685. Vector3.subtract(center,OrientedBoundBox._tempV30,OrientedBoundBox._tempV34);
  14686. Vector3.add(OrientedBoundBox._tempV34,OrientedBoundBox._tempV31,OrientedBoundBox._tempV34);
  14687. Vector3.add(OrientedBoundBox._tempV34,OrientedBoundBox._tempV32,corners[3]);
  14688. Vector3.add(center,OrientedBoundBox._tempV30,OrientedBoundBox._tempV34);
  14689. Vector3.subtract(OrientedBoundBox._tempV34,OrientedBoundBox._tempV31,OrientedBoundBox._tempV34);
  14690. Vector3.add(OrientedBoundBox._tempV34,OrientedBoundBox._tempV32,corners[4]);
  14691. Vector3.add(center,OrientedBoundBox._tempV30,OrientedBoundBox._tempV34);
  14692. Vector3.subtract(OrientedBoundBox._tempV34,OrientedBoundBox._tempV31,OrientedBoundBox._tempV34);
  14693. Vector3.subtract(OrientedBoundBox._tempV34,OrientedBoundBox._tempV32,corners[5]);
  14694. Vector3.subtract(center,OrientedBoundBox._tempV30,OrientedBoundBox._tempV34);
  14695. Vector3.subtract(OrientedBoundBox._tempV34,OrientedBoundBox._tempV31,OrientedBoundBox._tempV34);
  14696. Vector3.subtract(OrientedBoundBox._tempV34,OrientedBoundBox._tempV32,corners[6]);
  14697. Vector3.subtract(center,OrientedBoundBox._tempV30,OrientedBoundBox._tempV34);
  14698. Vector3.subtract(OrientedBoundBox._tempV34,OrientedBoundBox._tempV31,OrientedBoundBox._tempV34);
  14699. Vector3.add(OrientedBoundBox._tempV34,OrientedBoundBox._tempV32,corners[7]);
  14700. }
  14701. /**
  14702. *变换该包围盒的矩阵信息。
  14703. *@param mat 矩阵
  14704. */
  14705. __proto.transform=function(mat){
  14706. Matrix4x4.multiply(this.transformation,mat,this.transformation);
  14707. }
  14708. /**
  14709. *缩放该包围盒
  14710. *@param scaling 各轴的缩放比。
  14711. */
  14712. __proto.scale=function(scaling){
  14713. Vector3.multiply(this.extents,scaling,this.extents);
  14714. }
  14715. /**
  14716. *平移该包围盒。
  14717. *@param translation 平移参数
  14718. */
  14719. __proto.translate=function(translation){
  14720. this.transformation.getTranslationVector(OrientedBoundBox._tempV30);
  14721. Vector3.add(OrientedBoundBox._tempV30,translation,OrientedBoundBox._tempV31);
  14722. this.transformation.setTranslationVector(OrientedBoundBox._tempV31);
  14723. }
  14724. /**
  14725. *该包围盒的尺寸。
  14726. *@param out 输出
  14727. */
  14728. __proto.Size=function(out){
  14729. Vector3.scale(this.extents,2,out);
  14730. }
  14731. /**
  14732. *该包围盒需要考虑的尺寸
  14733. *@param out 输出
  14734. */
  14735. __proto.getSize=function(out){
  14736. OrientedBoundBox._tempV30.x=this.extents.x;
  14737. OrientedBoundBox._tempV31.y=this.extents.y;
  14738. OrientedBoundBox._tempV32.z=this.extents.z;
  14739. Vector3.TransformNormal(OrientedBoundBox._tempV30,this.transformation,OrientedBoundBox._tempV30);
  14740. Vector3.TransformNormal(OrientedBoundBox._tempV31,this.transformation,OrientedBoundBox._tempV31);
  14741. Vector3.TransformNormal(OrientedBoundBox._tempV31,this.transformation,OrientedBoundBox._tempV32);
  14742. out.x=Vector3.scalarLength(OrientedBoundBox._tempV30);
  14743. out.y=Vector3.scalarLength(OrientedBoundBox._tempV31);
  14744. out.z=Vector3.scalarLength(OrientedBoundBox._tempV32);
  14745. }
  14746. /**
  14747. *该包围盒需要考虑尺寸的平方
  14748. *@param out 输出
  14749. */
  14750. __proto.getSizeSquared=function(out){
  14751. OrientedBoundBox._tempV30.x=this.extents.x;
  14752. OrientedBoundBox._tempV31.y=this.extents.y;
  14753. OrientedBoundBox._tempV32.z=this.extents.z;
  14754. Vector3.TransformNormal(OrientedBoundBox._tempV30,this.transformation,OrientedBoundBox._tempV30);
  14755. Vector3.TransformNormal(OrientedBoundBox._tempV31,this.transformation,OrientedBoundBox._tempV31);
  14756. Vector3.TransformNormal(OrientedBoundBox._tempV31,this.transformation,OrientedBoundBox._tempV32);
  14757. out.x=Vector3.scalarLengthSquared(OrientedBoundBox._tempV30);
  14758. out.y=Vector3.scalarLengthSquared(OrientedBoundBox._tempV31);
  14759. out.z=Vector3.scalarLengthSquared(OrientedBoundBox._tempV32);
  14760. }
  14761. /**
  14762. *该包围盒的几何中心
  14763. */
  14764. __proto.getCenter=function(center){
  14765. this.transformation.getTranslationVector(center);
  14766. }
  14767. /**
  14768. *该包围盒是否包含空间中一点
  14769. *@param point 点
  14770. *@return 返回位置关系
  14771. */
  14772. __proto.containsPoint=function(point){
  14773. var extentsEX=this.extents.x;
  14774. var extentsEY=this.extents.y;
  14775. var extentsEZ=this.extents.z;
  14776. this.transformation.invert(OrientedBoundBox._tempM0);
  14777. Vector3.transformCoordinate(point,OrientedBoundBox._tempM0,OrientedBoundBox._tempV30);
  14778. var _tempV30ex=Math.abs(OrientedBoundBox._tempV30.x);
  14779. var _tempV30ey=Math.abs(OrientedBoundBox._tempV30.y);
  14780. var _tempV30ez=Math.abs(OrientedBoundBox._tempV30.z);
  14781. if (MathUtils3D.nearEqual(_tempV30ex,extentsEX)&& MathUtils3D.nearEqual(_tempV30ey,extentsEY)&& MathUtils3D.nearEqual(_tempV30ez,extentsEZ))
  14782. return /*laya.d3.math.ContainmentType.Intersects*/2;
  14783. if (_tempV30ex < extentsEX && _tempV30ey < extentsEY && _tempV30ez < extentsEZ)
  14784. return /*laya.d3.math.ContainmentType.Contains*/1;
  14785. else
  14786. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  14787. }
  14788. /**
  14789. *该包围盒是否包含空间中多点
  14790. *@param point 点
  14791. *@return 返回位置关系
  14792. */
  14793. __proto.containsPoints=function(points){
  14794. var extentsex=this.extents.x;
  14795. var extentsey=this.extents.y;
  14796. var extentsez=this.extents.z;
  14797. this.transformation.invert(OrientedBoundBox._tempM0);
  14798. var containsAll=true;
  14799. var containsAny=false;
  14800. for (var i=0;i < points.length;i++){
  14801. Vector3.transformCoordinate(points[i],OrientedBoundBox._tempM0,OrientedBoundBox._tempV30);
  14802. var _tempV30ex=Math.abs(OrientedBoundBox._tempV30.x);
  14803. var _tempV30ey=Math.abs(OrientedBoundBox._tempV30.y);
  14804. var _tempV30ez=Math.abs(OrientedBoundBox._tempV30.z);
  14805. if (MathUtils3D.nearEqual(_tempV30ex,extentsex)&& MathUtils3D.nearEqual(_tempV30ey,extentsey)&& MathUtils3D.nearEqual(_tempV30ez,extentsez))
  14806. containsAny=true;
  14807. if (_tempV30ex < extentsex && _tempV30ey < extentsey && _tempV30ez < extentsez)
  14808. containsAny=true;
  14809. else
  14810. containsAll=false;
  14811. }
  14812. if (containsAll)
  14813. return /*laya.d3.math.ContainmentType.Contains*/1;
  14814. else if (containsAny)
  14815. return /*laya.d3.math.ContainmentType.Intersects*/2;
  14816. else
  14817. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  14818. }
  14819. /**
  14820. *该包围盒是否包含空间中一包围球
  14821. *@param sphere 包围球
  14822. *@param ignoreScale 是否考虑该包围盒的缩放
  14823. *@return 返回位置关系
  14824. */
  14825. __proto.containsSphere=function(sphere,ignoreScale){
  14826. (ignoreScale===void 0)&& (ignoreScale=false);
  14827. var extentsEX=this.extents.x;
  14828. var extentsEY=this.extents.y;
  14829. var extentsEZ=this.extents.z;
  14830. var sphereR=sphere.radius;
  14831. this.transformation.invert(OrientedBoundBox._tempM0);
  14832. Vector3.transformCoordinate(sphere.center,OrientedBoundBox._tempM0,OrientedBoundBox._tempV30);
  14833. var locRadius=NaN;
  14834. if (ignoreScale){
  14835. locRadius=sphereR;
  14836. }else {
  14837. Vector3.scale(Vector3._UnitX,sphereR,OrientedBoundBox._tempV31);
  14838. Vector3.TransformNormal(OrientedBoundBox._tempV31,OrientedBoundBox._tempM0,OrientedBoundBox._tempV31);
  14839. locRadius=Vector3.scalarLength(OrientedBoundBox._tempV31);
  14840. }
  14841. Vector3.scale(this.extents,-1,OrientedBoundBox._tempV32);
  14842. Vector3.Clamp(OrientedBoundBox._tempV30,OrientedBoundBox._tempV32,this.extents,OrientedBoundBox._tempV33);
  14843. var distance=Vector3.distanceSquared(OrientedBoundBox._tempV30,OrientedBoundBox._tempV33);
  14844. if (distance > locRadius *locRadius)
  14845. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  14846. var tempV30ex=OrientedBoundBox._tempV30.x;
  14847. var tempV30ey=OrientedBoundBox._tempV30.y;
  14848. var tempV30ez=OrientedBoundBox._tempV30.z;
  14849. var tempV32ex=OrientedBoundBox._tempV32.x;
  14850. var tempV32ey=OrientedBoundBox._tempV32.y;
  14851. var tempV32ez=OrientedBoundBox._tempV32.z;
  14852. if ((((tempV32ex+locRadius <=tempV30ex)&& (tempV30ex <=extentsEX-locRadius))&& ((extentsEX-tempV32ex > locRadius)&& (tempV32ey+locRadius <=tempV30ey)))&& (((tempV30ey <=extentsEY-locRadius)&& (extentsEY-tempV32ey > locRadius))&& (((tempV32ez+locRadius <=tempV30ez)&& (tempV30ez <=extentsEZ-locRadius))&& (extentsEZ-tempV32ez > locRadius)))){
  14853. return /*laya.d3.math.ContainmentType.Contains*/1;
  14854. }
  14855. return /*laya.d3.math.ContainmentType.Intersects*/2;
  14856. }
  14857. /**
  14858. *For accuracy,The transformation matrix for both <see cref="OrientedBoundingBox"/> must not have any scaling applied to it.
  14859. *Anyway,scaling using Scale method will keep this method accurate.
  14860. *该包围盒是否包含空间中另一OBB包围盒
  14861. *@param obb OBB包围盒
  14862. *@return 返回位置关系
  14863. */
  14864. __proto.containsOrientedBoundBox=function(obb){
  14865. var i=0,k=0;
  14866. obb.getCorners(OrientedBoundBox._corners);
  14867. var cornersCheck=this.containsPoints(OrientedBoundBox._corners);
  14868. if (cornersCheck !=/*laya.d3.math.ContainmentType.Disjoint*/0)
  14869. return cornersCheck;
  14870. OrientedBoundBox._sizeAe[0]=this.extents.x;
  14871. OrientedBoundBox._sizeAe[1]=this.extents.y;
  14872. OrientedBoundBox._sizeAe[2]=this.extents.z;
  14873. obb.extents.cloneTo(OrientedBoundBox._tempV35);
  14874. OrientedBoundBox._sizeBe[0]=OrientedBoundBox._tempV35.x;
  14875. OrientedBoundBox._sizeBe[1]=OrientedBoundBox._tempV35.y;
  14876. OrientedBoundBox._sizeBe[2]=OrientedBoundBox._tempV35.z;
  14877. OrientedBoundBox._getRows(this.transformation,OrientedBoundBox._rows1);
  14878. OrientedBoundBox._getRows(obb.transformation,OrientedBoundBox._rows2);
  14879. var extentA=NaN,extentB=NaN,separation=NaN,dotNumber=NaN;
  14880. for (i=0;i < 4;i++){
  14881. for (k=0;k < 4;k++){
  14882. if (i==3 || k==3){
  14883. OrientedBoundBox._tempM0.setElementByRowColumn(i,k,0);
  14884. OrientedBoundBox._tempM1.setElementByRowColumn(i,k,0);
  14885. }else {
  14886. dotNumber=Vector3.dot(OrientedBoundBox._rows1[i],OrientedBoundBox._rows2[k]);
  14887. OrientedBoundBox._tempM0.setElementByRowColumn(i,k,dotNumber);
  14888. OrientedBoundBox._tempM1.setElementByRowColumn(i,k,Math.abs(dotNumber));
  14889. }
  14890. }
  14891. }
  14892. obb.getCenter(OrientedBoundBox._tempV34);
  14893. this.getCenter(OrientedBoundBox._tempV36);
  14894. Vector3.subtract(OrientedBoundBox._tempV34,OrientedBoundBox._tempV36,OrientedBoundBox._tempV30);
  14895. OrientedBoundBox._tempV31.x=Vector3.dot(OrientedBoundBox._tempV30,OrientedBoundBox._rows1[0]);
  14896. OrientedBoundBox._tempV31.y=Vector3.dot(OrientedBoundBox._tempV30,OrientedBoundBox._rows1[1]);
  14897. OrientedBoundBox._tempV31.z=Vector3.dot(OrientedBoundBox._tempV30,OrientedBoundBox._rows1[2]);
  14898. OrientedBoundBox._vsepAe[0]=OrientedBoundBox._tempV31.x;
  14899. OrientedBoundBox._vsepAe[1]=OrientedBoundBox._tempV31.y;
  14900. OrientedBoundBox._vsepAe[2]=OrientedBoundBox._tempV31.z;
  14901. for (i=0;i < 3;i++){
  14902. OrientedBoundBox._tempV32.x=OrientedBoundBox._tempM1.getElementByRowColumn(i,0);
  14903. OrientedBoundBox._tempV32.y=OrientedBoundBox._tempM1.getElementByRowColumn(i,1);
  14904. OrientedBoundBox._tempV32.z=OrientedBoundBox._tempM1.getElementByRowColumn(i,2);
  14905. extentA=OrientedBoundBox._sizeAe[i];
  14906. extentB=Vector3.dot(OrientedBoundBox._tempV35,OrientedBoundBox._tempV32);
  14907. separation=Math.abs(OrientedBoundBox._vsepAe[i]);
  14908. if (separation > extentA+extentB)
  14909. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  14910. }
  14911. for (k=0;k < 3;k++){
  14912. OrientedBoundBox._tempV32.x=OrientedBoundBox._tempM1.getElementByRowColumn(0,k);
  14913. OrientedBoundBox._tempV32.y=OrientedBoundBox._tempM1.getElementByRowColumn(1,k);
  14914. OrientedBoundBox._tempV32.z=OrientedBoundBox._tempM1.getElementByRowColumn(2,k);
  14915. OrientedBoundBox._tempV33.x=OrientedBoundBox._tempM0.getElementByRowColumn(0,k);
  14916. OrientedBoundBox._tempV33.y=OrientedBoundBox._tempM0.getElementByRowColumn(1,k);
  14917. OrientedBoundBox._tempV33.z=OrientedBoundBox._tempM0.getElementByRowColumn(2,k);
  14918. extentA=Vector3.dot(this.extents,OrientedBoundBox._tempV32);
  14919. extentB=OrientedBoundBox._sizeBe[k];
  14920. separation=Math.abs(Vector3.dot(OrientedBoundBox._tempV31,OrientedBoundBox._tempV33));
  14921. if (separation > extentA+extentB)
  14922. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  14923. }
  14924. for (i=0;i < 3;i++){
  14925. for (k=0;k < 3;k++){
  14926. var i1=(i+1)% 3,i2=(i+2)% 3;
  14927. var k1=(k+1)% 3,k2=(k+2)% 3;
  14928. extentA=OrientedBoundBox._sizeAe[i1] *OrientedBoundBox._tempM1.getElementByRowColumn(i2,k)+OrientedBoundBox._sizeAe[i2] *OrientedBoundBox._tempM1.getElementByRowColumn(i1,k);
  14929. extentB=OrientedBoundBox._sizeBe[k1] *OrientedBoundBox._tempM1.getElementByRowColumn(i,k2)+OrientedBoundBox._sizeBe[k2] *OrientedBoundBox._tempM1.getElementByRowColumn(i,k1);
  14930. separation=Math.abs(OrientedBoundBox._vsepAe[i2] *OrientedBoundBox._tempM0.getElementByRowColumn(i1,k)-OrientedBoundBox._vsepAe[i1] *OrientedBoundBox._tempM0.getElementByRowColumn(i2,k));
  14931. if (separation > extentA+extentB)
  14932. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  14933. }
  14934. }
  14935. return /*laya.d3.math.ContainmentType.Intersects*/2;
  14936. }
  14937. /**
  14938. *该包围盒是否包含空间中一条线
  14939. *@param point1 点1
  14940. *@param point2 点2
  14941. *@return 返回位置关系
  14942. */
  14943. __proto.containsLine=function(point1,point2){
  14944. OrientedBoundBox._corners[0]=point1;
  14945. OrientedBoundBox._corners[1]=point2;
  14946. var cornersCheck=this.containsPoints(OrientedBoundBox._corners);
  14947. if (cornersCheck !=/*laya.d3.math.ContainmentType.Disjoint*/0)
  14948. return cornersCheck;
  14949. var extentsX=this.extents.x;
  14950. var extentsY=this.extents.y;
  14951. var extentsZ=this.extents.z;
  14952. this.transformation.invert(OrientedBoundBox._tempM0);
  14953. Vector3.transformCoordinate(point1,OrientedBoundBox._tempM0,OrientedBoundBox._tempV30);
  14954. Vector3.transformCoordinate(point2,OrientedBoundBox._tempM0,OrientedBoundBox._tempV31);
  14955. Vector3.add(OrientedBoundBox._tempV30,OrientedBoundBox._tempV31,OrientedBoundBox._tempV32);
  14956. Vector3.scale(OrientedBoundBox._tempV32,0.5,OrientedBoundBox._tempV32);
  14957. Vector3.subtract(OrientedBoundBox._tempV30,OrientedBoundBox._tempV32,OrientedBoundBox._tempV33);
  14958. var _tempV33X=OrientedBoundBox._tempV33.x;
  14959. var _tempV33Y=OrientedBoundBox._tempV33.y;
  14960. var _tempV33Z=OrientedBoundBox._tempV33.z;
  14961. var _tempV34X=OrientedBoundBox._tempV34.x=Math.abs(OrientedBoundBox._tempV33.x);
  14962. var _tempV34Y=OrientedBoundBox._tempV34.y=Math.abs(OrientedBoundBox._tempV33.y);
  14963. var _tempV34Z=OrientedBoundBox._tempV34.z=Math.abs(OrientedBoundBox._tempV33.z);
  14964. var _tempV32X=OrientedBoundBox._tempV32.x;
  14965. var _tempV32Y=OrientedBoundBox._tempV32.y;
  14966. var _tempV32Z=OrientedBoundBox._tempV32.z;
  14967. if (Math.abs(_tempV32X)> extentsX+_tempV34X)
  14968. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  14969. if (Math.abs(_tempV32Y)> extentsY+_tempV34Y)
  14970. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  14971. if (Math.abs(_tempV32Z)> extentsZ+_tempV34Z)
  14972. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  14973. if (Math.abs(_tempV32Y *_tempV33Z-_tempV32Z *_tempV33Y)> (extentsY *_tempV34Z+extentsZ *_tempV34Y))
  14974. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  14975. if (Math.abs(_tempV32X *_tempV33Z-_tempV32Z *_tempV33X)> (extentsX *_tempV34Z+extentsZ *_tempV34X))
  14976. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  14977. if (Math.abs(_tempV32X *_tempV33Y-_tempV32Y *_tempV33X)> (extentsX *_tempV34Y+extentsY *_tempV34X))
  14978. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  14979. return /*laya.d3.math.ContainmentType.Intersects*/2;
  14980. }
  14981. /**
  14982. *该包围盒是否包含空间中另一OBB包围盒
  14983. *@param box 包围盒
  14984. *@return 返回位置关系
  14985. */
  14986. __proto.containsBoundBox=function(box){
  14987. var i=0,k=0;
  14988. var min=box.min;
  14989. var max=box.max;
  14990. box.getCorners(OrientedBoundBox._corners);
  14991. var cornersCheck=this.containsPoints(OrientedBoundBox._corners);
  14992. if (cornersCheck !=/*laya.d3.math.ContainmentType.Disjoint*/0)
  14993. return cornersCheck;
  14994. Vector3.subtract(max,min,OrientedBoundBox._tempV30);
  14995. Vector3.scale(OrientedBoundBox._tempV30,0.5,OrientedBoundBox._tempV30);
  14996. Vector3.add(min,OrientedBoundBox._tempV30,OrientedBoundBox._tempV30);
  14997. Vector3.subtract(max,OrientedBoundBox._tempV30,OrientedBoundBox._tempV31);
  14998. OrientedBoundBox._sizeAe[0]=this.extents.x;
  14999. OrientedBoundBox._sizeAe[1]=this.extents.y;
  15000. OrientedBoundBox._sizeAe[2]=this.extents.z;
  15001. OrientedBoundBox._sizeBe[0]=OrientedBoundBox._tempV31.x;
  15002. OrientedBoundBox._sizeBe[1]=OrientedBoundBox._tempV31.y;
  15003. OrientedBoundBox._sizeBe[2]=OrientedBoundBox._tempV31.z;
  15004. OrientedBoundBox._getRows(this.transformation,OrientedBoundBox._rows1);
  15005. this.transformation.invert(OrientedBoundBox._tempM0);
  15006. var extentA=NaN,extentB=NaN,separation=NaN,dotNumber=NaN;
  15007. for (i=0;i < 3;i++){
  15008. for (k=0;k < 3;k++){
  15009. OrientedBoundBox._tempM1.setElementByRowColumn(i,k,Math.abs(OrientedBoundBox._tempM0.getElementByRowColumn(i,k)));
  15010. }
  15011. }
  15012. this.getCenter(OrientedBoundBox._tempV35);
  15013. Vector3.subtract(OrientedBoundBox._tempV30,OrientedBoundBox._tempV35,OrientedBoundBox._tempV32);
  15014. OrientedBoundBox._tempV31.x=Vector3.dot(OrientedBoundBox._tempV32,OrientedBoundBox._rows1[0]);
  15015. OrientedBoundBox._tempV31.y=Vector3.dot(OrientedBoundBox._tempV32,OrientedBoundBox._rows1[1]);
  15016. OrientedBoundBox._tempV31.z=Vector3.dot(OrientedBoundBox._tempV32,OrientedBoundBox._rows1[2]);
  15017. OrientedBoundBox._vsepAe[0]=OrientedBoundBox._tempV31.x;
  15018. OrientedBoundBox._vsepAe[1]=OrientedBoundBox._tempV31.y;
  15019. OrientedBoundBox._vsepAe[2]=OrientedBoundBox._tempV31.z;
  15020. for (i=0;i < 3;i++){
  15021. OrientedBoundBox._tempV33.x=OrientedBoundBox._tempM1.getElementByRowColumn(i,0);
  15022. OrientedBoundBox._tempV33.y=OrientedBoundBox._tempM1.getElementByRowColumn(i,1);
  15023. OrientedBoundBox._tempV33.z=OrientedBoundBox._tempM1.getElementByRowColumn(i,2);
  15024. extentA=OrientedBoundBox._sizeAe[i];
  15025. extentB=Vector3.dot(OrientedBoundBox._tempV31,OrientedBoundBox._tempV33);
  15026. separation=Math.abs(OrientedBoundBox._vsepAe[i]);
  15027. if (separation > extentA+extentB)
  15028. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  15029. }
  15030. for (k=0;k < 3;k++){
  15031. OrientedBoundBox._tempV33.x=OrientedBoundBox._tempM1.getElementByRowColumn(0,k);
  15032. OrientedBoundBox._tempV33.y=OrientedBoundBox._tempM1.getElementByRowColumn(1,k);
  15033. OrientedBoundBox._tempV33.z=OrientedBoundBox._tempM1.getElementByRowColumn(2,k);
  15034. OrientedBoundBox._tempV34.x=OrientedBoundBox._tempM0.getElementByRowColumn(0,k);
  15035. OrientedBoundBox._tempV34.y=OrientedBoundBox._tempM0.getElementByRowColumn(1,k);
  15036. OrientedBoundBox._tempV34.z=OrientedBoundBox._tempM0.getElementByRowColumn(2,k);
  15037. extentA=Vector3.dot(this.extents,OrientedBoundBox._tempV33);
  15038. extentB=OrientedBoundBox._sizeBe[k];
  15039. separation=Math.abs(Vector3.dot(OrientedBoundBox._tempV31,OrientedBoundBox._tempV34));
  15040. if (separation > extentA+extentB)
  15041. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  15042. }
  15043. for (i=0;i < 3;i++){
  15044. for (k=0;k < 3;k++){
  15045. var i1=(i+1)% 3,i2=(i+2)% 3;
  15046. var k1=(k+1)% 3,k2=(k+2)% 3;
  15047. extentA=OrientedBoundBox._sizeAe[i1] *OrientedBoundBox._tempM1.getElementByRowColumn(i2,k)+OrientedBoundBox._sizeAe[i2] *OrientedBoundBox._tempM1.getElementByRowColumn(i1,k);
  15048. extentB=OrientedBoundBox._sizeBe[k1] *OrientedBoundBox._tempM1.getElementByRowColumn(i,k2)+OrientedBoundBox._sizeBe[k2] *OrientedBoundBox._tempM1.getElementByRowColumn(i,k1);
  15049. separation=Math.abs(OrientedBoundBox._vsepAe[i2] *OrientedBoundBox._tempM0.getElementByRowColumn(i1,k)-OrientedBoundBox._vsepAe[i1] *OrientedBoundBox._tempM0.getElementByRowColumn(i2,k));
  15050. if (separation > extentA+extentB)
  15051. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  15052. }
  15053. }
  15054. return /*laya.d3.math.ContainmentType.Intersects*/2;
  15055. }
  15056. /**
  15057. *该包围盒是否与空间中另一射线相交
  15058. *@param ray
  15059. *@param out
  15060. *@return
  15061. */
  15062. __proto.intersectsRay=function(ray,out){
  15063. Vector3.scale(this.extents,-1,OrientedBoundBox._tempV30);
  15064. this.transformation.invert(OrientedBoundBox._tempM0);
  15065. Vector3.TransformNormal(ray.direction,OrientedBoundBox._tempM0,OrientedBoundBox._ray.direction);
  15066. Vector3.transformCoordinate(ray.origin,OrientedBoundBox._tempM0,OrientedBoundBox._ray.origin);
  15067. OrientedBoundBox._boxBound1.min=OrientedBoundBox._tempV30;
  15068. OrientedBoundBox._boxBound1.max=this.extents;
  15069. var intersects=CollisionUtils.intersectsRayAndBoxRP(OrientedBoundBox._ray,OrientedBoundBox._boxBound1,out);
  15070. if (intersects!==-1)
  15071. Vector3.transformCoordinate(out,this.transformation,out);
  15072. return intersects;
  15073. }
  15074. __proto._getLocalCorners=function(corners){
  15075. corners.length=8;
  15076. OrientedBoundBox._tempV30.x=this.extents.x;
  15077. OrientedBoundBox._tempV31.y=this.extents.y;
  15078. OrientedBoundBox._tempV32.z=this.extents.z;
  15079. Vector3.add(OrientedBoundBox._tempV30,OrientedBoundBox._tempV31,OrientedBoundBox._tempV33);
  15080. Vector3.add(OrientedBoundBox._tempV33,OrientedBoundBox._tempV32,corners[0]);
  15081. Vector3.add(OrientedBoundBox._tempV30,OrientedBoundBox._tempV31,OrientedBoundBox._tempV33);
  15082. Vector3.subtract(OrientedBoundBox._tempV33,OrientedBoundBox._tempV32,corners[1]);
  15083. Vector3.subtract(OrientedBoundBox._tempV31,OrientedBoundBox._tempV30,OrientedBoundBox._tempV33);
  15084. Vector3.subtract(OrientedBoundBox._tempV33,OrientedBoundBox._tempV30,corners[2]);
  15085. Vector3.subtract(OrientedBoundBox._tempV31,OrientedBoundBox._tempV30,OrientedBoundBox._tempV33);
  15086. Vector3.add(OrientedBoundBox._tempV33,OrientedBoundBox._tempV32,corners[3]);
  15087. Vector3.subtract(OrientedBoundBox._tempV30,OrientedBoundBox._tempV31,OrientedBoundBox._tempV33);
  15088. Vector3.add(OrientedBoundBox._tempV33,OrientedBoundBox._tempV32,corners[4]);
  15089. Vector3.subtract(OrientedBoundBox._tempV30,OrientedBoundBox._tempV31,OrientedBoundBox._tempV33);
  15090. Vector3.subtract(OrientedBoundBox._tempV33,OrientedBoundBox._tempV32,corners[5]);
  15091. Vector3.scale(corners[0],-1,corners[6]);
  15092. Vector3.subtract(OrientedBoundBox._tempV32,OrientedBoundBox._tempV30,OrientedBoundBox._tempV33);
  15093. Vector3.subtract(OrientedBoundBox._tempV33,OrientedBoundBox._tempV31,corners[7]);
  15094. }
  15095. /**
  15096. *判断两个包围盒是否相等
  15097. *@param obb obb包围盒
  15098. *@return Boolean
  15099. */
  15100. __proto.equals=function(obb){
  15101. return this.extents==obb.extents && this.transformation==obb.transformation;
  15102. }
  15103. /**
  15104. *克隆。
  15105. *@param destObject 克隆源。
  15106. */
  15107. __proto.cloneTo=function(destObject){
  15108. var dest=destObject;
  15109. this.extents.cloneTo(dest.extents);
  15110. this.transformation.cloneTo(dest.transformation);
  15111. }
  15112. OrientedBoundBox.createByBoundBox=function(box,out){
  15113. var min=box.min;
  15114. var max=box.max;
  15115. Vector3.subtract(max,min,OrientedBoundBox._tempV30);
  15116. Vector3.scale(OrientedBoundBox._tempV30,0.5,OrientedBoundBox._tempV30);
  15117. Vector3.add(min,OrientedBoundBox._tempV30,OrientedBoundBox._tempV31);
  15118. Vector3.subtract(max,OrientedBoundBox._tempV31,OrientedBoundBox._tempV32);
  15119. Matrix4x4.translation(OrientedBoundBox._tempV31,OrientedBoundBox._tempM0);
  15120. var extents=OrientedBoundBox._tempV32.clone();
  15121. var transformation=OrientedBoundBox._tempM0.clone();
  15122. out.extents=extents;
  15123. out.transformation=transformation;
  15124. }
  15125. OrientedBoundBox.createByMinAndMaxVertex=function(min,max){
  15126. Vector3.subtract(max,min,OrientedBoundBox._tempV30);
  15127. Vector3.scale(OrientedBoundBox._tempV30,0.5,OrientedBoundBox._tempV30);
  15128. Vector3.add(min,OrientedBoundBox._tempV30,OrientedBoundBox._tempV31);
  15129. Vector3.subtract(max,OrientedBoundBox._tempV31,OrientedBoundBox._tempV32);
  15130. Matrix4x4.translation(OrientedBoundBox._tempV31,OrientedBoundBox._tempM0);
  15131. var obb=new OrientedBoundBox(OrientedBoundBox._tempV32,OrientedBoundBox._tempM0);
  15132. return obb;
  15133. }
  15134. OrientedBoundBox._getRows=function(mat,out){
  15135. out.length=3;
  15136. var mate=mat.elements;
  15137. out[0].x=mate[0];
  15138. out[0].y=mate[1];
  15139. out[0].z=mate[2];
  15140. out[1].x=mate[4];
  15141. out[1].y=mate[5];
  15142. out[1].z=mate[6];
  15143. out[2].x=mate[8];
  15144. out[2].y=mate[9];
  15145. out[2].z=mate[10];
  15146. }
  15147. OrientedBoundBox.getObbtoObbMatrix4x4=function(a,b,noMatrixScaleApplied,out){
  15148. var at=a.transformation;
  15149. var bt=b.transformation;
  15150. if (noMatrixScaleApplied){
  15151. OrientedBoundBox._getRows(at,OrientedBoundBox._rows1);
  15152. OrientedBoundBox._getRows(bt,OrientedBoundBox._rows2);
  15153. for (var i=0;i < 3;i++){
  15154. for (var k=0;k < 3;k++){
  15155. out.setElementByRowColumn(i,k,Vector3.dot(OrientedBoundBox._rows2[i],OrientedBoundBox._rows1[k]));
  15156. }
  15157. }
  15158. b.getCenter(OrientedBoundBox._tempV30);
  15159. a.getCenter(OrientedBoundBox._tempV31);
  15160. Vector3.subtract(OrientedBoundBox._tempV30,OrientedBoundBox._tempV31,OrientedBoundBox._tempV32);
  15161. var AtoBMe=out.elements;
  15162. AtoBMe[12]=Vector3.dot(OrientedBoundBox._tempV32,OrientedBoundBox._rows1[0]);
  15163. AtoBMe[13]=Vector3.dot(OrientedBoundBox._tempV32,OrientedBoundBox._rows1[1]);
  15164. AtoBMe[14]=Vector3.dot(OrientedBoundBox._tempV32,OrientedBoundBox._rows1[2]);
  15165. AtoBMe[15]=1;
  15166. }else {
  15167. at.invert(OrientedBoundBox._tempM0);
  15168. Matrix4x4.multiply(bt,OrientedBoundBox._tempM0,out);
  15169. }
  15170. }
  15171. OrientedBoundBox.merge=function(a,b,noMatrixScaleApplied){
  15172. var ae=a.extents;
  15173. var at=a.transformation;
  15174. OrientedBoundBox.getObbtoObbMatrix4x4(a,b,noMatrixScaleApplied,OrientedBoundBox._tempM0);
  15175. b._getLocalCorners(OrientedBoundBox._corners);
  15176. Vector3.transformCoordinate(OrientedBoundBox._corners[0],OrientedBoundBox._tempM0,OrientedBoundBox._corners[0]);
  15177. Vector3.transformCoordinate(OrientedBoundBox._corners[1],OrientedBoundBox._tempM0,OrientedBoundBox._corners[1]);
  15178. Vector3.transformCoordinate(OrientedBoundBox._corners[2],OrientedBoundBox._tempM0,OrientedBoundBox._corners[2]);
  15179. Vector3.transformCoordinate(OrientedBoundBox._corners[3],OrientedBoundBox._tempM0,OrientedBoundBox._corners[3]);
  15180. Vector3.transformCoordinate(OrientedBoundBox._corners[4],OrientedBoundBox._tempM0,OrientedBoundBox._corners[4]);
  15181. Vector3.transformCoordinate(OrientedBoundBox._corners[5],OrientedBoundBox._tempM0,OrientedBoundBox._corners[5]);
  15182. Vector3.transformCoordinate(OrientedBoundBox._corners[6],OrientedBoundBox._tempM0,OrientedBoundBox._corners[6]);
  15183. Vector3.transformCoordinate(OrientedBoundBox._corners[7],OrientedBoundBox._tempM0,OrientedBoundBox._corners[7]);
  15184. Vector3.scale(ae,-1,OrientedBoundBox._boxBound1.min);
  15185. ae.cloneTo(OrientedBoundBox._boxBound1.max);
  15186. BoundBox.createfromPoints(OrientedBoundBox._corners,OrientedBoundBox._boxBound2);
  15187. BoundBox.merge(OrientedBoundBox._boxBound2,OrientedBoundBox._boxBound1,OrientedBoundBox._boxBound3);
  15188. var box3Min=OrientedBoundBox._boxBound3.min;
  15189. var box3Max=OrientedBoundBox._boxBound3.max;
  15190. Vector3.subtract(box3Max,box3Min,OrientedBoundBox._tempV30);
  15191. Vector3.scale(OrientedBoundBox._tempV30,0.5,OrientedBoundBox._tempV30);
  15192. Vector3.add(box3Min,OrientedBoundBox._tempV30,OrientedBoundBox._tempV32);
  15193. Vector3.subtract(box3Max,OrientedBoundBox._tempV32,ae);
  15194. Vector3.transformCoordinate(OrientedBoundBox._tempV32,at,OrientedBoundBox._tempV33);
  15195. }
  15196. __static(OrientedBoundBox,
  15197. ['_tempV30',function(){return this._tempV30=new Vector3();},'_tempV31',function(){return this._tempV31=new Vector3();},'_tempV32',function(){return this._tempV32=new Vector3();},'_tempV33',function(){return this._tempV33=new Vector3();},'_tempV34',function(){return this._tempV34=new Vector3();},'_tempV35',function(){return this._tempV35=new Vector3();},'_tempV36',function(){return this._tempV36=new Vector3();},'_tempM0',function(){return this._tempM0=new Matrix4x4();},'_tempM1',function(){return this._tempM1=new Matrix4x4();},'_corners',function(){return this._corners=/*new vector.<>*/[new Vector3(),new Vector3(),new Vector3(),new Vector3(),new Vector3(),new Vector3(),new Vector3(),new Vector3()];},'_rows1',function(){return this._rows1=/*new vector.<>*/[new Vector3(),new Vector3(),new Vector3()];},'_rows2',function(){return this._rows2=/*new vector.<>*/[new Vector3(),new Vector3(),new Vector3()];},'_ray',function(){return this._ray=new Ray(new Vector3(),new Vector3());},'_boxBound1',function(){return this._boxBound1=new BoundBox(new Vector3(),new Vector3());},'_boxBound2',function(){return this._boxBound2=new BoundBox(new Vector3(),new Vector3());},'_boxBound3',function(){return this._boxBound3=new BoundBox(new Vector3(),new Vector3());},'_vsepAe',function(){return this._vsepAe=new Float32Array();},'_sizeBe',function(){return this._sizeBe=new Float32Array();},'_sizeAe',function(){return this._sizeAe=new Float32Array();}
  15198. ]);
  15199. return OrientedBoundBox;
  15200. })()
  15201. /**
  15202. *@private
  15203. *<code>RenderQuene</code> 类用于实现渲染队列。
  15204. */
  15205. //class laya.d3.core.render.RenderQueue
  15206. var RenderQueue=(function(){
  15207. function RenderQueue(isTransparent){
  15208. /**@private [只读]*/
  15209. //this.isTransparent=false;
  15210. /**@private */
  15211. //this.elements=null;
  15212. /**@private */
  15213. //this.lastTransparentRenderElement=null;
  15214. /**@private */
  15215. //this.lastTransparentBatched=false;
  15216. (isTransparent===void 0)&& (isTransparent=false);
  15217. this.isTransparent=isTransparent;
  15218. this.elements=[];
  15219. }
  15220. __class(RenderQueue,'laya.d3.core.render.RenderQueue');
  15221. var __proto=RenderQueue.prototype;
  15222. /**
  15223. *@private
  15224. */
  15225. __proto._compare=function(left,right){
  15226. var renderQueue=left.material.renderQueue-right.material.renderQueue;
  15227. if (renderQueue===0){
  15228. var sort=this.isTransparent ? right.render._distanceForSort-left.render._distanceForSort :left.render._distanceForSort-right.render._distanceForSort;
  15229. return sort+right.render.sortingFudge-left.render.sortingFudge;
  15230. }else {
  15231. return renderQueue;
  15232. }
  15233. }
  15234. /**
  15235. *@private
  15236. */
  15237. __proto._partitionRenderObject=function(left,right){
  15238. var pivot=this.elements[Math.floor((right+left)/ 2)];
  15239. while (left <=right){
  15240. while (this._compare(this.elements[left],pivot)< 0)
  15241. left++;
  15242. while (this._compare(this.elements[right],pivot)> 0)
  15243. right--;
  15244. if (left < right){
  15245. var temp=this.elements[left];
  15246. this.elements[left]=this.elements[right];
  15247. this.elements[right]=temp;
  15248. left++;
  15249. right--;
  15250. }else if (left===right){
  15251. left++;
  15252. break ;
  15253. }
  15254. }
  15255. return left;
  15256. }
  15257. /**
  15258. *@private
  15259. */
  15260. __proto._quickSort=function(left,right){
  15261. if (this.elements.length > 1){
  15262. var index=this._partitionRenderObject(left,right);
  15263. var leftIndex=index-1;
  15264. if (left < leftIndex)
  15265. this._quickSort(left,leftIndex);
  15266. if (index < right)
  15267. this._quickSort(index,right);
  15268. }
  15269. }
  15270. /**
  15271. *@private
  15272. */
  15273. __proto._render=function(context,isTarget,customShader,replacementTag){
  15274. for (var i=0,n=this.elements.length;i < n;i++)
  15275. this.elements[i]._render(context,isTarget,customShader,replacementTag);
  15276. }
  15277. /**
  15278. *@private
  15279. */
  15280. __proto.clear=function(){
  15281. this.elements.length=0;
  15282. this.lastTransparentRenderElement=null;
  15283. this.lastTransparentBatched=false;
  15284. }
  15285. return RenderQueue;
  15286. })()
  15287. /**
  15288. *...
  15289. *@author ...
  15290. */
  15291. //class laya.d3.core.TextureMode
  15292. var TextureMode=(function(){
  15293. function TextureMode(){}
  15294. __class(TextureMode,'laya.d3.core.TextureMode');
  15295. TextureMode.Stretch=0;
  15296. TextureMode.Tile=1;
  15297. return TextureMode;
  15298. })()
  15299. /**
  15300. *...
  15301. *@author ...
  15302. */
  15303. //class laya.d3.physics.shape.HeightfieldColliderShape
  15304. var HeightfieldColliderShape=(function(){
  15305. function HeightfieldColliderShape(){}
  15306. __class(HeightfieldColliderShape,'laya.d3.physics.shape.HeightfieldColliderShape');
  15307. return HeightfieldColliderShape;
  15308. })()
  15309. /**
  15310. *...
  15311. *@author ...
  15312. */
  15313. //class laya.d3.core.particleShuriKen.module.shape.ShapeUtils
  15314. var ShapeUtils=(function(){
  15315. function ShapeUtils(){}
  15316. __class(ShapeUtils,'laya.d3.core.particleShuriKen.module.shape.ShapeUtils');
  15317. ShapeUtils._randomPointUnitArcCircle=function(arc,out,rand){
  15318. var angle=NaN;
  15319. if (rand)
  15320. angle=rand.getFloat()*arc;
  15321. else
  15322. angle=Math.random()*arc;
  15323. out.x=Math.cos(angle);
  15324. out.y=Math.sin(angle);
  15325. }
  15326. ShapeUtils._randomPointInsideUnitArcCircle=function(arc,out,rand){
  15327. ShapeUtils._randomPointUnitArcCircle(arc,out,rand);
  15328. var range=NaN;
  15329. if (rand)
  15330. range=Math.pow(rand.getFloat(),1.0 / 2.0);
  15331. else
  15332. range=Math.pow(Math.random(),1.0 / 2.0);
  15333. out.x=out.x *range;
  15334. out.y=out.y *range;
  15335. }
  15336. ShapeUtils._randomPointUnitCircle=function(out,rand){
  15337. var angle=NaN;
  15338. if (rand)
  15339. angle=rand.getFloat()*Math.PI *2;
  15340. else
  15341. angle=Math.random()*Math.PI *2;
  15342. out.x=Math.cos(angle);
  15343. out.y=Math.sin(angle);
  15344. }
  15345. ShapeUtils._randomPointInsideUnitCircle=function(out,rand){
  15346. ShapeUtils._randomPointUnitCircle(out);
  15347. var range=NaN;
  15348. if (rand)
  15349. range=Math.pow(rand.getFloat(),1.0 / 2.0);
  15350. else
  15351. range=Math.pow(Math.random(),1.0 / 2.0);
  15352. out.x=out.x *range;
  15353. out.y=out.y *range;
  15354. }
  15355. ShapeUtils._randomPointUnitSphere=function(out,rand){
  15356. var z=NaN;
  15357. var a=NaN;
  15358. if (rand){
  15359. z=out.z=rand.getFloat()*2-1.0;
  15360. a=rand.getFloat()*Math.PI *2;
  15361. }else {
  15362. z=out.z=Math.random()*2-1.0;
  15363. a=Math.random()*Math.PI *2;
  15364. };
  15365. var r=Math.sqrt(1.0-z *z);
  15366. out.x=r *Math.cos(a);
  15367. out.y=r *Math.sin(a);
  15368. }
  15369. ShapeUtils._randomPointInsideUnitSphere=function(out,rand){;
  15370. ShapeUtils._randomPointUnitSphere(out);
  15371. var range=NaN;
  15372. if (rand)
  15373. range=Math.pow(rand.getFloat(),1.0 / 3.0);
  15374. else
  15375. range=Math.pow(Math.random(),1.0 / 3.0);
  15376. out.x=out.x *range;
  15377. out.y=out.y *range;
  15378. out.z=out.z *range;
  15379. }
  15380. ShapeUtils._randomPointInsideHalfUnitBox=function(out,rand){
  15381. if (rand){
  15382. out.x=(rand.getFloat()-0.5);
  15383. out.y=(rand.getFloat()-0.5);
  15384. out.z=(rand.getFloat()-0.5);
  15385. }else {
  15386. out.x=(Math.random()-0.5);
  15387. out.y=(Math.random()-0.5);
  15388. out.z=(Math.random()-0.5);
  15389. }
  15390. }
  15391. return ShapeUtils;
  15392. })()
  15393. /**
  15394. *...
  15395. *@author ...
  15396. */
  15397. //class laya.d3.graphics.VertexElementFormat
  15398. var VertexElementFormat=(function(){
  15399. function VertexElementFormat(){}
  15400. __class(VertexElementFormat,'laya.d3.graphics.VertexElementFormat');
  15401. VertexElementFormat.getElementInfos=function(element){
  15402. var info=VertexElementFormat._elementInfos[element];
  15403. if (info)
  15404. return info;
  15405. else
  15406. throw "VertexElementFormat: this vertexElementFormat is not implement.";
  15407. }
  15408. VertexElementFormat.Single="single";
  15409. VertexElementFormat.Vector2="vector2";
  15410. VertexElementFormat.Vector3="vector3";
  15411. VertexElementFormat.Vector4="vector4";
  15412. VertexElementFormat.Color="color";
  15413. VertexElementFormat.Byte4="byte4";
  15414. VertexElementFormat.Short2="short2";
  15415. VertexElementFormat.Short4="short4";
  15416. VertexElementFormat.NormalizedShort2="normalizedshort2";
  15417. VertexElementFormat.NormalizedShort4="normalizedshort4";
  15418. VertexElementFormat.HalfVector2="halfvector2";
  15419. VertexElementFormat.HalfVector4="halfvector4";
  15420. __static(VertexElementFormat,
  15421. ['_elementInfos',function(){return this._elementInfos={
  15422. "single":[1,/*laya.webgl.WebGLContext.FLOAT*/0x1406,0],
  15423. "vector2":[2,/*laya.webgl.WebGLContext.FLOAT*/0x1406,0],
  15424. "vector3":[3,/*laya.webgl.WebGLContext.FLOAT*/0x1406,0],
  15425. "vector4":[4,/*laya.webgl.WebGLContext.FLOAT*/0x1406,0],
  15426. "color":[4,/*laya.webgl.WebGLContext.FLOAT*/0x1406,0],
  15427. "byte4":[4,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,0],
  15428. "short2":[2,/*laya.webgl.WebGLContext.FLOAT*/0x1406,0],
  15429. "short4":[4,/*laya.webgl.WebGLContext.FLOAT*/0x1406,0],
  15430. "normalizedshort2":[2,/*laya.webgl.WebGLContext.FLOAT*/0x1406,0],
  15431. "normalizedshort4":[4,/*laya.webgl.WebGLContext.FLOAT*/0x1406,0],
  15432. "halfvector2":[2,/*laya.webgl.WebGLContext.FLOAT*/0x1406,0],
  15433. "halfvector4":[4,/*laya.webgl.WebGLContext.FLOAT*/0x1406,0]
  15434. };}
  15435. ]);
  15436. return VertexElementFormat;
  15437. })()
  15438. /**
  15439. *<code>RotationOverLifetime</code> 类用于粒子的生命周期旋转。
  15440. */
  15441. //class laya.d3.core.particleShuriKen.module.RotationOverLifetime
  15442. var RotationOverLifetime=(function(){
  15443. function RotationOverLifetime(angularVelocity){
  15444. /**@private */
  15445. this._angularVelocity=null;
  15446. /**是否启用*/
  15447. this.enbale=false;
  15448. this._angularVelocity=angularVelocity;
  15449. }
  15450. __class(RotationOverLifetime,'laya.d3.core.particleShuriKen.module.RotationOverLifetime');
  15451. var __proto=RotationOverLifetime.prototype;
  15452. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  15453. /**
  15454. *克隆。
  15455. *@param destObject 克隆源。
  15456. */
  15457. __proto.cloneTo=function(destObject){
  15458. var destRotationOverLifetime=destObject;
  15459. this._angularVelocity.cloneTo(destRotationOverLifetime._angularVelocity);
  15460. destRotationOverLifetime.enbale=this.enbale;
  15461. }
  15462. /**
  15463. *克隆。
  15464. *@return 克隆副本。
  15465. */
  15466. __proto.clone=function(){
  15467. var destAngularVelocity;
  15468. switch (this._angularVelocity.type){
  15469. case 0:
  15470. if (this._angularVelocity.separateAxes)
  15471. destAngularVelocity=GradientAngularVelocity.createByConstantSeparate(this._angularVelocity.constantSeparate.clone());
  15472. else
  15473. destAngularVelocity=GradientAngularVelocity.createByConstant(this._angularVelocity.constant);
  15474. break ;
  15475. case 1:
  15476. if (this._angularVelocity.separateAxes)
  15477. destAngularVelocity=GradientAngularVelocity.createByGradientSeparate(this._angularVelocity.gradientX.clone(),this._angularVelocity.gradientY.clone(),this._angularVelocity.gradientZ.clone());
  15478. else
  15479. destAngularVelocity=GradientAngularVelocity.createByGradient(this._angularVelocity.gradient.clone());
  15480. break ;
  15481. case 2:
  15482. if (this._angularVelocity.separateAxes)
  15483. destAngularVelocity=GradientAngularVelocity.createByRandomTwoConstantSeparate(this._angularVelocity.constantMinSeparate.clone(),this._angularVelocity.constantMaxSeparate.clone());
  15484. else
  15485. destAngularVelocity=GradientAngularVelocity.createByRandomTwoConstant(this._angularVelocity.constantMin,this._angularVelocity.constantMax);
  15486. break ;
  15487. case 3:
  15488. if (this._angularVelocity.separateAxes)
  15489. destAngularVelocity=GradientAngularVelocity.createByRandomTwoGradientSeparate(this._angularVelocity.gradientXMin.clone(),this._angularVelocity.gradientYMin.clone(),this._angularVelocity.gradientZMin.clone(),this._angularVelocity.gradientWMin.clone(),this._angularVelocity.gradientXMax.clone(),this._angularVelocity.gradientYMax.clone(),this._angularVelocity.gradientZMax.clone(),this._angularVelocity.gradientWMax.clone());
  15490. else
  15491. destAngularVelocity=GradientAngularVelocity.createByRandomTwoGradient(this._angularVelocity.gradientMin.clone(),this._angularVelocity.gradientMax.clone());
  15492. break ;
  15493. };
  15494. var destRotationOverLifetime=/*__JS__ */new this.constructor(destAngularVelocity);
  15495. destRotationOverLifetime.enbale=this.enbale;
  15496. return destRotationOverLifetime;
  15497. }
  15498. /**
  15499. *获取角速度。
  15500. */
  15501. __getset(0,__proto,'angularVelocity',function(){
  15502. return this._angularVelocity;
  15503. });
  15504. return RotationOverLifetime;
  15505. })()
  15506. /**
  15507. *<code>BoundFrustum</code> 类用于创建锥截体。
  15508. */
  15509. //class laya.d3.math.BoundFrustum
  15510. var BoundFrustum=(function(){
  15511. function BoundFrustum(matrix){
  15512. /**4x4矩阵*/
  15513. this._matrix=null;
  15514. /**近平面*/
  15515. this._near=null;
  15516. /**远平面*/
  15517. this._far=null;
  15518. /**左平面*/
  15519. this._left=null;
  15520. /**右平面*/
  15521. this._right=null;
  15522. /**顶平面*/
  15523. this._top=null;
  15524. /**底平面*/
  15525. this._bottom=null;
  15526. this._matrix=matrix;
  15527. this._near=new Plane(new Vector3());
  15528. this._far=new Plane(new Vector3());
  15529. this._left=new Plane(new Vector3());
  15530. this._right=new Plane(new Vector3());
  15531. this._top=new Plane(new Vector3());
  15532. this._bottom=new Plane(new Vector3());
  15533. BoundFrustum._getPlanesFromMatrix(this._matrix,this._near,this._far,this._left,this._right,this._top,this._bottom);
  15534. }
  15535. __class(BoundFrustum,'laya.d3.math.BoundFrustum');
  15536. var __proto=BoundFrustum.prototype;
  15537. /**
  15538. *判断是否与其他锥截体相等。
  15539. *@param other 锥截体。
  15540. */
  15541. __proto.equalsBoundFrustum=function(other){
  15542. return this._matrix.equalsOtherMatrix(other.matrix)
  15543. }
  15544. /**
  15545. *判断是否与其他对象相等。
  15546. *@param obj 对象。
  15547. */
  15548. __proto.equalsObj=function(obj){
  15549. if ((obj instanceof laya.d3.math.BoundFrustum )){
  15550. var bf=obj;
  15551. return this.equalsBoundFrustum(bf);
  15552. }
  15553. return false;
  15554. }
  15555. /**
  15556. *获取锥截体的任意一平面。
  15557. *0:近平面
  15558. *1:远平面
  15559. *2:左平面
  15560. *3:右平面
  15561. *4:顶平面
  15562. *5:底平面
  15563. *@param index 索引。
  15564. */
  15565. __proto.getPlane=function(index){
  15566. switch (index){
  15567. case 0:
  15568. return this._near;
  15569. case 1:
  15570. return this._far;
  15571. case 2:
  15572. return this._left;
  15573. case 3:
  15574. return this._right;
  15575. case 4:
  15576. return this._top;
  15577. case 5:
  15578. return this._bottom;
  15579. default :
  15580. return null;
  15581. }
  15582. }
  15583. /**
  15584. *锥截体的8个顶点。
  15585. *@param corners 返回顶点的输出队列。
  15586. */
  15587. __proto.getCorners=function(corners){
  15588. BoundFrustum._get3PlaneInterPoint(this._near,this._bottom,this._right).cloneTo(corners[0]);
  15589. BoundFrustum._get3PlaneInterPoint(this._near,this._top,this._right).cloneTo(corners[1]);
  15590. BoundFrustum._get3PlaneInterPoint(this._near,this._top,this._left).cloneTo(corners[2]);
  15591. BoundFrustum._get3PlaneInterPoint(this._near,this._bottom,this._left).cloneTo(corners[3]);
  15592. BoundFrustum._get3PlaneInterPoint(this._far,this._bottom,this._right).cloneTo(corners[4]);
  15593. BoundFrustum._get3PlaneInterPoint(this._far,this._top,this._right).cloneTo(corners[5]);
  15594. BoundFrustum._get3PlaneInterPoint(this._far,this._top,this._left).cloneTo(corners[6]);
  15595. BoundFrustum._get3PlaneInterPoint(this._far,this._bottom,this._left).cloneTo(corners[7]);
  15596. }
  15597. /**
  15598. *与点的位置关系。返回-1,包涵;0,相交;1,不相交
  15599. *@param point 点。
  15600. */
  15601. __proto.containsPoint=function(point){
  15602. var result=Plane.PlaneIntersectionType_Front;
  15603. var planeResult=Plane.PlaneIntersectionType_Front;
  15604. for (var i=0;i < 6;i++){
  15605. switch (i){
  15606. case 0:
  15607. planeResult=CollisionUtils.intersectsPlaneAndPoint(this._near,point);
  15608. break ;
  15609. case 1:
  15610. planeResult=CollisionUtils.intersectsPlaneAndPoint(this._far,point);
  15611. break ;
  15612. case 2:
  15613. planeResult=CollisionUtils.intersectsPlaneAndPoint(this._left,point);
  15614. break ;
  15615. case 3:
  15616. planeResult=CollisionUtils.intersectsPlaneAndPoint(this._right,point);
  15617. break ;
  15618. case 4:
  15619. planeResult=CollisionUtils.intersectsPlaneAndPoint(this._top,point);
  15620. break ;
  15621. case 5:
  15622. planeResult=CollisionUtils.intersectsPlaneAndPoint(this._bottom,point);
  15623. break ;
  15624. }
  15625. switch (planeResult){
  15626. case Plane.PlaneIntersectionType_Back:
  15627. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  15628. case Plane.PlaneIntersectionType_Intersecting:
  15629. result=Plane.PlaneIntersectionType_Intersecting;
  15630. break ;
  15631. }
  15632. }
  15633. switch (result){
  15634. case Plane.PlaneIntersectionType_Intersecting:
  15635. return /*laya.d3.math.ContainmentType.Intersects*/2;
  15636. default :
  15637. return /*laya.d3.math.ContainmentType.Contains*/1;
  15638. }
  15639. }
  15640. /**
  15641. *与包围盒的位置关系。返回-1,包涵;0,相交;1,不相交
  15642. *@param box 包围盒。
  15643. */
  15644. __proto.containsBoundBox=function(box){
  15645. var p=BoundFrustum._tempV30,n=BoundFrustum._tempV31;
  15646. var boxMin=box.min;
  15647. var boxMax=box.max;
  15648. var result=/*laya.d3.math.ContainmentType.Contains*/1;
  15649. for (var i=0;i < 6;i++){
  15650. var plane=this.getPlane(i);
  15651. var planeNor=plane.normal;
  15652. if (planeNor.x >=0){
  15653. p.x=boxMax.x;
  15654. n.x=boxMin.x;
  15655. }else {
  15656. p.x=boxMin.x;
  15657. n.x=boxMax.x;
  15658. }
  15659. if (planeNor.y >=0){
  15660. p.y=boxMax.y;
  15661. n.y=boxMin.y;
  15662. }else {
  15663. p.y=boxMin.y;
  15664. n.y=boxMax.y;
  15665. }
  15666. if (planeNor.z >=0){
  15667. p.z=boxMax.z;
  15668. n.z=boxMin.z;
  15669. }else {
  15670. p.z=boxMin.z;
  15671. n.z=boxMax.z;
  15672. }
  15673. if (CollisionUtils.intersectsPlaneAndPoint(plane,p)===Plane.PlaneIntersectionType_Back)
  15674. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  15675. if (CollisionUtils.intersectsPlaneAndPoint(plane,n)===Plane.PlaneIntersectionType_Back)
  15676. result=/*laya.d3.math.ContainmentType.Intersects*/2;
  15677. }
  15678. return result;
  15679. }
  15680. /**
  15681. *与包围球的位置关系。返回-1,包涵;0,相交;1,不相交
  15682. *@param sphere 包围球。
  15683. */
  15684. __proto.containsBoundSphere=function(sphere){
  15685. var result=Plane.PlaneIntersectionType_Front;
  15686. var planeResult=Plane.PlaneIntersectionType_Front;
  15687. for (var i=0;i < 6;i++){
  15688. switch (i){
  15689. case 0:
  15690. planeResult=CollisionUtils.intersectsPlaneAndSphere(this._near,sphere);
  15691. break ;
  15692. case 1:
  15693. planeResult=CollisionUtils.intersectsPlaneAndSphere(this._far,sphere);
  15694. break ;
  15695. case 2:
  15696. planeResult=CollisionUtils.intersectsPlaneAndSphere(this._left,sphere);
  15697. break ;
  15698. case 3:
  15699. planeResult=CollisionUtils.intersectsPlaneAndSphere(this._right,sphere);
  15700. break ;
  15701. case 4:
  15702. planeResult=CollisionUtils.intersectsPlaneAndSphere(this._top,sphere);
  15703. break ;
  15704. case 5:
  15705. planeResult=CollisionUtils.intersectsPlaneAndSphere(this._bottom,sphere);
  15706. break ;
  15707. }
  15708. switch (planeResult){
  15709. case Plane.PlaneIntersectionType_Back:
  15710. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  15711. case Plane.PlaneIntersectionType_Intersecting:
  15712. result=Plane.PlaneIntersectionType_Intersecting;
  15713. break ;
  15714. }
  15715. }
  15716. switch (result){
  15717. case Plane.PlaneIntersectionType_Intersecting:
  15718. return /*laya.d3.math.ContainmentType.Intersects*/2;
  15719. default :
  15720. return /*laya.d3.math.ContainmentType.Contains*/1;
  15721. }
  15722. }
  15723. /**
  15724. *获取顶平面。
  15725. *@return 顶平面。
  15726. */
  15727. __getset(0,__proto,'top',function(){
  15728. return this._top;
  15729. });
  15730. /**
  15731. *设置描述矩阵。
  15732. *@param matrix 描述矩阵。
  15733. */
  15734. /**
  15735. *获取描述矩阵。
  15736. *@return 描述矩阵。
  15737. */
  15738. __getset(0,__proto,'matrix',function(){
  15739. return this._matrix;
  15740. },function(matrix){
  15741. this._matrix=matrix;
  15742. BoundFrustum._getPlanesFromMatrix(this._matrix,this._near,this._far,this._left,this._right,this._top,this._bottom);
  15743. });
  15744. /**
  15745. *获取近平面。
  15746. *@return 近平面。
  15747. */
  15748. __getset(0,__proto,'near',function(){
  15749. return this._near;
  15750. });
  15751. /**
  15752. *获取远平面。
  15753. *@return 远平面。
  15754. */
  15755. __getset(0,__proto,'far',function(){
  15756. return this._far;
  15757. });
  15758. /**
  15759. *获取左平面。
  15760. *@return 左平面。
  15761. */
  15762. __getset(0,__proto,'left',function(){
  15763. return this._left;
  15764. });
  15765. /**
  15766. *获取右平面。
  15767. *@return 右平面。
  15768. */
  15769. __getset(0,__proto,'right',function(){
  15770. return this._right;
  15771. });
  15772. /**
  15773. *获取底平面。
  15774. *@return 底平面。
  15775. */
  15776. __getset(0,__proto,'bottom',function(){
  15777. return this._bottom;
  15778. });
  15779. BoundFrustum._getPlanesFromMatrix=function(m,np,fp,lp,rp,tp,bp){
  15780. var matrixE=m.elements;
  15781. var m11=matrixE[0];
  15782. var m12=matrixE[1];
  15783. var m13=matrixE[2];
  15784. var m14=matrixE[3];
  15785. var m21=matrixE[4];
  15786. var m22=matrixE[5];
  15787. var m23=matrixE[6];
  15788. var m24=matrixE[7];
  15789. var m31=matrixE[8];
  15790. var m32=matrixE[9];
  15791. var m33=matrixE[10];
  15792. var m34=matrixE[11];
  15793. var m41=matrixE[12];
  15794. var m42=matrixE[13];
  15795. var m43=matrixE[14];
  15796. var m44=matrixE[15];
  15797. var nearNorE=np.normal;
  15798. nearNorE.x=m14+m13;
  15799. nearNorE.y=m24+m23;
  15800. nearNorE.z=m34+m33;
  15801. np.distance=m44+m43;
  15802. np.normalize();
  15803. var farNorE=fp.normal;
  15804. farNorE.x=m14-m13;
  15805. farNorE.y=m24-m23;
  15806. farNorE.z=m34-m33;
  15807. fp.distance=m44-m43;
  15808. fp.normalize();
  15809. var leftNorE=lp.normal;
  15810. leftNorE.x=m14+m11;
  15811. leftNorE.y=m24+m21;
  15812. leftNorE.z=m34+m31;
  15813. lp.distance=m44+m41;
  15814. lp.normalize();
  15815. var rightNorE=rp.normal;
  15816. rightNorE.x=m14-m11;
  15817. rightNorE.y=m24-m21;
  15818. rightNorE.z=m34-m31;
  15819. rp.distance=m44-m41;
  15820. rp.normalize();
  15821. var topNorE=tp.normal;
  15822. topNorE.x=m14-m12;
  15823. topNorE.y=m24-m22;
  15824. topNorE.z=m34-m32;
  15825. tp.distance=m44-m42;
  15826. tp.normalize();
  15827. var bottomNorE=bp.normal;
  15828. bottomNorE.x=m14+m12;
  15829. bottomNorE.y=m24+m22;
  15830. bottomNorE.z=m34+m32;
  15831. bp.distance=m44+m42;
  15832. bp.normalize();
  15833. }
  15834. BoundFrustum._get3PlaneInterPoint=function(p1,p2,p3){
  15835. var p1Nor=p1.normal;
  15836. var p2Nor=p2.normal;
  15837. var p3Nor=p3.normal;
  15838. Vector3.cross(p2Nor,p3Nor,BoundFrustum._tempV30);
  15839. Vector3.cross(p3Nor,p1Nor,BoundFrustum._tempV31);
  15840. Vector3.cross(p1Nor,p2Nor,BoundFrustum._tempV32);
  15841. var a=Vector3.dot(p1Nor,BoundFrustum._tempV30);
  15842. var b=Vector3.dot(p2Nor,BoundFrustum._tempV31);
  15843. var c=Vector3.dot(p3Nor,BoundFrustum._tempV32);
  15844. Vector3.scale(BoundFrustum._tempV30,-p1.distance / a,BoundFrustum._tempV33);
  15845. Vector3.scale(BoundFrustum._tempV31,-p2.distance / b,BoundFrustum._tempV34);
  15846. Vector3.scale(BoundFrustum._tempV32,-p3.distance / c,BoundFrustum._tempV35);
  15847. Vector3.add(BoundFrustum._tempV33,BoundFrustum._tempV34,BoundFrustum._tempV36);
  15848. Vector3.add(BoundFrustum._tempV35,BoundFrustum._tempV36,BoundFrustum._tempV37);
  15849. var v=BoundFrustum._tempV37;
  15850. return v;
  15851. }
  15852. __static(BoundFrustum,
  15853. ['_tempV30',function(){return this._tempV30=new Vector3();},'_tempV31',function(){return this._tempV31=new Vector3();},'_tempV32',function(){return this._tempV32=new Vector3();},'_tempV33',function(){return this._tempV33=new Vector3();},'_tempV34',function(){return this._tempV34=new Vector3();},'_tempV35',function(){return this._tempV35=new Vector3();},'_tempV36',function(){return this._tempV36=new Vector3();},'_tempV37',function(){return this._tempV37=new Vector3();}
  15854. ]);
  15855. return BoundFrustum;
  15856. })()
  15857. /**
  15858. *@private
  15859. *<code>KeyframeNodeOwner</code> 类用于保存帧节点的拥有者信息。
  15860. */
  15861. //class laya.d3.component.KeyframeNodeOwner
  15862. var KeyframeNodeOwner=(function(){
  15863. function KeyframeNodeOwner(){
  15864. /**@private */
  15865. this.indexInList=-1;
  15866. /**@private */
  15867. this.referenceCount=0;
  15868. /**@private */
  15869. this.updateMark=-1;
  15870. /**@private */
  15871. this.type=-1;
  15872. /**@private */
  15873. this.fullPath=null;
  15874. /**@private */
  15875. this.propertyOwner=null;
  15876. /**@private */
  15877. this.property=null;
  15878. /**@private */
  15879. this.defaultValue=null;
  15880. /**@private */
  15881. this.crossFixedValue=null;
  15882. }
  15883. __class(KeyframeNodeOwner,'laya.d3.component.KeyframeNodeOwner');
  15884. var __proto=KeyframeNodeOwner.prototype;
  15885. /**
  15886. *@private
  15887. */
  15888. __proto.saveCrossFixedValue=function(){
  15889. var pro=this.propertyOwner;
  15890. if (pro){
  15891. switch (this.type){
  15892. case 0:;
  15893. var proPat=this.property;
  15894. var m=proPat.length-1;
  15895. for (var j=0;j < m;j++){
  15896. pro=pro[proPat[j]];
  15897. if (!pro)
  15898. break ;
  15899. }
  15900. this.crossFixedValue=pro[proPat[m]];
  15901. break ;
  15902. case 1:;
  15903. var locPos=pro.localPosition;
  15904. this.crossFixedValue || (this.crossFixedValue=new Vector3());
  15905. this.crossFixedValue.x=locPos.x;
  15906. this.crossFixedValue.y=locPos.y;
  15907. this.crossFixedValue.z=locPos.z;
  15908. break ;
  15909. case 2:;
  15910. var locRot=pro.localRotation;
  15911. this.crossFixedValue || (this.crossFixedValue=new Quaternion());
  15912. this.crossFixedValue.x=locRot.x;
  15913. this.crossFixedValue.y=locRot.y;
  15914. this.crossFixedValue.z=locRot.z;
  15915. this.crossFixedValue.w=locRot.w;
  15916. break ;
  15917. case 3:;
  15918. var locSca=pro.localScale;
  15919. this.crossFixedValue || (this.crossFixedValue=new Vector3());
  15920. this.crossFixedValue.x=locSca.x;
  15921. this.crossFixedValue.y=locSca.y;
  15922. this.crossFixedValue.z=locSca.z;
  15923. break ;
  15924. case 4:;
  15925. var locEul=pro.localRotationEuler;
  15926. this.crossFixedValue || (this.crossFixedValue=new Vector3());
  15927. this.crossFixedValue.x=locEul.x;
  15928. this.crossFixedValue.y=locEul.y;
  15929. this.crossFixedValue.z=locEul.z;
  15930. break ;
  15931. default :
  15932. throw "Animator:unknown type.";
  15933. }
  15934. }
  15935. }
  15936. return KeyframeNodeOwner;
  15937. })()
  15938. /**
  15939. *@private
  15940. *<code>FrustumCulling</code> 类用于裁剪。
  15941. */
  15942. //class laya.d3.graphics.FrustumCulling
  15943. var FrustumCulling=(function(){
  15944. /**
  15945. *创建一个 <code>FrustumCulling</code> 实例。
  15946. */
  15947. function FrustumCulling(){}
  15948. __class(FrustumCulling,'laya.d3.graphics.FrustumCulling');
  15949. FrustumCulling.__init__=function(){
  15950. if (Render.supportWebGLPlusCulling){
  15951. FrustumCulling._cullingBufferLength=0;
  15952. FrustumCulling._cullingBuffer=new Float32Array(4096);
  15953. }
  15954. }
  15955. FrustumCulling._drawTraversalCullingBound=function(renderList,debugTool){
  15956. var validCount=renderList.length;
  15957. var renders=renderList.elements;
  15958. for (var i=0,n=renderList.length;i < n;i++){
  15959. var color=FrustumCulling._tempColor0;
  15960. color.r=0;
  15961. color.g=1;
  15962. color.b=0;
  15963. color.a=1;
  15964. Utils3D._drawBound(debugTool,(renders [i]).bounds._getBoundBox(),color);
  15965. }
  15966. }
  15967. FrustumCulling._traversalCulling=function(camera,scene,context,renderList){
  15968. var validCount=renderList.length;
  15969. var renders=renderList.elements;
  15970. var boundFrustum=camera.boundFrustum;
  15971. var camPos=camera._transform.position;
  15972. for (var i=0;i < validCount;i++){
  15973. var render=renders [i];
  15974. if (camera._isLayerVisible(render._owner._layer)&& render._enable){
  15975. Stat.frustumCulling++;
  15976. if (!camera.useOcclusionCulling || render._needRender(boundFrustum)){
  15977. render._visible=true;
  15978. var bounds=render.bounds;
  15979. render._distanceForSort=Vector3.distance(bounds.getCenter(),camPos);
  15980. var elements=render._renderElements;
  15981. for (var j=0,m=elements.length;j < m;j++){
  15982. var element=elements[j];
  15983. var renderQueue=scene._getRenderQueue(element.material.renderQueue);
  15984. if (renderQueue.isTransparent)
  15985. element.addToTransparentRenderQueue(context,renderQueue);
  15986. else
  15987. element.addToOpaqueRenderQueue(context,renderQueue);
  15988. }
  15989. }else {
  15990. render._visible=false;
  15991. }
  15992. }else {
  15993. render._visible=false;
  15994. }
  15995. }
  15996. }
  15997. FrustumCulling.renderObjectCulling=function(camera,scene,context,renderList){
  15998. var i=0,n=0,j=0,m=0;
  15999. var opaqueQueue=scene._opaqueQueue;
  16000. var transparentQueue=scene._transparentQueue;
  16001. opaqueQueue.clear();
  16002. transparentQueue.clear();
  16003. var staticBatchManagers=StaticBatchManager._managers;
  16004. for (i=0,n=staticBatchManagers.length;i < n;i++)
  16005. staticBatchManagers[i]._clear();
  16006. var dynamicBatchManagers=DynamicBatchManager._managers;
  16007. for (i=0,n=dynamicBatchManagers.length;i < n;i++)
  16008. dynamicBatchManagers[i]._clear();
  16009. var octree=scene._octree;
  16010. if (octree){
  16011. octree.updateMotionObjects();
  16012. octree.shrinkRootIfPossible();
  16013. octree.getCollidingWithFrustum(context);
  16014. }else {
  16015. FrustumCulling._traversalCulling(camera,scene,context,renderList);
  16016. }
  16017. if (Laya3D._config.debugFrustumCulling){
  16018. var debugTool=scene._debugTool;
  16019. debugTool.clear();
  16020. if (octree){
  16021. octree.drawAllBounds(debugTool);
  16022. octree.drawAllObjects(debugTool);
  16023. }else {
  16024. FrustumCulling._drawTraversalCullingBound(renderList,debugTool);
  16025. }
  16026. };
  16027. var count=opaqueQueue.elements.length;
  16028. (count > 0)&& (opaqueQueue._quickSort(0,count-1));
  16029. count=transparentQueue.elements.length;
  16030. (count > 0)&& (transparentQueue._quickSort(0,count-1));
  16031. }
  16032. FrustumCulling.renderObjectCullingNative=function(camera,scene,context,renderList){
  16033. var i=0,n=0,j=0,m=0;
  16034. var opaqueQueue=scene._opaqueQueue;
  16035. var transparentQueue=scene._transparentQueue;
  16036. opaqueQueue.clear();
  16037. transparentQueue.clear();
  16038. var staticBatchManagers=StaticBatchManager._managers;
  16039. for (i=0,n=staticBatchManagers.length;i < n;i++)
  16040. staticBatchManagers[i]._clear();
  16041. var dynamicBatchManagers=DynamicBatchManager._managers;
  16042. for (i=0,n=dynamicBatchManagers.length;i < n;i++)
  16043. dynamicBatchManagers[i]._clear();
  16044. var validCount=renderList.length;
  16045. var renders=renderList.elements;
  16046. for (i=0;i < validCount;i++){
  16047. (renders [i]).bounds;
  16048. };
  16049. var boundFrustum=camera.boundFrustum;
  16050. FrustumCulling.cullingNative(camera._boundFrustumBuffer,FrustumCulling._cullingBuffer,scene._cullingBufferIndices,validCount,scene._cullingBufferResult);
  16051. var camPos=context.camera._transform.position;
  16052. for (i=0;i < validCount;i++){
  16053. var render=renders [i];
  16054. if (camera._isLayerVisible(render._owner._layer)&& render._enable && scene._cullingBufferResult[i]){
  16055. render._visible=true;
  16056. render._distanceForSort=Vector3.distance(render.bounds.getCenter(),camPos);
  16057. var elements=render._renderElements;
  16058. for (j=0,m=elements.length;j < m;j++){
  16059. var element=elements[j];
  16060. var renderQueue=scene._getRenderQueue(element.material.renderQueue);
  16061. if (renderQueue.isTransparent)
  16062. element.addToTransparentRenderQueue(context,renderQueue);
  16063. else
  16064. element.addToOpaqueRenderQueue(context,renderQueue);
  16065. }
  16066. }else {
  16067. render._visible=false;
  16068. }
  16069. };
  16070. var count=opaqueQueue.elements.length;
  16071. (count > 0)&& (opaqueQueue._quickSort(0,count-1));
  16072. count=transparentQueue.elements.length;
  16073. (count > 0)&& (transparentQueue._quickSort(0,count-1));
  16074. }
  16075. FrustumCulling.cullingNative=function(boundFrustumBuffer,cullingBuffer,cullingBufferIndices,cullingCount,cullingBufferResult){
  16076. return LayaGL.instance.culling(boundFrustumBuffer,cullingBuffer,cullingBufferIndices,cullingCount,cullingBufferResult);
  16077. }
  16078. FrustumCulling._cullingBufferLength=0;
  16079. FrustumCulling._cullingBuffer=null;
  16080. __static(FrustumCulling,
  16081. ['_tempVector3',function(){return this._tempVector3=new Vector3();},'_tempColor0',function(){return this._tempColor0=new Color();}
  16082. ]);
  16083. return FrustumCulling;
  16084. })()
  16085. /**
  16086. *<code>AnimatorControllerLayer</code> 类用于创建动画控制器层。
  16087. */
  16088. //class laya.d3.component.AnimatorControllerLayer
  16089. var AnimatorControllerLayer=(function(){
  16090. function AnimatorControllerLayer(name){
  16091. /**@private */
  16092. this._defaultState=null;
  16093. /**@private 0:常规播放、1:动态融合播放、2:固定融合播放*/
  16094. //this._playType=0;
  16095. /**@private */
  16096. //this._crossDuration=NaN;
  16097. /**@private */
  16098. //this._crossPlayState=null;
  16099. /**@private */
  16100. //this._crossMark=0;
  16101. /**@private */
  16102. //this._crossNodesOwnersCount=0;
  16103. /**@private */
  16104. //this._crossNodesOwners=null;
  16105. /**@private */
  16106. //this._crossNodesOwnersIndicesMap=null;
  16107. /**@private */
  16108. //this._srcCrossClipNodeIndices=null;
  16109. /**@private */
  16110. //this._destCrossClipNodeIndices=null;
  16111. /**@private */
  16112. //this._currentPlayState=null;
  16113. /**@private */
  16114. this._statesMap={};
  16115. /**@private */
  16116. //this._states=null;
  16117. /**@private */
  16118. //this._playStateInfo=null;
  16119. /**@private */
  16120. //this._crossPlayStateInfo=null;
  16121. /**层的名称。*/
  16122. //this.name=null;
  16123. /**名称。*/
  16124. //this.blendingMode=0;
  16125. /**权重。*/
  16126. //this.defaultWeight=0;
  16127. /**激活时是否自动播放*/
  16128. this.playOnWake=true;
  16129. this._playType=-1;
  16130. this._crossMark=0;
  16131. this._crossDuration=-1;
  16132. this._crossNodesOwnersIndicesMap={};
  16133. this._crossNodesOwnersCount=0;
  16134. this._crossNodesOwners=[];
  16135. this._currentPlayState=null;
  16136. this._states=[];
  16137. this._playStateInfo=new AnimatorPlayState();
  16138. this._crossPlayStateInfo=new AnimatorPlayState();
  16139. this._srcCrossClipNodeIndices=[];
  16140. this._destCrossClipNodeIndices=[];
  16141. this.name=name;
  16142. this.defaultWeight=1.0;
  16143. this.blendingMode=laya.d3.component.AnimatorControllerLayer.BLENDINGMODE_OVERRIDE;
  16144. }
  16145. __class(AnimatorControllerLayer,'laya.d3.component.AnimatorControllerLayer');
  16146. var __proto=AnimatorControllerLayer.prototype;
  16147. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  16148. /**
  16149. *@private
  16150. */
  16151. __proto.getAnimatorState=function(name){
  16152. var state=this._statesMap[name];
  16153. return state ? state :null;
  16154. }
  16155. /**
  16156. *@private
  16157. */
  16158. __proto.destroy=function(){
  16159. this._statesMap=null;
  16160. this._states=null;
  16161. this._playStateInfo=null;
  16162. this._crossPlayStateInfo=null;
  16163. this._defaultState=null;
  16164. }
  16165. /**
  16166. *克隆。
  16167. *@param destObject 克隆源。
  16168. */
  16169. __proto.cloneTo=function(destObject){
  16170. var dest=destObject;
  16171. dest.name=this.name;
  16172. dest.blendingMode=this.blendingMode;
  16173. dest.defaultWeight=this.defaultWeight;
  16174. dest.playOnWake=this.playOnWake;
  16175. }
  16176. /**
  16177. *克隆。
  16178. *@return 克隆副本。
  16179. */
  16180. __proto.clone=function(){
  16181. var dest=/*__JS__ */new this.constructor();
  16182. this.cloneTo(dest);
  16183. return dest;
  16184. }
  16185. /**
  16186. *设置默认动画状态。
  16187. *@param value 默认动画状态。
  16188. */
  16189. /**
  16190. *获取默认动画状态。
  16191. *@return 默认动画状态。
  16192. */
  16193. __getset(0,__proto,'defaultState',function(){
  16194. return this._defaultState;
  16195. },function(value){
  16196. this._defaultState=value;
  16197. this._statesMap[value.name]=value;
  16198. });
  16199. AnimatorControllerLayer.BLENDINGMODE_OVERRIDE=0;
  16200. AnimatorControllerLayer.BLENDINGMODE_ADDTIVE=1;
  16201. return AnimatorControllerLayer;
  16202. })()
  16203. /**
  16204. *<code>Collision</code> 类用于检测碰撞。
  16205. */
  16206. //class laya.d3.math.CollisionUtils
  16207. var CollisionUtils=(function(){
  16208. /**
  16209. *创建一个 <code>Collision</code> 实例。
  16210. */
  16211. function CollisionUtils(){}
  16212. __class(CollisionUtils,'laya.d3.math.CollisionUtils');
  16213. CollisionUtils.distancePlaneToPoint=function(plane,point){
  16214. var dot=Vector3.dot(plane.normal,point);
  16215. return dot-plane.distance;
  16216. }
  16217. CollisionUtils.distanceBoxToPoint=function(box,point){
  16218. var boxMin=box.min;
  16219. var boxMineX=boxMin.x;
  16220. var boxMineY=boxMin.y;
  16221. var boxMineZ=boxMin.z;
  16222. var boxMax=box.max;
  16223. var boxMaxeX=boxMax.x;
  16224. var boxMaxeY=boxMax.y;
  16225. var boxMaxeZ=boxMax.z;
  16226. var pointeX=point.x;
  16227. var pointeY=point.y;
  16228. var pointeZ=point.z;
  16229. var distance=0;
  16230. if (pointeX < boxMineX)
  16231. distance+=(boxMineX-pointeX)*(boxMineX-pointeX);
  16232. if (pointeX > boxMaxeX)
  16233. distance+=(boxMaxeX-pointeX)*(boxMaxeX-pointeX);
  16234. if (pointeY < boxMineY)
  16235. distance+=(boxMineY-pointeY)*(boxMineY-pointeY);
  16236. if (pointeY > boxMaxeY)
  16237. distance+=(boxMaxeY-pointeY)*(boxMaxeY-pointeY);
  16238. if (pointeZ < boxMineZ)
  16239. distance+=(boxMineZ-pointeZ)*(boxMineZ-pointeZ);
  16240. if (pointeZ > boxMaxeZ)
  16241. distance+=(boxMaxeZ-pointeZ)*(boxMaxeZ-pointeZ);
  16242. return Math.sqrt(distance);
  16243. }
  16244. CollisionUtils.distanceBoxToBox=function(box1,box2){
  16245. var box1Mine=box1.min;
  16246. var box1MineX=box1Mine.x;
  16247. var box1MineY=box1Mine.y;
  16248. var box1MineZ=box1Mine.z;
  16249. var box1Maxe=box1.max;
  16250. var box1MaxeX=box1Maxe.x;
  16251. var box1MaxeY=box1Maxe.y;
  16252. var box1MaxeZ=box1Maxe.z;
  16253. var box2Mine=box2.min;
  16254. var box2MineX=box2Mine.x;
  16255. var box2MineY=box2Mine.y;
  16256. var box2MineZ=box2Mine.z;
  16257. var box2Maxe=box2.max;
  16258. var box2MaxeX=box2Maxe.x;
  16259. var box2MaxeY=box2Maxe.y;
  16260. var box2MaxeZ=box2Maxe.z;
  16261. var distance=0;
  16262. var delta=NaN;
  16263. if (box1MineX > box2MaxeX){
  16264. delta=box1MineX-box2MaxeX;
  16265. distance+=delta *delta;
  16266. }else if (box2MineX > box1MaxeX){
  16267. delta=box2MineX-box1MaxeX;
  16268. distance+=delta *delta;
  16269. }
  16270. if (box1MineY > box2MaxeY){
  16271. delta=box1MineY-box2MaxeY;
  16272. distance+=delta *delta;
  16273. }else if (box2MineY > box1MaxeY){
  16274. delta=box2MineY-box1MaxeY;
  16275. distance+=delta *delta;
  16276. }
  16277. if (box1MineZ > box2MaxeZ){
  16278. delta=box1MineZ-box2MaxeZ;
  16279. distance+=delta *delta;
  16280. }else if (box2MineZ > box1MaxeZ){
  16281. delta=box2MineZ-box1MaxeZ;
  16282. distance+=delta *delta;
  16283. }
  16284. return Math.sqrt(distance);
  16285. }
  16286. CollisionUtils.distanceSphereToPoint=function(sphere,point){
  16287. var distance=Math.sqrt(Vector3.distanceSquared(sphere.center,point));
  16288. distance-=sphere.radius;
  16289. return Math.max(distance,0);
  16290. }
  16291. CollisionUtils.distanceSphereToSphere=function(sphere1,sphere2){
  16292. var distance=Math.sqrt(Vector3.distanceSquared(sphere1.center,sphere2.center));
  16293. distance-=sphere1.radius+sphere2.radius;
  16294. return Math.max(distance,0);
  16295. }
  16296. CollisionUtils.intersectsRayAndTriangleRD=function(ray,vertex1,vertex2,vertex3,out){
  16297. var rayO=ray.origin;
  16298. var rayOeX=rayO.x;
  16299. var rayOeY=rayO.y;
  16300. var rayOeZ=rayO.z;
  16301. var rayD=ray.direction;
  16302. var rayDeX=rayD.x;
  16303. var rayDeY=rayD.y;
  16304. var rayDeZ=rayD.z;
  16305. var v1eX=vertex1.x;
  16306. var v1eY=vertex1.y;
  16307. var v1eZ=vertex1.z;
  16308. var v2eX=vertex2.x;
  16309. var v2eY=vertex2.y;
  16310. var v2eZ=vertex2.z;
  16311. var v3eX=vertex3.x;
  16312. var v3eY=vertex3.y;
  16313. var v3eZ=vertex3.z;
  16314. var _tempV30eX=CollisionUtils._tempV30.x;
  16315. var _tempV30eY=CollisionUtils._tempV30.y;
  16316. var _tempV30eZ=CollisionUtils._tempV30.z;
  16317. _tempV30eX=v2eX-v1eX;
  16318. _tempV30eY=v2eY-v1eY;
  16319. _tempV30eZ=v2eZ-v1eZ;
  16320. var _tempV31eX=CollisionUtils._tempV31.x;
  16321. var _tempV31eY=CollisionUtils._tempV31.y;
  16322. var _tempV31eZ=CollisionUtils._tempV31.z;
  16323. _tempV31eX=v3eX-v1eX;
  16324. _tempV31eY=v3eY-v1eY;
  16325. _tempV31eZ=v3eZ-v1eZ;
  16326. var _tempV32eX=CollisionUtils._tempV32.x;
  16327. var _tempV32eY=CollisionUtils._tempV32.y;
  16328. var _tempV32eZ=CollisionUtils._tempV32.z;
  16329. _tempV32eX=(rayDeY *_tempV31eZ)-(rayDeZ *_tempV31eY);
  16330. _tempV32eY=(rayDeZ *_tempV31eX)-(rayDeX *_tempV31eZ);
  16331. _tempV32eZ=(rayDeX *_tempV31eY)-(rayDeY *_tempV31eX);
  16332. var determinant=(_tempV30eX *_tempV32eX)+(_tempV30eY *_tempV32eY)+(_tempV30eZ *_tempV32eZ);
  16333. if (MathUtils3D.isZero(determinant)){
  16334. out=0;
  16335. return false;
  16336. };
  16337. var inversedeterminant=1 / determinant;
  16338. var _tempV33eX=CollisionUtils._tempV33.x;
  16339. var _tempV33eY=CollisionUtils._tempV33.y;
  16340. var _tempV33eZ=CollisionUtils._tempV33.z;
  16341. _tempV33eX=rayOeX-v1eX;
  16342. _tempV33eY=rayOeY-v1eY;
  16343. _tempV33eZ=rayOeZ-v1eZ;
  16344. var triangleU=(_tempV33eX *_tempV32eX)+(_tempV33eY *_tempV32eY)+(_tempV33eZ *_tempV32eZ);
  16345. triangleU *=inversedeterminant;
  16346. if (triangleU < 0 || triangleU > 1){
  16347. out=0;
  16348. return false;
  16349. };
  16350. var _tempV34eX=CollisionUtils._tempV34.x;
  16351. var _tempV34eY=CollisionUtils._tempV34.y;
  16352. var _tempV34eZ=CollisionUtils._tempV34.z;
  16353. _tempV34eX=(_tempV33eY *_tempV30eZ)-(_tempV33eZ *_tempV30eY);
  16354. _tempV34eY=(_tempV33eZ *_tempV30eX)-(_tempV33eX *_tempV30eZ);
  16355. _tempV34eZ=(_tempV33eX *_tempV30eY)-(_tempV33eY *_tempV30eX);
  16356. var triangleV=((rayDeX *_tempV34eX)+(rayDeY *_tempV34eY))+(rayDeZ *_tempV34eZ);
  16357. triangleV *=inversedeterminant;
  16358. if (triangleV < 0 || triangleU+triangleV > 1){
  16359. out=0;
  16360. return false;
  16361. };
  16362. var raydistance=(_tempV31eX *_tempV34eX)+(_tempV31eY *_tempV34eY)+(_tempV31eZ *_tempV34eZ);
  16363. raydistance *=inversedeterminant;
  16364. if (raydistance < 0){
  16365. out=0;
  16366. return false;
  16367. }
  16368. out=raydistance;
  16369. return true;
  16370. }
  16371. CollisionUtils.intersectsRayAndTriangleRP=function(ray,vertex1,vertex2,vertex3,out){
  16372. var distance=NaN;
  16373. if (!CollisionUtils.intersectsRayAndTriangleRD(ray,vertex1,vertex2,vertex3,distance)){
  16374. out=Vector3._ZERO;
  16375. return false;
  16376. }
  16377. Vector3.scale(ray.direction,distance,CollisionUtils._tempV30);
  16378. Vector3.add(ray.origin,CollisionUtils._tempV30,out);
  16379. return true;
  16380. }
  16381. CollisionUtils.intersectsRayAndPoint=function(ray,point){
  16382. Vector3.subtract(ray.origin,point,CollisionUtils._tempV30);
  16383. var b=Vector3.dot(CollisionUtils._tempV30,ray.direction);
  16384. var c=Vector3.dot(CollisionUtils._tempV30,CollisionUtils._tempV30)-MathUtils3D.zeroTolerance;
  16385. if (c > 0 && b > 0)
  16386. return false;
  16387. var discriminant=b *b-c;
  16388. if (discriminant < 0)
  16389. return false;
  16390. return true;
  16391. }
  16392. CollisionUtils.intersectsRayAndRay=function(ray1,ray2,out){
  16393. var ray1o=ray1.origin;
  16394. var ray1oeX=ray1o.x;
  16395. var ray1oeY=ray1o.y;
  16396. var ray1oeZ=ray1o.z;
  16397. var ray1d=ray1.direction;
  16398. var ray1deX=ray1d.x;
  16399. var ray1deY=ray1d.y;
  16400. var ray1deZ=ray1d.z;
  16401. var ray2o=ray2.origin;
  16402. var ray2oeX=ray2o.x;
  16403. var ray2oeY=ray2o.y;
  16404. var ray2oeZ=ray2o.z;
  16405. var ray2d=ray2.direction;
  16406. var ray2deX=ray2d.x;
  16407. var ray2deY=ray2d.y;
  16408. var ray2deZ=ray2d.z;
  16409. Vector3.cross(ray1d,ray2d,CollisionUtils._tempV30);
  16410. var tempV3=CollisionUtils._tempV30;
  16411. var denominator=Vector3.scalarLength(CollisionUtils._tempV30);
  16412. if (MathUtils3D.isZero(denominator)){
  16413. if (MathUtils3D.nearEqual(ray2oeX,ray1oeX)&& MathUtils3D.nearEqual(ray2oeY,ray1oeY)&& MathUtils3D.nearEqual(ray2oeZ,ray1oeZ)){
  16414. out=Vector3._ZERO;
  16415. return true;
  16416. }
  16417. }
  16418. denominator=denominator *denominator;
  16419. var m11=ray2oeX-ray1oeX;
  16420. var m12=ray2oeY-ray1oeY;
  16421. var m13=ray2oeZ-ray1oeZ;
  16422. var m21=ray2deX;
  16423. var m22=ray2deY;
  16424. var m23=ray2deZ;
  16425. var m31=tempV3.x;
  16426. var m32=tempV3.y;
  16427. var m33=tempV3.z;
  16428. var dets=m11 *m22 *m33+m12 *m23 *m31+m13 *m21 *m32-m11 *m23 *m32-m12 *m21 *m33-m13 *m22 *m31;
  16429. m21=ray1deX;
  16430. m22=ray1deY;
  16431. m23=ray1deZ;
  16432. var dett=m11 *m22 *m33+m12 *m23 *m31+m13 *m21 *m32-m11 *m23 *m32-m12 *m21 *m33-m13 *m22 *m31;
  16433. var s=dets / denominator;
  16434. var t=dett / denominator;
  16435. Vector3.scale(ray1d,s,CollisionUtils._tempV30);
  16436. Vector3.scale(ray2d,s,CollisionUtils._tempV31);
  16437. Vector3.add(ray1o,CollisionUtils._tempV30,CollisionUtils._tempV32);
  16438. Vector3.add(ray2o,CollisionUtils._tempV31,CollisionUtils._tempV33);
  16439. var point1e=CollisionUtils._tempV32;
  16440. var point2e=CollisionUtils._tempV33;
  16441. if (!MathUtils3D.nearEqual(point2e.x,point1e.x)|| !MathUtils3D.nearEqual(point2e.y,point1e.y)|| !MathUtils3D.nearEqual(point2e.z,point1e.z)){
  16442. out=Vector3._ZERO;
  16443. return false;
  16444. }
  16445. out=CollisionUtils._tempV32;
  16446. return true;
  16447. }
  16448. CollisionUtils.intersectsPlaneAndTriangle=function(plane,vertex1,vertex2,vertex3){
  16449. var test1=CollisionUtils.intersectsPlaneAndPoint(plane,vertex1);
  16450. var test2=CollisionUtils.intersectsPlaneAndPoint(plane,vertex2);
  16451. var test3=CollisionUtils.intersectsPlaneAndPoint(plane,vertex3);
  16452. if (test1==Plane.PlaneIntersectionType_Front && test2==Plane.PlaneIntersectionType_Front && test3==Plane.PlaneIntersectionType_Front)
  16453. return Plane.PlaneIntersectionType_Front;
  16454. if (test1==Plane.PlaneIntersectionType_Back && test2==Plane.PlaneIntersectionType_Back && test3==Plane.PlaneIntersectionType_Back)
  16455. return Plane.PlaneIntersectionType_Back;
  16456. return Plane.PlaneIntersectionType_Intersecting;
  16457. }
  16458. CollisionUtils.intersectsRayAndPlaneRD=function(ray,plane,out){
  16459. var planeNor=plane.normal;
  16460. var direction=Vector3.dot(planeNor,ray.direction);
  16461. if (MathUtils3D.isZero(direction)){
  16462. out=0;
  16463. return false;
  16464. };
  16465. var position=Vector3.dot(planeNor,ray.origin);
  16466. out=(-plane.distance-position)/ direction;
  16467. if (out < 0){
  16468. out=0;
  16469. return false;
  16470. }
  16471. return true;
  16472. }
  16473. CollisionUtils.intersectsRayAndPlaneRP=function(ray,plane,out){
  16474. var distance=NaN;
  16475. if (!CollisionUtils.intersectsRayAndPlaneRD(ray,plane,distance)){
  16476. out=Vector3._ZERO;
  16477. return false;
  16478. }
  16479. Vector3.scale(ray.direction,distance,CollisionUtils._tempV30);
  16480. Vector3.add(ray.origin,CollisionUtils._tempV30,CollisionUtils._tempV31);
  16481. out=CollisionUtils._tempV31;
  16482. return true;
  16483. }
  16484. CollisionUtils.intersectsRayAndBoxRD=function(ray,box){
  16485. var rayoe=ray.origin;
  16486. var rayoeX=rayoe.x;
  16487. var rayoeY=rayoe.y;
  16488. var rayoeZ=rayoe.z;
  16489. var rayde=ray.direction;
  16490. var raydeX=rayde.x;
  16491. var raydeY=rayde.y;
  16492. var raydeZ=rayde.z;
  16493. var boxMine=box.min;
  16494. var boxMineX=boxMine.x;
  16495. var boxMineY=boxMine.y;
  16496. var boxMineZ=boxMine.z;
  16497. var boxMaxe=box.max;
  16498. var boxMaxeX=boxMaxe.x;
  16499. var boxMaxeY=boxMaxe.y;
  16500. var boxMaxeZ=boxMaxe.z;
  16501. var out=0;
  16502. var tmax=MathUtils3D.MaxValue;
  16503. if (MathUtils3D.isZero(raydeX)){
  16504. if (rayoeX < boxMineX || rayoeX > boxMaxeX){
  16505. return-1;
  16506. }
  16507. }else {
  16508. var inverse=1 / raydeX;
  16509. var t1=(boxMineX-rayoeX)*inverse;
  16510. var t2=(boxMaxeX-rayoeX)*inverse;
  16511. if (t1 > t2){
  16512. var temp=t1;
  16513. t1=t2;
  16514. t2=temp;
  16515. }
  16516. out=Math.max(t1,out);
  16517. tmax=Math.min(t2,tmax);
  16518. if (out > tmax){
  16519. return-1;
  16520. }
  16521. }
  16522. if (MathUtils3D.isZero(raydeY)){
  16523. if (rayoeY < boxMineY || rayoeY > boxMaxeY){
  16524. return-1;
  16525. }
  16526. }else {
  16527. var inverse1=1 / raydeY;
  16528. var t3=(boxMineY-rayoeY)*inverse1;
  16529. var t4=(boxMaxeY-rayoeY)*inverse1;
  16530. if (t3 > t4){
  16531. var temp1=t3;
  16532. t3=t4;
  16533. t4=temp1;
  16534. }
  16535. out=Math.max(t3,out);
  16536. tmax=Math.min(t4,tmax);
  16537. if (out > tmax){
  16538. return-1;
  16539. }
  16540. }
  16541. if (MathUtils3D.isZero(raydeZ)){
  16542. if (rayoeZ < boxMineZ || rayoeZ > boxMaxeZ){
  16543. return-1;
  16544. }
  16545. }else {
  16546. var inverse2=1 / raydeZ;
  16547. var t5=(boxMineZ-rayoeZ)*inverse2;
  16548. var t6=(boxMaxeZ-rayoeZ)*inverse2;
  16549. if (t5 > t6){
  16550. var temp2=t5;
  16551. t5=t6;
  16552. t6=temp2;
  16553. }
  16554. out=Math.max(t5,out);
  16555. tmax=Math.min(t6,tmax);
  16556. if (out > tmax){
  16557. return-1;
  16558. }
  16559. }
  16560. return out;
  16561. }
  16562. CollisionUtils.intersectsRayAndBoxRP=function(ray,box,out){
  16563. var distance=CollisionUtils.intersectsRayAndBoxRD(ray,box);
  16564. if (distance===-1){
  16565. Vector3._ZERO.cloneTo(out);
  16566. return distance;
  16567. }
  16568. Vector3.scale(ray.direction,distance,CollisionUtils._tempV30);
  16569. Vector3.add(ray.origin,CollisionUtils._tempV30,CollisionUtils._tempV31);
  16570. CollisionUtils._tempV31.cloneTo(out);
  16571. return distance;
  16572. }
  16573. CollisionUtils.intersectsRayAndSphereRD=function(ray,sphere){
  16574. var sphereR=sphere.radius;
  16575. Vector3.subtract(ray.origin,sphere.center,CollisionUtils._tempV30);
  16576. var b=Vector3.dot(CollisionUtils._tempV30,ray.direction);
  16577. var c=Vector3.dot(CollisionUtils._tempV30,CollisionUtils._tempV30)-(sphereR *sphereR);
  16578. if (c > 0 && b > 0){
  16579. return-1;
  16580. };
  16581. var discriminant=b *b-c;
  16582. if (discriminant < 0){
  16583. return-1;
  16584. };
  16585. var distance=-b-Math.sqrt(discriminant);
  16586. if (distance < 0)
  16587. distance=0;
  16588. return distance;
  16589. }
  16590. CollisionUtils.intersectsRayAndSphereRP=function(ray,sphere,out){
  16591. var distance=CollisionUtils.intersectsRayAndSphereRD(ray,sphere);
  16592. if (distance===-1){
  16593. Vector3._ZERO.cloneTo(out);
  16594. return distance;
  16595. }
  16596. Vector3.scale(ray.direction,distance,CollisionUtils._tempV30);
  16597. Vector3.add(ray.origin,CollisionUtils._tempV30,CollisionUtils._tempV31);
  16598. CollisionUtils._tempV31.cloneTo(out);
  16599. return distance;
  16600. }
  16601. CollisionUtils.intersectsSphereAndTriangle=function(sphere,vertex1,vertex2,vertex3){
  16602. var sphereC=sphere.center;
  16603. var sphereR=sphere.radius;
  16604. CollisionUtils.closestPointPointTriangle(sphereC,vertex1,vertex2,vertex3,CollisionUtils._tempV30);
  16605. Vector3.subtract(CollisionUtils._tempV30,sphereC,CollisionUtils._tempV31);
  16606. var dot=Vector3.dot(CollisionUtils._tempV31,CollisionUtils._tempV31);
  16607. return dot <=sphereR *sphereR;
  16608. }
  16609. CollisionUtils.intersectsPlaneAndPoint=function(plane,point){
  16610. var distance=Vector3.dot(plane.normal,point)+plane.distance;
  16611. if (distance > 0)
  16612. return Plane.PlaneIntersectionType_Front;
  16613. if (distance < 0)
  16614. return Plane.PlaneIntersectionType_Back;
  16615. return Plane.PlaneIntersectionType_Intersecting;
  16616. }
  16617. CollisionUtils.intersectsPlaneAndPlane=function(plane1,plane2){
  16618. Vector3.cross(plane1.normal,plane2.normal,CollisionUtils._tempV30);
  16619. var denominator=Vector3.dot(CollisionUtils._tempV30,CollisionUtils._tempV30);
  16620. if (MathUtils3D.isZero(denominator))
  16621. return false;
  16622. return true;
  16623. }
  16624. CollisionUtils.intersectsPlaneAndPlaneRL=function(plane1,plane2,line){
  16625. var plane1nor=plane1.normal;
  16626. var plane2nor=plane2.normal;
  16627. Vector3.cross(plane1nor,plane2nor,CollisionUtils._tempV34);
  16628. var denominator=Vector3.dot(CollisionUtils._tempV34,CollisionUtils._tempV34);
  16629. if (MathUtils3D.isZero(denominator))
  16630. return false;
  16631. Vector3.scale(plane2nor,plane1.distance,CollisionUtils._tempV30);
  16632. Vector3.scale(plane1nor,plane2.distance,CollisionUtils._tempV31);
  16633. Vector3.subtract(CollisionUtils._tempV30,CollisionUtils._tempV31,CollisionUtils._tempV32);
  16634. Vector3.cross(CollisionUtils._tempV32,CollisionUtils._tempV34,CollisionUtils._tempV33);
  16635. Vector3.normalize(CollisionUtils._tempV34,CollisionUtils._tempV34);
  16636. line=new Ray(CollisionUtils._tempV33,CollisionUtils._tempV34);
  16637. return true;
  16638. }
  16639. CollisionUtils.intersectsPlaneAndBox=function(plane,box){
  16640. var planeD=plane.distance;
  16641. var planeNor=plane.normal;
  16642. var planeNoreX=planeNor.x;
  16643. var planeNoreY=planeNor.y;
  16644. var planeNoreZ=planeNor.z;
  16645. var boxMine=box.min;
  16646. var boxMineX=boxMine.x;
  16647. var boxMineY=boxMine.y;
  16648. var boxMineZ=boxMine.z;
  16649. var boxMaxe=box.max;
  16650. var boxMaxeX=boxMaxe.x;
  16651. var boxMaxeY=boxMaxe.y;
  16652. var boxMaxeZ=boxMaxe.z;
  16653. CollisionUtils._tempV30.x=(planeNoreX > 0)? boxMineX :boxMaxeX;
  16654. CollisionUtils._tempV30.y=(planeNoreY > 0)? boxMineY :boxMaxeY;
  16655. CollisionUtils._tempV30.z=(planeNoreZ > 0)? boxMineZ :boxMaxeZ;
  16656. CollisionUtils._tempV31.x=(planeNoreX > 0)? boxMaxeX :boxMineX;
  16657. CollisionUtils._tempV31.y=(planeNoreY > 0)? boxMaxeY :boxMineY;
  16658. CollisionUtils._tempV31.z=(planeNoreZ > 0)? boxMaxeZ :boxMineZ;
  16659. var distance=Vector3.dot(planeNor,CollisionUtils._tempV30);
  16660. if (distance+planeD > 0)
  16661. return Plane.PlaneIntersectionType_Front;
  16662. distance=Vector3.dot(planeNor,CollisionUtils._tempV31);
  16663. if (distance+planeD < 0)
  16664. return Plane.PlaneIntersectionType_Back;
  16665. return Plane.PlaneIntersectionType_Intersecting;
  16666. }
  16667. CollisionUtils.intersectsPlaneAndSphere=function(plane,sphere){
  16668. var sphereR=sphere.radius;
  16669. var distance=Vector3.dot(plane.normal,sphere.center)+plane.distance;
  16670. if (distance > sphereR)
  16671. return Plane.PlaneIntersectionType_Front;
  16672. if (distance <-sphereR)
  16673. return Plane.PlaneIntersectionType_Back;
  16674. return Plane.PlaneIntersectionType_Intersecting;
  16675. }
  16676. CollisionUtils.intersectsBoxAndBox=function(box1,box2){
  16677. var box1Mine=box1.min;
  16678. var box1Maxe=box1.max;
  16679. var box2Mine=box2.min;
  16680. var box2Maxe=box2.max;
  16681. if (box1Mine.x > box2Maxe.x || box2Mine.x > box1Maxe.x)
  16682. return false;
  16683. if (box1Mine.y > box2Maxe.y || box2Mine.y > box1Maxe.y)
  16684. return false;
  16685. if (box1Mine.z > box2Maxe.z || box2Mine.z > box1Maxe.z)
  16686. return false;
  16687. return true;
  16688. }
  16689. CollisionUtils.intersectsBoxAndSphere=function(box,sphere){
  16690. var sphereC=sphere.center;
  16691. var sphereR=sphere.radius;
  16692. Vector3.Clamp(sphereC,box.min,box.max,CollisionUtils._tempV30);
  16693. var distance=Vector3.distanceSquared(sphereC,CollisionUtils._tempV30);
  16694. return distance <=sphereR *sphereR;
  16695. }
  16696. CollisionUtils.intersectsSphereAndSphere=function(sphere1,sphere2){
  16697. var radiisum=sphere1.radius+sphere2.radius;
  16698. return Vector3.distanceSquared(sphere1.center,sphere2.center)<=radiisum *radiisum;
  16699. }
  16700. CollisionUtils.boxContainsPoint=function(box,point){
  16701. var boxMine=box.min;
  16702. var boxMaxe=box.max;
  16703. if (boxMine.x <=point.x && boxMaxe.x >=point.x && boxMine.y <=point.y && boxMaxe.y >=point.y && boxMine.z <=point.z && boxMaxe.z >=point.z)
  16704. return /*laya.d3.math.ContainmentType.Contains*/1;
  16705. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  16706. }
  16707. CollisionUtils.boxContainsBox=function(box1,box2){
  16708. var box1Mine=box1.min;
  16709. var box1MineX=box1Mine.x;
  16710. var box1MineY=box1Mine.y;
  16711. var box1MineZ=box1Mine.z;
  16712. var box1Maxe=box1.max;
  16713. var box1MaxeX=box1Maxe.x;
  16714. var box1MaxeY=box1Maxe.y;
  16715. var box1MaxeZ=box1Maxe.z;
  16716. var box2Mine=box2.min;
  16717. var box2MineX=box2Mine.x;
  16718. var box2MineY=box2Mine.y;
  16719. var box2MineZ=box2Mine.z;
  16720. var box2Maxe=box2.max;
  16721. var box2MaxeX=box2Maxe.x;
  16722. var box2MaxeY=box2Maxe.y;
  16723. var box2MaxeZ=box2Maxe.z;
  16724. if (box1MaxeX < box2MineX || box1MineX > box2MaxeX)
  16725. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  16726. if (box1MaxeY < box2MineY || box1MineY > box2MaxeY)
  16727. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  16728. if (box1MaxeZ < box2MineZ || box1MineZ > box2MaxeZ)
  16729. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  16730. if (box1MineX <=box2MineX && box2MaxeX <=box1MaxeX && box1MineY <=box2MineY && box2MaxeY <=box1MaxeY && box1MineZ <=box2MineZ && box2MaxeZ <=box1MaxeZ){
  16731. return /*laya.d3.math.ContainmentType.Contains*/1;
  16732. }
  16733. return /*laya.d3.math.ContainmentType.Intersects*/2;
  16734. }
  16735. CollisionUtils.boxContainsSphere=function(box,sphere){
  16736. var boxMin=box.min;
  16737. var boxMineX=boxMin.x;
  16738. var boxMineY=boxMin.y;
  16739. var boxMineZ=boxMin.z;
  16740. var boxMax=box.max;
  16741. var boxMaxeX=boxMax.x;
  16742. var boxMaxeY=boxMax.y;
  16743. var boxMaxeZ=boxMax.z;
  16744. var sphereC=sphere.center;
  16745. var sphereCeX=sphereC.x;
  16746. var sphereCeY=sphereC.y;
  16747. var sphereCeZ=sphereC.z;
  16748. var sphereR=sphere.radius;
  16749. Vector3.Clamp(sphereC,boxMin,boxMax,CollisionUtils._tempV30);
  16750. var distance=Vector3.distanceSquared(sphereC,CollisionUtils._tempV30);
  16751. if (distance > sphereR *sphereR)
  16752. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  16753. if ((((boxMineX+sphereR <=sphereCeX)&& (sphereCeX <=boxMaxeX-sphereR))&& ((boxMaxeX-boxMineX > sphereR)&&
  16754. (boxMineY+sphereR <=sphereCeY)))&& (((sphereCeY <=boxMaxeY-sphereR)&& (boxMaxeY-boxMineY > sphereR))&&
  16755. (((boxMineZ+sphereR <=sphereCeZ)&& (sphereCeZ <=boxMaxeZ-sphereR))&& (boxMaxeZ-boxMineZ > sphereR))))
  16756. return /*laya.d3.math.ContainmentType.Contains*/1;
  16757. return /*laya.d3.math.ContainmentType.Intersects*/2;
  16758. }
  16759. CollisionUtils.sphereContainsPoint=function(sphere,point){
  16760. if (Vector3.distanceSquared(point,sphere.center)<=sphere.radius *sphere.radius)
  16761. return /*laya.d3.math.ContainmentType.Contains*/1;
  16762. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  16763. }
  16764. CollisionUtils.sphereContainsTriangle=function(sphere,vertex1,vertex2,vertex3){
  16765. var test1=CollisionUtils.sphereContainsPoint(sphere,vertex1);
  16766. var test2=CollisionUtils.sphereContainsPoint(sphere,vertex2);
  16767. var test3=CollisionUtils.sphereContainsPoint(sphere,vertex3);
  16768. if (test1==/*laya.d3.math.ContainmentType.Contains*/1 && test2==/*laya.d3.math.ContainmentType.Contains*/1 && test3==/*laya.d3.math.ContainmentType.Contains*/1)
  16769. return /*laya.d3.math.ContainmentType.Contains*/1;
  16770. if (CollisionUtils.intersectsSphereAndTriangle(sphere,vertex1,vertex2,vertex3))
  16771. return /*laya.d3.math.ContainmentType.Intersects*/2;
  16772. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  16773. }
  16774. CollisionUtils.sphereContainsBox=function(sphere,box){
  16775. var sphereC=sphere.center;
  16776. var sphereCeX=sphereC.x;
  16777. var sphereCeY=sphereC.y;
  16778. var sphereCeZ=sphereC.z;
  16779. var sphereR=sphere.radius;
  16780. var boxMin=box.min;
  16781. var boxMineX=boxMin.x;
  16782. var boxMineY=boxMin.y;
  16783. var boxMineZ=boxMin.z;
  16784. var boxMax=box.max;
  16785. var boxMaxeX=boxMax.x;
  16786. var boxMaxeY=boxMax.y;
  16787. var boxMaxeZ=boxMax.z;
  16788. var _tempV30e=CollisionUtils._tempV30;
  16789. var _tempV30eX=_tempV30e.x;
  16790. var _tempV30eY=_tempV30e.y;
  16791. var _tempV30eZ=_tempV30e.z;
  16792. if (!CollisionUtils.intersectsBoxAndSphere(box,sphere))
  16793. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  16794. var radiusSquared=sphereR *sphereR;
  16795. _tempV30eX=sphereCeX-boxMineX;
  16796. _tempV30eY=sphereCeY-boxMaxeY;
  16797. _tempV30eZ=sphereCeZ-boxMaxeZ;
  16798. if (Vector3.scalarLengthSquared(CollisionUtils._tempV30)> radiusSquared)
  16799. return /*laya.d3.math.ContainmentType.Intersects*/2;
  16800. _tempV30eX=sphereCeX-boxMaxeX;
  16801. _tempV30eY=sphereCeY-boxMaxeY;
  16802. _tempV30eZ=sphereCeZ-boxMaxeZ;
  16803. if (Vector3.scalarLengthSquared(CollisionUtils._tempV30)> radiusSquared)
  16804. return /*laya.d3.math.ContainmentType.Intersects*/2;
  16805. _tempV30eX=sphereCeX-boxMaxeX;
  16806. _tempV30eY=sphereCeY-boxMineY;
  16807. _tempV30eZ=sphereCeZ-boxMaxeZ;
  16808. if (Vector3.scalarLengthSquared(CollisionUtils._tempV30)> radiusSquared)
  16809. return /*laya.d3.math.ContainmentType.Intersects*/2;
  16810. _tempV30eX=sphereCeX-boxMineX;
  16811. _tempV30eY=sphereCeY-boxMineY;
  16812. _tempV30eZ=sphereCeZ-boxMaxeZ;
  16813. if (Vector3.scalarLengthSquared(CollisionUtils._tempV30)> radiusSquared)
  16814. return /*laya.d3.math.ContainmentType.Intersects*/2;
  16815. _tempV30eX=sphereCeX-boxMineX;
  16816. _tempV30eY=sphereCeY-boxMaxeY;
  16817. _tempV30eZ=sphereCeZ-boxMineZ;
  16818. if (Vector3.scalarLengthSquared(CollisionUtils._tempV30)> radiusSquared)
  16819. return /*laya.d3.math.ContainmentType.Intersects*/2;
  16820. _tempV30eX=sphereCeX-boxMaxeX;
  16821. _tempV30eY=sphereCeY-boxMaxeY;
  16822. _tempV30eZ=sphereCeZ-boxMineZ;
  16823. if (Vector3.scalarLengthSquared(CollisionUtils._tempV30)> radiusSquared)
  16824. return /*laya.d3.math.ContainmentType.Intersects*/2;
  16825. _tempV30eX=sphereCeX-boxMaxeX;
  16826. _tempV30eY=sphereCeY-boxMineY;
  16827. _tempV30eZ=sphereCeZ-boxMineZ;
  16828. if (Vector3.scalarLengthSquared(CollisionUtils._tempV30)> radiusSquared)
  16829. return /*laya.d3.math.ContainmentType.Intersects*/2;
  16830. _tempV30eX=sphereCeX-boxMineX;
  16831. _tempV30eY=sphereCeY-boxMineY;
  16832. _tempV30eZ=sphereCeZ-boxMineZ;
  16833. if (Vector3.scalarLengthSquared(CollisionUtils._tempV30)> radiusSquared)
  16834. return /*laya.d3.math.ContainmentType.Intersects*/2;
  16835. return /*laya.d3.math.ContainmentType.Contains*/1;
  16836. }
  16837. CollisionUtils.sphereContainsSphere=function(sphere1,sphere2){
  16838. var sphere1R=sphere1.radius;
  16839. var sphere2R=sphere2.radius;
  16840. var distance=Vector3.distance(sphere1.center,sphere2.center);
  16841. if (sphere1R+sphere2R < distance)
  16842. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  16843. if (sphere1R-sphere2R < distance)
  16844. return /*laya.d3.math.ContainmentType.Intersects*/2;
  16845. return /*laya.d3.math.ContainmentType.Contains*/1;
  16846. }
  16847. CollisionUtils.closestPointPointTriangle=function(point,vertex1,vertex2,vertex3,out){
  16848. Vector3.subtract(vertex2,vertex1,CollisionUtils._tempV30);
  16849. Vector3.subtract(vertex3,vertex1,CollisionUtils._tempV31);
  16850. Vector3.subtract(point,vertex1,CollisionUtils._tempV32);
  16851. Vector3.subtract(point,vertex2,CollisionUtils._tempV33);
  16852. Vector3.subtract(point,vertex3,CollisionUtils._tempV34);
  16853. var d1=Vector3.dot(CollisionUtils._tempV30,CollisionUtils._tempV32);
  16854. var d2=Vector3.dot(CollisionUtils._tempV31,CollisionUtils._tempV32);
  16855. var d3=Vector3.dot(CollisionUtils._tempV30,CollisionUtils._tempV33);
  16856. var d4=Vector3.dot(CollisionUtils._tempV31,CollisionUtils._tempV33);
  16857. var d5=Vector3.dot(CollisionUtils._tempV30,CollisionUtils._tempV34);
  16858. var d6=Vector3.dot(CollisionUtils._tempV31,CollisionUtils._tempV34);
  16859. if (d1 <=0 && d2 <=0){
  16860. vertex1.cloneTo(out);
  16861. return;
  16862. }
  16863. if (d3 >=0 && d4 <=d3){
  16864. vertex2.cloneTo(out);
  16865. return;
  16866. };
  16867. var vc=d1 *d4-d3 *d2;
  16868. if (vc <=0 && d1 >=0 && d3 <=0){
  16869. var v=d1 / (d1-d3);
  16870. Vector3.scale(CollisionUtils._tempV30,v,out);
  16871. Vector3.add(vertex1,out,out);
  16872. return;
  16873. }
  16874. if (d6 >=0 && d5 <=d6){
  16875. vertex3.cloneTo(out);
  16876. return;
  16877. };
  16878. var vb=d5 *d2-d1 *d6;
  16879. if (vb <=0 && d2 >=0 && d6 <=0){
  16880. var w=d2 / (d2-d6);
  16881. Vector3.scale(CollisionUtils._tempV31,w,out);
  16882. Vector3.add(vertex1,out,out);
  16883. return;
  16884. };
  16885. var va=d3 *d6-d5 *d4;
  16886. if (va <=0 && (d4-d3)>=0 && (d5-d6)>=0){
  16887. var w3=(d4-d3)/ ((d4-d3)+(d5-d6));
  16888. Vector3.subtract(vertex3,vertex2,out);
  16889. Vector3.scale(out,w3,out);
  16890. Vector3.add(vertex2,out,out);
  16891. return;
  16892. };
  16893. var denom=1 / (va+vb+vc);
  16894. var v2=vb *denom;
  16895. var w2=vc *denom;
  16896. Vector3.scale(CollisionUtils._tempV30,v2,CollisionUtils._tempV35);
  16897. Vector3.scale(CollisionUtils._tempV31,w2,CollisionUtils._tempV36);
  16898. Vector3.add(CollisionUtils._tempV35,CollisionUtils._tempV36,out);
  16899. Vector3.add(vertex1,out,out);
  16900. }
  16901. CollisionUtils.closestPointPlanePoint=function(plane,point,out){
  16902. var planeN=plane.normal;
  16903. var t=Vector3.dot(planeN,point)-plane.distance;
  16904. Vector3.scale(planeN,t,CollisionUtils._tempV30);
  16905. Vector3.subtract(point,CollisionUtils._tempV30,out);
  16906. }
  16907. CollisionUtils.closestPointBoxPoint=function(box,point,out){
  16908. Vector3.max(point,box.min,CollisionUtils._tempV30);
  16909. Vector3.min(CollisionUtils._tempV30,box.max,out);
  16910. }
  16911. CollisionUtils.closestPointSpherePoint=function(sphere,point,out){
  16912. var sphereC=sphere.center;
  16913. Vector3.subtract(point,sphereC,out);
  16914. Vector3.normalize(out,out);
  16915. Vector3.scale(out,sphere.radius,out);
  16916. Vector3.add(out,sphereC,out);
  16917. }
  16918. CollisionUtils.closestPointSphereSphere=function(sphere1,sphere2,out){
  16919. var sphere1C=sphere1.center;
  16920. Vector3.subtract(sphere2.center,sphere1C,out);
  16921. Vector3.normalize(out,out);
  16922. Vector3.scale(out,sphere1.radius,out);
  16923. Vector3.add(out,sphere1C,out);
  16924. }
  16925. __static(CollisionUtils,
  16926. ['_tempV30',function(){return this._tempV30=new Vector3();},'_tempV31',function(){return this._tempV31=new Vector3();},'_tempV32',function(){return this._tempV32=new Vector3();},'_tempV33',function(){return this._tempV33=new Vector3();},'_tempV34',function(){return this._tempV34=new Vector3();},'_tempV35',function(){return this._tempV35=new Vector3();},'_tempV36',function(){return this._tempV36=new Vector3();}
  16927. ]);
  16928. return CollisionUtils;
  16929. })()
  16930. /**
  16931. *<code>Matrix3x3</code> 类用于创建3x3矩阵。
  16932. */
  16933. //class laya.d3.math.Matrix3x3
  16934. var Matrix3x3=(function(){
  16935. function Matrix3x3(){
  16936. /**矩阵元素数组*/
  16937. //this.elements=null;
  16938. var e=this.elements=new Float32Array(9);
  16939. e[0]=1;
  16940. e[1]=0;
  16941. e[2]=0;
  16942. e[3]=0;
  16943. e[4]=1;
  16944. e[5]=0;
  16945. e[6]=0;
  16946. e[7]=0;
  16947. e[8]=1;
  16948. }
  16949. __class(Matrix3x3,'laya.d3.math.Matrix3x3');
  16950. var __proto=Matrix3x3.prototype;
  16951. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  16952. /**
  16953. *计算3x3矩阵的行列式
  16954. *@return 矩阵的行列式
  16955. */
  16956. __proto.determinant=function(){
  16957. var f=this.elements;
  16958. var a00=f[0],a01=f[1],a02=f[2];
  16959. var a10=f[3],a11=f[4],a12=f[5];
  16960. var a20=f[6],a21=f[7],a22=f[8];
  16961. return a00 *(a22 *a11-a12 *a21)+a01 *(-a22 *a10+a12 *a20)+a02 *(a21 *a10-a11 *a20);
  16962. }
  16963. /**
  16964. *通过一个二维向量转换3x3矩阵
  16965. *@param tra 转换向量
  16966. *@param out 输出矩阵
  16967. */
  16968. __proto.translate=function(trans,out){
  16969. var e=out.elements;
  16970. var f=this.elements;
  16971. var a00=f[0],a01=f[1],a02=f[2];
  16972. var a10=f[3],a11=f[4],a12=f[5];
  16973. var a20=f[6],a21=f[7],a22=f[8];
  16974. var x=trans.x,y=trans.y;
  16975. e[0]=a00;
  16976. e[1]=a01;
  16977. e[2]=a02;
  16978. e[3]=a10;
  16979. e[4]=a11;
  16980. e[5]=a12;
  16981. e[6]=x *a00+y *a10+a20;
  16982. e[7]=x *a01+y *a11+a21;
  16983. e[8]=x *a02+y *a12+a22;
  16984. }
  16985. /**
  16986. *根据指定角度旋转3x3矩阵
  16987. *@param rad 旋转角度
  16988. *@param out 输出矩阵
  16989. */
  16990. __proto.rotate=function(rad,out){
  16991. var e=out.elements;
  16992. var f=this.elements;
  16993. var a00=f[0],a01=f[1],a02=f[2];
  16994. var a10=f[3],a11=f[4],a12=f[5];
  16995. var a20=f[6],a21=f[7],a22=f[8];
  16996. var s=Math.sin(rad);
  16997. var c=Math.cos(rad);
  16998. e[0]=c *a00+s *a10;
  16999. e[1]=c *a01+s *a11;
  17000. e[2]=c *a02+s *a12;
  17001. e[3]=c *a10-s *a00;
  17002. e[4]=c *a11-s *a01;
  17003. e[5]=c *a12-s *a02;
  17004. e[6]=a20;
  17005. e[7]=a21;
  17006. e[8]=a22;
  17007. }
  17008. /**
  17009. *根据制定缩放3x3矩阵
  17010. *@param scale 缩放值
  17011. *@param out 输出矩阵
  17012. */
  17013. __proto.scale=function(scale,out){
  17014. var e=out.elements;
  17015. var f=this.elements;
  17016. var x=scale.x,y=scale.y;
  17017. e[0]=x *f[0];
  17018. e[1]=x *f[1];
  17019. e[2]=x *f[2];
  17020. e[3]=y *f[3];
  17021. e[4]=y *f[4];
  17022. e[5]=y *f[5];
  17023. e[6]=f[6];
  17024. e[7]=f[7];
  17025. e[8]=f[8];
  17026. }
  17027. /**
  17028. *计算3x3矩阵的逆矩阵
  17029. *@param out 输出的逆矩阵
  17030. */
  17031. __proto.invert=function(out){
  17032. var e=out.elements;
  17033. var f=this.elements;
  17034. var a00=f[0],a01=f[1],a02=f[2];
  17035. var a10=f[3],a11=f[4],a12=f[5];
  17036. var a20=f[6],a21=f[7],a22=f[8];
  17037. var b01=a22 *a11-a12 *a21;
  17038. var b11=-a22 *a10+a12 *a20;
  17039. var b21=a21 *a10-a11 *a20;
  17040. var det=a00 *b01+a01 *b11+a02 *b21;
  17041. if (!det){
  17042. out=null;
  17043. }
  17044. det=1.0 / det;
  17045. e[0]=b01 *det;
  17046. e[1]=(-a22 *a01+a02 *a21)*det;
  17047. e[2]=(a12 *a01-a02 *a11)*det;
  17048. e[3]=b11 *det;
  17049. e[4]=(a22 *a00-a02 *a20)*det;
  17050. e[5]=(-a12 *a00+a02 *a10)*det;
  17051. e[6]=b21 *det;
  17052. e[7]=(-a21 *a00+a01 *a20)*det;
  17053. e[8]=(a11 *a00-a01 *a10)*det;
  17054. }
  17055. /**
  17056. *计算3x3矩阵的转置矩阵
  17057. *@param out 输出矩阵
  17058. */
  17059. __proto.transpose=function(out){
  17060. var e=out.elements;
  17061. var f=this.elements;
  17062. if (out===this){
  17063. var a01=f[1],a02=f[2],a12=f[5];
  17064. e[1]=f[3];
  17065. e[2]=f[6];
  17066. e[3]=a01;
  17067. e[5]=f[7];
  17068. e[6]=a02;
  17069. e[7]=a12;
  17070. }else {
  17071. e[0]=f[0];
  17072. e[1]=f[3];
  17073. e[2]=f[6];
  17074. e[3]=f[1];
  17075. e[4]=f[4];
  17076. e[5]=f[7];
  17077. e[6]=f[2];
  17078. e[7]=f[5];
  17079. e[8]=f[8];
  17080. }
  17081. }
  17082. /**设置已有的矩阵为单位矩阵*/
  17083. __proto.identity=function(){
  17084. var e=this.elements;
  17085. e[0]=1;
  17086. e[1]=0;
  17087. e[2]=0;
  17088. e[3]=0;
  17089. e[4]=1;
  17090. e[5]=0;
  17091. e[6]=0;
  17092. e[7]=0;
  17093. e[8]=1;
  17094. }
  17095. /**
  17096. *克隆。
  17097. *@param destObject 克隆源。
  17098. */
  17099. __proto.cloneTo=function(destObject){
  17100. var i,s,d;
  17101. s=this.elements;
  17102. d=destObject.elements;
  17103. if (s===d){
  17104. return;
  17105. }
  17106. for (i=0;i < 9;++i){
  17107. d[i]=s[i];
  17108. }
  17109. }
  17110. /**
  17111. *克隆。
  17112. *@return 克隆副本。
  17113. */
  17114. __proto.clone=function(){
  17115. var dest=/*__JS__ */new this.constructor();
  17116. this.cloneTo(dest);
  17117. return dest;
  17118. }
  17119. Matrix3x3.createFromTranslation=function(trans,out){
  17120. var e=out.elements;
  17121. out[0]=1;
  17122. out[1]=0;
  17123. out[2]=0;
  17124. out[3]=0;
  17125. out[4]=1;
  17126. out[5]=0;
  17127. out[6]=trans.x;
  17128. out[7]=trans.y;
  17129. out[8]=1;
  17130. }
  17131. Matrix3x3.createFromRotation=function(rad,out){
  17132. var e=out.elements;
  17133. var s=Math.sin(rad),c=Math.cos(rad);
  17134. e[0]=c;
  17135. e[1]=s;
  17136. e[2]=0;
  17137. e[3]=-s;
  17138. e[4]=c;
  17139. e[5]=0;
  17140. e[6]=0;
  17141. e[7]=0;
  17142. e[8]=1;
  17143. }
  17144. Matrix3x3.createFromScaling=function(scale,out){
  17145. var e=out.elements;
  17146. e[0]=scale.x;
  17147. e[1]=0;
  17148. e[2]=0;
  17149. e[3]=0;
  17150. e[4]=scale.y;
  17151. e[5]=0;
  17152. e[6]=0;
  17153. e[7]=0;
  17154. e[8]=1;
  17155. }
  17156. Matrix3x3.createFromMatrix4x4=function(sou,out){
  17157. out[0]=sou[0];
  17158. out[1]=sou[1];
  17159. out[2]=sou[2];
  17160. out[3]=sou[4];
  17161. out[4]=sou[5];
  17162. out[5]=sou[6];
  17163. out[6]=sou[8];
  17164. out[7]=sou[9];
  17165. out[8]=sou[10];
  17166. }
  17167. Matrix3x3.multiply=function(left,right,out){
  17168. var e=out.elements;
  17169. var f=left.elements;
  17170. var g=right.elements;
  17171. var a00=f[0],a01=f[1],a02=f[2];
  17172. var a10=f[3],a11=f[4],a12=f[5];
  17173. var a20=f[6],a21=f[7],a22=f[8];
  17174. var b00=g[0],b01=g[1],b02=g[2];
  17175. var b10=g[3],b11=g[4],b12=g[5];
  17176. var b20=g[6],b21=g[7],b22=g[8];
  17177. e[0]=b00 *a00+b01 *a10+b02 *a20;
  17178. e[1]=b00 *a01+b01 *a11+b02 *a21;
  17179. e[2]=b00 *a02+b01 *a12+b02 *a22;
  17180. e[3]=b10 *a00+b11 *a10+b12 *a20;
  17181. e[4]=b10 *a01+b11 *a11+b12 *a21;
  17182. e[5]=b10 *a02+b11 *a12+b12 *a22;
  17183. e[6]=b20 *a00+b21 *a10+b22 *a20;
  17184. e[7]=b20 *a01+b21 *a11+b22 *a21;
  17185. e[8]=b20 *a02+b21 *a12+b22 *a22;
  17186. }
  17187. Matrix3x3.lookAt=function(eye,target,up,out){
  17188. Vector3.subtract(eye,target,Matrix3x3._tempV30);
  17189. Vector3.normalize(Matrix3x3._tempV30,Matrix3x3._tempV30);
  17190. Vector3.cross(up,Matrix3x3._tempV30,Matrix3x3._tempV31);
  17191. Vector3.normalize(Matrix3x3._tempV31,Matrix3x3._tempV31);
  17192. Vector3.cross(Matrix3x3._tempV30,Matrix3x3._tempV31,Matrix3x3._tempV32);
  17193. var v0=Matrix3x3._tempV30;
  17194. var v1=Matrix3x3._tempV31;
  17195. var v2=Matrix3x3._tempV32;
  17196. var me=out.elements;
  17197. me[0]=v1.x;
  17198. me[3]=v1.y;
  17199. me[6]=v1.z;
  17200. me[1]=v2.x;
  17201. me[4]=v2.y;
  17202. me[7]=v2.z;
  17203. me[2]=v0.x;
  17204. me[5]=v0.y;
  17205. me[8]=v0.z;
  17206. }
  17207. Matrix3x3.DEFAULT=new Matrix3x3();
  17208. __static(Matrix3x3,
  17209. ['_tempV30',function(){return this._tempV30=new Vector3();},'_tempV31',function(){return this._tempV31=new Vector3();},'_tempV32',function(){return this._tempV32=new Vector3();}
  17210. ]);
  17211. return Matrix3x3;
  17212. })()
  17213. /**
  17214. *<code>Physics</code> 类用于简单物理检测。
  17215. */
  17216. //class laya.d3.utils.Physics3DUtils
  17217. var Physics3DUtils=(function(){
  17218. /**
  17219. *创建一个 <code>Physics</code> 实例。
  17220. */
  17221. function Physics3DUtils(){}
  17222. __class(Physics3DUtils,'laya.d3.utils.Physics3DUtils');
  17223. Physics3DUtils.setColliderCollision=function(collider1,collider2,collsion){}
  17224. Physics3DUtils.getIColliderCollision=function(collider1,collider2){
  17225. return false;
  17226. }
  17227. Physics3DUtils.COLLISIONFILTERGROUP_DEFAULTFILTER=0x1;
  17228. Physics3DUtils.COLLISIONFILTERGROUP_STATICFILTER=0x2;
  17229. Physics3DUtils.COLLISIONFILTERGROUP_KINEMATICFILTER=0x4;
  17230. Physics3DUtils.COLLISIONFILTERGROUP_DEBRISFILTER=0x8;
  17231. Physics3DUtils.COLLISIONFILTERGROUP_SENSORTRIGGER=0x10;
  17232. Physics3DUtils.COLLISIONFILTERGROUP_CHARACTERFILTER=0x20;
  17233. Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER1=0x40;
  17234. Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER2=0x80;
  17235. Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER3=0x100;
  17236. Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER4=0x200;
  17237. Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER5=0x400;
  17238. Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER6=0x800;
  17239. Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER7=0x1000;
  17240. Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER8=0x2000;
  17241. Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER9=0x4000;
  17242. Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER10=0x8000;
  17243. Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER=-1;
  17244. __static(Physics3DUtils,
  17245. ['gravity',function(){return this.gravity=new Vector3(0,-9.81,0);}
  17246. ]);
  17247. return Physics3DUtils;
  17248. })()
  17249. /**
  17250. *<code>BoundBox</code> 类用于创建包围盒。
  17251. */
  17252. //class laya.d3.math.BoundBox
  17253. var BoundBox=(function(){
  17254. function BoundBox(min,max){
  17255. /**最小顶点。*/
  17256. this.min=null;
  17257. /**最大顶点。*/
  17258. this.max=null;
  17259. this.min=min;
  17260. this.max=max;
  17261. }
  17262. __class(BoundBox,'laya.d3.math.BoundBox');
  17263. var __proto=BoundBox.prototype;
  17264. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  17265. /**
  17266. *@private
  17267. */
  17268. __proto._rotateExtents=function(extents,rotation,out){
  17269. var extentsX=extents.x;
  17270. var extentsY=extents.y;
  17271. var extentsZ=extents.z;
  17272. var matElements=rotation.elements;
  17273. out.x=Math.abs(matElements[0] *extentsX)+Math.abs(matElements[4] *extentsY)+Math.abs(matElements[8] *extentsZ);
  17274. out.y=Math.abs(matElements[1] *extentsX)+Math.abs(matElements[5] *extentsY)+Math.abs(matElements[9] *extentsZ);
  17275. out.z=Math.abs(matElements[2] *extentsX)+Math.abs(matElements[6] *extentsY)+Math.abs(matElements[10] *extentsZ);
  17276. }
  17277. /**
  17278. *获取包围盒的8个角顶点。
  17279. *@param corners 返回顶点的输出队列。
  17280. */
  17281. __proto.getCorners=function(corners){
  17282. corners.length=8;
  17283. var minX=this.min.x;
  17284. var minY=this.min.y;
  17285. var minZ=this.min.z;
  17286. var maxX=this.max.x;
  17287. var maxY=this.max.y;
  17288. var maxZ=this.max.z;
  17289. corners[0]=new Vector3(minX,maxY,maxZ);
  17290. corners[1]=new Vector3(maxX,maxY,maxZ);
  17291. corners[2]=new Vector3(maxX,minY,maxZ);
  17292. corners[3]=new Vector3(minX,minY,maxZ);
  17293. corners[4]=new Vector3(minX,maxY,minZ);
  17294. corners[5]=new Vector3(maxX,maxY,minZ);
  17295. corners[6]=new Vector3(maxX,minY,minZ);
  17296. corners[7]=new Vector3(minX,minY,minZ);
  17297. }
  17298. /**
  17299. *获取中心点。
  17300. *@param out
  17301. */
  17302. __proto.getCenter=function(out){
  17303. Vector3.add(this.min,this.max,out);
  17304. Vector3.scale(out,0.5,out);
  17305. }
  17306. /**
  17307. *获取范围。
  17308. *@param out
  17309. */
  17310. __proto.getExtent=function(out){
  17311. Vector3.subtract(this.max,this.min,out);
  17312. Vector3.scale(out,0.5,out);
  17313. }
  17314. /**
  17315. *设置中心点和范围。
  17316. *@param center
  17317. */
  17318. __proto.setCenterAndExtent=function(center,extent){
  17319. Vector3.subtract(center,extent,this.min);
  17320. Vector3.add(center,extent,this.max);
  17321. }
  17322. /**
  17323. *@private
  17324. */
  17325. __proto.tranform=function(matrix,out){
  17326. var center=BoundBox._tempVector30;
  17327. var extent=BoundBox._tempVector31;
  17328. this.getCenter(center);
  17329. this.getExtent(extent);
  17330. Vector3.transformCoordinate(center,matrix,center);
  17331. this._rotateExtents(extent,matrix,extent);
  17332. out.setCenterAndExtent(center,extent);
  17333. }
  17334. __proto.toDefault=function(){
  17335. this.min.toDefault();
  17336. this.max.toDefault();
  17337. }
  17338. /**
  17339. *克隆。
  17340. *@param destObject 克隆源。
  17341. */
  17342. __proto.cloneTo=function(destObject){
  17343. var dest=destObject;
  17344. this.min.cloneTo(dest.min);
  17345. this.max.cloneTo(dest.max);
  17346. }
  17347. /**
  17348. *克隆。
  17349. *@return 克隆副本。
  17350. */
  17351. __proto.clone=function(){
  17352. var dest=/*__JS__ */new this.constructor(new Vector3(),new Vector3());
  17353. this.cloneTo(dest);
  17354. return dest;
  17355. }
  17356. BoundBox.createfromPoints=function(points,out){
  17357. if (points==null)
  17358. throw new Error("points");
  17359. var min=out.min;
  17360. var max=out.max;
  17361. min.x=Number.MAX_VALUE;
  17362. min.y=Number.MAX_VALUE;
  17363. min.z=Number.MAX_VALUE;
  17364. max.x=-Number.MAX_VALUE;
  17365. max.y=-Number.MAX_VALUE;
  17366. max.z=-Number.MAX_VALUE;
  17367. for (var i=0,n=points.length;i < n;++i){
  17368. Vector3.min(min,points[i],min);
  17369. Vector3.max(max,points[i],max);
  17370. }
  17371. }
  17372. BoundBox.merge=function(box1,box2,out){
  17373. Vector3.min(box1.min,box2.min,out.min);
  17374. Vector3.max(box1.max,box2.max,out.max);
  17375. }
  17376. __static(BoundBox,
  17377. ['_tempVector30',function(){return this._tempVector30=new Vector3();},'_tempVector31',function(){return this._tempVector31=new Vector3();}
  17378. ]);
  17379. return BoundBox;
  17380. })()
  17381. /**
  17382. *<code>AnimatorState</code> 类用于创建动作状态。
  17383. */
  17384. //class laya.d3.component.AnimatorState
  17385. var AnimatorState=(function(){
  17386. function AnimatorState(){
  17387. /**@private */
  17388. //this._clip=null;
  17389. /**@private */
  17390. //this._currentFrameIndices=null;
  17391. /**@private */
  17392. //this._scripts=null;
  17393. /**名称。*/
  17394. //this.name=null;
  17395. /**动画播放速度,1.0为正常播放速度。*/
  17396. this.speed=1.0;
  17397. /**动作播放起始时间。*/
  17398. this.clipStart=0.0;
  17399. /**动作播放结束时间。*/
  17400. this.clipEnd=1.0;
  17401. this._nodeOwners=[];
  17402. }
  17403. __class(AnimatorState,'laya.d3.component.AnimatorState');
  17404. var __proto=AnimatorState.prototype;
  17405. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  17406. /**
  17407. *@private
  17408. */
  17409. __proto._resetFrameIndices=function(){
  17410. for (var i=0,n=this._currentFrameIndices.length;i < n;i++)
  17411. this._currentFrameIndices[i]=-1;
  17412. }
  17413. /**
  17414. *添加脚本。
  17415. *@param type 组件类型。
  17416. *@return 脚本。
  17417. *
  17418. */
  17419. __proto.addScript=function(type){
  17420. var script=new type();
  17421. this._scripts=this._scripts || [];
  17422. this._scripts.push(script);
  17423. return script;
  17424. }
  17425. /**
  17426. *获取脚本。
  17427. *@param type 组件类型。
  17428. *@return 脚本。
  17429. *
  17430. */
  17431. __proto.getScript=function(type){
  17432. if (this._scripts){
  17433. for (var i=0,n=this._scripts.length;i < n;i++){
  17434. var script=this._scripts[i];
  17435. if (Laya.__typeof(script,type))
  17436. return script;
  17437. }
  17438. }
  17439. return null;
  17440. }
  17441. /**
  17442. *获取脚本集合。
  17443. *@param type 组件类型。
  17444. *@return 脚本集合。
  17445. *
  17446. */
  17447. __proto.getScripts=function(type){
  17448. var coms;
  17449. if (this._scripts){
  17450. for (var i=0,n=this._scripts.length;i < n;i++){
  17451. var script=this._scripts[i];
  17452. if (Laya.__typeof(script,type)){
  17453. coms=coms ||[];
  17454. coms.push(script);
  17455. }
  17456. }
  17457. }
  17458. return coms;
  17459. }
  17460. /**
  17461. *克隆。
  17462. *@param destObject 克隆源。
  17463. */
  17464. __proto.cloneTo=function(destObject){
  17465. var dest=destObject;
  17466. dest.name=this.name;
  17467. dest.speed=this.speed;
  17468. dest.clipStart=this.clipStart;
  17469. dest.clipEnd=this.clipEnd;
  17470. dest.clip=this._clip;
  17471. }
  17472. /**
  17473. *克隆。
  17474. *@return 克隆副本。
  17475. */
  17476. __proto.clone=function(){
  17477. var dest=/*__JS__ */new this.constructor();
  17478. this.cloneTo(dest);
  17479. return dest;
  17480. }
  17481. /**
  17482. *设置动作。
  17483. *@param value 动作。
  17484. */
  17485. /**
  17486. *获取动作。
  17487. *@return 动作
  17488. */
  17489. __getset(0,__proto,'clip',function(){
  17490. return this._clip;
  17491. },function(value){
  17492. this._clip=value;
  17493. this._currentFrameIndices=new Int16Array(value._nodes.count);
  17494. this._resetFrameIndices();
  17495. });
  17496. return AnimatorState;
  17497. })()
  17498. /**
  17499. *<code>TextMesh</code> 类用于创建文本网格。
  17500. */
  17501. //class laya.d3.text.TextMesh
  17502. var TextMesh=(function(){
  17503. function TextMesh(){
  17504. /**@private */
  17505. this._vertices=null;
  17506. /**@private */
  17507. this._vertexBuffer=null;
  17508. /**@private */
  17509. this._text=null;
  17510. /**@private */
  17511. this._fontSize=0;
  17512. /**@private */
  17513. this._color=null;
  17514. }
  17515. __class(TextMesh,'laya.d3.text.TextMesh');
  17516. var __proto=TextMesh.prototype;
  17517. /**
  17518. *@private
  17519. */
  17520. __proto._createVertexBuffer=function(charCount){}
  17521. /**
  17522. *@private
  17523. */
  17524. __proto._resizeVertexBuffer=function(charCount){}
  17525. /**
  17526. *@private
  17527. */
  17528. __proto._addChar=function(){}
  17529. /**
  17530. *设置文本。
  17531. *@param value 文本。
  17532. */
  17533. /**
  17534. *获取文本。
  17535. *@return 文本。
  17536. */
  17537. __getset(0,__proto,'text',function(){
  17538. return this._text;
  17539. },function(value){
  17540. this._text=value;
  17541. });
  17542. /**
  17543. *设置字体储存。
  17544. *@return 字体尺寸。
  17545. */
  17546. /**
  17547. *获取字体尺寸。
  17548. *@param value 字体尺寸。
  17549. */
  17550. __getset(0,__proto,'fontSize',function(){
  17551. return this._fontSize;
  17552. },function(value){
  17553. this._fontSize=value;
  17554. });
  17555. /**
  17556. *设置颜色。
  17557. *@param 颜色。
  17558. */
  17559. /**
  17560. *获取颜色。
  17561. *@return 颜色。
  17562. */
  17563. __getset(0,__proto,'color',function(){
  17564. return this._color;
  17565. },function(value){
  17566. this._color=value;
  17567. });
  17568. TextMesh._indexBuffer=null;
  17569. return TextMesh;
  17570. })()
  17571. /**
  17572. *<code>Matrix4x4</code> 类用于创建4x4矩阵。
  17573. */
  17574. //class laya.d3.math.Matrix4x4
  17575. var Matrix4x4=(function(){
  17576. function Matrix4x4(m11,m12,m13,m14,m21,m22,m23,m24,m31,m32,m33,m34,m41,m42,m43,m44,elements){
  17577. /**矩阵元素数组*/
  17578. //this.elements=null;
  17579. (m11===void 0)&& (m11=1);
  17580. (m12===void 0)&& (m12=0);
  17581. (m13===void 0)&& (m13=0);
  17582. (m14===void 0)&& (m14=0);
  17583. (m21===void 0)&& (m21=0);
  17584. (m22===void 0)&& (m22=1);
  17585. (m23===void 0)&& (m23=0);
  17586. (m24===void 0)&& (m24=0);
  17587. (m31===void 0)&& (m31=0);
  17588. (m32===void 0)&& (m32=0);
  17589. (m33===void 0)&& (m33=1);
  17590. (m34===void 0)&& (m34=0);
  17591. (m41===void 0)&& (m41=0);
  17592. (m42===void 0)&& (m42=0);
  17593. (m43===void 0)&& (m43=0);
  17594. (m44===void 0)&& (m44=1);
  17595. var e=elements ? this.elements=elements :this.elements=new Float32Array(16);
  17596. e[0]=m11;
  17597. e[1]=m12;
  17598. e[2]=m13;
  17599. e[3]=m14;
  17600. e[4]=m21;
  17601. e[5]=m22;
  17602. e[6]=m23;
  17603. e[7]=m24;
  17604. e[8]=m31;
  17605. e[9]=m32;
  17606. e[10]=m33;
  17607. e[11]=m34;
  17608. e[12]=m41;
  17609. e[13]=m42;
  17610. e[14]=m43;
  17611. e[15]=m44;
  17612. }
  17613. __class(Matrix4x4,'laya.d3.math.Matrix4x4');
  17614. var __proto=Matrix4x4.prototype;
  17615. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  17616. __proto.setRotation=function(rotation){
  17617. var rotationX=rotation.x;
  17618. var rotationY=rotation.y;
  17619. var rotationZ=rotation.z;
  17620. var rotationW=rotation.w;
  17621. var xx=rotationX *rotationX;
  17622. var yy=rotationY *rotationY;
  17623. var zz=rotationZ *rotationZ;
  17624. var xy=rotationX *rotationY;
  17625. var zw=rotationZ *rotationW;
  17626. var zx=rotationZ *rotationX;
  17627. var yw=rotationY *rotationW;
  17628. var yz=rotationY *rotationZ;
  17629. var xw=rotationX *rotationW;
  17630. var e=this.elements;
  17631. e[0]=1.0-(2.0 *(yy+zz));
  17632. e[1]=2.0 *(xy+zw);
  17633. e[2]=2.0 *(zx-yw);
  17634. e[4]=2.0 *(xy-zw);
  17635. e[5]=1.0-(2.0 *(zz+xx));
  17636. e[6]=2.0 *(yz+xw);
  17637. e[8]=2.0 *(zx+yw);
  17638. e[9]=2.0 *(yz-xw);
  17639. e[10]=1.0-(2.0 *(yy+xx));
  17640. }
  17641. __proto.setPosition=function(position){
  17642. var e=this.elements;
  17643. e[12]=position.x;
  17644. e[13]=position.y;
  17645. e[14]=position.z;
  17646. }
  17647. __proto.getElementByRowColumn=function(row,column){
  17648. if (row < 0 || row > 3)
  17649. throw new Error("row","Rows and columns for matrices run from 0 to 3, inclusive.");
  17650. if (column < 0 || column > 3)
  17651. throw new Error("column","Rows and columns for matrices run from 0 to 3, inclusive.");
  17652. return this.elements[(row *4)+column];
  17653. }
  17654. __proto.setElementByRowColumn=function(row,column,value){
  17655. if (row < 0 || row > 3)
  17656. throw new Error("row","Rows and columns for matrices run from 0 to 3, inclusive.");
  17657. if (column < 0 || column > 3)
  17658. throw new Error("column","Rows and columns for matrices run from 0 to 3, inclusive.");
  17659. this.elements[(row *4)+column]=value;
  17660. }
  17661. /**
  17662. *判断两个4x4矩阵的值是否相等。
  17663. *@param other 4x4矩阵
  17664. */
  17665. __proto.equalsOtherMatrix=function(other){
  17666. var e=this.elements;
  17667. var oe=other.elements;
  17668. return (MathUtils3D.nearEqual(e[0],oe[0])&& MathUtils3D.nearEqual(e[1],oe[1])&& MathUtils3D.nearEqual(e[2],oe[2])&& MathUtils3D.nearEqual(e[3],oe[3])&& MathUtils3D.nearEqual(e[4],oe[4])&& MathUtils3D.nearEqual(e[5],oe[5])&& MathUtils3D.nearEqual(e[6],oe[6])&& MathUtils3D.nearEqual(e[7],oe[7])&& MathUtils3D.nearEqual(e[8],oe[8])&& MathUtils3D.nearEqual(e[9],oe[9])&& MathUtils3D.nearEqual(e[10],oe[10])&& MathUtils3D.nearEqual(e[11],oe[11])&& MathUtils3D.nearEqual(e[12],oe[12])&& MathUtils3D.nearEqual(e[13],oe[13])&& MathUtils3D.nearEqual(e[14],oe[14])&& MathUtils3D.nearEqual(e[15],oe[15]));
  17669. }
  17670. /**
  17671. *分解矩阵为平移向量、旋转四元数、缩放向量。
  17672. *@param translation 平移向量。
  17673. *@param rotation 旋转四元数。
  17674. *@param scale 缩放向量。
  17675. *@return 是否分解成功。
  17676. */
  17677. __proto.decomposeTransRotScale=function(translation,rotation,scale){
  17678. var rotationMatrix=Matrix4x4._tempMatrix4x4;
  17679. if (this.decomposeTransRotMatScale(translation,rotationMatrix,scale)){
  17680. Quaternion.createFromMatrix4x4(rotationMatrix,rotation);
  17681. return true;
  17682. }else {
  17683. rotation.identity();
  17684. return false;
  17685. }
  17686. }
  17687. /**
  17688. *分解矩阵为平移向量、旋转矩阵、缩放向量。
  17689. *@param translation 平移向量。
  17690. *@param rotationMatrix 旋转矩阵。
  17691. *@param scale 缩放向量。
  17692. *@return 是否分解成功。
  17693. */
  17694. __proto.decomposeTransRotMatScale=function(translation,rotationMatrix,scale){
  17695. var e=this.elements;
  17696. var te=translation;
  17697. var re=rotationMatrix.elements;
  17698. var se=scale;
  17699. te.x=e[12];
  17700. te.y=e[13];
  17701. te.z=e[14];
  17702. var m11=e[0],m12=e[1],m13=e[2];
  17703. var m21=e[4],m22=e[5],m23=e[6];
  17704. var m31=e[8],m32=e[9],m33=e[10];
  17705. var sX=se.x=Math.sqrt((m11 *m11)+(m12 *m12)+(m13 *m13));
  17706. var sY=se.y=Math.sqrt((m21 *m21)+(m22 *m22)+(m23 *m23));
  17707. var sZ=se.z=Math.sqrt((m31 *m31)+(m32 *m32)+(m33 *m33));
  17708. if (MathUtils3D.isZero(sX)|| MathUtils3D.isZero(sY)|| MathUtils3D.isZero(sZ)){
  17709. re[1]=re[2]=re[3]=re[4]=re[6]=re[7]=re[8]=re[9]=re[11]=re[12]=re[13]=re[14]=0;
  17710. re[0]=re[5]=re[10]=re[15]=1;
  17711. return false;
  17712. };
  17713. var at=Matrix4x4._tempVector0;
  17714. at.x=m31 / sZ;
  17715. at.y=m32 / sZ;
  17716. at.z=m33 / sZ;
  17717. var tempRight=Matrix4x4._tempVector1;
  17718. tempRight.x=m11 / sX;
  17719. tempRight.y=m12 / sX;
  17720. tempRight.z=m13 / sX;
  17721. var up=Matrix4x4._tempVector2;
  17722. Vector3.cross(at,tempRight,up);
  17723. var right=Matrix4x4._tempVector1;
  17724. Vector3.cross(up,at,right);
  17725. re[3]=re[7]=re[11]=re[12]=re[13]=re[14]=0;
  17726. re[15]=1;
  17727. re[0]=right.x;
  17728. re[1]=right.y;
  17729. re[2]=right.z;
  17730. re[4]=up.x;
  17731. re[5]=up.y;
  17732. re[6]=up.z;
  17733. re[8]=at.x;
  17734. re[9]=at.y;
  17735. re[10]=at.z;
  17736. ((re[0] *m11+re[1] *m12+re[2] *m13)< 0.0)&& (se[0]=-sX);
  17737. ((re[4] *m21+re[5] *m22+re[6] *m23)< 0.0)&& (se[1]=-sY);
  17738. ((re[8] *m31+re[9] *m32+re[10] *m33)< 0.0)&& (se[2]=-sZ);
  17739. return true;
  17740. }
  17741. /**
  17742. *分解旋转矩阵的旋转为YawPitchRoll欧拉角。
  17743. *@param out float yaw
  17744. *@param out float pitch
  17745. *@param out float roll
  17746. *@return
  17747. */
  17748. __proto.decomposeYawPitchRoll=function(yawPitchRoll){
  17749. var pitch=Math.asin(-this.elements[9]);
  17750. yawPitchRoll.y=pitch;
  17751. var test=Math.cos(pitch);
  17752. if (test > MathUtils3D.zeroTolerance){
  17753. yawPitchRoll.z=Math.atan2(this.elements[1],this.elements[5]);
  17754. yawPitchRoll.x=Math.atan2(this.elements[8],this.elements[10]);
  17755. }else {
  17756. yawPitchRoll.z=Math.atan2(-this.elements[4],this.elements[0]);
  17757. yawPitchRoll.x=0.0;
  17758. }
  17759. }
  17760. /**归一化矩阵 */
  17761. __proto.normalize=function(){
  17762. var v=this.elements;
  17763. var c=v[0],d=v[1],e=v[2],g=Math.sqrt(c *c+d *d+e *e);
  17764. if (g){
  17765. if (g==1)
  17766. return;
  17767. }else {
  17768. v[0]=0;
  17769. v[1]=0;
  17770. v[2]=0;
  17771. return;
  17772. }
  17773. g=1 / g;
  17774. v[0]=c *g;
  17775. v[1]=d *g;
  17776. v[2]=e *g;
  17777. }
  17778. /**计算矩阵的转置矩阵*/
  17779. __proto.transpose=function(){
  17780. var e,t;
  17781. e=this.elements;
  17782. t=e[1];
  17783. e[1]=e[4];
  17784. e[4]=t;
  17785. t=e[2];
  17786. e[2]=e[8];
  17787. e[8]=t;
  17788. t=e[3];
  17789. e[3]=e[12];
  17790. e[12]=t;
  17791. t=e[6];
  17792. e[6]=e[9];
  17793. e[9]=t;
  17794. t=e[7];
  17795. e[7]=e[13];
  17796. e[13]=t;
  17797. t=e[11];
  17798. e[11]=e[14];
  17799. e[14]=t;
  17800. return this;
  17801. }
  17802. /**
  17803. *计算一个矩阵的逆矩阵
  17804. *@param out 输出矩阵
  17805. */
  17806. __proto.invert=function(out){
  17807. var ae=this.elements;
  17808. var oe=out.elements;
  17809. var a00=ae[0],a01=ae[1],a02=ae[2],a03=ae[3],a10=ae[4],a11=ae[5],a12=ae[6],a13=ae[7],a20=ae[8],a21=ae[9],a22=ae[10],a23=ae[11],a30=ae[12],a31=ae[13],a32=ae[14],a33=ae[15],
  17810. b00=a00 *a11-a01 *a10,b01=a00 *a12-a02 *a10,b02=a00 *a13-a03 *a10,b03=a01 *a12-a02 *a11,b04=a01 *a13-a03 *a11,b05=a02 *a13-a03 *a12,b06=a20 *a31-a21 *a30,b07=a20 *a32-a22 *a30,b08=a20 *a33-a23 *a30,b09=a21 *a32-a22 *a31,b10=a21 *a33-a23 *a31,b11=a22 *a33-a23 *a32,
  17811. det=b00 *b11-b01 *b10+b02 *b09+b03 *b08-b04 *b07+b05 *b06;
  17812. if (Math.abs(det)===0.0){
  17813. return;
  17814. }
  17815. det=1.0 / det;
  17816. oe[0]=(a11 *b11-a12 *b10+a13 *b09)*det;
  17817. oe[1]=(a02 *b10-a01 *b11-a03 *b09)*det;
  17818. oe[2]=(a31 *b05-a32 *b04+a33 *b03)*det;
  17819. oe[3]=(a22 *b04-a21 *b05-a23 *b03)*det;
  17820. oe[4]=(a12 *b08-a10 *b11-a13 *b07)*det;
  17821. oe[5]=(a00 *b11-a02 *b08+a03 *b07)*det;
  17822. oe[6]=(a32 *b02-a30 *b05-a33 *b01)*det;
  17823. oe[7]=(a20 *b05-a22 *b02+a23 *b01)*det;
  17824. oe[8]=(a10 *b10-a11 *b08+a13 *b06)*det;
  17825. oe[9]=(a01 *b08-a00 *b10-a03 *b06)*det;
  17826. oe[10]=(a30 *b04-a31 *b02+a33 *b00)*det;
  17827. oe[11]=(a21 *b02-a20 *b04-a23 *b00)*det;
  17828. oe[12]=(a11 *b07-a10 *b09-a12 *b06)*det;
  17829. oe[13]=(a00 *b09-a01 *b07+a02 *b06)*det;
  17830. oe[14]=(a31 *b01-a30 *b03-a32 *b00)*det;
  17831. oe[15]=(a20 *b03-a21 *b01+a22 *b00)*det;
  17832. }
  17833. /**设置矩阵为单位矩阵*/
  17834. __proto.identity=function(){
  17835. var e=this.elements;
  17836. e[1]=e[2]=e[3]=e[4]=e[6]=e[7]=e[8]=e[9]=e[11]=e[12]=e[13]=e[14]=0;
  17837. e[0]=e[5]=e[10]=e[15]=1;
  17838. }
  17839. /**
  17840. *克隆。
  17841. *@param destObject 克隆源。
  17842. */
  17843. __proto.cloneTo=function(destObject){
  17844. var i,s,d;
  17845. s=this.elements;
  17846. d=destObject.elements;
  17847. if (s===d){
  17848. return;
  17849. }
  17850. for (i=0;i < 16;++i){
  17851. d[i]=s[i];
  17852. }
  17853. }
  17854. /**
  17855. *克隆。
  17856. *@return 克隆副本。
  17857. */
  17858. __proto.clone=function(){
  17859. var dest=/*__JS__ */new this.constructor();
  17860. this.cloneTo(dest);
  17861. return dest;
  17862. }
  17863. /**
  17864. *获取平移向量。
  17865. *@param out 平移向量。
  17866. */
  17867. __proto.getTranslationVector=function(out){
  17868. var me=this.elements;
  17869. out.x=me[12];
  17870. out.y=me[13];
  17871. out.z=me[14];
  17872. }
  17873. /**
  17874. *设置平移向量。
  17875. *@param translate 平移向量。
  17876. */
  17877. __proto.setTranslationVector=function(translate){
  17878. var me=this.elements;
  17879. var ve=translate;
  17880. me[12]=ve.x;
  17881. me[13]=ve.y;
  17882. me[14]=ve.z;
  17883. }
  17884. /**
  17885. *获取前向量。
  17886. *@param out 前向量。
  17887. */
  17888. __proto.getForward=function(out){
  17889. var me=this.elements;
  17890. out.x=-me[8];
  17891. out.y=-me[9];
  17892. out.z=-me[10];
  17893. }
  17894. /**
  17895. *设置前向量。
  17896. *@param forward 前向量。
  17897. */
  17898. __proto.setForward=function(forward){
  17899. var me=this.elements;
  17900. me[8]=-forward.x;
  17901. me[9]=-forward.y;
  17902. me[10]=-forward.z;
  17903. }
  17904. Matrix4x4.createRotationX=function(rad,out){
  17905. var oe=out.elements;
  17906. var s=Math.sin(rad),c=Math.cos(rad);
  17907. oe[1]=oe[2]=oe[3]=oe[4]=oe[7]=oe[8]=oe[11]=oe[12]=oe[13]=oe[14]=0;
  17908. oe[0]=oe[15]=1;
  17909. oe[5]=oe[10]=c;
  17910. oe[6]=s;
  17911. oe[9]=-s;
  17912. }
  17913. Matrix4x4.createRotationY=function(rad,out){
  17914. var oe=out.elements;
  17915. var s=Math.sin(rad),c=Math.cos(rad);
  17916. oe[1]=oe[3]=oe[4]=oe[6]=oe[7]=oe[9]=oe[11]=oe[12]=oe[13]=oe[14]=0;
  17917. oe[5]=oe[15]=1;
  17918. oe[0]=oe[10]=c;
  17919. oe[2]=-s;
  17920. oe[8]=s;
  17921. }
  17922. Matrix4x4.createRotationZ=function(rad,out){
  17923. var oe=out.elements;
  17924. var s=Math.sin(rad),c=Math.cos(rad);
  17925. oe[2]=oe[3]=oe[6]=oe[7]=oe[8]=oe[9]=oe[11]=oe[12]=oe[13]=oe[14]=0;
  17926. oe[10]=oe[15]=1;
  17927. oe[0]=oe[5]=c;
  17928. oe[1]=s;
  17929. oe[4]=-s;
  17930. }
  17931. Matrix4x4.createRotationYawPitchRoll=function(yaw,pitch,roll,result){
  17932. Quaternion.createFromYawPitchRoll(yaw,pitch,roll,Matrix4x4._tempQuaternion);
  17933. Matrix4x4.createRotationQuaternion(Matrix4x4._tempQuaternion,result);
  17934. }
  17935. Matrix4x4.createRotationAxis=function(axis,angle,result){
  17936. var x=axis.x;
  17937. var y=axis.y;
  17938. var z=axis.z;
  17939. var cos=Math.cos(angle);
  17940. var sin=Math.sin(angle);
  17941. var xx=x *x;
  17942. var yy=y *y;
  17943. var zz=z *z;
  17944. var xy=x *y;
  17945. var xz=x *z;
  17946. var yz=y *z;
  17947. var resultE=result.elements;
  17948. resultE[3]=resultE[7]=resultE[11]=resultE[12]=resultE[13]=resultE[14]=0;
  17949. resultE[15]=1.0;
  17950. resultE[0]=xx+(cos *(1.0-xx));
  17951. resultE[1]=(xy-(cos *xy))+(sin *z);
  17952. resultE[2]=(xz-(cos *xz))-(sin *y);
  17953. resultE[4]=(xy-(cos *xy))-(sin *z);
  17954. resultE[5]=yy+(cos *(1.0-yy));
  17955. resultE[6]=(yz-(cos *yz))+(sin *x);
  17956. resultE[8]=(xz-(cos *xz))+(sin *y);
  17957. resultE[9]=(yz-(cos *yz))-(sin *x);
  17958. resultE[10]=zz+(cos *(1.0-zz));
  17959. }
  17960. Matrix4x4.createRotationQuaternion=function(rotation,result){
  17961. var resultE=result.elements;
  17962. var rotationX=rotation.x;
  17963. var rotationY=rotation.y;
  17964. var rotationZ=rotation.z;
  17965. var rotationW=rotation.w;
  17966. var xx=rotationX *rotationX;
  17967. var yy=rotationY *rotationY;
  17968. var zz=rotationZ *rotationZ;
  17969. var xy=rotationX *rotationY;
  17970. var zw=rotationZ *rotationW;
  17971. var zx=rotationZ *rotationX;
  17972. var yw=rotationY *rotationW;
  17973. var yz=rotationY *rotationZ;
  17974. var xw=rotationX *rotationW;
  17975. resultE[3]=resultE[7]=resultE[11]=resultE[12]=resultE[13]=resultE[14]=0;
  17976. resultE[15]=1.0;
  17977. resultE[0]=1.0-(2.0 *(yy+zz));
  17978. resultE[1]=2.0 *(xy+zw);
  17979. resultE[2]=2.0 *(zx-yw);
  17980. resultE[4]=2.0 *(xy-zw);
  17981. resultE[5]=1.0-(2.0 *(zz+xx));
  17982. resultE[6]=2.0 *(yz+xw);
  17983. resultE[8]=2.0 *(zx+yw);
  17984. resultE[9]=2.0 *(yz-xw);
  17985. resultE[10]=1.0-(2.0 *(yy+xx));
  17986. }
  17987. Matrix4x4.createTranslate=function(trans,out){
  17988. var oe=out.elements;
  17989. oe[4]=oe[8]=oe[1]=oe[9]=oe[2]=oe[6]=oe[3]=oe[7]=oe[11]=0;
  17990. oe[0]=oe[5]=oe[10]=oe[15]=1;
  17991. oe[12]=trans.x;
  17992. oe[13]=trans.y;
  17993. oe[14]=trans.z;
  17994. }
  17995. Matrix4x4.createScaling=function(scale,out){
  17996. var oe=out.elements;
  17997. oe[0]=scale.x;
  17998. oe[5]=scale.y;
  17999. oe[10]=scale.z;
  18000. oe[1]=oe[4]=oe[8]=oe[12]=oe[9]=oe[13]=oe[2]=oe[6]=oe[14]=oe[3]=oe[7]=oe[11]=0;
  18001. oe[15]=1;
  18002. }
  18003. Matrix4x4.multiply=function(left,right,out){
  18004. var i,e,a,b,ai0,ai1,ai2,ai3;
  18005. e=out.elements;
  18006. a=left.elements;
  18007. b=right.elements;
  18008. if (e===b){
  18009. b=new Float32Array(16);
  18010. for (i=0;i < 16;++i){
  18011. b[i]=e[i];
  18012. }
  18013. };
  18014. var b0=b[0],b1=b[1],b2=b[2],b3=b[3];
  18015. var b4=b[4],b5=b[5],b6=b[6],b7=b[7];
  18016. var b8=b[8],b9=b[9],b10=b[10],b11=b[11];
  18017. var b12=b[12],b13=b[13],b14=b[14],b15=b[15];
  18018. for (i=0;i < 4;i++){
  18019. ai0=a[i];
  18020. ai1=a[i+4];
  18021. ai2=a[i+8];
  18022. ai3=a[i+12];
  18023. e[i]=ai0 *b0+ai1 *b1+ai2 *b2+ai3 *b3;
  18024. e[i+4]=ai0 *b4+ai1 *b5+ai2 *b6+ai3 *b7;
  18025. e[i+8]=ai0 *b8+ai1 *b9+ai2 *b10+ai3 *b11;
  18026. e[i+12]=ai0 *b12+ai1 *b13+ai2 *b14+ai3 *b15;
  18027. }
  18028. }
  18029. Matrix4x4.multiplyForNative=function(left,right,out){
  18030. LayaGL.instance.matrix4x4Multiply(left.elements,right.elements,out.elements);
  18031. }
  18032. Matrix4x4.createFromQuaternion=function(rotation,out){
  18033. var e=out.elements;
  18034. var x=rotation.x,y=rotation.y,z=rotation.z,w=rotation.w;
  18035. var x2=x+x;
  18036. var y2=y+y;
  18037. var z2=z+z;
  18038. var xx=x *x2;
  18039. var yx=y *x2;
  18040. var yy=y *y2;
  18041. var zx=z *x2;
  18042. var zy=z *y2;
  18043. var zz=z *z2;
  18044. var wx=w *x2;
  18045. var wy=w *y2;
  18046. var wz=w *z2;
  18047. e[0]=1-yy-zz;
  18048. e[1]=yx+wz;
  18049. e[2]=zx-wy;
  18050. e[3]=0;
  18051. e[4]=yx-wz;
  18052. e[5]=1-xx-zz;
  18053. e[6]=zy+wx;
  18054. e[7]=0;
  18055. e[8]=zx+wy;
  18056. e[9]=zy-wx;
  18057. e[10]=1-xx-yy;
  18058. e[11]=0;
  18059. e[12]=0;
  18060. e[13]=0;
  18061. e[14]=0;
  18062. e[15]=1;
  18063. }
  18064. Matrix4x4.createAffineTransformation=function(trans,rot,scale,out){
  18065. var oe=out.elements;
  18066. var x=rot.x,y=rot.y,z=rot.z,w=rot.w,x2=x+x,y2=y+y,z2=z+z;
  18067. var xx=x *x2,xy=x *y2,xz=x *z2,yy=y *y2,yz=y *z2,zz=z *z2;
  18068. var wx=w *x2,wy=w *y2,wz=w *z2,sx=scale.x,sy=scale.y,sz=scale.z;
  18069. oe[0]=(1-(yy+zz))*sx;
  18070. oe[1]=(xy+wz)*sx;
  18071. oe[2]=(xz-wy)*sx;
  18072. oe[3]=0;
  18073. oe[4]=(xy-wz)*sy;
  18074. oe[5]=(1-(xx+zz))*sy;
  18075. oe[6]=(yz+wx)*sy;
  18076. oe[7]=0;
  18077. oe[8]=(xz+wy)*sz;
  18078. oe[9]=(yz-wx)*sz;
  18079. oe[10]=(1-(xx+yy))*sz;
  18080. oe[11]=0;
  18081. oe[12]=trans.x;
  18082. oe[13]=trans.y;
  18083. oe[14]=trans.z;
  18084. oe[15]=1;
  18085. }
  18086. Matrix4x4.createLookAt=function(eye,target,up,out){
  18087. var oE=out.elements;
  18088. var xaxis=Matrix4x4._tempVector0;
  18089. var yaxis=Matrix4x4._tempVector1;
  18090. var zaxis=Matrix4x4._tempVector2;
  18091. Vector3.subtract(eye,target,zaxis);
  18092. Vector3.normalize(zaxis,zaxis);
  18093. Vector3.cross(up,zaxis,xaxis);
  18094. Vector3.normalize(xaxis,xaxis);
  18095. Vector3.cross(zaxis,xaxis,yaxis);
  18096. out.identity();
  18097. oE[0]=xaxis.x;
  18098. oE[4]=xaxis.y;
  18099. oE[8]=xaxis.z;
  18100. oE[1]=yaxis.x;
  18101. oE[5]=yaxis.y;
  18102. oE[9]=yaxis.z;
  18103. oE[2]=zaxis.x;
  18104. oE[6]=zaxis.y;
  18105. oE[10]=zaxis.z;
  18106. oE[12]=-Vector3.dot(xaxis,eye);
  18107. oE[13]=-Vector3.dot(yaxis,eye);
  18108. oE[14]=-Vector3.dot(zaxis,eye);
  18109. }
  18110. Matrix4x4.createPerspective=function(fov,aspect,znear,zfar,out){
  18111. var yScale=1.0 / Math.tan(fov *0.5);
  18112. var xScale=yScale / aspect;
  18113. var halfWidth=znear / xScale;
  18114. var halfHeight=znear / yScale;
  18115. Matrix4x4.createPerspectiveOffCenter(-halfWidth,halfWidth,-halfHeight,halfHeight,znear,zfar,out);
  18116. }
  18117. Matrix4x4.createPerspectiveOffCenter=function(left,right,bottom,top,znear,zfar,out){
  18118. var oe=out.elements;
  18119. var zRange=zfar / (zfar-znear);
  18120. oe[1]=oe[2]=oe[3]=oe[4]=oe[6]=oe[7]=oe[12]=oe[13]=oe[15]=0;
  18121. oe[0]=2.0 *znear / (right-left);
  18122. oe[5]=2.0 *znear / (top-bottom);
  18123. oe[8]=(left+right)/ (right-left);
  18124. oe[9]=(top+bottom)/ (top-bottom);
  18125. oe[10]=-zRange;
  18126. oe[11]=-1.0;
  18127. oe[14]=-znear *zRange;
  18128. }
  18129. Matrix4x4.createOrthoOffCenter=function(left,right,bottom,top,znear,zfar,out){
  18130. var oe=out.elements;
  18131. var zRange=1.0 / (zfar-znear);
  18132. oe[1]=oe[2]=oe[3]=oe[4]=oe[6]=oe[8]=oe[7]=oe[9]=oe[11]=0;
  18133. oe[15]=1;
  18134. oe[0]=2.0 / (right-left);
  18135. oe[5]=2.0 / (top-bottom);
  18136. oe[10]=-zRange;
  18137. oe[12]=(left+right)/ (left-right);
  18138. oe[13]=(top+bottom)/ (bottom-top);
  18139. oe[14]=-znear *zRange;
  18140. }
  18141. Matrix4x4.billboard=function(objectPosition,cameraPosition,cameraRight,cameraUp,cameraForward,mat){
  18142. Vector3.subtract(objectPosition,cameraPosition,Matrix4x4._tempVector0);
  18143. var lengthSq=Vector3.scalarLengthSquared(Matrix4x4._tempVector0);
  18144. if (MathUtils3D.isZero(lengthSq)){
  18145. Vector3.scale(cameraForward,-1,Matrix4x4._tempVector1);
  18146. Matrix4x4._tempVector1.cloneTo(Matrix4x4._tempVector0);
  18147. }else {
  18148. Vector3.scale(Matrix4x4._tempVector0,1 / Math.sqrt(lengthSq),Matrix4x4._tempVector0);
  18149. }
  18150. Vector3.cross(cameraUp,Matrix4x4._tempVector0,Matrix4x4._tempVector2);
  18151. Vector3.normalize(Matrix4x4._tempVector2,Matrix4x4._tempVector2);
  18152. Vector3.cross(Matrix4x4._tempVector0,Matrix4x4._tempVector2,Matrix4x4._tempVector3);
  18153. var crosse=Matrix4x4._tempVector2;
  18154. var finale=Matrix4x4._tempVector3;
  18155. var diffee=Matrix4x4._tempVector0;
  18156. var obpose=objectPosition;
  18157. var mate=mat.elements;
  18158. mate[0]=crosse.x;
  18159. mate[1]=crosse.y;
  18160. mate[2]=crosse.z;
  18161. mate[3]=0.0;
  18162. mate[4]=finale.x;
  18163. mate[5]=finale.y;
  18164. mate[6]=finale.z;
  18165. mate[7]=0.0;
  18166. mate[8]=diffee.x;
  18167. mate[9]=diffee.y;
  18168. mate[10]=diffee.z;
  18169. mate[11]=0.0;
  18170. mate[12]=obpose.x;
  18171. mate[13]=obpose.y;
  18172. mate[14]=obpose.z;
  18173. mate[15]=1.0;
  18174. }
  18175. Matrix4x4.translation=function(v3,out){
  18176. var oe=out.elements;
  18177. oe[0]=oe[5]=oe[10]=oe[15]=1;
  18178. oe[12]=v3.x;
  18179. oe[13]=v3.y;
  18180. oe[14]=v3.z;
  18181. }
  18182. __static(Matrix4x4,
  18183. ['_tempMatrix4x4',function(){return this._tempMatrix4x4=new Matrix4x4();},'_tempVector0',function(){return this._tempVector0=new Vector3();},'_tempVector1',function(){return this._tempVector1=new Vector3();},'_tempVector2',function(){return this._tempVector2=new Vector3();},'_tempVector3',function(){return this._tempVector3=new Vector3();},'_tempQuaternion',function(){return this._tempQuaternion=new Quaternion();},'DEFAULT',function(){return this.DEFAULT=new Matrix4x4();},'ZERO',function(){return this.ZERO=new Matrix4x4(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);}
  18184. ]);
  18185. return Matrix4x4;
  18186. })()
  18187. /**
  18188. *<code>Simulation</code> 类用于创建物理模拟器。
  18189. */
  18190. //class laya.d3.physics.PhysicsSimulation
  18191. var PhysicsSimulation=(function(){
  18192. function PhysicsSimulation(configuration,flags){
  18193. /**@private */
  18194. this._nativeDiscreteDynamicsWorld=null;
  18195. /**@private */
  18196. this._nativeCollisionWorld=null;
  18197. /**@private */
  18198. this._nativeDispatcher=null;
  18199. /**@private */
  18200. this._nativeCollisionConfiguration=null;
  18201. /**@private */
  18202. this._nativeBroadphase=null;
  18203. /**@private */
  18204. this._nativeSolverInfo=null;
  18205. /**@private */
  18206. this._nativeDispatchInfo=null;
  18207. /**@private */
  18208. this._nativeClosestRayResultCallback=null;
  18209. /**@private */
  18210. this._nativeAllHitsRayResultCallback=null;
  18211. /**@private */
  18212. this._nativeClosestConvexResultCallback=null;
  18213. /**@private */
  18214. this._nativeAllConvexResultCallback=null;
  18215. /**@private */
  18216. this._updatedRigidbodies=0;
  18217. /**物理引擎在一帧中用于补偿减速的最大次数:模拟器每帧允许的最大模拟次数,如果引擎运行缓慢,可能需要增加该次数,否则模拟器会丢失“时间",引擎间隔时间小于maxSubSteps*fixedTimeStep非常重要。*/
  18218. this.maxSubSteps=1;
  18219. /**物理模拟器帧的间隔时间:通过减少fixedTimeStep可增加模拟精度,默认是1.0 / 60.0。*/
  18220. this.fixedTimeStep=1.0 / 60.0;
  18221. this._gravity=new Vector3(0,-10,0);
  18222. this._nativeVector3Zero=new Laya3D._physics3D.btVector3(0,0,0);
  18223. this._nativeDefaultQuaternion=new Laya3D._physics3D.btQuaternion(0,0,0,-1);
  18224. this._collisionsUtils=new CollisionTool();
  18225. this._previousFrameCollisions=[];
  18226. this._currentFrameCollisions=[];
  18227. this._physicsUpdateList=new PhysicsUpdateList();
  18228. this._characters=[];
  18229. (flags===void 0)&& (flags=0);
  18230. this.maxSubSteps=configuration.maxSubSteps;
  18231. this.fixedTimeStep=configuration.fixedTimeStep;
  18232. var physics3D=Laya3D._physics3D;
  18233. this._nativeCollisionConfiguration=new physics3D.btDefaultCollisionConfiguration();
  18234. this._nativeDispatcher=new physics3D.btCollisionDispatcher(this._nativeCollisionConfiguration);
  18235. this._nativeBroadphase=new physics3D.btDbvtBroadphase();
  18236. this._nativeBroadphase.getOverlappingPairCache().setInternalGhostPairCallback(new physics3D.btGhostPairCallback());
  18237. var conFlags=configuration.flags;
  18238. if (conFlags & 0x1){
  18239. this._nativeCollisionWorld=new physics3D.btCollisionWorld(this._nativeDispatcher,this._nativeBroadphase,this._nativeCollisionConfiguration);
  18240. }else if (conFlags & 0x2){
  18241. throw "PhysicsSimulation:SoftBody processing is not yet available";
  18242. }else {
  18243. var solver=new physics3D.btSequentialImpulseConstraintSolver();
  18244. this._nativeDiscreteDynamicsWorld=new physics3D.btDiscreteDynamicsWorld(this._nativeDispatcher,this._nativeBroadphase,solver,this._nativeCollisionConfiguration);
  18245. this._nativeCollisionWorld=this._nativeDiscreteDynamicsWorld;
  18246. }
  18247. if (this._nativeDiscreteDynamicsWorld){
  18248. this._nativeSolverInfo=this._nativeDiscreteDynamicsWorld.getSolverInfo();
  18249. this._nativeDispatchInfo=this._nativeDiscreteDynamicsWorld.getDispatchInfo();
  18250. }
  18251. this._nativeClosestRayResultCallback=new physics3D.ClosestRayResultCallback(this._nativeVector3Zero,this._nativeVector3Zero);
  18252. this._nativeAllHitsRayResultCallback=new physics3D.AllHitsRayResultCallback(this._nativeVector3Zero,this._nativeVector3Zero);
  18253. this._nativeClosestConvexResultCallback=new physics3D.ClosestConvexResultCallback(this._nativeVector3Zero,this._nativeVector3Zero);
  18254. this._nativeAllConvexResultCallback=new physics3D.AllConvexResultCallback(this._nativeVector3Zero,this._nativeVector3Zero);
  18255. physics3D._btGImpactCollisionAlgorithm_RegisterAlgorithm(this._nativeDispatcher.a);
  18256. }
  18257. __class(PhysicsSimulation,'laya.d3.physics.PhysicsSimulation');
  18258. var __proto=PhysicsSimulation.prototype;
  18259. /**
  18260. *@private
  18261. */
  18262. __proto._simulate=function(deltaTime){
  18263. this._updatedRigidbodies=0;
  18264. if (this._nativeDiscreteDynamicsWorld)
  18265. this._nativeDiscreteDynamicsWorld.stepSimulation(deltaTime,this.maxSubSteps,this.fixedTimeStep);
  18266. else
  18267. this._nativeCollisionWorld.PerformDiscreteCollisionDetection();
  18268. }
  18269. /**
  18270. *@private
  18271. */
  18272. __proto._destroy=function(){
  18273. var physics3D=Laya3D._physics3D;
  18274. if (this._nativeDiscreteDynamicsWorld){
  18275. physics3D.destroy(this._nativeDiscreteDynamicsWorld);
  18276. this._nativeDiscreteDynamicsWorld=null;
  18277. }else {
  18278. physics3D.destroy(this._nativeCollisionWorld);
  18279. this._nativeCollisionWorld=null;
  18280. }
  18281. physics3D.destroy(this._nativeBroadphase);
  18282. this._nativeBroadphase=null;
  18283. physics3D.destroy(this._nativeDispatcher);
  18284. this._nativeDispatcher=null;
  18285. physics3D.destroy(this._nativeCollisionConfiguration);
  18286. this._nativeCollisionConfiguration=null;
  18287. }
  18288. /**
  18289. *@private
  18290. */
  18291. __proto._addPhysicsCollider=function(component,group,mask){
  18292. this._nativeCollisionWorld.addCollisionObject(component._nativeColliderObject,group,mask);
  18293. }
  18294. /**
  18295. *@private
  18296. */
  18297. __proto._removePhysicsCollider=function(component){
  18298. this._nativeCollisionWorld.removeCollisionObject(component._nativeColliderObject);
  18299. }
  18300. /**
  18301. *@private
  18302. */
  18303. __proto._addRigidBody=function(rigidBody,group,mask){
  18304. if (!this._nativeDiscreteDynamicsWorld)
  18305. throw "Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";
  18306. this._nativeCollisionWorld.addRigidBody(rigidBody._nativeColliderObject,group,mask);
  18307. }
  18308. /**
  18309. *@private
  18310. */
  18311. __proto._removeRigidBody=function(rigidBody){
  18312. if (!this._nativeDiscreteDynamicsWorld)
  18313. throw "Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";
  18314. this._nativeCollisionWorld.removeRigidBody(rigidBody._nativeColliderObject);
  18315. }
  18316. /**
  18317. *@private
  18318. */
  18319. __proto._addCharacter=function(character,group,mask){
  18320. if (!this._nativeDiscreteDynamicsWorld)
  18321. throw "Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";
  18322. this._nativeCollisionWorld.addCollisionObject(character._nativeColliderObject,group,mask);
  18323. this._nativeCollisionWorld.addAction(character._nativeKinematicCharacter);
  18324. }
  18325. /**
  18326. *@private
  18327. */
  18328. __proto._removeCharacter=function(character){
  18329. if (!this._nativeDiscreteDynamicsWorld)
  18330. throw "Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";
  18331. this._nativeCollisionWorld.removeCollisionObject(character._nativeColliderObject);
  18332. this._nativeCollisionWorld.removeAction(character._nativeKinematicCharacter);
  18333. }
  18334. /**
  18335. *射线检测第一个碰撞物体。
  18336. *@param from 起始位置。
  18337. *@param to 结束位置。
  18338. *@param out 碰撞结果。
  18339. *@param collisonGroup 射线所属碰撞组。
  18340. *@param collisionMask 与射线可产生碰撞的组。
  18341. *@return 是否成功。
  18342. */
  18343. __proto.raycastFromTo=function(from,to,out,collisonGroup,collisionMask){
  18344. (collisonGroup===void 0)&& (collisonGroup=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  18345. (collisionMask===void 0)&& (collisionMask=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  18346. var rayResultCall=this._nativeClosestRayResultCallback;
  18347. var rayFrom=PhysicsSimulation._nativeTempVector30;
  18348. var rayTo=PhysicsSimulation._nativeTempVector31;
  18349. rayFrom.setValue(-from.x,from.y,from.z);
  18350. rayTo.setValue(-to.x,to.y,to.z);
  18351. rayResultCall.set_m_rayFromWorld(rayFrom);
  18352. rayResultCall.set_m_rayToWorld(rayTo);
  18353. rayResultCall.set_m_collisionFilterGroup(collisonGroup);
  18354. rayResultCall.set_m_collisionFilterMask(collisionMask);
  18355. rayResultCall.set_m_collisionObject(null);
  18356. rayResultCall.set_m_closestHitFraction(1);
  18357. this._nativeCollisionWorld.rayTest(rayFrom,rayTo,rayResultCall);
  18358. if (rayResultCall.hasHit()){
  18359. if (out){
  18360. out.succeeded=true;
  18361. out.collider=PhysicsComponent._physicObjectsMap[rayResultCall.get_m_collisionObject().getUserIndex()];
  18362. out.hitFraction=rayResultCall.get_m_closestHitFraction();
  18363. var nativePoint=rayResultCall.get_m_hitPointWorld();
  18364. var point=out.point;
  18365. point.x=-nativePoint.x();
  18366. point.y=nativePoint.y();
  18367. point.z=nativePoint.z();
  18368. var nativeNormal=rayResultCall.get_m_hitNormalWorld();
  18369. var normal=out.normal;
  18370. normal.x=-nativeNormal.x();
  18371. normal.y=nativeNormal.y();
  18372. normal.z=nativeNormal.z();
  18373. }
  18374. return true;
  18375. }else {
  18376. if (out)
  18377. out.succeeded=false;
  18378. return false;
  18379. }
  18380. }
  18381. /**
  18382. *射线检测所有碰撞的物体。
  18383. *@param from 起始位置。
  18384. *@param to 结束位置。
  18385. *@param out 碰撞结果[数组元素会被回收]。
  18386. *@param collisonGroup 射线所属碰撞组。
  18387. *@param collisionMask 与射线可产生碰撞的组。
  18388. *@return 是否成功。
  18389. */
  18390. __proto.raycastAllFromTo=function(from,to,out,collisonGroup,collisionMask){
  18391. (collisonGroup===void 0)&& (collisonGroup=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  18392. (collisionMask===void 0)&& (collisionMask=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  18393. var rayResultCall=this._nativeAllHitsRayResultCallback;
  18394. var rayFrom=PhysicsSimulation._nativeTempVector30;
  18395. var rayTo=PhysicsSimulation._nativeTempVector31;
  18396. out.length=0;
  18397. rayFrom.setValue(-from.x,from.y,from.z);
  18398. rayTo.setValue(-to.x,to.y,to.z);
  18399. rayResultCall.set_m_rayFromWorld(rayFrom);
  18400. rayResultCall.set_m_rayToWorld(rayTo);
  18401. rayResultCall.set_m_collisionFilterGroup(collisonGroup);
  18402. rayResultCall.set_m_collisionFilterMask(collisionMask);
  18403. var collisionObjects=rayResultCall.get_m_collisionObjects();
  18404. var nativePoints=rayResultCall.get_m_hitPointWorld();
  18405. var nativeNormals=rayResultCall.get_m_hitNormalWorld();
  18406. var nativeFractions=rayResultCall.get_m_hitFractions();
  18407. collisionObjects.clear();
  18408. nativePoints.clear();
  18409. nativeNormals.clear();
  18410. nativeFractions.clear();
  18411. this._nativeCollisionWorld.rayTest(rayFrom,rayTo,rayResultCall);
  18412. var count=collisionObjects.size();
  18413. if (count > 0){
  18414. this._collisionsUtils.recoverAllHitResultsPool();
  18415. for (var i=0;i < count;i++){
  18416. var hitResult=this._collisionsUtils.getHitResult();
  18417. out.push(hitResult);
  18418. hitResult.succeeded=true;
  18419. hitResult.collider=PhysicsComponent._physicObjectsMap[collisionObjects.at(i).getUserIndex()];
  18420. hitResult.hitFraction=nativeFractions.at(i);
  18421. var nativePoint=nativePoints.at(i);
  18422. var pointE=hitResult.point;
  18423. pointE.x=-nativePoint.x();
  18424. pointE.y=nativePoint.y();
  18425. pointE.z=nativePoint.z();
  18426. var nativeNormal=nativeNormals.at(i);
  18427. var normalE=hitResult.normal;
  18428. normalE.x=-nativeNormal.x();
  18429. normalE.y=nativeNormal.y();
  18430. normalE.z=nativeNormal.z();
  18431. }
  18432. return true;
  18433. }else {
  18434. return false;
  18435. }
  18436. }
  18437. /**
  18438. *射线检测第一个碰撞物体。
  18439. *@param ray 射线
  18440. *@param outHitInfo 与该射线发生碰撞的第一个碰撞器的碰撞信息
  18441. *@param distance 射线长度,默认为最大值
  18442. *@param collisonGroup 射线所属碰撞组。
  18443. *@param collisionMask 与射线可产生碰撞的组。
  18444. *@return 是否检测成功。
  18445. */
  18446. __proto.rayCast=function(ray,outHitResult,distance,collisonGroup,collisionMask){
  18447. (distance===void 0)&& (distance=2147483647);
  18448. (collisonGroup===void 0)&& (collisonGroup=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  18449. (collisionMask===void 0)&& (collisionMask=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  18450. var from=ray.origin;
  18451. var to=PhysicsSimulation._tempVector30;
  18452. Vector3.normalize(ray.direction,to);
  18453. Vector3.scale(to,distance,to);
  18454. Vector3.add(from,to,to);
  18455. return this.raycastFromTo(from,to,outHitResult,collisonGroup,collisionMask);
  18456. }
  18457. /**
  18458. *射线检测所有碰撞的物体。
  18459. *@param ray 射线
  18460. *@param out 碰撞结果[数组元素会被回收]。
  18461. *@param distance 射线长度,默认为最大值
  18462. *@param collisonGroup 射线所属碰撞组。
  18463. *@param collisionMask 与射线可产生碰撞的组。
  18464. *@return 是否检测成功。
  18465. */
  18466. __proto.rayCastAll=function(ray,out,distance,collisonGroup,collisionMask){
  18467. (distance===void 0)&& (distance=2147483647);
  18468. (collisonGroup===void 0)&& (collisonGroup=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  18469. (collisionMask===void 0)&& (collisionMask=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  18470. var from=ray.origin;
  18471. var to=PhysicsSimulation._tempVector30;
  18472. Vector3.normalize(ray.direction,to);
  18473. Vector3.scale(to,distance,to);
  18474. Vector3.add(from,to,to);
  18475. return this.raycastAllFromTo(from,to,out,collisonGroup,collisionMask);
  18476. }
  18477. /**
  18478. *形状检测第一个碰撞的物体。
  18479. *@param shape 形状。
  18480. *@param fromPosition 世界空间起始位置。
  18481. *@param toPosition 世界空间结束位置。
  18482. *@param out 碰撞结果。
  18483. *@param fromRotation 起始旋转。
  18484. *@param toRotation 结束旋转。
  18485. *@param collisonGroup 射线所属碰撞组。
  18486. *@param collisionMask 与射线可产生碰撞的组。
  18487. *@return 是否成功。
  18488. */
  18489. __proto.shapeCast=function(shape,fromPosition,toPosition,out,fromRotation,toRotation,collisonGroup,collisionMask,allowedCcdPenetration){
  18490. (collisonGroup===void 0)&& (collisonGroup=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  18491. (collisionMask===void 0)&& (collisionMask=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  18492. (allowedCcdPenetration===void 0)&& (allowedCcdPenetration=0.0);
  18493. var convexResultCall=this._nativeClosestConvexResultCallback;
  18494. var convexPosFrom=PhysicsSimulation._nativeTempVector30;
  18495. var convexPosTo=PhysicsSimulation._nativeTempVector31;
  18496. var convexRotFrom=PhysicsSimulation._nativeTempQuaternion0;
  18497. var convexRotTo=PhysicsSimulation._nativeTempQuaternion1;
  18498. var convexTransform=PhysicsSimulation._nativeTempTransform0;
  18499. var convexTransTo=PhysicsSimulation._nativeTempTransform1;
  18500. var sweepShape=shape._nativeShape;
  18501. convexPosFrom.setValue(-fromPosition.x,fromPosition.y,fromPosition.z);
  18502. convexPosTo.setValue(-toPosition.x,toPosition.y,toPosition.z);
  18503. convexResultCall.set_m_collisionFilterGroup(collisonGroup);
  18504. convexResultCall.set_m_collisionFilterMask(collisionMask);
  18505. convexTransform.setOrigin(convexPosFrom);
  18506. convexTransTo.setOrigin(convexPosTo);
  18507. if (fromRotation){
  18508. convexRotFrom.setValue(-fromRotation.x,fromRotation.y,fromRotation.z,-fromRotation.w);
  18509. convexTransform.setRotation(convexRotFrom);
  18510. }else {
  18511. convexTransform.setRotation(this._nativeDefaultQuaternion);
  18512. }
  18513. if (toRotation){
  18514. convexRotTo.setValue(-toRotation.x,toRotation.y,toRotation.z,-toRotation.w);
  18515. convexTransTo.setRotation(convexRotTo);
  18516. }else {
  18517. convexTransTo.setRotation(this._nativeDefaultQuaternion);
  18518. }
  18519. convexResultCall.set_m_hitCollisionObject(null);
  18520. convexResultCall.set_m_closestHitFraction(1);
  18521. this._nativeCollisionWorld.convexSweepTest(sweepShape,convexTransform,convexTransTo,convexResultCall,allowedCcdPenetration);
  18522. if (convexResultCall.hasHit()){
  18523. if (out){
  18524. out.succeeded=true;
  18525. out.collider=PhysicsComponent._physicObjectsMap[convexResultCall.get_m_hitCollisionObject().getUserIndex()];
  18526. out.hitFraction=convexResultCall.get_m_closestHitFraction();
  18527. var nativePoint=convexResultCall.get_m_hitPointWorld();
  18528. var nativeNormal=convexResultCall.get_m_hitNormalWorld();
  18529. var point=out.point;
  18530. var normal=out.normal;
  18531. point.x=-nativePoint.x();
  18532. point.y=nativePoint.y();
  18533. point.z=nativePoint.z();
  18534. normal.x=-nativeNormal.x();
  18535. normal.y=nativeNormal.y();
  18536. normal.z=nativeNormal.z();
  18537. }
  18538. return true;
  18539. }else {
  18540. if (out)
  18541. out.succeeded=false;
  18542. return false;
  18543. }
  18544. }
  18545. /**
  18546. *形状检测所有碰撞的物体。
  18547. *@param shape 形状。
  18548. *@param fromPosition 世界空间起始位置。
  18549. *@param toPosition 世界空间结束位置。
  18550. *@param out 碰撞结果[数组元素会被回收]。
  18551. *@param fromRotation 起始旋转。
  18552. *@param toRotation 结束旋转。
  18553. *@param collisonGroup 射线所属碰撞组。
  18554. *@param collisionMask 与射线可产生碰撞的组。
  18555. *@return 是否成功。
  18556. */
  18557. __proto.shapeCastAll=function(shape,fromPosition,toPosition,out,fromRotation,toRotation,collisonGroup,collisionMask,allowedCcdPenetration){
  18558. (collisonGroup===void 0)&& (collisonGroup=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  18559. (collisionMask===void 0)&& (collisionMask=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  18560. (allowedCcdPenetration===void 0)&& (allowedCcdPenetration=0.0);
  18561. var convexResultCall=this._nativeAllConvexResultCallback;
  18562. var convexPosFrom=PhysicsSimulation._nativeTempVector30;
  18563. var convexPosTo=PhysicsSimulation._nativeTempVector31;
  18564. var convexRotFrom=PhysicsSimulation._nativeTempQuaternion0;
  18565. var convexRotTo=PhysicsSimulation._nativeTempQuaternion1;
  18566. var convexTransform=PhysicsSimulation._nativeTempTransform0;
  18567. var convexTransTo=PhysicsSimulation._nativeTempTransform1;
  18568. var sweepShape=shape._nativeShape;
  18569. out.length=0;
  18570. convexPosFrom.setValue(-fromPosition.x,fromPosition.y,fromPosition.z);
  18571. convexPosTo.setValue(-toPosition.x,toPosition.y,toPosition.z);
  18572. convexResultCall.set_m_collisionFilterGroup(collisonGroup);
  18573. convexResultCall.set_m_collisionFilterMask(collisionMask);
  18574. convexTransform.setOrigin(convexPosFrom);
  18575. convexTransTo.setOrigin(convexPosTo);
  18576. if (fromRotation){
  18577. convexRotFrom.setValue(-fromRotation.x,fromRotation.y,fromRotation.z,-fromRotation.w);
  18578. convexTransform.setRotation(convexRotFrom);
  18579. }else {
  18580. convexTransform.setRotation(this._nativeDefaultQuaternion);
  18581. }
  18582. if (toRotation){
  18583. convexRotTo.setValue(-toRotation.x,toRotation.y,toRotation.z,-toRotation.w);
  18584. convexTransTo.setRotation(convexRotTo);
  18585. }else {
  18586. convexTransTo.setRotation(this._nativeDefaultQuaternion);
  18587. };
  18588. var collisionObjects=convexResultCall.get_m_collisionObjects();
  18589. collisionObjects.clear();
  18590. this._nativeCollisionWorld.convexSweepTest(sweepShape,convexTransform,convexTransTo,convexResultCall,allowedCcdPenetration);
  18591. var count=collisionObjects.size();
  18592. if (count > 0){
  18593. var nativePoints=convexResultCall.get_m_hitPointWorld();
  18594. var nativeNormals=convexResultCall.get_m_hitNormalWorld();
  18595. var nativeFractions=convexResultCall.get_m_hitFractions();
  18596. for (var i=0;i < count;i++){
  18597. var hitResult=this._collisionsUtils.getHitResult();
  18598. out.push(hitResult);
  18599. hitResult.succeeded=true;
  18600. hitResult.collider=PhysicsComponent._physicObjectsMap[collisionObjects.at(i).getUserIndex()];
  18601. hitResult.hitFraction=nativeFractions.at(i);
  18602. var nativePoint=nativePoints.at(i);
  18603. var point=hitResult.point;
  18604. point.x=-nativePoint.x();
  18605. point.y=nativePoint.y();
  18606. point.z=nativePoint.z();
  18607. var nativeNormal=nativeNormals.at(i);
  18608. var normal=hitResult.normal;
  18609. normal.x=-nativeNormal.x();
  18610. normal.y=nativeNormal.y();
  18611. normal.z=nativeNormal.z();
  18612. }
  18613. return true;
  18614. }else {
  18615. return false;
  18616. }
  18617. }
  18618. /**
  18619. *添加刚体运动的约束条件。
  18620. *@param constraint 约束。
  18621. *@param disableCollisionsBetweenLinkedBodies 是否禁用
  18622. */
  18623. __proto.addConstraint=function(constraint,disableCollisionsBetweenLinkedBodies){
  18624. (disableCollisionsBetweenLinkedBodies===void 0)&& (disableCollisionsBetweenLinkedBodies=false);
  18625. if (!this._nativeDiscreteDynamicsWorld)
  18626. throw "Cannot perform this action when the physics engine is set to CollisionsOnly";
  18627. this._nativeDiscreteDynamicsWorld.addConstraint(constraint._nativeConstraint,disableCollisionsBetweenLinkedBodies);
  18628. constraint._simulation=this;
  18629. }
  18630. /**
  18631. *移除刚体运动的约束条件。
  18632. */
  18633. __proto.removeConstraint=function(constraint){
  18634. if (!this._nativeDiscreteDynamicsWorld)
  18635. throw "Cannot perform this action when the physics engine is set to CollisionsOnly";
  18636. this._nativeDiscreteDynamicsWorld.removeConstraint(constraint._nativeConstraint);
  18637. }
  18638. /**
  18639. *@private
  18640. */
  18641. __proto._updatePhysicsTransformFromRender=function(){
  18642. var elements=this._physicsUpdateList.elements;
  18643. for (var i=0,n=this._physicsUpdateList.length;i < n;i++){
  18644. var physicCollider=elements[i];
  18645. physicCollider._derivePhysicsTransformation(false);
  18646. physicCollider._inPhysicUpdateListIndex=-1;
  18647. }
  18648. this._physicsUpdateList.length=0;
  18649. }
  18650. /**
  18651. *@private
  18652. */
  18653. __proto._updateCharacters=function(){
  18654. for (var i=0,n=this._characters.length;i < n;i++){
  18655. var character=this._characters[i];
  18656. character._updateTransformComponent(character._nativeColliderObject.getWorldTransform());
  18657. }
  18658. }
  18659. /**
  18660. *@private
  18661. */
  18662. __proto._updateCollisions=function(){
  18663. this._collisionsUtils.recoverAllContactPointsPool();
  18664. var previous=this._currentFrameCollisions;
  18665. this._currentFrameCollisions=this._previousFrameCollisions;
  18666. this._currentFrameCollisions.length=0;
  18667. this._previousFrameCollisions=previous;
  18668. var loopCount=Stat.loopCount;
  18669. var numManifolds=this._nativeDispatcher.getNumManifolds();
  18670. for (var i=0;i < numManifolds;i++){
  18671. var contactManifold=this._nativeDispatcher.getManifoldByIndexInternal(i);
  18672. var componentA=PhysicsComponent._physicObjectsMap[contactManifold.getBody0().getUserIndex()];
  18673. var componentB=PhysicsComponent._physicObjectsMap[contactManifold.getBody1().getUserIndex()];
  18674. var collision=null;
  18675. var isFirstCollision=false;
  18676. var contacts=null;
  18677. var isTrigger=componentA.isTrigger || componentB.isTrigger;
  18678. if (isTrigger && ((componentA.owner)._needProcessTriggers || (componentB.owner)._needProcessTriggers)){
  18679. var numContacts=contactManifold.getNumContacts();
  18680. for (var j=0;j < numContacts;j++){
  18681. var pt=contactManifold.getContactPoint(j);
  18682. var distance=pt.getDistance();
  18683. if (distance <=0){
  18684. collision=this._collisionsUtils.getCollision(componentA,componentB);
  18685. contacts=collision.contacts;
  18686. isFirstCollision=collision._updateFrame!==loopCount;
  18687. if (isFirstCollision){
  18688. collision._isTrigger=true;
  18689. contacts.length=0;
  18690. }
  18691. break ;
  18692. }
  18693. }
  18694. }else if ((componentA.owner)._needProcessCollisions || (componentB.owner)._needProcessCollisions){
  18695. if (componentA._enableProcessCollisions || componentB._enableProcessCollisions){
  18696. numContacts=contactManifold.getNumContacts();
  18697. for (j=0;j < numContacts;j++){
  18698. pt=contactManifold.getContactPoint(j);
  18699. distance=pt.getDistance();
  18700. if (distance <=0){
  18701. var contactPoint=this._collisionsUtils.getContactPoints();
  18702. contactPoint.colliderA=componentA;
  18703. contactPoint.colliderB=componentB;
  18704. contactPoint.distance=distance;
  18705. var nativeNormal=pt.get_m_normalWorldOnB();
  18706. var normal=contactPoint.normal;
  18707. normal.x=-nativeNormal.x();
  18708. normal.y=nativeNormal.y();
  18709. normal.z=nativeNormal.z();
  18710. var nativePostionA=pt.get_m_positionWorldOnA();
  18711. var positionOnA=contactPoint.positionOnA;
  18712. positionOnA.x=-nativePostionA.x();
  18713. positionOnA.y=nativePostionA.y();
  18714. positionOnA.z=nativePostionA.z();
  18715. var nativePostionB=pt.get_m_positionWorldOnB();
  18716. var positionOnB=contactPoint.positionOnB;
  18717. positionOnB.x=-nativePostionB.x();
  18718. positionOnB.y=nativePostionB.y();
  18719. positionOnB.z=nativePostionB.z();
  18720. if (!collision){
  18721. collision=this._collisionsUtils.getCollision(componentA,componentB);
  18722. contacts=collision.contacts;
  18723. isFirstCollision=collision._updateFrame!==loopCount;
  18724. if (isFirstCollision){
  18725. collision._isTrigger=false;
  18726. contacts.length=0;
  18727. }
  18728. }
  18729. contacts.push(contactPoint);
  18730. }
  18731. }
  18732. }
  18733. }
  18734. if (collision && isFirstCollision){
  18735. this._currentFrameCollisions.push(collision);
  18736. collision._setUpdateFrame(loopCount);
  18737. }
  18738. }
  18739. }
  18740. /**
  18741. *@private
  18742. */
  18743. __proto._eventScripts=function(){
  18744. var loopCount=Stat.loopCount;
  18745. for (var i=0,n=this._currentFrameCollisions.length;i < n;i++){
  18746. var curFrameCol=this._currentFrameCollisions[i];
  18747. var colliderA=curFrameCol._colliderA;
  18748. var colliderB=curFrameCol._colliderB;
  18749. if (colliderA.destroyed || colliderB.destroyed)
  18750. continue ;
  18751. if (loopCount-curFrameCol._lastUpdateFrame===1){
  18752. var ownerA=colliderA.owner;
  18753. var scriptsA=ownerA._scripts;
  18754. if (scriptsA){
  18755. if (curFrameCol._isTrigger){
  18756. if (ownerA._needProcessTriggers){
  18757. for (var j=0,m=scriptsA.length;j < m;j++)
  18758. scriptsA[j].onTriggerStay(colliderB);
  18759. }
  18760. }else {
  18761. if (ownerA._needProcessCollisions){
  18762. for (j=0,m=scriptsA.length;j < m;j++){
  18763. curFrameCol.other=colliderB;
  18764. scriptsA[j].onCollisionStay(curFrameCol);
  18765. }
  18766. }
  18767. }
  18768. };
  18769. var ownerB=colliderB.owner;
  18770. var scriptsB=ownerB._scripts;
  18771. if (scriptsB){
  18772. if (curFrameCol._isTrigger){
  18773. if (ownerB._needProcessTriggers){
  18774. for (j=0,m=scriptsB.length;j < m;j++)
  18775. scriptsB[j].onTriggerStay(colliderA);
  18776. }
  18777. }else {
  18778. if (ownerB._needProcessCollisions){
  18779. for (j=0,m=scriptsB.length;j < m;j++){
  18780. curFrameCol.other=colliderA;
  18781. scriptsB[j].onCollisionStay(curFrameCol);
  18782. }
  18783. }
  18784. }
  18785. }
  18786. }else {
  18787. ownerA=colliderA.owner;
  18788. scriptsA=ownerA._scripts;
  18789. if (scriptsA){
  18790. if (curFrameCol._isTrigger){
  18791. if (ownerA._needProcessTriggers){
  18792. for (j=0,m=scriptsA.length;j < m;j++)
  18793. scriptsA[j].onTriggerEnter(colliderB);
  18794. }
  18795. }else {
  18796. if (ownerA._needProcessCollisions){
  18797. for (j=0,m=scriptsA.length;j < m;j++){
  18798. curFrameCol.other=colliderB;
  18799. scriptsA[j].onCollisionEnter(curFrameCol);
  18800. }
  18801. }
  18802. }
  18803. }
  18804. ownerB=colliderB.owner;
  18805. scriptsB=ownerB._scripts;
  18806. if (scriptsB){
  18807. if (curFrameCol._isTrigger){
  18808. if (ownerB._needProcessTriggers){
  18809. for (j=0,m=scriptsB.length;j < m;j++)
  18810. scriptsB[j].onTriggerEnter(colliderA);
  18811. }
  18812. }else {
  18813. if (ownerB._needProcessCollisions){
  18814. for (j=0,m=scriptsB.length;j < m;j++){
  18815. curFrameCol.other=colliderA;
  18816. scriptsB[j].onCollisionEnter(curFrameCol);
  18817. }
  18818. }
  18819. }
  18820. }
  18821. }
  18822. }
  18823. for (i=0,n=this._previousFrameCollisions.length;i < n;i++){
  18824. var preFrameCol=this._previousFrameCollisions[i];
  18825. var preColliderA=preFrameCol._colliderA;
  18826. var preColliderB=preFrameCol._colliderB;
  18827. if (preColliderA.destroyed || preColliderB.destroyed)
  18828. continue ;
  18829. if (loopCount-preFrameCol._updateFrame===1){
  18830. this._collisionsUtils.recoverCollision(preFrameCol);
  18831. ownerA=preColliderA.owner;
  18832. scriptsA=ownerA._scripts;
  18833. if (scriptsA){
  18834. if (preFrameCol._isTrigger){
  18835. if (ownerA._needProcessTriggers){
  18836. for (j=0,m=scriptsA.length;j < m;j++)
  18837. scriptsA[j].onTriggerExit(preColliderB);
  18838. }
  18839. }else {
  18840. if (ownerA._needProcessCollisions){
  18841. for (j=0,m=scriptsA.length;j < m;j++){
  18842. preFrameCol.other=preColliderB;
  18843. scriptsA[j].onCollisionExit(preFrameCol);
  18844. }
  18845. }
  18846. }
  18847. }
  18848. ownerB=preColliderB.owner;
  18849. scriptsB=ownerB._scripts;
  18850. if (scriptsB){
  18851. if (preFrameCol._isTrigger){
  18852. if (ownerB._needProcessTriggers){
  18853. for (j=0,m=scriptsB.length;j < m;j++)
  18854. scriptsB[j].onTriggerExit(preColliderA);
  18855. }
  18856. }else {
  18857. if (ownerB._needProcessCollisions){
  18858. for (j=0,m=scriptsB.length;j < m;j++){
  18859. preFrameCol.other=preColliderA;
  18860. scriptsB[j].onCollisionExit(preFrameCol);
  18861. }
  18862. }
  18863. }
  18864. }
  18865. }
  18866. }
  18867. }
  18868. /**
  18869. *清除力。
  18870. */
  18871. __proto.clearForces=function(){
  18872. if (!this._nativeDiscreteDynamicsWorld)
  18873. throw "Cannot perform this action when the physics engine is set to CollisionsOnly";
  18874. this._nativeDiscreteDynamicsWorld.clearForces();
  18875. }
  18876. /**
  18877. *设置重力。
  18878. */
  18879. /**
  18880. *获取重力。
  18881. */
  18882. __getset(0,__proto,'gravity',function(){
  18883. if (!this._nativeDiscreteDynamicsWorld)
  18884. throw "Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";
  18885. return this._gravity;
  18886. },function(value){
  18887. if (!this._nativeDiscreteDynamicsWorld)
  18888. throw "Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";
  18889. this._gravity=value;
  18890. var nativeGravity=PhysicsSimulation._nativeTempVector30;
  18891. nativeGravity.setValue(-value.x,value.y,value.z);
  18892. this._nativeDiscreteDynamicsWorld.setGravity(nativeGravity);
  18893. });
  18894. /**
  18895. *设置是否进行连续碰撞检测。
  18896. *@param value 是否进行连续碰撞检测。
  18897. */
  18898. /**
  18899. *获取是否进行连续碰撞检测。
  18900. *@return 是否进行连续碰撞检测。
  18901. */
  18902. __getset(0,__proto,'continuousCollisionDetection',function(){
  18903. return this._nativeDispatchInfo.get_m_useContinuous();
  18904. },function(value){
  18905. this._nativeDispatchInfo.set_m_useContinuous(value);
  18906. });
  18907. /**
  18908. *@private
  18909. */
  18910. /**
  18911. *@private
  18912. */
  18913. __getset(0,__proto,'speculativeContactRestitution',function(){
  18914. if (!this._nativeDiscreteDynamicsWorld)
  18915. throw "Simulation:Cannot Cannot perform this action when the physics engine is set to CollisionsOnly";
  18916. return this._nativeDiscreteDynamicsWorld.getApplySpeculativeContactRestitution();
  18917. },function(value){
  18918. if (!this._nativeDiscreteDynamicsWorld)
  18919. throw "Simulation:Cannot Cannot perform this action when the physics engine is set to CollisionsOnly";
  18920. this._nativeDiscreteDynamicsWorld.setApplySpeculativeContactRestitution(value);
  18921. });
  18922. PhysicsSimulation.createConstraint=function(){}
  18923. PhysicsSimulation.PHYSICSENGINEFLAGS_NONE=0x0;
  18924. PhysicsSimulation.PHYSICSENGINEFLAGS_COLLISIONSONLY=0x1;
  18925. PhysicsSimulation.PHYSICSENGINEFLAGS_SOFTBODYSUPPORT=0x2;
  18926. PhysicsSimulation.PHYSICSENGINEFLAGS_MULTITHREADED=0x4;
  18927. PhysicsSimulation.PHYSICSENGINEFLAGS_USEHARDWAREWHENPOSSIBLE=0x8;
  18928. PhysicsSimulation.SOLVERMODE_RANDMIZE_ORDER=1;
  18929. PhysicsSimulation.SOLVERMODE_FRICTION_SEPARATE=2;
  18930. PhysicsSimulation.SOLVERMODE_USE_WARMSTARTING=4;
  18931. PhysicsSimulation.SOLVERMODE_USE_2_FRICTION_DIRECTIONS=16;
  18932. PhysicsSimulation.SOLVERMODE_ENABLE_FRICTION_DIRECTION_CACHING=32;
  18933. PhysicsSimulation.SOLVERMODE_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION=64;
  18934. PhysicsSimulation.SOLVERMODE_CACHE_FRIENDLY=128;
  18935. PhysicsSimulation.SOLVERMODE_SIMD=256;
  18936. PhysicsSimulation.SOLVERMODE_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS=512;
  18937. PhysicsSimulation.SOLVERMODE_ALLOW_ZERO_LENGTH_FRICTION_DIRECTIONS=1024;
  18938. PhysicsSimulation.disableSimulation=false;
  18939. __static(PhysicsSimulation,
  18940. ['_nativeTempVector30',function(){return this._nativeTempVector30=new Laya3D._physics3D.btVector3(0,0,0);},'_nativeTempVector31',function(){return this._nativeTempVector31=new Laya3D._physics3D.btVector3(0,0,0);},'_nativeTempQuaternion0',function(){return this._nativeTempQuaternion0=new Laya3D._physics3D.btQuaternion(0,0,0,1);},'_nativeTempQuaternion1',function(){return this._nativeTempQuaternion1=new Laya3D._physics3D.btQuaternion(0,0,0,1);},'_nativeTempTransform0',function(){return this._nativeTempTransform0=new Laya3D._physics3D.btTransform();},'_nativeTempTransform1',function(){return this._nativeTempTransform1=new Laya3D._physics3D.btTransform();},'_tempVector30',function(){return this._tempVector30=new Vector3();}
  18941. ]);
  18942. return PhysicsSimulation;
  18943. })()
  18944. /**
  18945. *<code>PhysicsComponent</code> 类用于创建物理组件的父类。
  18946. */
  18947. //class laya.d3.physics.PhysicsComponent extends laya.components.Component
  18948. var PhysicsComponent=(function(_super){
  18949. function PhysicsComponent(collisionGroup,canCollideWith){
  18950. /**@private */
  18951. this._restitution=0.0;
  18952. /**@private */
  18953. this._friction=0.5;
  18954. /**@private */
  18955. this._rollingFriction=0.0;
  18956. /**@private */
  18957. this._ccdMotionThreshold=0.0;
  18958. /**@private */
  18959. this._ccdSweptSphereRadius=0.0;
  18960. /**@private */
  18961. this._colliderShape=null;
  18962. /**@private */
  18963. this._transformFlag=2147483647;
  18964. /**@private */
  18965. //this._nativeColliderObject=null;
  18966. /**@private */
  18967. //this._simulation=null;
  18968. /**@private */
  18969. this._enableProcessCollisions=true;
  18970. /**@private */
  18971. this._inPhysicUpdateListIndex=-1;
  18972. /**是否可以缩放Shape。 */
  18973. this.canScaleShape=true;
  18974. PhysicsComponent.__super.call(this);
  18975. this._collisionGroup=/*laya.d3.utils.Physics3DUtils.COLLISIONFILTERGROUP_DEFAULTFILTER*/0x1;
  18976. this._canCollideWith=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER;
  18977. this._collisionGroup=collisionGroup;
  18978. this._canCollideWith=canCollideWith;
  18979. PhysicsComponent._physicObjectsMap[this.id]=this;
  18980. }
  18981. __class(PhysicsComponent,'laya.d3.physics.PhysicsComponent',_super);
  18982. var __proto=PhysicsComponent.prototype;
  18983. /**
  18984. *@private
  18985. */
  18986. __proto._isValid=function(){
  18987. return this._simulation && this._colliderShape && this._enabled;
  18988. }
  18989. /**
  18990. *@inheritDoc
  18991. */
  18992. __proto._parse=function(data){
  18993. (data.collisionGroup !=null)&& (this.collisionGroup=data.collisionGroup);
  18994. (data.canCollideWith !=null)&& (this.canCollideWith=data.canCollideWith);
  18995. (data.ccdMotionThreshold !=null)&& (this.ccdMotionThreshold=data.ccdMotionThreshold);
  18996. (data.ccdSweptSphereRadius !=null)&& (this.ccdSweptSphereRadius=data.ccdSweptSphereRadius);
  18997. }
  18998. /**
  18999. *@private
  19000. */
  19001. __proto._parseShape=function(shapesData){
  19002. var shapeCount=shapesData.length;
  19003. if (shapeCount===1){
  19004. var shape=ColliderShape._creatShape(shapesData[0]);
  19005. this.colliderShape=shape;
  19006. }else {
  19007. var compoundShape=new CompoundColliderShape();
  19008. for (var i=0;i < shapeCount;i++){
  19009. shape=ColliderShape._creatShape(shapesData[i]);
  19010. compoundShape.addChildShape(shape);
  19011. }
  19012. this.colliderShape=compoundShape;
  19013. }
  19014. }
  19015. /**
  19016. *@private
  19017. */
  19018. __proto._onScaleChange=function(scale){
  19019. this._colliderShape._setScale(scale);
  19020. }
  19021. /**
  19022. *@private
  19023. */
  19024. __proto._setTransformFlag=function(type,value){
  19025. if (value)
  19026. this._transformFlag |=type;
  19027. else
  19028. this._transformFlag &=~type;
  19029. }
  19030. /**
  19031. *@private
  19032. */
  19033. __proto._getTransformFlag=function(type){
  19034. return (this._transformFlag & type)!=0;
  19035. }
  19036. /**
  19037. *@private
  19038. */
  19039. __proto._addToSimulation=function(){}
  19040. /**
  19041. *@private
  19042. */
  19043. __proto._removeFromSimulation=function(){}
  19044. /**
  19045. *@private
  19046. */
  19047. __proto._derivePhysicsTransformation=function(force){
  19048. this._innerDerivePhysicsTransformation(this._nativeColliderObject.getWorldTransform(),force);
  19049. }
  19050. /**
  19051. *@private
  19052. *通过渲染矩阵更新物理矩阵。
  19053. */
  19054. __proto._innerDerivePhysicsTransformation=function(physicTransformOut,force){
  19055. var transform=(this.owner)._transform;
  19056. var rotation=transform.rotation;
  19057. if (force || this._getTransformFlag(/*laya.d3.core.Transform3D.TRANSFORM_WORLDPOSITION*/0x08)){
  19058. var shapeOffset=this._colliderShape.localOffset;
  19059. var position=transform.position;
  19060. var nativePosition=PhysicsComponent._nativeVector30;
  19061. if (shapeOffset.x!==0 || shapeOffset.y!==0 || shapeOffset.z!==0){
  19062. var physicPosition=PhysicsComponent._tempVector30;
  19063. PhysicsComponent.physicVector3TransformQuat(shapeOffset,rotation.x,rotation.y,rotation.z,rotation.w,physicPosition);
  19064. Vector3.add(position,physicPosition,physicPosition);
  19065. nativePosition.setValue(-physicPosition.x,physicPosition.y,physicPosition.z);
  19066. }else {
  19067. nativePosition.setValue(-position.x,position.y,position.z);
  19068. }
  19069. physicTransformOut.setOrigin(nativePosition);
  19070. this._setTransformFlag(/*laya.d3.core.Transform3D.TRANSFORM_WORLDPOSITION*/0x08,false);
  19071. }
  19072. if (force || this._getTransformFlag(/*laya.d3.core.Transform3D.TRANSFORM_WORLDQUATERNION*/0x10)){
  19073. var shapeRotation=this._colliderShape.localRotation;
  19074. var nativeRotation=PhysicsComponent._nativeQuaternion0;
  19075. if (shapeRotation.x!==0 || shapeRotation.y!==0 || shapeRotation.z!==0 || shapeRotation.w!==1){
  19076. var physicRotation=PhysicsComponent._tempQuaternion0;
  19077. PhysicsComponent.physicQuaternionMultiply(rotation.x,rotation.y,rotation.z,rotation.w,shapeRotation,physicRotation);
  19078. nativeRotation.setValue(-physicRotation.x,physicRotation.y,physicRotation.z,-physicRotation.w);
  19079. }else {
  19080. nativeRotation.setValue(-rotation.x,rotation.y,rotation.z,-rotation.w);
  19081. }
  19082. physicTransformOut.setRotation(nativeRotation);
  19083. this._setTransformFlag(/*laya.d3.core.Transform3D.TRANSFORM_WORLDQUATERNION*/0x10,false);
  19084. }
  19085. if (force || this._getTransformFlag(/*laya.d3.core.Transform3D.TRANSFORM_WORLDSCALE*/0x20)){
  19086. this._onScaleChange(transform.scale);
  19087. this._setTransformFlag(/*laya.d3.core.Transform3D.TRANSFORM_WORLDSCALE*/0x20,false);
  19088. }
  19089. }
  19090. /**
  19091. *@private
  19092. *通过物理矩阵更新渲染矩阵。
  19093. */
  19094. __proto._updateTransformComponent=function(physicsTransform){
  19095. var localOffset=this._colliderShape.localOffset;
  19096. var localRotation=this._colliderShape.localRotation;
  19097. var transform=(this.owner)._transform;
  19098. var position=transform.position;
  19099. var rotation=transform.rotation;
  19100. var nativePosition=physicsTransform.getOrigin();
  19101. var nativeRotation=physicsTransform.getRotation();
  19102. var nativeRotX=-nativeRotation.x();
  19103. var nativeRotY=nativeRotation.y();
  19104. var nativeRotZ=nativeRotation.z();
  19105. var nativeRotW=-nativeRotation.w();
  19106. if (localOffset.x!==0 || localOffset.y!==0 || localOffset.z!==0){
  19107. var rotShapePosition=PhysicsComponent._tempVector30;
  19108. PhysicsComponent.physicVector3TransformQuat(localOffset,nativeRotX,nativeRotY,nativeRotZ,nativeRotW,rotShapePosition);
  19109. position.x=-nativePosition.x()-rotShapePosition.x;
  19110. position.y=nativePosition.y()-rotShapePosition.y;
  19111. position.z=nativePosition.z()-rotShapePosition.z;
  19112. }else {
  19113. position.x=-nativePosition.x();
  19114. position.y=nativePosition.y();
  19115. position.z=nativePosition.z();
  19116. }
  19117. transform.position=position;
  19118. if (localRotation.x!==0 || localRotation.y!==0 || localRotation.z!==0 || localRotation.w!==1){
  19119. var invertShapeRotaion=PhysicsComponent._tempQuaternion0;
  19120. localRotation.invert(invertShapeRotaion);
  19121. PhysicsComponent.physicQuaternionMultiply(nativeRotX,nativeRotY,nativeRotZ,nativeRotW,invertShapeRotaion,rotation);
  19122. }else {
  19123. rotation.x=nativeRotX;
  19124. rotation.y=nativeRotY;
  19125. rotation.z=nativeRotZ;
  19126. rotation.w=nativeRotW;
  19127. }
  19128. transform.rotation=rotation;
  19129. }
  19130. /**
  19131. *@inheritDoc
  19132. */
  19133. __proto._onEnable=function(){
  19134. this._simulation=(this.owner._scene).physicsSimulation;
  19135. this._nativeColliderObject.setContactProcessingThreshold(1e30);
  19136. if (this._colliderShape && this._enabled){
  19137. this._derivePhysicsTransformation(true);
  19138. this._addToSimulation();
  19139. }
  19140. }
  19141. /**
  19142. *@inheritDoc
  19143. */
  19144. __proto._onDisable=function(){
  19145. if (this._colliderShape && this._enabled){
  19146. this._removeFromSimulation();
  19147. (this._inPhysicUpdateListIndex!==-1)&& (this._simulation._physicsUpdateList.remove(this));
  19148. }
  19149. this._simulation=null;
  19150. }
  19151. /**
  19152. *@private
  19153. */
  19154. __proto._onShapeChange=function(colShape){
  19155. var btColObj=this._nativeColliderObject;
  19156. var flags=btColObj.getCollisionFlags();
  19157. if (colShape.needsCustomCollisionCallback){
  19158. if ((flags & 8)===0)
  19159. btColObj.setCollisionFlags(flags | 8);
  19160. }else {
  19161. if ((flags & 8)> 0)
  19162. btColObj.setCollisionFlags(flags ^ 8);
  19163. }
  19164. }
  19165. /**
  19166. *@inheritDoc
  19167. */
  19168. __proto._onAdded=function(){
  19169. this.enabled=this._enabled;
  19170. this.restitution=this._restitution;
  19171. this.friction=this._friction;
  19172. this.rollingFriction=this._rollingFriction;
  19173. this.ccdMotionThreshold=this._ccdMotionThreshold;
  19174. this.ccdSweptSphereRadius=this._ccdSweptSphereRadius;
  19175. (this.owner).transform.on(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this,this._onTransformChanged);
  19176. }
  19177. /**
  19178. *@inheritDoc
  19179. */
  19180. __proto._onDestroy=function(){
  19181. var physics3D=Laya3D._physics3D;
  19182. delete PhysicsComponent._physicObjectsMap[this.id];
  19183. physics3D.destroy(this._nativeColliderObject);
  19184. this._colliderShape.destroy();
  19185. _super.prototype._onDestroy.call(this);
  19186. this._nativeColliderObject=null;
  19187. this._colliderShape=null;
  19188. this._simulation=null;
  19189. (this.owner).transform.off(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this,this._onTransformChanged);
  19190. }
  19191. /**
  19192. *@private
  19193. */
  19194. __proto._onTransformChanged=function(flag){
  19195. if (PhysicsComponent._addUpdateList){
  19196. flag &=/*laya.d3.core.Transform3D.TRANSFORM_WORLDPOSITION*/0x08 | /*laya.d3.core.Transform3D.TRANSFORM_WORLDQUATERNION*/0x10 | /*laya.d3.core.Transform3D.TRANSFORM_WORLDSCALE*/0x20;
  19197. if (flag){
  19198. this._transformFlag |=flag;
  19199. if (this._isValid()&& this._inPhysicUpdateListIndex===-1)
  19200. this._simulation._physicsUpdateList.add(this);
  19201. }
  19202. }
  19203. }
  19204. /**
  19205. *@inheritDoc
  19206. */
  19207. __proto._cloneTo=function(dest){
  19208. var destPhysicsComponent=dest;
  19209. destPhysicsComponent.restitution=this._restitution;
  19210. destPhysicsComponent.friction=this._friction;
  19211. destPhysicsComponent.rollingFriction=this._rollingFriction;
  19212. destPhysicsComponent.ccdMotionThreshold=this._ccdMotionThreshold;
  19213. destPhysicsComponent.ccdSweptSphereRadius=this._ccdSweptSphereRadius;
  19214. destPhysicsComponent.collisionGroup=this._collisionGroup;
  19215. destPhysicsComponent.canCollideWith=this._canCollideWith;
  19216. destPhysicsComponent.canScaleShape=this.canScaleShape;
  19217. (this._colliderShape)&& (destPhysicsComponent.colliderShape=this._colliderShape.clone());
  19218. }
  19219. /**
  19220. *获取是否激活。
  19221. */
  19222. __getset(0,__proto,'isActive',function(){
  19223. return this._nativeColliderObject ? this._nativeColliderObject.isActive():false;
  19224. });
  19225. /**
  19226. *设置弹力。
  19227. *@param 弹力。
  19228. */
  19229. /**
  19230. *获取弹力。
  19231. *@return 弹力。
  19232. */
  19233. __getset(0,__proto,'restitution',function(){
  19234. return this._restitution;
  19235. },function(value){
  19236. this._restitution=value;
  19237. this._nativeColliderObject && this._nativeColliderObject.setRestitution(value);
  19238. });
  19239. /**
  19240. *设置摩擦力。
  19241. *@param value 摩擦力。
  19242. */
  19243. /**
  19244. *获取摩擦力。
  19245. *@return 摩擦力。
  19246. */
  19247. __getset(0,__proto,'friction',function(){
  19248. return this._friction;
  19249. },function(value){
  19250. this._friction=value;
  19251. this._nativeColliderObject && this._nativeColliderObject.setFriction(value);
  19252. });
  19253. /**
  19254. *设置滚动摩擦力。
  19255. *@param 滚动摩擦力。
  19256. */
  19257. /**
  19258. *获取滚动摩擦力。
  19259. *@return 滚动摩擦力。
  19260. */
  19261. __getset(0,__proto,'rollingFriction',function(){
  19262. return this._nativeColliderObject.getRollingFriction();
  19263. },function(value){
  19264. this._rollingFriction=value;
  19265. this._nativeColliderObject && this._nativeColliderObject.setRollingFriction(value);
  19266. });
  19267. /**
  19268. *设置用于连续碰撞检测(CCD)的速度阈值,当物体移动速度小于该值时不进行CCD检测,防止快速移动物体(例如:子弹)错误的穿过其它物体,0表示禁止。
  19269. *@param value 连续碰撞检测(CCD)的速度阈值。
  19270. */
  19271. /**
  19272. *获取用于连续碰撞检测(CCD)的速度阈值,当物体移动速度小于该值时不进行CCD检测,防止快速移动物体(例如:子弹)错误的穿过其它物体,0表示禁止。
  19273. *@return 连续碰撞检测(CCD)的速度阈值。
  19274. */
  19275. __getset(0,__proto,'ccdMotionThreshold',function(){
  19276. return this._ccdMotionThreshold;
  19277. },function(value){
  19278. this._ccdMotionThreshold=value;
  19279. this._nativeColliderObject && this._nativeColliderObject.setCcdMotionThreshold(value);
  19280. });
  19281. /**
  19282. *设置用于进入连续碰撞检测(CCD)范围的球半径。
  19283. *@param 球半径。
  19284. */
  19285. /**
  19286. *获取用于进入连续碰撞检测(CCD)范围的球半径。
  19287. *@return 球半径。
  19288. */
  19289. __getset(0,__proto,'ccdSweptSphereRadius',function(){
  19290. return this._ccdSweptSphereRadius;
  19291. },function(value){
  19292. this._ccdSweptSphereRadius=value;
  19293. this._nativeColliderObject && this._nativeColliderObject.setCcdSweptSphereRadius(value);
  19294. });
  19295. /**
  19296. *设置所属碰撞组。
  19297. *@param 所属碰撞组。
  19298. */
  19299. /**
  19300. *获取所属碰撞组。
  19301. *@return 所属碰撞组。
  19302. */
  19303. __getset(0,__proto,'collisionGroup',function(){
  19304. return this._collisionGroup;
  19305. },function(value){
  19306. if (this._collisionGroup!==value){
  19307. this._collisionGroup=value;
  19308. if (this._simulation && this._colliderShape && this._enabled){
  19309. this._removeFromSimulation();
  19310. this._addToSimulation();
  19311. }
  19312. }
  19313. });
  19314. /**
  19315. *获取模拟器。
  19316. *@return 模拟器。
  19317. */
  19318. __getset(0,__proto,'simulation',function(){
  19319. return this._simulation;
  19320. });
  19321. /**
  19322. *设置碰撞形状。
  19323. */
  19324. /**
  19325. *获取碰撞形状。
  19326. */
  19327. __getset(0,__proto,'colliderShape',function(){
  19328. return this._colliderShape;
  19329. },function(value){
  19330. var lastColliderShape=this._colliderShape;
  19331. if (lastColliderShape){
  19332. lastColliderShape._attatched=false;
  19333. lastColliderShape._attatchedCollisionObject=null;
  19334. }
  19335. this._colliderShape=value;
  19336. if (value){
  19337. if (value._attatched){
  19338. throw "PhysicsComponent: this shape has attatched to other entity.";
  19339. }else {
  19340. value._attatched=true;
  19341. value._attatchedCollisionObject=this;
  19342. }
  19343. if (this._nativeColliderObject){
  19344. this._nativeColliderObject.setCollisionShape(value._nativeShape);
  19345. var canInSimulation=this._simulation && this._enabled;
  19346. (canInSimulation && lastColliderShape)&& (this._removeFromSimulation());
  19347. this._onShapeChange(value);
  19348. if (canInSimulation){
  19349. this._derivePhysicsTransformation(true);
  19350. this._addToSimulation();
  19351. }
  19352. }
  19353. }else {
  19354. if (this._simulation && this._enabled)
  19355. lastColliderShape && this._removeFromSimulation();
  19356. }
  19357. });
  19358. /**
  19359. *@inheritDoc
  19360. */
  19361. __getset(0,__proto,'enabled',_super.prototype._$get_enabled,function(value){
  19362. if (this._simulation && this._colliderShape){
  19363. if (value){
  19364. this._derivePhysicsTransformation(true);
  19365. this._addToSimulation();
  19366. }else {
  19367. this._removeFromSimulation();
  19368. }
  19369. }
  19370. Laya.superSet(Component,this,'enabled',value);
  19371. });
  19372. /**
  19373. *设置可碰撞的碰撞组。
  19374. *@param 可碰撞组。
  19375. */
  19376. /**
  19377. *获取可碰撞的碰撞组。
  19378. *@return 可碰撞组。
  19379. */
  19380. __getset(0,__proto,'canCollideWith',function(){
  19381. return this._canCollideWith;
  19382. },function(value){
  19383. if (this._canCollideWith!==value){
  19384. this._canCollideWith=value;
  19385. if (this._simulation && this._colliderShape && this._enabled){
  19386. this._removeFromSimulation();
  19387. this._addToSimulation();
  19388. }
  19389. }
  19390. });
  19391. PhysicsComponent._createAffineTransformationArray=function(tranX,tranY,tranZ,rotX,rotY,rotZ,rotW,scale,outE){
  19392. var x2=rotX+rotX,y2=rotY+rotY,z2=rotZ+rotZ;
  19393. var xx=rotX *x2,xy=rotX *y2,xz=rotX *z2,yy=rotY *y2,yz=rotY *z2,zz=rotZ *z2;
  19394. var wx=rotW *x2,wy=rotW *y2,wz=rotW *z2,sx=scale[0],sy=scale[1],sz=scale[2];
  19395. outE[0]=(1-(yy+zz))*sx;
  19396. outE[1]=(xy+wz)*sx;
  19397. outE[2]=(xz-wy)*sx;
  19398. outE[3]=0;
  19399. outE[4]=(xy-wz)*sy;
  19400. outE[5]=(1-(xx+zz))*sy;
  19401. outE[6]=(yz+wx)*sy;
  19402. outE[7]=0;
  19403. outE[8]=(xz+wy)*sz;
  19404. outE[9]=(yz-wx)*sz;
  19405. outE[10]=(1-(xx+yy))*sz;
  19406. outE[11]=0;
  19407. outE[12]=tranX;
  19408. outE[13]=tranY;
  19409. outE[14]=tranZ;
  19410. outE[15]=1;
  19411. }
  19412. PhysicsComponent.physicVector3TransformQuat=function(source,qx,qy,qz,qw,out){
  19413. var x=source.x,y=source.y,z=source.z,
  19414. ix=qw *x+qy *z-qz *y,iy=qw *y+qz *x-qx *z,iz=qw *z+qx *y-qy *x,iw=-qx *x-qy *y-qz *z;
  19415. out.x=ix *qw+iw *-qx+iy *-qz-iz *-qy;
  19416. out.y=iy *qw+iw *-qy+iz *-qx-ix *-qz;
  19417. out.z=iz *qw+iw *-qz+ix *-qy-iy *-qx;
  19418. }
  19419. PhysicsComponent.physicQuaternionMultiply=function(lx,ly,lz,lw,right,out){
  19420. var rx=right.x;
  19421. var ry=right.y;
  19422. var rz=right.z;
  19423. var rw=right.w;
  19424. var a=(ly *rz-lz *ry);
  19425. var b=(lz *rx-lx *rz);
  19426. var c=(lx *ry-ly *rx);
  19427. var d=(lx *rx+ly *ry+lz *rz);
  19428. out.x=(lx *rw+rx *lw)+a;
  19429. out.y=(ly *rw+ry *lw)+b;
  19430. out.z=(lz *rw+rz *lw)+c;
  19431. out.w=lw *rw-d;
  19432. }
  19433. PhysicsComponent.ACTIVATIONSTATE_ACTIVE_TAG=1;
  19434. PhysicsComponent.ACTIVATIONSTATE_ISLAND_SLEEPING=2;
  19435. PhysicsComponent.ACTIVATIONSTATE_WANTS_DEACTIVATION=3;
  19436. PhysicsComponent.ACTIVATIONSTATE_DISABLE_DEACTIVATION=4;
  19437. PhysicsComponent.ACTIVATIONSTATE_DISABLE_SIMULATION=5;
  19438. PhysicsComponent.COLLISIONFLAGS_STATIC_OBJECT=1;
  19439. PhysicsComponent.COLLISIONFLAGS_KINEMATIC_OBJECT=2;
  19440. PhysicsComponent.COLLISIONFLAGS_NO_CONTACT_RESPONSE=4;
  19441. PhysicsComponent.COLLISIONFLAGS_CUSTOM_MATERIAL_CALLBACK=8;
  19442. PhysicsComponent.COLLISIONFLAGS_CHARACTER_OBJECT=16;
  19443. PhysicsComponent.COLLISIONFLAGS_DISABLE_VISUALIZE_OBJECT=32;
  19444. PhysicsComponent.COLLISIONFLAGS_DISABLE_SPU_COLLISION_PROCESSING=64;
  19445. PhysicsComponent._physicObjectsMap={};
  19446. PhysicsComponent._addUpdateList=true;
  19447. __static(PhysicsComponent,
  19448. ['_tempVector30',function(){return this._tempVector30=new Vector3();},'_tempQuaternion0',function(){return this._tempQuaternion0=new Quaternion();},'_tempQuaternion1',function(){return this._tempQuaternion1=new Quaternion();},'_tempMatrix4x40',function(){return this._tempMatrix4x40=new Matrix4x4();},'_nativeVector30',function(){return this._nativeVector30=new Laya3D._physics3D.btVector3(0,0,0);},'_nativeQuaternion0',function(){return this._nativeQuaternion0=new Laya3D._physics3D.btQuaternion(0,0,0,1);}
  19449. ]);
  19450. return PhysicsComponent;
  19451. })(Component)
  19452. /**
  19453. *<code>Render</code> 类用于渲染器的父类,抽象类不允许实例。
  19454. */
  19455. //class laya.d3.core.render.BaseRender extends laya.events.EventDispatcher
  19456. var BaseRender=(function(_super){
  19457. function BaseRender(owner){
  19458. /**@private */
  19459. //this._id=0;
  19460. /**@private */
  19461. //this._lightmapScaleOffset=null;
  19462. /**@private */
  19463. //this._lightmapIndex=0;
  19464. /**@private */
  19465. //this._receiveShadow=false;
  19466. /**@private */
  19467. //this._materialsInstance=null;
  19468. /**@private */
  19469. //this._castShadow=false;
  19470. /**@private [实现IListPool接口]*/
  19471. this._indexInList=-1;
  19472. /**@private */
  19473. this._indexInCastShadowList=-1;
  19474. /**@private */
  19475. //this._bounds=null;
  19476. /**@private */
  19477. this._boundsChange=true;
  19478. /**@private */
  19479. //this._enable=false;
  19480. /**@private */
  19481. //this._shaderValues=null;
  19482. /**@private */
  19483. //this._defineDatas=null;
  19484. /**@private */
  19485. //this._scene=null;
  19486. /**@private */
  19487. //this._owner=null;
  19488. /**@private */
  19489. //this._renderElements=null;
  19490. /**@private */
  19491. //this._distanceForSort=NaN;
  19492. /**@private */
  19493. this._visible=true;
  19494. /**@private */
  19495. //this._octreeNode=null;
  19496. /**@private */
  19497. this._indexInOctreeMotionList=-1;
  19498. /**@private */
  19499. this._updateMark=-1;
  19500. /**@private */
  19501. this._updateRenderType=-1;
  19502. /**@private */
  19503. this._isPartOfStaticBatch=false;
  19504. /**@private */
  19505. this._staticBatch=null;
  19506. /**排序矫正值。*/
  19507. //this.sortingFudge=NaN;
  19508. /**@private [NATIVE]*/
  19509. //this._cullingBufferIndex=0;
  19510. BaseRender.__super.call(this);
  19511. this._sharedMaterials=[];
  19512. this._id=++BaseRender._uniqueIDCounter;
  19513. this._indexInCastShadowList=-1;
  19514. this._bounds=new Bounds(Vector3._ZERO,Vector3._ZERO);
  19515. if (Render.supportWebGLPlusCulling){
  19516. var length=FrustumCulling._cullingBufferLength;
  19517. this._cullingBufferIndex=length;
  19518. var cullingBuffer=FrustumCulling._cullingBuffer;
  19519. var resizeLength=length+7;
  19520. if (resizeLength >=cullingBuffer.length){
  19521. var temp=cullingBuffer;
  19522. cullingBuffer=FrustumCulling._cullingBuffer=new Float32Array(cullingBuffer.length+4096);
  19523. cullingBuffer.set(temp,0);
  19524. }
  19525. cullingBuffer[length]=2;
  19526. FrustumCulling._cullingBufferLength=resizeLength;
  19527. }
  19528. this._renderElements=[];
  19529. this._owner=owner;
  19530. this._enable=true;
  19531. this._materialsInstance=[];
  19532. this._shaderValues=new ShaderData(null);
  19533. this._defineDatas=new DefineDatas();
  19534. this.lightmapIndex=-1;
  19535. this._castShadow=false;
  19536. this.receiveShadow=false;
  19537. this.sortingFudge=0.0;
  19538. (owner)&& (this._owner.transform.on(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this,this._onWorldMatNeedChange));
  19539. }
  19540. __class(BaseRender,'laya.d3.core.render.BaseRender',_super);
  19541. var __proto=BaseRender.prototype;
  19542. Laya.imps(__proto,{"laya.resource.ISingletonElement":true,"laya.d3.core.scene.IOctreeObject":true})
  19543. /**
  19544. *@private
  19545. */
  19546. __proto._getOctreeNode=function(){
  19547. return this._octreeNode;
  19548. }
  19549. /**
  19550. *@private
  19551. */
  19552. __proto._setOctreeNode=function(value){
  19553. this._octreeNode=value;
  19554. }
  19555. /**
  19556. *@private
  19557. */
  19558. __proto._getIndexInMotionList=function(){
  19559. return this._indexInOctreeMotionList;
  19560. }
  19561. /**
  19562. *@private
  19563. */
  19564. __proto._setIndexInMotionList=function(value){
  19565. this._indexInOctreeMotionList=value;
  19566. }
  19567. /**
  19568. *@private
  19569. */
  19570. __proto._changeMaterialReference=function(lastValue,value){
  19571. (lastValue)&& (lastValue._removeReference());
  19572. value._addReference();
  19573. }
  19574. /**
  19575. *@private
  19576. */
  19577. __proto._getInstanceMaterial=function(material,index){
  19578. var insMat=/*__JS__ */new material.constructor();
  19579. material.cloneTo(insMat);
  19580. insMat.name=insMat.name+"(Instance)";
  19581. this._materialsInstance[index]=true;
  19582. this._changeMaterialReference(this._sharedMaterials[index],insMat);
  19583. this._sharedMaterials[index]=insMat;
  19584. return insMat;
  19585. }
  19586. /**
  19587. *@private
  19588. */
  19589. __proto._applyLightMapParams=function(){
  19590. if (this._scene && this._lightmapIndex >=0){
  19591. var lightMaps=this._scene.getlightmaps();
  19592. if (this._lightmapIndex < lightMaps.length){
  19593. this._defineDatas.add(RenderableSprite3D.SAHDERDEFINE_LIGHTMAP);
  19594. this._shaderValues.setTexture(RenderableSprite3D.LIGHTMAP,lightMaps[this._lightmapIndex]);
  19595. }else {
  19596. this._defineDatas.remove(RenderableSprite3D.SAHDERDEFINE_LIGHTMAP);
  19597. }
  19598. }else {
  19599. this._defineDatas.remove(RenderableSprite3D.SAHDERDEFINE_LIGHTMAP);
  19600. }
  19601. }
  19602. /**
  19603. *@private
  19604. */
  19605. __proto._onWorldMatNeedChange=function(flag){
  19606. this._boundsChange=true;
  19607. if (this._octreeNode){
  19608. flag &=/*laya.d3.core.Transform3D.TRANSFORM_WORLDPOSITION*/0x08 | /*laya.d3.core.Transform3D.TRANSFORM_WORLDQUATERNION*/0x10 | /*laya.d3.core.Transform3D.TRANSFORM_WORLDSCALE*/0x20;
  19609. if (flag){
  19610. if (this._indexInOctreeMotionList===-1)
  19611. this._octreeNode._octree.addMotionObject(this);
  19612. }
  19613. }
  19614. }
  19615. /**
  19616. *@private
  19617. */
  19618. __proto._calculateBoundingBox=function(){
  19619. throw("BaseRender: must override it.");
  19620. }
  19621. /**
  19622. *@private [实现ISingletonElement接口]
  19623. */
  19624. __proto._getIndexInList=function(){
  19625. return this._indexInList;
  19626. }
  19627. /**
  19628. *@private [实现ISingletonElement接口]
  19629. */
  19630. __proto._setIndexInList=function(index){
  19631. this._indexInList=index;
  19632. }
  19633. /**
  19634. *@private
  19635. */
  19636. __proto._setBelongScene=function(scene){
  19637. if (this._scene!==scene){
  19638. this._scene=scene;
  19639. this._applyLightMapParams();
  19640. }
  19641. }
  19642. /**
  19643. *@private
  19644. *@param boundFrustum 如果boundFrustum为空则为摄像机不裁剪模式。
  19645. */
  19646. __proto._needRender=function(boundFrustum){
  19647. return true;
  19648. }
  19649. /**
  19650. *@private
  19651. */
  19652. __proto._renderUpdate=function(context,transform){}
  19653. /**
  19654. *@private
  19655. */
  19656. __proto._renderUpdateWithCamera=function(context,transform){}
  19657. /**
  19658. *@private
  19659. */
  19660. __proto._revertBatchRenderUpdate=function(context){}
  19661. /**
  19662. *@private
  19663. */
  19664. __proto._destroy=function(){
  19665. (this._indexInOctreeMotionList!==-1)&& (this._octreeNode._octree.removeMotionObject(this));
  19666. this.offAll();
  19667. var i=0,n=0;
  19668. for (i=0,n=this._renderElements.length;i < n;i++)
  19669. this._renderElements[i].destroy();
  19670. for (i=0,n=this._sharedMaterials.length;i < n;i++)
  19671. (this._sharedMaterials[i].destroyed)|| (this._sharedMaterials[i]._removeReference());
  19672. this._renderElements=null;
  19673. this._owner=null;
  19674. this._sharedMaterials=null;
  19675. this._bounds=null;
  19676. this._lightmapScaleOffset=null;
  19677. }
  19678. /**
  19679. *获取包围盒,只读,不允许修改其值。
  19680. *@return 包围盒。
  19681. */
  19682. __getset(0,__proto,'bounds',function(){
  19683. if (this._boundsChange){
  19684. this._calculateBoundingBox();
  19685. this._boundsChange=false;
  19686. }
  19687. return this._bounds;
  19688. });
  19689. /**
  19690. *获取唯一标识ID,通常用于识别。
  19691. */
  19692. __getset(0,__proto,'id',function(){
  19693. return this._id;
  19694. });
  19695. /**
  19696. *设置第一个实例材质。
  19697. *@param value 第一个实例材质。
  19698. */
  19699. /**
  19700. *返回第一个实例材质,第一次使用会拷贝实例对象。
  19701. *@return 第一个实例材质。
  19702. */
  19703. __getset(0,__proto,'material',function(){
  19704. var material=this._sharedMaterials[0];
  19705. if (material && !this._materialsInstance[0]){
  19706. var insMat=this._getInstanceMaterial(material,0);
  19707. var renderElement=this._renderElements[0];
  19708. (renderElement)&& (renderElement.material=insMat);
  19709. }
  19710. return this._sharedMaterials[0];
  19711. },function(value){
  19712. this.sharedMaterial=value;
  19713. });
  19714. /**
  19715. *是否是静态的一部分。
  19716. */
  19717. __getset(0,__proto,'isPartOfStaticBatch',function(){
  19718. return this._isPartOfStaticBatch;
  19719. });
  19720. /**
  19721. *设置第一个材质。
  19722. *@param value 第一个材质。
  19723. */
  19724. /**
  19725. *返回第一个材质。
  19726. *@return 第一个材质。
  19727. */
  19728. __getset(0,__proto,'sharedMaterial',function(){
  19729. return this._sharedMaterials[0];
  19730. },function(value){
  19731. var lastValue=this._sharedMaterials[0];
  19732. if (lastValue!==value){
  19733. this._sharedMaterials[0]=value;
  19734. this._materialsInstance[0]=false;
  19735. this._changeMaterialReference(lastValue,value);
  19736. var renderElement=this._renderElements[0];
  19737. (renderElement)&& (renderElement.material=value);
  19738. }
  19739. });
  19740. /**
  19741. *设置光照贴图的索引。
  19742. *@param value 光照贴图的索引。
  19743. */
  19744. /**
  19745. *获取光照贴图的索引。
  19746. *@return 光照贴图的索引。
  19747. */
  19748. __getset(0,__proto,'lightmapIndex',function(){
  19749. return this._lightmapIndex;
  19750. },function(value){
  19751. if (this._lightmapIndex!==value){
  19752. this._lightmapIndex=value;
  19753. this._applyLightMapParams();
  19754. }
  19755. });
  19756. /**
  19757. *设置光照贴图的缩放和偏移。
  19758. *@param 光照贴图的缩放和偏移。
  19759. */
  19760. /**
  19761. *获取光照贴图的缩放和偏移。
  19762. *@return 光照贴图的缩放和偏移。
  19763. */
  19764. __getset(0,__proto,'lightmapScaleOffset',function(){
  19765. return this._lightmapScaleOffset;
  19766. },function(value){
  19767. this._lightmapScaleOffset=value;
  19768. this._shaderValues.setVector(RenderableSprite3D.LIGHTMAPSCALEOFFSET,value);
  19769. this._defineDatas.add(RenderableSprite3D.SHADERDEFINE_SCALEOFFSETLIGHTINGMAPUV);
  19770. });
  19771. /**
  19772. *设置是否产生阴影。
  19773. *@param value 是否产生阴影。
  19774. */
  19775. /**
  19776. *获取是否产生阴影。
  19777. *@return 是否产生阴影。
  19778. */
  19779. __getset(0,__proto,'castShadow',function(){
  19780. return this._castShadow;
  19781. },function(value){
  19782. if (this._castShadow!==value){
  19783. if (this._owner.activeInHierarchy){
  19784. if (value)
  19785. this._scene._addShadowCastRenderObject(this);
  19786. else
  19787. this._scene._removeShadowCastRenderObject(this);
  19788. }
  19789. this._castShadow=value;
  19790. }
  19791. });
  19792. /**
  19793. *设置是否可用。
  19794. *@param value 是否可用。
  19795. */
  19796. /**
  19797. *获取是否可用。
  19798. *@return 是否可用。
  19799. */
  19800. __getset(0,__proto,'enable',function(){
  19801. return this._enable;
  19802. },function(value){
  19803. this._enable=!!value;
  19804. });
  19805. /**
  19806. *设置实例材质列表。
  19807. *@param value 实例材质列表。
  19808. */
  19809. /**
  19810. *获取潜拷贝实例材质列表,第一次使用会拷贝实例对象。
  19811. *@return 浅拷贝实例材质列表。
  19812. */
  19813. __getset(0,__proto,'materials',function(){
  19814. for (var i=0,n=this._sharedMaterials.length;i < n;i++){
  19815. if (!this._materialsInstance[i]){
  19816. var insMat=this._getInstanceMaterial(this._sharedMaterials[i],i);
  19817. var renderElement=this._renderElements[i];
  19818. (renderElement)&& (renderElement.material=insMat);
  19819. }
  19820. }
  19821. return this._sharedMaterials.slice();
  19822. },function(value){
  19823. this.sharedMaterials=value;
  19824. });
  19825. /**
  19826. *设置材质列表。
  19827. *@param value 材质列表。
  19828. */
  19829. /**
  19830. *获取浅拷贝材质列表。
  19831. *@return 浅拷贝材质列表。
  19832. */
  19833. __getset(0,__proto,'sharedMaterials',function(){
  19834. return this._sharedMaterials.slice();
  19835. },function(value){
  19836. var mats=this._sharedMaterials;
  19837. for (var i=0,n=mats.length;i < n;i++)
  19838. mats[i]._removeReference();
  19839. if (value){
  19840. var count=value.length;
  19841. this._materialsInstance.length=count;
  19842. mats.length=count;
  19843. for (i=0;i < count;i++){
  19844. var lastMat=mats[i];
  19845. var mat=value[i];
  19846. if (lastMat!==mat){
  19847. this._materialsInstance[i]=false;
  19848. var renderElement=this._renderElements[i];
  19849. (renderElement)&& (renderElement.material=mat);
  19850. }
  19851. mat._addReference();
  19852. mats[i]=mat;
  19853. }
  19854. }else {
  19855. throw new Error("BaseRender: shadredMaterials value can't be null.");
  19856. }
  19857. });
  19858. /**
  19859. *设置是否接收阴影属性
  19860. */
  19861. /**
  19862. *获得是否接收阴影属性
  19863. */
  19864. __getset(0,__proto,'receiveShadow',function(){
  19865. return this._receiveShadow;
  19866. },function(value){
  19867. if (this._receiveShadow!==value){
  19868. this._receiveShadow=value;
  19869. if (value)
  19870. this._defineDatas.add(RenderableSprite3D.SHADERDEFINE_RECEIVE_SHADOW);
  19871. else
  19872. this._defineDatas.remove(RenderableSprite3D.SHADERDEFINE_RECEIVE_SHADOW);
  19873. }
  19874. });
  19875. BaseRender._uniqueIDCounter=0;
  19876. __static(BaseRender,
  19877. ['_tempBoundBoxCorners',function(){return this._tempBoundBoxCorners=/*new vector.<>*/[new Vector3(),new Vector3(),new Vector3(),new Vector3(),new Vector3(),new Vector3(),new Vector3(),new Vector3()];}
  19878. ]);
  19879. return BaseRender;
  19880. })(EventDispatcher)
  19881. /**
  19882. *<code>Script3D</code> 类用于创建脚本的父类,该类为抽象类,不允许实例。
  19883. */
  19884. //class laya.d3.component.Script3D extends laya.components.Component
  19885. var Script3D=(function(_super){
  19886. function Script3D(){
  19887. Script3D.__super.call(this);;
  19888. }
  19889. __class(Script3D,'laya.d3.component.Script3D',_super);
  19890. var __proto=Script3D.prototype;
  19891. /**
  19892. *@private
  19893. */
  19894. __proto._checkProcessTriggers=function(){
  19895. var prototype=laya.d3.component.Script3D.prototype;
  19896. if (this.onTriggerEnter!==prototype.onTriggerEnter)
  19897. return true;
  19898. if (this.onTriggerStay!==prototype.onTriggerStay)
  19899. return true;
  19900. if (this.onTriggerExit!==prototype.onTriggerExit)
  19901. return true;
  19902. return false;
  19903. }
  19904. /**
  19905. *@private
  19906. */
  19907. __proto._checkProcessCollisions=function(){
  19908. var prototype=laya.d3.component.Script3D.prototype;
  19909. if (this.onCollisionEnter!==prototype.onCollisionEnter)
  19910. return true;
  19911. if (this.onCollisionStay!==prototype.onCollisionStay)
  19912. return true;
  19913. if (this.onCollisionExit!==prototype.onCollisionExit)
  19914. return true;
  19915. return false;
  19916. }
  19917. /**
  19918. *@inheritDoc
  19919. */
  19920. __proto._onAwake=function(){
  19921. this.onAwake();
  19922. if (this.onStart!==laya.d3.component.Script3D.prototype.onStart)
  19923. Laya.startTimer.callLater(this,this.onStart);
  19924. }
  19925. /**
  19926. *@inheritDoc
  19927. */
  19928. __proto._onEnable=function(){
  19929. (this.owner)._scene._scriptPool.add(this);
  19930. var proto=laya.d3.component.Script3D.prototype;
  19931. if (this.onKeyDown!==proto.onKeyDown){
  19932. Laya.stage.on(/*laya.events.Event.KEY_DOWN*/"keydown",this,this.onKeyDown);
  19933. }
  19934. if (this.onKeyPress!==proto.onKeyPress){
  19935. Laya.stage.on(/*laya.events.Event.KEY_PRESS*/"keypress",this,this.onKeyUp);
  19936. }
  19937. if (this.onKeyUp!==proto.onKeyUp){
  19938. Laya.stage.on(/*laya.events.Event.KEY_UP*/"keyup",this,this.onKeyUp);
  19939. }
  19940. }
  19941. /**
  19942. *@inheritDoc
  19943. */
  19944. __proto._onDisable=function(){
  19945. (this.owner)._scene._scriptPool.remove(this);
  19946. this.owner.offAllCaller(this);
  19947. Laya.stage.offAllCaller(this);
  19948. }
  19949. /**
  19950. *@inheritDoc
  19951. */
  19952. __proto._isScript=function(){
  19953. return true;
  19954. }
  19955. /**
  19956. *@inheritDoc
  19957. */
  19958. __proto._onAdded=function(){
  19959. var sprite=this.owner;
  19960. var scripts=sprite._scripts;
  19961. scripts || (sprite._scripts=scripts=[]);
  19962. scripts.push(this);
  19963. if (!sprite._needProcessCollisions)
  19964. sprite._needProcessCollisions=this._checkProcessCollisions();
  19965. if (!sprite._needProcessTriggers)
  19966. sprite._needProcessTriggers=this._checkProcessTriggers();
  19967. }
  19968. /**
  19969. *@inheritDoc
  19970. */
  19971. __proto._onDestroy=function(){
  19972. var scripts=(this.owner)._scripts;
  19973. scripts.splice(scripts.indexOf(this),1);
  19974. var sprite=this.owner;
  19975. sprite._needProcessTriggers=false;
  19976. for (var i=0,n=scripts.length;i < n;i++){
  19977. if (scripts[i]._checkProcessTriggers()){
  19978. sprite._needProcessTriggers=true;
  19979. break ;
  19980. }
  19981. }
  19982. sprite._needProcessCollisions=false;
  19983. for (i=0,n=scripts.length;i < n;i++){
  19984. if (scripts[i]._checkProcessCollisions()){
  19985. sprite._needProcessCollisions=true;
  19986. break ;
  19987. }
  19988. }
  19989. this.onDestroy();
  19990. }
  19991. /**
  19992. *创建后只执行一次
  19993. *此方法为虚方法,使用时重写覆盖即可
  19994. */
  19995. __proto.onAwake=function(){}
  19996. /**
  19997. *每次启动后执行
  19998. *此方法为虚方法,使用时重写覆盖即可
  19999. */
  20000. __proto.onEnable=function(){}
  20001. /**
  20002. *第一次执行update之前执行,只会执行一次
  20003. *此方法为虚方法,使用时重写覆盖即可
  20004. */
  20005. __proto.onStart=function(){}
  20006. /**
  20007. *开始触发时执行
  20008. *此方法为虚方法,使用时重写覆盖即可
  20009. */
  20010. __proto.onTriggerEnter=function(other){}
  20011. /**
  20012. *持续触发时执行
  20013. *此方法为虚方法,使用时重写覆盖即可
  20014. */
  20015. __proto.onTriggerStay=function(other){}
  20016. /**
  20017. *结束触发时执行
  20018. *此方法为虚方法,使用时重写覆盖即可
  20019. */
  20020. __proto.onTriggerExit=function(other){}
  20021. /**
  20022. *开始碰撞时执行
  20023. *此方法为虚方法,使用时重写覆盖即可
  20024. */
  20025. __proto.onCollisionEnter=function(collision){}
  20026. /**
  20027. *持续碰撞时执行
  20028. *此方法为虚方法,使用时重写覆盖即可
  20029. */
  20030. __proto.onCollisionStay=function(collision){}
  20031. /**
  20032. *结束碰撞时执行
  20033. *此方法为虚方法,使用时重写覆盖即可
  20034. */
  20035. __proto.onCollisionExit=function(collision){}
  20036. /**
  20037. *鼠标按下时执行
  20038. *此方法为虚方法,使用时重写覆盖即可
  20039. */
  20040. __proto.onMouseDown=function(){}
  20041. /**
  20042. *鼠标拖拽时执行
  20043. *此方法为虚方法,使用时重写覆盖即可
  20044. */
  20045. __proto.onMouseDrag=function(){}
  20046. /**
  20047. *鼠标点击时执行
  20048. *此方法为虚方法,使用时重写覆盖即可
  20049. */
  20050. __proto.onMouseClick=function(){}
  20051. /**
  20052. *鼠标弹起时执行
  20053. *此方法为虚方法,使用时重写覆盖即可
  20054. */
  20055. __proto.onMouseUp=function(){}
  20056. /**
  20057. *鼠标进入时执行
  20058. *此方法为虚方法,使用时重写覆盖即可
  20059. */
  20060. __proto.onMouseEnter=function(){}
  20061. /**
  20062. *鼠标经过时执行
  20063. *此方法为虚方法,使用时重写覆盖即可
  20064. */
  20065. __proto.onMouseOver=function(){}
  20066. /**
  20067. *鼠标离开时执行
  20068. *此方法为虚方法,使用时重写覆盖即可
  20069. */
  20070. __proto.onMouseOut=function(){}
  20071. /**
  20072. *键盘按下时执行
  20073. *此方法为虚方法,使用时重写覆盖即可
  20074. */
  20075. __proto.onKeyDown=function(e){}
  20076. /**
  20077. *键盘产生一个字符时执行
  20078. *此方法为虚方法,使用时重写覆盖即可
  20079. */
  20080. __proto.onKeyPress=function(e){}
  20081. /**
  20082. *键盘抬起时执行
  20083. *此方法为虚方法,使用时重写覆盖即可
  20084. */
  20085. __proto.onKeyUp=function(e){}
  20086. /**
  20087. *每帧更新时执行
  20088. *此方法为虚方法,使用时重写覆盖即可
  20089. */
  20090. __proto.onUpdate=function(){}
  20091. /**
  20092. *每帧更新时执行,在update之后执行
  20093. *此方法为虚方法,使用时重写覆盖即可
  20094. */
  20095. __proto.onLateUpdate=function(){}
  20096. /**
  20097. *渲染之前执行
  20098. *此方法为虚方法,使用时重写覆盖即可
  20099. */
  20100. __proto.onPreRender=function(){}
  20101. /**
  20102. *渲染之后执行
  20103. *此方法为虚方法,使用时重写覆盖即可
  20104. */
  20105. __proto.onPostRender=function(){}
  20106. /**
  20107. *禁用时执行
  20108. *此方法为虚方法,使用时重写覆盖即可
  20109. */
  20110. __proto.onDisable=function(){}
  20111. /**
  20112. *销毁时执行
  20113. *此方法为虚方法,使用时重写覆盖即可
  20114. */
  20115. __proto.onDestroy=function(){}
  20116. /**
  20117. *@inheritDoc
  20118. */
  20119. __getset(0,__proto,'isSingleton',function(){
  20120. return false;
  20121. });
  20122. return Script3D;
  20123. })(Component)
  20124. /**
  20125. *<code>Transform3D</code> 类用于实现3D变换。
  20126. */
  20127. //class laya.d3.core.Transform3D extends laya.events.EventDispatcher
  20128. var Transform3D=(function(_super){
  20129. function Transform3D(owner){
  20130. /**@private */
  20131. this._owner=null;
  20132. /**@private */
  20133. this._children=null;
  20134. /**@private */
  20135. this._parent=null;
  20136. /**@private */
  20137. this._dummy=null;
  20138. /**@private */
  20139. this._transformFlag=0;
  20140. Transform3D.__super.call(this);
  20141. this._localPosition=new Vector3(0,0,0);
  20142. this._localRotation=new Quaternion(0,0,0,1);
  20143. this._localScale=new Vector3(1,1,1);
  20144. this._localRotationEuler=new Vector3(0,0,0);
  20145. this._localMatrix=new Matrix4x4();
  20146. this._position=new Vector3(0,0,0);
  20147. this._rotation=new Quaternion(0,0,0,1);
  20148. this._scale=new Vector3(1,1,1);
  20149. this._rotationEuler=new Vector3(0,0,0);
  20150. this._worldMatrix=new Matrix4x4();
  20151. this._owner=owner;
  20152. this._children=[];
  20153. this._setTransformFlag(0x01 | 0x02 | 0x04,false);
  20154. this._setTransformFlag(0x08 | 0x10 | 0x80 | 0x20 | 0x40,true);
  20155. }
  20156. __class(Transform3D,'laya.d3.core.Transform3D',_super);
  20157. var __proto=Transform3D.prototype;
  20158. /**
  20159. *@private
  20160. */
  20161. __proto._setTransformFlag=function(type,value){
  20162. if (value)
  20163. this._transformFlag |=type;
  20164. else
  20165. this._transformFlag &=~type;
  20166. }
  20167. /**
  20168. *@private
  20169. */
  20170. __proto._getTransformFlag=function(type){
  20171. return (this._transformFlag & type)!=0;
  20172. }
  20173. /**
  20174. *@private
  20175. */
  20176. __proto._setParent=function(value){
  20177. if (this._parent!==value){
  20178. if (this._parent){
  20179. var parentChilds=this._parent._children;
  20180. var index=parentChilds.indexOf(this);
  20181. parentChilds.splice(index,1);
  20182. }
  20183. if (value){
  20184. value._children.push(this);
  20185. (value)&& (this._onWorldTransform());
  20186. }
  20187. this._parent=value;
  20188. }
  20189. }
  20190. /**
  20191. *@private
  20192. */
  20193. __proto._updateLocalMatrix=function(){
  20194. Matrix4x4.createAffineTransformation(this._localPosition,this.localRotation,this._localScale,this._localMatrix);
  20195. }
  20196. /**
  20197. *@private
  20198. */
  20199. __proto._onWorldPositionRotationTransform=function(){
  20200. if (!this._getTransformFlag(0x40)|| !this._getTransformFlag(0x08)|| !this._getTransformFlag(0x10)|| !this._getTransformFlag(0x80)){
  20201. this._setTransformFlag(0x40 | 0x08 | 0x10 | 0x80,true);
  20202. this.event(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this._transformFlag);
  20203. for (var i=0,n=this._children.length;i < n;i++)
  20204. this._children[i]._onWorldPositionRotationTransform();
  20205. }
  20206. }
  20207. /**
  20208. *@private
  20209. */
  20210. __proto._onWorldPositionScaleTransform=function(){
  20211. if (!this._getTransformFlag(0x40)|| !this._getTransformFlag(0x08)|| !this._getTransformFlag(0x20)){
  20212. this._setTransformFlag(0x40 | 0x08 | 0x20,true);
  20213. this.event(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this._transformFlag);
  20214. for (var i=0,n=this._children.length;i < n;i++)
  20215. this._children[i]._onWorldPositionScaleTransform();
  20216. }
  20217. }
  20218. /**
  20219. *@private
  20220. */
  20221. __proto._onWorldPositionTransform=function(){
  20222. if (!this._getTransformFlag(0x40)|| !this._getTransformFlag(0x08)){
  20223. this._setTransformFlag(0x40 | 0x08,true);
  20224. this.event(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this._transformFlag);
  20225. for (var i=0,n=this._children.length;i < n;i++)
  20226. this._children[i]._onWorldPositionTransform();
  20227. }
  20228. }
  20229. /**
  20230. *@private
  20231. */
  20232. __proto._onWorldRotationTransform=function(){
  20233. if (!this._getTransformFlag(0x40)|| !this._getTransformFlag(0x10)|| !this._getTransformFlag(0x80)){
  20234. this._setTransformFlag(0x40 | 0x10 | 0x80,true);
  20235. this.event(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this._transformFlag);
  20236. for (var i=0,n=this._children.length;i < n;i++)
  20237. this._children[i]._onWorldPositionRotationTransform();
  20238. }
  20239. }
  20240. /**
  20241. *@private
  20242. */
  20243. __proto._onWorldScaleTransform=function(){
  20244. if (!this._getTransformFlag(0x40)|| !this._getTransformFlag(0x20)){
  20245. this._setTransformFlag(0x40 | 0x20,true);
  20246. this.event(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this._transformFlag);
  20247. for (var i=0,n=this._children.length;i < n;i++)
  20248. this._children[i]._onWorldPositionScaleTransform();
  20249. }
  20250. }
  20251. /**
  20252. *@private
  20253. */
  20254. __proto._onWorldTransform=function(){
  20255. if (!this._getTransformFlag(0x40)|| !this._getTransformFlag(0x08)|| !this._getTransformFlag(0x10)|| !this._getTransformFlag(0x80)|| !this._getTransformFlag(0x20)){
  20256. this._setTransformFlag(0x40 | 0x08 | 0x10 | 0x80 | 0x20,true);
  20257. this.event(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this._transformFlag);
  20258. for (var i=0,n=this._children.length;i < n;i++)
  20259. this._children[i]._onWorldTransform();
  20260. }
  20261. }
  20262. /**
  20263. *平移变换。
  20264. *@param translation 移动距离。
  20265. *@param isLocal 是否局部空间。
  20266. */
  20267. __proto.translate=function(translation,isLocal){
  20268. (isLocal===void 0)&& (isLocal=true);
  20269. if (isLocal){
  20270. Matrix4x4.createFromQuaternion(this.localRotation,Transform3D._tempMatrix0);
  20271. Vector3.transformCoordinate(translation,Transform3D._tempMatrix0,Transform3D._tempVector30);
  20272. Vector3.add(this.localPosition,Transform3D._tempVector30,this._localPosition);
  20273. this.localPosition=this._localPosition;
  20274. }else {
  20275. Vector3.add(this.position,translation,this._position);
  20276. this.position=this._position;
  20277. }
  20278. }
  20279. /**
  20280. *旋转变换。
  20281. *@param rotations 旋转幅度。
  20282. *@param isLocal 是否局部空间。
  20283. *@param isRadian 是否弧度制。
  20284. */
  20285. __proto.rotate=function(rotation,isLocal,isRadian){
  20286. (isLocal===void 0)&& (isLocal=true);
  20287. (isRadian===void 0)&& (isRadian=true);
  20288. var rot;
  20289. if (isRadian){
  20290. rot=rotation;
  20291. }else {
  20292. Vector3.scale(rotation,Math.PI / 180.0,Transform3D._tempVector30);
  20293. rot=Transform3D._tempVector30;
  20294. }
  20295. Quaternion.createFromYawPitchRoll(rot.y,rot.x,rot.z,Transform3D._tempQuaternion0);
  20296. if (isLocal){
  20297. Quaternion.multiply(this._localRotation,Transform3D._tempQuaternion0,this._localRotation);
  20298. this.localRotation=this._localRotation;
  20299. }else {
  20300. Quaternion.multiply(Transform3D._tempQuaternion0,this.rotation,this._rotation);
  20301. this.rotation=this._rotation;
  20302. }
  20303. }
  20304. /**
  20305. *获取向前方向。
  20306. *@param 前方向。
  20307. */
  20308. __proto.getForward=function(forward){
  20309. var worldMatElem=this.worldMatrix.elements;
  20310. forward.x=-worldMatElem[8];
  20311. forward.y=-worldMatElem[9];
  20312. forward.z=-worldMatElem[10];
  20313. }
  20314. /**
  20315. *获取向上方向。
  20316. *@param 上方向。
  20317. */
  20318. __proto.getUp=function(up){
  20319. var worldMatElem=this.worldMatrix.elements;
  20320. up.x=worldMatElem[4];
  20321. up.y=worldMatElem[5];
  20322. up.z=worldMatElem[6];
  20323. }
  20324. /**
  20325. *获取向右方向。
  20326. *@param 右方向。
  20327. */
  20328. __proto.getRight=function(right){
  20329. var worldMatElem=this.worldMatrix.elements;
  20330. right.x=worldMatElem[0];
  20331. right.y=worldMatElem[1];
  20332. right.z=worldMatElem[2];
  20333. }
  20334. /**
  20335. *观察目标位置。
  20336. *@param target 观察目标。
  20337. *@param up 向上向量。
  20338. *@param isLocal 是否局部空间。
  20339. */
  20340. __proto.lookAt=function(target,up,isLocal){
  20341. (isLocal===void 0)&& (isLocal=false);
  20342. var eye;
  20343. if (isLocal){
  20344. eye=this._localPosition;
  20345. if (Math.abs(eye.x-target.x)< MathUtils3D.zeroTolerance && Math.abs(eye.y-target.y)< MathUtils3D.zeroTolerance && Math.abs(eye.z-target.z)< MathUtils3D.zeroTolerance)
  20346. return;
  20347. Quaternion.lookAt(this._localPosition,target,up,this._localRotation);
  20348. this._localRotation.invert(this._localRotation);
  20349. this.localRotation=this._localRotation;
  20350. }else {
  20351. var worldPosition=this.position;
  20352. eye=worldPosition;
  20353. if (Math.abs(eye.x-target.x)< MathUtils3D.zeroTolerance && Math.abs(eye.y-target.y)< MathUtils3D.zeroTolerance && Math.abs(eye.z-target.z)< MathUtils3D.zeroTolerance)
  20354. return;
  20355. Quaternion.lookAt(worldPosition,target,up,this._rotation);
  20356. this._rotation.invert(this._rotation);
  20357. this.rotation=this._rotation;
  20358. }
  20359. }
  20360. /**
  20361. *@private
  20362. */
  20363. __getset(0,__proto,'_isFrontFaceInvert',function(){
  20364. var scale=this.scale;
  20365. var isInvert=scale.x < 0;
  20366. (scale.y < 0)&& (isInvert=!isInvert);
  20367. (scale.z < 0)&& (isInvert=!isInvert);
  20368. return isInvert;
  20369. });
  20370. /**
  20371. *获取所属精灵。
  20372. */
  20373. __getset(0,__proto,'owner',function(){
  20374. return this._owner;
  20375. });
  20376. /**
  20377. *设置局部位置Y轴分量。
  20378. *@param y 局部位置Y轴分量。
  20379. */
  20380. /**
  20381. *获取局部位置Y轴分量。
  20382. *@return 局部位置Y轴分量。
  20383. */
  20384. __getset(0,__proto,'localPositionY',function(){
  20385. return this._localPosition.y;
  20386. },function(y){
  20387. this._localPosition.y=y;
  20388. this.localPosition=this._localPosition;
  20389. });
  20390. /**
  20391. *设置局部缩放X。
  20392. *@param value 局部缩放X。
  20393. */
  20394. /**
  20395. *获取局部缩放X。
  20396. *@return 局部缩放X。
  20397. */
  20398. __getset(0,__proto,'localScaleX',function(){
  20399. return this._localScale.x;
  20400. },function(value){
  20401. this._localScale.x=value;
  20402. this.localScale=this._localScale;
  20403. });
  20404. /**
  20405. *获取世界矩阵是否需要更新。
  20406. *@return 世界矩阵是否需要更新。
  20407. */
  20408. __getset(0,__proto,'worldNeedUpdate',function(){
  20409. return this._getTransformFlag(0x40);
  20410. });
  20411. /**
  20412. *设置局部位置X轴分量。
  20413. *@param x 局部位置X轴分量。
  20414. */
  20415. /**
  20416. *获取局部位置X轴分量。
  20417. *@return 局部位置X轴分量。
  20418. */
  20419. __getset(0,__proto,'localPositionX',function(){
  20420. return this._localPosition.x;
  20421. },function(x){
  20422. this._localPosition.x=x;
  20423. this.localPosition=this._localPosition;
  20424. });
  20425. /**
  20426. *设置局部位置。
  20427. *@param value 局部位置。
  20428. */
  20429. /**
  20430. *获取局部位置。
  20431. *@return 局部位置。
  20432. */
  20433. __getset(0,__proto,'localPosition',function(){
  20434. return this._localPosition;
  20435. },function(value){
  20436. if (this._localPosition!==value)
  20437. value.cloneTo(this._localPosition);
  20438. this._setTransformFlag(0x04,true);
  20439. this._onWorldPositionTransform();
  20440. });
  20441. /**
  20442. *设置局部位置Z轴分量。
  20443. *@param z 局部位置Z轴分量。
  20444. */
  20445. /**
  20446. *获取局部位置Z轴分量。
  20447. *@return 局部位置Z轴分量。
  20448. */
  20449. __getset(0,__proto,'localPositionZ',function(){
  20450. return this._localPosition.z;
  20451. },function(z){
  20452. this._localPosition.z=z;
  20453. this.localPosition=this._localPosition;
  20454. });
  20455. /**
  20456. *设置局部旋转四元数X分量。
  20457. *@param x 局部旋转四元数X分量。
  20458. */
  20459. /**
  20460. *获取局部旋转四元数X分量。
  20461. *@return 局部旋转四元数X分量。
  20462. */
  20463. __getset(0,__proto,'localRotationX',function(){
  20464. return this.localRotation.x;
  20465. },function(x){
  20466. this._localRotation.x=x;
  20467. this.localRotation=this._localRotation;
  20468. });
  20469. /**
  20470. *设置局部旋转四元数Y分量。
  20471. *@param y 局部旋转四元数Y分量。
  20472. */
  20473. /**
  20474. *获取局部旋转四元数Y分量。
  20475. *@return 局部旋转四元数Y分量。
  20476. */
  20477. __getset(0,__proto,'localRotationY',function(){
  20478. return this.localRotation.y;
  20479. },function(y){
  20480. this._localRotation.y=y;
  20481. this.localRotation=this._localRotation;
  20482. });
  20483. /**
  20484. *设置局部旋转四元数Z分量。
  20485. *@param z 局部旋转四元数Z分量。
  20486. */
  20487. /**
  20488. *获取局部旋转四元数Z分量。
  20489. *@return 局部旋转四元数Z分量。
  20490. */
  20491. __getset(0,__proto,'localRotationZ',function(){
  20492. return this.localRotation.z;
  20493. },function(z){
  20494. this._localRotation.z=z;
  20495. this.localRotation=this._localRotation;
  20496. });
  20497. /**
  20498. *设置局部旋转四元数W分量。
  20499. *@param w 局部旋转四元数W分量。
  20500. */
  20501. /**
  20502. *获取局部旋转四元数W分量。
  20503. *@return 局部旋转四元数W分量。
  20504. */
  20505. __getset(0,__proto,'localRotationW',function(){
  20506. return this.localRotation.w;
  20507. },function(w){
  20508. this._localRotation.w=w;
  20509. this.localRotation=this._localRotation;
  20510. });
  20511. /**
  20512. *设置局部旋转。
  20513. *@param value 局部旋转。
  20514. */
  20515. /**
  20516. *获取局部旋转。
  20517. *@return 局部旋转。
  20518. */
  20519. __getset(0,__proto,'localRotation',function(){
  20520. if (this._getTransformFlag(0x01)){
  20521. var eulerE=this._localRotationEuler;
  20522. Quaternion.createFromYawPitchRoll(eulerE.y / Transform3D._angleToRandin,eulerE.x / Transform3D._angleToRandin,eulerE.z / Transform3D._angleToRandin,this._localRotation);
  20523. this._setTransformFlag(0x01,false);
  20524. }
  20525. return this._localRotation;
  20526. },function(value){
  20527. if (this._localRotation!==value)
  20528. value.cloneTo(this._localRotation);
  20529. this._localRotation.normalize(this._localRotation);
  20530. this._setTransformFlag(0x02 | 0x04,true);
  20531. this._setTransformFlag(0x01,false);
  20532. this._onWorldRotationTransform();
  20533. });
  20534. /**
  20535. *设置局部缩放Y。
  20536. *@param value 局部缩放Y。
  20537. */
  20538. /**
  20539. *获取局部缩放Y。
  20540. *@return 局部缩放Y。
  20541. */
  20542. __getset(0,__proto,'localScaleY',function(){
  20543. return this._localScale.y;
  20544. },function(value){
  20545. this._localScale.y=value;
  20546. this.localScale=this._localScale;
  20547. });
  20548. /**
  20549. *设置局部缩放Z。
  20550. *@param value 局部缩放Z。
  20551. */
  20552. /**
  20553. *获取局部缩放Z。
  20554. *@return 局部缩放Z。
  20555. */
  20556. __getset(0,__proto,'localScaleZ',function(){
  20557. return this._localScale.z;
  20558. },function(value){
  20559. this._localScale.z=value;
  20560. this.localScale=this._localScale;
  20561. });
  20562. /**
  20563. *设置世界位置。
  20564. *@param value 世界位置。
  20565. */
  20566. /**
  20567. *获取世界位置。
  20568. *@return 世界位置。
  20569. */
  20570. __getset(0,__proto,'position',function(){
  20571. if (this._getTransformFlag(0x08)){
  20572. if (this._parent !=null){
  20573. var parentPosition=this._parent.position;
  20574. Vector3.multiply(this._localPosition,this._parent.scale,Transform3D._tempVector30);
  20575. Vector3.transformQuat(Transform3D._tempVector30,this._parent.rotation,Transform3D._tempVector30);
  20576. Vector3.add(parentPosition,Transform3D._tempVector30,this._position);
  20577. }else {
  20578. this._localPosition.cloneTo(this._position);
  20579. }
  20580. this._setTransformFlag(0x08,false);
  20581. }
  20582. return this._position;
  20583. },function(value){
  20584. if (this._parent !=null){
  20585. Vector3.subtract(value,this._parent.position,this._localPosition);
  20586. var parentScale=this._parent.scale;
  20587. var psX=parentScale.x,psY=parentScale.y,psZ=parentScale.z;
  20588. if (psX!==1.0 || psY!==1.0 || psZ!==1.0){
  20589. var invertScale=Transform3D._tempVector30;
  20590. invertScale.x=1.0 / psX;
  20591. invertScale.y=1.0 / psY;
  20592. invertScale.z=1.0 / psZ;
  20593. Vector3.multiply(this._localPosition,invertScale,this._localPosition);
  20594. };
  20595. var parentRotation=this._parent.rotation;
  20596. parentRotation.invert(Transform3D._tempQuaternion0);
  20597. Vector3.transformQuat(this._localPosition,Transform3D._tempQuaternion0,this._localPosition);
  20598. }else {
  20599. value.cloneTo(this._localPosition);
  20600. }
  20601. this.localPosition=this._localPosition;
  20602. if (this._position!==value)
  20603. value.cloneTo(this._position);
  20604. this._setTransformFlag(0x08,false);
  20605. });
  20606. /**
  20607. *设置局部空间的Y轴欧拉角。
  20608. *@param value 局部空间的Y轴欧拉角。
  20609. */
  20610. /**
  20611. *获取局部空间的Y轴欧拉角。
  20612. *@return 局部空间的Y轴欧拉角。
  20613. */
  20614. __getset(0,__proto,'localRotationEulerY',function(){
  20615. return this.localRotationEuler.y;
  20616. },function(value){
  20617. this._localRotationEuler.y=value;
  20618. this.localRotationEuler=this._localRotationEuler;
  20619. });
  20620. /**
  20621. *设置局部缩放。
  20622. *@param value 局部缩放。
  20623. */
  20624. /**
  20625. *获取局部缩放。
  20626. *@return 局部缩放。
  20627. */
  20628. __getset(0,__proto,'localScale',function(){
  20629. return this._localScale;
  20630. },function(value){
  20631. if (this._localScale!==value)
  20632. value.cloneTo(this._localScale);
  20633. this._setTransformFlag(0x04,true);
  20634. this._onWorldScaleTransform();
  20635. });
  20636. /**
  20637. *设置局部空间的X轴欧拉角。
  20638. *@param value 局部空间的X轴欧拉角。
  20639. */
  20640. /**
  20641. *获取局部空间的X轴欧拉角。
  20642. *@return 局部空间的X轴欧拉角。
  20643. */
  20644. __getset(0,__proto,'localRotationEulerX',function(){
  20645. return this.localRotationEuler.x;
  20646. },function(value){
  20647. this._localRotationEuler.x=value;
  20648. this.localRotationEuler=this._localRotationEuler;
  20649. });
  20650. /**
  20651. *设置局部空间的Z轴欧拉角。
  20652. *@param value 局部空间的Z轴欧拉角。
  20653. */
  20654. /**
  20655. *获取局部空间的Z轴欧拉角。
  20656. *@return 局部空间的Z轴欧拉角。
  20657. */
  20658. __getset(0,__proto,'localRotationEulerZ',function(){
  20659. return this.localRotationEuler.z;
  20660. },function(value){
  20661. this._localRotationEuler.z=value;
  20662. this.localRotationEuler=this._localRotationEuler;
  20663. });
  20664. /**
  20665. *设置局部空间的欧拉角。
  20666. *@param value 欧拉角的旋转值。
  20667. */
  20668. /**
  20669. *获取局部空间欧拉角。
  20670. *@return 欧拉角的旋转值。
  20671. */
  20672. __getset(0,__proto,'localRotationEuler',function(){
  20673. if (this._getTransformFlag(0x02)){
  20674. this._localRotation.getYawPitchRoll(Transform3D._tempVector30);
  20675. var euler=Transform3D._tempVector30;
  20676. var localRotationEuler=this._localRotationEuler;
  20677. localRotationEuler.x=euler.y *Transform3D._angleToRandin;
  20678. localRotationEuler.y=euler.x *Transform3D._angleToRandin;
  20679. localRotationEuler.z=euler.z *Transform3D._angleToRandin;
  20680. this._setTransformFlag(0x02,false);
  20681. }
  20682. return this._localRotationEuler;
  20683. },function(value){
  20684. if (this._localRotationEuler!==value)
  20685. value.cloneTo(this._localRotationEuler);
  20686. this._setTransformFlag(0x02,false);
  20687. this._setTransformFlag(0x01 | 0x04,true);
  20688. this._onWorldRotationTransform();
  20689. });
  20690. /**
  20691. *设置局部矩阵。
  20692. *@param value 局部矩阵。
  20693. */
  20694. /**
  20695. *获取局部矩阵。
  20696. *@return 局部矩阵。
  20697. */
  20698. __getset(0,__proto,'localMatrix',function(){
  20699. if (this._getTransformFlag(0x04)){
  20700. this._updateLocalMatrix();
  20701. this._setTransformFlag(0x04,false);
  20702. }
  20703. return this._localMatrix;
  20704. },function(value){
  20705. if (this._localMatrix!==value)
  20706. value.cloneTo(this._localMatrix);
  20707. this._localMatrix.decomposeTransRotScale(this._localPosition,this._localRotation,this._localScale);
  20708. this._setTransformFlag(0x04,false);
  20709. this._onWorldTransform();
  20710. });
  20711. /**
  20712. *设置世界旋转。
  20713. *@param value 世界旋转。
  20714. */
  20715. /**
  20716. *获取世界旋转。
  20717. *@return 世界旋转。
  20718. */
  20719. __getset(0,__proto,'rotation',function(){
  20720. if (this._getTransformFlag(0x10)){
  20721. if (this._parent !=null)
  20722. Quaternion.multiply(this._parent.rotation,this.localRotation,this._rotation);
  20723. else
  20724. this.localRotation.cloneTo(this._rotation);
  20725. this._setTransformFlag(0x10,false);
  20726. }
  20727. return this._rotation;
  20728. },function(value){
  20729. if (this._parent !=null){
  20730. this._parent.rotation.invert(Transform3D._tempQuaternion0);
  20731. Quaternion.multiply(Transform3D._tempQuaternion0,value,this._localRotation);
  20732. }else {
  20733. value.cloneTo(this._localRotation);
  20734. }
  20735. this.localRotation=this._localRotation;
  20736. if (value!==this._rotation)
  20737. value.cloneTo(this._rotation);
  20738. this._setTransformFlag(0x10,false);
  20739. });
  20740. /**
  20741. *设置世界缩放。
  20742. *@param value 世界缩放。
  20743. */
  20744. /**
  20745. *获取世界缩放。
  20746. *@return 世界缩放。
  20747. */
  20748. __getset(0,__proto,'scale',function(){
  20749. if (!this._getTransformFlag(0x20))
  20750. return this._scale;
  20751. if (this._parent!==null)
  20752. Vector3.multiply(this._parent.scale,this._localScale,this._scale);
  20753. else
  20754. this._localScale.cloneTo(this._scale);
  20755. this._setTransformFlag(0x20,false);
  20756. return this._scale;
  20757. },function(value){
  20758. if (this._parent!==null){
  20759. var parScale=this._parent.scale;
  20760. var invParScale=Transform3D._tempVector30;
  20761. invParScale.x=1.0 / parScale.x;
  20762. invParScale.y=1.0 / parScale.y;
  20763. invParScale.z=1.0 / parScale.z;
  20764. Vector3.multiply(value,Transform3D._tempVector30,this._localScale);
  20765. }else {
  20766. value.cloneTo(this._localScale);
  20767. }
  20768. this.localScale=this._localScale;
  20769. if (this._scale!==value)
  20770. value.cloneTo(this._scale);
  20771. this._setTransformFlag(0x20,false);
  20772. });
  20773. /**
  20774. *设置世界空间的旋转角度。
  20775. *@param 欧拉角的旋转值,顺序为x、y、z。
  20776. */
  20777. /**
  20778. *获取世界空间的旋转角度。
  20779. *@return 欧拉角的旋转值,顺序为x、y、z。
  20780. */
  20781. __getset(0,__proto,'rotationEuler',function(){
  20782. if (this._getTransformFlag(0x80)){
  20783. this.rotation.getYawPitchRoll(Transform3D._tempVector30);
  20784. var eulerE=Transform3D._tempVector30;
  20785. var rotationEulerE=this._rotationEuler;
  20786. rotationEulerE.x=eulerE.y *Transform3D._angleToRandin;
  20787. rotationEulerE.y=eulerE.x *Transform3D._angleToRandin;
  20788. rotationEulerE.z=eulerE.z *Transform3D._angleToRandin;
  20789. this._setTransformFlag(0x80,false);
  20790. }
  20791. return this._rotationEuler;
  20792. },function(value){
  20793. Quaternion.createFromYawPitchRoll(value.y / Transform3D._angleToRandin,value.x / Transform3D._angleToRandin,value.z / Transform3D._angleToRandin,this._rotation);
  20794. this.rotation=this._rotation;
  20795. if (this._rotationEuler!==value)
  20796. value.cloneTo(this._rotationEuler);
  20797. this._setTransformFlag(0x80,false);
  20798. });
  20799. /**
  20800. *设置世界矩阵。
  20801. *@param value 世界矩阵。
  20802. */
  20803. /**
  20804. *获取世界矩阵。
  20805. *@return 世界矩阵。
  20806. */
  20807. __getset(0,__proto,'worldMatrix',function(){
  20808. if (this._getTransformFlag(0x40)){
  20809. if (this._parent !=null)
  20810. Matrix4x4.multiply(this._parent.worldMatrix,this.localMatrix,this._worldMatrix);
  20811. else
  20812. this.localMatrix.cloneTo(this._worldMatrix);
  20813. this._setTransformFlag(0x40,false);
  20814. }
  20815. return this._worldMatrix;
  20816. },function(value){
  20817. if (this._parent===null){
  20818. value.cloneTo(this._localMatrix);
  20819. }else {
  20820. this._parent.worldMatrix.invert(this._localMatrix);
  20821. Matrix4x4.multiply(this._localMatrix,value,this._localMatrix);
  20822. }
  20823. this.localMatrix=this._localMatrix;
  20824. if (this._worldMatrix!==value)
  20825. value.cloneTo(this._worldMatrix);
  20826. this._setTransformFlag(0x40,false);
  20827. });
  20828. Transform3D.TRANSFORM_LOCALQUATERNION=0x01;
  20829. Transform3D.TRANSFORM_LOCALEULER=0x02;
  20830. Transform3D.TRANSFORM_LOCALMATRIX=0x04;
  20831. Transform3D.TRANSFORM_WORLDPOSITION=0x08;
  20832. Transform3D.TRANSFORM_WORLDQUATERNION=0x10;
  20833. Transform3D.TRANSFORM_WORLDSCALE=0x20;
  20834. Transform3D.TRANSFORM_WORLDMATRIX=0x40;
  20835. Transform3D.TRANSFORM_WORLDEULER=0x80;
  20836. __static(Transform3D,
  20837. ['_tempVector30',function(){return this._tempVector30=new Vector3();},'_tempVector31',function(){return this._tempVector31=new Vector3();},'_tempVector32',function(){return this._tempVector32=new Vector3();},'_tempVector33',function(){return this._tempVector33=new Vector3();},'_tempQuaternion0',function(){return this._tempQuaternion0=new Quaternion();},'_tempMatrix0',function(){return this._tempMatrix0=new Matrix4x4();},'_angleToRandin',function(){return this._angleToRandin=180 / Math.PI;}
  20838. ]);
  20839. return Transform3D;
  20840. })(EventDispatcher)
  20841. /**
  20842. *<code>Animator</code> 类用于创建动画组件。
  20843. */
  20844. //class laya.d3.component.Animator extends laya.components.Component
  20845. var Animator=(function(_super){
  20846. function Animator(){
  20847. /**@private */
  20848. //this._speed=NaN;
  20849. /**@private */
  20850. //this._keyframeNodeOwnerMap=null;
  20851. /**@private */
  20852. //this._updateMark=0;
  20853. /**@private */
  20854. //this._controllerLayers=null;
  20855. /**@private */
  20856. //this._linkSprites=null;
  20857. /**@private */
  20858. //this._avatarNodeMap=null;
  20859. /**@private */
  20860. this._linkAvatarSpritesData={};
  20861. /**@private [NATIVE]*/
  20862. //this._animationNodeLocalPositions=null;
  20863. /**@private [NATIVE]*/
  20864. //this._animationNodeLocalRotations=null;
  20865. /**@private [NATIVE]*/
  20866. //this._animationNodeLocalScales=null;
  20867. /**@private [NATIVE]*/
  20868. //this._animationNodeWorldMatrixs=null;
  20869. /**@private [NATIVE]*/
  20870. //this._animationNodeParentIndices=null;
  20871. /**@private */
  20872. //this._avatar=null;
  20873. this._keyframeNodeOwners=[];
  20874. this._linkAvatarSprites=[];
  20875. this._renderableSprites=[];
  20876. this.cullingMode=2;
  20877. Animator.__super.call(this);
  20878. this._controllerLayers=[];
  20879. this._linkSprites={};
  20880. this._speed=1.0;
  20881. this._keyframeNodeOwnerMap={};
  20882. this._updateMark=0;
  20883. }
  20884. __class(Animator,'laya.d3.component.Animator',_super);
  20885. var __proto=Animator.prototype;
  20886. /**
  20887. *@private
  20888. */
  20889. __proto._linkToSprites=function(linkSprites){
  20890. for (var k in linkSprites){
  20891. var nodeOwner=this.owner;
  20892. var path=linkSprites[k];
  20893. for (var j=0,m=path.length;j < m;j++){
  20894. var p=path[j];
  20895. if (p===""){
  20896. break ;
  20897. }else {
  20898. nodeOwner=nodeOwner.getChildByName(p);
  20899. if (!nodeOwner)
  20900. break ;
  20901. }
  20902. }
  20903. (nodeOwner)&& (this.linkSprite3DToAvatarNode(k,nodeOwner));
  20904. }
  20905. }
  20906. /**
  20907. *@private
  20908. */
  20909. __proto._addKeyframeNodeOwner=function(clipOwners,node,propertyOwner){
  20910. var nodeIndex=node._indexInList;
  20911. var fullPath=node.fullPath;
  20912. var keyframeNodeOwner=this._keyframeNodeOwnerMap[fullPath];
  20913. if (keyframeNodeOwner){
  20914. keyframeNodeOwner.referenceCount++;
  20915. clipOwners[nodeIndex]=keyframeNodeOwner;
  20916. }else {
  20917. var property=propertyOwner;
  20918. for (var i=0,n=node.propertyCount;i < n;i++){
  20919. property=property[node.getPropertyByIndex(i)];
  20920. if (!property)
  20921. break ;
  20922. }
  20923. keyframeNodeOwner=this._keyframeNodeOwnerMap[fullPath]=new KeyframeNodeOwner();
  20924. keyframeNodeOwner.fullPath=fullPath;
  20925. keyframeNodeOwner.indexInList=this._keyframeNodeOwners.length;
  20926. keyframeNodeOwner.referenceCount=1;
  20927. keyframeNodeOwner.propertyOwner=propertyOwner;
  20928. var propertyCount=node.propertyCount;
  20929. var propertys=__newvec(propertyCount);
  20930. for (i=0;i < propertyCount;i++)
  20931. propertys[i]=node.getPropertyByIndex(i);
  20932. keyframeNodeOwner.property=propertys;
  20933. keyframeNodeOwner.type=node.type;
  20934. if (property){
  20935. if (node.type===0){
  20936. keyframeNodeOwner.defaultValue=property;
  20937. }else {
  20938. var defaultValue=new property.constructor();
  20939. property.cloneTo(defaultValue);
  20940. keyframeNodeOwner.defaultValue=defaultValue;
  20941. }
  20942. }
  20943. this._keyframeNodeOwners.push(keyframeNodeOwner);
  20944. clipOwners[nodeIndex]=keyframeNodeOwner;
  20945. }
  20946. }
  20947. /**
  20948. *@private
  20949. */
  20950. __proto._removeKeyframeNodeOwner=function(nodeOwners,node){
  20951. var fullPath=node.fullPath;
  20952. var keyframeNodeOwner=this._keyframeNodeOwnerMap[fullPath];
  20953. if (keyframeNodeOwner){
  20954. keyframeNodeOwner.referenceCount--;
  20955. if (keyframeNodeOwner.referenceCount===0){
  20956. delete this._keyframeNodeOwnerMap[fullPath];
  20957. this._keyframeNodeOwners.splice(this._keyframeNodeOwners.indexOf(keyframeNodeOwner),1);
  20958. }
  20959. nodeOwners[node._indexInList]=null;
  20960. }
  20961. }
  20962. /**
  20963. *@private
  20964. */
  20965. __proto._getOwnersByClip=function(clipStateInfo){
  20966. var frameNodes=clipStateInfo._clip._nodes;
  20967. var frameNodesCount=frameNodes.count;
  20968. var nodeOwners=clipStateInfo._nodeOwners;
  20969. nodeOwners.length=frameNodesCount;
  20970. for (var i=0;i < frameNodesCount;i++){
  20971. var node=frameNodes.getNodeByIndex(i);
  20972. var property=this._avatar ? this._avatarNodeMap[this._avatar._rootNode.name] :this.owner;
  20973. for (var j=0,m=node.ownerPathCount;j < m;j++){
  20974. var ownPat=node.getOwnerPathByIndex(j);
  20975. if (ownPat===""){
  20976. break ;
  20977. }else {
  20978. property=property.getChildByName(ownPat);
  20979. if (!property)
  20980. break ;
  20981. }
  20982. }
  20983. if (property){
  20984. var propertyOwner=node.propertyOwner;
  20985. (propertyOwner)&& (property=property[propertyOwner]);
  20986. property && this._addKeyframeNodeOwner(nodeOwners,node,property);
  20987. }
  20988. }
  20989. }
  20990. /**
  20991. *@private
  20992. */
  20993. __proto._updatePlayer=function(animatorState,playState,elapsedTime,islooping){
  20994. var clipDuration=animatorState._clip._duration *(animatorState.clipEnd-animatorState.clipStart);
  20995. var lastElapsedTime=playState._elapsedTime;
  20996. var elapsedPlaybackTime=lastElapsedTime+elapsedTime;
  20997. playState._lastElapsedTime=lastElapsedTime;
  20998. playState._elapsedTime=elapsedPlaybackTime;
  20999. var normalizedTime=elapsedPlaybackTime / clipDuration;
  21000. playState._normalizedTime=normalizedTime;
  21001. var playTime=normalizedTime % 1.0;
  21002. playState._normalizedPlayTime=playTime < 0 ? playTime+1.0 :playTime;
  21003. playState._duration=clipDuration;
  21004. var scripts=animatorState._scripts;
  21005. if ((!islooping && elapsedPlaybackTime >=clipDuration)){
  21006. playState._finish=true;
  21007. playState._elapsedTime=clipDuration;
  21008. playState._normalizedPlayTime=1.0;
  21009. if (scripts){
  21010. for (var i=0,n=scripts.length;i < n;i++)
  21011. scripts[i].onStateExit();
  21012. }
  21013. return;
  21014. }
  21015. if (scripts){
  21016. for (i=0,n=scripts.length;i < n;i++)
  21017. scripts[i].onStateUpdate();
  21018. }
  21019. }
  21020. /**
  21021. *@private
  21022. */
  21023. __proto._eventScript=function(scripts,events,eventIndex,endTime,front){
  21024. if (front){
  21025. for (var n=events.length;eventIndex < n;eventIndex++){
  21026. var event=events[eventIndex];
  21027. if (event.time <=endTime){
  21028. for (var j=0,m=scripts.length;j < m;j++){
  21029. var script=scripts[j];
  21030. var fun=script[event.eventName];
  21031. (fun)&& (fun.apply(script,event.params));
  21032. }
  21033. }else {
  21034. break ;
  21035. }
  21036. }
  21037. }else {
  21038. for (;eventIndex >=0;eventIndex--){
  21039. event=events[eventIndex];
  21040. if (event.time >=endTime){
  21041. for (j=0,m=scripts.length;j < m;j++){
  21042. script=scripts[j];
  21043. fun=script[event.eventName];
  21044. (fun)&& (fun.apply(script,event.params));
  21045. }
  21046. }else {
  21047. break ;
  21048. }
  21049. }
  21050. }
  21051. return eventIndex;
  21052. }
  21053. /**
  21054. *@private
  21055. */
  21056. __proto._updateEventScript=function(stateInfo,playStateInfo){
  21057. var scripts=(this.owner)._scripts;
  21058. if (scripts){
  21059. var clip=stateInfo._clip;
  21060. var events=clip._events;
  21061. var clipDuration=clip._duration;
  21062. var elapsedTime=playStateInfo._elapsedTime;
  21063. var time=elapsedTime % clipDuration;
  21064. var loopCount=Math.abs(Math.floor(elapsedTime / clipDuration)-Math.floor(playStateInfo._lastElapsedTime / clipDuration));
  21065. var frontPlay=playStateInfo._elapsedTime >=playStateInfo._lastElapsedTime;
  21066. if (playStateInfo._lastIsFront!==frontPlay){
  21067. if (frontPlay)
  21068. playStateInfo._playEventIndex++;
  21069. else
  21070. playStateInfo._playEventIndex--;
  21071. playStateInfo._lastIsFront=frontPlay;
  21072. }
  21073. if (loopCount==0){
  21074. playStateInfo._playEventIndex=this._eventScript(scripts,events,playStateInfo._playEventIndex,time,frontPlay);
  21075. }else {
  21076. if (frontPlay){
  21077. this._eventScript(scripts,events,playStateInfo._playEventIndex,clipDuration,true);
  21078. for (var i=0,n=loopCount-1;i < n;i++)
  21079. this._eventScript(scripts,events,0,clipDuration,true);
  21080. playStateInfo._playEventIndex=this._eventScript(scripts,events,0,time,true);
  21081. }else {
  21082. this._eventScript(scripts,events,playStateInfo._playEventIndex,0,false);
  21083. var eventIndex=events.length-1;
  21084. for (i=0,n=loopCount-1;i < n;i++)
  21085. this._eventScript(scripts,events,eventIndex,0,false);
  21086. playStateInfo._playEventIndex=this._eventScript(scripts,events,eventIndex,time,false);
  21087. }
  21088. }
  21089. }
  21090. }
  21091. /**
  21092. *@private
  21093. */
  21094. __proto._updateClipDatas=function(animatorState,addtive,playStateInfo,scale){
  21095. var clip=animatorState._clip;
  21096. var clipDuration=clip._duration;
  21097. var curPlayTime=animatorState.clipStart *clipDuration+playStateInfo._normalizedPlayTime *playStateInfo._duration;
  21098. var currentFrameIndices=animatorState._currentFrameIndices;
  21099. var frontPlay=playStateInfo._elapsedTime > playStateInfo._lastElapsedTime;
  21100. clip._evaluateClipDatasRealTime(clip._nodes,curPlayTime,currentFrameIndices,addtive,frontPlay);
  21101. }
  21102. /**
  21103. *@private
  21104. */
  21105. __proto._applyFloat=function(pro,proName,nodeOwner,additive,weight,isFirstLayer,data){
  21106. if (nodeOwner.updateMark===this._updateMark){
  21107. if (additive){
  21108. pro[proName]+=weight *(data);
  21109. }else {
  21110. var oriValue=pro[proName];
  21111. pro[proName]=oriValue+weight *(data-oriValue);
  21112. }
  21113. }else {
  21114. if (isFirstLayer){
  21115. if (additive)
  21116. pro[proName]=nodeOwner.defaultValue+data;
  21117. else
  21118. pro[proName]=data;
  21119. }else {
  21120. if (additive){
  21121. pro[proName]=nodeOwner.defaultValue+weight *(data);
  21122. }else {
  21123. var defValue=nodeOwner.defaultValue;
  21124. pro[proName]=defValue+weight *(data-defValue);
  21125. }
  21126. }
  21127. }
  21128. }
  21129. /**
  21130. *@private
  21131. */
  21132. __proto._applyPositionAndRotationEuler=function(nodeOwner,additive,weight,isFirstLayer,data,out){
  21133. if (nodeOwner.updateMark===this._updateMark){
  21134. if (additive){
  21135. out.x+=weight *data.x;
  21136. out.y+=weight *data.y;
  21137. out.z+=weight *data.z;
  21138. }else {
  21139. var oriX=out.x;
  21140. var oriY=out.y;
  21141. var oriZ=out.z;
  21142. out.x=oriX+weight *(data.x-oriX);
  21143. out.y=oriY+weight *(data.y-oriY);
  21144. out.z=oriZ+weight *(data.z-oriZ);
  21145. }
  21146. }else {
  21147. if (isFirstLayer){
  21148. if (additive){
  21149. var defValue=nodeOwner.defaultValue;
  21150. out.x=defValue.x+data.x;
  21151. out.y=defValue.y+data.y;
  21152. out.z=defValue.z+data.z;
  21153. }else {
  21154. out.x=data.x;
  21155. out.y=data.y;
  21156. out.z=data.z;
  21157. }
  21158. }else {
  21159. defValue=nodeOwner.defaultValue;
  21160. if (additive){
  21161. out.x=defValue.x+weight *data.x;
  21162. out.y=defValue.y+weight *data.y;
  21163. out.z=defValue.z+weight *data.z;
  21164. }else {
  21165. var defX=defValue.x;
  21166. var defY=defValue.y;
  21167. var defZ=defValue.z;
  21168. out.x=defX+weight *(data.x-defX);
  21169. out.y=defY+weight *(data.y-defY);
  21170. out.z=defZ+weight *(data.z-defZ);
  21171. }
  21172. }
  21173. }
  21174. }
  21175. /**
  21176. *@private
  21177. */
  21178. __proto._applyRotation=function(nodeOwner,additive,weight,isFirstLayer,clipRot,localRotation){
  21179. if (nodeOwner.updateMark===this._updateMark){
  21180. if (additive){
  21181. var tempQuat=Animator._tempQuaternion1;
  21182. Utils3D.quaternionWeight(clipRot,weight,tempQuat);
  21183. tempQuat.normalize(tempQuat);
  21184. Quaternion.multiply(localRotation,tempQuat,localRotation);
  21185. }else {
  21186. Quaternion.lerp(localRotation,clipRot,weight,localRotation);
  21187. }
  21188. }else {
  21189. if (isFirstLayer){
  21190. if (additive){
  21191. var defaultRot=nodeOwner.defaultValue;
  21192. Quaternion.multiply(defaultRot,clipRot,localRotation);
  21193. }else {
  21194. localRotation.x=clipRot.x;
  21195. localRotation.y=clipRot.y;
  21196. localRotation.z=clipRot.z;
  21197. localRotation.w=clipRot.w;
  21198. }
  21199. }else {
  21200. defaultRot=nodeOwner.defaultValue;
  21201. if (additive){
  21202. tempQuat=Animator._tempQuaternion1;
  21203. Utils3D.quaternionWeight(clipRot,weight,tempQuat);
  21204. tempQuat.normalize(tempQuat);
  21205. Quaternion.multiply(defaultRot,tempQuat,localRotation);
  21206. }else {
  21207. Quaternion.lerp(defaultRot,clipRot,weight,localRotation);
  21208. }
  21209. }
  21210. }
  21211. }
  21212. /**
  21213. *@private
  21214. */
  21215. __proto._applyScale=function(nodeOwner,additive,weight,isFirstLayer,clipSca,localScale){
  21216. if (nodeOwner.updateMark===this._updateMark){
  21217. if (additive){
  21218. var scale=Animator._tempVector31;
  21219. Utils3D.scaleWeight(clipSca,weight,scale);
  21220. localScale.x=localScale.x *scale.x;
  21221. localScale.y=localScale.y *scale.y;
  21222. localScale.z=localScale.z *scale.z;
  21223. }else {
  21224. Utils3D.scaleBlend(localScale,clipSca,weight,localScale);
  21225. }
  21226. }else {
  21227. if (isFirstLayer){
  21228. if (additive){
  21229. var defaultSca=nodeOwner.defaultValue;
  21230. localScale.x=defaultSca.x *clipSca.x;
  21231. localScale.y=defaultSca.y *clipSca.y;
  21232. localScale.z=defaultSca.z *clipSca.z;
  21233. }else {
  21234. localScale.x=clipSca.x;
  21235. localScale.y=clipSca.y;
  21236. localScale.z=clipSca.z;
  21237. }
  21238. }else {
  21239. defaultSca=nodeOwner.defaultValue;
  21240. if (additive){
  21241. scale=Animator._tempVector31;
  21242. Utils3D.scaleWeight(clipSca,weight,scale);
  21243. localScale.x=defaultSca.x *scale.x;
  21244. localScale.y=defaultSca.y *scale.y;
  21245. localScale.z=defaultSca.z *scale.z;
  21246. }else {
  21247. Utils3D.scaleBlend(defaultSca,clipSca,weight,localScale);
  21248. }
  21249. }
  21250. }
  21251. }
  21252. /**
  21253. *@private
  21254. */
  21255. __proto._applyCrossData=function(nodeOwner,additive,weight,isFirstLayer,srcValue,desValue,crossWeight){
  21256. var pro=nodeOwner.propertyOwner;
  21257. if (pro){
  21258. switch (nodeOwner.type){
  21259. case 0:;
  21260. var proPat=nodeOwner.property;
  21261. var m=proPat.length-1;
  21262. for (var j=0;j < m;j++){
  21263. pro=pro[proPat[j]];
  21264. if (!pro)
  21265. break ;
  21266. };
  21267. var crossValue=srcValue+crossWeight *(desValue-srcValue);
  21268. this._applyFloat(pro,proPat[m],nodeOwner,additive,weight,isFirstLayer,crossValue);
  21269. break ;
  21270. case 1:;
  21271. var localPos=pro.localPosition;
  21272. var position=Animator._tempVector30;
  21273. var srcX=srcValue.x,srcY=srcValue.y,srcZ=srcValue.z;
  21274. position.x=srcX+crossWeight *(desValue.x-srcX);
  21275. position.y=srcY+crossWeight *(desValue.y-srcY);
  21276. position.z=srcZ+crossWeight *(desValue.z-srcZ);
  21277. this._applyPositionAndRotationEuler(nodeOwner,additive,weight,isFirstLayer,position,localPos);
  21278. pro.localPosition=localPos;
  21279. break ;
  21280. case 2:;
  21281. var localRot=pro.localRotation;
  21282. var rotation=Animator._tempQuaternion0;
  21283. Quaternion.lerp(srcValue,desValue,crossWeight,rotation);
  21284. this._applyRotation(nodeOwner,additive,weight,isFirstLayer,rotation,localRot);
  21285. pro.localRotation=localRot;
  21286. break ;
  21287. case 3:;
  21288. var localSca=pro.localScale;
  21289. var scale=Animator._tempVector30;
  21290. Utils3D.scaleBlend(srcValue,desValue,crossWeight,scale);
  21291. this._applyScale(nodeOwner,additive,weight,isFirstLayer,scale,localSca);
  21292. pro.localScale=localSca;
  21293. break ;
  21294. case 4:;
  21295. var localEuler=pro.localRotationEuler;
  21296. var rotationEuler=Animator._tempVector30;
  21297. srcX=srcValue.x,srcY=srcValue.y,srcZ=srcValue.z;
  21298. rotationEuler.x=srcX+crossWeight *(desValue.x-srcX);
  21299. rotationEuler.y=srcY+crossWeight *(desValue.y-srcY);
  21300. rotationEuler.z=srcZ+crossWeight *(desValue.z-srcZ);
  21301. this._applyPositionAndRotationEuler(nodeOwner,additive,weight,isFirstLayer,rotationEuler,localEuler);
  21302. pro.localRotationEuler=localEuler;
  21303. break ;
  21304. }
  21305. nodeOwner.updateMark=this._updateMark;
  21306. }
  21307. }
  21308. /**
  21309. *@private
  21310. */
  21311. __proto._setClipDatasToNode=function(stateInfo,additive,weight,isFirstLayer){
  21312. var nodes=stateInfo._clip._nodes;
  21313. var nodeOwners=stateInfo._nodeOwners;
  21314. for (var i=0,n=nodes.count;i < n;i++){
  21315. var nodeOwner=nodeOwners[i];
  21316. if (nodeOwner){
  21317. var pro=nodeOwner.propertyOwner;
  21318. if (pro){
  21319. switch (nodeOwner.type){
  21320. case 0:;
  21321. var proPat=nodeOwner.property;
  21322. var m=proPat.length-1;
  21323. for (var j=0;j < m;j++){
  21324. pro=pro[proPat[j]];
  21325. if (!pro)
  21326. break ;
  21327. }
  21328. this._applyFloat(pro,proPat[m],nodeOwner,additive,weight,isFirstLayer,nodes.getNodeByIndex(i).data);
  21329. break ;
  21330. case 1:;
  21331. var localPos=pro.localPosition;
  21332. this._applyPositionAndRotationEuler(nodeOwner,additive,weight,isFirstLayer,nodes.getNodeByIndex(i).data,localPos);
  21333. pro.localPosition=localPos;
  21334. break ;
  21335. case 2:;
  21336. var localRot=pro.localRotation;
  21337. this._applyRotation(nodeOwner,additive,weight,isFirstLayer,nodes.getNodeByIndex(i).data,localRot);
  21338. pro.localRotation=localRot;
  21339. break ;
  21340. case 3:;
  21341. var localSca=pro.localScale;
  21342. this._applyScale(nodeOwner,additive,weight,isFirstLayer,nodes.getNodeByIndex(i).data,localSca);
  21343. pro.localScale=localSca;
  21344. break ;
  21345. case 4:;
  21346. var localEuler=pro.localRotationEuler;
  21347. this._applyPositionAndRotationEuler(nodeOwner,additive,weight,isFirstLayer,nodes.getNodeByIndex(i).data,localEuler);
  21348. pro.localRotationEuler=localEuler;
  21349. break ;
  21350. }
  21351. nodeOwner.updateMark=this._updateMark;
  21352. }
  21353. }
  21354. }
  21355. }
  21356. /**
  21357. *@private
  21358. */
  21359. __proto._setCrossClipDatasToNode=function(controllerLayer,srcState,destState,crossWeight,isFirstLayer){
  21360. var nodeOwners=controllerLayer._crossNodesOwners;
  21361. var ownerCount=controllerLayer._crossNodesOwnersCount;
  21362. var additive=controllerLayer.blendingMode!==AnimatorControllerLayer.BLENDINGMODE_OVERRIDE;
  21363. var weight=controllerLayer.defaultWeight;
  21364. var destDataIndices=controllerLayer._destCrossClipNodeIndices;
  21365. var destNodes=destState._clip._nodes;
  21366. var destNodeOwners=destState._nodeOwners;
  21367. var srcDataIndices=controllerLayer._srcCrossClipNodeIndices;
  21368. var srcNodeOwners=srcState._nodeOwners;
  21369. var srcNodes=srcState._clip._nodes;
  21370. for (var i=0;i < ownerCount;i++){
  21371. var nodeOwner=nodeOwners[i];
  21372. if (nodeOwner){
  21373. var srcIndex=srcDataIndices[i];
  21374. var destIndex=destDataIndices[i];
  21375. var srcValue=srcIndex!==-1 ? srcNodes.getNodeByIndex(srcIndex).data :destNodeOwners[destIndex].defaultValue;
  21376. var desValue=destIndex!==-1 ? destNodes.getNodeByIndex(destIndex).data :srcNodeOwners[srcIndex].defaultValue;
  21377. this._applyCrossData(nodeOwner,additive,weight,isFirstLayer,srcValue,desValue,crossWeight);
  21378. }
  21379. }
  21380. }
  21381. /**
  21382. *@private
  21383. */
  21384. __proto._setFixedCrossClipDatasToNode=function(controllerLayer,destState,crossWeight,isFirstLayer){
  21385. var nodeOwners=controllerLayer._crossNodesOwners;
  21386. var ownerCount=controllerLayer._crossNodesOwnersCount;
  21387. var additive=controllerLayer.blendingMode!==AnimatorControllerLayer.BLENDINGMODE_OVERRIDE;
  21388. var weight=controllerLayer.defaultWeight;
  21389. var destDataIndices=controllerLayer._destCrossClipNodeIndices;
  21390. var destNodes=destState._clip._nodes;
  21391. for (var i=0;i < ownerCount;i++){
  21392. var nodeOwner=nodeOwners[i];
  21393. if (nodeOwner){
  21394. var destIndex=destDataIndices[i];
  21395. var srcValue=nodeOwner.crossFixedValue;
  21396. var desValue=destIndex!==-1 ? destNodes.getNodeByIndex(destIndex).data :nodeOwner.defaultValue;
  21397. this._applyCrossData(nodeOwner,additive,weight,isFirstLayer,srcValue,desValue,crossWeight);
  21398. }
  21399. }
  21400. }
  21401. /**
  21402. *@private
  21403. */
  21404. __proto._revertDefaultKeyframeNodes=function(clipStateInfo){
  21405. var nodeOwners=clipStateInfo._nodeOwners;
  21406. for (var i=0,n=nodeOwners.length;i < n;i++){
  21407. var nodeOwner=nodeOwners[i];
  21408. if (nodeOwner){
  21409. var pro=nodeOwner.propertyOwner;
  21410. if (pro){
  21411. switch (nodeOwner.type){
  21412. case 0:;
  21413. var proPat=nodeOwner.property;
  21414. var m=proPat.length-1;
  21415. for (var j=0;j < m;j++){
  21416. pro=pro[proPat[j]];
  21417. if (!pro)
  21418. break ;
  21419. }
  21420. pro[proPat[m]]=nodeOwner.defaultValue;
  21421. break ;
  21422. case 1:;
  21423. var locPos=pro.localPosition;
  21424. var def=nodeOwner.defaultValue;
  21425. locPos.x=def.x;
  21426. locPos.y=def.y;
  21427. locPos.z=def.z;
  21428. pro.localPosition=locPos;
  21429. break ;
  21430. case 2:;
  21431. var locRot=pro.localRotation;
  21432. var defQua=nodeOwner.defaultValue;
  21433. locRot.x=defQua.x;
  21434. locRot.y=defQua.y;
  21435. locRot.z=defQua.z;
  21436. locRot.w=defQua.w;
  21437. pro.localRotation=locRot;
  21438. break ;
  21439. case 3:;
  21440. var locSca=pro.localScale;
  21441. def=nodeOwner.defaultValue;
  21442. locSca.x=def.x;
  21443. locSca.y=def.y;
  21444. locSca.z=def.z;
  21445. pro.localScale=locSca;
  21446. break ;
  21447. case 4:;
  21448. var locEul=pro.localRotationEuler;
  21449. def=nodeOwner.defaultValue;
  21450. locEul.x=def.x;
  21451. locEul.y=def.y;
  21452. locEul.z=def.z;
  21453. pro.localRotationEuler=locEul;
  21454. break ;
  21455. default :
  21456. throw "Animator:unknown type.";
  21457. }
  21458. }
  21459. }
  21460. }
  21461. }
  21462. /**
  21463. *@private
  21464. */
  21465. __proto._removeClip=function(clipStateInfos,statesMap,index,state){
  21466. var clip=state._clip;
  21467. clip._removeReference();
  21468. clipStateInfos.splice(index,1);
  21469. delete statesMap[state.name];
  21470. var clipStateInfo=clipStateInfos[index];
  21471. var frameNodes=clip._nodes;
  21472. var nodeOwners=clipStateInfo._nodeOwners;
  21473. for (var i=0,n=frameNodes.count;i < n;i++)
  21474. this._removeKeyframeNodeOwner(nodeOwners,frameNodes.getNodeByIndex(i));
  21475. }
  21476. /**
  21477. *@inheritDoc
  21478. */
  21479. __proto._onAdded=function(){
  21480. var parent=this.owner._parent;
  21481. (this.owner)._setHierarchyAnimator(this,parent ? (parent)._hierarchyAnimator :null);
  21482. (this.owner)._changeAnimatorToLinkSprite3DNoAvatar(this,true,/*new vector.<>*/[]);
  21483. }
  21484. /**
  21485. *@inheritDoc
  21486. */
  21487. __proto._onDestroy=function(){
  21488. for (var i=0,n=this._controllerLayers.length;i < n;i++){
  21489. var clipStateInfos=this._controllerLayers[i]._states;
  21490. for (var j=0,m=clipStateInfos.length;j < m;j++)
  21491. clipStateInfos[j]._clip._removeReference();
  21492. };
  21493. var parent=this.owner._parent;
  21494. (this.owner)._clearHierarchyAnimator(this,parent ? (parent)._hierarchyAnimator :null);
  21495. }
  21496. /**
  21497. *@inheritDoc
  21498. */
  21499. __proto._onEnableInScene=function(){
  21500. (this.owner._scene)._animatorPool.add(this);
  21501. }
  21502. /**
  21503. *@inheritDoc
  21504. */
  21505. __proto._onDisableInScene=function(){
  21506. (this.owner._scene)._animatorPool.remove(this);
  21507. }
  21508. /**
  21509. *@inheritDoc
  21510. */
  21511. __proto._onEnable=function(){
  21512. for (var i=0,n=this._controllerLayers.length;i < n;i++){
  21513. if (this._controllerLayers[i].playOnWake){
  21514. var defaultClip=this.getDefaultState(i);
  21515. (defaultClip)&& (this.play(null,i,0));
  21516. }
  21517. }
  21518. }
  21519. /**
  21520. *@private
  21521. */
  21522. __proto._handleSpriteOwnersBySprite=function(isLink,path,sprite){
  21523. for (var i=0,n=this._controllerLayers.length;i < n;i++){
  21524. var clipStateInfos=this._controllerLayers[i]._states;
  21525. for (var j=0,m=clipStateInfos.length;j < m;j++){
  21526. var clipStateInfo=clipStateInfos[j];
  21527. var clip=clipStateInfo._clip;
  21528. var nodePath=path.join("/");
  21529. var ownersNodes=clip._nodesMap[nodePath];
  21530. if (ownersNodes){
  21531. var nodeOwners=clipStateInfo._nodeOwners;
  21532. for (var k=0,p=ownersNodes.length;k < p;k++){
  21533. if (isLink)
  21534. this._addKeyframeNodeOwner(nodeOwners,ownersNodes[k],sprite);
  21535. else
  21536. this._removeKeyframeNodeOwner(nodeOwners,ownersNodes[k]);
  21537. }
  21538. }
  21539. }
  21540. }
  21541. }
  21542. /**
  21543. *@inheritDoc
  21544. */
  21545. __proto._parse=function(data){
  21546. var avatarData=data.avatar;
  21547. if (avatarData){
  21548. this.avatar=Loader.getRes(avatarData.path);
  21549. var linkSprites=avatarData.linkSprites;
  21550. this._linkSprites=linkSprites;
  21551. this._linkToSprites(linkSprites);
  21552. };
  21553. var clipPaths=data.clipPaths;
  21554. var play=data.playOnWake;
  21555. var layersData=data.layers;
  21556. for (var i=0;i < layersData.length;i++){
  21557. var layerData=layersData[i];
  21558. var animatorLayer=new AnimatorControllerLayer(layerData.name);
  21559. if (i===0)
  21560. animatorLayer.defaultWeight=1.0;
  21561. else
  21562. animatorLayer.defaultWeight=layerData.weight;
  21563. var blendingModeData=layerData.blendingMode;
  21564. (blendingModeData)&& (animatorLayer.blendingMode=blendingModeData);
  21565. this.addControllerLayer(animatorLayer);
  21566. var states=layerData.states;
  21567. for (var j=0,m=states.length;j < m;j++){
  21568. var state=states[j];
  21569. var clipPath=state.clipPath;
  21570. if (clipPath){
  21571. var name=state.name;
  21572. var motion;
  21573. motion=Loader.getRes(clipPath);
  21574. if (motion){
  21575. var animatorState=new AnimatorState();
  21576. animatorState.name=name;
  21577. animatorState.clip=motion;
  21578. this.addState(animatorState,i);
  21579. (j===0)&& (this.getControllerLayer(i).defaultState=animatorState);
  21580. }
  21581. }
  21582. }
  21583. (play!==undefined)&& (animatorLayer.playOnWake=play);
  21584. };
  21585. var cullingModeData=data.cullingMode;
  21586. (cullingModeData!==undefined)&& (this.cullingMode=cullingModeData);
  21587. }
  21588. /**
  21589. *@private
  21590. */
  21591. __proto._update=function(){
  21592. if (this._speed===0)
  21593. return;
  21594. var needRender=false;
  21595. if (this.cullingMode===2){
  21596. needRender=false;
  21597. for (var i=0,n=this._renderableSprites.length;i < n;i++){
  21598. if (this._renderableSprites[i]._render._visible){
  21599. needRender=true;
  21600. break ;
  21601. }
  21602. }
  21603. }else {
  21604. needRender=true;
  21605. }
  21606. this._updateMark++;
  21607. var timer=(this.owner._scene).timer;
  21608. var delta=timer._delta / 1000.0;
  21609. var timerScale=timer.scale;
  21610. for (i=0,n=this._controllerLayers.length;i < n;i++){
  21611. var controllerLayer=this._controllerLayers[i];
  21612. var playStateInfo=controllerLayer._playStateInfo;
  21613. var crossPlayStateInfo=controllerLayer._crossPlayStateInfo;
  21614. addtive=controllerLayer.blendingMode!==AnimatorControllerLayer.BLENDINGMODE_OVERRIDE;
  21615. switch (controllerLayer._playType){
  21616. case 0:;
  21617. var animatorState=controllerLayer._currentPlayState;
  21618. var clip=animatorState._clip;
  21619. var speed=this._speed *animatorState.speed;
  21620. var finish=playStateInfo._finish;
  21621. finish || this._updatePlayer(animatorState,playStateInfo,delta *speed,clip.islooping);
  21622. if (needRender){
  21623. var addtive=controllerLayer.blendingMode!==AnimatorControllerLayer.BLENDINGMODE_OVERRIDE;
  21624. this._updateClipDatas(animatorState,addtive,playStateInfo,timerScale *speed);
  21625. this._setClipDatasToNode(animatorState,addtive,controllerLayer.defaultWeight,i===0);
  21626. finish || this._updateEventScript(animatorState,playStateInfo);
  21627. }
  21628. break ;
  21629. case 1:
  21630. animatorState=controllerLayer._currentPlayState;
  21631. clip=animatorState._clip;
  21632. var crossClipState=controllerLayer._crossPlayState;
  21633. var crossClip=crossClipState._clip;
  21634. var crossDuratuion=controllerLayer._crossDuration;
  21635. var startPlayTime=crossPlayStateInfo._startPlayTime;
  21636. var crossClipDuration=crossClip._duration-startPlayTime;
  21637. var crossScale=crossDuratuion > crossClipDuration ? crossClipDuration / crossDuratuion :1.0;
  21638. var crossSpeed=this._speed *crossClipState.speed;
  21639. this._updatePlayer(crossClipState,crossPlayStateInfo,delta *crossScale *crossSpeed,crossClip.islooping);
  21640. var crossWeight=((crossPlayStateInfo._elapsedTime-startPlayTime)/ crossScale)/ crossDuratuion;
  21641. if (crossWeight >=1.0){
  21642. if (needRender){
  21643. this._updateClipDatas(crossClipState,addtive,crossPlayStateInfo,timerScale *crossSpeed);
  21644. this._setClipDatasToNode(crossClipState,addtive,controllerLayer.defaultWeight,i===0);
  21645. controllerLayer._playType=0;
  21646. controllerLayer._currentPlayState=crossClipState;
  21647. crossPlayStateInfo._cloneTo(playStateInfo);
  21648. }
  21649. }else {
  21650. if (!playStateInfo._finish){
  21651. speed=this._speed *animatorState.speed;
  21652. this._updatePlayer(animatorState,playStateInfo,delta *speed,clip.islooping);
  21653. if (needRender){
  21654. this._updateClipDatas(animatorState,addtive,playStateInfo,timerScale *speed);
  21655. }
  21656. }
  21657. if (needRender){
  21658. this._updateClipDatas(crossClipState,addtive,crossPlayStateInfo,timerScale *crossScale *crossSpeed);
  21659. this._setCrossClipDatasToNode(controllerLayer,animatorState,crossClipState,crossWeight,i===0);
  21660. }
  21661. }
  21662. if (needRender){
  21663. this._updateEventScript(animatorState,playStateInfo);
  21664. this._updateEventScript(crossClipState,crossPlayStateInfo);
  21665. }
  21666. break ;
  21667. case 2:
  21668. crossClipState=controllerLayer._crossPlayState;
  21669. crossClip=crossClipState._clip;
  21670. crossDuratuion=controllerLayer._crossDuration;
  21671. startPlayTime=crossPlayStateInfo._startPlayTime;
  21672. crossClipDuration=crossClip._duration-startPlayTime;
  21673. crossScale=crossDuratuion > crossClipDuration ? crossClipDuration / crossDuratuion :1.0;
  21674. crossSpeed=this._speed *crossClipState.speed;
  21675. this._updatePlayer(crossClipState,crossPlayStateInfo,delta *crossScale *crossSpeed,crossClip.islooping);
  21676. if (needRender){
  21677. crossWeight=((crossPlayStateInfo._elapsedTime-startPlayTime)/ crossScale)/ crossDuratuion;
  21678. if (crossWeight >=1.0){
  21679. this._updateClipDatas(crossClipState,addtive,crossPlayStateInfo,timerScale *crossSpeed);
  21680. this._setClipDatasToNode(crossClipState,addtive,1.0,i===0);
  21681. controllerLayer._playType=0;
  21682. controllerLayer._currentPlayState=crossClipState;
  21683. crossPlayStateInfo._cloneTo(playStateInfo);
  21684. }else {
  21685. this._updateClipDatas(crossClipState,addtive,crossPlayStateInfo,timerScale *crossScale *crossSpeed);
  21686. this._setFixedCrossClipDatasToNode(controllerLayer,crossClipState,crossWeight,i===0);
  21687. }
  21688. this._updateEventScript(crossClipState,crossPlayStateInfo);
  21689. }
  21690. break ;
  21691. }
  21692. }
  21693. if (needRender){
  21694. if (this._avatar){
  21695. Render.supportWebGLPlusAnimation && this._updateAnimationNodeWorldMatix(this._animationNodeLocalPositions,this._animationNodeLocalRotations,this._animationNodeLocalScales,this._animationNodeWorldMatrixs,this._animationNodeParentIndices);
  21696. this._updateAvatarNodesToSprite();
  21697. }
  21698. }
  21699. }
  21700. /**
  21701. *@private
  21702. */
  21703. __proto._cloneTo=function(dest){
  21704. var animator=dest;
  21705. animator.avatar=this.avatar;
  21706. for (var i=0,n=this._controllerLayers.length;i < n;i++){
  21707. var controllLayer=this._controllerLayers[i];
  21708. animator.addControllerLayer(controllLayer.clone());
  21709. var animatorStates=controllLayer._states;
  21710. for (var j=0,m=animatorStates.length;j < m;j++){
  21711. var state=animatorStates[j].clone();
  21712. animator.addState(state,i);
  21713. (j==0)&& (animator.getControllerLayer(i).defaultState=state);
  21714. }
  21715. }
  21716. animator._linkSprites=this._linkSprites;
  21717. animator._linkToSprites(this._linkSprites);
  21718. }
  21719. /**
  21720. *获取默认动画状态。
  21721. *@param layerIndex 层索引。
  21722. *@return 默认动画状态。
  21723. */
  21724. __proto.getDefaultState=function(layerIndex){
  21725. (layerIndex===void 0)&& (layerIndex=0);
  21726. var controllerLayer=this._controllerLayers[layerIndex];
  21727. return controllerLayer.defaultState;
  21728. }
  21729. /**
  21730. *添加动画状态。
  21731. *@param state 动画状态。
  21732. *@param layerIndex 层索引。
  21733. */
  21734. __proto.addState=function(state,layerIndex){
  21735. (layerIndex===void 0)&& (layerIndex=0);
  21736. var stateName=state.name;
  21737. var controllerLayer=this._controllerLayers[layerIndex];
  21738. var statesMap=controllerLayer._statesMap;
  21739. var states=controllerLayer._states;
  21740. if (statesMap[stateName]){
  21741. throw "Animator:this stat's name has exist.";
  21742. }else {
  21743. statesMap[stateName]=state;
  21744. states.push(state);
  21745. state._clip._addReference();
  21746. this._getOwnersByClip(state);
  21747. }
  21748. }
  21749. /**
  21750. *移除动画状态。
  21751. *@param state 动画状态。
  21752. *@param layerIndex 层索引。
  21753. */
  21754. __proto.removeState=function(state,layerIndex){
  21755. (layerIndex===void 0)&& (layerIndex=0);
  21756. var controllerLayer=this._controllerLayers[layerIndex];
  21757. var clipStateInfos=controllerLayer._states;
  21758. var statesMap=controllerLayer._statesMap;
  21759. var index=-1;
  21760. for (var i=0,n=clipStateInfos.length;i < n;i++){
  21761. if (clipStateInfos[i]===state){
  21762. index=i;
  21763. break ;
  21764. }
  21765. }
  21766. if (index!==-1)
  21767. this._removeClip(clipStateInfos,statesMap,index,state);
  21768. }
  21769. /**
  21770. *添加控制器层。
  21771. */
  21772. __proto.addControllerLayer=function(controllderLayer){
  21773. this._controllerLayers.push(controllderLayer);
  21774. }
  21775. /**
  21776. *获取控制器层。
  21777. */
  21778. __proto.getControllerLayer=function(layerInex){
  21779. (layerInex===void 0)&& (layerInex=0);
  21780. return this._controllerLayers[layerInex];
  21781. }
  21782. /**
  21783. *获取当前的播放状态。
  21784. *@param layerIndex 层索引。
  21785. *@return 动画播放状态。
  21786. */
  21787. __proto.getCurrentAnimatorPlayState=function(layerInex){
  21788. (layerInex===void 0)&& (layerInex=0);
  21789. return this._controllerLayers[layerInex]._playStateInfo;
  21790. }
  21791. /**
  21792. *播放动画。
  21793. *@param name 如果为null则播放默认动画,否则按名字播放动画片段。
  21794. *@param layerIndex 层索引。
  21795. *@param normalizedTime 归一化的播放起始时间。
  21796. */
  21797. __proto.play=function(name,layerIndex,normalizedTime){
  21798. (layerIndex===void 0)&& (layerIndex=0);
  21799. (normalizedTime===void 0)&& (normalizedTime=Number.NEGATIVE_INFINITY);
  21800. var controllerLayer=this._controllerLayers[layerIndex];
  21801. var defaultState=controllerLayer.defaultState;
  21802. if (!name && !defaultState)
  21803. throw new Error("Animator:must have default clip value,please set clip property.");
  21804. var curPlayState=controllerLayer._currentPlayState;
  21805. var playStateInfo=controllerLayer._playStateInfo;
  21806. var animatorState=name ? controllerLayer._statesMap[name] :defaultState;
  21807. var clipDuration=animatorState._clip._duration;
  21808. if (curPlayState!==animatorState){
  21809. if (normalizedTime!==Number.NEGATIVE_INFINITY)
  21810. playStateInfo._resetPlayState(clipDuration *normalizedTime);
  21811. else
  21812. playStateInfo._resetPlayState(0.0);
  21813. (curPlayState!==null && curPlayState!==animatorState)&& (this._revertDefaultKeyframeNodes(curPlayState));
  21814. controllerLayer._playType=0;
  21815. controllerLayer._currentPlayState=animatorState;
  21816. }else {
  21817. if (normalizedTime!==Number.NEGATIVE_INFINITY){
  21818. playStateInfo._resetPlayState(clipDuration *normalizedTime);
  21819. controllerLayer._playType=0;
  21820. }
  21821. };
  21822. var scripts=animatorState._scripts;
  21823. if (scripts){
  21824. for (var i=0,n=scripts.length;i < n;i++)
  21825. scripts[i].onStateEnter();
  21826. }
  21827. }
  21828. /**
  21829. *在当前动画状态和目标动画状态之间进行融合过渡播放。
  21830. *@param name 目标动画状态。
  21831. *@param transitionDuration 过渡时间,该值为当前动画状态的归一化时间,值在0.0~1.0之间。
  21832. *@param layerIndex 层索引。
  21833. *@param normalizedTime 归一化的播放起始时间。
  21834. */
  21835. __proto.crossFade=function(name,transitionDuration,layerIndex,normalizedTime){
  21836. (layerIndex===void 0)&& (layerIndex=0);
  21837. (normalizedTime===void 0)&& (normalizedTime=Number.NEGATIVE_INFINITY);
  21838. var controllerLayer=this._controllerLayers[layerIndex];
  21839. var destAnimatorState=controllerLayer._statesMap[name];
  21840. if (destAnimatorState){
  21841. var playType=controllerLayer._playType;
  21842. if (playType===-1){
  21843. this.play(name,layerIndex,normalizedTime);
  21844. return;
  21845. };
  21846. var crossPlayStateInfo=controllerLayer._crossPlayStateInfo;
  21847. var crossNodeOwners=controllerLayer._crossNodesOwners;
  21848. var crossNodeOwnerIndicesMap=controllerLayer._crossNodesOwnersIndicesMap;
  21849. var srcAnimatorState=controllerLayer._currentPlayState;
  21850. var destNodeOwners=destAnimatorState._nodeOwners;
  21851. var destCrossClipNodeIndices=controllerLayer._destCrossClipNodeIndices;
  21852. var destClip=destAnimatorState._clip;
  21853. var destNodes=destClip._nodes;
  21854. var destNodesMap=destClip._nodesDic;
  21855. switch (playType){
  21856. case 0:;
  21857. var srcNodeOwners=srcAnimatorState._nodeOwners;
  21858. var scrCrossClipNodeIndices=controllerLayer._srcCrossClipNodeIndices;
  21859. var srcClip=srcAnimatorState._clip;
  21860. var srcNodes=srcClip._nodes;
  21861. var srcNodesMap=srcClip._nodesDic;
  21862. controllerLayer._playType=1;
  21863. var crossMark=++controllerLayer._crossMark;
  21864. var crossCount=controllerLayer._crossNodesOwnersCount=0;
  21865. for (var i=0,n=srcNodes.count;i < n;i++){
  21866. var srcNode=srcNodes.getNodeByIndex(i);
  21867. var srcIndex=srcNode._indexInList;
  21868. var srcNodeOwner=srcNodeOwners[srcIndex];
  21869. if (srcNodeOwner){
  21870. var srcFullPath=srcNode.fullPath;
  21871. scrCrossClipNodeIndices[crossCount]=srcIndex;
  21872. var destNode=destNodesMap[srcFullPath];
  21873. if (destNode)
  21874. destCrossClipNodeIndices[crossCount]=destNode._indexInList;
  21875. else
  21876. destCrossClipNodeIndices[crossCount]=-1;
  21877. crossNodeOwnerIndicesMap[srcFullPath]=crossMark;
  21878. crossNodeOwners[crossCount]=srcNodeOwner;
  21879. crossCount++;
  21880. }
  21881. }
  21882. for (i=0,n=destNodes.count;i < n;i++){
  21883. destNode=destNodes.getNodeByIndex(i);
  21884. var destIndex=destNode._indexInList;
  21885. var destNodeOwner=destNodeOwners[destIndex];
  21886. if (destNodeOwner){
  21887. var destFullPath=destNode.fullPath;
  21888. if (!srcNodesMap[destFullPath]){
  21889. scrCrossClipNodeIndices[crossCount]=-1;
  21890. destCrossClipNodeIndices[crossCount]=destIndex;
  21891. crossNodeOwnerIndicesMap[destFullPath]=crossMark;
  21892. crossNodeOwners[crossCount]=destNodeOwner;
  21893. crossCount++;
  21894. }
  21895. }
  21896. }
  21897. break ;
  21898. case 1:
  21899. case 2:
  21900. controllerLayer._playType=2;
  21901. for (i=0,n=crossNodeOwners.length;i < n;i++){
  21902. var nodeOwner=crossNodeOwners[i];
  21903. nodeOwner.saveCrossFixedValue();
  21904. destNode=destNodesMap[nodeOwner.fullPath];
  21905. if (destNode)
  21906. destCrossClipNodeIndices[i]=destNode._indexInList;
  21907. else
  21908. destCrossClipNodeIndices[i]=-1;
  21909. }
  21910. crossCount=controllerLayer._crossNodesOwnersCount;
  21911. crossMark=controllerLayer._crossMark;
  21912. for (i=0,n=destNodes.count;i < n;i++){
  21913. destNode=destNodes.getNodeByIndex(i);
  21914. destIndex=destNode._indexInList;
  21915. destNodeOwner=destNodeOwners[destIndex];
  21916. if (destNodeOwner){
  21917. destFullPath=destNode.fullPath;
  21918. if (crossNodeOwnerIndicesMap[destFullPath]!==crossMark){
  21919. destCrossClipNodeIndices[crossCount]=destIndex;
  21920. crossNodeOwnerIndicesMap[destFullPath]=crossMark;
  21921. nodeOwner=destNodeOwners[destIndex];
  21922. crossNodeOwners[crossCount]=nodeOwner;
  21923. nodeOwner.saveCrossFixedValue();
  21924. crossCount++;
  21925. }
  21926. }
  21927. }
  21928. break ;
  21929. default :
  21930. }
  21931. controllerLayer._crossNodesOwnersCount=crossCount;
  21932. controllerLayer._crossPlayState=destAnimatorState;
  21933. controllerLayer._crossDuration=srcAnimatorState._clip._duration *transitionDuration;
  21934. if (normalizedTime!==Number.NEGATIVE_INFINITY)
  21935. crossPlayStateInfo._resetPlayState(destClip._duration *normalizedTime);
  21936. else
  21937. crossPlayStateInfo._resetPlayState(0.0);
  21938. };
  21939. var scripts=destAnimatorState._scripts;
  21940. if (scripts){
  21941. for (i=0,n=scripts.length;i < n;i++)
  21942. scripts[i].onStateEnter();
  21943. }
  21944. }
  21945. /**
  21946. *@private
  21947. */
  21948. __proto._getAvatarOwnersAndInitDatasAsync=function(){
  21949. for (var i=0,n=this._controllerLayers.length;i < n;i++){
  21950. var clipStateInfos=this._controllerLayers[i]._states;
  21951. for (var j=0,m=clipStateInfos.length;j < m;j++)
  21952. this._getOwnersByClip(clipStateInfos[j]);
  21953. }
  21954. this._avatar._cloneDatasToAnimator(this);
  21955. for (var k in this._linkAvatarSpritesData){
  21956. var sprites=this._linkAvatarSpritesData[k];
  21957. if (sprites){
  21958. for (var c=0,p=sprites.length;c < p;c++)
  21959. this._isLinkSpriteToAnimationNode(sprites[c],k,true);
  21960. }
  21961. }
  21962. }
  21963. /**
  21964. *@private
  21965. */
  21966. __proto._isLinkSpriteToAnimationNode=function(sprite,nodeName,isLink){
  21967. if (this._avatar){
  21968. var node=this._avatarNodeMap[nodeName];
  21969. if (node){
  21970. if (isLink){
  21971. sprite._transform._dummy=node.transform;
  21972. this._linkAvatarSprites.push(sprite);
  21973. var nodeTransform=node.transform;
  21974. var spriteTransform=sprite.transform;
  21975. if (!spriteTransform.owner.isStatic && nodeTransform){
  21976. var spriteWorldMatrix=spriteTransform.worldMatrix;
  21977. var ownParTra=(this.owner)._transform._parent;
  21978. if (ownParTra){
  21979. Utils3D.matrix4x4MultiplyMFM(ownParTra.worldMatrix,nodeTransform.getWorldMatrix(),spriteWorldMatrix);
  21980. }else {
  21981. var sprWorE=spriteWorldMatrix.elements;
  21982. var nodWorE=nodeTransform.getWorldMatrix();
  21983. for (var i=0;i < 16;i++)
  21984. sprWorE[i]=nodWorE[i];
  21985. }
  21986. spriteTransform.worldMatrix=spriteWorldMatrix;
  21987. }
  21988. }else {
  21989. sprite._transform._dummy=null;
  21990. this._linkAvatarSprites.splice(this._linkAvatarSprites.indexOf(sprite),1);
  21991. }
  21992. }
  21993. }
  21994. }
  21995. /**
  21996. *@private
  21997. */
  21998. __proto._isLinkSpriteToAnimationNodeData=function(sprite,nodeName,isLink){
  21999. var linkSprites=this._linkAvatarSpritesData[nodeName];
  22000. if (isLink){
  22001. linkSprites || (this._linkAvatarSpritesData[nodeName]=linkSprites=[]);
  22002. linkSprites.push(sprite);
  22003. }else {
  22004. linkSprites.splice(sprite,1);
  22005. }
  22006. }
  22007. /**
  22008. *@private
  22009. */
  22010. __proto._updateAvatarNodesToSprite=function(){
  22011. for (var i=0,n=this._linkAvatarSprites.length;i < n;i++){
  22012. var sprite=this._linkAvatarSprites[i];
  22013. var nodeTransform=sprite.transform._dummy;
  22014. var spriteTransform=sprite.transform;
  22015. if (!spriteTransform.owner.isStatic && nodeTransform){
  22016. var spriteWorldMatrix=spriteTransform.worldMatrix;
  22017. var ownTra=(this.owner)._transform;
  22018. Utils3D.matrix4x4MultiplyMFM(ownTra.worldMatrix,nodeTransform.getWorldMatrix(),spriteWorldMatrix);
  22019. spriteTransform.worldMatrix=spriteWorldMatrix;
  22020. }
  22021. }
  22022. }
  22023. /**
  22024. *关联精灵节点到Avatar节点,此Animator必须有Avatar文件。
  22025. *@param nodeName 关联节点的名字。
  22026. *@param sprite3D 精灵节点。
  22027. *@return 是否关联成功。
  22028. */
  22029. __proto.linkSprite3DToAvatarNode=function(nodeName,sprite3D){
  22030. this._isLinkSpriteToAnimationNodeData(sprite3D,nodeName,true);
  22031. this._isLinkSpriteToAnimationNode(sprite3D,nodeName,true);
  22032. return true;
  22033. }
  22034. /**
  22035. *解除精灵节点到Avatar节点的关联,此Animator必须有Avatar文件。
  22036. *@param sprite3D 精灵节点。
  22037. *@return 是否解除关联成功。
  22038. */
  22039. __proto.unLinkSprite3DToAvatarNode=function(sprite3D){
  22040. if (sprite3D._hierarchyAnimator===this){
  22041. var dummy=sprite3D.transform._dummy;
  22042. if (dummy){
  22043. var nodeName=dummy._owner.name;
  22044. this._isLinkSpriteToAnimationNodeData(sprite3D,nodeName,false);
  22045. this._isLinkSpriteToAnimationNode(sprite3D,nodeName,false);
  22046. return true;
  22047. }else {
  22048. return false;
  22049. }
  22050. }else {
  22051. throw("Animator:sprite3D must belong to this Animator");
  22052. return false;
  22053. }
  22054. }
  22055. /**
  22056. *@private
  22057. *[NATIVE]
  22058. */
  22059. __proto._updateAnimationNodeWorldMatix=function(localPositions,localRotations,localScales,worldMatrixs,parentIndices){
  22060. LayaGL.instance.updateAnimationNodeWorldMatix(localPositions,localRotations,localScales,parentIndices,worldMatrixs);
  22061. }
  22062. /**
  22063. *设置动画的播放速度,1.0为正常播放速度。
  22064. *@param 动画的播放速度。
  22065. */
  22066. /**
  22067. *获取动画的播放速度,1.0为正常播放速度。
  22068. *@return 动画的播放速度。
  22069. */
  22070. __getset(0,__proto,'speed',function(){
  22071. return this._speed;
  22072. },function(value){
  22073. this._speed=value;
  22074. });
  22075. /**
  22076. *设置avatar。
  22077. *@param value avatar。
  22078. */
  22079. /**
  22080. *获取avatar。
  22081. *@return avator。
  22082. */
  22083. __getset(0,__proto,'avatar',function(){
  22084. return this._avatar;
  22085. },function(value){
  22086. if (this._avatar!==value){
  22087. this._avatar=value;
  22088. if (value){
  22089. this._getAvatarOwnersAndInitDatasAsync();
  22090. (this.owner)._changeHierarchyAnimatorAvatar(this,value);
  22091. }else {
  22092. var parent=this.owner._parent;
  22093. (this.owner)._changeHierarchyAnimatorAvatar(this,parent ? (parent)._hierarchyAnimator._avatar :null);
  22094. }
  22095. }
  22096. });
  22097. Animator._update=function(scene){
  22098. var pool=scene._animatorPool;
  22099. var elements=pool.elements;
  22100. for (var i=0,n=pool.length;i < n;i++){
  22101. var animator=elements[i];
  22102. (animator && animator.enabled)&& (animator._update());
  22103. }
  22104. }
  22105. Animator._tempVector3Array0=new Float32Array(3);
  22106. Animator._tempVector3Array1=new Float32Array(3);
  22107. Animator._tempQuaternionArray0=new Float32Array(4);
  22108. Animator._tempQuaternionArray1=new Float32Array(4);
  22109. Animator.CULLINGMODE_ALWAYSANIMATE=0;
  22110. Animator.CULLINGMODE_CULLCOMPLETELY=2;
  22111. __static(Animator,
  22112. ['_tempVector30',function(){return this._tempVector30=new Vector3();},'_tempVector31',function(){return this._tempVector31=new Vector3();},'_tempQuaternion0',function(){return this._tempQuaternion0=new Quaternion();},'_tempQuaternion1',function(){return this._tempQuaternion1=new Quaternion();}
  22113. ]);
  22114. return Animator;
  22115. })(Component)
  22116. /**
  22117. *<code>AnimationTransform3D</code> 类用于实现3D变换。
  22118. */
  22119. //class laya.d3.animation.AnimationTransform3D extends laya.events.EventDispatcher
  22120. var AnimationTransform3D=(function(_super){
  22121. function AnimationTransform3D(owner,localPosition,localRotation,localScale,worldMatrix){
  22122. /**@private */
  22123. //this._localMatrix=null;
  22124. /**@private */
  22125. //this._worldMatrix=null;
  22126. /**@private */
  22127. //this._localPosition=null;
  22128. /**@private */
  22129. //this._localRotation=null;
  22130. /**@private */
  22131. //this._localScale=null;
  22132. /**@private */
  22133. //this._localQuaternionUpdate=false;
  22134. /**@private */
  22135. //this._locaEulerlUpdate=false;
  22136. /**@private */
  22137. //this._localUpdate=false;
  22138. /**@private */
  22139. //this._parent=null;
  22140. /**@private */
  22141. //this._children=null;
  22142. /**@private */
  22143. //this._localRotationEuler=null;
  22144. /**@private */
  22145. //this._owner=null;
  22146. /**@private */
  22147. //this._worldUpdate=false;
  22148. AnimationTransform3D.__super.call(this);
  22149. this._owner=owner;
  22150. this._children=[];
  22151. this._localMatrix=new Float32Array(16);
  22152. if (Render.supportWebGLPlusAnimation){
  22153. /*__JS__ */this._localPosition=new ConchVector3(0,0,0,localPosition);
  22154. /*__JS__ */this._localRotation=new ConchQuaternion(0,0,0,1,localRotation);
  22155. /*__JS__ */this._localScale=new ConchVector3(0,0,0,localScale);
  22156. this._worldMatrix=worldMatrix;
  22157. }else {
  22158. this._localPosition=new Vector3();
  22159. this._localRotation=new Quaternion();
  22160. this._localScale=new Vector3();
  22161. this._worldMatrix=new Float32Array(16);
  22162. }
  22163. this._localQuaternionUpdate=false;
  22164. this._locaEulerlUpdate=false;
  22165. this._localUpdate=false;
  22166. this._worldUpdate=true;
  22167. }
  22168. __class(AnimationTransform3D,'laya.d3.animation.AnimationTransform3D',_super);
  22169. var __proto=AnimationTransform3D.prototype;
  22170. /**
  22171. *@private
  22172. */
  22173. __proto._getlocalMatrix=function(){
  22174. if (this._localUpdate){
  22175. Utils3D._createAffineTransformationArray(this._localPosition,this._localRotation,this._localScale,this._localMatrix);
  22176. this._localUpdate=false;
  22177. }
  22178. return this._localMatrix;
  22179. }
  22180. /**
  22181. *@private
  22182. */
  22183. __proto._onWorldTransform=function(){
  22184. if (!this._worldUpdate){
  22185. this._worldUpdate=true;
  22186. this.event(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged");
  22187. for (var i=0,n=this._children.length;i < n;i++)
  22188. this._children[i]._onWorldTransform();
  22189. }
  22190. }
  22191. /**
  22192. *获取世界矩阵。
  22193. *@return 世界矩阵。
  22194. */
  22195. __proto.getWorldMatrix=function(){
  22196. if (!Render.supportWebGLPlusAnimation && this._worldUpdate){
  22197. if (this._parent !=null){
  22198. Utils3D.matrix4x4MultiplyFFF(this._parent.getWorldMatrix(),this._getlocalMatrix(),this._worldMatrix);
  22199. }else {
  22200. var e=this._worldMatrix;
  22201. e[1]=e[2]=e[3]=e[4]=e[6]=e[7]=e[8]=e[9]=e[11]=e[12]=e[13]=e[14]=0;
  22202. e[0]=e[5]=e[10]=e[15]=1;
  22203. }
  22204. this._worldUpdate=false;
  22205. }
  22206. if (Render.supportWebGLPlusAnimation && this._worldUpdate){
  22207. this._worldUpdate=false;
  22208. }
  22209. return this._worldMatrix;
  22210. }
  22211. /**
  22212. *设置父3D变换。
  22213. *@param value 父3D变换。
  22214. */
  22215. __proto.setParent=function(value){
  22216. if (this._parent!==value){
  22217. if (this._parent){
  22218. var parentChilds=this._parent._children;
  22219. var index=parentChilds.indexOf(this);
  22220. parentChilds.splice(index,1);
  22221. }
  22222. if (value){
  22223. value._children.push(this);
  22224. (value)&& (this._onWorldTransform());
  22225. }
  22226. this._parent=value;
  22227. }
  22228. }
  22229. /**
  22230. *@private
  22231. */
  22232. /**
  22233. *@private
  22234. */
  22235. __getset(0,__proto,'localPosition',function(){
  22236. return this._localPosition;
  22237. },function(value){
  22238. this._localPosition=value;
  22239. this._localUpdate=true;
  22240. this._onWorldTransform();
  22241. });
  22242. /*
  22243. *@private
  22244. */
  22245. /**
  22246. *@private
  22247. */
  22248. __getset(0,__proto,'localRotation',function(){
  22249. if (this._localQuaternionUpdate){
  22250. var euler=this._localRotationEuler;
  22251. Quaternion.createFromYawPitchRoll(euler.y / AnimationTransform3D._angleToRandin,euler.x / AnimationTransform3D._angleToRandin,euler.z / AnimationTransform3D._angleToRandin,this._localRotation);
  22252. this._localQuaternionUpdate=false;
  22253. }
  22254. return this._localRotation;
  22255. },function(value){
  22256. this._localRotation=value;
  22257. this._locaEulerlUpdate=true;
  22258. this._localQuaternionUpdate=false;
  22259. this._localUpdate=true;
  22260. this._onWorldTransform();
  22261. });
  22262. /**
  22263. *@private
  22264. */
  22265. /**
  22266. *@private
  22267. */
  22268. __getset(0,__proto,'localScale',function(){
  22269. return this._localScale;
  22270. },function(value){
  22271. this._localScale=value;
  22272. this._localUpdate=true;
  22273. this._onWorldTransform();
  22274. });
  22275. /**
  22276. *@private
  22277. */
  22278. /**
  22279. *@private
  22280. */
  22281. __getset(0,__proto,'localRotationEuler',function(){
  22282. if (this._locaEulerlUpdate){
  22283. this._localRotation.getYawPitchRoll(AnimationTransform3D._tempVector3);
  22284. var euler=AnimationTransform3D._tempVector3;
  22285. var localRotationEuler=this._localRotationEuler;
  22286. localRotationEuler.x=euler.y *AnimationTransform3D._angleToRandin;
  22287. localRotationEuler.y=euler.x *AnimationTransform3D._angleToRandin;
  22288. localRotationEuler.z=euler.z *AnimationTransform3D._angleToRandin;
  22289. this._locaEulerlUpdate=false;
  22290. }
  22291. return this._localRotationEuler;
  22292. },function(value){
  22293. this._localRotationEuler=value;
  22294. this._locaEulerlUpdate=false;
  22295. this._localQuaternionUpdate=true;
  22296. this._localUpdate=true;
  22297. this._onWorldTransform();
  22298. });
  22299. __static(AnimationTransform3D,
  22300. ['_tempVector3',function(){return this._tempVector3=new Vector3();},'_angleToRandin',function(){return this._angleToRandin=180 / Math.PI;}
  22301. ]);
  22302. return AnimationTransform3D;
  22303. })(EventDispatcher)
  22304. /**
  22305. *<code>VertexBuffer3D</code> 类用于创建顶点缓冲。
  22306. */
  22307. //class laya.d3.graphics.VertexBuffer3D extends laya.webgl.utils.Buffer
  22308. var VertexBuffer3D=(function(_super){
  22309. function VertexBuffer3D(byteLength,bufferUsage,canRead,dateType){
  22310. /**@private */
  22311. this._vertexCount=0;
  22312. /**@private */
  22313. this._canRead=false;
  22314. /**@private */
  22315. this._dataType=0;
  22316. /**@private */
  22317. this._vertexDeclaration=null;
  22318. (canRead===void 0)&& (canRead=false);
  22319. (dateType===void 0)&& (dateType=0);
  22320. VertexBuffer3D.__super.call(this);
  22321. this._vertexCount=-1;
  22322. this._bufferUsage=bufferUsage;
  22323. this._bufferType=/*laya.webgl.WebGLContext.ARRAY_BUFFER*/0x8892;
  22324. this._canRead=canRead;
  22325. this._dataType=dateType;
  22326. this._byteLength=byteLength;
  22327. this.bind();
  22328. LayaGL.instance.bufferData(this._bufferType,this._byteLength,this._bufferUsage);
  22329. if (canRead){
  22330. switch (dateType){
  22331. case 0:
  22332. this._buffer=new Float32Array(byteLength / 4);
  22333. break ;
  22334. case 1:
  22335. this._buffer=new Uint8Array(byteLength);
  22336. break ;
  22337. }
  22338. }
  22339. }
  22340. __class(VertexBuffer3D,'laya.d3.graphics.VertexBuffer3D',_super);
  22341. var __proto=VertexBuffer3D.prototype;
  22342. /**
  22343. *@inheritDoc
  22344. */
  22345. __proto.bind=function(){
  22346. if (Buffer._bindedVertexBuffer!==this._glBuffer){
  22347. LayaGL.instance.bindBuffer(/*laya.webgl.WebGLContext.ARRAY_BUFFER*/0x8892,this._glBuffer);
  22348. Buffer._bindedVertexBuffer=this._glBuffer;
  22349. return true;
  22350. }else {
  22351. return false;
  22352. }
  22353. }
  22354. /**
  22355. *设置数据。
  22356. *@param data 顶点数据。
  22357. *@param bufferOffset 顶点缓冲中的偏移。
  22358. *@param dataStartIndex 顶点数据的偏移。
  22359. *@param dataCount 顶点数据的数量。
  22360. */
  22361. __proto.setData=function(data,bufferOffset,dataStartIndex,dataCount){
  22362. (bufferOffset===void 0)&& (bufferOffset=0);
  22363. (dataStartIndex===void 0)&& (dataStartIndex=0);
  22364. (dataCount===void 0)&& (dataCount=4294967295);
  22365. this.bind();
  22366. var needSubData=dataStartIndex!==0 || dataCount!==4294967295;
  22367. if (needSubData){
  22368. switch (this._dataType){
  22369. case 0:
  22370. data=new Float32Array(data.buffer,dataStartIndex *4,dataCount);
  22371. break ;
  22372. case 1:
  22373. data=new Uint8Array(data.buffer,dataStartIndex,dataCount);
  22374. break ;
  22375. }
  22376. }
  22377. switch (this._dataType){
  22378. case 0:
  22379. LayaGL.instance.bufferSubData(this._bufferType,bufferOffset *4,data);
  22380. break ;
  22381. case 1:
  22382. LayaGL.instance.bufferSubData(this._bufferType,bufferOffset,data);
  22383. break ;
  22384. }
  22385. if (this._canRead)
  22386. this._buffer.set(data,bufferOffset);
  22387. }
  22388. /**
  22389. *获取顶点数据。
  22390. *@return 顶点数据。
  22391. */
  22392. __proto.getData=function(){
  22393. if (this._canRead)
  22394. return this._buffer;
  22395. else
  22396. throw new Error("Can't read data from VertexBuffer with only write flag!");
  22397. }
  22398. /**
  22399. *@inheritDoc
  22400. */
  22401. __proto.destroy=function(){
  22402. _super.prototype.destroy.call(this);
  22403. this._buffer=null;
  22404. this._vertexDeclaration=null;
  22405. }
  22406. /**
  22407. *获取顶点声明。
  22408. */
  22409. /**
  22410. *获取顶点声明。
  22411. */
  22412. __getset(0,__proto,'vertexDeclaration',function(){
  22413. return this._vertexDeclaration;
  22414. },function(value){
  22415. if (this._vertexDeclaration!==value){
  22416. this._vertexDeclaration=value;
  22417. this._vertexCount=value ? this._byteLength / value.vertexStride :-1;
  22418. }
  22419. });
  22420. /**
  22421. *获取顶点个数。
  22422. *@return 顶点个数。
  22423. */
  22424. __getset(0,__proto,'vertexCount',function(){
  22425. return this._vertexCount;
  22426. });
  22427. /**
  22428. *获取是否可读。
  22429. *@return 是否可读。
  22430. */
  22431. __getset(0,__proto,'canRead',function(){
  22432. return this._canRead;
  22433. });
  22434. VertexBuffer3D.DATATYPE_FLOAT32ARRAY=0;
  22435. VertexBuffer3D.DATATYPE_UINT8ARRAY=1;
  22436. return VertexBuffer3D;
  22437. })(Buffer)
  22438. /**
  22439. *<code>ConstraintComponent</code> 类用于创建约束的父类。
  22440. */
  22441. //class laya.d3.physics.constraints.ConstraintComponent extends laya.components.Component
  22442. var ConstraintComponent=(function(_super){
  22443. function ConstraintComponent(){
  22444. /**@private */
  22445. this._nativeConstraint=null;
  22446. /**@private */
  22447. this._breakingImpulseThreshold=NaN;
  22448. /**@private */
  22449. this._connectedBody=null;
  22450. /**@private */
  22451. this._feedbackEnabled=false;
  22452. ConstraintComponent.__super.call(this);
  22453. }
  22454. __class(ConstraintComponent,'laya.d3.physics.constraints.ConstraintComponent',_super);
  22455. var __proto=ConstraintComponent.prototype;
  22456. /**
  22457. *@inheritDoc
  22458. */
  22459. __proto._onDestroy=function(){
  22460. var physics3D=Laya3D._physics3D;
  22461. physics3D.destroy(this._nativeConstraint);
  22462. this._nativeConstraint=null;
  22463. }
  22464. /**
  22465. *设置打破冲力阈值。
  22466. *@param value 打破冲力阈值。
  22467. */
  22468. /**
  22469. *获取打破冲力阈值。
  22470. *@return 打破冲力阈值。
  22471. */
  22472. __getset(0,__proto,'breakingImpulseThreshold',function(){
  22473. return this._breakingImpulseThreshold;
  22474. },function(value){
  22475. this._nativeConstraint.BreakingImpulseThreshold=value;
  22476. this._breakingImpulseThreshold=value;
  22477. });
  22478. /**
  22479. *@inheritDoc
  22480. */
  22481. /**
  22482. *@inheritDoc
  22483. */
  22484. __getset(0,__proto,'enabled',function(){
  22485. return Laya.superGet(Component,this,'enabled');
  22486. },function(value){
  22487. this._nativeConstraint.IsEnabled=value;
  22488. Laya.superSet(Component,this,'enabled',value);
  22489. });
  22490. /**
  22491. *获取应用的冲力。
  22492. */
  22493. __getset(0,__proto,'appliedImpulse',function(){
  22494. if (!this._feedbackEnabled){
  22495. this._nativeConstraint.EnableFeedback(true);
  22496. this._feedbackEnabled=true;
  22497. }
  22498. return this._nativeConstraint.AppliedImpulse;
  22499. });
  22500. /**
  22501. *设置已连接刚体。
  22502. *@param value 已连接刚体。
  22503. */
  22504. /**
  22505. *获取已连接的刚体。
  22506. *@return 已连接刚体。
  22507. */
  22508. __getset(0,__proto,'connectedBody',function(){
  22509. return this._connectedBody;
  22510. },function(value){
  22511. this._connectedBody=value;
  22512. });
  22513. return ConstraintComponent;
  22514. })(Component)
  22515. /**
  22516. *<code>IndexBuffer3D</code> 类用于创建索引缓冲。
  22517. */
  22518. //class laya.d3.graphics.IndexBuffer3D extends laya.webgl.utils.Buffer
  22519. var IndexBuffer3D=(function(_super){
  22520. function IndexBuffer3D(indexType,indexCount,bufferUsage,canRead){
  22521. /**@private */
  22522. this._indexType=null;
  22523. /**@private */
  22524. this._indexTypeByteCount=0;
  22525. /**@private */
  22526. this._indexCount=0;
  22527. /**@private */
  22528. this._canRead=false;
  22529. (bufferUsage===void 0)&& (bufferUsage=0x88E4);
  22530. (canRead===void 0)&& (canRead=false);
  22531. IndexBuffer3D.__super.call(this);
  22532. this._indexType=indexType;
  22533. this._indexCount=indexCount;
  22534. this._bufferUsage=bufferUsage;
  22535. this._bufferType=/*laya.webgl.WebGLContext.ELEMENT_ARRAY_BUFFER*/0x8893;
  22536. this._canRead=canRead;
  22537. var byteLength=0;
  22538. if (indexType==/*CLASS CONST:laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort")
  22539. this._indexTypeByteCount=2;
  22540. else if (indexType==/*CLASS CONST:laya.d3.graphics.IndexBuffer3D.INDEXTYPE_UBYTE*/"ubyte")
  22541. this._indexTypeByteCount=1;
  22542. else
  22543. throw new Error("unidentification index type.");
  22544. byteLength=this._indexTypeByteCount *indexCount;
  22545. this._byteLength=byteLength;
  22546. var curBufSta=BufferStateBase._curBindedBufferState;
  22547. if (curBufSta){
  22548. if (curBufSta._bindedIndexBuffer===this){
  22549. LayaGL.instance.bufferData(this._bufferType,byteLength,this._bufferUsage);
  22550. }else {
  22551. curBufSta.unBind();
  22552. this.bind();
  22553. LayaGL.instance.bufferData(this._bufferType,byteLength,this._bufferUsage);
  22554. curBufSta.bind();
  22555. }
  22556. }else {
  22557. this.bind();
  22558. LayaGL.instance.bufferData(this._bufferType,byteLength,this._bufferUsage);
  22559. }
  22560. if (canRead){
  22561. if (indexType==/*CLASS CONST:laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort")
  22562. this._buffer=new Uint16Array(indexCount);
  22563. else if (indexType==/*CLASS CONST:laya.d3.graphics.IndexBuffer3D.INDEXTYPE_UBYTE*/"ubyte")
  22564. this._buffer=new Uint8Array(indexCount);
  22565. }
  22566. }
  22567. __class(IndexBuffer3D,'laya.d3.graphics.IndexBuffer3D',_super);
  22568. var __proto=IndexBuffer3D.prototype;
  22569. /**
  22570. *@inheritDoc
  22571. */
  22572. __proto._bindForVAO=function(){
  22573. if (BufferStateBase._curBindedBufferState){
  22574. LayaGL.instance.bindBuffer(/*laya.webgl.WebGLContext.ELEMENT_ARRAY_BUFFER*/0x8893,this._glBuffer);
  22575. }else {
  22576. throw "IndexBuffer3D: must bind current BufferState.";
  22577. }
  22578. }
  22579. /**
  22580. *@inheritDoc
  22581. */
  22582. __proto.bind=function(){
  22583. if (BufferStateBase._curBindedBufferState){
  22584. throw "IndexBuffer3D: must unbind current BufferState.";
  22585. }else {
  22586. if (Buffer._bindedIndexBuffer!==this._glBuffer){
  22587. LayaGL.instance.bindBuffer(/*laya.webgl.WebGLContext.ELEMENT_ARRAY_BUFFER*/0x8893,this._glBuffer);
  22588. Buffer._bindedIndexBuffer=this._glBuffer;
  22589. return true;
  22590. }else {
  22591. return false;
  22592. }
  22593. }
  22594. }
  22595. /**
  22596. *设置数据。
  22597. *@param data 索引数据。
  22598. *@param bufferOffset 索引缓冲中的偏移。
  22599. *@param dataStartIndex 索引数据的偏移。
  22600. *@param dataCount 索引数据的数量。
  22601. */
  22602. __proto.setData=function(data,bufferOffset,dataStartIndex,dataCount){
  22603. (bufferOffset===void 0)&& (bufferOffset=0);
  22604. (dataStartIndex===void 0)&& (dataStartIndex=0);
  22605. (dataCount===void 0)&& (dataCount=4294967295);
  22606. var byteCount=0;
  22607. if (this._indexType==/*CLASS CONST:laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort"){
  22608. byteCount=2;
  22609. if (dataStartIndex!==0 || dataCount!==4294967295)
  22610. data=new Uint16Array(data.buffer,dataStartIndex *byteCount,dataCount);
  22611. }else if (this._indexType==/*CLASS CONST:laya.d3.graphics.IndexBuffer3D.INDEXTYPE_UBYTE*/"ubyte"){
  22612. byteCount=1;
  22613. if (dataStartIndex!==0 || dataCount!==4294967295)
  22614. data=new Uint8Array(data.buffer,dataStartIndex *byteCount,dataCount);
  22615. };
  22616. var curBufSta=BufferStateBase._curBindedBufferState;
  22617. if (curBufSta){
  22618. if (curBufSta._bindedIndexBuffer===this){
  22619. LayaGL.instance.bufferSubData(this._bufferType,bufferOffset *byteCount,data);
  22620. }else {
  22621. curBufSta.unBind();
  22622. this.bind();
  22623. LayaGL.instance.bufferSubData(this._bufferType,bufferOffset *byteCount,data);
  22624. curBufSta.bind();
  22625. }
  22626. }else {
  22627. this.bind();
  22628. LayaGL.instance.bufferSubData(this._bufferType,bufferOffset *byteCount,data);
  22629. }
  22630. if (this._canRead){
  22631. if (bufferOffset!==0 || dataStartIndex!==0 || dataCount!==4294967295){
  22632. var maxLength=this._buffer.length-bufferOffset;
  22633. if (dataCount > maxLength)
  22634. dataCount=maxLength;
  22635. for (var i=0;i < dataCount;i++)
  22636. this._buffer[bufferOffset+i]=data[i];
  22637. }else {
  22638. this._buffer=data;
  22639. }
  22640. }
  22641. }
  22642. /**
  22643. *获取索引数据。
  22644. *@return 索引数据。
  22645. */
  22646. __proto.getData=function(){
  22647. if (this._canRead)
  22648. return this._buffer;
  22649. else
  22650. throw new Error("Can't read data from VertexBuffer with only write flag!");
  22651. }
  22652. /**
  22653. *@inheritDoc
  22654. */
  22655. __proto.destroy=function(){
  22656. _super.prototype.destroy.call(this);
  22657. this._buffer=null;
  22658. }
  22659. /**
  22660. *获取索引类型。
  22661. *@return 索引类型。
  22662. */
  22663. __getset(0,__proto,'indexType',function(){
  22664. return this._indexType;
  22665. });
  22666. /**
  22667. *获取索引类型字节数量。
  22668. *@return 索引类型字节数量。
  22669. */
  22670. __getset(0,__proto,'indexTypeByteCount',function(){
  22671. return this._indexTypeByteCount;
  22672. });
  22673. /**
  22674. *获取索引个数。
  22675. *@return 索引个数。
  22676. */
  22677. __getset(0,__proto,'indexCount',function(){
  22678. return this._indexCount;
  22679. });
  22680. /**
  22681. *获取是否可读。
  22682. *@return 是否可读。
  22683. */
  22684. __getset(0,__proto,'canRead',function(){
  22685. return this._canRead;
  22686. });
  22687. IndexBuffer3D.INDEXTYPE_UBYTE="ubyte";
  22688. IndexBuffer3D.INDEXTYPE_USHORT="ushort";
  22689. return IndexBuffer3D;
  22690. })(Buffer)
  22691. /**
  22692. *<code>ShaderPass</code> 类用于实现ShaderPass。
  22693. */
  22694. //class laya.d3.shader.ShaderPass extends laya.webgl.utils.ShaderCompile
  22695. var ShaderPass=(function(_super){
  22696. function ShaderPass(owner,vs,ps,stateMap){
  22697. /**@private */
  22698. //this._owner=null;
  22699. /**@private */
  22700. //this._stateMap=null;
  22701. /**@private */
  22702. //this._cacheSharders=null;
  22703. /**@private */
  22704. //this._publicValidDefine=0;
  22705. /**@private */
  22706. //this._spriteValidDefine=0;
  22707. /**@private */
  22708. //this._materialValidDefine=0;
  22709. /**@private */
  22710. //this._validDefineMap=null;
  22711. this._renderState=new RenderState();
  22712. this._owner=owner;
  22713. this._cacheSharders=[];
  22714. this._publicValidDefine=0;
  22715. this._spriteValidDefine=0;
  22716. this._materialValidDefine=0;
  22717. this._validDefineMap={};
  22718. ShaderPass.__super.call(this,vs,ps,null,this._validDefineMap);
  22719. var publicDefineMap=this._owner._publicDefinesMap;
  22720. var spriteDefineMap=this._owner._spriteDefinesMap;
  22721. var materialDefineMap=this._owner._materialDefinesMap;
  22722. for (var k in this._validDefineMap){
  22723. if (publicDefineMap[k] !=null)
  22724. this._publicValidDefine |=publicDefineMap[k];
  22725. else if (spriteDefineMap[k] !=null)
  22726. this._spriteValidDefine |=spriteDefineMap[k];
  22727. else if (materialDefineMap[k] !=null)
  22728. this._materialValidDefine |=materialDefineMap[k];
  22729. }
  22730. this._stateMap=stateMap;
  22731. }
  22732. __class(ShaderPass,'laya.d3.shader.ShaderPass',_super);
  22733. var __proto=ShaderPass.prototype;
  22734. /**
  22735. *@private
  22736. */
  22737. __proto._definesToNameDic=function(value,int2Name){
  22738. var o={};
  22739. var d=1;
  22740. for (var i=0;i < 32;i++){
  22741. d=1 << i;
  22742. if (d > value)break ;
  22743. if (value & d){
  22744. var name=int2Name[d];
  22745. o[name]="";
  22746. }
  22747. }
  22748. return o;
  22749. }
  22750. /**
  22751. *@inheritDoc
  22752. */
  22753. __proto._compileToTree=function(parent,lines,start,includefiles,defs){
  22754. var node,preNode;
  22755. var text,name,fname;
  22756. var ofs=0,words,noUseNode;
  22757. var i=0,n=0,j=0;
  22758. for (i=start;i < lines.length;i++){
  22759. text=lines[i];
  22760. if (text.length < 1)continue ;
  22761. ofs=text.indexOf("//");
  22762. if (ofs===0)continue ;
  22763. if (ofs >=0)text=text.substr(0,ofs);
  22764. node=noUseNode || new ShaderNode(includefiles);
  22765. noUseNode=null;
  22766. node.text=text;
  22767. if ((ofs=text.indexOf("#"))>=0){
  22768. name="#";
  22769. for (j=ofs+1,n=text.length;j < n;j++){
  22770. var c=text.charAt(j);
  22771. if (c===' ' || c==='\t' || c==='?')break ;
  22772. name+=c;
  22773. }
  22774. node.name=name;
  22775. switch (name){
  22776. case "#ifdef":
  22777. case "#ifndef":
  22778. node.setParent(parent);
  22779. parent=node;
  22780. if (defs){
  22781. words=text.substr(j).split(ShaderCompile._splitToWordExps3);
  22782. for (j=0;j < words.length;j++){
  22783. text=words[j];
  22784. text.length && (defs[text]=true);
  22785. }
  22786. }
  22787. continue ;
  22788. case "#if":
  22789. case "#elif":
  22790. node.setParent(parent);
  22791. parent=node;
  22792. if (defs){
  22793. words=text.substr(j).split(ShaderCompile._splitToWordExps3);
  22794. for (j=0;j < words.length;j++){
  22795. text=words[j];
  22796. text.length && text !="defined" && (defs[text]=true);
  22797. }
  22798. }
  22799. continue ;
  22800. case "#else":
  22801. parent=parent.parent;
  22802. preNode=parent.childs[parent.childs.length-1];
  22803. node.setParent(parent);
  22804. parent=node;
  22805. continue ;
  22806. case "#endif":
  22807. parent=parent.parent;
  22808. preNode=parent.childs[parent.childs.length-1];
  22809. node.setParent(parent);
  22810. continue ;
  22811. case "#include":
  22812. words=ShaderCompile.splitToWords(text,null);
  22813. var inlcudeFile=ShaderCompile.includes[words[1]];
  22814. if (!inlcudeFile){
  22815. throw "ShaderCompile error no this include file:"+words[1];
  22816. }
  22817. if ((ofs=words[0].indexOf("?"))< 0){
  22818. node.setParent(parent);
  22819. text=inlcudeFile.getWith(words[2]=='with' ? words[3] :null);
  22820. this._compileToTree(node,text.split('\n'),0,includefiles,defs);
  22821. node.text="";
  22822. continue ;
  22823. }
  22824. node.setCondition(words[0].substr(ofs+1),1);
  22825. node.text=inlcudeFile.getWith(words[2]=='with' ? words[3] :null);
  22826. break ;
  22827. case "#import":
  22828. words=ShaderCompile.splitToWords(text,null);
  22829. fname=words[1];
  22830. includefiles.push({node:node,file:ShaderCompile.includes[fname],ofs:node.text.length});
  22831. continue ;
  22832. }
  22833. }else {
  22834. preNode=parent.childs[parent.childs.length-1];
  22835. if (preNode && !preNode.name){
  22836. includefiles.length > 0 && ShaderCompile.splitToWords(text,preNode);
  22837. noUseNode=node;
  22838. preNode.text+="\n"+text;
  22839. continue ;
  22840. }
  22841. includefiles.length > 0 && ShaderCompile.splitToWords(text,node);
  22842. }
  22843. node.setParent(parent);
  22844. }
  22845. }
  22846. /**
  22847. *@private
  22848. */
  22849. __proto.withCompile=function(publicDefine,spriteDefine,materialDefine){
  22850. publicDefine &=this._publicValidDefine;
  22851. spriteDefine &=this._spriteValidDefine;
  22852. materialDefine &=this._materialValidDefine;
  22853. var shader;
  22854. var spriteDefShaders,materialDefShaders;
  22855. spriteDefShaders=this._cacheSharders[publicDefine];
  22856. if (spriteDefShaders){
  22857. materialDefShaders=spriteDefShaders[spriteDefine];
  22858. if (materialDefShaders){
  22859. shader=materialDefShaders[materialDefine];
  22860. if (shader)
  22861. return shader;
  22862. }else {
  22863. materialDefShaders=spriteDefShaders[spriteDefine]=[];
  22864. }
  22865. }else {
  22866. spriteDefShaders=this._cacheSharders[publicDefine]=[];
  22867. materialDefShaders=spriteDefShaders[spriteDefine]=[];
  22868. };
  22869. var publicDefGroup=this._definesToNameDic(publicDefine,this._owner._publicDefines);
  22870. var spriteDefGroup=this._definesToNameDic(spriteDefine,this._owner._spriteDefines);
  22871. var materialDefGroup=this._definesToNameDic(materialDefine,this._owner._materialDefines);
  22872. var key;
  22873. if (Shader3D.debugMode){
  22874. var publicDefGroupStr="";
  22875. for (key in publicDefGroup)
  22876. publicDefGroupStr+=key+" ";
  22877. var spriteDefGroupStr="";
  22878. for (key in spriteDefGroup)
  22879. spriteDefGroupStr+=key+" ";
  22880. var materialDefGroupStr="";
  22881. for (key in materialDefGroup)
  22882. materialDefGroupStr+=key+" ";
  22883. if (!WebGL.shaderHighPrecision)
  22884. publicDefine+=Shader3D.SHADERDEFINE_HIGHPRECISION;
  22885. console.log("%cShader3DDebugMode---(Name:"+this._owner._owner._name+" PassIndex:"+this._owner._passes.indexOf(this)+" PublicDefine:"+publicDefine+" SpriteDefine:"+spriteDefine+" MaterialDefine:"+materialDefine+" PublicDefineGroup:"+publicDefGroupStr+" SpriteDefineGroup:"+spriteDefGroupStr+"MaterialDefineGroup: "+materialDefGroupStr+")---ShaderCompile3DDebugMode","color:green");
  22886. };
  22887. var defMap={};
  22888. var defineStr="";
  22889. if (publicDefGroup){
  22890. for (key in publicDefGroup){
  22891. defineStr+="#define "+key+"\n";
  22892. defMap[key]=true;
  22893. }
  22894. }
  22895. if (spriteDefGroup){
  22896. for (key in spriteDefGroup){
  22897. defineStr+="#define "+key+"\n";
  22898. defMap[key]=true;
  22899. }
  22900. }
  22901. if (materialDefGroup){
  22902. for (key in materialDefGroup){
  22903. defineStr+="#define "+key+"\n";
  22904. defMap[key]=true;
  22905. }
  22906. };
  22907. var vs=this._VS.toscript(defMap,[]);
  22908. var vsVersion='';
  22909. if (vs[0].indexOf('#version')==0){
  22910. vsVersion=vs[0]+'\n';
  22911. vs.shift();
  22912. };
  22913. var ps=this._PS.toscript(defMap,[]);
  22914. var psVersion='';
  22915. if (ps[0].indexOf('#version')==0){
  22916. psVersion=ps[0]+'\n';
  22917. ps.shift();
  22918. }
  22919. shader=new ShaderInstance(vsVersion+defineStr+vs.join('\n'),psVersion+defineStr+ps.join('\n'),this._owner._attributeMap||this._owner._owner._attributeMap,this._owner._uniformMap||this._owner._owner._uniformMap,this);
  22920. materialDefShaders[materialDefine]=shader;
  22921. return shader;
  22922. }
  22923. /**
  22924. *获取渲染状态。
  22925. *@return 渲染状态。
  22926. */
  22927. __getset(0,__proto,'renderState',function(){
  22928. return this._renderState;
  22929. });
  22930. return ShaderPass;
  22931. })(ShaderCompile)
  22932. /**
  22933. *@private
  22934. *<code>BufferState</code> 类用于实现渲染所需的Buffer状态集合。
  22935. */
  22936. //class laya.d3.core.BufferState extends laya.webgl.BufferStateBase
  22937. var BufferState=(function(_super){
  22938. /**
  22939. *创建一个 <code>BufferState</code> 实例。
  22940. */
  22941. function BufferState(){
  22942. BufferState.__super.call(this);
  22943. }
  22944. __class(BufferState,'laya.d3.core.BufferState',_super);
  22945. var __proto=BufferState.prototype;
  22946. /**
  22947. *@private
  22948. *vertexBuffer的vertexDeclaration不能为空,该函数比较消耗性能,建议初始化时使用。
  22949. */
  22950. __proto.applyVertexBuffer=function(vertexBuffer){
  22951. if (BufferStateBase._curBindedBufferState===this){
  22952. var gl=LayaGL.instance;
  22953. var verDec=vertexBuffer.vertexDeclaration;
  22954. var valueData=null;
  22955. if (Render.supportWebGLPlusRendering)
  22956. valueData=verDec._shaderValues._nativeArray;
  22957. else
  22958. valueData=verDec._shaderValues.getData();
  22959. vertexBuffer.bind();
  22960. for (var k in valueData){
  22961. var loc=parseInt(k);
  22962. var attribute=valueData[k];
  22963. gl.enableVertexAttribArray(loc);
  22964. gl.vertexAttribPointer(loc,attribute[0],attribute[1],!!attribute[2],attribute[3],attribute[4]);
  22965. }
  22966. }else {
  22967. throw "BufferState: must call bind() function first.";
  22968. }
  22969. }
  22970. /**
  22971. *@private
  22972. *vertexBuffers中的vertexDeclaration不能为空,该函数比较消耗性能,建议初始化时使用。
  22973. */
  22974. __proto.applyVertexBuffers=function(vertexBuffers){
  22975. if (BufferStateBase._curBindedBufferState===this){
  22976. var gl=LayaGL.instance;
  22977. for (var i=0,n=vertexBuffers.length;i < n;i++){
  22978. var verBuf=vertexBuffers[i];
  22979. var verDec=verBuf.vertexDeclaration;
  22980. var valueData=null;
  22981. if (Render.supportWebGLPlusRendering)
  22982. valueData=verDec._shaderValues._nativeArray;
  22983. else
  22984. valueData=verDec._shaderValues.getData();
  22985. verBuf.bind();
  22986. for (var k in valueData){
  22987. var loc=parseInt(k);
  22988. var attribute=valueData[k];
  22989. gl.enableVertexAttribArray(loc);
  22990. gl.vertexAttribPointer(loc,attribute[0],attribute[1],!!attribute[2],attribute[3],attribute[4]);
  22991. }
  22992. }
  22993. }else {
  22994. throw "BufferState: must call bind() function first.";
  22995. }
  22996. }
  22997. /**
  22998. *@private
  22999. */
  23000. __proto.applyInstanceVertexBuffer=function(vertexBuffer){
  23001. if (WebGLContext._angleInstancedArrays){
  23002. if (BufferStateBase._curBindedBufferState===this){
  23003. var gl=LayaGL.instance;
  23004. var verDec=vertexBuffer.vertexDeclaration;
  23005. var valueData=null;
  23006. if (Render.supportWebGLPlusRendering)
  23007. valueData=verDec._shaderValues._nativeArray;
  23008. else
  23009. valueData=verDec._shaderValues.getData();
  23010. vertexBuffer.bind();
  23011. for (var k in valueData){
  23012. var loc=parseInt(k);
  23013. var attribute=valueData[k];
  23014. gl.enableVertexAttribArray(loc);
  23015. gl.vertexAttribPointer(loc,attribute[0],attribute[1],!!attribute[2],attribute[3],attribute[4]);
  23016. WebGLContext._angleInstancedArrays.vertexAttribDivisorANGLE(loc,1);
  23017. }
  23018. }else {
  23019. throw "BufferState: must call bind() function first.";
  23020. }
  23021. }
  23022. }
  23023. /**
  23024. *@private
  23025. */
  23026. __proto.applyIndexBuffer=function(indexBuffer){
  23027. if (BufferStateBase._curBindedBufferState===this){
  23028. if (this._bindedIndexBuffer!==indexBuffer){
  23029. indexBuffer._bindForVAO();
  23030. this._bindedIndexBuffer=indexBuffer;
  23031. }
  23032. }else {
  23033. throw "BufferState: must call bind() function first.";
  23034. }
  23035. }
  23036. return BufferState;
  23037. })(BufferStateBase)
  23038. /**
  23039. *<code>ConeShape</code> 类用于创建锥形粒子形状。
  23040. */
  23041. //class laya.d3.core.particleShuriKen.module.shape.ConeShape extends laya.d3.core.particleShuriKen.module.shape.BaseShape
  23042. var ConeShape=(function(_super){
  23043. function ConeShape(){
  23044. /**发射角度。*/
  23045. this.angle=NaN;
  23046. /**发射器半径。*/
  23047. this.radius=NaN;
  23048. /**椎体长度。*/
  23049. this.length=NaN;
  23050. /**发射类型,0为Base,1为BaseShell,2为Volume,3为VolumeShell。*/
  23051. this.emitType=0;
  23052. ConeShape.__super.call(this);
  23053. this.angle=25.0 / 180.0 *Math.PI;
  23054. this.radius=1.0;
  23055. this.length=5.0;
  23056. this.emitType=0;
  23057. this.randomDirection=false;
  23058. }
  23059. __class(ConeShape,'laya.d3.core.particleShuriKen.module.shape.ConeShape',_super);
  23060. var __proto=ConeShape.prototype;
  23061. /**
  23062. *@inheritDoc
  23063. */
  23064. __proto._getShapeBoundBox=function(boundBox){
  23065. var coneRadius2=this.radius+this.length *Math.sin(this.angle);
  23066. var coneLength=this.length *Math.cos(this.angle);
  23067. var min=boundBox.min;
  23068. min.x=min.y=-coneRadius2;
  23069. min.z=0;
  23070. var max=boundBox.max;
  23071. max.x=max.y=coneRadius2;
  23072. max.z=coneLength;
  23073. }
  23074. /**
  23075. *@inheritDoc
  23076. */
  23077. __proto._getSpeedBoundBox=function(boundBox){
  23078. var sinA=Math.sin(this.angle);
  23079. var min=boundBox.min;
  23080. min.x=min.y=-sinA;
  23081. min.z=0;
  23082. var max=boundBox.max;
  23083. max.x=max.y=sinA;
  23084. max.z=1;
  23085. }
  23086. /**
  23087. *用于生成粒子初始位置和方向。
  23088. *@param position 粒子位置。
  23089. *@param direction 粒子方向。
  23090. */
  23091. __proto.generatePositionAndDirection=function(position,direction,rand,randomSeeds){
  23092. var positionPointE=ConeShape._tempPositionPoint;
  23093. var positionX=NaN;
  23094. var positionY=NaN;
  23095. var directionPointE;
  23096. var dirCosA=Math.cos(this.angle);
  23097. var dirSinA=Math.sin(this.angle);
  23098. switch (this.emitType){
  23099. case 0:
  23100. if (rand){
  23101. rand.seed=randomSeeds[16];
  23102. ShapeUtils._randomPointInsideUnitCircle(ConeShape._tempPositionPoint,rand);
  23103. randomSeeds[16]=rand.seed;
  23104. }else {
  23105. ShapeUtils._randomPointInsideUnitCircle(ConeShape._tempPositionPoint);
  23106. }
  23107. positionX=positionPointE.x;
  23108. positionY=positionPointE.y;
  23109. position.x=positionX *this.radius;
  23110. position.y=positionY *this.radius;
  23111. position.z=0;
  23112. if (this.randomDirection){
  23113. if (rand){
  23114. rand.seed=randomSeeds[17];
  23115. ShapeUtils._randomPointInsideUnitCircle(ConeShape._tempDirectionPoint,rand);
  23116. randomSeeds[17]=rand.seed;
  23117. }else {
  23118. ShapeUtils._randomPointInsideUnitCircle(ConeShape._tempDirectionPoint);
  23119. }
  23120. directionPointE=ConeShape._tempDirectionPoint;
  23121. direction.x=directionPointE.x *dirSinA;
  23122. direction.y=directionPointE.y *dirSinA;
  23123. }else {
  23124. direction.x=positionX *dirSinA;
  23125. direction.y=positionY *dirSinA;
  23126. }
  23127. direction.z=dirCosA;
  23128. break ;
  23129. case 1:
  23130. if (rand){
  23131. rand.seed=randomSeeds[16];
  23132. ShapeUtils._randomPointUnitCircle(ConeShape._tempPositionPoint,rand);
  23133. randomSeeds[16]=rand.seed;
  23134. }else {
  23135. ShapeUtils._randomPointUnitCircle(ConeShape._tempPositionPoint);
  23136. }
  23137. positionX=positionPointE.x;
  23138. positionY=positionPointE.y;
  23139. position.x=positionX *this.radius;
  23140. position.y=positionY *this.radius;
  23141. position.z=0;
  23142. if (this.randomDirection){
  23143. if (rand){
  23144. rand.seed=randomSeeds[17];
  23145. ShapeUtils._randomPointInsideUnitCircle(ConeShape._tempDirectionPoint,rand);
  23146. randomSeeds[17]=rand.seed;
  23147. }else {
  23148. ShapeUtils._randomPointInsideUnitCircle(ConeShape._tempDirectionPoint);
  23149. }
  23150. directionPointE=ConeShape._tempDirectionPoint;
  23151. direction.x=directionPointE.x *dirSinA;
  23152. direction.y=directionPointE.y *dirSinA;
  23153. }else {
  23154. direction.x=positionX *dirSinA;
  23155. direction.y=positionY *dirSinA;
  23156. }
  23157. direction.z=dirCosA;
  23158. break ;
  23159. case 2:
  23160. if (rand){
  23161. rand.seed=randomSeeds[16];
  23162. ShapeUtils._randomPointInsideUnitCircle(ConeShape._tempPositionPoint,rand);
  23163. }else {
  23164. ShapeUtils._randomPointInsideUnitCircle(ConeShape._tempPositionPoint);
  23165. }
  23166. positionX=positionPointE.x;
  23167. positionY=positionPointE.y;
  23168. position.x=positionX *this.radius;
  23169. position.y=positionY *this.radius;
  23170. position.z=0;
  23171. direction.x=positionX *dirSinA;
  23172. direction.y=positionY *dirSinA;
  23173. direction.z=dirCosA;
  23174. Vector3.normalize(direction,direction);
  23175. if (rand){
  23176. Vector3.scale(direction,this.length *rand.getFloat(),direction);
  23177. randomSeeds[16]=rand.seed;
  23178. }else {
  23179. Vector3.scale(direction,this.length *Math.random(),direction);
  23180. }
  23181. Vector3.add(position,direction,position);
  23182. if (this.randomDirection){
  23183. if (rand){
  23184. rand.seed=randomSeeds[17];
  23185. ShapeUtils._randomPointUnitSphere(direction,rand);
  23186. randomSeeds[17]=rand.seed;
  23187. }else {
  23188. ShapeUtils._randomPointUnitSphere(direction);
  23189. }
  23190. }
  23191. break ;
  23192. case 3:
  23193. if (rand){
  23194. rand.seed=randomSeeds[16];
  23195. ShapeUtils._randomPointUnitCircle(ConeShape._tempPositionPoint,rand);
  23196. }else {
  23197. ShapeUtils._randomPointUnitCircle(ConeShape._tempPositionPoint);
  23198. }
  23199. positionX=positionPointE.x;
  23200. positionY=positionPointE.y;
  23201. position.x=positionX *this.radius;
  23202. position.y=positionY *this.radius;
  23203. position.z=0;
  23204. direction.x=positionX *dirSinA;
  23205. direction.y=positionY *dirSinA;
  23206. direction.z=dirCosA;
  23207. Vector3.normalize(direction,direction);
  23208. if (rand){
  23209. Vector3.scale(direction,this.length *rand.getFloat(),direction);
  23210. randomSeeds[16]=rand.seed;
  23211. }else {
  23212. Vector3.scale(direction,this.length *Math.random(),direction);
  23213. }
  23214. Vector3.add(position,direction,position);
  23215. if (this.randomDirection){
  23216. if (rand){
  23217. rand.seed=randomSeeds[17];
  23218. ShapeUtils._randomPointUnitSphere(direction,rand);
  23219. randomSeeds[17]=rand.seed;
  23220. }else {
  23221. ShapeUtils._randomPointUnitSphere(direction);
  23222. }
  23223. }
  23224. break ;
  23225. default :
  23226. throw new Error("ConeShape:emitType is invalid.");
  23227. }
  23228. }
  23229. __proto.cloneTo=function(destObject){
  23230. _super.prototype.cloneTo.call(this,destObject);
  23231. var destShape=destObject;
  23232. destShape.angle=this.angle;
  23233. destShape.radius=this.radius;
  23234. destShape.length=this.length;
  23235. destShape.emitType=this.emitType;
  23236. destShape.randomDirection=this.randomDirection;
  23237. }
  23238. __static(ConeShape,
  23239. ['_tempPositionPoint',function(){return this._tempPositionPoint=new Vector2();},'_tempDirectionPoint',function(){return this._tempDirectionPoint=new Vector2();}
  23240. ]);
  23241. return ConeShape;
  23242. })(BaseShape)
  23243. /**
  23244. *<code>SphereColliderShape</code> 类用于创建球形碰撞器。
  23245. */
  23246. //class laya.d3.physics.shape.SphereColliderShape extends laya.d3.physics.shape.ColliderShape
  23247. var SphereColliderShape=(function(_super){
  23248. function SphereColliderShape(radius){
  23249. /**@private */
  23250. //this._radius=NaN;
  23251. SphereColliderShape.__super.call(this);
  23252. (radius===void 0)&& (radius=0.5);
  23253. this._radius=radius;
  23254. this._type=/*laya.d3.physics.shape.ColliderShape.SHAPETYPES_SPHERE*/1;
  23255. this._nativeShape=new Laya3D._physics3D.btSphereShape(radius);
  23256. }
  23257. __class(SphereColliderShape,'laya.d3.physics.shape.SphereColliderShape',_super);
  23258. var __proto=SphereColliderShape.prototype;
  23259. /**
  23260. *@inheritDoc
  23261. */
  23262. __proto.clone=function(){
  23263. var dest=new SphereColliderShape(this._radius);
  23264. this.cloneTo(dest);
  23265. return dest;
  23266. }
  23267. /**
  23268. *获取半径。
  23269. */
  23270. __getset(0,__proto,'radius',function(){
  23271. return this._radius;
  23272. });
  23273. return SphereColliderShape;
  23274. })(ColliderShape)
  23275. /**
  23276. *<code>CircleShape</code> 类用于创建环形粒子形状。
  23277. */
  23278. //class laya.d3.core.particleShuriKen.module.shape.CircleShape extends laya.d3.core.particleShuriKen.module.shape.BaseShape
  23279. var CircleShape=(function(_super){
  23280. function CircleShape(){
  23281. /**发射器半径。*/
  23282. this.radius=NaN;
  23283. /**环形弧度。*/
  23284. this.arc=NaN;
  23285. /**从边缘发射。*/
  23286. this.emitFromEdge=false;
  23287. CircleShape.__super.call(this);
  23288. this.radius=1.0;
  23289. this.arc=360.0 / 180.0 *Math.PI;
  23290. this.emitFromEdge=false;
  23291. this.randomDirection=false;
  23292. }
  23293. __class(CircleShape,'laya.d3.core.particleShuriKen.module.shape.CircleShape',_super);
  23294. var __proto=CircleShape.prototype;
  23295. /**
  23296. *@inheritDoc
  23297. */
  23298. __proto._getShapeBoundBox=function(boundBox){
  23299. var min=boundBox.min;
  23300. min.x=min.z=-this.radius;
  23301. min.y=0;
  23302. var max=boundBox.max;
  23303. max.x=max.z=this.radius;
  23304. max.y=0;
  23305. }
  23306. /**
  23307. *@inheritDoc
  23308. */
  23309. __proto._getSpeedBoundBox=function(boundBox){
  23310. var min=boundBox.min;
  23311. min.x=min.y=-1;
  23312. min.z=0;
  23313. var max=boundBox.max;
  23314. max.x=max.y=1;
  23315. max.z=0;
  23316. }
  23317. /**
  23318. *用于生成粒子初始位置和方向。
  23319. *@param position 粒子位置。
  23320. *@param direction 粒子方向。
  23321. */
  23322. __proto.generatePositionAndDirection=function(position,direction,rand,randomSeeds){
  23323. var positionPoint=CircleShape._tempPositionPoint;
  23324. if (rand){
  23325. rand.seed=randomSeeds[16];
  23326. if (this.emitFromEdge)
  23327. ShapeUtils._randomPointUnitArcCircle(this.arc,CircleShape._tempPositionPoint,rand);
  23328. else
  23329. ShapeUtils._randomPointInsideUnitArcCircle(this.arc,CircleShape._tempPositionPoint,rand);
  23330. randomSeeds[16]=rand.seed;
  23331. }else {
  23332. if (this.emitFromEdge)
  23333. ShapeUtils._randomPointUnitArcCircle(this.arc,CircleShape._tempPositionPoint);
  23334. else
  23335. ShapeUtils._randomPointInsideUnitArcCircle(this.arc,CircleShape._tempPositionPoint);
  23336. }
  23337. position.x=-positionPoint.x;
  23338. position.y=positionPoint.y;
  23339. position.z=0;
  23340. Vector3.scale(position,this.radius,position);
  23341. if (this.randomDirection){
  23342. if (rand){
  23343. rand.seed=randomSeeds[17];
  23344. ShapeUtils._randomPointUnitSphere(direction,rand);
  23345. randomSeeds[17]=rand.seed;
  23346. }else {
  23347. ShapeUtils._randomPointUnitSphere(direction);
  23348. }
  23349. }else {
  23350. position.cloneTo(direction);
  23351. }
  23352. }
  23353. __proto.cloneTo=function(destObject){
  23354. _super.prototype.cloneTo.call(this,destObject);
  23355. var destShape=destObject;
  23356. destShape.radius=this.radius;
  23357. destShape.arc=this.arc;
  23358. destShape.emitFromEdge=this.emitFromEdge;
  23359. destShape.randomDirection=this.randomDirection;
  23360. }
  23361. __static(CircleShape,
  23362. ['_tempPositionPoint',function(){return this._tempPositionPoint=new Vector2();}
  23363. ]);
  23364. return CircleShape;
  23365. })(BaseShape)
  23366. /**
  23367. *@private
  23368. *<code>BlitCMD</code> 类用于创建从一张渲染目标输出到另外一张渲染目标指令。
  23369. */
  23370. //class laya.d3.core.render.command.BlitCMD extends laya.d3.core.render.command.Command
  23371. var BlitCMD=(function(_super){
  23372. function BlitCMD(){
  23373. /**@private */
  23374. this._source=null;
  23375. /**@private */
  23376. this._dest=null;
  23377. /**@private */
  23378. this._shader=null;
  23379. /**@private */
  23380. this._shaderData=null;
  23381. /**@private */
  23382. this._subShader=0;
  23383. BlitCMD.__super.call(this);
  23384. }
  23385. __class(BlitCMD,'laya.d3.core.render.command.BlitCMD',_super);
  23386. var __proto=BlitCMD.prototype;
  23387. /**
  23388. *@inheritDoc
  23389. */
  23390. __proto.run=function(){
  23391. this._shaderData.setTexture(CommandBuffer.SCREENTEXTURE_ID,this._source);
  23392. var dest=this._dest;
  23393. if (dest)
  23394. dest._start();
  23395. var subShader=this._shader.getSubShaderAt(this._subShader);
  23396. var passes=subShader._passes;
  23397. for (var i=0,n=passes.length;i < n;i++){
  23398. var shaderPass=passes[i].withCompile(0,0,0);
  23399. shaderPass.bind();
  23400. (this._shaderData)&& (shaderPass.uploadUniforms(shaderPass._materialUniformParamsMap,this._shaderData,true));
  23401. shaderPass.uploadRenderStateBlendDepth(this._shaderData);
  23402. shaderPass.uploadRenderStateFrontFace(this._shaderData,true,null);
  23403. ScreenQuad.instance.render();
  23404. }
  23405. if (dest)
  23406. dest._end();
  23407. }
  23408. /**
  23409. *@inheritDoc
  23410. */
  23411. __proto.recover=function(){
  23412. BlitCMD._pool.push(this);
  23413. this._dest=null;
  23414. this._shader=null;
  23415. this._shaderData=null;
  23416. }
  23417. BlitCMD.create=function(source,dest,shader,shaderData,subShader){
  23418. (subShader===void 0)&& (subShader=0);
  23419. var cmd;
  23420. cmd=BlitCMD._pool.length > 0 ? BlitCMD._pool.pop():new BlitCMD();
  23421. cmd._source=source;
  23422. cmd._dest=dest;
  23423. cmd._shader=shader;
  23424. cmd._shaderData=shaderData;
  23425. cmd._subShader=subShader;
  23426. return cmd;
  23427. }
  23428. BlitCMD._pool=[];
  23429. return BlitCMD;
  23430. })(Command)
  23431. /**
  23432. *<code>CastShadowList</code> 类用于实现产生阴影者队列。
  23433. */
  23434. //class laya.d3.CastShadowList extends laya.d3.component.SingletonList
  23435. var CastShadowList=(function(_super){
  23436. /**
  23437. *创建一个新的 <code>CastShadowList</code> 实例。
  23438. */
  23439. function CastShadowList(){
  23440. CastShadowList.__super.call(this);
  23441. }
  23442. __class(CastShadowList,'laya.d3.CastShadowList',_super);
  23443. var __proto=CastShadowList.prototype;
  23444. /**
  23445. *@private
  23446. */
  23447. __proto.add=function(element){
  23448. var index=element._indexInCastShadowList;
  23449. if (index!==-1)
  23450. throw "CastShadowList:element has in CastShadowList.";
  23451. this._add(element);
  23452. element._indexInCastShadowList=this.length++;
  23453. }
  23454. /**
  23455. *@private
  23456. */
  23457. __proto.remove=function(element){
  23458. var index=element._indexInCastShadowList;
  23459. this.length--;
  23460. if (index!==this.length){
  23461. var end=this.elements[this.length];
  23462. this.elements[index]=end;
  23463. end._indexInCastShadowList=index;
  23464. }
  23465. element._indexInCastShadowList=-1;
  23466. }
  23467. return CastShadowList;
  23468. })(SingletonList)
  23469. /**
  23470. *<code>CapsuleColliderShape</code> 类用于创建胶囊形状碰撞器。
  23471. */
  23472. //class laya.d3.physics.shape.CapsuleColliderShape extends laya.d3.physics.shape.ColliderShape
  23473. var CapsuleColliderShape=(function(_super){
  23474. function CapsuleColliderShape(radius,length,orientation){
  23475. /**@private */
  23476. //this._radius=NaN;
  23477. /**@private */
  23478. //this._length=NaN;
  23479. /**@private */
  23480. //this._orientation=0;
  23481. CapsuleColliderShape.__super.call(this);
  23482. (radius===void 0)&& (radius=0.5);
  23483. (length===void 0)&& (length=1.25);
  23484. (orientation===void 0)&& (orientation=/*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPY*/1);
  23485. this._radius=radius;
  23486. this._length=length;
  23487. this._orientation=orientation;
  23488. this._type=/*laya.d3.physics.shape.ColliderShape.SHAPETYPES_CAPSULE*/3;
  23489. switch (orientation){
  23490. case /*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPX*/0:
  23491. this._nativeShape=new Laya3D._physics3D.btCapsuleShapeX(radius,length-radius *2);
  23492. break ;
  23493. case /*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPY*/1:
  23494. this._nativeShape=new Laya3D._physics3D.btCapsuleShape(radius,length-radius *2);
  23495. break ;
  23496. case /*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPZ*/2:
  23497. this._nativeShape=new Laya3D._physics3D.btCapsuleShapeZ(radius,length-radius *2);
  23498. break ;
  23499. default :
  23500. throw "CapsuleColliderShape:unknown orientation.";
  23501. }
  23502. }
  23503. __class(CapsuleColliderShape,'laya.d3.physics.shape.CapsuleColliderShape',_super);
  23504. var __proto=CapsuleColliderShape.prototype;
  23505. /**
  23506. *@inheritDoc
  23507. */
  23508. __proto._setScale=function(value){
  23509. var fixScale=CapsuleColliderShape._tempVector30;
  23510. switch (this.orientation){
  23511. case /*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPX*/0:
  23512. fixScale.x=value.x;
  23513. fixScale.y=fixScale.z=Math.max(value.y,value.z);
  23514. break ;
  23515. case /*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPY*/1:
  23516. fixScale.y=value.y;
  23517. fixScale.x=fixScale.z=Math.max(value.x,value.z);
  23518. break ;
  23519. case /*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPZ*/2:
  23520. fixScale.z=value.z;
  23521. fixScale.x=fixScale.y=Math.max(value.x,value.y);
  23522. break ;
  23523. default :
  23524. throw "CapsuleColliderShape:unknown orientation.";
  23525. }
  23526. _super.prototype._setScale.call(this,fixScale);
  23527. }
  23528. /**
  23529. *@inheritDoc
  23530. */
  23531. __proto.clone=function(){
  23532. var dest=new CapsuleColliderShape(this._radius,this._length,this._orientation);
  23533. this.cloneTo(dest);
  23534. return dest;
  23535. }
  23536. /**
  23537. *获取半径。
  23538. */
  23539. __getset(0,__proto,'radius',function(){
  23540. return this._radius;
  23541. });
  23542. /**
  23543. *获取长度。
  23544. */
  23545. __getset(0,__proto,'length',function(){
  23546. return this._length;
  23547. });
  23548. /**
  23549. *获取方向。
  23550. */
  23551. __getset(0,__proto,'orientation',function(){
  23552. return this._orientation;
  23553. });
  23554. __static(CapsuleColliderShape,
  23555. ['_tempVector30',function(){return this._tempVector30=new Vector3();}
  23556. ]);
  23557. return CapsuleColliderShape;
  23558. })(ColliderShape)
  23559. /**
  23560. *<code>SubMesh</code> 类用于创建子网格数据模板。
  23561. */
  23562. //class laya.d3.resource.models.SubMesh extends laya.d3.core.GeometryElement
  23563. var SubMesh=(function(_super){
  23564. function SubMesh(mesh){
  23565. /**@private */
  23566. this._mesh=null;
  23567. /**@private */
  23568. this._boneIndicesList=null;
  23569. /**@private */
  23570. this._subIndexBufferStart=null;
  23571. /**@private */
  23572. this._subIndexBufferCount=null;
  23573. /**@private */
  23574. this._skinAnimationDatas=null;
  23575. /**@private */
  23576. this._indexInMesh=0;
  23577. /**@private */
  23578. this._vertexStart=0;
  23579. /**@private */
  23580. this._indexStart=0;
  23581. /**@private */
  23582. this._indexCount=0;
  23583. /**@private */
  23584. this._indices=null;
  23585. /**@private [只读]*/
  23586. this._vertexBuffer=null;
  23587. /**@private [只读]*/
  23588. this._indexBuffer=null;
  23589. /**@private */
  23590. this._id=0;
  23591. SubMesh.__super.call(this);
  23592. this._id=++SubMesh._uniqueIDCounter;
  23593. this._mesh=mesh;
  23594. this._boneIndicesList=[];
  23595. this._subIndexBufferStart=[];
  23596. this._subIndexBufferCount=[];
  23597. }
  23598. __class(SubMesh,'laya.d3.resource.models.SubMesh',_super);
  23599. var __proto=SubMesh.prototype;
  23600. /**
  23601. *@inheritDoc
  23602. */
  23603. __proto._getType=function(){
  23604. return SubMesh._type;
  23605. }
  23606. /**
  23607. *@inheritDoc
  23608. */
  23609. __proto._render=function(state){
  23610. this._mesh._bufferState.bind();
  23611. var skinnedDatas=(state.renderElement.render)._skinnedData;
  23612. if (skinnedDatas){
  23613. var subSkinnedDatas=skinnedDatas[this._indexInMesh];
  23614. var boneIndicesListCount=this._boneIndicesList.length;
  23615. for (var i=0;i < boneIndicesListCount;i++){
  23616. state.shader.uploadCustomUniform(SkinnedMeshSprite3D.BONES,subSkinnedDatas[i]);
  23617. LayaGL.instance.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,this._subIndexBufferCount[i],/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,this._subIndexBufferStart[i] *2);
  23618. }
  23619. }else {
  23620. LayaGL.instance.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,this._indexCount,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,this._indexStart *2);
  23621. }
  23622. Stat.trianglesFaces+=this._indexCount / 3;
  23623. Stat.renderBatches++;
  23624. }
  23625. /**
  23626. *@private
  23627. */
  23628. __proto.getIndices=function(){
  23629. return this._indices;
  23630. }
  23631. /**
  23632. *@inheritDoc
  23633. */
  23634. __proto.destroy=function(){
  23635. if (this._destroyed)
  23636. return;
  23637. _super.prototype.destroy.call(this);
  23638. this._indexBuffer.destroy();
  23639. this._indexBuffer=null;
  23640. this._mesh=null;
  23641. this._boneIndicesList=null;
  23642. this._subIndexBufferStart=null;
  23643. this._subIndexBufferCount=null;
  23644. this._skinAnimationDatas=null;
  23645. }
  23646. SubMesh._uniqueIDCounter=0;
  23647. __static(SubMesh,
  23648. ['_type',function(){return this._type=GeometryElement._typeCounter++;}
  23649. ]);
  23650. return SubMesh;
  23651. })(GeometryElement)
  23652. /**
  23653. *<code>ShurikenParticleSystem</code> 类用于创建3D粒子数据模板。
  23654. */
  23655. //class laya.d3.core.particleShuriKen.ShurikenParticleSystem extends laya.d3.core.GeometryElement
  23656. var ShurikenParticleSystem=(function(_super){
  23657. function ShurikenParticleSystem(owner){
  23658. /**@private */
  23659. //this._boundingSphere=null;
  23660. /**@private */
  23661. //this._boundingBox=null;
  23662. /**@private */
  23663. //this._boundingBoxCorners=null;
  23664. /**@private */
  23665. //this._owner=null;
  23666. /**@private */
  23667. //this._ownerRender=null;
  23668. /**@private */
  23669. //this._vertices=null;
  23670. /**@private */
  23671. //this._floatCountPerVertex=0;
  23672. /**@private */
  23673. //this._startLifeTimeIndex=0;
  23674. /**@private */
  23675. //this._timeIndex=0;
  23676. /**@private */
  23677. //this._simulateUpdate=false;
  23678. /**@private */
  23679. //this._firstActiveElement=0;
  23680. /**@private */
  23681. //this._firstNewElement=0;
  23682. /**@private */
  23683. //this._firstFreeElement=0;
  23684. /**@private */
  23685. //this._firstRetiredElement=0;
  23686. /**@private */
  23687. //this._drawCounter=0;
  23688. /**@private */
  23689. //this._bufferMaxParticles=0;
  23690. /**@private */
  23691. //this._emission=null;
  23692. /**@private */
  23693. //this._shape=null;
  23694. /**@private */
  23695. //this._isEmitting=false;
  23696. /**@private */
  23697. //this._isPlaying=false;
  23698. /**@private */
  23699. //this._isPaused=false;
  23700. /**@private */
  23701. //this._playStartDelay=NaN;
  23702. /**@private 发射的累计时间。*/
  23703. //this._frameRateTime=NaN;
  23704. /**@private 一次循环内的累计时间。*/
  23705. //this._emissionTime=NaN;
  23706. /**@private */
  23707. //this._totalDelayTime=NaN;
  23708. /**@private */
  23709. //this._burstsIndex=0;
  23710. /**@private */
  23711. //this._velocityOverLifetime=null;
  23712. /**@private */
  23713. //this._colorOverLifetime=null;
  23714. /**@private */
  23715. //this._sizeOverLifetime=null;
  23716. /**@private */
  23717. //this._rotationOverLifetime=null;
  23718. /**@private */
  23719. //this._textureSheetAnimation=null;
  23720. /**@private */
  23721. //this._startLifetimeType=0;
  23722. /**@private */
  23723. //this._startLifetimeConstant=NaN;
  23724. /**@private */
  23725. //this._startLifeTimeGradient=null;
  23726. /**@private */
  23727. //this._startLifetimeConstantMin=NaN;
  23728. /**@private */
  23729. //this._startLifetimeConstantMax=NaN;
  23730. /**@private */
  23731. //this._startLifeTimeGradientMin=null;
  23732. /**@private */
  23733. //this._startLifeTimeGradientMax=null;
  23734. /**@private */
  23735. //this._maxStartLifetime=NaN;
  23736. /**@private */
  23737. //this._vertexStride=0;
  23738. /**@private */
  23739. //this._indexStride=0;
  23740. /**@private */
  23741. //this._vertexBuffer=null;
  23742. /**@private */
  23743. //this._indexBuffer=null;
  23744. /**@private */
  23745. //this._currentTime=NaN;
  23746. /**@private */
  23747. //this._startUpdateLoopCount=0;
  23748. /**@private */
  23749. //this._rand=null;
  23750. /**@private */
  23751. //this._randomSeeds=null;
  23752. /**粒子运行的总时长,单位为秒。*/
  23753. //this.duration=NaN;
  23754. /**是否循环。*/
  23755. //this.looping=false;
  23756. /**是否预热。暂不支持*/
  23757. //this.prewarm=false;
  23758. /**开始延迟类型,0为常量模式,1为随机随机双常量模式,不能和prewarm一起使用。*/
  23759. //this.startDelayType=0;
  23760. /**开始播放延迟,不能和prewarm一起使用。*/
  23761. //this.startDelay=NaN;
  23762. /**开始播放最小延迟,不能和prewarm一起使用。*/
  23763. //this.startDelayMin=NaN;
  23764. /**开始播放最大延迟,不能和prewarm一起使用。*/
  23765. //this.startDelayMax=NaN;
  23766. /**开始速度模式,0为恒定速度,2为两个恒定速度的随机插值。缺少1、3模式*/
  23767. //this.startSpeedType=0;
  23768. /**开始速度,0模式。*/
  23769. //this.startSpeedConstant=NaN;
  23770. /**最小开始速度,1模式。*/
  23771. //this.startSpeedConstantMin=NaN;
  23772. /**最大开始速度,1模式。*/
  23773. //this.startSpeedConstantMax=NaN;
  23774. /**开始尺寸是否为3D模式。*/
  23775. //this.threeDStartSize=false;
  23776. /**开始尺寸模式,0为恒定尺寸,2为两个恒定尺寸的随机插值。缺少1、3模式和对应的二种3D模式*/
  23777. //this.startSizeType=0;
  23778. /**开始尺寸,0模式。*/
  23779. //this.startSizeConstant=NaN;
  23780. /**开始三维尺寸,0模式。*/
  23781. //this.startSizeConstantSeparate=null;
  23782. /**最小开始尺寸,2模式。*/
  23783. //this.startSizeConstantMin=NaN;
  23784. /**最大开始尺寸,2模式。*/
  23785. //this.startSizeConstantMax=NaN;
  23786. /**最小三维开始尺寸,2模式。*/
  23787. //this.startSizeConstantMinSeparate=null;
  23788. /**最大三维开始尺寸,2模式。*/
  23789. //this.startSizeConstantMaxSeparate=null;
  23790. /**3D开始旋转,暂不支持*/
  23791. //this.threeDStartRotation=false;
  23792. /**开始旋转模式,0为恒定尺寸,2为两个恒定旋转的随机插值,缺少2种模式,和对应的四种3D模式。*/
  23793. //this.startRotationType=0;
  23794. /**开始旋转,0模式。*/
  23795. //this.startRotationConstant=NaN;
  23796. /**开始三维旋转,0模式。*/
  23797. //this.startRotationConstantSeparate=null;
  23798. /**最小开始旋转,1模式。*/
  23799. //this.startRotationConstantMin=NaN;
  23800. /**最大开始旋转,1模式。*/
  23801. //this.startRotationConstantMax=NaN;
  23802. /**最小开始三维旋转,1模式。*/
  23803. //this.startRotationConstantMinSeparate=null;
  23804. /**最大开始三维旋转,1模式。*/
  23805. //this.startRotationConstantMaxSeparate=null;
  23806. /**随机旋转方向,范围为0.0到1.0*/
  23807. //this.randomizeRotationDirection=NaN;
  23808. /**开始颜色模式,0为恒定颜色,2为两个恒定颜色的随机插值,缺少2种模式。*/
  23809. //this.startColorType=0;
  23810. /**开始颜色,0模式。*/
  23811. //this.startColorConstant=null;
  23812. /**最小开始颜色,1模式。*/
  23813. //this.startColorConstantMin=null;
  23814. /**最大开始颜色,1模式。*/
  23815. //this.startColorConstantMax=null;
  23816. /**重力敏感度。*/
  23817. //this.gravityModifier=NaN;
  23818. /**模拟器空间,0为World,1为Local。暂不支持Custom。*/
  23819. //this.simulationSpace=0;
  23820. /**缩放模式,0为Hiercachy,1为Local,2为World。*/
  23821. //this.scaleMode=0;
  23822. /**激活时是否自动播放。*/
  23823. //this.playOnAwake=false;
  23824. /**随机种子,注:play()前设置有效。*/
  23825. //this.randomSeed=null;
  23826. /**是否使用随机种子。 */
  23827. //this.autoRandomSeed=false;
  23828. /**是否为性能模式,性能模式下会延迟粒子释放。*/
  23829. //this.isPerformanceMode=false;
  23830. ShurikenParticleSystem.__super.call(this);
  23831. this._tempRotationMatrix=new Matrix4x4();
  23832. this._uvLength=new Vector2();
  23833. this._bufferState=new BufferState();
  23834. this._firstActiveElement=0;
  23835. this._firstNewElement=0;
  23836. this._firstFreeElement=0;
  23837. this._firstRetiredElement=0;
  23838. this._owner=owner;
  23839. this._ownerRender=owner.particleRenderer;
  23840. this._boundingBoxCorners=__newvec(8,null);
  23841. this._boundingSphere=new BoundSphere(new Vector3(),Number.MAX_VALUE);
  23842. this._boundingBox=new BoundBox(new Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),new Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE));
  23843. this._currentTime=0;
  23844. this._isEmitting=false;
  23845. this._isPlaying=false;
  23846. this._isPaused=false;
  23847. this._burstsIndex=0;
  23848. this._frameRateTime=0;
  23849. this._emissionTime=0;
  23850. this._totalDelayTime=0;
  23851. this._simulateUpdate=false;
  23852. this._bufferMaxParticles=1;
  23853. this.duration=5.0;
  23854. this.looping=true;
  23855. this.prewarm=false;
  23856. this.startDelayType=0;
  23857. this.startDelay=0.0;
  23858. this.startDelayMin=0.0;
  23859. this.startDelayMax=0.0;
  23860. this._startLifetimeType=0;
  23861. this._startLifetimeConstant=5.0;
  23862. this._startLifeTimeGradient=new GradientDataNumber();
  23863. this._startLifetimeConstantMin=0.0;
  23864. this._startLifetimeConstantMax=5.0;
  23865. this._startLifeTimeGradientMin=new GradientDataNumber();
  23866. this._startLifeTimeGradientMax=new GradientDataNumber();
  23867. this._maxStartLifetime=5.0;
  23868. this.startSpeedType=0;
  23869. this.startSpeedConstant=5.0;
  23870. this.startSpeedConstantMin=0.0;
  23871. this.startSpeedConstantMax=5.0;
  23872. this.threeDStartSize=false;
  23873. this.startSizeType=0;
  23874. this.startSizeConstant=1;
  23875. this.startSizeConstantSeparate=new Vector3(1,1,1);
  23876. this.startSizeConstantMin=0;
  23877. this.startSizeConstantMax=1;
  23878. this.startSizeConstantMinSeparate=new Vector3(0,0,0);
  23879. this.startSizeConstantMaxSeparate=new Vector3(1,1,1);
  23880. this.threeDStartRotation=false;
  23881. this.startRotationType=0;
  23882. this.startRotationConstant=0;
  23883. this.startRotationConstantSeparate=new Vector3(0,0,0);
  23884. this.startRotationConstantMin=0.0;
  23885. this.startRotationConstantMax=0.0;
  23886. this.startRotationConstantMinSeparate=new Vector3(0,0,0);
  23887. this.startRotationConstantMaxSeparate=new Vector3(0,0,0);
  23888. this.randomizeRotationDirection=0.0;
  23889. this.startColorType=0;
  23890. this.startColorConstant=new Vector4(1,1,1,1);
  23891. this.startColorConstantMin=new Vector4(1,1,1,1);
  23892. this.startColorConstantMax=new Vector4(1,1,1,1);
  23893. this.gravityModifier=0.0;
  23894. this.simulationSpace=1;
  23895. this.scaleMode=0;
  23896. this.playOnAwake=true;
  23897. this._rand=new Rand(0);
  23898. this.autoRandomSeed=true;
  23899. this.randomSeed=new Uint32Array(1);
  23900. this._randomSeeds=new Uint32Array(ShurikenParticleSystem._RANDOMOFFSET.length);
  23901. this.isPerformanceMode=true;
  23902. this._emission=new Emission();
  23903. this._emission.enbale=true;
  23904. }
  23905. __class(ShurikenParticleSystem,'laya.d3.core.particleShuriKen.ShurikenParticleSystem',_super);
  23906. var __proto=ShurikenParticleSystem.prototype;
  23907. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  23908. __proto._getVertexBuffer=function(index){
  23909. (index===void 0)&& (index=0);
  23910. if (index===0)
  23911. return this._vertexBuffer;
  23912. else
  23913. return null;
  23914. }
  23915. __proto._getIndexBuffer=function(){
  23916. return this._indexBuffer;
  23917. }
  23918. /**
  23919. *@private
  23920. */
  23921. __proto._generateBoundingSphere=function(){
  23922. var centerE=this._boundingSphere.center;
  23923. centerE.x=0;
  23924. centerE.y=0;
  23925. centerE.z=0;
  23926. this._boundingSphere.radius=Number.MAX_VALUE;
  23927. }
  23928. /**
  23929. *@private
  23930. */
  23931. __proto._generateBoundingBox=function(){
  23932. var particle=this._owner;
  23933. var particleRender=particle.particleRenderer;
  23934. var boundMin=this._boundingBox.min;
  23935. var boundMax=this._boundingBox.max;
  23936. var i=0,n=0;
  23937. var maxStartLifeTime=NaN;
  23938. switch (this.startLifetimeType){
  23939. case 0:
  23940. maxStartLifeTime=this.startLifetimeConstant;
  23941. break ;
  23942. case 1:
  23943. maxStartLifeTime=-Number.MAX_VALUE;
  23944. var startLifeTimeGradient=startLifeTimeGradient;
  23945. for (i=0,n=startLifeTimeGradient.gradientCount;i < n;i++)
  23946. maxStartLifeTime=Math.max(maxStartLifeTime,startLifeTimeGradient.getValueByIndex(i));
  23947. break ;
  23948. case 2:
  23949. maxStartLifeTime=Math.max(this.startLifetimeConstantMin,this.startLifetimeConstantMax);
  23950. break ;
  23951. case 3:
  23952. maxStartLifeTime=-Number.MAX_VALUE;
  23953. var startLifeTimeGradientMin=startLifeTimeGradientMin;
  23954. for (i=0,n=startLifeTimeGradientMin.gradientCount;i < n;i++)
  23955. maxStartLifeTime=Math.max(maxStartLifeTime,startLifeTimeGradientMin.getValueByIndex(i));
  23956. var startLifeTimeGradientMax=startLifeTimeGradientMax;
  23957. for (i=0,n=startLifeTimeGradientMax.gradientCount;i < n;i++)
  23958. maxStartLifeTime=Math.max(maxStartLifeTime,startLifeTimeGradientMax.getValueByIndex(i));
  23959. break ;
  23960. };
  23961. var minStartSpeed=NaN,maxStartSpeed=NaN;
  23962. switch (this.startSpeedType){
  23963. case 0:
  23964. minStartSpeed=maxStartSpeed=this.startSpeedConstant;
  23965. break ;
  23966. case 1:
  23967. break ;
  23968. case 2:
  23969. minStartSpeed=this.startLifetimeConstantMin;
  23970. maxStartSpeed=this.startLifetimeConstantMax;
  23971. break ;
  23972. case 3:
  23973. break ;
  23974. };
  23975. var minPosition,maxPosition,minDirection,maxDirection;
  23976. if (this._shape && this._shape.enable){
  23977. }else {
  23978. minPosition=maxPosition=Vector3._ZERO;
  23979. minDirection=Vector3._ZERO;
  23980. maxDirection=Vector3._UnitZ;
  23981. };
  23982. var startMinVelocity=new Vector3(minDirection.x *minStartSpeed,minDirection.y *minStartSpeed,minDirection.z *minStartSpeed);
  23983. var startMaxVelocity=new Vector3(maxDirection.x *maxStartSpeed,maxDirection.y *maxStartSpeed,maxDirection.z *maxStartSpeed);
  23984. if (this._velocityOverLifetime && this._velocityOverLifetime.enbale){
  23985. var lifeMinVelocity;
  23986. var lifeMaxVelocity;
  23987. var velocity=this._velocityOverLifetime.velocity;
  23988. switch (velocity.type){
  23989. case 0:
  23990. lifeMinVelocity=lifeMaxVelocity=velocity.constant;
  23991. break ;
  23992. case 1:
  23993. lifeMinVelocity=lifeMaxVelocity=new Vector3(velocity.gradientX.getAverageValue(),velocity.gradientY.getAverageValue(),velocity.gradientZ.getAverageValue());
  23994. break ;
  23995. case 2:
  23996. lifeMinVelocity=velocity.constantMin;
  23997. lifeMaxVelocity=velocity.constantMax;
  23998. break ;
  23999. case 3:
  24000. lifeMinVelocity=new Vector3(velocity.gradientXMin.getAverageValue(),velocity.gradientYMin.getAverageValue(),velocity.gradientZMin.getAverageValue());
  24001. lifeMaxVelocity=new Vector3(velocity.gradientXMax.getAverageValue(),velocity.gradientYMax.getAverageValue(),velocity.gradientZMax.getAverageValue());
  24002. break ;
  24003. }
  24004. };
  24005. var positionScale,velocityScale;
  24006. var transform=this._owner.transform;
  24007. var worldPosition=transform.position;
  24008. var sizeScale=ShurikenParticleSystem._tempVector39;
  24009. var renderMode=particleRender.renderMode;
  24010. switch (this.scaleMode){
  24011. case 0:;
  24012. var scale=transform.scale;
  24013. positionScale=scale;
  24014. sizeScale.x=scale.x;
  24015. sizeScale.y=scale.z;
  24016. sizeScale.z=scale.y;
  24017. (renderMode===1)&& (velocityScale=scale);
  24018. break ;
  24019. case 1:;
  24020. var localScale=transform.localScale;
  24021. positionScale=localScale;
  24022. sizeScale.x=localScale.x;
  24023. sizeScale.y=localScale.z;
  24024. sizeScale.z=localScale.y;
  24025. (renderMode===1)&& (velocityScale=localScale);
  24026. break ;
  24027. case 2:
  24028. positionScale=transform.scale;
  24029. sizeScale.x=sizeScale.y=sizeScale.z=1;
  24030. (renderMode===1)&& (velocityScale=Vector3._ONE);
  24031. break ;
  24032. };
  24033. var minStratPosition,maxStratPosition;
  24034. if (this._velocityOverLifetime && this._velocityOverLifetime.enbale){
  24035. }else {
  24036. minStratPosition=new Vector3(startMinVelocity.x *maxStartLifeTime,startMinVelocity.y *maxStartLifeTime,startMinVelocity.z *maxStartLifeTime);
  24037. maxStratPosition=new Vector3(startMaxVelocity.x *maxStartLifeTime,startMaxVelocity.y *maxStartLifeTime,startMaxVelocity.z *maxStartLifeTime);
  24038. if (this.scaleMode !=2){
  24039. Vector3.add(minPosition,minStratPosition,boundMin);
  24040. Vector3.multiply(positionScale,boundMin,boundMin);
  24041. Vector3.add(maxPosition,maxStratPosition,boundMax);
  24042. Vector3.multiply(positionScale,boundMax,boundMax);
  24043. }else {
  24044. Vector3.multiply(positionScale,minPosition,boundMin);
  24045. Vector3.add(boundMin,minStratPosition,boundMin);
  24046. Vector3.multiply(positionScale,maxPosition,boundMax);
  24047. Vector3.add(boundMax,maxStratPosition,boundMax);
  24048. }
  24049. }
  24050. switch (this.simulationSpace){
  24051. case 0:
  24052. break ;
  24053. case 1:
  24054. Vector3.add(boundMin,worldPosition,boundMin);
  24055. Vector3.add(boundMax,worldPosition,boundMax);
  24056. break ;
  24057. };
  24058. var maxSize=NaN,maxSizeY=NaN;
  24059. switch (this.startSizeType){
  24060. case 0:
  24061. if (this.threeDStartSize){
  24062. var startSizeConstantSeparate=startSizeConstantSeparate;
  24063. maxSize=Math.max(startSizeConstantSeparate.x,startSizeConstantSeparate.y);
  24064. if (renderMode===1)
  24065. maxSizeY=startSizeConstantSeparate.y;
  24066. }else {
  24067. maxSize=this.startSizeConstant;
  24068. if (renderMode===1)
  24069. maxSizeY=this.startSizeConstant;
  24070. }
  24071. break ;
  24072. case 1:
  24073. break ;
  24074. case 2:
  24075. if (this.threeDStartSize){
  24076. var startSizeConstantMaxSeparate=startSizeConstantMaxSeparate;
  24077. maxSize=Math.max(startSizeConstantMaxSeparate.x,startSizeConstantMaxSeparate.y);
  24078. if (renderMode===1)
  24079. maxSizeY=startSizeConstantMaxSeparate.y;
  24080. }else {
  24081. maxSize=this.startSizeConstantMax;
  24082. if (renderMode===1)
  24083. maxSizeY=this.startSizeConstantMax;
  24084. }
  24085. break ;
  24086. case 3:
  24087. break ;
  24088. }
  24089. if (this._sizeOverLifetime && this._sizeOverLifetime.enbale){
  24090. var size=this._sizeOverLifetime.size;
  24091. maxSize *=this._sizeOverLifetime.size.getMaxSizeInGradient();
  24092. };
  24093. var threeDMaxSize=ShurikenParticleSystem._tempVector30;
  24094. var rotSize=NaN,nonRotSize=NaN;
  24095. switch (renderMode){
  24096. case 0:
  24097. rotSize=maxSize *ShurikenParticleSystem.halfKSqrtOf2;
  24098. Vector3.scale(sizeScale,maxSize,threeDMaxSize);
  24099. Vector3.subtract(boundMin,threeDMaxSize,boundMin);
  24100. Vector3.add(boundMax,threeDMaxSize,boundMax);
  24101. break ;
  24102. case 1:;
  24103. var maxStretchPosition=ShurikenParticleSystem._tempVector31;
  24104. var maxStretchVelocity=ShurikenParticleSystem._tempVector32;
  24105. var minStretchVelocity=ShurikenParticleSystem._tempVector33;
  24106. var minStretchPosition=ShurikenParticleSystem._tempVector34;
  24107. if (this._velocityOverLifetime && this._velocityOverLifetime.enbale){
  24108. }else {
  24109. Vector3.multiply(velocityScale,startMaxVelocity,maxStretchVelocity);
  24110. Vector3.multiply(velocityScale,startMinVelocity,minStretchVelocity);
  24111. };
  24112. var sizeStretch=maxSizeY *particleRender.stretchedBillboardLengthScale;
  24113. var maxStretchLength=Vector3.scalarLength(maxStretchVelocity)*particleRender.stretchedBillboardSpeedScale+sizeStretch;
  24114. var minStretchLength=Vector3.scalarLength(minStretchVelocity)*particleRender.stretchedBillboardSpeedScale+sizeStretch;
  24115. var norMaxStretchVelocity=ShurikenParticleSystem._tempVector35;
  24116. var norMinStretchVelocity=ShurikenParticleSystem._tempVector36;
  24117. Vector3.normalize(maxStretchVelocity,norMaxStretchVelocity);
  24118. Vector3.scale(norMaxStretchVelocity,maxStretchLength,minStretchPosition);
  24119. Vector3.subtract(maxStratPosition,minStretchPosition,minStretchPosition);
  24120. Vector3.normalize(minStretchVelocity,norMinStretchVelocity);
  24121. Vector3.scale(norMinStretchVelocity,minStretchLength,maxStretchPosition);
  24122. Vector3.add(minStratPosition,maxStretchPosition,maxStretchPosition);
  24123. rotSize=maxSize *ShurikenParticleSystem.halfKSqrtOf2;
  24124. Vector3.scale(sizeScale,rotSize,threeDMaxSize);
  24125. var halfNorMaxStretchVelocity=ShurikenParticleSystem._tempVector37;
  24126. var halfNorMinStretchVelocity=ShurikenParticleSystem._tempVector38;
  24127. Vector3.scale(norMaxStretchVelocity,0.5,halfNorMaxStretchVelocity);
  24128. Vector3.scale(norMinStretchVelocity,0.5,halfNorMinStretchVelocity);
  24129. Vector3.multiply(halfNorMaxStretchVelocity,sizeScale,halfNorMaxStretchVelocity);
  24130. Vector3.multiply(halfNorMinStretchVelocity,sizeScale,halfNorMinStretchVelocity);
  24131. Vector3.add(boundMin,halfNorMinStretchVelocity,boundMin);
  24132. Vector3.min(boundMin,minStretchPosition,boundMin);
  24133. Vector3.subtract(boundMin,threeDMaxSize,boundMin);
  24134. Vector3.subtract(boundMax,halfNorMaxStretchVelocity,boundMax);
  24135. Vector3.max(boundMax,maxStretchPosition,boundMax);
  24136. Vector3.add(boundMax,threeDMaxSize,boundMax);
  24137. break ;
  24138. case 2:
  24139. maxSize *=Math.cos(0.78539816339744830961566084581988);
  24140. nonRotSize=maxSize *0.5;
  24141. threeDMaxSize.x=sizeScale.x *nonRotSize;
  24142. threeDMaxSize.y=sizeScale.z *nonRotSize;
  24143. Vector3.subtract(boundMin,threeDMaxSize,boundMin);
  24144. Vector3.add(boundMax,threeDMaxSize,boundMax);
  24145. break ;
  24146. case 3:
  24147. maxSize *=Math.cos(0.78539816339744830961566084581988);
  24148. nonRotSize=maxSize *0.5;
  24149. Vector3.scale(sizeScale,nonRotSize,threeDMaxSize);
  24150. Vector3.subtract(boundMin,threeDMaxSize,boundMin);
  24151. Vector3.add(boundMax,threeDMaxSize,boundMax);
  24152. break ;
  24153. }
  24154. this._boundingBox.getCorners(this._boundingBoxCorners);
  24155. }
  24156. /**
  24157. *@private
  24158. */
  24159. __proto._updateEmission=function(){
  24160. if (!this.isAlive)
  24161. return;
  24162. if (this._simulateUpdate){
  24163. this._simulateUpdate=false;
  24164. }
  24165. else{
  24166. var elapsedTime=(this._startUpdateLoopCount!==Stat.loopCount && !this._isPaused)?(this._owner._scene).timer._delta / 1000.0:0;
  24167. elapsedTime=Math.min(ShurikenParticleSystem._maxElapsedTime,elapsedTime);
  24168. this._updateParticles(elapsedTime);
  24169. }
  24170. }
  24171. /**
  24172. *@private
  24173. */
  24174. __proto._updateParticles=function(elapsedTime){
  24175. if (this._ownerRender.renderMode===4 && !this._ownerRender.mesh)
  24176. return;
  24177. this._currentTime+=elapsedTime;
  24178. this._retireActiveParticles();
  24179. this._freeRetiredParticles();
  24180. this._totalDelayTime+=elapsedTime;
  24181. if (this._totalDelayTime < this._playStartDelay){
  24182. return;
  24183. }
  24184. if (this._emission.enbale&&this._isEmitting &&!this._isPaused)
  24185. this._advanceTime(elapsedTime,this._currentTime);
  24186. }
  24187. /**
  24188. *@private
  24189. */
  24190. __proto._updateParticlesSimulationRestart=function(time){
  24191. this._firstActiveElement=0;
  24192. this._firstNewElement=0;
  24193. this._firstFreeElement=0;
  24194. this._firstRetiredElement=0;
  24195. this._burstsIndex=0;
  24196. this._frameRateTime=time;
  24197. this._emissionTime=0;
  24198. this._totalDelayTime=0;
  24199. this._currentTime=time;
  24200. var delayTime=time;
  24201. if (delayTime < this._playStartDelay){
  24202. this._totalDelayTime=delayTime;
  24203. return;
  24204. }
  24205. if (this._emission.enbale)
  24206. this._advanceTime(time,time);
  24207. }
  24208. /**
  24209. *@private
  24210. */
  24211. __proto._retireActiveParticles=function(){
  24212. var epsilon=0.0001;
  24213. while (this._firstActiveElement !=this._firstNewElement){
  24214. var index=this._firstActiveElement *this._floatCountPerVertex *this._vertexStride;
  24215. var timeIndex=index+this._timeIndex;
  24216. var particleAge=this._currentTime-this._vertices[timeIndex];
  24217. if (particleAge+epsilon < this._vertices[index+this._startLifeTimeIndex])
  24218. break ;
  24219. this._vertices[timeIndex]=this._drawCounter;
  24220. this._firstActiveElement++;
  24221. if (this._firstActiveElement >=this._bufferMaxParticles)
  24222. this._firstActiveElement=0;
  24223. }
  24224. }
  24225. /**
  24226. *@private
  24227. */
  24228. __proto._freeRetiredParticles=function(){
  24229. while (this._firstRetiredElement !=this._firstActiveElement){
  24230. var age=this._drawCounter-this._vertices[this._firstRetiredElement *this._floatCountPerVertex *this._vertexStride+this._timeIndex];
  24231. if (this.isPerformanceMode)
  24232. if (age < 3)
  24233. break ;
  24234. this._firstRetiredElement++;
  24235. if (this._firstRetiredElement >=this._bufferMaxParticles)
  24236. this._firstRetiredElement=0;
  24237. }
  24238. }
  24239. /**
  24240. *@private
  24241. */
  24242. __proto._burst=function(fromTime,toTime){
  24243. var totalEmitCount=0;
  24244. var bursts=this._emission._bursts;
  24245. for (var n=bursts.length;this._burstsIndex < n;this._burstsIndex++){
  24246. var burst=bursts[this._burstsIndex];
  24247. var burstTime=burst.time;
  24248. if (fromTime<=burstTime && burstTime < toTime){
  24249. var emitCount=0;
  24250. if (this.autoRandomSeed){
  24251. emitCount=MathUtil.lerp(burst.minCount,burst.maxCount,Math.random());
  24252. }else {
  24253. this._rand.seed=this._randomSeeds[0];
  24254. emitCount=MathUtil.lerp(burst.minCount,burst.maxCount,this._rand.getFloat());
  24255. this._randomSeeds[0]=this._rand.seed;
  24256. }
  24257. totalEmitCount+=emitCount;
  24258. }else {
  24259. break ;
  24260. }
  24261. }
  24262. return totalEmitCount;
  24263. }
  24264. /**
  24265. *@private
  24266. */
  24267. __proto._advanceTime=function(elapsedTime,emitTime){
  24268. var i=0;
  24269. var lastEmissionTime=this._emissionTime;
  24270. this._emissionTime+=elapsedTime;
  24271. var totalEmitCount=0;
  24272. if (this._emissionTime > this.duration){
  24273. if (this.looping){
  24274. totalEmitCount+=this._burst(lastEmissionTime,this._emissionTime);
  24275. this._emissionTime-=this.duration;
  24276. this._burstsIndex=0;
  24277. totalEmitCount+=this._burst(0,this._emissionTime);
  24278. }else {
  24279. totalEmitCount=Math.min(this.maxParticles-this.aliveParticleCount,totalEmitCount);
  24280. for (i=0;i < totalEmitCount;i++)
  24281. this.emit(emitTime);
  24282. this._isPlaying=false;
  24283. this.stop();
  24284. return;
  24285. }
  24286. }else {
  24287. totalEmitCount+=this._burst(lastEmissionTime,this._emissionTime);
  24288. }
  24289. totalEmitCount=Math.min(this.maxParticles-this.aliveParticleCount,totalEmitCount);
  24290. for (i=0;i < totalEmitCount;i++)
  24291. this.emit(emitTime);
  24292. var emissionRate=this.emission.emissionRate;
  24293. if (emissionRate>0){
  24294. var minEmissionTime=1/emissionRate;
  24295. this._frameRateTime+=minEmissionTime;
  24296. this._frameRateTime=this._currentTime-(this._currentTime-this._frameRateTime)% this._maxStartLifetime;
  24297. while (this._frameRateTime <=emitTime){
  24298. if (this.emit(this._frameRateTime))
  24299. this._frameRateTime+=minEmissionTime;
  24300. else
  24301. break ;
  24302. }
  24303. this._frameRateTime=Math.floor(emitTime / minEmissionTime)*minEmissionTime;
  24304. }
  24305. }
  24306. /**
  24307. *@private
  24308. */
  24309. __proto._initBufferDatas=function(){
  24310. if (this._vertexBuffer){
  24311. this._vertexBuffer.destroy();
  24312. this._indexBuffer.destroy();
  24313. };
  24314. var render=this._ownerRender;
  24315. var renderMode=render.renderMode;
  24316. if (renderMode!==-1 && this.maxParticles > 0){
  24317. var indices,i=0,j=0,m=0,indexOffset=0,perPartOffset=0,vertexDeclaration;;
  24318. var vbMemorySize=0,memorySize=0;
  24319. var mesh=render.mesh;
  24320. if (renderMode===4){
  24321. if(mesh){
  24322. var vertexBufferCount=mesh._vertexBuffers.length;
  24323. if (vertexBufferCount > 1){
  24324. throw new Error("ShurikenParticleSystem: submesh Count mesh be One or all subMeshes have the same vertexDeclaration.");
  24325. }else {
  24326. vertexDeclaration=VertexShurikenParticleMesh.vertexDeclaration;
  24327. this._floatCountPerVertex=vertexDeclaration.vertexStride/4;
  24328. this._startLifeTimeIndex=12;
  24329. this._timeIndex=16;
  24330. this._vertexStride=mesh._vertexBuffers[0].vertexCount;
  24331. var totalVertexCount=this._bufferMaxParticles *this._vertexStride;
  24332. var vbCount=Math.floor(totalVertexCount / 65535)+1;
  24333. var lastVBVertexCount=totalVertexCount % 65535;
  24334. if (vbCount > 1){
  24335. throw new Error("ShurikenParticleSystem:the maxParticleCount multiply mesh vertexCount is large than 65535.");
  24336. }
  24337. vbMemorySize=vertexDeclaration.vertexStride *lastVBVertexCount;
  24338. this._vertexBuffer=new VertexBuffer3D(vbMemorySize,/*laya.webgl.WebGLContext.DYNAMIC_DRAW*/0x88E8);
  24339. this._vertexBuffer.vertexDeclaration=vertexDeclaration;
  24340. this._vertices=new Float32Array(this._floatCountPerVertex *lastVBVertexCount);
  24341. this._indexStride=mesh._indexBuffer.indexCount;
  24342. var indexDatas=mesh._indexBuffer.getData();
  24343. var indexCount=this._bufferMaxParticles *this._indexStride;
  24344. this._indexBuffer=new IndexBuffer3D(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",indexCount,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4);
  24345. indices=new Uint16Array(indexCount);
  24346. memorySize=vbMemorySize+indexCount *2;
  24347. indexOffset=0;
  24348. for (i=0;i < this._bufferMaxParticles;i++){
  24349. var indexValueOffset=i *this._vertexStride;
  24350. for (j=0,m=indexDatas.length;j < m;j++)
  24351. indices[indexOffset++]=indexValueOffset+indexDatas[j];
  24352. }
  24353. this._indexBuffer.setData(indices);
  24354. this._bufferState.bind();
  24355. this._bufferState.applyVertexBuffer(this._vertexBuffer);
  24356. this._bufferState.applyIndexBuffer(this._indexBuffer);
  24357. this._bufferState.unBind();
  24358. }
  24359. }
  24360. }else {
  24361. vertexDeclaration=VertexShurikenParticleBillboard.vertexDeclaration;
  24362. this._floatCountPerVertex=vertexDeclaration.vertexStride/4;
  24363. this._startLifeTimeIndex=7;
  24364. this._timeIndex=11;
  24365. this._vertexStride=4;
  24366. vbMemorySize=vertexDeclaration.vertexStride *this._bufferMaxParticles *this._vertexStride;
  24367. this._vertexBuffer=new VertexBuffer3D(vbMemorySize,/*laya.webgl.WebGLContext.DYNAMIC_DRAW*/0x88E8);
  24368. this._vertexBuffer.vertexDeclaration=vertexDeclaration;
  24369. this._vertices=new Float32Array(this._floatCountPerVertex *this._bufferMaxParticles *this._vertexStride);
  24370. for (i=0;i < this._bufferMaxParticles;i++){
  24371. perPartOffset=i *this._floatCountPerVertex *this._vertexStride;
  24372. this._vertices[perPartOffset]=-0.5;
  24373. this._vertices[perPartOffset+1]=-0.5;
  24374. this._vertices[perPartOffset+2]=0;
  24375. this._vertices[perPartOffset+3]=1;
  24376. perPartOffset+=this._floatCountPerVertex;
  24377. this._vertices[perPartOffset]=0.5;
  24378. this._vertices[perPartOffset+1]=-0.5;
  24379. this._vertices[perPartOffset+2]=1;
  24380. this._vertices[perPartOffset+3]=1;
  24381. perPartOffset+=this._floatCountPerVertex
  24382. this._vertices[perPartOffset]=0.5;
  24383. this._vertices[perPartOffset+1]=0.5;
  24384. this._vertices[perPartOffset+2]=1;
  24385. this._vertices[perPartOffset+3]=0;
  24386. perPartOffset+=this._floatCountPerVertex
  24387. this._vertices[perPartOffset]=-0.5;
  24388. this._vertices[perPartOffset+1]=0.5;
  24389. this._vertices[perPartOffset+2]=0;
  24390. this._vertices[perPartOffset+3]=0;
  24391. }
  24392. this._indexStride=6;
  24393. this._indexBuffer=new IndexBuffer3D(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",this._bufferMaxParticles *6,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4);
  24394. indices=new Uint16Array(this._bufferMaxParticles *6);
  24395. for (i=0;i < this._bufferMaxParticles;i++){
  24396. indexOffset=i *6;
  24397. var firstVertex=i *this._vertexStride,secondVertex=firstVertex+2;
  24398. indices[indexOffset++]=firstVertex;
  24399. indices[indexOffset++]=secondVertex;
  24400. indices[indexOffset++]=firstVertex+1;
  24401. indices[indexOffset++]=firstVertex;
  24402. indices[indexOffset++]=firstVertex+3;
  24403. indices[indexOffset++]=secondVertex;
  24404. }
  24405. this._indexBuffer.setData(indices);
  24406. memorySize=vbMemorySize+this._bufferMaxParticles *6 *2;
  24407. this._bufferState.bind();
  24408. this._bufferState.applyVertexBuffer(this._vertexBuffer);
  24409. this._bufferState.applyIndexBuffer(this._indexBuffer);
  24410. this._bufferState.unBind();
  24411. }
  24412. Resource._addMemory(memorySize,memorySize);
  24413. }
  24414. }
  24415. /**
  24416. *@private
  24417. */
  24418. __proto.destroy=function(){
  24419. _super.prototype.destroy.call(this);
  24420. var memorySize=this._vertexBuffer._byteLength+this._indexBuffer.indexCount *2;
  24421. Resource._addMemory(-memorySize,-memorySize);
  24422. this._bufferState.destroy();
  24423. this._vertexBuffer.destroy();
  24424. this._indexBuffer.destroy();
  24425. this._emission.destroy();
  24426. this._bufferState=null;
  24427. this._vertexBuffer=null;
  24428. this._indexBuffer=null;
  24429. this._owner=null;
  24430. this._vertices=null;
  24431. this._indexBuffer=null;
  24432. this._emission=null;
  24433. this._shape=null;
  24434. this.startLifeTimeGradient=null;
  24435. this.startLifeTimeGradientMin=null;
  24436. this.startLifeTimeGradientMax=null;
  24437. this.startSizeConstantSeparate=null;
  24438. this.startSizeConstantMinSeparate=null;
  24439. this.startSizeConstantMaxSeparate=null;
  24440. this.startRotationConstantSeparate=null;
  24441. this.startRotationConstantMinSeparate=null;
  24442. this.startRotationConstantMaxSeparate=null;
  24443. this.startColorConstant=null;
  24444. this.startColorConstantMin=null;
  24445. this.startColorConstantMax=null;
  24446. this._velocityOverLifetime=null;
  24447. this._colorOverLifetime=null;
  24448. this._sizeOverLifetime=null;
  24449. this._rotationOverLifetime=null;
  24450. this._textureSheetAnimation=null;
  24451. }
  24452. /**
  24453. *发射一个粒子。
  24454. */
  24455. __proto.emit=function(time){
  24456. var position=ShurikenParticleSystem._tempPosition;
  24457. var direction=ShurikenParticleSystem._tempDirection;
  24458. if (this._shape&&this._shape.enable){
  24459. if (this.autoRandomSeed)
  24460. this._shape.generatePositionAndDirection(position,direction);
  24461. else
  24462. this._shape.generatePositionAndDirection(position,direction,this._rand,this._randomSeeds);
  24463. }else {
  24464. position.x=position.y=position.z=0;
  24465. direction.x=direction.y=0;
  24466. direction.z=1;
  24467. }
  24468. return this.addParticle(position,direction,time);
  24469. }
  24470. //TODO:提前判断优化
  24471. __proto.addParticle=function(position,direction,time){
  24472. Vector3.normalize(direction,direction);
  24473. var nextFreeParticle=this._firstFreeElement+1;
  24474. if (nextFreeParticle >=this._bufferMaxParticles)
  24475. nextFreeParticle=0;
  24476. if (nextFreeParticle===this._firstRetiredElement)
  24477. return false;
  24478. ShurikenParticleData.create(this,this._ownerRender,this._owner.transform);
  24479. var particleAge=this._currentTime-time;
  24480. if (particleAge >=ShurikenParticleData.startLifeTime)
  24481. return true;
  24482. var randomVelocityX=NaN,randomVelocityY=NaN,randomVelocityZ=NaN,randomColor=NaN,randomSize=NaN,randomRotation=NaN,randomTextureAnimation=NaN;
  24483. var needRandomVelocity=this._velocityOverLifetime && this._velocityOverLifetime.enbale;
  24484. if (needRandomVelocity){
  24485. var velocityType=this._velocityOverLifetime.velocity.type;
  24486. if (velocityType===2 || velocityType===3){
  24487. if (this.autoRandomSeed){
  24488. randomVelocityX=Math.random();
  24489. randomVelocityY=Math.random();
  24490. randomVelocityZ=Math.random();
  24491. }else {
  24492. this._rand.seed=this._randomSeeds[9];
  24493. randomVelocityX=this._rand.getFloat();
  24494. randomVelocityY=this._rand.getFloat();
  24495. randomVelocityZ=this._rand.getFloat();
  24496. this._randomSeeds[9]=this._rand.seed;
  24497. }
  24498. }else {
  24499. needRandomVelocity=false;
  24500. }
  24501. }else {
  24502. needRandomVelocity=false;
  24503. };
  24504. var needRandomColor=this._colorOverLifetime && this._colorOverLifetime.enbale;
  24505. if (needRandomColor){
  24506. var colorType=this._colorOverLifetime.color.type;
  24507. if (colorType===3){
  24508. if (this.autoRandomSeed){
  24509. randomColor=Math.random();
  24510. }else {
  24511. this._rand.seed=this._randomSeeds[10];
  24512. randomColor=this._rand.getFloat();
  24513. this._randomSeeds[10]=this._rand.seed;
  24514. }
  24515. }else {
  24516. needRandomColor=false;
  24517. }
  24518. }else {
  24519. needRandomColor=false;
  24520. };
  24521. var needRandomSize=this._sizeOverLifetime && this._sizeOverLifetime.enbale;
  24522. if (needRandomSize){
  24523. var sizeType=this._sizeOverLifetime.size.type;
  24524. if (sizeType===3){
  24525. if (this.autoRandomSeed){
  24526. randomSize=Math.random();
  24527. }else {
  24528. this._rand.seed=this._randomSeeds[11];
  24529. randomSize=this._rand.getFloat();
  24530. this._randomSeeds[11]=this._rand.seed;
  24531. }
  24532. }else {
  24533. needRandomSize=false;
  24534. }
  24535. }else {
  24536. needRandomSize=false;
  24537. };
  24538. var needRandomRotation=this._rotationOverLifetime && this._rotationOverLifetime.enbale;
  24539. if (needRandomRotation){
  24540. var rotationType=this._rotationOverLifetime.angularVelocity.type;
  24541. if (rotationType===2 || rotationType===3){
  24542. if (this.autoRandomSeed){
  24543. randomRotation=Math.random();
  24544. }else {
  24545. this._rand.seed=this._randomSeeds[12];
  24546. randomRotation=this._rand.getFloat();
  24547. this._randomSeeds[12]=this._rand.seed;
  24548. }
  24549. }else {
  24550. needRandomRotation=false;
  24551. }
  24552. }else {
  24553. needRandomRotation=false;
  24554. };
  24555. var needRandomTextureAnimation=this._textureSheetAnimation && this._textureSheetAnimation.enable;
  24556. if (needRandomTextureAnimation){
  24557. var textureAnimationType=this._textureSheetAnimation.frame.type;
  24558. if (textureAnimationType===3){
  24559. if (this.autoRandomSeed){
  24560. randomTextureAnimation=Math.random();
  24561. }else {
  24562. this._rand.seed=this._randomSeeds[15];
  24563. randomTextureAnimation=this._rand.getFloat();
  24564. this._randomSeeds[15]=this._rand.seed;
  24565. }
  24566. }else {
  24567. needRandomTextureAnimation=false;
  24568. }
  24569. }else {
  24570. needRandomTextureAnimation=false;
  24571. };
  24572. var startIndex=this._firstFreeElement *this._floatCountPerVertex *this._vertexStride;
  24573. var subU=ShurikenParticleData.startUVInfo[0];
  24574. var subV=ShurikenParticleData.startUVInfo[1];
  24575. var startU=ShurikenParticleData.startUVInfo[2];
  24576. var startV=ShurikenParticleData.startUVInfo[3];
  24577. var meshVertices,meshVertexStride=0,meshPosOffset=0,meshCorOffset=0,meshUVOffset=0,meshVertexIndex=0;
  24578. var render=this._ownerRender;
  24579. if (render.renderMode===4){
  24580. var meshVB=render.mesh._vertexBuffers[0];
  24581. meshVertices=meshVB.getData();
  24582. var meshVertexDeclaration=meshVB.vertexDeclaration;
  24583. meshPosOffset=meshVertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0).offset / 4;
  24584. var colorElement=meshVertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_COLOR0*/1);
  24585. meshCorOffset=colorElement?colorElement.offset / 4:-1;
  24586. var uvElement=meshVertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE0*/2);
  24587. meshUVOffset=uvElement?uvElement.offset / 4:-1;
  24588. meshVertexStride=meshVertexDeclaration.vertexStride / 4;
  24589. meshVertexIndex=0;
  24590. }else {
  24591. this._vertices[startIndex+2]=startU;
  24592. this._vertices[startIndex+3]=startV+subV;
  24593. var secondOffset=startIndex+this._floatCountPerVertex;
  24594. this._vertices[secondOffset+2]=startU+subU;
  24595. this._vertices[secondOffset+3]=startV+subV;
  24596. var thirdOffset=secondOffset+this._floatCountPerVertex;
  24597. this._vertices[thirdOffset+2]=startU+subU;
  24598. this._vertices[thirdOffset+3]=startV;
  24599. var fourthOffset=thirdOffset+this._floatCountPerVertex;
  24600. this._vertices[fourthOffset+2]=startU;
  24601. this._vertices[fourthOffset+3]=startV;
  24602. }
  24603. for (var i=startIndex,n=startIndex+this._floatCountPerVertex *this._vertexStride;i < n;i+=this._floatCountPerVertex){
  24604. var offset=0;
  24605. if (render.renderMode===4){
  24606. offset=i;
  24607. var vertexOffset=meshVertexStride *(meshVertexIndex++);
  24608. var meshOffset=vertexOffset+meshPosOffset;
  24609. this._vertices[offset++]=meshVertices[meshOffset++];
  24610. this._vertices[offset++]=meshVertices[meshOffset++];
  24611. this._vertices[offset++]=meshVertices[meshOffset];
  24612. if (meshCorOffset===-1){
  24613. this._vertices[offset++]=1.0;
  24614. this._vertices[offset++]=1.0;
  24615. this._vertices[offset++]=1.0;
  24616. this._vertices[offset++]=1.0;
  24617. }
  24618. else{
  24619. meshOffset=vertexOffset+meshCorOffset;
  24620. this._vertices[offset++]=meshVertices[meshOffset++];
  24621. this._vertices[offset++]=meshVertices[meshOffset++];
  24622. this._vertices[offset++]=meshVertices[meshOffset++];
  24623. this._vertices[offset++]=meshVertices[meshOffset];
  24624. }
  24625. if (meshUVOffset===-1){
  24626. this._vertices[offset++]=0.0;
  24627. this._vertices[offset++]=0.0;
  24628. }
  24629. else{
  24630. meshOffset=vertexOffset+meshUVOffset;
  24631. this._vertices[offset++]=startU+meshVertices[meshOffset++] *subU;
  24632. this._vertices[offset++]=startV+meshVertices[meshOffset] *subV;
  24633. }
  24634. }else {
  24635. offset=i+4;
  24636. }
  24637. this._vertices[offset++]=position.x;
  24638. this._vertices[offset++]=position.y;
  24639. this._vertices[offset++]=position.z;
  24640. this._vertices[offset++]=ShurikenParticleData.startLifeTime;
  24641. this._vertices[offset++]=direction.x;
  24642. this._vertices[offset++]=direction.y;
  24643. this._vertices[offset++]=direction.z;
  24644. this._vertices[offset++]=time;
  24645. this._vertices[offset++]=ShurikenParticleData.startColor.x;
  24646. this._vertices[offset++]=ShurikenParticleData.startColor.y;
  24647. this._vertices[offset++]=ShurikenParticleData.startColor.z;
  24648. this._vertices[offset++]=ShurikenParticleData.startColor.w;
  24649. this._vertices[offset++]=ShurikenParticleData.startSize[0];
  24650. this._vertices[offset++]=ShurikenParticleData.startSize[1];
  24651. this._vertices[offset++]=ShurikenParticleData.startSize[2];
  24652. this._vertices[offset++]=ShurikenParticleData.startRotation[0];
  24653. this._vertices[offset++]=ShurikenParticleData.startRotation[1];
  24654. this._vertices[offset++]=ShurikenParticleData.startRotation[2];
  24655. this._vertices[offset++]=ShurikenParticleData.startSpeed;
  24656. needRandomColor && (this._vertices[offset+1]=randomColor);
  24657. needRandomSize && (this._vertices[offset+2]=randomSize);
  24658. needRandomRotation && (this._vertices[offset+3]=randomRotation);
  24659. needRandomTextureAnimation && (this._vertices[offset+4]=randomTextureAnimation);
  24660. if (needRandomVelocity){
  24661. this._vertices[offset+5]=randomVelocityX;
  24662. this._vertices[offset+6]=randomVelocityY;
  24663. this._vertices[offset+7]=randomVelocityZ;
  24664. }
  24665. switch(this.simulationSpace){
  24666. case 0:
  24667. offset+=8;
  24668. this._vertices[offset++]=ShurikenParticleData.simulationWorldPostion[0];
  24669. this._vertices[offset++]=ShurikenParticleData.simulationWorldPostion[1];
  24670. this._vertices[offset++]=ShurikenParticleData.simulationWorldPostion[2];
  24671. this._vertices[offset++]=ShurikenParticleData.simulationWorldRotation[0];
  24672. this._vertices[offset++]=ShurikenParticleData.simulationWorldRotation[1];
  24673. this._vertices[offset++]=ShurikenParticleData.simulationWorldRotation[2];
  24674. this._vertices[offset++]=ShurikenParticleData.simulationWorldRotation[3];
  24675. break ;
  24676. case 1:
  24677. break ;
  24678. default :
  24679. throw new Error("ShurikenParticleMaterial: SimulationSpace value is invalid.");
  24680. }
  24681. }
  24682. this._firstFreeElement=nextFreeParticle;
  24683. return true;
  24684. }
  24685. __proto.addNewParticlesToVertexBuffer=function(){
  24686. var start=0;
  24687. if (this._firstNewElement < this._firstFreeElement){
  24688. start=this._firstNewElement *this._vertexStride *this._floatCountPerVertex;
  24689. this._vertexBuffer.setData(this._vertices,start,start,(this._firstFreeElement-this._firstNewElement)*this._vertexStride *this._floatCountPerVertex);
  24690. }else {
  24691. start=this._firstNewElement *this._vertexStride *this._floatCountPerVertex;
  24692. this._vertexBuffer.setData(this._vertices,start,start,(this._bufferMaxParticles-this._firstNewElement)*this._vertexStride *this._floatCountPerVertex);
  24693. if (this._firstFreeElement > 0){
  24694. this._vertexBuffer.setData(this._vertices,0,0,this._firstFreeElement *this._vertexStride *this._floatCountPerVertex);
  24695. }
  24696. }
  24697. this._firstNewElement=this._firstFreeElement;
  24698. }
  24699. /**
  24700. *@inheritDoc
  24701. */
  24702. __proto._getType=function(){
  24703. return ShurikenParticleSystem._type;
  24704. }
  24705. /**
  24706. *@inheritDoc
  24707. */
  24708. __proto._prepareRender=function(state){
  24709. this._updateEmission();
  24710. if (this._firstNewElement !=this._firstFreeElement)
  24711. this.addNewParticlesToVertexBuffer();
  24712. this._drawCounter++;
  24713. if (this._firstActiveElement !=this._firstFreeElement)
  24714. return true;
  24715. else
  24716. return false;
  24717. }
  24718. /**
  24719. *@private
  24720. */
  24721. __proto._render=function(state){
  24722. this._bufferState.bind();
  24723. var indexCount=0;
  24724. var gl=LayaGL.instance;
  24725. if (this._firstActiveElement < this._firstFreeElement){
  24726. indexCount=(this._firstFreeElement-this._firstActiveElement)*this._indexStride;
  24727. gl.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,indexCount,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,2 *this._firstActiveElement *this._indexStride);
  24728. Stat.trianglesFaces+=indexCount / 3;
  24729. Stat.renderBatches++;
  24730. }else {
  24731. indexCount=(this._bufferMaxParticles-this._firstActiveElement)*this._indexStride;
  24732. gl.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,indexCount,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,2 *this._firstActiveElement *this._indexStride);
  24733. Stat.trianglesFaces+=indexCount / 3;
  24734. Stat.renderBatches++;
  24735. if (this._firstFreeElement > 0){
  24736. indexCount=this._firstFreeElement *this._indexStride;
  24737. gl.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,indexCount,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,0);
  24738. Stat.trianglesFaces+=indexCount / 3;
  24739. Stat.renderBatches++;
  24740. }
  24741. }
  24742. }
  24743. /**
  24744. *开始发射粒子。
  24745. */
  24746. __proto.play=function(){
  24747. this._burstsIndex=0;
  24748. this._isEmitting=true;
  24749. this._isPlaying=true;
  24750. this._isPaused=false;
  24751. this._emissionTime=0;
  24752. this._totalDelayTime=0;
  24753. if (!this.autoRandomSeed){
  24754. for (var i=0,n=this._randomSeeds.length;i < n;i++)
  24755. this._randomSeeds[i]=this.randomSeed[0]+ShurikenParticleSystem._RANDOMOFFSET[i];
  24756. }
  24757. switch (this.startDelayType){
  24758. case 0:
  24759. this._playStartDelay=this.startDelay;
  24760. break ;
  24761. case 1:
  24762. if (this.autoRandomSeed){
  24763. this._playStartDelay=MathUtil.lerp(this.startDelayMin,this.startDelayMax,Math.random());
  24764. }else {
  24765. this._rand.seed=this._randomSeeds[2];
  24766. this._playStartDelay=MathUtil.lerp(this.startDelayMin,this.startDelayMax,this._rand.getFloat());
  24767. this._randomSeeds[2]=this._rand.seed;
  24768. }
  24769. break ;
  24770. default :
  24771. throw new Error("Utils3D: startDelayType is invalid.");
  24772. }
  24773. this._frameRateTime=this._currentTime+this._playStartDelay;
  24774. this._startUpdateLoopCount=Stat.loopCount;
  24775. }
  24776. /**
  24777. *暂停发射粒子。
  24778. */
  24779. __proto.pause=function(){
  24780. this._isPaused=true;
  24781. }
  24782. /**
  24783. *通过指定时间增加粒子播放进度,并暂停播放。
  24784. *@param time 进度时间.如果restart为true,粒子播放时间会归零后再更新进度。
  24785. *@param restart 是否重置播放状态。
  24786. */
  24787. __proto.simulate=function(time,restart){
  24788. (restart===void 0)&& (restart=true);
  24789. this._simulateUpdate=true;
  24790. if (restart){
  24791. this._updateParticlesSimulationRestart(time);
  24792. }
  24793. else{
  24794. this._isPaused=false;
  24795. this._updateParticles(time);
  24796. }
  24797. this.pause();
  24798. }
  24799. /**
  24800. *停止发射粒子。
  24801. */
  24802. __proto.stop=function(){
  24803. this._burstsIndex=0;
  24804. this._isEmitting=false;
  24805. this._emissionTime=0;
  24806. }
  24807. /**
  24808. *克隆。
  24809. *@param destObject 克隆源。
  24810. */
  24811. __proto.cloneTo=function(destObject){
  24812. var dest=destObject;
  24813. dest.duration=this.duration;
  24814. dest.looping=this.looping;
  24815. dest.prewarm=this.prewarm;
  24816. dest.startDelayType=this.startDelayType;
  24817. dest.startDelay=this.startDelay;
  24818. dest.startDelayMin=this.startDelayMin;
  24819. dest.startDelayMax=this.startDelayMax;
  24820. dest._maxStartLifetime=this._maxStartLifetime;
  24821. dest.startLifetimeType=this.startLifetimeType;
  24822. dest.startLifetimeConstant=this.startLifetimeConstant;
  24823. this.startLifeTimeGradient.cloneTo(dest.startLifeTimeGradient);
  24824. dest.startLifetimeConstantMin=this.startLifetimeConstantMin;
  24825. dest.startLifetimeConstantMax=this.startLifetimeConstantMax;
  24826. this.startLifeTimeGradientMin.cloneTo(dest.startLifeTimeGradientMin);
  24827. this.startLifeTimeGradientMax.cloneTo(dest.startLifeTimeGradientMax);
  24828. dest.startSpeedType=this.startSpeedType;
  24829. dest.startSpeedConstant=this.startSpeedConstant;
  24830. dest.startSpeedConstantMin=this.startSpeedConstantMin;
  24831. dest.startSpeedConstantMax=this.startSpeedConstantMax;
  24832. dest.threeDStartSize=this.threeDStartSize;
  24833. dest.startSizeType=this.startSizeType;
  24834. dest.startSizeConstant=this.startSizeConstant;
  24835. this.startSizeConstantSeparate.cloneTo(dest.startSizeConstantSeparate);
  24836. dest.startSizeConstantMin=this.startSizeConstantMin;
  24837. dest.startSizeConstantMax=this.startSizeConstantMax;
  24838. this.startSizeConstantMinSeparate.cloneTo(dest.startSizeConstantMinSeparate);
  24839. this.startSizeConstantMaxSeparate.cloneTo(dest.startSizeConstantMaxSeparate);
  24840. dest.threeDStartRotation=this.threeDStartRotation;
  24841. dest.startRotationType=this.startRotationType;
  24842. dest.startRotationConstant=this.startRotationConstant;
  24843. this.startRotationConstantSeparate.cloneTo(dest.startRotationConstantSeparate);
  24844. dest.startRotationConstantMin=this.startRotationConstantMin;
  24845. dest.startRotationConstantMax=this.startRotationConstantMax;
  24846. this.startRotationConstantMinSeparate.cloneTo(dest.startRotationConstantMinSeparate);
  24847. this.startRotationConstantMaxSeparate.cloneTo(dest.startRotationConstantMaxSeparate);
  24848. dest.randomizeRotationDirection=this.randomizeRotationDirection;
  24849. dest.startColorType=this.startColorType;
  24850. this.startColorConstant.cloneTo(dest.startColorConstant);
  24851. this.startColorConstantMin.cloneTo(dest.startColorConstantMin);
  24852. this.startColorConstantMax.cloneTo(dest.startColorConstantMax);
  24853. dest.gravityModifier=this.gravityModifier;
  24854. dest.simulationSpace=this.simulationSpace;
  24855. dest.scaleMode=this.scaleMode;
  24856. dest.playOnAwake=this.playOnAwake;
  24857. dest.maxParticles=this.maxParticles;
  24858. (this._emission)&& (dest._emission=this._emission.clone());
  24859. (this.shape)&& (dest.shape=this.shape.clone());
  24860. (this.velocityOverLifetime)&& (dest.velocityOverLifetime=this.velocityOverLifetime.clone());
  24861. (this.colorOverLifetime)&& (dest.colorOverLifetime=this.colorOverLifetime.clone());
  24862. (this.sizeOverLifetime)&& (dest.sizeOverLifetime=this.sizeOverLifetime.clone());
  24863. (this.rotationOverLifetime)&& (dest.rotationOverLifetime=this.rotationOverLifetime.clone());
  24864. (this.textureSheetAnimation)&& (dest.textureSheetAnimation=this.textureSheetAnimation.clone());
  24865. dest.isPerformanceMode=this.isPerformanceMode;
  24866. dest._isEmitting=this._isEmitting;
  24867. dest._isPlaying=this._isPlaying;
  24868. dest._isPaused=this._isPaused;
  24869. dest._playStartDelay=this._playStartDelay;
  24870. dest._frameRateTime=this._frameRateTime;
  24871. dest._emissionTime=this._emissionTime;
  24872. dest._totalDelayTime=this._totalDelayTime;
  24873. dest._burstsIndex=this._burstsIndex;
  24874. }
  24875. /**
  24876. *克隆。
  24877. *@return 克隆副本。
  24878. */
  24879. __proto.clone=function(){
  24880. var dest=/*__JS__ */new this.constructor();
  24881. this.cloneTo(dest);
  24882. return dest;
  24883. }
  24884. /**设置最大粒子数,注意:谨慎修改此属性,有性能损耗。*/
  24885. /**获取最大粒子数。*/
  24886. __getset(0,__proto,'maxParticles',function(){
  24887. return this._bufferMaxParticles-1;
  24888. },function(value){
  24889. var newMaxParticles=value+1;
  24890. if (newMaxParticles!==this._bufferMaxParticles){
  24891. this._bufferMaxParticles=newMaxParticles;
  24892. this._initBufferDatas();
  24893. }
  24894. });
  24895. /**
  24896. *是否正在发射。
  24897. */
  24898. __getset(0,__proto,'isEmitting',function(){
  24899. return this._isEmitting;
  24900. });
  24901. /**
  24902. *是否存活。
  24903. */
  24904. __getset(0,__proto,'isAlive',function(){
  24905. if (this._isPlaying || this.aliveParticleCount > 0)
  24906. return true;
  24907. return false;
  24908. });
  24909. /**
  24910. *设置形状。
  24911. */
  24912. /**
  24913. *获取形状。
  24914. */
  24915. __getset(0,__proto,'shape',function(){
  24916. return this._shape;
  24917. },function(value){
  24918. if (this._shape!==value){
  24919. if (value&&value.enable)
  24920. this._owner._render._defineDatas.add(ShuriKenParticle3D.SHADERDEFINE_SHAPE);
  24921. else
  24922. this._owner._render._defineDatas.remove(ShuriKenParticle3D.SHADERDEFINE_SHAPE);
  24923. this._shape=value;
  24924. }
  24925. });
  24926. /**
  24927. *设置生命周期旋转,注意:如修改该值的某些属性,需重新赋值此属性才可生效。
  24928. *@param value 生命周期旋转。
  24929. */
  24930. /**
  24931. *获取生命周期旋转,注意:如修改该值的某些属性,需重新赋值此属性才可生效。
  24932. *@return 生命周期旋转。
  24933. */
  24934. __getset(0,__proto,'rotationOverLifetime',function(){
  24935. return this._rotationOverLifetime;
  24936. },function(value){
  24937. var defDat=this._owner._render._defineDatas;
  24938. var shaDat=this._owner._render._shaderValues;
  24939. if (value){
  24940. var rotation=value.angularVelocity;
  24941. if (!rotation)
  24942. return;
  24943. var rotationSeparate=rotation.separateAxes;
  24944. var rotationType=rotation.type;
  24945. if (value.enbale){
  24946. if (rotationSeparate)
  24947. defDat.add(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE);
  24948. else
  24949. defDat.add(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIME);
  24950. switch (rotationType){
  24951. case 0:
  24952. defDat.add(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT);
  24953. break ;
  24954. case 1:
  24955. defDat.add(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE);
  24956. break ;
  24957. case 2:
  24958. defDat.add(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS);
  24959. break ;
  24960. case 3:
  24961. defDat.add(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES);
  24962. break ;
  24963. }
  24964. }else {
  24965. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIME);
  24966. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE);
  24967. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT);
  24968. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE);
  24969. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS);
  24970. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES);
  24971. }
  24972. switch (rotationType){
  24973. case 0:
  24974. if (rotationSeparate){
  24975. shaDat.setVector3(ShuriKenParticle3D.ROLANGULARVELOCITYCONSTSEPRARATE,rotation.constantSeparate);
  24976. }else {
  24977. shaDat.setNumber(ShuriKenParticle3D.ROLANGULARVELOCITYCONST,rotation.constant);
  24978. }
  24979. break ;
  24980. case 1:
  24981. if (rotationSeparate){
  24982. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTX,rotation.gradientX._elements);
  24983. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTY,rotation.gradientY._elements);
  24984. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTZ,rotation.gradientZ._elements);
  24985. }else {
  24986. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENT,rotation.gradient._elements);
  24987. }
  24988. break ;
  24989. case 2:
  24990. if (rotationSeparate){
  24991. shaDat.setVector3(ShuriKenParticle3D.ROLANGULARVELOCITYCONSTSEPRARATE,rotation.constantMinSeparate);
  24992. shaDat.setVector3(ShuriKenParticle3D.ROLANGULARVELOCITYCONSTMAXSEPRARATE,rotation.constantMaxSeparate);
  24993. }else {
  24994. shaDat.setNumber(ShuriKenParticle3D.ROLANGULARVELOCITYCONST,rotation.constantMin);
  24995. shaDat.setNumber(ShuriKenParticle3D.ROLANGULARVELOCITYCONSTMAX,rotation.constantMax);
  24996. }
  24997. break ;
  24998. case 3:
  24999. if (rotationSeparate){
  25000. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTX,rotation.gradientXMin._elements);
  25001. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTXMAX,rotation.gradientXMax._elements);
  25002. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTY,rotation.gradientYMin._elements);
  25003. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTYMAX,rotation.gradientYMax._elements);
  25004. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTZ,rotation.gradientZMin._elements);
  25005. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTZMAX,rotation.gradientZMax._elements);
  25006. }else {
  25007. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENT,rotation.gradientMin._elements);
  25008. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTMAX,rotation.gradientMax._elements);
  25009. }
  25010. break ;
  25011. }
  25012. }else {
  25013. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIME);
  25014. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE);
  25015. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT);
  25016. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE);
  25017. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS);
  25018. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES);
  25019. shaDat.setVector(ShuriKenParticle3D.ROLANGULARVELOCITYCONSTSEPRARATE,null);
  25020. shaDat.setVector(ShuriKenParticle3D.ROLANGULARVELOCITYCONSTMAXSEPRARATE,null);
  25021. shaDat.setNumber(ShuriKenParticle3D.ROLANGULARVELOCITYCONST,undefined);
  25022. shaDat.setNumber(ShuriKenParticle3D.ROLANGULARVELOCITYCONSTMAX,undefined);
  25023. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTX,null);
  25024. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTXMAX,null);
  25025. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTY,null);
  25026. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTYMAX,null);
  25027. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTZ,null);
  25028. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTZMAX,null);
  25029. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTWMAX,null);
  25030. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENT,null);
  25031. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTMAX,null);
  25032. }
  25033. this._rotationOverLifetime=value;
  25034. });
  25035. /**
  25036. *获取发射器。
  25037. */
  25038. __getset(0,__proto,'emission',function(){
  25039. return this._emission;
  25040. });
  25041. /**
  25042. *获取一次循环内的累计时间。
  25043. *@return 一次循环内的累计时间。
  25044. */
  25045. __getset(0,__proto,'emissionTime',function(){
  25046. return this._emissionTime > this.duration ? this.duration :this._emissionTime;
  25047. });
  25048. /**
  25049. *粒子存活个数。
  25050. */
  25051. __getset(0,__proto,'aliveParticleCount',function(){
  25052. if (this._firstNewElement >=this._firstRetiredElement)
  25053. return this._firstNewElement-this._firstRetiredElement;
  25054. else
  25055. return this._bufferMaxParticles-this._firstRetiredElement+this._firstNewElement;
  25056. });
  25057. /**
  25058. *是否正在播放。
  25059. */
  25060. __getset(0,__proto,'isPlaying',function(){
  25061. return this._isPlaying;
  25062. });
  25063. /**
  25064. *是否已暂停。
  25065. */
  25066. __getset(0,__proto,'isPaused',function(){
  25067. return this._isPaused;
  25068. });
  25069. /**
  25070. *设置开始生命周期模式,0为固定时间,1为渐变时间,2为两个固定之间的随机插值,3为两个渐变时间的随机插值。
  25071. */
  25072. /**
  25073. *获取开始生命周期模式,0为固定时间,1为渐变时间,2为两个固定之间的随机插值,3为两个渐变时间的随机插值。
  25074. */
  25075. __getset(0,__proto,'startLifetimeType',function(){
  25076. return this._startLifetimeType;
  25077. },function(value){
  25078. var i=0,n=0;
  25079. switch (this.startLifetimeType){
  25080. case 0:
  25081. this._maxStartLifetime=this.startLifetimeConstant;
  25082. break ;
  25083. case 1:
  25084. this._maxStartLifetime=-Number.MAX_VALUE;
  25085. var startLifeTimeGradient=startLifeTimeGradient;
  25086. for (i=0,n=startLifeTimeGradient.gradientCount;i < n;i++)
  25087. this._maxStartLifetime=Math.max(this._maxStartLifetime,startLifeTimeGradient.getValueByIndex(i));
  25088. break ;
  25089. case 2:
  25090. this._maxStartLifetime=Math.max(this.startLifetimeConstantMin,this.startLifetimeConstantMax);
  25091. break ;
  25092. case 3:
  25093. this._maxStartLifetime=-Number.MAX_VALUE;
  25094. var startLifeTimeGradientMin=startLifeTimeGradientMin;
  25095. for (i=0,n=startLifeTimeGradientMin.gradientCount;i < n;i++)
  25096. this._maxStartLifetime=Math.max(this._maxStartLifetime,startLifeTimeGradientMin.getValueByIndex(i));
  25097. var startLifeTimeGradientMax=startLifeTimeGradientMax;
  25098. for (i=0,n=startLifeTimeGradientMax.gradientCount;i < n;i++)
  25099. this._maxStartLifetime=Math.max(this._maxStartLifetime,startLifeTimeGradientMax.getValueByIndex(i));
  25100. break ;
  25101. }
  25102. this._startLifetimeType=value;
  25103. });
  25104. /**
  25105. *设置开始生命周期,0模式,单位为秒。
  25106. */
  25107. /**
  25108. *获取开始生命周期,0模式,单位为秒。
  25109. */
  25110. __getset(0,__proto,'startLifetimeConstant',function(){
  25111. return this._startLifetimeConstant;
  25112. },function(value){
  25113. if(this._startLifetimeType===0)
  25114. this._maxStartLifetime=value;
  25115. this._startLifetimeConstant=value;
  25116. });
  25117. /**
  25118. *设置最小开始生命周期,2模式,单位为秒。
  25119. */
  25120. /**
  25121. *获取最小开始生命周期,2模式,单位为秒。
  25122. */
  25123. __getset(0,__proto,'startLifetimeConstantMin',function(){
  25124. return this._startLifetimeConstantMin;
  25125. },function(value){
  25126. if (this._startLifetimeType===2)
  25127. this._maxStartLifetime=Math.max(value,this._startLifetimeConstantMax);
  25128. this._startLifetimeConstantMin=value;
  25129. });
  25130. /**
  25131. *设置开始渐变生命周期,1模式,单位为秒。
  25132. */
  25133. /**
  25134. *获取开始渐变生命周期,1模式,单位为秒。
  25135. */
  25136. __getset(0,__proto,'startLifeTimeGradient',function(){
  25137. return this._startLifeTimeGradient;
  25138. },function(value){
  25139. if (this._startLifetimeType===1){
  25140. this._maxStartLifetime=-Number.MAX_VALUE;
  25141. for (var i=0,n=value.gradientCount;i < n;i++)
  25142. this._maxStartLifetime=Math.max(this._maxStartLifetime,value.getValueByIndex(i));
  25143. }
  25144. this._startLifeTimeGradient=value;
  25145. });
  25146. /**
  25147. *设置最大开始生命周期,2模式,单位为秒。
  25148. */
  25149. /**
  25150. *获取最大开始生命周期,2模式,单位为秒。
  25151. */
  25152. __getset(0,__proto,'startLifetimeConstantMax',function(){
  25153. return this._startLifetimeConstantMax;
  25154. },function(value){
  25155. if (this._startLifetimeType===2)
  25156. this._maxStartLifetime=Math.max(this._startLifetimeConstantMin,value);
  25157. this._startLifetimeConstantMax=value;
  25158. });
  25159. /**
  25160. *设置开始渐变最小生命周期,3模式,单位为秒。
  25161. */
  25162. /**
  25163. *获取开始渐变最小生命周期,3模式,单位为秒。
  25164. */
  25165. __getset(0,__proto,'startLifeTimeGradientMin',function(){
  25166. return this._startLifeTimeGradientMin;
  25167. },function(value){
  25168. if (this._startLifetimeType===3){
  25169. var i=0,n=0;
  25170. this._maxStartLifetime=-Number.MAX_VALUE;
  25171. for (i=0,n=value.gradientCount;i < n;i++)
  25172. this._maxStartLifetime=Math.max(this._maxStartLifetime,value.getValueByIndex(i));
  25173. for (i=0,n=this._startLifeTimeGradientMax.gradientCount;i < n;i++)
  25174. this._maxStartLifetime=Math.max(this._maxStartLifetime,this._startLifeTimeGradientMax.getValueByIndex(i));
  25175. }
  25176. this._startLifeTimeGradientMin=value;
  25177. });
  25178. /**
  25179. *设置开始渐变最大生命周期,3模式,单位为秒。
  25180. */
  25181. /**
  25182. *获取开始渐变最大生命周期,3模式,单位为秒。
  25183. */
  25184. __getset(0,__proto,'startLifeTimeGradientMax',function(){
  25185. return this._startLifeTimeGradientMax;
  25186. },function(value){
  25187. if (this._startLifetimeType===3){
  25188. var i=0,n=0;
  25189. this._maxStartLifetime=-Number.MAX_VALUE;
  25190. for (i=0,n=this._startLifeTimeGradientMin.gradientCount;i < n;i++)
  25191. this._maxStartLifetime=Math.max(this._maxStartLifetime,this._startLifeTimeGradientMin.getValueByIndex(i));
  25192. for (i=0,n=value.gradientCount;i < n;i++)
  25193. this._maxStartLifetime=Math.max(this._maxStartLifetime,value.getValueByIndex(i));
  25194. }
  25195. this._startLifeTimeGradientMax=value;
  25196. });
  25197. /**
  25198. *设置生命周期速度,注意:如修改该值的某些属性,需重新赋值此属性才可生效。
  25199. *@param value 生命周期速度.
  25200. */
  25201. /**
  25202. *获取生命周期速度,注意:如修改该值的某些属性,需重新赋值此属性才可生效。
  25203. *@return 生命周期速度.
  25204. */
  25205. __getset(0,__proto,'velocityOverLifetime',function(){
  25206. return this._velocityOverLifetime;
  25207. },function(value){
  25208. var defDat=this._owner._render._defineDatas;
  25209. var shaDat=this._owner._render._shaderValues;
  25210. if (value){
  25211. var velocity=value.velocity;
  25212. var velocityType=velocity.type;
  25213. if (value.enbale){
  25214. switch (velocityType){
  25215. case 0:
  25216. defDat.add(ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMECONSTANT);
  25217. break ;
  25218. case 1:
  25219. defDat.add(ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMECURVE);
  25220. break ;
  25221. case 2:
  25222. defDat.add(ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCONSTANT);
  25223. break ;
  25224. case 3:
  25225. defDat.add(ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCURVE);
  25226. break ;
  25227. }
  25228. }else {
  25229. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMECONSTANT);
  25230. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMECURVE);
  25231. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCONSTANT);
  25232. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCURVE);
  25233. }
  25234. switch (velocityType){
  25235. case 0:
  25236. shaDat.setVector3(ShuriKenParticle3D.VOLVELOCITYCONST,velocity.constant);
  25237. break ;
  25238. case 1:
  25239. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTX,velocity.gradientX._elements);
  25240. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTY,velocity.gradientY._elements);
  25241. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTZ,velocity.gradientZ._elements);
  25242. break ;
  25243. case 2:
  25244. shaDat.setVector3(ShuriKenParticle3D.VOLVELOCITYCONST,velocity.constantMin);
  25245. shaDat.setVector3(ShuriKenParticle3D.VOLVELOCITYCONSTMAX,velocity.constantMax);
  25246. break ;
  25247. case 3:
  25248. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTX,velocity.gradientXMin._elements);
  25249. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTXMAX,velocity.gradientXMax._elements);
  25250. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTY,velocity.gradientYMin._elements);
  25251. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTYMAX,velocity.gradientYMax._elements);
  25252. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTZ,velocity.gradientZMin._elements);
  25253. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTZMAX,velocity.gradientZMax._elements);
  25254. break ;
  25255. }
  25256. shaDat.setInt(ShuriKenParticle3D.VOLSPACETYPE,value.space);
  25257. }else {
  25258. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMECONSTANT);
  25259. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMECURVE);
  25260. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCONSTANT);
  25261. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCURVE);
  25262. shaDat.setVector(ShuriKenParticle3D.VOLVELOCITYCONST,null);
  25263. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTX,null);
  25264. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTY,null);
  25265. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTZ,null);
  25266. shaDat.setVector(ShuriKenParticle3D.VOLVELOCITYCONST,null);
  25267. shaDat.setVector(ShuriKenParticle3D.VOLVELOCITYCONSTMAX,null);
  25268. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTX,null);
  25269. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTXMAX,null);
  25270. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTY,null);
  25271. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTYMAX,null);
  25272. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTZ,null);
  25273. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTZMAX,null);
  25274. shaDat.setInt(ShuriKenParticle3D.VOLSPACETYPE,undefined);
  25275. }
  25276. this._velocityOverLifetime=value;
  25277. });
  25278. /**
  25279. *设置生命周期颜色,注意:如修改该值的某些属性,需重新赋值此属性才可生效。
  25280. *@param value 生命周期颜色
  25281. */
  25282. /**
  25283. *获取生命周期颜色,注意:如修改该值的某些属性,需重新赋值此属性才可生效。
  25284. *@return 生命周期颜色
  25285. */
  25286. __getset(0,__proto,'colorOverLifetime',function(){
  25287. return this._colorOverLifetime;
  25288. },function(value){
  25289. var defDat=this._owner._render._defineDatas;
  25290. var shaDat=this._owner._render._shaderValues;
  25291. if (value){
  25292. var color=value.color;
  25293. if (value.enbale){
  25294. switch (color.type){
  25295. case 1:
  25296. defDat.add(ShuriKenParticle3D.SHADERDEFINE_COLOROVERLIFETIME);
  25297. break ;
  25298. case 3:
  25299. defDat.add(ShuriKenParticle3D.SHADERDEFINE_RANDOMCOLOROVERLIFETIME);
  25300. break ;
  25301. }
  25302. }else {
  25303. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_COLOROVERLIFETIME);
  25304. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_RANDOMCOLOROVERLIFETIME);
  25305. }
  25306. switch (color.type){
  25307. case 1:;
  25308. var gradientColor=color.gradient;
  25309. shaDat.setBuffer(ShuriKenParticle3D.COLOROVERLIFEGRADIENTALPHAS,gradientColor._alphaElements);
  25310. shaDat.setBuffer(ShuriKenParticle3D.COLOROVERLIFEGRADIENTCOLORS,gradientColor._rgbElements);
  25311. break ;
  25312. case 3:;
  25313. var minGradientColor=color.gradientMin;
  25314. var maxGradientColor=color.gradientMax;
  25315. shaDat.setBuffer(ShuriKenParticle3D.COLOROVERLIFEGRADIENTALPHAS,minGradientColor._alphaElements);
  25316. shaDat.setBuffer(ShuriKenParticle3D.COLOROVERLIFEGRADIENTCOLORS,minGradientColor._rgbElements);
  25317. shaDat.setBuffer(ShuriKenParticle3D.MAXCOLOROVERLIFEGRADIENTALPHAS,maxGradientColor._alphaElements);
  25318. shaDat.setBuffer(ShuriKenParticle3D.MAXCOLOROVERLIFEGRADIENTCOLORS,maxGradientColor._rgbElements);
  25319. break ;
  25320. }
  25321. }else {
  25322. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_COLOROVERLIFETIME);
  25323. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_RANDOMCOLOROVERLIFETIME);
  25324. shaDat.setBuffer(ShuriKenParticle3D.COLOROVERLIFEGRADIENTALPHAS,gradientColor._alphaElements);
  25325. shaDat.setBuffer(ShuriKenParticle3D.COLOROVERLIFEGRADIENTCOLORS,gradientColor._rgbElements);
  25326. shaDat.setBuffer(ShuriKenParticle3D.COLOROVERLIFEGRADIENTALPHAS,minGradientColor._alphaElements);
  25327. shaDat.setBuffer(ShuriKenParticle3D.COLOROVERLIFEGRADIENTCOLORS,minGradientColor._rgbElements);
  25328. shaDat.setBuffer(ShuriKenParticle3D.MAXCOLOROVERLIFEGRADIENTALPHAS,maxGradientColor._alphaElements);
  25329. shaDat.setBuffer(ShuriKenParticle3D.MAXCOLOROVERLIFEGRADIENTCOLORS,maxGradientColor._rgbElements);
  25330. }
  25331. this._colorOverLifetime=value;
  25332. });
  25333. /**
  25334. *设置生命周期尺寸,注意:如修改该值的某些属性,需重新赋值此属性才可生效。
  25335. *@param value 生命周期尺寸
  25336. */
  25337. /**
  25338. *获取生命周期尺寸,注意:如修改该值的某些属性,需重新赋值此属性才可生效。
  25339. *@return 生命周期尺寸
  25340. */
  25341. __getset(0,__proto,'sizeOverLifetime',function(){
  25342. return this._sizeOverLifetime;
  25343. },function(value){
  25344. var defDat=this._owner._render._defineDatas;
  25345. var shaDat=this._owner._render._shaderValues;
  25346. if (value){
  25347. var size=value.size;
  25348. var sizeSeparate=size.separateAxes;
  25349. var sizeType=size.type;
  25350. if (value.enbale){
  25351. switch (sizeType){
  25352. case 0:
  25353. if (sizeSeparate)
  25354. defDat.add(ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMECURVESEPERATE);
  25355. else
  25356. defDat.add(ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMECURVE);
  25357. break ;
  25358. case 2:
  25359. if (sizeSeparate)
  25360. defDat.add(ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVESSEPERATE);
  25361. else
  25362. defDat.add(ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVES);
  25363. break ;
  25364. }
  25365. }else {
  25366. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMECURVE);
  25367. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMECURVESEPERATE);
  25368. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVES);
  25369. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVESSEPERATE);
  25370. }
  25371. switch (sizeType){
  25372. case 0:
  25373. if (sizeSeparate){
  25374. shaDat.setBuffer(ShuriKenParticle3D.SOLSIZEGRADIENTX,size.gradientX._elements);
  25375. shaDat.setBuffer(ShuriKenParticle3D.SOLSIZEGRADIENTY,size.gradientY._elements);
  25376. shaDat.setBuffer(ShuriKenParticle3D.SOLSizeGradientZ,size.gradientZ._elements);
  25377. }else {
  25378. shaDat.setBuffer(ShuriKenParticle3D.SOLSIZEGRADIENT,size.gradient._elements);
  25379. }
  25380. break ;
  25381. case 2:
  25382. if (sizeSeparate){
  25383. shaDat.setBuffer(ShuriKenParticle3D.SOLSIZEGRADIENTX,size.gradientXMin._elements);
  25384. shaDat.setBuffer(ShuriKenParticle3D.SOLSIZEGRADIENTXMAX,size.gradientXMax._elements);
  25385. shaDat.setBuffer(ShuriKenParticle3D.SOLSIZEGRADIENTY,size.gradientYMin._elements);
  25386. shaDat.setBuffer(ShuriKenParticle3D.SOLSIZEGRADIENTYMAX,size.gradientYMax._elements);
  25387. shaDat.setBuffer(ShuriKenParticle3D.SOLSizeGradientZ,size.gradientZMin._elements);
  25388. shaDat.setBuffer(ShuriKenParticle3D.SOLSizeGradientZMAX,size.gradientZMax._elements);
  25389. }else {
  25390. shaDat.setBuffer(ShuriKenParticle3D.SOLSIZEGRADIENT,size.gradientMin._elements);
  25391. shaDat.setBuffer(ShuriKenParticle3D.SOLSizeGradientMax,size.gradientMax._elements);
  25392. }
  25393. break ;
  25394. }
  25395. }else {
  25396. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMECURVE);
  25397. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMECURVESEPERATE);
  25398. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVES);
  25399. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVESSEPERATE);
  25400. shaDat.setBuffer(ShuriKenParticle3D.SOLSIZEGRADIENTX,null);
  25401. shaDat.setBuffer(ShuriKenParticle3D.SOLSIZEGRADIENTXMAX,null);
  25402. shaDat.setBuffer(ShuriKenParticle3D.SOLSIZEGRADIENTY,null);
  25403. shaDat.setBuffer(ShuriKenParticle3D.SOLSIZEGRADIENTYMAX,null);
  25404. shaDat.setBuffer(ShuriKenParticle3D.SOLSizeGradientZ,null);
  25405. shaDat.setBuffer(ShuriKenParticle3D.SOLSizeGradientZMAX,null);
  25406. shaDat.setBuffer(ShuriKenParticle3D.SOLSIZEGRADIENT,null);
  25407. shaDat.setBuffer(ShuriKenParticle3D.SOLSizeGradientMax,null);
  25408. }
  25409. this._sizeOverLifetime=value;
  25410. });
  25411. /**
  25412. *设置生命周期纹理动画,注意:如修改该值的某些属性,需重新赋值此属性才可生效。
  25413. *@param value 生命周期纹理动画。
  25414. */
  25415. /**
  25416. *获取生命周期纹理动画,注意:如修改该值的某些属性,需重新赋值此属性才可生效。
  25417. *@return 生命周期纹理动画。
  25418. */
  25419. __getset(0,__proto,'textureSheetAnimation',function(){
  25420. return this._textureSheetAnimation;
  25421. },function(value){
  25422. var defDat=this._owner._render._defineDatas;
  25423. var shaDat=this._owner._render._shaderValues;
  25424. if (value){
  25425. var frameOverTime=value.frame;
  25426. var textureAniType=frameOverTime.type;
  25427. if (value.enable){
  25428. switch (textureAniType){
  25429. case 1:
  25430. defDat.add(ShuriKenParticle3D.SHADERDEFINE_TEXTURESHEETANIMATIONCURVE);
  25431. break ;
  25432. case 3:
  25433. defDat.add(ShuriKenParticle3D.SHADERDEFINE_TEXTURESHEETANIMATIONRANDOMCURVE);
  25434. break ;
  25435. }
  25436. }else {
  25437. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_TEXTURESHEETANIMATIONCURVE);
  25438. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_TEXTURESHEETANIMATIONRANDOMCURVE);
  25439. }
  25440. if (textureAniType===1 || textureAniType===3){
  25441. shaDat.setNumber(ShuriKenParticle3D.TEXTURESHEETANIMATIONCYCLES,value.cycles);
  25442. var title=value.tiles;
  25443. var _uvLengthE=this._uvLength;
  25444. _uvLengthE.x=1.0 / title.x;
  25445. _uvLengthE.y=1.0 / title.y;
  25446. shaDat.setVector2(ShuriKenParticle3D.TEXTURESHEETANIMATIONSUBUVLENGTH,this._uvLength);
  25447. }
  25448. switch (textureAniType){
  25449. case 1:
  25450. shaDat.setBuffer(ShuriKenParticle3D.TEXTURESHEETANIMATIONGRADIENTUVS,frameOverTime.frameOverTimeData._elements);
  25451. break ;
  25452. case 3:
  25453. shaDat.setBuffer(ShuriKenParticle3D.TEXTURESHEETANIMATIONGRADIENTUVS,frameOverTime.frameOverTimeDataMin._elements);
  25454. shaDat.setBuffer(ShuriKenParticle3D.TEXTURESHEETANIMATIONGRADIENTMAXUVS,frameOverTime.frameOverTimeDataMax._elements);
  25455. break ;
  25456. }
  25457. }else {
  25458. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_TEXTURESHEETANIMATIONCURVE);
  25459. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_TEXTURESHEETANIMATIONRANDOMCURVE);
  25460. shaDat.setNumber(ShuriKenParticle3D.TEXTURESHEETANIMATIONCYCLES,undefined);
  25461. shaDat.setVector(ShuriKenParticle3D.TEXTURESHEETANIMATIONSUBUVLENGTH,null);
  25462. shaDat.setBuffer(ShuriKenParticle3D.TEXTURESHEETANIMATIONGRADIENTUVS,null);
  25463. shaDat.setBuffer(ShuriKenParticle3D.TEXTURESHEETANIMATIONGRADIENTMAXUVS,null);
  25464. }
  25465. this._textureSheetAnimation=value;
  25466. });
  25467. ShurikenParticleSystem.halfKSqrtOf2=1.42 *0.5;
  25468. __static(ShurikenParticleSystem,
  25469. ['_RANDOMOFFSET',function(){return this._RANDOMOFFSET=new Uint32Array([0x23571a3e,0xc34f56fe,0x13371337,0x12460f3b,0x6aed452e,0xdec4aea1,0x96aa4de3,0x8d2c8431,0xf3857f6f,0xe0fbd834,0x13740583,0x591bc05c,0x40eb95e4,0xbc524e5f,0xaf502044,0xa614b381,0x1034e524,0xfc524e5f]);},'_maxElapsedTime',function(){return this._maxElapsedTime=1.0 / 3.0;},'_tempVector30',function(){return this._tempVector30=new Vector3();},'_tempVector31',function(){return this._tempVector31=new Vector3();},'_tempVector32',function(){return this._tempVector32=new Vector3();},'_tempVector33',function(){return this._tempVector33=new Vector3();},'_tempVector34',function(){return this._tempVector34=new Vector3();},'_tempVector35',function(){return this._tempVector35=new Vector3();},'_tempVector36',function(){return this._tempVector36=new Vector3();},'_tempVector37',function(){return this._tempVector37=new Vector3();},'_tempVector38',function(){return this._tempVector38=new Vector3();},'_tempVector39',function(){return this._tempVector39=new Vector3();},'_tempPosition',function(){return this._tempPosition=new Vector3();},'_tempDirection',function(){return this._tempDirection=new Vector3();},'_type',function(){return this._type=GeometryElement._typeCounter++;}
  25470. ]);
  25471. return ShurikenParticleSystem;
  25472. })(GeometryElement)
  25473. /**
  25474. *<code>StaticPlaneColliderShape</code> 类用于创建静态平面碰撞器。
  25475. */
  25476. //class laya.d3.physics.shape.StaticPlaneColliderShape extends laya.d3.physics.shape.ColliderShape
  25477. var StaticPlaneColliderShape=(function(_super){
  25478. function StaticPlaneColliderShape(normal,offset){
  25479. /**@private */
  25480. //this._offset=NaN;
  25481. /**@private */
  25482. //this._normal=null;
  25483. StaticPlaneColliderShape.__super.call(this);
  25484. this._normal=normal;
  25485. this._offset=offset;
  25486. this._type=/*laya.d3.physics.shape.ColliderShape.SHAPETYPES_STATICPLANE*/6;
  25487. StaticPlaneColliderShape._nativeNormal.setValue(-normal.x,normal.y,normal.z);
  25488. this._nativeShape=new Laya3D._physics3D.btStaticPlaneShape(StaticPlaneColliderShape._nativeNormal,offset);
  25489. }
  25490. __class(StaticPlaneColliderShape,'laya.d3.physics.shape.StaticPlaneColliderShape',_super);
  25491. var __proto=StaticPlaneColliderShape.prototype;
  25492. /**
  25493. *@inheritDoc
  25494. */
  25495. __proto.clone=function(){
  25496. var dest=new StaticPlaneColliderShape(this._normal,this._offset);
  25497. this.cloneTo(dest);
  25498. return dest;
  25499. }
  25500. __static(StaticPlaneColliderShape,
  25501. ['_nativeNormal',function(){return this._nativeNormal=new Laya3D._physics3D.btVector3(0,0,0);}
  25502. ]);
  25503. return StaticPlaneColliderShape;
  25504. })(ColliderShape)
  25505. /**
  25506. *@private
  25507. *<code>MeshSprite3DDynamicBatchManager</code> 类用于网格精灵动态批处理管理。
  25508. */
  25509. //class laya.d3.graphics.MeshRenderDynamicBatchManager extends laya.d3.graphics.DynamicBatchManager
  25510. var MeshRenderDynamicBatchManager=(function(_super){
  25511. function MeshRenderDynamicBatchManager(){
  25512. /**@private [只读]*/
  25513. //this._updateCountMark=0;
  25514. this._instanceBatchOpaqueMarks=[];
  25515. this._vertexBatchOpaqueMarks=[];
  25516. this._cacheBufferStates=[];
  25517. MeshRenderDynamicBatchManager.__super.call(this);
  25518. SubMeshDynamicBatch.instance=new SubMeshDynamicBatch();
  25519. this._updateCountMark=0;
  25520. }
  25521. __class(MeshRenderDynamicBatchManager,'laya.d3.graphics.MeshRenderDynamicBatchManager',_super);
  25522. var __proto=MeshRenderDynamicBatchManager.prototype;
  25523. /**
  25524. *@private
  25525. */
  25526. __proto.getInstanceBatchOpaquaMark=function(lightMapIndex,receiveShadow,materialID,subMeshID){
  25527. var instanceLightMapMarks=(this._instanceBatchOpaqueMarks[lightMapIndex])|| (this._instanceBatchOpaqueMarks[lightMapIndex]=[]);
  25528. var instanceReceiveShadowMarks=(instanceLightMapMarks[receiveShadow ? 0 :1])|| (instanceLightMapMarks[receiveShadow ? 0 :1]=[]);
  25529. var instanceMaterialMarks=(instanceReceiveShadowMarks[materialID])|| (instanceReceiveShadowMarks[materialID]=[]);
  25530. return instanceMaterialMarks[subMeshID] || (instanceMaterialMarks[subMeshID]=new BatchMark());
  25531. }
  25532. /**
  25533. *@private
  25534. */
  25535. __proto.getVertexBatchOpaquaMark=function(lightMapIndex,receiveShadow,materialID,verDecID){
  25536. var dynLightMapMarks=(this._vertexBatchOpaqueMarks[lightMapIndex])|| (this._vertexBatchOpaqueMarks[lightMapIndex]=[]);
  25537. var dynReceiveShadowMarks=(dynLightMapMarks[receiveShadow ? 0 :1])|| (dynLightMapMarks[receiveShadow ? 0 :1]=[]);
  25538. var dynMaterialMarks=(dynReceiveShadowMarks[materialID])|| (dynReceiveShadowMarks[materialID]=[]);
  25539. return dynMaterialMarks[verDecID] || (dynMaterialMarks[verDecID]=new BatchMark());
  25540. }
  25541. /**
  25542. *@private
  25543. */
  25544. __proto._getBufferState=function(vertexDeclaration){
  25545. var bufferState=this._cacheBufferStates[vertexDeclaration.id];
  25546. if (!bufferState){
  25547. var instance=SubMeshDynamicBatch.instance;
  25548. bufferState=new BufferState();
  25549. bufferState.bind();
  25550. var vertexBuffer=instance._vertexBuffer;
  25551. vertexBuffer.vertexDeclaration=vertexDeclaration;
  25552. bufferState.applyVertexBuffer(vertexBuffer);
  25553. bufferState.applyIndexBuffer(instance._indexBuffer);
  25554. bufferState.unBind();
  25555. this._cacheBufferStates[vertexDeclaration.id]=bufferState;
  25556. }
  25557. return bufferState;
  25558. }
  25559. /**
  25560. *@inheritDoc
  25561. */
  25562. __proto._getBatchRenderElementFromPool=function(){
  25563. var renderElement=this._batchRenderElementPool [this._batchRenderElementPoolIndex++];
  25564. if (!renderElement){
  25565. renderElement=new SubMeshRenderElement();
  25566. this._batchRenderElementPool[this._batchRenderElementPoolIndex-1]=renderElement;
  25567. renderElement.vertexBatchElementList=[];
  25568. renderElement.instanceBatchElementList=[];
  25569. }
  25570. return renderElement;
  25571. }
  25572. /**
  25573. *@inheritDoc
  25574. */
  25575. __proto._clear=function(){
  25576. _super.prototype._clear.call(this);
  25577. this._updateCountMark++;
  25578. }
  25579. __static(MeshRenderDynamicBatchManager,
  25580. ['instance',function(){return this.instance=new MeshRenderDynamicBatchManager();}
  25581. ]);
  25582. return MeshRenderDynamicBatchManager;
  25583. })(DynamicBatchManager)
  25584. /**
  25585. *<code>BoxColliderShape</code> 类用于创建盒子形状碰撞器。
  25586. */
  25587. //class laya.d3.physics.shape.BoxColliderShape extends laya.d3.physics.shape.ColliderShape
  25588. var BoxColliderShape=(function(_super){
  25589. function BoxColliderShape(sizeX,sizeY,sizeZ){
  25590. /**@private */
  25591. //this._sizeX=NaN;
  25592. /**@private */
  25593. //this._sizeY=NaN;
  25594. /**@private */
  25595. //this._sizeZ=NaN;
  25596. BoxColliderShape.__super.call(this);
  25597. (sizeX===void 0)&& (sizeX=1.0);
  25598. (sizeY===void 0)&& (sizeY=1.0);
  25599. (sizeZ===void 0)&& (sizeZ=1.0);
  25600. this._sizeX=sizeX;
  25601. this._sizeY=sizeY;
  25602. this._sizeZ=sizeZ;
  25603. this._type=/*laya.d3.physics.shape.ColliderShape.SHAPETYPES_BOX*/0;
  25604. BoxColliderShape._nativeSize.setValue(sizeX / 2,sizeY / 2,sizeZ / 2);
  25605. this._nativeShape=new Laya3D._physics3D.btBoxShape(BoxColliderShape._nativeSize);
  25606. }
  25607. __class(BoxColliderShape,'laya.d3.physics.shape.BoxColliderShape',_super);
  25608. var __proto=BoxColliderShape.prototype;
  25609. /**
  25610. *@inheritDoc
  25611. */
  25612. __proto.clone=function(){
  25613. var dest=new BoxColliderShape(this._sizeX,this._sizeY,this._sizeZ);
  25614. this.cloneTo(dest);
  25615. return dest;
  25616. }
  25617. /**
  25618. *获取X轴尺寸。
  25619. */
  25620. __getset(0,__proto,'sizeX',function(){
  25621. return this._sizeX;
  25622. });
  25623. /**
  25624. *获取Y轴尺寸。
  25625. */
  25626. __getset(0,__proto,'sizeY',function(){
  25627. return this._sizeY;
  25628. });
  25629. /**
  25630. *获取Z轴尺寸。
  25631. */
  25632. __getset(0,__proto,'sizeZ',function(){
  25633. return this._sizeZ;
  25634. });
  25635. __static(BoxColliderShape,
  25636. ['_nativeSize',function(){return this._nativeSize=new Laya3D._physics3D.btVector3(0,0,0);}
  25637. ]);
  25638. return BoxColliderShape;
  25639. })(ColliderShape)
  25640. /**
  25641. *<code>SimpleSingletonList</code> 类用于实现单例队列。
  25642. */
  25643. //class laya.d3.component.SimpleSingletonList extends laya.d3.component.SingletonList
  25644. var SimpleSingletonList=(function(_super){
  25645. /**
  25646. *创建一个新的 <code>SimpleSingletonList</code> 实例。
  25647. */
  25648. function SimpleSingletonList(){
  25649. SimpleSingletonList.__super.call(this);
  25650. }
  25651. __class(SimpleSingletonList,'laya.d3.component.SimpleSingletonList',_super);
  25652. var __proto=SimpleSingletonList.prototype;
  25653. /**
  25654. *@private
  25655. */
  25656. __proto.add=function(element){
  25657. var index=element._getIndexInList();
  25658. if (index!==-1)
  25659. throw "SimpleSingletonList:"+element+" has in SingletonList.";
  25660. this._add(element);
  25661. element._setIndexInList(this.length++);
  25662. }
  25663. /**
  25664. *@private
  25665. */
  25666. __proto.remove=function(element){
  25667. var index=element._getIndexInList();
  25668. this.length--;
  25669. if (index!==this.length){
  25670. var end=this.elements[this.length];
  25671. this.elements[index]=end;
  25672. end._setIndexInList(index);
  25673. }
  25674. element._setIndexInList(-1);
  25675. }
  25676. return SimpleSingletonList;
  25677. })(SingletonList)
  25678. /**
  25679. *<code>PhysicsUpdateList</code> 类用于实现物理更新队列。
  25680. */
  25681. //class laya.d3.physics.PhysicsUpdateList extends laya.d3.component.SingletonList
  25682. var PhysicsUpdateList=(function(_super){
  25683. /**
  25684. *创建一个新的 <code>PhysicsUpdateList</code> 实例。
  25685. */
  25686. function PhysicsUpdateList(){
  25687. PhysicsUpdateList.__super.call(this);
  25688. }
  25689. __class(PhysicsUpdateList,'laya.d3.physics.PhysicsUpdateList',_super);
  25690. var __proto=PhysicsUpdateList.prototype;
  25691. /**
  25692. *@private
  25693. */
  25694. __proto.add=function(element){
  25695. var index=element._inPhysicUpdateListIndex;
  25696. if (index!==-1)
  25697. throw "PhysicsUpdateList:element has in PhysicsUpdateList.";
  25698. this._add(element);
  25699. element._inPhysicUpdateListIndex=this.length++;
  25700. }
  25701. /**
  25702. *@private
  25703. */
  25704. __proto.remove=function(element){
  25705. var index=element._inPhysicUpdateListIndex;
  25706. this.length--;
  25707. if (index!==this.length){
  25708. var end=this.elements[this.length];
  25709. this.elements[index]=end;
  25710. end._inPhysicUpdateListIndex=index;
  25711. }
  25712. element._inPhysicUpdateListIndex=-1;
  25713. }
  25714. return PhysicsUpdateList;
  25715. })(SingletonList)
  25716. /**
  25717. *@private
  25718. *<code>SubMeshStaticBatch</code> 类用于网格静态合并。
  25719. */
  25720. //class laya.d3.graphics.SubMeshStaticBatch extends laya.d3.core.GeometryElement
  25721. var SubMeshStaticBatch=(function(_super){
  25722. function SubMeshStaticBatch(batchOwner,number,vertexDeclaration){
  25723. /**@private */
  25724. //this._currentBatchVertexCount=0;
  25725. /**@private */
  25726. //this._currentBatchIndexCount=0;
  25727. /**@private */
  25728. //this._vertexDeclaration=null;
  25729. /**@private */
  25730. //this._vertexBuffer=null;
  25731. /**@private */
  25732. //this._indexBuffer=null;
  25733. /**@private */
  25734. //this._batchElements=null;
  25735. /**@private */
  25736. //this._batchID=0;
  25737. /**@private [只读]*/
  25738. //this.batchOwner=null;
  25739. /**@private [只读]*/
  25740. //this.number=0;
  25741. SubMeshStaticBatch.__super.call(this);
  25742. this._bufferState=new BufferState();
  25743. this._batchID=SubMeshStaticBatch._batchIDCounter++;
  25744. this._batchElements=[];
  25745. this._currentBatchVertexCount=0;
  25746. this._currentBatchIndexCount=0;
  25747. this._vertexDeclaration=vertexDeclaration;
  25748. this.batchOwner=batchOwner;
  25749. this.number=number;
  25750. }
  25751. __class(SubMeshStaticBatch,'laya.d3.graphics.SubMeshStaticBatch',_super);
  25752. var __proto=SubMeshStaticBatch.prototype;
  25753. Laya.imps(__proto,{"laya.resource.IDispose":true})
  25754. /**
  25755. *@private
  25756. */
  25757. __proto._getStaticBatchBakedVertexs=function(batchVertices,batchOffset,batchOwnerTransform,transform,render,mesh){
  25758. var vertexBuffer=mesh._vertexBuffers[0];
  25759. var vertexDeclaration=vertexBuffer.vertexDeclaration;
  25760. var positionOffset=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0).offset / 4;
  25761. var normalElement=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_NORMAL0*/3);
  25762. var normalOffset=normalElement ? normalElement.offset / 4 :-1;
  25763. var colorElement=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_COLOR0*/1);
  25764. var colorOffset=colorElement ? colorElement.offset / 4 :-1;
  25765. var uv0Element=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE0*/2);
  25766. var uv0Offset=uv0Element ? uv0Element.offset / 4 :-1;
  25767. var uv1Element=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE1*/7);
  25768. var uv1Offset=uv1Element ? uv1Element.offset / 4 :-1;
  25769. var tangentElement=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_TANGENT0*/4);
  25770. var sTangentOffset=tangentElement ? tangentElement.offset / 4 :-1;
  25771. var bakeVertexFloatCount=18;
  25772. var oriVertexFloatCount=vertexDeclaration.vertexStride / 4;
  25773. var oriVertexes=vertexBuffer.getData();
  25774. var worldMat;
  25775. if (batchOwnerTransform){
  25776. var rootMat=batchOwnerTransform.worldMatrix;
  25777. rootMat.invert(SubMeshStaticBatch._tempMatrix4x40);
  25778. worldMat=SubMeshStaticBatch._tempMatrix4x41;
  25779. Matrix4x4.multiply(SubMeshStaticBatch._tempMatrix4x40,transform.worldMatrix,worldMat);
  25780. }else {
  25781. worldMat=transform.worldMatrix;
  25782. };
  25783. var rotation=SubMeshStaticBatch._tempQuaternion0;
  25784. worldMat.decomposeTransRotScale(SubMeshStaticBatch._tempVector30,rotation,SubMeshStaticBatch._tempVector31);
  25785. var lightmapScaleOffset=render.lightmapScaleOffset;
  25786. var vertexCount=mesh.vertexCount;
  25787. for (var i=0;i < vertexCount;i++){
  25788. var oriOffset=i *oriVertexFloatCount;
  25789. var bakeOffset=(i+batchOffset)*bakeVertexFloatCount;
  25790. Utils3D.transformVector3ArrayToVector3ArrayCoordinate(oriVertexes,oriOffset+positionOffset,worldMat,batchVertices,bakeOffset+0);
  25791. if (normalOffset!==-1)
  25792. Utils3D.transformVector3ArrayByQuat(oriVertexes,oriOffset+normalOffset,rotation,batchVertices,bakeOffset+3);
  25793. var j=0,m=0;
  25794. var bakOff=bakeOffset+6;
  25795. if (colorOffset!==-1){
  25796. var oriOff=oriOffset+colorOffset;
  25797. for (j=0,m=4;j < m;j++)
  25798. batchVertices[bakOff+j]=oriVertexes[oriOff+j];
  25799. }else {
  25800. for (j=0,m=4;j < m;j++)
  25801. batchVertices[bakOff+j]=1.0;
  25802. }
  25803. if (uv0Offset!==-1){
  25804. var absUv0Offset=oriOffset+uv0Offset;
  25805. batchVertices[bakeOffset+10]=oriVertexes[absUv0Offset];
  25806. batchVertices[bakeOffset+11]=oriVertexes[absUv0Offset+1];
  25807. }
  25808. if (lightmapScaleOffset){
  25809. if (uv1Offset!==-1)
  25810. Utils3D.transformLightingMapTexcoordArray(oriVertexes,oriOffset+uv1Offset,lightmapScaleOffset,batchVertices,bakeOffset+12);
  25811. else
  25812. Utils3D.transformLightingMapTexcoordArray(oriVertexes,oriOffset+uv0Offset,lightmapScaleOffset,batchVertices,bakeOffset+12);
  25813. }
  25814. if (sTangentOffset!==-1){
  25815. var absSTanegntOffset=oriOffset+sTangentOffset;
  25816. batchVertices[bakeOffset+14]=oriVertexes[absSTanegntOffset];
  25817. batchVertices[bakeOffset+15]=oriVertexes[absSTanegntOffset+1];
  25818. batchVertices[bakeOffset+16]=oriVertexes[absSTanegntOffset+2];
  25819. batchVertices[bakeOffset+17]=oriVertexes[absSTanegntOffset+3];
  25820. }
  25821. }
  25822. return vertexCount;
  25823. }
  25824. /**
  25825. *@private
  25826. */
  25827. __proto.addTest=function(sprite){
  25828. var vertexCount=0;
  25829. var subMeshVertexCount=((sprite).meshFilter.sharedMesh).vertexCount;
  25830. vertexCount=this._currentBatchVertexCount+subMeshVertexCount;
  25831. if (vertexCount > 65535)
  25832. return false;
  25833. return true;
  25834. }
  25835. /**
  25836. *@private
  25837. */
  25838. __proto.add=function(sprite){
  25839. var oldStaticBatch=sprite._render._staticBatch;
  25840. (oldStaticBatch)&& (oldStaticBatch.remove(sprite));
  25841. var mesh=(sprite).meshFilter.sharedMesh;
  25842. var subMeshVertexCount=mesh.vertexCount;
  25843. this._batchElements.push(sprite);
  25844. var render=sprite._render;
  25845. render._isPartOfStaticBatch=true;
  25846. render._staticBatch=this;
  25847. var renderElements=render._renderElements;
  25848. for (var i=0,n=renderElements.length;i < n;i++)
  25849. renderElements[i].staticBatch=this;
  25850. this._currentBatchIndexCount+=mesh._indexBuffer.indexCount;
  25851. this._currentBatchVertexCount+=subMeshVertexCount;
  25852. }
  25853. /**
  25854. *@private
  25855. */
  25856. __proto.remove=function(sprite){
  25857. var mesh=(sprite).meshFilter.sharedMesh;
  25858. var index=this._batchElements.indexOf(sprite);
  25859. if (index!==-1){
  25860. this._batchElements.splice(index,1);
  25861. var render=sprite._render;
  25862. var renderElements=sprite._render._renderElements;
  25863. for (var i=0,n=renderElements.length;i < n;i++)
  25864. renderElements[i].staticBatch=null;
  25865. var meshVertexCount=mesh.vertexCount;
  25866. this._currentBatchIndexCount=this._currentBatchIndexCount-mesh._indexBuffer.indexCount;
  25867. this._currentBatchVertexCount=this._currentBatchVertexCount-meshVertexCount;
  25868. sprite._render._isPartOfStaticBatch=false;
  25869. }
  25870. }
  25871. /**
  25872. *@private
  25873. */
  25874. __proto.finishInit=function(){
  25875. if (this._vertexBuffer){
  25876. this._vertexBuffer.destroy();
  25877. this._indexBuffer.destroy();
  25878. Resource._addGPUMemory(-(this._vertexBuffer._byteLength+this._indexBuffer._byteLength));
  25879. };
  25880. var batchVertexCount=0;
  25881. var batchIndexCount=0;
  25882. var rootOwner=this.batchOwner;
  25883. var floatStride=this._vertexDeclaration.vertexStride / 4;
  25884. var vertexDatas=new Float32Array(floatStride *this._currentBatchVertexCount);
  25885. var indexDatas=new Uint16Array(this._currentBatchIndexCount);
  25886. this._vertexBuffer=new VertexBuffer3D(this._vertexDeclaration.vertexStride *this._currentBatchVertexCount,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4);
  25887. this._vertexBuffer.vertexDeclaration=this._vertexDeclaration;
  25888. this._indexBuffer=new IndexBuffer3D(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",this._currentBatchIndexCount,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4);
  25889. for (var i=0,n=this._batchElements.length;i < n;i++){
  25890. var sprite=this._batchElements [i];
  25891. var mesh=sprite.meshFilter.sharedMesh;
  25892. var meshVerCount=this._getStaticBatchBakedVertexs(vertexDatas,batchVertexCount,rootOwner ? rootOwner._transform :null,sprite._transform,(sprite._render),mesh);
  25893. var indices=mesh._indexBuffer.getData();
  25894. var indexOffset=batchVertexCount;
  25895. var indexEnd=batchIndexCount+indices.length;
  25896. var elements=sprite._render._renderElements;
  25897. for (var j=0,m=mesh.subMeshCount;j < m;j++){
  25898. var subMesh=mesh._subMeshes[j];
  25899. var start=batchIndexCount+subMesh._indexStart;
  25900. var element=elements [j];
  25901. element.staticBatchIndexStart=start;
  25902. element.staticBatchIndexEnd=start+subMesh._indexCount;
  25903. }
  25904. indexDatas.set(indices,batchIndexCount);
  25905. var k=0;
  25906. var isInvert=rootOwner ? (sprite._transform._isFrontFaceInvert!==rootOwner.transform._isFrontFaceInvert):sprite._transform._isFrontFaceInvert;
  25907. if (isInvert){
  25908. for (k=batchIndexCount;k < indexEnd;k+=3){
  25909. indexDatas[k]=indexOffset+indexDatas[k];
  25910. var index1=indexDatas[k+1];
  25911. var index2=indexDatas[k+2];
  25912. indexDatas[k+1]=indexOffset+index2;
  25913. indexDatas[k+2]=indexOffset+index1;
  25914. }
  25915. }else {
  25916. for (k=batchIndexCount;k < indexEnd;k+=3){
  25917. indexDatas[k]=indexOffset+indexDatas[k];
  25918. indexDatas[k+1]=indexOffset+indexDatas[k+1];
  25919. indexDatas[k+2]=indexOffset+indexDatas[k+2];
  25920. }
  25921. }
  25922. batchIndexCount+=indices.length;
  25923. batchVertexCount+=meshVerCount;
  25924. }
  25925. this._vertexBuffer.setData(vertexDatas);
  25926. this._indexBuffer.setData(indexDatas);
  25927. var memorySize=this._vertexBuffer._byteLength+this._indexBuffer._byteLength;
  25928. Resource._addGPUMemory(memorySize);
  25929. this._bufferState.bind();
  25930. this._bufferState.applyVertexBuffer(this._vertexBuffer);
  25931. this._bufferState.applyIndexBuffer(this._indexBuffer);
  25932. this._bufferState.unBind();
  25933. }
  25934. /**
  25935. *@inheritDoc
  25936. */
  25937. __proto._render=function(state){
  25938. this._bufferState.bind();
  25939. var element=state.renderElement;
  25940. var batchElementList=(element).staticBatchElementList;
  25941. var from=0;
  25942. var end=0;
  25943. var count=batchElementList.length;
  25944. for (var i=1;i < count;i++){
  25945. var lastElement=batchElementList[i-1];
  25946. if (lastElement.staticBatchIndexEnd===batchElementList[i].staticBatchIndexStart){
  25947. end++;
  25948. continue ;
  25949. }else {
  25950. var start=batchElementList[from].staticBatchIndexStart;
  25951. var indexCount=batchElementList[end].staticBatchIndexEnd-start;
  25952. LayaGL.instance.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,indexCount,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,start *2);
  25953. from=++end;
  25954. Stat.trianglesFaces+=indexCount / 3;
  25955. }
  25956. }
  25957. start=batchElementList[from].staticBatchIndexStart;
  25958. indexCount=batchElementList[end].staticBatchIndexEnd-start;
  25959. LayaGL.instance.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,indexCount,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,start *2);
  25960. Stat.renderBatches++;
  25961. Stat.savedRenderBatches+=count-1;
  25962. Stat.trianglesFaces+=indexCount / 3;
  25963. }
  25964. /**
  25965. *@private
  25966. */
  25967. __proto.dispose=function(){
  25968. var memorySize=this._vertexBuffer._byteLength+this._indexBuffer._byteLength;
  25969. Resource._addGPUMemory(-memorySize);
  25970. this._batchElements=null;
  25971. this.batchOwner=null;
  25972. this._vertexDeclaration=null;
  25973. this._bufferState.destroy();
  25974. this._vertexBuffer.destroy();
  25975. this._indexBuffer.destroy();
  25976. this._vertexBuffer=null;
  25977. this._indexBuffer=null;
  25978. this._bufferState=null;
  25979. }
  25980. SubMeshStaticBatch.maxBatchVertexCount=65535;
  25981. SubMeshStaticBatch._batchIDCounter=0;
  25982. __static(SubMeshStaticBatch,
  25983. ['_tempVector30',function(){return this._tempVector30=new Vector3();},'_tempVector31',function(){return this._tempVector31=new Vector3();},'_tempQuaternion0',function(){return this._tempQuaternion0=new Quaternion();},'_tempMatrix4x40',function(){return this._tempMatrix4x40=new Matrix4x4();},'_tempMatrix4x41',function(){return this._tempMatrix4x41=new Matrix4x4();}
  25984. ]);
  25985. return SubMeshStaticBatch;
  25986. })(GeometryElement)
  25987. /**
  25988. *<code>TrailGeometry</code> 类用于创建拖尾渲染单元。
  25989. */
  25990. //class laya.d3.core.trail.TrailGeometry extends laya.d3.core.GeometryElement
  25991. var TrailGeometry=(function(_super){
  25992. function TrailGeometry(owner){
  25993. /**@private */
  25994. this._floatCountPerVertices1=8;
  25995. /**@private */
  25996. this._floatCountPerVertices2=1;
  25997. /**@private */
  25998. this._increaseSegementCount=128;
  25999. /**@private */
  26000. this._activeIndex=0;
  26001. /**@private */
  26002. this._endIndex=0;
  26003. /**@private */
  26004. this._needAddFirstVertex=false;
  26005. /**@private */
  26006. this._isTempEndVertex=false;
  26007. /**@private */
  26008. this._subBirthTime=null;
  26009. /**@private */
  26010. this._subDistance=null;
  26011. /**@private */
  26012. this._segementCount=0;
  26013. /**@private */
  26014. this._vertices1=null;
  26015. /**@private */
  26016. this._vertices2=null;
  26017. /**@private */
  26018. this._vertexBuffer1=null;
  26019. /**@private */
  26020. this._vertexBuffer2=null;
  26021. /**@private */
  26022. this._owner=null;
  26023. TrailGeometry.__super.call(this);
  26024. this._lastFixedVertexPosition=new Vector3();
  26025. this._bufferState=new BufferState();
  26026. this._owner=owner;;
  26027. this._resizeData(this._increaseSegementCount,this._bufferState);
  26028. }
  26029. __class(TrailGeometry,'laya.d3.core.trail.TrailGeometry',_super);
  26030. var __proto=TrailGeometry.prototype;
  26031. /**
  26032. *@private
  26033. */
  26034. __proto._resizeData=function(segementCount,bufferState){
  26035. this._segementCount=this._increaseSegementCount;
  26036. this._subBirthTime=new Float32Array(segementCount);
  26037. this._subDistance=new Float32Array(segementCount);
  26038. var vertexCount=segementCount *2;
  26039. var vertexDeclaration1=VertexTrail.vertexDeclaration1;
  26040. var vertexDeclaration2=VertexTrail.vertexDeclaration2;
  26041. var vertexBuffers=[];
  26042. var vertexbuffer1Size=vertexCount *vertexDeclaration1.vertexStride;
  26043. var vertexbuffer2Size=vertexCount *vertexDeclaration2.vertexStride;
  26044. var memorySize=vertexbuffer1Size+vertexbuffer2Size;
  26045. this._vertices1=new Float32Array(vertexCount *this._floatCountPerVertices1);
  26046. this._vertexBuffer1=new VertexBuffer3D(vertexbuffer1Size,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,false);
  26047. this._vertexBuffer1.vertexDeclaration=vertexDeclaration1;
  26048. this._vertices2=new Float32Array(vertexCount *this._floatCountPerVertices2);
  26049. this._vertexBuffer2=new VertexBuffer3D(vertexbuffer2Size,/*laya.webgl.WebGLContext.DYNAMIC_DRAW*/0x88E8,false);
  26050. this._vertexBuffer2.vertexDeclaration=vertexDeclaration2;
  26051. vertexBuffers.push(this._vertexBuffer1);
  26052. vertexBuffers.push(this._vertexBuffer2);
  26053. bufferState.bind();
  26054. bufferState.applyVertexBuffers(vertexBuffers);
  26055. bufferState.unBind();
  26056. Resource._addMemory(memorySize,memorySize);
  26057. }
  26058. /**
  26059. *@private
  26060. */
  26061. __proto._resetData=function(){
  26062. var count=this._endIndex-this._activeIndex;
  26063. if (count==this._segementCount){
  26064. this._vertexBuffer1.destroy();
  26065. this._vertexBuffer2.destroy();
  26066. this._segementCount+=this._increaseSegementCount;
  26067. this._resizeData(this._segementCount,this._bufferState);
  26068. }
  26069. this._vertexBuffer1.setData(this._vertices1,0,this._floatCountPerVertices1 *2 *this._activeIndex,this._floatCountPerVertices1 *2 *count);
  26070. this._vertexBuffer2.setData(this._vertices2,0,this._floatCountPerVertices2 *2 *this._activeIndex,this._floatCountPerVertices2 *2 *count);
  26071. var offset=this._activeIndex *4;
  26072. var rightSubDistance=new Float32Array(this._subDistance.buffer,offset,count);
  26073. var rightSubBirthTime=new Float32Array(this._subBirthTime.buffer,offset,count);
  26074. this._subDistance.set(rightSubDistance,0);
  26075. this._subBirthTime.set(rightSubBirthTime,0);
  26076. this._endIndex=count;
  26077. this._activeIndex=0;
  26078. }
  26079. /**
  26080. *@private
  26081. *更新Trail数据
  26082. */
  26083. __proto._updateTrail=function(camera,lastPosition,position){
  26084. if (!Vector3.equals(lastPosition,position)){
  26085. if ((this._endIndex-this._activeIndex)===0)
  26086. this._addTrailByFirstPosition(camera,position);
  26087. else
  26088. this._addTrailByNextPosition(camera,position);
  26089. }
  26090. }
  26091. /**
  26092. *@private
  26093. *通过起始位置添加TrailRenderElement起始数据
  26094. */
  26095. __proto._addTrailByFirstPosition=function(camera,position){
  26096. (this._endIndex===this._segementCount)&& (this._resetData());
  26097. this._subDistance[this._endIndex]=0;
  26098. this._subBirthTime[this._endIndex]=this._owner._curtime;
  26099. this._endIndex++;
  26100. position.cloneTo(this._lastFixedVertexPosition);
  26101. this._needAddFirstVertex=true;
  26102. }
  26103. /**
  26104. *@private
  26105. *通过位置更新TrailRenderElement数据
  26106. */
  26107. __proto._addTrailByNextPosition=function(camera,position){
  26108. var delVector3=TrailGeometry._tempVector30;
  26109. var pointAtoBVector3=TrailGeometry._tempVector31;
  26110. Vector3.subtract(position,this._lastFixedVertexPosition,delVector3);
  26111. var forward=TrailGeometry._tempVector32;
  26112. switch (this._owner.alignment){
  26113. case /*laya.d3.core.trail.TrailFilter.ALIGNMENT_VIEW*/0:
  26114. camera.transform.getForward(forward);
  26115. Vector3.cross(delVector3,forward,pointAtoBVector3);
  26116. break ;
  26117. case /*laya.d3.core.trail.TrailFilter.ALIGNMENT_TRANSFORM_Z*/1:
  26118. this._owner._owner.transform.getForward(forward);
  26119. Vector3.cross(delVector3,forward,pointAtoBVector3);
  26120. break ;
  26121. }
  26122. Vector3.normalize(pointAtoBVector3,pointAtoBVector3);
  26123. Vector3.scale(pointAtoBVector3,this._owner.widthMultiplier / 2,pointAtoBVector3);
  26124. var delLength=Vector3.scalarLength(delVector3);
  26125. var tempEndIndex=0;
  26126. var offset=NaN;
  26127. if (this._needAddFirstVertex){
  26128. this._updateVerticesByPositionData(position,pointAtoBVector3,this._endIndex-1);
  26129. this._needAddFirstVertex=false;
  26130. }
  26131. if (delLength-this._owner.minVertexDistance >=MathUtils3D.zeroTolerance){
  26132. if (this._isTempEndVertex){
  26133. tempEndIndex=this._endIndex-1;
  26134. offset=delLength-this._subDistance[tempEndIndex];
  26135. this._updateVerticesByPosition(position,pointAtoBVector3,delLength,tempEndIndex);
  26136. this._owner._totalLength+=offset;
  26137. }else {
  26138. (this._endIndex===this._segementCount)&& (this._resetData());
  26139. this._updateVerticesByPosition(position,pointAtoBVector3,delLength,this._endIndex);
  26140. this._owner._totalLength+=delLength;
  26141. this._endIndex++;
  26142. }
  26143. position.cloneTo(this._lastFixedVertexPosition);
  26144. this._isTempEndVertex=false;
  26145. }else {
  26146. if (this._isTempEndVertex){
  26147. tempEndIndex=this._endIndex-1;
  26148. offset=delLength-this._subDistance[tempEndIndex];
  26149. this._updateVerticesByPosition(position,pointAtoBVector3,delLength,tempEndIndex);
  26150. this._owner._totalLength+=offset;
  26151. }else {
  26152. (this._endIndex===this._segementCount)&& (this._resetData());
  26153. this._updateVerticesByPosition(position,pointAtoBVector3,delLength,this._endIndex);
  26154. this._owner._totalLength+=delLength;
  26155. this._endIndex++;
  26156. }
  26157. this._isTempEndVertex=true;
  26158. }
  26159. }
  26160. /**
  26161. *@private
  26162. *通过位置更新顶点数据
  26163. */
  26164. __proto._updateVerticesByPositionData=function(position,pointAtoBVector3,index){
  26165. var vertexOffset=this._floatCountPerVertices1 *2 *index;
  26166. var curtime=this._owner._curtime;
  26167. this._vertices1[vertexOffset]=position.x;
  26168. this._vertices1[vertexOffset+1]=position.y;
  26169. this._vertices1[vertexOffset+2]=position.z;
  26170. this._vertices1[vertexOffset+3]=-pointAtoBVector3.x;
  26171. this._vertices1[vertexOffset+4]=-pointAtoBVector3.y;
  26172. this._vertices1[vertexOffset+5]=-pointAtoBVector3.z;
  26173. this._vertices1[vertexOffset+6]=curtime;
  26174. this._vertices1[vertexOffset+7]=1.0;
  26175. this._vertices1[vertexOffset+8]=position.x;
  26176. this._vertices1[vertexOffset+9]=position.y;
  26177. this._vertices1[vertexOffset+10]=position.z;
  26178. this._vertices1[vertexOffset+11]=pointAtoBVector3.x;
  26179. this._vertices1[vertexOffset+12]=pointAtoBVector3.y;
  26180. this._vertices1[vertexOffset+13]=pointAtoBVector3.z;
  26181. this._vertices1[vertexOffset+14]=curtime;
  26182. this._vertices1[vertexOffset+15]=0.0;
  26183. var floatCount=this._floatCountPerVertices1 *2;
  26184. this._vertexBuffer1.setData(this._vertices1,vertexOffset,vertexOffset,floatCount);
  26185. }
  26186. /**
  26187. *@private
  26188. *通过位置更新顶点数据、距离、出生时间
  26189. */
  26190. __proto._updateVerticesByPosition=function(position,pointAtoBVector3,delDistance,index){
  26191. this._updateVerticesByPositionData(position,pointAtoBVector3,index);
  26192. this._subDistance[index]=delDistance;
  26193. this._subBirthTime[index]=this._owner._curtime;
  26194. }
  26195. /**
  26196. *@private
  26197. *更新VertexBuffer2数据
  26198. */
  26199. __proto._updateVertexBufferUV=function(){
  26200. var vertexCount=this._endIndex;
  26201. var curLength=0;
  26202. for (var i=this._activeIndex,j=vertexCount;i < j;i++){
  26203. (i!==this._activeIndex)&& (curLength+=this._subDistance[i]);
  26204. var uvX=NaN;
  26205. if (this._owner.textureMode==/*laya.d3.core.TextureMode.Stretch*/0)
  26206. uvX=1.0-curLength / this._owner._totalLength;
  26207. else
  26208. uvX=1.0-(this._owner._totalLength-curLength);
  26209. this._vertices2[i *2]=uvX;
  26210. this._vertices2[i *2+1]=uvX;
  26211. };
  26212. var offset=this._activeIndex *2;
  26213. this._vertexBuffer2.setData(this._vertices2,offset,offset,vertexCount *2-offset);
  26214. }
  26215. /**
  26216. *@private
  26217. */
  26218. __proto._updateDisappear=function(){
  26219. var count=this._endIndex;
  26220. for (var i=this._activeIndex;i < count;i++){
  26221. if (this._owner._curtime-this._subBirthTime[i] >=this._owner.time+MathUtils3D.zeroTolerance){
  26222. var nextIndex=i+1;
  26223. if (nextIndex!==count)
  26224. this._owner._totalLength-=this._subDistance[nextIndex];
  26225. if (this._isTempEndVertex && (nextIndex===count-1)){
  26226. var offset=this._floatCountPerVertices1 *i *2;
  26227. var fixedPos=this._lastFixedVertexPosition;
  26228. fixedPos.x=this._vertices1[0];
  26229. fixedPos.y=this._vertices1[1];
  26230. fixedPos.z=this._vertices1[2];
  26231. this._isTempEndVertex=false;
  26232. }
  26233. this._activeIndex++;
  26234. }else {
  26235. break ;
  26236. }
  26237. }
  26238. }
  26239. /**
  26240. *@inheritDoc
  26241. */
  26242. __proto._getType=function(){
  26243. return TrailGeometry._type;
  26244. }
  26245. /**
  26246. *@inheritDoc
  26247. */
  26248. __proto._prepareRender=function(state){
  26249. return this._endIndex-this._activeIndex > 1;
  26250. }
  26251. /**
  26252. *@inheritDoc
  26253. */
  26254. __proto._render=function(state){
  26255. this._bufferState.bind();
  26256. var start=this._activeIndex *2;
  26257. var count=this._endIndex *2-start;
  26258. LayaGL.instance.drawArrays(/*laya.webgl.WebGLContext.TRIANGLE_STRIP*/0x0005,start,count);
  26259. Stat.renderBatches++;
  26260. Stat.trianglesFaces+=count-2;
  26261. }
  26262. /**
  26263. *@inheritDoc
  26264. */
  26265. __proto.destroy=function(){
  26266. _super.prototype.destroy.call(this);
  26267. var memorySize=this._vertexBuffer1._byteLength+this._vertexBuffer2._byteLength;
  26268. Resource._addMemory(-memorySize,-memorySize);
  26269. this._bufferState.destroy();
  26270. this._vertexBuffer1.destroy();
  26271. this._vertexBuffer2.destroy();
  26272. this._bufferState=null;
  26273. this._vertices1=null;
  26274. this._vertexBuffer1=null;
  26275. this._vertices2=null;
  26276. this._vertexBuffer2=null;
  26277. this._subBirthTime=null;
  26278. this._subDistance=null;
  26279. this._lastFixedVertexPosition=null;
  26280. }
  26281. __static(TrailGeometry,
  26282. ['_tempVector30',function(){return this._tempVector30=new Vector3();},'_tempVector31',function(){return this._tempVector31=new Vector3();},'_tempVector32',function(){return this._tempVector32=new Vector3();},'_type',function(){return this._type=GeometryElement._typeCounter++;}
  26283. ]);
  26284. return TrailGeometry;
  26285. })(GeometryElement)
  26286. /**
  26287. *<code>CompoundColliderShape</code> 类用于创建盒子形状碰撞器。
  26288. */
  26289. //class laya.d3.physics.shape.CompoundColliderShape extends laya.d3.physics.shape.ColliderShape
  26290. var CompoundColliderShape=(function(_super){
  26291. function CompoundColliderShape(){
  26292. CompoundColliderShape.__super.call(this);
  26293. this._childColliderShapes=[];
  26294. this._type=/*laya.d3.physics.shape.ColliderShape.SHAPETYPES_COMPOUND*/5;
  26295. this._nativeShape=new Laya3D._physics3D.btCompoundShape();
  26296. }
  26297. __class(CompoundColliderShape,'laya.d3.physics.shape.CompoundColliderShape',_super);
  26298. var __proto=CompoundColliderShape.prototype;
  26299. /**
  26300. *@private
  26301. */
  26302. __proto._clearChildShape=function(shape){
  26303. shape._attatched=false;
  26304. shape._compoundParent=null;
  26305. shape._indexInCompound=-1;
  26306. }
  26307. /**
  26308. *@inheritDoc
  26309. */
  26310. __proto._addReference=function(){}
  26311. /**
  26312. *@inheritDoc
  26313. */
  26314. __proto._removeReference=function(){}
  26315. /**
  26316. *@private
  26317. */
  26318. __proto._updateChildTransform=function(shape){
  26319. var offset=shape.localOffset;
  26320. var rotation=shape.localRotation;
  26321. var nativeOffset=ColliderShape._nativeVector30;
  26322. var nativeQuaternion=ColliderShape._nativQuaternion0;
  26323. var nativeTransform=ColliderShape._nativeTransform0;
  26324. nativeOffset.setValue(-offset.x,offset.y,offset.z);
  26325. nativeQuaternion.setValue(-rotation.x,rotation.y,rotation.z,-rotation.w);
  26326. nativeTransform.setOrigin(nativeOffset);
  26327. nativeTransform.setRotation(nativeQuaternion);
  26328. this._nativeShape.updateChildTransform(shape._indexInCompound,nativeTransform,true);
  26329. }
  26330. /**
  26331. *添加子碰撞器形状。
  26332. *@param shape 子碰撞器形状。
  26333. */
  26334. __proto.addChildShape=function(shape){
  26335. if (shape._attatched)
  26336. throw "CompoundColliderShape: this shape has attatched to other entity.";
  26337. shape._attatched=true;
  26338. shape._compoundParent=this;
  26339. shape._indexInCompound=this._childColliderShapes.length;
  26340. this._childColliderShapes.push(shape);
  26341. var offset=shape.localOffset;
  26342. var rotation=shape.localRotation;
  26343. CompoundColliderShape._nativeOffset.setValue(-offset.x,offset.y,offset.z);
  26344. CompoundColliderShape._nativRotation.setValue(-rotation.x,rotation.y,rotation.z,-rotation.w);
  26345. CompoundColliderShape._nativeTransform.setOrigin(CompoundColliderShape._nativeOffset);
  26346. CompoundColliderShape._nativeTransform.setRotation(CompoundColliderShape._nativRotation);
  26347. var nativeScale=this._nativeShape.getLocalScaling();
  26348. this._nativeShape.setLocalScaling(CompoundColliderShape._nativeVector3One);
  26349. this._nativeShape.addChildShape(CompoundColliderShape._nativeTransform,shape._nativeShape);
  26350. this._nativeShape.setLocalScaling(nativeScale);
  26351. (this._attatchedCollisionObject)&& (this._attatchedCollisionObject.colliderShape=this);
  26352. }
  26353. /**
  26354. *移除子碰撞器形状。
  26355. *@param shape 子碰撞器形状。
  26356. */
  26357. __proto.removeChildShape=function(shape){
  26358. if (shape._compoundParent===this){
  26359. var index=shape._indexInCompound;
  26360. this._clearChildShape(shape);
  26361. var endShape=this._childColliderShapes[this._childColliderShapes.length-1];
  26362. endShape._indexInCompound=index;
  26363. this._childColliderShapes[index]=endShape;
  26364. this._childColliderShapes.pop();
  26365. this._nativeShape.removeChildShapeByIndex(index);
  26366. }
  26367. }
  26368. /**
  26369. *清空子碰撞器形状。
  26370. */
  26371. __proto.clearChildShape=function(){
  26372. for (var i=0,n=this._childColliderShapes.length;i < n;i++){
  26373. this._clearChildShape(this._childColliderShapes[i]);
  26374. this._nativeShape.removeChildShapeByIndex(0);
  26375. }
  26376. this._childColliderShapes.length=0;
  26377. }
  26378. /**
  26379. *获取子形状数量。
  26380. *@return
  26381. */
  26382. __proto.getChildShapeCount=function(){
  26383. return this._childColliderShapes.length;
  26384. }
  26385. /**
  26386. *@inheritDoc
  26387. */
  26388. __proto.cloneTo=function(destObject){
  26389. var destCompoundColliderShape=destObject;
  26390. destCompoundColliderShape.clearChildShape();
  26391. for (var i=0,n=this._childColliderShapes.length;i < n;i++)
  26392. destCompoundColliderShape.addChildShape(this._childColliderShapes[i].clone());
  26393. }
  26394. /**
  26395. *@inheritDoc
  26396. */
  26397. __proto.clone=function(){
  26398. var dest=new CompoundColliderShape();
  26399. this.cloneTo(dest);
  26400. return dest;
  26401. }
  26402. /**
  26403. *@inheritDoc
  26404. */
  26405. __proto.destroy=function(){
  26406. _super.prototype.destroy.call(this);
  26407. for (var i=0,n=this._childColliderShapes.length;i < n;i++){
  26408. var childShape=this._childColliderShapes[i];
  26409. if (childShape._referenceCount===0)
  26410. childShape.destroy();
  26411. }
  26412. }
  26413. __static(CompoundColliderShape,
  26414. ['_nativeVector3One',function(){return this._nativeVector3One=new Laya3D._physics3D.btVector3(1,1,1);},'_nativeTransform',function(){return this._nativeTransform=new Laya3D._physics3D.btTransform();},'_nativeOffset',function(){return this._nativeOffset=new Laya3D._physics3D.btVector3(0,0,0);},'_nativRotation',function(){return this._nativRotation=new Laya3D._physics3D.btQuaternion(0,0,0,1);}
  26415. ]);
  26416. return CompoundColliderShape;
  26417. })(ColliderShape)
  26418. /**
  26419. *<code>PixelLineFilter</code> 类用于线过滤器。
  26420. */
  26421. //class laya.d3.core.pixelLine.PixelLineFilter extends laya.d3.core.GeometryElement
  26422. var PixelLineFilter=(function(_super){
  26423. function PixelLineFilter(owner,maxLineCount){
  26424. /**@private */
  26425. this._floatCountPerVertices=7;
  26426. /**@private */
  26427. this._owner=null;
  26428. /**@private */
  26429. this._vertexBuffer=null;
  26430. /**@private */
  26431. this._vertices=null;
  26432. /**@private */
  26433. this._maxLineCount=0;
  26434. /**@private */
  26435. this._lineCount=0;
  26436. PixelLineFilter.__super.call(this);
  26437. this._minUpdate=Number.MAX_VALUE;
  26438. this._maxUpdate=Number.MIN_VALUE;
  26439. this._bufferState=new BufferState();
  26440. var pointCount=maxLineCount *2;
  26441. this._owner=owner;
  26442. this._maxLineCount=maxLineCount;
  26443. this._vertices=new Float32Array(pointCount *this._floatCountPerVertices);
  26444. this._vertexBuffer=new VertexBuffer3D(PixelLineVertex.vertexDeclaration.vertexStride *pointCount,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,false);
  26445. this._vertexBuffer.vertexDeclaration=PixelLineVertex.vertexDeclaration;
  26446. this._bufferState.bind();
  26447. this._bufferState.applyVertexBuffer(this._vertexBuffer);
  26448. this._bufferState.unBind();
  26449. }
  26450. __class(PixelLineFilter,'laya.d3.core.pixelLine.PixelLineFilter',_super);
  26451. var __proto=PixelLineFilter.prototype;
  26452. /**
  26453. *@inheritDoc
  26454. */
  26455. __proto._getType=function(){
  26456. return PixelLineFilter._type;
  26457. }
  26458. /**
  26459. *@private
  26460. */
  26461. __proto._resizeLineData=function(maxCount){
  26462. var pointCount=maxCount *2;
  26463. var lastVertices=this._vertices;
  26464. this._vertexBuffer.destroy();
  26465. this._maxLineCount=maxCount;
  26466. var vertexCount=pointCount *this._floatCountPerVertices;
  26467. this._vertices=new Float32Array(vertexCount);
  26468. this._vertexBuffer=new VertexBuffer3D(PixelLineVertex.vertexDeclaration.vertexStride *pointCount,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,false);
  26469. this._vertexBuffer.vertexDeclaration=PixelLineVertex.vertexDeclaration;
  26470. if (vertexCount < lastVertices.length){
  26471. this._vertices.set(new Float32Array(lastVertices.buffer,0,vertexCount));
  26472. this._vertexBuffer.setData(this._vertices,0,0,vertexCount);
  26473. }else {
  26474. this._vertices.set(lastVertices);
  26475. this._vertexBuffer.setData(this._vertices,0,0,lastVertices.length);
  26476. }
  26477. this._bufferState.bind();
  26478. this._bufferState.applyVertexBuffer(this._vertexBuffer);
  26479. this._bufferState.unBind();
  26480. }
  26481. /**
  26482. *@private
  26483. */
  26484. __proto._updateLineVertices=function(offset,startPosition,endPosition,startColor,endColor){
  26485. if (startPosition){
  26486. this._vertices[offset+0]=startPosition.x;
  26487. this._vertices[offset+1]=startPosition.y;
  26488. this._vertices[offset+2]=startPosition.z;
  26489. }
  26490. if (startColor){
  26491. this._vertices[offset+3]=startColor.r;
  26492. this._vertices[offset+4]=startColor.g;
  26493. this._vertices[offset+5]=startColor.b;
  26494. this._vertices[offset+6]=startColor.a;
  26495. }
  26496. if (endPosition){
  26497. this._vertices[offset+7]=endPosition.x;
  26498. this._vertices[offset+8]=endPosition.y;
  26499. this._vertices[offset+9]=endPosition.z;
  26500. }
  26501. if (endColor){
  26502. this._vertices[offset+10]=endColor.r;
  26503. this._vertices[offset+11]=endColor.g;
  26504. this._vertices[offset+12]=endColor.b;
  26505. this._vertices[offset+13]=endColor.a;
  26506. }
  26507. this._minUpdate=Math.min(this._minUpdate,offset);
  26508. this._maxUpdate=Math.max(this._maxUpdate,offset+this._floatCountPerVertices *2);
  26509. }
  26510. /**
  26511. *@private
  26512. */
  26513. __proto._removeLineData=function(index){
  26514. var floatCount=this._floatCountPerVertices *2;
  26515. var nextIndex=index+1;
  26516. var offset=index *floatCount;
  26517. var nextOffset=nextIndex *floatCount;
  26518. var rightPartVertices=new Float32Array(this._vertices.buffer,nextIndex *floatCount *4,(this._lineCount-nextIndex)*floatCount);
  26519. this._vertices.set(rightPartVertices,offset);
  26520. this._minUpdate=offset;
  26521. this._maxUpdate=offset+this._floatCountPerVertices *2;
  26522. this._lineCount--;
  26523. }
  26524. /**
  26525. *@private
  26526. */
  26527. __proto._updateLineData=function(index,startPosition,endPosition,startColor,endColor){
  26528. var floatCount=this._floatCountPerVertices *2;
  26529. var offset=index *floatCount;
  26530. this._updateLineVertices(offset,startPosition,endPosition,startColor,endColor);
  26531. }
  26532. /**
  26533. *@private
  26534. */
  26535. __proto._updateLineDatas=function(index,data){
  26536. var floatCount=this._floatCountPerVertices *2;
  26537. var offset=index *floatCount;
  26538. var count=data.length;
  26539. for (var i=0;i < count;i++){
  26540. var line=data[i];
  26541. this._updateLineVertices((index+i)*floatCount,line.startPosition,line.endPosition,line.startColor,line.endColor);
  26542. }
  26543. }
  26544. /**
  26545. *获取线段数据
  26546. *@return 线段数据。
  26547. */
  26548. __proto._getLineData=function(index,out){
  26549. var startPosition=out.startPosition;
  26550. var startColor=out.startColor;
  26551. var endPosition=out.endPosition;
  26552. var endColor=out.endColor;
  26553. var vertices=this._vertices;
  26554. var offset=index *this._floatCountPerVertices *2;
  26555. startPosition.x=vertices[offset+0];
  26556. startPosition.y=vertices[offset+1];
  26557. startPosition.z=vertices[offset+2];
  26558. startColor.r=vertices[offset+3];
  26559. startColor.g=vertices[offset+4];
  26560. startColor.b=vertices[offset+5];
  26561. startColor.a=vertices[offset+6];
  26562. endPosition.x=vertices[offset+7];
  26563. endPosition.y=vertices[offset+8];
  26564. endPosition.z=vertices[offset+9];
  26565. endColor.r=vertices[offset+10];
  26566. endColor.g=vertices[offset+11];
  26567. endColor.b=vertices[offset+12];
  26568. endColor.a=vertices[offset+13];
  26569. }
  26570. /**
  26571. *@inheritDoc
  26572. */
  26573. __proto._prepareRender=function(state){
  26574. return true;
  26575. }
  26576. /**
  26577. *@inheritDoc
  26578. */
  26579. __proto._render=function(state){
  26580. if (this._minUpdate!==Number.MAX_VALUE && this._maxUpdate!==Number.MIN_VALUE){
  26581. this._vertexBuffer.setData(this._vertices,this._minUpdate,this._minUpdate,this._maxUpdate-this._minUpdate);
  26582. this._minUpdate=Number.MAX_VALUE;
  26583. this._maxUpdate=Number.MIN_VALUE;
  26584. }
  26585. if (this._lineCount > 0){
  26586. this._bufferState.bind();
  26587. LayaGL.instance.drawArrays(/*laya.webgl.WebGLContext.LINES*/0x0001,0,this._lineCount *2);
  26588. Stat.renderBatches++;
  26589. }
  26590. }
  26591. /**
  26592. *@inheritDoc
  26593. */
  26594. __proto.destroy=function(){
  26595. if (this._destroyed)
  26596. return;
  26597. _super.prototype.destroy.call(this);
  26598. this._bufferState.destroy();
  26599. this._vertexBuffer.destroy();
  26600. this._bufferState=null;
  26601. this._vertexBuffer=null;
  26602. this._vertices=null;
  26603. }
  26604. __static(PixelLineFilter,
  26605. ['_type',function(){return this._type=GeometryElement._typeCounter++;}
  26606. ]);
  26607. return PixelLineFilter;
  26608. })(GeometryElement)
  26609. /**
  26610. *<code>CylinderColliderShape</code> 类用于创建圆柱碰撞器。
  26611. */
  26612. //class laya.d3.physics.shape.CylinderColliderShape extends laya.d3.physics.shape.ColliderShape
  26613. var CylinderColliderShape=(function(_super){
  26614. function CylinderColliderShape(radius,height,orientation){
  26615. /**@private */
  26616. //this._orientation=0;
  26617. /**@private */
  26618. this._radius=1;
  26619. /**@private */
  26620. this._height=0.5;
  26621. CylinderColliderShape.__super.call(this);
  26622. (radius===void 0)&& (radius=0.5);
  26623. (height===void 0)&& (height=1.0);
  26624. (orientation===void 0)&& (orientation=/*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPY*/1);
  26625. this._radius=radius;
  26626. this._height=height;
  26627. this._orientation=orientation;
  26628. this._type=/*laya.d3.physics.shape.ColliderShape.SHAPETYPES_CYLINDER*/2;
  26629. switch (orientation){
  26630. case /*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPX*/0:
  26631. CylinderColliderShape._nativeSize.setValue(height / 2,radius,radius);
  26632. this._nativeShape=new Laya3D._physics3D.btCylinderShapeX(CylinderColliderShape._nativeSize);
  26633. break ;
  26634. case /*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPY*/1:
  26635. CylinderColliderShape._nativeSize.setValue(radius,height / 2,radius);
  26636. this._nativeShape=new Laya3D._physics3D.btCylinderShape(CylinderColliderShape._nativeSize);
  26637. break ;
  26638. case /*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPZ*/2:
  26639. CylinderColliderShape._nativeSize.setValue(radius,radius,height / 2);
  26640. this._nativeShape=new Laya3D._physics3D.btCylinderShapeZ(CylinderColliderShape._nativeSize);
  26641. break ;
  26642. default :
  26643. throw "CapsuleColliderShape:unknown orientation.";
  26644. }
  26645. }
  26646. __class(CylinderColliderShape,'laya.d3.physics.shape.CylinderColliderShape',_super);
  26647. var __proto=CylinderColliderShape.prototype;
  26648. /**
  26649. *@inheritDoc
  26650. */
  26651. __proto.clone=function(){
  26652. var dest=new CylinderColliderShape(this._radius,this._height,this._orientation);
  26653. this.cloneTo(dest);
  26654. return dest;
  26655. }
  26656. /**
  26657. *获取半径。
  26658. */
  26659. __getset(0,__proto,'radius',function(){
  26660. return this._radius;
  26661. });
  26662. /**
  26663. *获取高度。
  26664. */
  26665. __getset(0,__proto,'height',function(){
  26666. return this._height;
  26667. });
  26668. /**
  26669. *获取方向。
  26670. */
  26671. __getset(0,__proto,'orientation',function(){
  26672. return this._orientation;
  26673. });
  26674. __static(CylinderColliderShape,
  26675. ['_nativeSize',function(){return this._nativeSize=new Laya3D._physics3D.btVector3(0,0,0);}
  26676. ]);
  26677. return CylinderColliderShape;
  26678. })(ColliderShape)
  26679. /**
  26680. *<code>FloatKeyFrame</code> 类用于创建浮点关键帧实例。
  26681. */
  26682. //class laya.d3.core.FloatKeyframe extends laya.d3.core.Keyframe
  26683. var FloatKeyframe=(function(_super){
  26684. function FloatKeyframe(){
  26685. //this.inTangent=NaN;
  26686. //this.outTangent=NaN;
  26687. //this.value=NaN;
  26688. FloatKeyframe.__super.call(this);
  26689. }
  26690. __class(FloatKeyframe,'laya.d3.core.FloatKeyframe',_super);
  26691. var __proto=FloatKeyframe.prototype;
  26692. /**
  26693. *@inheritDoc
  26694. */
  26695. __proto.cloneTo=function(destObject){
  26696. _super.prototype.cloneTo.call(this,destObject);
  26697. var destKeyFrame=destObject;
  26698. destKeyFrame.inTangent=this.inTangent;
  26699. destKeyFrame.outTangent=this.outTangent;
  26700. destKeyFrame.value=this.value;
  26701. }
  26702. return FloatKeyframe;
  26703. })(Keyframe)
  26704. /**
  26705. *@private
  26706. */
  26707. //class laya.d3.graphics.SubMeshInstanceBatch extends laya.d3.core.GeometryElement
  26708. var SubMeshInstanceBatch=(function(_super){
  26709. function SubMeshInstanceBatch(){
  26710. /**@private */
  26711. this.maxInstanceCount=1024;
  26712. SubMeshInstanceBatch.__super.call(this);
  26713. this.instanceWorldMatrixData=new Float32Array(this.maxInstanceCount *16);
  26714. this.instanceMVPMatrixData=new Float32Array(this.maxInstanceCount *16);
  26715. this.instanceWorldMatrixBuffer=new VertexBuffer3D(this.instanceWorldMatrixData.length *4,/*laya.webgl.WebGLContext.DYNAMIC_DRAW*/0x88E8);
  26716. this.instanceMVPMatrixBuffer=new VertexBuffer3D(this.instanceMVPMatrixData.length *4,/*laya.webgl.WebGLContext.DYNAMIC_DRAW*/0x88E8);
  26717. this.instanceWorldMatrixBuffer.vertexDeclaration=VertexMesh.instanceWorldMatrixDeclaration;
  26718. this.instanceMVPMatrixBuffer.vertexDeclaration=VertexMesh.instanceMVPMatrixDeclaration;
  26719. }
  26720. __class(SubMeshInstanceBatch,'laya.d3.graphics.SubMeshInstanceBatch',_super);
  26721. var __proto=SubMeshInstanceBatch.prototype;
  26722. /**
  26723. *@inheritDoc
  26724. */
  26725. __proto._render=function(state){
  26726. var element=state.renderElement;
  26727. var subMesh=element.instanceSubMesh;
  26728. var count=element.instanceBatchElementList.length;
  26729. var indexCount=subMesh._indexCount;
  26730. subMesh._mesh._instanceBufferState.bind();
  26731. WebGLContext._angleInstancedArrays.drawElementsInstancedANGLE(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,indexCount,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,subMesh._indexStart *2,count);
  26732. Stat.renderBatches++;
  26733. Stat.savedRenderBatches+=count-1;
  26734. Stat.trianglesFaces+=indexCount *count / 3;
  26735. }
  26736. __static(SubMeshInstanceBatch,
  26737. ['instance',function(){return this.instance=new SubMeshInstanceBatch();}
  26738. ]);
  26739. return SubMeshInstanceBatch;
  26740. })(GeometryElement)
  26741. /**
  26742. *<code>OctreeMotionList</code> 类用于实现物理更新队列。
  26743. */
  26744. //class laya.d3.core.scene.OctreeMotionList extends laya.d3.component.SingletonList
  26745. var OctreeMotionList=(function(_super){
  26746. /**
  26747. *创建一个新的 <code>OctreeMotionList</code> 实例。
  26748. */
  26749. function OctreeMotionList(){
  26750. OctreeMotionList.__super.call(this);
  26751. }
  26752. __class(OctreeMotionList,'laya.d3.core.scene.OctreeMotionList',_super);
  26753. var __proto=OctreeMotionList.prototype;
  26754. /**
  26755. *@private
  26756. */
  26757. __proto.add=function(element){
  26758. var index=element._getIndexInMotionList();
  26759. if (index!==-1)
  26760. throw "OctreeMotionList:element has in PhysicsUpdateList.";
  26761. this._add(element);
  26762. element._setIndexInMotionList(this.length++);
  26763. }
  26764. /**
  26765. *@private
  26766. */
  26767. __proto.remove=function(element){
  26768. var index=element._getIndexInMotionList();
  26769. this.length--;
  26770. if (index!==this.length){
  26771. var end=this.elements[this.length];
  26772. this.elements[index]=end;
  26773. end._inPhysicUpdateListIndex=index;
  26774. }
  26775. element._setIndexInMotionList(-1);
  26776. }
  26777. return OctreeMotionList;
  26778. })(SingletonList)
  26779. /**
  26780. *@private
  26781. *<code>SetRenderTargetCMD</code> 类用于创建设置渲染目标指令。
  26782. */
  26783. //class laya.d3.core.render.command.SetRenderTargetCMD extends laya.d3.core.render.command.Command
  26784. var SetRenderTargetCMD=(function(_super){
  26785. function SetRenderTargetCMD(){
  26786. /**@private */
  26787. this._renderTexture=null;
  26788. SetRenderTargetCMD.__super.call(this);
  26789. }
  26790. __class(SetRenderTargetCMD,'laya.d3.core.render.command.SetRenderTargetCMD',_super);
  26791. var __proto=SetRenderTargetCMD.prototype;
  26792. /**
  26793. *@inheritDoc
  26794. */
  26795. __proto.run=function(){
  26796. this._renderTexture._start();
  26797. }
  26798. /**
  26799. *@inheritDoc
  26800. */
  26801. __proto.recover=function(){
  26802. SetRenderTargetCMD._pool.push(this);
  26803. this._renderTexture=null;
  26804. }
  26805. SetRenderTargetCMD.create=function(renderTexture){
  26806. var cmd;
  26807. cmd=SetRenderTargetCMD._pool.length > 0 ? SetRenderTargetCMD._pool.pop():new SetRenderTargetCMD();
  26808. cmd._renderTexture=renderTexture;
  26809. return cmd;
  26810. }
  26811. SetRenderTargetCMD._pool=[];
  26812. return SetRenderTargetCMD;
  26813. })(Command)
  26814. /**
  26815. *@private
  26816. *<code>MeshSprite3DStaticBatchManager</code> 类用于网格精灵静态批处理管理。
  26817. */
  26818. //class laya.d3.graphics.MeshRenderStaticBatchManager extends laya.d3.graphics.StaticBatchManager
  26819. var MeshRenderStaticBatchManager=(function(_super){
  26820. function MeshRenderStaticBatchManager(){
  26821. /**@private [只读]*/
  26822. //this._updateCountMark=0;
  26823. this._opaqueBatchMarks=[];
  26824. MeshRenderStaticBatchManager.__super.call(this);
  26825. this._updateCountMark=0;
  26826. }
  26827. __class(MeshRenderStaticBatchManager,'laya.d3.graphics.MeshRenderStaticBatchManager',_super);
  26828. var __proto=MeshRenderStaticBatchManager.prototype;
  26829. /**
  26830. *@inheritDoc
  26831. */
  26832. __proto._compare=function(left,right){
  26833. var lRender=left._render,rRender=right._render;
  26834. var leftGeo=(left).meshFilter.sharedMesh,rightGeo=(right).meshFilter.sharedMesh;
  26835. var lightOffset=lRender.lightmapIndex-rRender.lightmapIndex;
  26836. if (lightOffset===0){
  26837. var receiveShadowOffset=(lRender.receiveShadow ? 1 :0)-(rRender.receiveShadow ? 1 :0);
  26838. if (receiveShadowOffset===0){
  26839. var materialOffset=lRender.sharedMaterial.id-rRender.sharedMaterial.id;
  26840. if (materialOffset===0){
  26841. var verDec=leftGeo._vertexBuffers[0].vertexDeclaration.id-rightGeo._vertexBuffers[0].vertexDeclaration.id;
  26842. if (verDec===0){
  26843. return rightGeo._indexBuffer.indexCount-leftGeo._indexBuffer.indexCount;
  26844. }else {
  26845. return verDec;
  26846. }
  26847. }else {
  26848. return materialOffset;
  26849. }
  26850. }else {
  26851. return receiveShadowOffset;
  26852. }
  26853. }else {
  26854. return lightOffset;
  26855. }
  26856. }
  26857. /**
  26858. *@inheritDoc
  26859. */
  26860. __proto._getBatchRenderElementFromPool=function(){
  26861. var renderElement=this._batchRenderElementPool[this._batchRenderElementPoolIndex++];
  26862. if (!renderElement){
  26863. renderElement=new SubMeshRenderElement();
  26864. this._batchRenderElementPool[this._batchRenderElementPoolIndex-1]=renderElement;
  26865. renderElement.staticBatchElementList=[];
  26866. }
  26867. return renderElement;
  26868. }
  26869. /**
  26870. *@private
  26871. */
  26872. __proto._getStaticBatch=function(rootOwner,number){
  26873. var key=rootOwner ? rootOwner.id :0;
  26874. var batchOwner=this._staticBatches[key];
  26875. (batchOwner)|| (batchOwner=this._staticBatches[key]=[]);
  26876. return (batchOwner[number])|| (batchOwner[number]=new SubMeshStaticBatch(rootOwner,number,MeshRenderStaticBatchManager._verDec));
  26877. }
  26878. /**
  26879. *@inheritDoc
  26880. */
  26881. __proto._initStaticBatchs=function(rootOwner){
  26882. this._quickSort(this._initBatchSprites,0,this._initBatchSprites.length-1);
  26883. var lastCanMerage=false;
  26884. var curStaticBatch;
  26885. var batchNumber=0;
  26886. for (var i=0,n=this._initBatchSprites.length;i < n;i++){
  26887. var sprite=this._initBatchSprites[i];
  26888. if (lastCanMerage){
  26889. if (curStaticBatch.addTest(sprite)){
  26890. curStaticBatch.add(sprite);
  26891. }else {
  26892. lastCanMerage=false;
  26893. batchNumber++;
  26894. }
  26895. }else {
  26896. var lastIndex=n-1;
  26897. if (i!==lastIndex){
  26898. curStaticBatch=this._getStaticBatch(rootOwner,batchNumber);
  26899. curStaticBatch.add(sprite);
  26900. lastCanMerage=true;
  26901. }
  26902. }
  26903. }
  26904. for (var key in this._staticBatches){
  26905. var batches=this._staticBatches[key];
  26906. for (i=0,n=batches.length;i < n;i++)
  26907. batches[i].finishInit();
  26908. }
  26909. this._initBatchSprites.length=0;
  26910. }
  26911. /**
  26912. *@private
  26913. */
  26914. __proto._destroyRenderSprite=function(sprite){
  26915. var staticBatch=sprite._render._staticBatch;
  26916. staticBatch.remove(sprite);
  26917. if (staticBatch._batchElements.length===0){
  26918. var owner=staticBatch.batchOwner;
  26919. var ownerID=owner ? owner.id :0;
  26920. var batches=this._staticBatches[ownerID];
  26921. batches[staticBatch.number]=null;
  26922. staticBatch.dispose();
  26923. var empty=true;
  26924. for (var i=0;i < batches.length;i++){
  26925. if (batches[i])
  26926. empty=false;
  26927. }
  26928. if (empty){
  26929. delete this._staticBatches[ownerID];
  26930. }
  26931. }
  26932. }
  26933. /**
  26934. *@inheritDoc
  26935. */
  26936. __proto._clear=function(){
  26937. _super.prototype._clear.call(this);
  26938. this._updateCountMark++;
  26939. }
  26940. /**
  26941. *@inheritDoc
  26942. */
  26943. __proto._garbageCollection=function(){
  26944. for (var key in this._staticBatches){
  26945. var batches=this._staticBatches[key];
  26946. for (var i=0,n=batches.length;i < n;i++){
  26947. var staticBatch=batches[i];
  26948. if (staticBatch._batchElements.length===0){
  26949. staticBatch.dispose();
  26950. batches.splice(i,1);
  26951. i--,n--;
  26952. if (n===0)
  26953. delete this._staticBatches[key];
  26954. }
  26955. }
  26956. }
  26957. }
  26958. /**
  26959. *@private
  26960. */
  26961. __proto.getBatchOpaquaMark=function(lightMapIndex,receiveShadow,materialID,staticBatchID){
  26962. var staLightMapMarks=(this._opaqueBatchMarks[lightMapIndex])|| (this._opaqueBatchMarks[lightMapIndex]=[]);
  26963. var staReceiveShadowMarks=(staLightMapMarks[receiveShadow])|| (staLightMapMarks[receiveShadow]=[]);
  26964. var staMaterialMarks=(staReceiveShadowMarks[materialID])|| (staReceiveShadowMarks[materialID]=[]);
  26965. return (staMaterialMarks[staticBatchID])|| (staMaterialMarks[staticBatchID]=new BatchMark);
  26966. }
  26967. __static(MeshRenderStaticBatchManager,
  26968. ['_verDec',function(){return this._verDec=VertexMesh.getVertexDeclaration("POSITION,NORMAL,COLOR,UV,UV1,TANGENT");},'instance',function(){return this.instance=new MeshRenderStaticBatchManager();}
  26969. ]);
  26970. return MeshRenderStaticBatchManager;
  26971. })(StaticBatchManager)
  26972. /**
  26973. *@private
  26974. *<code>SubMeshDynamicBatch</code> 类用于网格动态合并。
  26975. */
  26976. //class laya.d3.graphics.SubMeshDynamicBatch extends laya.d3.core.GeometryElement
  26977. var SubMeshDynamicBatch=(function(_super){
  26978. function SubMeshDynamicBatch(){
  26979. /**@private */
  26980. this._vertices=null;
  26981. /**@private */
  26982. this._indices=null;
  26983. /**@private */
  26984. this._positionOffset=0;
  26985. /**@private */
  26986. this._normalOffset=0;
  26987. /**@private */
  26988. this._colorOffset=0;
  26989. /**@private */
  26990. this._uv0Offset=0;
  26991. /**@private */
  26992. this._uv1Offset=0;
  26993. /**@private */
  26994. this._sTangentOffset=0;
  26995. /**@private */
  26996. this._vertexBuffer=null;
  26997. /**@private */
  26998. this._indexBuffer=null;
  26999. SubMeshDynamicBatch.__super.call(this);
  27000. this._bufferState=new BufferState();
  27001. var maxVerDec=VertexMesh.getVertexDeclaration("POSITION,NORMAL,COLOR,UV,UV1,TANGENT");
  27002. var maxByteCount=maxVerDec.vertexStride *32000;
  27003. this._vertices=new Float32Array(maxByteCount / 4);
  27004. this._vertexBuffer=new VertexBuffer3D(maxByteCount,/*laya.webgl.WebGLContext.DYNAMIC_DRAW*/0x88E8);
  27005. this._indices=new Int16Array(/*CLASS CONST:laya.d3.graphics.SubMeshDynamicBatch.maxIndicesCount*/32000);
  27006. this._indexBuffer=new IndexBuffer3D(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",this._indices.length,/*laya.webgl.WebGLContext.DYNAMIC_DRAW*/0x88E8);
  27007. var memorySize=this._vertexBuffer._byteLength+this._indexBuffer._byteLength;
  27008. Resource._addMemory(memorySize,memorySize);
  27009. }
  27010. __class(SubMeshDynamicBatch,'laya.d3.graphics.SubMeshDynamicBatch',_super);
  27011. var __proto=SubMeshDynamicBatch.prototype;
  27012. /**
  27013. *@private
  27014. */
  27015. __proto._getBatchVertices=function(vertexDeclaration,batchVertices,batchOffset,transform,element,subMesh){
  27016. var vertexFloatCount=vertexDeclaration.vertexStride / 4;
  27017. var oriVertexes=subMesh._vertexBuffer.getData();
  27018. var lightmapScaleOffset=element.render.lightmapScaleOffset;
  27019. var multiSubMesh=element._dynamicMultiSubMesh;
  27020. var vertexCount=element._dynamicVertexCount;
  27021. element._computeWorldPositionsAndNormals(this._positionOffset,this._normalOffset,multiSubMesh,vertexCount);
  27022. var worldPositions=element._dynamicWorldPositions;
  27023. var worldNormals=element._dynamicWorldNormals;
  27024. var indices=subMesh._indices;
  27025. for (var i=0;i < vertexCount;i++){
  27026. var index=multiSubMesh ? indices[i] :i;
  27027. var oriOffset=index *vertexFloatCount;
  27028. var bakeOffset=(i+batchOffset)*vertexFloatCount;
  27029. var oriOff=i *3;
  27030. var bakOff=bakeOffset+this._positionOffset;
  27031. batchVertices[bakOff]=worldPositions[oriOff];
  27032. batchVertices[bakOff+1]=worldPositions[oriOff+1];
  27033. batchVertices[bakOff+2]=worldPositions[oriOff+2];
  27034. if (this._normalOffset!==-1){
  27035. bakOff=bakeOffset+this._normalOffset;
  27036. batchVertices[bakOff]=worldNormals[oriOff];
  27037. batchVertices[bakOff+1]=worldNormals[oriOff+1];
  27038. batchVertices[bakOff+2]=worldNormals[oriOff+2];
  27039. }
  27040. if (this._colorOffset!==-1){
  27041. bakOff=bakeOffset+this._colorOffset;
  27042. oriOff=oriOffset+this._colorOffset;
  27043. batchVertices[bakOff]=oriVertexes[oriOff];
  27044. batchVertices[bakOff+1]=oriVertexes[oriOff+1];
  27045. batchVertices[bakOff+2]=oriVertexes[oriOff+2];
  27046. batchVertices[bakOff+3]=oriVertexes[oriOff+3];
  27047. }
  27048. if (this._uv0Offset!==-1){
  27049. bakOff=bakeOffset+this._uv0Offset;
  27050. oriOff=oriOffset+this._uv0Offset;
  27051. batchVertices[bakOff]=oriVertexes[oriOff];
  27052. batchVertices[bakOff+1]=oriVertexes[oriOff+1];
  27053. }
  27054. if (this._sTangentOffset!==-1){
  27055. bakOff=bakeOffset+this._sTangentOffset;
  27056. oriOff=oriOffset+this._sTangentOffset;
  27057. batchVertices[bakOff]=oriVertexes[oriOff];
  27058. batchVertices[bakOff+1]=oriVertexes[oriOff+1];
  27059. batchVertices[bakOff+2]=oriVertexes[oriOff+2];
  27060. batchVertices[bakOff+3]=oriVertexes[oriOff+3];
  27061. bakOff=bakeOffset+this._sTangentOffset;
  27062. oriOff=oriOffset+this._sTangentOffset;
  27063. batchVertices[bakOff]=oriVertexes[oriOff];
  27064. batchVertices[bakOff+1]=oriVertexes[oriOff+1];
  27065. batchVertices[bakOff+2]=oriVertexes[oriOff+2];
  27066. batchVertices[bakOff+3]=oriVertexes[oriOff+3];
  27067. }
  27068. }
  27069. }
  27070. /**
  27071. *@private
  27072. */
  27073. __proto._getBatchIndices=function(batchIndices,batchIndexCount,batchVertexCount,transform,subMesh,multiSubMesh){
  27074. var subIndices=subMesh._indices;
  27075. var k=0,m=0,batchOffset=0;
  27076. var isInvert=transform._isFrontFaceInvert;
  27077. if (multiSubMesh){
  27078. if (isInvert){
  27079. for (k=0,m=subIndices.length;k < m;k+=3){
  27080. batchOffset=batchIndexCount+k;
  27081. var index=batchVertexCount+k;
  27082. batchIndices[batchOffset]=index;
  27083. batchIndices[batchOffset+1]=index+2;
  27084. batchIndices[batchOffset+2]=index+1;
  27085. }
  27086. }else {
  27087. for (k=m,m=subIndices.length;k < m;k+=3){
  27088. batchOffset=batchIndexCount+k;
  27089. index=batchVertexCount+k;
  27090. batchIndices[batchOffset]=index;
  27091. batchIndices[batchOffset+1]=index+1;
  27092. batchIndices[batchOffset+2]=index+2;
  27093. }
  27094. }
  27095. }else {
  27096. if (isInvert){
  27097. for (k=0,m=subIndices.length;k < m;k+=3){
  27098. batchOffset=batchIndexCount+k;
  27099. batchIndices[batchOffset]=batchVertexCount+subIndices[k];
  27100. batchIndices[batchOffset+1]=batchVertexCount+subIndices[k+2];
  27101. batchIndices[batchOffset+2]=batchVertexCount+subIndices[k+1];
  27102. }
  27103. }else {
  27104. for (k=m,m=subIndices.length;k < m;k+=3){
  27105. batchOffset=batchIndexCount+k;
  27106. batchIndices[batchOffset]=batchVertexCount+subIndices[k];
  27107. batchIndices[batchOffset+1]=batchVertexCount+subIndices[k+1];
  27108. batchIndices[batchOffset+2]=batchVertexCount+subIndices[k+2];
  27109. }
  27110. }
  27111. }
  27112. }
  27113. /**
  27114. *@private
  27115. */
  27116. __proto._flush=function(vertexCount,indexCount){
  27117. this._vertexBuffer.setData(this._vertices,0,0,vertexCount *(this._vertexBuffer.vertexDeclaration.vertexStride / 4));
  27118. this._indexBuffer.setData(this._indices,0,0,indexCount);
  27119. LayaGL.instance.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,indexCount,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,0);
  27120. }
  27121. /**
  27122. *@inheritDoc
  27123. */
  27124. __proto._prepareRender=function(state){
  27125. var element=state.renderElement;
  27126. var vertexDeclaration=element.vertexBatchVertexDeclaration;
  27127. this._bufferState=MeshRenderDynamicBatchManager.instance._getBufferState(vertexDeclaration);
  27128. this._positionOffset=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0).offset / 4;
  27129. var normalElement=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_NORMAL0*/3);
  27130. this._normalOffset=normalElement ? normalElement.offset / 4 :-1;
  27131. var colorElement=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_COLOR0*/1);
  27132. this._colorOffset=colorElement ? colorElement.offset / 4 :-1;
  27133. var uv0Element=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE0*/2);
  27134. this._uv0Offset=uv0Element ? uv0Element.offset / 4 :-1;
  27135. var uv1Element=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE1*/7);
  27136. this._uv1Offset=uv1Element ? uv1Element.offset / 4 :-1;
  27137. var tangentElement=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_TANGENT0*/4);
  27138. this._sTangentOffset=tangentElement ? tangentElement.offset / 4 :-1;
  27139. return true;
  27140. }
  27141. /**
  27142. *@inheritDoc
  27143. */
  27144. __proto._render=function(context){
  27145. this._bufferState.bind();
  27146. var element=context.renderElement;
  27147. var vertexDeclaration=element.vertexBatchVertexDeclaration;
  27148. var batchElements=element.vertexBatchElementList;
  27149. var batchVertexCount=0;
  27150. var batchIndexCount=0;
  27151. var floatStride=vertexDeclaration.vertexStride / 4;
  27152. var renderBatchCount=0;
  27153. var elementCount=batchElements.length;
  27154. for (var i=0;i < elementCount;i++){
  27155. var subElement=batchElements [i];
  27156. var subMesh=subElement._geometry;
  27157. var indexCount=subMesh._indexCount;
  27158. if (batchIndexCount+indexCount > /*CLASS CONST:laya.d3.graphics.SubMeshDynamicBatch.maxIndicesCount*/32000){
  27159. this._flush(batchVertexCount,batchIndexCount);
  27160. renderBatchCount++;
  27161. Stat.trianglesFaces+=batchIndexCount / 3;
  27162. batchVertexCount=batchIndexCount=0;
  27163. };
  27164. var transform=subElement._transform;
  27165. this._getBatchVertices(vertexDeclaration,this._vertices,batchVertexCount,transform,subElement,subMesh);
  27166. this._getBatchIndices(this._indices,batchIndexCount,batchVertexCount,transform,subMesh,subElement._dynamicMultiSubMesh);
  27167. batchVertexCount+=subElement._dynamicVertexCount;
  27168. batchIndexCount+=indexCount;
  27169. }
  27170. this._flush(batchVertexCount,batchIndexCount);
  27171. renderBatchCount++;
  27172. Stat.renderBatches+=renderBatchCount;
  27173. Stat.savedRenderBatches+=elementCount-renderBatchCount;
  27174. Stat.trianglesFaces+=batchIndexCount / 3;
  27175. }
  27176. SubMeshDynamicBatch.maxAllowVertexCount=10;
  27177. SubMeshDynamicBatch.maxAllowAttribueCount=900;
  27178. SubMeshDynamicBatch.maxIndicesCount=32000;
  27179. SubMeshDynamicBatch.instance=null;
  27180. return SubMeshDynamicBatch;
  27181. })(GeometryElement)
  27182. /**
  27183. *<code>SkyBox</code> 类用于创建天空盒。
  27184. */
  27185. //class laya.d3.resource.models.SkyBox extends laya.d3.resource.models.SkyMesh
  27186. var SkyBox=(function(_super){
  27187. /**
  27188. *创建一个 <code>SkyBox</code> 实例。
  27189. */
  27190. function SkyBox(){
  27191. SkyBox.__super.call(this);
  27192. var halfHeight=0.5;
  27193. var halfWidth=0.5;
  27194. var halfDepth=0.5;
  27195. var vertices=new Float32Array([-halfDepth,halfHeight,-halfWidth,halfDepth,halfHeight,-halfWidth,halfDepth,halfHeight,halfWidth,-halfDepth,halfHeight,halfWidth,
  27196. -halfDepth,-halfHeight,-halfWidth,halfDepth,-halfHeight,-halfWidth,halfDepth,-halfHeight,halfWidth,-halfDepth,-halfHeight,halfWidth]);
  27197. var indices=new Uint8Array([0,1,2,2,3,0,
  27198. 4,7,6,6,5,4,
  27199. 0,3,7,7,4,0,
  27200. 1,5,6,6,2,1,
  27201. 3,2,6,6,7,3,
  27202. 0,4,5,5,1,0]);
  27203. var verDec=VertexMesh.getVertexDeclaration("POSITION");
  27204. this._vertexBuffer=new VertexBuffer3D(verDec.vertexStride *8,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,false);
  27205. this._vertexBuffer.vertexDeclaration=verDec;
  27206. this._indexBuffer=new IndexBuffer3D(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_UBYTE*/"ubyte",36,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,false);
  27207. this._vertexBuffer.setData(vertices);
  27208. this._indexBuffer.setData(indices);
  27209. var bufferState=new BufferState();
  27210. bufferState.bind();
  27211. bufferState.applyVertexBuffer(this._vertexBuffer);
  27212. bufferState.applyIndexBuffer(this._indexBuffer);
  27213. bufferState.unBind();
  27214. this._bufferState=bufferState;
  27215. }
  27216. __class(SkyBox,'laya.d3.resource.models.SkyBox',_super);
  27217. var __proto=SkyBox.prototype;
  27218. /**
  27219. *@inheritDoc
  27220. */
  27221. __proto._render=function(state){
  27222. LayaGL.instance.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,36,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,0);
  27223. Stat.trianglesFaces+=12;
  27224. Stat.renderBatches++;
  27225. }
  27226. SkyBox.__init__=function(){
  27227. SkyBox.instance=new SkyBox();
  27228. }
  27229. SkyBox.instance=null;
  27230. return SkyBox;
  27231. })(SkyMesh)
  27232. /**
  27233. *<code>MeshColliderShape</code> 类用于创建网格碰撞器。
  27234. */
  27235. //class laya.d3.physics.shape.MeshColliderShape extends laya.d3.physics.shape.ColliderShape
  27236. var MeshColliderShape=(function(_super){
  27237. function MeshColliderShape(){
  27238. /**@private */
  27239. this._mesh=null;
  27240. /**@private */
  27241. this._convex=false;
  27242. MeshColliderShape.__super.call(this);
  27243. }
  27244. __class(MeshColliderShape,'laya.d3.physics.shape.MeshColliderShape',_super);
  27245. var __proto=MeshColliderShape.prototype;
  27246. /**
  27247. *@inheritDoc
  27248. */
  27249. __proto._setScale=function(value){
  27250. if (this._compoundParent){
  27251. this.updateLocalTransformations();
  27252. }else {
  27253. ColliderShape._nativeScale.setValue(value.x,value.y,value.z);
  27254. this._nativeShape.setLocalScaling(ColliderShape._nativeScale);
  27255. this._nativeShape.updateBound();
  27256. }
  27257. }
  27258. /**
  27259. *@inheritDoc
  27260. */
  27261. __proto.cloneTo=function(destObject){
  27262. var destMeshCollider=destObject;
  27263. destMeshCollider.convex=this._convex;
  27264. destMeshCollider.mesh=this._mesh;
  27265. _super.prototype.cloneTo.call(this,destObject);
  27266. }
  27267. /**
  27268. *@inheritDoc
  27269. */
  27270. __proto.clone=function(){
  27271. var dest=new MeshColliderShape();
  27272. this.cloneTo(dest);
  27273. return dest;
  27274. }
  27275. /**
  27276. *@inheritDoc
  27277. */
  27278. __proto.destroy=function(){
  27279. if (this._nativeShape){
  27280. var physics3D=Laya3D._physics3D;
  27281. physics3D.destroy(this._nativeShape);
  27282. this._nativeShape=null;
  27283. }
  27284. }
  27285. /**
  27286. *设置网格。
  27287. *@param 网格。
  27288. */
  27289. /**
  27290. *获取网格。
  27291. *@return 网格。
  27292. */
  27293. __getset(0,__proto,'mesh',function(){
  27294. return this._mesh;
  27295. },function(value){
  27296. if (this._mesh!==value){
  27297. var physics3D=Laya3D._physics3D;
  27298. if (this._mesh){
  27299. physics3D.destroy(this._nativeShape);
  27300. }
  27301. if (value){
  27302. this._nativeShape=new physics3D.btGImpactMeshShape(value._getPhysicMesh());
  27303. this._nativeShape.updateBound();
  27304. }
  27305. this._mesh=value;
  27306. }
  27307. });
  27308. /**
  27309. *设置是否使用凸多边形。
  27310. *@param value 是否使用凸多边形。
  27311. */
  27312. /**
  27313. *获取是否使用凸多边形。
  27314. *@return 是否使用凸多边形。
  27315. */
  27316. __getset(0,__proto,'convex',function(){
  27317. return this._convex;
  27318. },function(value){
  27319. this._convex=value;
  27320. });
  27321. return MeshColliderShape;
  27322. })(ColliderShape)
  27323. /**
  27324. *<code>HemisphereShape</code> 类用于创建半球形粒子形状。
  27325. */
  27326. //class laya.d3.core.particleShuriKen.module.shape.HemisphereShape extends laya.d3.core.particleShuriKen.module.shape.BaseShape
  27327. var HemisphereShape=(function(_super){
  27328. function HemisphereShape(){
  27329. /**发射器半径。*/
  27330. this.radius=NaN;
  27331. /**从外壳发射。*/
  27332. this.emitFromShell=false;
  27333. HemisphereShape.__super.call(this);
  27334. this.radius=1.0;
  27335. this.emitFromShell=false;
  27336. this.randomDirection=false;
  27337. }
  27338. __class(HemisphereShape,'laya.d3.core.particleShuriKen.module.shape.HemisphereShape',_super);
  27339. var __proto=HemisphereShape.prototype;
  27340. /**
  27341. *@inheritDoc
  27342. */
  27343. __proto._getShapeBoundBox=function(boundBox){
  27344. var min=boundBox.min;
  27345. min.x=min.y=min.z=-this.radius;
  27346. var max=boundBox.max;
  27347. max.x=max.y=this.radius;
  27348. max.z=0;
  27349. }
  27350. /**
  27351. *@inheritDoc
  27352. */
  27353. __proto._getSpeedBoundBox=function(boundBox){
  27354. var min=boundBox.min;
  27355. min.x=min.y=-1;
  27356. min.z=0;
  27357. var max=boundBox.max;
  27358. max.x=max.y=max.z=1;
  27359. }
  27360. /**
  27361. *用于生成粒子初始位置和方向。
  27362. *@param position 粒子位置。
  27363. *@param direction 粒子方向。
  27364. */
  27365. __proto.generatePositionAndDirection=function(position,direction,rand,randomSeeds){
  27366. if (rand){
  27367. rand.seed=randomSeeds[16];
  27368. if (this.emitFromShell)
  27369. ShapeUtils._randomPointUnitSphere(position,rand);
  27370. else
  27371. ShapeUtils._randomPointInsideUnitSphere(position,rand);
  27372. randomSeeds[16]=rand.seed;
  27373. }else {
  27374. if (this.emitFromShell)
  27375. ShapeUtils._randomPointUnitSphere(position);
  27376. else
  27377. ShapeUtils._randomPointInsideUnitSphere(position);
  27378. }
  27379. Vector3.scale(position,this.radius,position);
  27380. var z=position.z;
  27381. (z < 0.0)&& (position.z=z *-1.0);
  27382. if (this.randomDirection){
  27383. if (rand){
  27384. rand.seed=randomSeeds[17];
  27385. ShapeUtils._randomPointUnitSphere(direction,rand);
  27386. randomSeeds[17]=rand.seed;
  27387. }else {
  27388. ShapeUtils._randomPointUnitSphere(direction);
  27389. }
  27390. }else {
  27391. position.cloneTo(direction);
  27392. }
  27393. }
  27394. __proto.cloneTo=function(destObject){
  27395. _super.prototype.cloneTo.call(this,destObject);
  27396. var destShape=destObject;
  27397. destShape.radius=this.radius;
  27398. destShape.emitFromShell=this.emitFromShell;
  27399. destShape.randomDirection=this.randomDirection;
  27400. }
  27401. return HemisphereShape;
  27402. })(BaseShape)
  27403. /**
  27404. *<code>TerrainFilter</code> 类用于创建TerrainFilter过滤器。
  27405. */
  27406. //class laya.d3.terrain.TerrainFilter extends laya.d3.core.GeometryElement
  27407. var TerrainFilter=(function(_super){
  27408. function TerrainFilter(owner,chunkOffsetX,chunkOffsetZ,gridSize,terrainHeightData,heightDataWidth,heightDataHeight,cameraCoordinateInverse){
  27409. this._owner=null;
  27410. this._gridSize=NaN;
  27411. this.memorySize=0;
  27412. this._numberVertices=0;
  27413. this._maxNumberIndices=0;
  27414. this._currentNumberIndices=0;
  27415. this._numberTriangle=0;
  27416. this._vertexBuffer=null;
  27417. this._indexBuffer=null;
  27418. this._indexArrayBuffer=null;
  27419. this._boundingBoxCorners=null;
  27420. this._leafs=null;
  27421. this._leafNum=0;
  27422. this._terrainHeightData=null;
  27423. this._terrainHeightDataWidth=0;
  27424. this._terrainHeightDataHeight=0;
  27425. this._chunkOffsetX=0;
  27426. this._chunkOffsetZ=0;
  27427. this._cameraCoordinateInverse=false;
  27428. this._cameraPos=null;
  27429. this._currentLOD=0;
  27430. //LOD级别 4个叶子节点 第1个叶子的level<<24+第2个叶子的level<<16+第3个叶子的level<<8+第4个叶子的level
  27431. this._perspectiveFactor=NaN;
  27432. this._LODTolerance=0;
  27433. /**@private */
  27434. this._boundingSphere=null;
  27435. /**@private */
  27436. this._boundingBox=null;
  27437. TerrainFilter.__super.call(this);
  27438. this._bufferState=new BufferState();
  27439. this._owner=owner;
  27440. this._cameraPos=new Vector3();
  27441. this._chunkOffsetX=chunkOffsetX;
  27442. this._chunkOffsetZ=chunkOffsetZ;
  27443. this._gridSize=gridSize;
  27444. this._terrainHeightData=terrainHeightData;
  27445. this._terrainHeightDataWidth=heightDataWidth;
  27446. this._terrainHeightDataHeight=heightDataHeight;
  27447. this._leafNum=(TerrainLeaf.CHUNK_GRID_NUM / TerrainLeaf.LEAF_GRID_NUM)*(TerrainLeaf.CHUNK_GRID_NUM / TerrainLeaf.LEAF_GRID_NUM);
  27448. this._leafs=__newvec(this._leafNum);
  27449. this._cameraCoordinateInverse=cameraCoordinateInverse;
  27450. for (var i=0;i < this._leafNum;i++){
  27451. this._leafs[i]=new TerrainLeaf();
  27452. }
  27453. this.recreateResource();
  27454. }
  27455. __class(TerrainFilter,'laya.d3.terrain.TerrainFilter',_super);
  27456. var __proto=TerrainFilter.prototype;
  27457. __proto.recreateResource=function(){
  27458. this._currentNumberIndices=0;
  27459. this._numberTriangle=0;
  27460. var nLeafVertexCount=TerrainLeaf.LEAF_VERTEXT_COUNT;
  27461. var nLeafIndexCount=TerrainLeaf.LEAF_MAX_INDEX_COUNT;
  27462. this._numberVertices=nLeafVertexCount *this._leafNum;
  27463. this._maxNumberIndices=nLeafIndexCount *this._leafNum;
  27464. this._indexArrayBuffer=new Uint16Array(this._maxNumberIndices);
  27465. var vertexDeclaration=VertexPositionTerrain.vertexDeclaration;
  27466. var vertexFloatStride=vertexDeclaration.vertexStride / 4;
  27467. var vertices=new Float32Array(this._numberVertices *vertexFloatStride);
  27468. var nNum=TerrainLeaf.CHUNK_GRID_NUM / TerrainLeaf.LEAF_GRID_NUM;
  27469. var i=0,x=0,z=0;
  27470. for (i=0;i < this._leafNum;i++){
  27471. x=i % nNum;
  27472. z=Math.floor(i / nNum);
  27473. this._leafs[i].calcVertextBuffer(this._chunkOffsetX,this._chunkOffsetZ,x *TerrainLeaf.LEAF_GRID_NUM,z *TerrainLeaf.LEAF_GRID_NUM,this._gridSize,vertices,i *TerrainLeaf.LEAF_PLANE_VERTEXT_COUNT,vertexFloatStride,this._terrainHeightData,this._terrainHeightDataWidth,this._terrainHeightDataHeight,this._cameraCoordinateInverse);
  27474. }
  27475. for (i=0;i < this._leafNum;i++){
  27476. x=i % nNum;
  27477. z=Math.floor(i / nNum);
  27478. this._leafs[i].calcSkirtVertextBuffer(this._chunkOffsetX,this._chunkOffsetZ,x *TerrainLeaf.LEAF_GRID_NUM,z *TerrainLeaf.LEAF_GRID_NUM,this._gridSize,vertices,this._leafNum *TerrainLeaf.LEAF_PLANE_VERTEXT_COUNT+i *TerrainLeaf.LEAF_SKIRT_VERTEXT_COUNT,vertexFloatStride,this._terrainHeightData,this._terrainHeightDataWidth,this._terrainHeightDataHeight);
  27479. }
  27480. this.assembleIndexInit();
  27481. this._vertexBuffer=new VertexBuffer3D(vertexDeclaration.vertexStride *this._numberVertices,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,false);
  27482. this._vertexBuffer.vertexDeclaration=vertexDeclaration;
  27483. this._indexBuffer=new IndexBuffer3D(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",this._maxNumberIndices,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,false);
  27484. this._vertexBuffer.setData(vertices);
  27485. this._indexBuffer.setData(this._indexArrayBuffer);
  27486. this.memorySize=(this._vertexBuffer._byteLength+this._indexBuffer._byteLength)*2;
  27487. this.calcOriginalBoudingBoxAndSphere();
  27488. this._bufferState.bind();
  27489. this._bufferState.applyVertexBuffer(this._vertexBuffer);
  27490. this._bufferState.applyIndexBuffer(this._indexBuffer);
  27491. this._bufferState.unBind();
  27492. }
  27493. __proto.setLODLevel=function(leafsLODLevel){
  27494. if (leafsLODLevel.length !=4)return true;
  27495. var nLOD=((leafsLODLevel[0]+1)<< 24)+((leafsLODLevel[1]+1)<< 16)+((leafsLODLevel[2]+1)<< 8)+(leafsLODLevel[3]+1);
  27496. if (this._currentLOD==nLOD){
  27497. return false;
  27498. }
  27499. this._currentLOD=nLOD;
  27500. return true;
  27501. }
  27502. __proto.assembleIndexInit=function(){
  27503. this._currentNumberIndices=0;
  27504. this._numberTriangle=0;
  27505. var nOffsetIndex=0;
  27506. for (var i=0;i < this._leafNum;i++){
  27507. var planeLODIndex=TerrainLeaf.getPlaneLODIndex(i,0);
  27508. this._indexArrayBuffer.set(planeLODIndex,nOffsetIndex);
  27509. nOffsetIndex+=planeLODIndex.length;
  27510. var skirtLODIndex=TerrainLeaf.getSkirtLODIndex(i,0);
  27511. this._indexArrayBuffer.set(skirtLODIndex,nOffsetIndex);
  27512. nOffsetIndex+=skirtLODIndex.length;
  27513. this._currentNumberIndices+=(planeLODIndex.length+skirtLODIndex.length);
  27514. }
  27515. this._numberTriangle=this._currentNumberIndices / 3;
  27516. }
  27517. __proto.isNeedAssemble=function(camera,cameraPostion){
  27518. var perspectiveFactor=Math.min(camera.viewport.width,camera.viewport.height)/ (2 *Math.tan(Math.PI *camera.fieldOfView / 180.0));
  27519. if (this._perspectiveFactor !=perspectiveFactor){
  27520. this._perspectiveFactor=perspectiveFactor;
  27521. return 1;
  27522. }
  27523. if (this._LODTolerance !=Terrain.LOD_TOLERANCE_VALUE){
  27524. this._LODTolerance=Terrain.LOD_TOLERANCE_VALUE;
  27525. return 1;
  27526. }
  27527. if (Vector3.equals(cameraPostion,this._cameraPos)==false){
  27528. this._cameraPos.x=cameraPostion.x;
  27529. this._cameraPos.y=cameraPostion.y;
  27530. this._cameraPos.z=cameraPostion.z;
  27531. return 2;
  27532. }
  27533. return 0;
  27534. }
  27535. __proto.assembleIndex=function(camera,cameraPostion){
  27536. var nNeedType=this.isNeedAssemble(camera,cameraPostion);
  27537. if (nNeedType > 0){
  27538. for (var i=0;i < this._leafNum;i++){
  27539. TerrainFilter._TEMP_ARRAY_BUFFER[i]=this._leafs[i].determineLod(cameraPostion,this._perspectiveFactor,Terrain.LOD_TOLERANCE_VALUE,nNeedType==1);
  27540. }
  27541. if (this.setLODLevel(TerrainFilter._TEMP_ARRAY_BUFFER)){
  27542. this._currentNumberIndices=0;
  27543. this._numberTriangle=0;
  27544. var nOffsetIndex=0;
  27545. for (i=0;i < this._leafNum;i++){
  27546. var nLODLevel=TerrainFilter._TEMP_ARRAY_BUFFER[i];
  27547. var planeLODIndex=TerrainLeaf.getPlaneLODIndex(i,nLODLevel);
  27548. this._indexArrayBuffer.set(planeLODIndex,nOffsetIndex);
  27549. nOffsetIndex+=planeLODIndex.length;
  27550. var skirtLODIndex=TerrainLeaf.getSkirtLODIndex(i,nLODLevel);
  27551. this._indexArrayBuffer.set(skirtLODIndex,nOffsetIndex);
  27552. nOffsetIndex+=skirtLODIndex.length;
  27553. this._currentNumberIndices+=(planeLODIndex.length+skirtLODIndex.length);
  27554. }
  27555. this._numberTriangle=this._currentNumberIndices / 3;
  27556. return true;
  27557. }
  27558. }
  27559. return false;
  27560. }
  27561. __proto.calcOriginalBoudingBoxAndSphere=function(){
  27562. var sizeOfY=new Vector2(2147483647,-2147483647);
  27563. for (var i=0;i < this._leafNum;i++){
  27564. sizeOfY.x=this._leafs[i]._sizeOfY.x < sizeOfY.x ? this._leafs[i]._sizeOfY.x :sizeOfY.x;
  27565. sizeOfY.y=this._leafs[i]._sizeOfY.y > sizeOfY.y ? this._leafs[i]._sizeOfY.y :sizeOfY.y;
  27566. };
  27567. var min=new Vector3(this._chunkOffsetX *TerrainLeaf.CHUNK_GRID_NUM *this._gridSize,sizeOfY.x,this._chunkOffsetZ *TerrainLeaf.CHUNK_GRID_NUM *this._gridSize);
  27568. var max=new Vector3((this._chunkOffsetX+1)*TerrainLeaf.CHUNK_GRID_NUM *this._gridSize,sizeOfY.y,(this._chunkOffsetZ+1)*TerrainLeaf.CHUNK_GRID_NUM *this._gridSize);
  27569. if (TerrainLeaf.__ADAPT_MATRIX__){
  27570. Vector3.transformV3ToV3(min,TerrainLeaf.__ADAPT_MATRIX__,min);
  27571. Vector3.transformV3ToV3(max,TerrainLeaf.__ADAPT_MATRIX__,max);
  27572. }
  27573. this._boundingBox=new BoundBox(min,max);
  27574. var size=new Vector3();
  27575. Vector3.subtract(max,min,size);
  27576. Vector3.scale(size,0.5,size);
  27577. var center=new Vector3();
  27578. Vector3.add(min,size,center);
  27579. this._boundingSphere=new BoundSphere(center,Vector3.scalarLength(size));
  27580. this._boundingBoxCorners=__newvec(8,null);
  27581. this._boundingBox.getCorners(this._boundingBoxCorners);
  27582. }
  27583. __proto.calcLeafBoudingBox=function(worldMatrix){
  27584. for (var i=0;i < this._leafNum;i++){
  27585. this._leafs[i].calcLeafBoudingBox(worldMatrix);
  27586. }
  27587. }
  27588. __proto.calcLeafBoudingSphere=function(worldMatrix,maxScale){
  27589. for (var i=0;i < this._leafNum;i++){
  27590. this._leafs[i].calcLeafBoudingSphere(worldMatrix,maxScale);
  27591. }
  27592. }
  27593. __proto._getVertexBuffer=function(index){
  27594. (index===void 0)&& (index=0);
  27595. if (index==0){
  27596. return this._vertexBuffer;
  27597. }
  27598. return null;
  27599. }
  27600. __proto._getIndexBuffer=function(){
  27601. return this._indexBuffer;
  27602. }
  27603. /**
  27604. *@inheritDoc
  27605. */
  27606. __proto._getType=function(){
  27607. return TerrainFilter._type;
  27608. }
  27609. /**
  27610. *@inheritDoc
  27611. */
  27612. __proto._prepareRender=function(state){
  27613. return true;
  27614. }
  27615. /**
  27616. *@inheritDoc
  27617. */
  27618. __proto._render=function(state){
  27619. this._bufferState.bind();
  27620. LayaGL.instance.drawElements(Terrain.RENDER_LINE_MODEL ? /*laya.webgl.WebGLContext.LINES*/0x0001 :/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,this._currentNumberIndices,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,0);
  27621. Stat.trianglesFaces+=this._numberTriangle;
  27622. Stat.renderBatches++;
  27623. }
  27624. /**
  27625. *@inheritDoc
  27626. */
  27627. __proto.destroy=function(){
  27628. this._owner=null;
  27629. this._bufferState.destroy();
  27630. if (this._vertexBuffer)this._vertexBuffer.destroy();
  27631. if (this._indexBuffer)this._indexBuffer.destroy();
  27632. }
  27633. __static(TerrainFilter,
  27634. ['_TEMP_ARRAY_BUFFER',function(){return this._TEMP_ARRAY_BUFFER=new Uint32Array(TerrainLeaf.CHUNK_GRID_NUM / TerrainLeaf.LEAF_GRID_NUM *TerrainLeaf.CHUNK_GRID_NUM / TerrainLeaf.LEAF_GRID_NUM);},'_type',function(){return this._type=GeometryElement._typeCounter++;}
  27635. ]);
  27636. return TerrainFilter;
  27637. })(GeometryElement)
  27638. /**
  27639. *<code>BloomEffect</code> 类用于创建泛光效果。
  27640. */
  27641. //class laya.d3.core.render.BloomEffect extends laya.d3.core.render.PostProcessEffect
  27642. var BloomEffect=(function(_super){
  27643. function BloomEffect(){
  27644. /**@private */
  27645. this._shader=null;
  27646. /**@private */
  27647. this._pyramid=null;
  27648. /**@private */
  27649. this._intensity=0.0;
  27650. /**@private */
  27651. this._threshold=1.0;
  27652. /**@private */
  27653. this._softKnee=0.5;
  27654. /**@private */
  27655. this._diffusion=7.0;
  27656. /**@private */
  27657. this._anamorphicRatio=0.0;
  27658. /**@private */
  27659. this._dirtIntensity=0.0;
  27660. /**限制泛光像素的数量,该值在伽马空间。*/
  27661. this.clamp=65472.0;
  27662. /**是否开启快速模式。该模式通过降低质量来提升性能。*/
  27663. this.fastMode=false;
  27664. /**镜头污渍纹路,用于为泛光特效增加污渍灰尘效果*/
  27665. this.dirtTexture=null;
  27666. BloomEffect.__super.call(this);
  27667. this._shaderData=new ShaderData();
  27668. this._linearColor=new Color();
  27669. this._shaderThreshold=new Vector4();
  27670. this._shaderParams=new Vector4();
  27671. this._shaderSetting=new Vector4();
  27672. this._dirtTileOffset=new Vector4();
  27673. this.color=new Color(1.0,1.0,1.0,1.0);
  27674. this._shader=Shader3D.find("PostProcessBloom");
  27675. this._pyramid=new Array(16 *2);
  27676. }
  27677. __class(BloomEffect,'laya.d3.core.render.BloomEffect',_super);
  27678. var __proto=BloomEffect.prototype;
  27679. /**
  27680. *@inheritDoc
  27681. */
  27682. __proto.render=function(context){
  27683. var cmd=context.command;
  27684. var viewport=context.camera.viewport;
  27685. this._shaderData.setTexture(BloomEffect.SHADERVALUE_AUTOEXPOSURETEX,Texture2D.whiteTexture);
  27686. var ratio=this._anamorphicRatio;
  27687. var rw=ratio < 0 ?-ratio :0;
  27688. var rh=ratio > 0 ? ratio :0;
  27689. var tw=Math.floor(viewport.width / (2-rw));
  27690. var th=Math.floor(viewport.height / (2-rh));
  27691. var s=Math.max(tw,th);
  27692. var logs=NaN;
  27693. /*__JS__ */logs=Math.log2(s)+this._diffusion-10;
  27694. var logsInt=Math.floor(logs);
  27695. var iterations=Math.min(Math.max(logsInt,1),16);
  27696. var sampleScale=0.5+logs-logsInt;
  27697. this._shaderData.setNumber(BloomEffect.SHADERVALUE_SAMPLESCALE,sampleScale);
  27698. var lthresh=Utils3D.gammaToLinearSpace(this.threshold);
  27699. var knee=lthresh *this._softKnee+1e-5;
  27700. this._shaderThreshold.setValue(lthresh,lthresh-knee,knee *2,0.25 / knee);
  27701. this._shaderData.setVector(BloomEffect.SHADERVALUE_THRESHOLD,this._shaderThreshold);
  27702. var lclamp=Utils3D.gammaToLinearSpace(this.clamp);
  27703. this._shaderParams.setValue(lclamp,0,0,0);
  27704. this._shaderData.setVector(BloomEffect.SHADERVALUE_PARAMS,this._shaderParams);
  27705. var qualityOffset=this.fastMode ? 1 :0;
  27706. var lastDownTexture=context.source;
  27707. for (var i=0;i < iterations;i++){
  27708. var downIndex=i *2;
  27709. var upIndex=downIndex+1;
  27710. var subShader=i==0 ? 0+qualityOffset :2+qualityOffset;
  27711. var mipDownTexture=RenderTexture.getTemporary(tw,th,/*laya.resource.BaseTexture.FORMAT_R8G8B8*/0,/*laya.resource.BaseTexture.FORMAT_DEPTHSTENCIL_NONE*/3,/*laya.resource.BaseTexture.FILTERMODE_BILINEAR*/1);
  27712. var mipUpTexture=RenderTexture.getTemporary(tw,th,/*laya.resource.BaseTexture.FORMAT_R8G8B8*/0,/*laya.resource.BaseTexture.FORMAT_DEPTHSTENCIL_NONE*/3,/*laya.resource.BaseTexture.FILTERMODE_BILINEAR*/1);
  27713. this._pyramid[downIndex]=mipDownTexture;
  27714. this._pyramid[upIndex]=mipUpTexture;
  27715. cmd.blit(lastDownTexture,mipDownTexture,this._shader,this._shaderData,subShader);
  27716. lastDownTexture=mipDownTexture;
  27717. tw=Math.max(tw / 2,1);
  27718. th=Math.max(th / 2,1);
  27719. };
  27720. var lastUpTexture=this._pyramid[2 *iterations-3];
  27721. for (i=iterations-2;i >=0;i--){
  27722. downIndex=i *2;
  27723. upIndex=downIndex+1;
  27724. mipDownTexture=this._pyramid[downIndex];
  27725. mipUpTexture=this._pyramid[upIndex];
  27726. cmd.setShaderDataTexture(this._shaderData,BloomEffect.SHADERVALUE_BLOOMTEX,mipDownTexture);
  27727. cmd.blit(lastUpTexture,mipUpTexture,this._shader,this._shaderData,4+qualityOffset);
  27728. lastUpTexture=mipUpTexture;
  27729. };
  27730. var linearColor=this._linearColor;
  27731. this.color.toLinear(linearColor);
  27732. var intensity=Math.pow(2,this._intensity / 10.0)-1.0;
  27733. var shaderSettings=this._shaderSetting;
  27734. this._shaderSetting.setValue(sampleScale,intensity,this._dirtIntensity,iterations);
  27735. var dirtTexture=dirtTexture ? dirtTexture :Texture2D.blackTexture;
  27736. var dirtRatio=dirtTexture.width / dirtTexture.height;
  27737. var screenRatio=viewport.width / viewport.height;
  27738. var dirtTileOffset=this._dirtTileOffset;
  27739. dirtTileOffset.setValue(1.0,1.0,0.0,0.0);
  27740. if (dirtRatio > screenRatio)
  27741. dirtTileOffset.setValue(screenRatio / dirtRatio,1.0,(1.0-dirtTileOffset.x)*0.5,0.0);
  27742. else if (dirtRatio < screenRatio)
  27743. dirtTileOffset.setValue(1.0,dirtRatio / screenRatio,0.0,(1.0-dirtTileOffset.y)*0.5);
  27744. var compositeShaderData=context.compositeShaderData;
  27745. var compositeDefineData=context.compositeDefineData;
  27746. if (this.fastMode)
  27747. compositeDefineData.add(PostProcess.SHADERDEFINE_BLOOM_LOW);
  27748. else
  27749. compositeDefineData.add(PostProcess.SHADERDEFINE_BLOOM);
  27750. compositeShaderData.setVector(PostProcess.SHADERVALUE_BLOOM_DIRTTILEOFFSET,dirtTileOffset);
  27751. compositeShaderData.setVector(PostProcess.SHADERVALUE_BLOOM_SETTINGS,shaderSettings);
  27752. compositeShaderData.setVector(PostProcess.SHADERVALUE_BLOOM_COLOR,new Vector4(linearColor.r,linearColor.g,linearColor.b,linearColor.a));
  27753. compositeShaderData.setTexture(PostProcess.SHADERVALUE_BLOOM_DIRTTEX,dirtTexture);
  27754. compositeShaderData.setTexture(PostProcess.SHADERVALUE_BLOOMTEX,lastUpTexture);
  27755. for (i=0;i < iterations;i++){
  27756. downIndex=i *2;
  27757. upIndex=downIndex+1;
  27758. if (this._pyramid[downIndex] !=lastUpTexture)
  27759. RenderTexture.setReleaseTemporary(this._pyramid[downIndex]);
  27760. if (this._pyramid[upIndex] !=lastUpTexture)
  27761. RenderTexture.setReleaseTemporary(this._pyramid[upIndex]);
  27762. }
  27763. context.tempRenderTextures.push(lastUpTexture);
  27764. }
  27765. /**
  27766. *设置软膝盖过渡强度,在阈值以下进行渐变过渡(0为完全硬过度,1为完全软过度)。
  27767. *@param value 软膝盖值。
  27768. */
  27769. /**
  27770. *获取软膝盖过渡强度,在阈值以下进行渐变过渡(0为完全硬过度,1为完全软过度)。
  27771. *@return 软膝盖值。
  27772. */
  27773. __getset(0,__proto,'softKnee',function(){
  27774. return this._softKnee;
  27775. },function(value){
  27776. this._softKnee=Math.min(Math.max(value,0.0),1.0);
  27777. });
  27778. /**
  27779. *设置泛光过滤器强度,最小值为0。
  27780. *@param value 强度。
  27781. */
  27782. /**
  27783. *获取泛光过滤器强度,最小值为0。
  27784. *@return 强度。
  27785. */
  27786. __getset(0,__proto,'intensity',function(){
  27787. return this._intensity;
  27788. },function(value){
  27789. this._intensity=Math.max(value,0.0);
  27790. });
  27791. /**
  27792. *获取泛光阈值,在该阈值亮度以下的像素会被过滤掉,该值在伽马空间。
  27793. *@param value 阈值。
  27794. */
  27795. /**
  27796. *设置泛光阈值,在该阈值亮度以下的像素会被过滤掉,该值在伽马空间。
  27797. *@return 阈值。
  27798. */
  27799. __getset(0,__proto,'threshold',function(){
  27800. return this._threshold;
  27801. },function(value){
  27802. this._threshold=Math.max(value,0.0);
  27803. });
  27804. /**
  27805. *设置形变比,通过扭曲泛光产生视觉上形变,负值为垂直扭曲,正值为水平扭曲。
  27806. *@param value 形变比。
  27807. */
  27808. /**
  27809. *获取形变比,通过扭曲泛光产生视觉上形变,负值为垂直扭曲,正值为水平扭曲。
  27810. *@return 形变比。
  27811. */
  27812. __getset(0,__proto,'anamorphicRatio',function(){
  27813. return this._anamorphicRatio;
  27814. },function(value){
  27815. this._anamorphicRatio=Math.min(Math.max(value,-1.0),1.0);
  27816. });
  27817. /**
  27818. *设置扩散值,改变泛光的扩散范围,最好使用整数值保证效果,该值会改变内部的迭代次数,范围是1到10。
  27819. *@param value 光晕的扩散范围。
  27820. */
  27821. /**
  27822. *获取扩散值,改变泛光的扩散范围,最好使用整数值保证效果,该值会改变内部的迭代次数,范围是1到10。
  27823. *@return 光晕的扩散范围。
  27824. */
  27825. __getset(0,__proto,'diffusion',function(){
  27826. return this._diffusion;
  27827. },function(value){
  27828. this._diffusion=Math.min(Math.max(value,1),10);
  27829. });
  27830. /**
  27831. *设置污渍强度。
  27832. *@param value 污渍强度。
  27833. */
  27834. /**
  27835. *获取污渍强度。
  27836. *@return 污渍强度。
  27837. */
  27838. __getset(0,__proto,'dirtIntensity',function(){
  27839. return this._dirtIntensity;
  27840. },function(value){
  27841. this._dirtIntensity=Math.max(value,0.0);
  27842. });
  27843. BloomEffect.SUBSHADER_PREFILTER13=0;
  27844. BloomEffect.SUBSHADER_PREFILTER4=1;
  27845. BloomEffect.SUBSHADER_DOWNSAMPLE13=2;
  27846. BloomEffect.SUBSHADER_DOWNSAMPLE4=3;
  27847. BloomEffect.SUBSHADER_UPSAMPLETENT=4;
  27848. BloomEffect.SUBSHADER_UPSAMPLEBOX=5;
  27849. BloomEffect.MAXPYRAMIDSIZE=16;
  27850. __static(BloomEffect,
  27851. ['SHADERVALUE_MAINTEX',function(){return this.SHADERVALUE_MAINTEX=Shader3D.propertyNameToID("u_MainTex");},'SHADERVALUE_AUTOEXPOSURETEX',function(){return this.SHADERVALUE_AUTOEXPOSURETEX=Shader3D.propertyNameToID("u_AutoExposureTex");},'SHADERVALUE_SAMPLESCALE',function(){return this.SHADERVALUE_SAMPLESCALE=Shader3D.propertyNameToID("u_SampleScale");},'SHADERVALUE_THRESHOLD',function(){return this.SHADERVALUE_THRESHOLD=Shader3D.propertyNameToID("u_Threshold");},'SHADERVALUE_PARAMS',function(){return this.SHADERVALUE_PARAMS=Shader3D.propertyNameToID("u_Params");},'SHADERVALUE_BLOOMTEX',function(){return this.SHADERVALUE_BLOOMTEX=Shader3D.propertyNameToID("u_BloomTex");}
  27852. ]);
  27853. return BloomEffect;
  27854. })(PostProcessEffect)
  27855. /**
  27856. *@private
  27857. *<code>SetShaderDataTextureCMD</code> 类用于创建设置渲染目标指令。
  27858. */
  27859. //class laya.d3.core.render.command.SetShaderDataTextureCMD extends laya.d3.core.render.command.Command
  27860. var SetShaderDataTextureCMD=(function(_super){
  27861. function SetShaderDataTextureCMD(){
  27862. /**@private */
  27863. this._shaderData=null;
  27864. /**@private */
  27865. this._nameID=0;
  27866. /**@private */
  27867. this._texture=null;
  27868. SetShaderDataTextureCMD.__super.call(this);
  27869. }
  27870. __class(SetShaderDataTextureCMD,'laya.d3.core.render.command.SetShaderDataTextureCMD',_super);
  27871. var __proto=SetShaderDataTextureCMD.prototype;
  27872. /**
  27873. *@inheritDoc
  27874. */
  27875. __proto.run=function(){
  27876. this._shaderData.setTexture(this._nameID,this._texture);
  27877. }
  27878. /**
  27879. *@inheritDoc
  27880. */
  27881. __proto.recover=function(){
  27882. SetShaderDataTextureCMD._pool.push(this);
  27883. this._shaderData=null;
  27884. this._nameID=0;
  27885. this._texture=null;
  27886. }
  27887. SetShaderDataTextureCMD.create=function(shaderData,nameID,texture){
  27888. var cmd;
  27889. cmd=SetShaderDataTextureCMD._pool.length > 0 ? SetShaderDataTextureCMD._pool.pop():new SetShaderDataTextureCMD();
  27890. cmd._shaderData=shaderData;
  27891. cmd._nameID=nameID;
  27892. cmd._texture=texture;
  27893. return cmd;
  27894. }
  27895. SetShaderDataTextureCMD._pool=[];
  27896. return SetShaderDataTextureCMD;
  27897. })(Command)
  27898. /**
  27899. *<code>SphereShape</code> 类用于创建球形粒子形状。
  27900. */
  27901. //class laya.d3.core.particleShuriKen.module.shape.SphereShape extends laya.d3.core.particleShuriKen.module.shape.BaseShape
  27902. var SphereShape=(function(_super){
  27903. function SphereShape(){
  27904. /**发射器半径。*/
  27905. this.radius=NaN;
  27906. /**从外壳发射。*/
  27907. this.emitFromShell=false;
  27908. SphereShape.__super.call(this);
  27909. this.radius=1.0;
  27910. this.emitFromShell=false;
  27911. this.randomDirection=false;
  27912. }
  27913. __class(SphereShape,'laya.d3.core.particleShuriKen.module.shape.SphereShape',_super);
  27914. var __proto=SphereShape.prototype;
  27915. /**
  27916. *@inheritDoc
  27917. */
  27918. __proto._getShapeBoundBox=function(boundBox){
  27919. var min=boundBox.min;
  27920. min.x=min.y=min.z=-this.radius;
  27921. var max=boundBox.max;
  27922. max.x=max.y=max.z=this.radius;
  27923. }
  27924. /**
  27925. *@inheritDoc
  27926. */
  27927. __proto._getSpeedBoundBox=function(boundBox){
  27928. var min=boundBox.min;
  27929. min.x=min.y=min.z=-1;
  27930. var max=boundBox.max;
  27931. max.x=max.y=max.z=1;
  27932. }
  27933. /**
  27934. *用于生成粒子初始位置和方向。
  27935. *@param position 粒子位置。
  27936. *@param direction 粒子方向。
  27937. */
  27938. __proto.generatePositionAndDirection=function(position,direction,rand,randomSeeds){
  27939. if (rand){
  27940. rand.seed=randomSeeds[16];
  27941. if (this.emitFromShell)
  27942. ShapeUtils._randomPointUnitSphere(position,rand);
  27943. else
  27944. ShapeUtils._randomPointInsideUnitSphere(position,rand);
  27945. randomSeeds[16]=rand.seed;
  27946. }else {
  27947. if (this.emitFromShell)
  27948. ShapeUtils._randomPointUnitSphere(position);
  27949. else
  27950. ShapeUtils._randomPointInsideUnitSphere(position);
  27951. }
  27952. Vector3.scale(position,this.radius,position);
  27953. if (this.randomDirection){
  27954. if (rand){
  27955. rand.seed=randomSeeds[17];
  27956. ShapeUtils._randomPointUnitSphere(direction,rand);
  27957. randomSeeds[17]=rand.seed;
  27958. }else {
  27959. ShapeUtils._randomPointUnitSphere(direction);
  27960. }
  27961. }else {
  27962. position.cloneTo(direction);
  27963. }
  27964. }
  27965. __proto.cloneTo=function(destObject){
  27966. _super.prototype.cloneTo.call(this,destObject);
  27967. var destShape=destObject;
  27968. destShape.radius=this.radius;
  27969. destShape.emitFromShell=this.emitFromShell;
  27970. destShape.randomDirection=this.randomDirection;
  27971. }
  27972. return SphereShape;
  27973. })(BaseShape)
  27974. /**
  27975. *<code>Vector3Keyframe</code> 类用于创建三维向量关键帧实例。
  27976. */
  27977. //class laya.d3.core.Vector3Keyframe extends laya.d3.core.Keyframe
  27978. var Vector3Keyframe=(function(_super){
  27979. function Vector3Keyframe(){
  27980. Vector3Keyframe.__super.call(this);
  27981. this.inTangent=new Vector3();
  27982. this.outTangent=new Vector3();
  27983. this.value=new Vector3();
  27984. }
  27985. __class(Vector3Keyframe,'laya.d3.core.Vector3Keyframe',_super);
  27986. var __proto=Vector3Keyframe.prototype;
  27987. /**
  27988. *克隆。
  27989. *@param destObject 克隆源。
  27990. */
  27991. __proto.cloneTo=function(dest){
  27992. _super.prototype.cloneTo.call(this,dest);
  27993. var destKeyFarme=dest;
  27994. this.inTangent.cloneTo(destKeyFarme.inTangent);
  27995. this.outTangent.cloneTo(destKeyFarme.outTangent);
  27996. this.value.cloneTo(destKeyFarme.value);
  27997. }
  27998. return Vector3Keyframe;
  27999. })(Keyframe)
  28000. /**
  28001. *<code>SkyDome</code> 类用于创建天空盒。
  28002. */
  28003. //class laya.d3.resource.models.SkyDome extends laya.d3.resource.models.SkyMesh
  28004. var SkyDome=(function(_super){
  28005. function SkyDome(stacks,slices){
  28006. /**@private */
  28007. this._stacks=0;
  28008. /**@private */
  28009. this._slices=0;
  28010. SkyDome.__super.call(this);
  28011. (stacks===void 0)&& (stacks=48);
  28012. (slices===void 0)&& (slices=48);
  28013. this._stacks=stacks;
  28014. this._slices=slices;
  28015. var vertexDeclaration=VertexPositionTexture0.vertexDeclaration;
  28016. var vertexFloatCount=vertexDeclaration.vertexStride / 4;
  28017. var numberVertices=(this._stacks+1)*(this._slices+1);
  28018. var numberIndices=(3 *this._stacks *(this._slices+1))*2;
  28019. var vertices=new Float32Array(numberVertices *vertexFloatCount);
  28020. var indices=new Uint16Array(numberIndices);
  28021. var stackAngle=Math.PI / this._stacks;
  28022. var sliceAngle=(Math.PI *2.0)/ this._slices;
  28023. var vertexIndex=0;
  28024. var vertexCount=0;
  28025. var indexCount=0;
  28026. for (var stack=0;stack < (this._stacks+1);stack++){
  28027. var r=Math.sin(stack *stackAngle);
  28028. var y=Math.cos(stack *stackAngle);
  28029. for (var slice=0;slice < (this._slices+1);slice++){
  28030. var x=r *Math.sin(slice *sliceAngle);
  28031. var z=r *Math.cos(slice *sliceAngle);
  28032. vertices[vertexCount+0]=x *SkyDome._radius;
  28033. vertices[vertexCount+1]=y *SkyDome._radius;
  28034. vertices[vertexCount+2]=z *SkyDome._radius;
  28035. vertices[vertexCount+3]=-(slice / this._slices)+0.75;
  28036. vertices[vertexCount+4]=stack / this._stacks;
  28037. vertexCount+=vertexFloatCount;
  28038. if (stack !=(this._stacks-1)){
  28039. indices[indexCount++]=vertexIndex+1;
  28040. indices[indexCount++]=vertexIndex;
  28041. indices[indexCount++]=vertexIndex+(this._slices+1);
  28042. indices[indexCount++]=vertexIndex+(this._slices+1);
  28043. indices[indexCount++]=vertexIndex;
  28044. indices[indexCount++]=vertexIndex+(this._slices);
  28045. vertexIndex++;
  28046. }
  28047. }
  28048. }
  28049. this._vertexBuffer=new VertexBuffer3D(vertices.length *4,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,false);
  28050. this._vertexBuffer.vertexDeclaration=vertexDeclaration;
  28051. this._indexBuffer=new IndexBuffer3D(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",indices.length,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,false);
  28052. this._vertexBuffer.setData(vertices);
  28053. this._indexBuffer.setData(indices);
  28054. var bufferState=new BufferState();
  28055. bufferState.bind();
  28056. bufferState.applyVertexBuffer(this._vertexBuffer);
  28057. bufferState.applyIndexBuffer(this._indexBuffer);
  28058. bufferState.unBind();
  28059. this._bufferState=bufferState;
  28060. }
  28061. __class(SkyDome,'laya.d3.resource.models.SkyDome',_super);
  28062. var __proto=SkyDome.prototype;
  28063. __proto._render=function(state){
  28064. var indexCount=this._indexBuffer.indexCount;
  28065. LayaGL.instance.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,indexCount,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,0);
  28066. Stat.trianglesFaces+=indexCount / 3;
  28067. Stat.renderBatches++;
  28068. }
  28069. /**
  28070. *获取堆数。
  28071. */
  28072. __getset(0,__proto,'stacks',function(){
  28073. return this._stacks;
  28074. });
  28075. /**
  28076. *获取层数。
  28077. */
  28078. __getset(0,__proto,'slices',function(){
  28079. return this._slices;
  28080. });
  28081. SkyDome.__init__=function(){
  28082. SkyDome.instance=new SkyDome();
  28083. }
  28084. SkyDome._radius=1;
  28085. SkyDome.instance=null;
  28086. return SkyDome;
  28087. })(SkyMesh)
  28088. /**
  28089. *<code>ConeColliderShape</code> 类用于创建圆柱碰撞器。
  28090. */
  28091. //class laya.d3.physics.shape.ConeColliderShape extends laya.d3.physics.shape.ColliderShape
  28092. var ConeColliderShape=(function(_super){
  28093. function ConeColliderShape(radius,height,orientation){
  28094. /**@private */
  28095. //this._orientation=0;
  28096. /**@private */
  28097. this._radius=1;
  28098. /**@private */
  28099. this._height=0.5;
  28100. ConeColliderShape.__super.call(this);
  28101. (radius===void 0)&& (radius=0.5);
  28102. (height===void 0)&& (height=1.0);
  28103. (orientation===void 0)&& (orientation=/*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPY*/1);
  28104. this._radius=radius;
  28105. this._height=height;
  28106. this._orientation=orientation;
  28107. this._type=/*laya.d3.physics.shape.ColliderShape.SHAPETYPES_CYLINDER*/2;
  28108. switch (orientation){
  28109. case /*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPX*/0:
  28110. this._nativeShape=new Laya3D._physics3D.btConeShapeX(radius,height);
  28111. break ;
  28112. case /*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPY*/1:
  28113. this._nativeShape=new Laya3D._physics3D.btConeShape(radius,height);
  28114. break ;
  28115. case /*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPZ*/2:
  28116. this._nativeShape=new Laya3D._physics3D.btConeShapeZ(radius,height);
  28117. break ;
  28118. default :
  28119. throw "ConeColliderShape:unknown orientation.";
  28120. }
  28121. }
  28122. __class(ConeColliderShape,'laya.d3.physics.shape.ConeColliderShape',_super);
  28123. var __proto=ConeColliderShape.prototype;
  28124. /**
  28125. *@inheritDoc
  28126. */
  28127. __proto.clone=function(){
  28128. var dest=new ConeColliderShape(this._radius,this._height,this._orientation);
  28129. this.cloneTo(dest);
  28130. return dest;
  28131. }
  28132. /**
  28133. *获取半径。
  28134. */
  28135. __getset(0,__proto,'radius',function(){
  28136. return this._radius;
  28137. });
  28138. /**
  28139. *获取高度。
  28140. */
  28141. __getset(0,__proto,'height',function(){
  28142. return this._height;
  28143. });
  28144. /**
  28145. *获取方向。
  28146. */
  28147. __getset(0,__proto,'orientation',function(){
  28148. return this._orientation;
  28149. });
  28150. return ConeColliderShape;
  28151. })(ColliderShape)
  28152. /**
  28153. *<code>BoxShape</code> 类用于创建球形粒子形状。
  28154. */
  28155. //class laya.d3.core.particleShuriKen.module.shape.BoxShape extends laya.d3.core.particleShuriKen.module.shape.BaseShape
  28156. var BoxShape=(function(_super){
  28157. function BoxShape(){
  28158. /**发射器X轴长度。*/
  28159. this.x=NaN;
  28160. /**发射器Y轴长度。*/
  28161. this.y=NaN;
  28162. /**发射器Z轴长度。*/
  28163. this.z=NaN;
  28164. BoxShape.__super.call(this);
  28165. this.x=1.0;
  28166. this.y=1.0;
  28167. this.z=1.0;
  28168. this.randomDirection=false;
  28169. }
  28170. __class(BoxShape,'laya.d3.core.particleShuriKen.module.shape.BoxShape',_super);
  28171. var __proto=BoxShape.prototype;
  28172. /**
  28173. *@inheritDoc
  28174. */
  28175. __proto._getShapeBoundBox=function(boundBox){
  28176. var min=boundBox.min;
  28177. min.x=-this.x *0.5;
  28178. min.y=-this.y *0.5;
  28179. min.z=-this.z *0.5;
  28180. var max=boundBox.max;
  28181. max.x=this.x *0.5;
  28182. max.y=this.y *0.5;
  28183. max.z=this.z *0.5;
  28184. }
  28185. /**
  28186. *@inheritDoc
  28187. */
  28188. __proto._getSpeedBoundBox=function(boundBox){
  28189. var min=boundBox.min;
  28190. min.x=0.0;
  28191. min.y=0.0;
  28192. min.z=0.0;
  28193. var max=boundBox.max;
  28194. max.x=0.0;
  28195. max.y=1.0;
  28196. max.z=0.0;
  28197. }
  28198. /**
  28199. *用于生成粒子初始位置和方向。
  28200. *@param position 粒子位置。
  28201. *@param direction 粒子方向。
  28202. */
  28203. __proto.generatePositionAndDirection=function(position,direction,rand,randomSeeds){
  28204. if (rand){
  28205. rand.seed=randomSeeds[16];
  28206. ShapeUtils._randomPointInsideHalfUnitBox(position,rand);
  28207. randomSeeds[16]=rand.seed;
  28208. }else {
  28209. ShapeUtils._randomPointInsideHalfUnitBox(position);
  28210. }
  28211. position.x=this.x *position.x;
  28212. position.y=this.y *position.y;
  28213. position.z=this.z *position.z;
  28214. if (this.randomDirection){
  28215. if (rand){
  28216. rand.seed=randomSeeds[17];
  28217. ShapeUtils._randomPointUnitSphere(direction,rand);
  28218. randomSeeds[17]=rand.seed;
  28219. }else {
  28220. ShapeUtils._randomPointUnitSphere(direction);
  28221. }
  28222. }else {
  28223. direction.x=0.0;
  28224. direction.y=0.0;
  28225. direction.z=1.0;
  28226. }
  28227. }
  28228. __proto.cloneTo=function(destObject){
  28229. _super.prototype.cloneTo.call(this,destObject);
  28230. var destShape=destObject;
  28231. destShape.x=this.x;
  28232. destShape.y=this.y;
  28233. destShape.z=this.z;
  28234. destShape.randomDirection=this.randomDirection;
  28235. }
  28236. return BoxShape;
  28237. })(BaseShape)
  28238. /**
  28239. *<code>QuaternionKeyframe</code> 类用于创建四元数关键帧实例。
  28240. */
  28241. //class laya.d3.core.QuaternionKeyframe extends laya.d3.core.Keyframe
  28242. var QuaternionKeyframe=(function(_super){
  28243. function QuaternionKeyframe(){
  28244. QuaternionKeyframe.__super.call(this);
  28245. this.inTangent=new Vector4();
  28246. this.outTangent=new Vector4();
  28247. this.value=new Quaternion();
  28248. }
  28249. __class(QuaternionKeyframe,'laya.d3.core.QuaternionKeyframe',_super);
  28250. var __proto=QuaternionKeyframe.prototype;
  28251. /**
  28252. *克隆。
  28253. *@param destObject 克隆源。
  28254. */
  28255. __proto.cloneTo=function(dest){
  28256. _super.prototype.cloneTo.call(this,dest);
  28257. var destKeyFarme=dest;
  28258. this.inTangent.cloneTo(destKeyFarme.inTangent);
  28259. this.outTangent.cloneTo(destKeyFarme.outTangent);
  28260. this.value.cloneTo(destKeyFarme.value);
  28261. }
  28262. return QuaternionKeyframe;
  28263. })(Keyframe)
  28264. /**
  28265. *<code>VertexShurikenParticle</code> 类用于创建粒子顶点结构。
  28266. */
  28267. //class laya.d3.graphics.Vertex.VertexShurikenParticleBillboard extends laya.d3.graphics.Vertex.VertexShuriKenParticle
  28268. var VertexShurikenParticleBillboard=(function(_super){
  28269. function VertexShurikenParticleBillboard(cornerTextureCoordinate,positionStartLifeTime,velocity,startColor,startSize,startRotation0,startRotation1,startRotation2,ageAddScale,time,startSpeed,randoms0,randoms1,simulationWorldPostion){
  28270. /**@private */
  28271. this._cornerTextureCoordinate=null;
  28272. /**@private */
  28273. this._positionStartLifeTime=null;
  28274. /**@private */
  28275. this._velocity=null;
  28276. /**@private */
  28277. this._startColor=null;
  28278. /**@private */
  28279. this._startSize=null;
  28280. /**@private */
  28281. this._startRotation0=null;
  28282. /**@private */
  28283. this._startRotation1=null;
  28284. /**@private */
  28285. this._startRotation2=null;
  28286. /**@private */
  28287. this._startLifeTime=NaN;
  28288. /**@private */
  28289. this._time=NaN;
  28290. /**@private */
  28291. this._startSpeed=NaN;
  28292. /**@private */
  28293. this._randoms0=null;
  28294. /**@private */
  28295. this._randoms1=null;
  28296. /**@private */
  28297. this._simulationWorldPostion=null;
  28298. VertexShurikenParticleBillboard.__super.call(this);
  28299. this._cornerTextureCoordinate=cornerTextureCoordinate;
  28300. this._positionStartLifeTime=positionStartLifeTime;
  28301. this._velocity=velocity;
  28302. this._startColor=startColor;
  28303. this._startSize=startSize;
  28304. this._startRotation0=startRotation0;
  28305. this._startRotation1=startRotation1;
  28306. this._startRotation2=startRotation2;
  28307. this._startLifeTime=ageAddScale;
  28308. this._time=time;
  28309. this._startSpeed=startSpeed;
  28310. this._randoms0=this.random0;
  28311. this._randoms1=this.random1;
  28312. this._simulationWorldPostion=simulationWorldPostion;
  28313. }
  28314. __class(VertexShurikenParticleBillboard,'laya.d3.graphics.Vertex.VertexShurikenParticleBillboard',_super);
  28315. var __proto=VertexShurikenParticleBillboard.prototype;
  28316. __getset(0,__proto,'cornerTextureCoordinate',function(){
  28317. return this._cornerTextureCoordinate;
  28318. });
  28319. __getset(0,__proto,'random1',function(){
  28320. return this._randoms1;
  28321. });
  28322. __getset(0,__proto,'startRotation2',function(){
  28323. return this._startRotation2;
  28324. });
  28325. __getset(0,__proto,'positionStartLifeTime',function(){
  28326. return this._positionStartLifeTime;
  28327. });
  28328. __getset(0,__proto,'velocity',function(){
  28329. return this._velocity;
  28330. });
  28331. __getset(0,__proto,'random0',function(){
  28332. return this._randoms0;
  28333. });
  28334. __getset(0,__proto,'startSize',function(){
  28335. return this._startSize;
  28336. });
  28337. __getset(0,__proto,'startColor',function(){
  28338. return this._startColor;
  28339. });
  28340. __getset(0,__proto,'startRotation0',function(){
  28341. return this._startRotation0;
  28342. });
  28343. __getset(0,__proto,'startRotation1',function(){
  28344. return this._startRotation1;
  28345. });
  28346. __getset(0,__proto,'startLifeTime',function(){
  28347. return this._startLifeTime;
  28348. });
  28349. __getset(0,__proto,'time',function(){
  28350. return this._time;
  28351. });
  28352. __getset(0,__proto,'startSpeed',function(){
  28353. return this._startSpeed;
  28354. });
  28355. __getset(0,__proto,'simulationWorldPostion',function(){
  28356. return this._simulationWorldPostion;
  28357. });
  28358. __getset(1,VertexShurikenParticleBillboard,'vertexDeclaration',function(){
  28359. return VertexShurikenParticleBillboard._vertexDeclaration;
  28360. },laya.d3.graphics.Vertex.VertexShuriKenParticle._$SET_vertexDeclaration);
  28361. __static(VertexShurikenParticleBillboard,
  28362. ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(152,[
  28363. new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_CORNERTEXTURECOORDINATE0*/0),
  28364. new VertexElement(16,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_SHAPEPOSITIONSTARTLIFETIME*/4),
  28365. new VertexElement(32,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_DIRECTIONTIME*/5),
  28366. new VertexElement(48,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_STARTCOLOR0*/6),
  28367. new VertexElement(64,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_STARTSIZE*/8),
  28368. new VertexElement(76,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_STARTROTATION*/9),
  28369. new VertexElement(88,/*laya.d3.graphics.VertexElementFormat.Single*/"single",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_STARTSPEED*/10),
  28370. new VertexElement(92,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_RANDOM0*/11),
  28371. new VertexElement(108,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_RANDOM1*/12),
  28372. new VertexElement(124,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_SIMULATIONWORLDPOSTION*/13),
  28373. new VertexElement(136,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_SIMULATIONWORLDROTATION*/14)]);}
  28374. ]);
  28375. return VertexShurikenParticleBillboard;
  28376. })(VertexShuriKenParticle)
  28377. /**
  28378. *@private
  28379. */
  28380. //class laya.d3.core.render.SubMeshRenderElement extends laya.d3.core.render.RenderElement
  28381. var SubMeshRenderElement=(function(_super){
  28382. function SubMeshRenderElement(){
  28383. /**@private */
  28384. //this._dynamicWorldPositionNormalNeedUpdate=false;
  28385. /**@private */
  28386. //this._dynamicVertexBatch=false;
  28387. /**@private */
  28388. //this._dynamicMultiSubMesh=false;
  28389. /**@private */
  28390. //this._dynamicVertexCount=0;
  28391. /**@private */
  28392. //this._dynamicWorldPositions=null;
  28393. /**@private */
  28394. //this._dynamicWorldNormals=null;
  28395. /**@private */
  28396. //this.staticBatchIndexStart=0;
  28397. /**@private */
  28398. //this.staticBatchIndexEnd=0;
  28399. /**@private */
  28400. //this.staticBatchElementList=null;
  28401. /**@private */
  28402. //this.instanceSubMesh=null;
  28403. /**@private */
  28404. //this.instanceBatchElementList=null;
  28405. /**@private */
  28406. //this.vertexBatchElementList=null;
  28407. /**@private */
  28408. //this.vertexBatchVertexDeclaration=null;
  28409. SubMeshRenderElement.__super.call(this);
  28410. this._dynamicWorldPositionNormalNeedUpdate=true;
  28411. }
  28412. __class(SubMeshRenderElement,'laya.d3.core.render.SubMeshRenderElement',_super);
  28413. var __proto=SubMeshRenderElement.prototype;
  28414. /**
  28415. *@private
  28416. */
  28417. __proto._onWorldMatrixChanged=function(){
  28418. this._dynamicWorldPositionNormalNeedUpdate=true;
  28419. }
  28420. /**
  28421. *@inheritDoc
  28422. */
  28423. __proto._computeWorldPositionsAndNormals=function(positionOffset,normalOffset,multiSubMesh,vertexCount){
  28424. if (this._dynamicWorldPositionNormalNeedUpdate){
  28425. var subMesh=this._geometry;
  28426. var vertexBuffer=subMesh._vertexBuffer;
  28427. var vertexFloatCount=vertexBuffer.vertexDeclaration.vertexStride / 4;
  28428. var oriVertexes=vertexBuffer.getData();
  28429. var worldMat=this._transform.worldMatrix;
  28430. var rotation=this._transform.rotation;
  28431. var indices=subMesh._indices;
  28432. for (var i=0;i < vertexCount;i++){
  28433. var index=multiSubMesh ? indices[i] :i;
  28434. var oriOffset=index *vertexFloatCount;
  28435. var bakeOffset=i *3;
  28436. Utils3D.transformVector3ArrayToVector3ArrayCoordinate(oriVertexes,oriOffset+positionOffset,worldMat,this._dynamicWorldPositions,bakeOffset);
  28437. (normalOffset!==-1)&& (Utils3D.transformVector3ArrayByQuat(oriVertexes,oriOffset+normalOffset,rotation,this._dynamicWorldNormals,bakeOffset));
  28438. }
  28439. this._dynamicWorldPositionNormalNeedUpdate=false;
  28440. }
  28441. }
  28442. /**
  28443. *@inheritDoc
  28444. */
  28445. __proto.setTransform=function(transform){
  28446. if (this._transform!==transform){
  28447. (this._transform)&& (this._transform.off(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this,this._onWorldMatrixChanged));
  28448. (transform)&& (transform.on(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this,this._onWorldMatrixChanged));
  28449. this._dynamicWorldPositionNormalNeedUpdate=true;
  28450. this._transform=transform;
  28451. }
  28452. }
  28453. /**
  28454. *@inheritDoc
  28455. */
  28456. __proto.setGeometry=function(geometry){
  28457. if (this._geometry!==geometry){
  28458. var subMesh=geometry;
  28459. var mesh=subMesh._mesh;
  28460. if (mesh){
  28461. var multiSubMesh=mesh._subMeshCount > 1;
  28462. var dynBatVerCount=multiSubMesh ? subMesh._indexCount :mesh._vertexCount;
  28463. if (dynBatVerCount <=/*laya.d3.graphics.SubMeshDynamicBatch.maxAllowVertexCount*/10){
  28464. var length=dynBatVerCount *3;
  28465. this._dynamicVertexBatch=true;
  28466. this._dynamicWorldPositions=new Float32Array(length);
  28467. this._dynamicWorldNormals=new Float32Array(length);
  28468. this._dynamicVertexCount=dynBatVerCount;
  28469. this._dynamicMultiSubMesh=multiSubMesh;
  28470. }else {
  28471. this._dynamicVertexBatch=false;
  28472. }
  28473. }
  28474. this._geometry=geometry;
  28475. }
  28476. }
  28477. /**
  28478. *@inheritDoc
  28479. */
  28480. __proto.addToOpaqueRenderQueue=function(context,queue){
  28481. var subMeshStaticBatch=this.staticBatch;
  28482. var elements=queue.elements;
  28483. if (subMeshStaticBatch){
  28484. var staManager=MeshRenderStaticBatchManager.instance;
  28485. var staBatchMarks=staManager.getBatchOpaquaMark(this.render.lightmapIndex+1,this.render.receiveShadow,this.material.id,subMeshStaticBatch._batchID);
  28486. if (staManager._updateCountMark===staBatchMarks.updateMark){
  28487. var staBatchIndex=staBatchMarks.indexInList;
  28488. if (staBatchMarks.batched){
  28489. elements[staBatchIndex].staticBatchElementList.push(this);
  28490. }else {
  28491. var staOriElement=elements[staBatchIndex];
  28492. var staOriRender=staOriElement.render;
  28493. var staBatchElement=staManager._getBatchRenderElementFromPool();
  28494. staBatchElement.renderType=/*laya.d3.core.render.RenderElement.RENDERTYPE_STATICBATCH*/1;
  28495. staBatchElement.setGeometry(subMeshStaticBatch);
  28496. staBatchElement.material=staOriElement.material;
  28497. var staRootOwner=subMeshStaticBatch.batchOwner;
  28498. var staBatchTransform=staRootOwner ? staRootOwner._transform :null;
  28499. staBatchElement.setTransform(staBatchTransform);
  28500. staBatchElement.render=staOriRender;
  28501. var staBatchList=staBatchElement.staticBatchElementList;
  28502. staBatchList.length=0;
  28503. staBatchList.push(staOriElement);
  28504. staBatchList.push(this);
  28505. elements[staBatchIndex]=staBatchElement;
  28506. staBatchMarks.batched=true;
  28507. }
  28508. }else {
  28509. staBatchMarks.updateMark=staManager._updateCountMark;
  28510. staBatchMarks.indexInList=elements.length;
  28511. staBatchMarks.batched=false;
  28512. elements.push(this);
  28513. }
  28514. }else if (this.material._shader._enableInstancing && WebGLContext._angleInstancedArrays){
  28515. var subMesh=this._geometry;
  28516. var insManager=MeshRenderDynamicBatchManager.instance;
  28517. var insBatchMarks=insManager.getInstanceBatchOpaquaMark(this.render.lightmapIndex+1,this.render.receiveShadow,this.material.id,subMesh._id);
  28518. if (insManager._updateCountMark===insBatchMarks.updateMark){
  28519. var insBatchIndex=insBatchMarks.indexInList;
  28520. if (insBatchMarks.batched){
  28521. var instanceBatchElementList=elements[insBatchIndex].instanceBatchElementList;
  28522. if (instanceBatchElementList.length===SubMeshInstanceBatch.instance.maxInstanceCount){
  28523. insBatchMarks.updateMark=insManager._updateCountMark;
  28524. insBatchMarks.indexInList=elements.length;
  28525. insBatchMarks.batched=false;
  28526. elements.push(this);
  28527. }else {
  28528. instanceBatchElementList.push(this);
  28529. }
  28530. }else {
  28531. var insOriElement=elements[insBatchIndex];
  28532. var insOriRender=insOriElement.render;
  28533. var insBatchElement=insManager._getBatchRenderElementFromPool();
  28534. insBatchElement.renderType=/*laya.d3.core.render.RenderElement.RENDERTYPE_INSTANCEBATCH*/2;
  28535. insBatchElement.setGeometry(SubMeshInstanceBatch.instance);
  28536. insBatchElement.material=insOriElement.material;
  28537. insBatchElement.setTransform(null);
  28538. insBatchElement.render=insOriRender;
  28539. insBatchElement.instanceSubMesh=subMesh;
  28540. var insBatchList=insBatchElement.instanceBatchElementList;
  28541. insBatchList.length=0;
  28542. insBatchList.push(insOriElement);
  28543. insBatchList.push(this);
  28544. elements[insBatchIndex]=insBatchElement;
  28545. insBatchMarks.batched=true;
  28546. }
  28547. }else {
  28548. insBatchMarks.updateMark=insManager._updateCountMark;
  28549. insBatchMarks.indexInList=elements.length;
  28550. insBatchMarks.batched=false;
  28551. elements.push(this);
  28552. }
  28553. }else if (this._dynamicVertexBatch){
  28554. var verDec=(this._geometry)._vertexBuffer.vertexDeclaration;
  28555. var dynManager=MeshRenderDynamicBatchManager.instance;
  28556. var dynBatchMarks=dynManager.getVertexBatchOpaquaMark(this.render.lightmapIndex+1,this.render.receiveShadow,this.material.id,verDec.id);
  28557. if (dynManager._updateCountMark===dynBatchMarks.updateMark){
  28558. var dynBatchIndex=dynBatchMarks.indexInList;
  28559. if (dynBatchMarks.batched){
  28560. elements[dynBatchIndex].vertexBatchElementList.push(this);
  28561. }else {
  28562. var dynOriElement=elements[dynBatchIndex];
  28563. var dynOriRender=dynOriElement.render;
  28564. var dynBatchElement=dynManager._getBatchRenderElementFromPool();
  28565. dynBatchElement.renderType=/*laya.d3.core.render.RenderElement.RENDERTYPE_VERTEXBATCH*/3;
  28566. dynBatchElement.setGeometry(SubMeshDynamicBatch.instance);
  28567. dynBatchElement.material=dynOriElement.material;
  28568. dynBatchElement.setTransform(null);
  28569. dynBatchElement.render=dynOriRender;
  28570. dynBatchElement.vertexBatchVertexDeclaration=verDec;
  28571. var dynBatchList=dynBatchElement.vertexBatchElementList;
  28572. dynBatchList.length=0;
  28573. dynBatchList.push(dynOriElement);
  28574. dynBatchList.push(this);
  28575. elements[dynBatchIndex]=dynBatchElement;
  28576. dynBatchMarks.batched=true;
  28577. }
  28578. }else {
  28579. dynBatchMarks.updateMark=dynManager._updateCountMark;
  28580. dynBatchMarks.indexInList=elements.length;
  28581. dynBatchMarks.batched=false;
  28582. elements.push(this);
  28583. }
  28584. }else {
  28585. elements.push(this);
  28586. }
  28587. }
  28588. /**
  28589. *@inheritDoc
  28590. */
  28591. __proto.addToTransparentRenderQueue=function(context,queue){
  28592. var subMeshStaticBatch=this.staticBatch;
  28593. var elements=queue.elements;
  28594. if (subMeshStaticBatch){
  28595. var staManager=MeshRenderStaticBatchManager.instance;
  28596. var staLastElement=queue.lastTransparentRenderElement;
  28597. if (staLastElement){
  28598. var staLastRender=staLastElement.render;
  28599. if (staLastElement._geometry._getType()!==this._geometry._getType()|| staLastElement.staticBatch!==subMeshStaticBatch || staLastElement.material!==this.material || staLastRender.receiveShadow!==this.render.receiveShadow || staLastRender.lightmapIndex!==this.render.lightmapIndex){
  28600. elements.push(this);
  28601. queue.lastTransparentBatched=false;
  28602. }else {
  28603. if (queue.lastTransparentBatched){
  28604. (elements [elements.length-1]).staticBatchElementList.push((this));
  28605. }else {
  28606. var staBatchElement=staManager._getBatchRenderElementFromPool();
  28607. staBatchElement.renderType=/*laya.d3.core.render.RenderElement.RENDERTYPE_STATICBATCH*/1;
  28608. staBatchElement.setGeometry(subMeshStaticBatch);
  28609. staBatchElement.material=staLastElement.material;
  28610. var staRootOwner=subMeshStaticBatch.batchOwner;
  28611. var staBatchTransform=staRootOwner ? staRootOwner._transform :null;
  28612. staBatchElement.setTransform(staBatchTransform);
  28613. staBatchElement.render=this.render;
  28614. var staBatchList=staBatchElement.staticBatchElementList;
  28615. staBatchList.length=0;
  28616. staBatchList.push(staLastElement);
  28617. staBatchList.push(this);
  28618. elements[elements.length-1]=staBatchElement;
  28619. }
  28620. queue.lastTransparentBatched=true;
  28621. }
  28622. }else {
  28623. elements.push(this);
  28624. queue.lastTransparentBatched=false;
  28625. }
  28626. }else if (this.material._shader._enableInstancing && WebGLContext._angleInstancedArrays){
  28627. var subMesh=this._geometry;
  28628. var insManager=MeshRenderDynamicBatchManager.instance;
  28629. var insLastElement=queue.lastTransparentRenderElement;
  28630. if (insLastElement){
  28631. var insLastRender=insLastElement.render;
  28632. if (insLastElement._geometry._getType()!==this._geometry._getType()|| (insLastElement._geometry)!==subMesh || insLastElement.material!==this.material || insLastRender.receiveShadow!==this.render.receiveShadow || insLastRender.lightmapIndex!==this.render.lightmapIndex){
  28633. elements.push(this);
  28634. queue.lastTransparentBatched=false;
  28635. }else {
  28636. if (queue.lastTransparentBatched){
  28637. (elements [elements.length-1]).instanceBatchElementList.push((this));
  28638. }else {
  28639. var insBatchElement=insManager._getBatchRenderElementFromPool();
  28640. insBatchElement.renderType=/*laya.d3.core.render.RenderElement.RENDERTYPE_INSTANCEBATCH*/2;
  28641. insBatchElement.setGeometry(SubMeshInstanceBatch.instance);
  28642. insBatchElement.material=insLastElement.material;
  28643. insBatchElement.setTransform(null);
  28644. insBatchElement.render=this.render;
  28645. insBatchElement.instanceSubMesh=subMesh;
  28646. var insBatchList=insBatchElement.instanceBatchElementList;
  28647. insBatchList.length=0;
  28648. insBatchList.push(insLastElement);
  28649. insBatchList.push(this);
  28650. elements[elements.length-1]=insBatchElement;
  28651. }
  28652. queue.lastTransparentBatched=true;
  28653. }
  28654. }else {
  28655. elements.push(this);
  28656. queue.lastTransparentBatched=false;
  28657. }
  28658. }else if (this._dynamicVertexBatch){
  28659. var verDec=(this._geometry)._vertexBuffer.vertexDeclaration;
  28660. var dynManager=MeshRenderDynamicBatchManager.instance;
  28661. var dynLastElement=queue.lastTransparentRenderElement;
  28662. if (dynLastElement){
  28663. var dynLastRender=dynLastElement.render;
  28664. if (dynLastElement._geometry._getType()!==this._geometry._getType()|| (dynLastElement._geometry)._vertexBuffer._vertexDeclaration!==verDec || dynLastElement.material!==this.material || dynLastRender.receiveShadow!==this.render.receiveShadow || dynLastRender.lightmapIndex!==this.render.lightmapIndex){
  28665. elements.push(this);
  28666. queue.lastTransparentBatched=false;
  28667. }else {
  28668. if (queue.lastTransparentBatched){
  28669. (elements [elements.length-1]).vertexBatchElementList.push((this));
  28670. }else {
  28671. var dynBatchElement=dynManager._getBatchRenderElementFromPool();
  28672. dynBatchElement.renderType=/*laya.d3.core.render.RenderElement.RENDERTYPE_VERTEXBATCH*/3;
  28673. dynBatchElement.setGeometry(SubMeshDynamicBatch.instance);
  28674. dynBatchElement.material=dynLastElement.material;
  28675. dynBatchElement.setTransform(null);
  28676. dynBatchElement.render=this.render;
  28677. dynBatchElement.vertexBatchVertexDeclaration=verDec;
  28678. var dynBatchList=dynBatchElement.vertexBatchElementList;
  28679. dynBatchList.length=0;
  28680. dynBatchList.push(dynLastElement);
  28681. dynBatchList.push(this);
  28682. elements[elements.length-1]=dynBatchElement;
  28683. }
  28684. queue.lastTransparentBatched=true;
  28685. }
  28686. }else {
  28687. elements.push(this);
  28688. queue.lastTransparentBatched=false;
  28689. }
  28690. }else {
  28691. elements.push(this);
  28692. }
  28693. queue.lastTransparentRenderElement=this;
  28694. }
  28695. /**
  28696. *@inheritDoc
  28697. */
  28698. __proto.destroy=function(){
  28699. _super.prototype.destroy.call(this);
  28700. this._dynamicWorldPositions=null;
  28701. this._dynamicWorldNormals=null;
  28702. this.staticBatch=null;
  28703. this.staticBatchElementList=null;
  28704. this.vertexBatchElementList=null;
  28705. this.vertexBatchVertexDeclaration=null;
  28706. }
  28707. SubMeshRenderElement._maxInstanceCount=1024;
  28708. __static(SubMeshRenderElement,
  28709. ['_instanceMatrixData',function(){return this._instanceMatrixData=new Float32Array(SubMeshRenderElement._maxInstanceCount *16);},'_instanceMatrixBuffer',function(){return this._instanceMatrixBuffer=new VertexBuffer3D(SubMeshRenderElement._instanceMatrixData.length *4,/*laya.webgl.WebGLContext.DYNAMIC_DRAW*/0x88E8);}
  28710. ]);
  28711. return SubMeshRenderElement;
  28712. })(RenderElement)
  28713. /**
  28714. *<code>VertexShurikenParticle</code> 类用于创建粒子顶点结构。
  28715. */
  28716. //class laya.d3.graphics.Vertex.VertexShurikenParticleMesh extends laya.d3.graphics.Vertex.VertexShuriKenParticle
  28717. var VertexShurikenParticleMesh=(function(_super){
  28718. function VertexShurikenParticleMesh(cornerTextureCoordinate,positionStartLifeTime,velocity,startColor,startSize,startRotation0,startRotation1,startRotation2,ageAddScale,time,startSpeed,randoms0,randoms1,simulationWorldPostion){
  28719. /**@private */
  28720. this._cornerTextureCoordinate=null;
  28721. /**@private */
  28722. this._positionStartLifeTime=null;
  28723. /**@private */
  28724. this._velocity=null;
  28725. /**@private */
  28726. this._startColor=null;
  28727. /**@private */
  28728. this._startSize=null;
  28729. /**@private */
  28730. this._startRotation0=null;
  28731. /**@private */
  28732. this._startRotation1=null;
  28733. /**@private */
  28734. this._startRotation2=null;
  28735. /**@private */
  28736. this._startLifeTime=NaN;
  28737. /**@private */
  28738. this._time=NaN;
  28739. /**@private */
  28740. this._startSpeed=NaN;
  28741. /**@private */
  28742. this._randoms0=null;
  28743. /**@private */
  28744. this._randoms1=null;
  28745. /**@private */
  28746. this._simulationWorldPostion=null;
  28747. VertexShurikenParticleMesh.__super.call(this);
  28748. this._cornerTextureCoordinate=cornerTextureCoordinate;
  28749. this._positionStartLifeTime=positionStartLifeTime;
  28750. this._velocity=velocity;
  28751. this._startColor=startColor;
  28752. this._startSize=startSize;
  28753. this._startRotation0=startRotation0;
  28754. this._startRotation1=startRotation1;
  28755. this._startRotation2=startRotation2;
  28756. this._startLifeTime=ageAddScale;
  28757. this._time=time;
  28758. this._startSpeed=startSpeed;
  28759. this._randoms0=this.random0;
  28760. this._randoms1=this.random1;
  28761. this._simulationWorldPostion=simulationWorldPostion;
  28762. }
  28763. __class(VertexShurikenParticleMesh,'laya.d3.graphics.Vertex.VertexShurikenParticleMesh',_super);
  28764. var __proto=VertexShurikenParticleMesh.prototype;
  28765. __getset(0,__proto,'cornerTextureCoordinate',function(){
  28766. return this._cornerTextureCoordinate;
  28767. });
  28768. __getset(0,__proto,'velocity',function(){
  28769. return this._velocity;
  28770. });
  28771. __getset(0,__proto,'position',function(){
  28772. return this._positionStartLifeTime;
  28773. });
  28774. __getset(0,__proto,'random0',function(){
  28775. return this._randoms0;
  28776. });
  28777. __getset(0,__proto,'startSize',function(){
  28778. return this._startSize;
  28779. });
  28780. __getset(0,__proto,'startColor',function(){
  28781. return this._startColor;
  28782. });
  28783. __getset(0,__proto,'startRotation0',function(){
  28784. return this._startRotation0;
  28785. });
  28786. __getset(0,__proto,'startRotation1',function(){
  28787. return this._startRotation1;
  28788. });
  28789. __getset(0,__proto,'random1',function(){
  28790. return this._randoms1;
  28791. });
  28792. __getset(0,__proto,'startRotation2',function(){
  28793. return this._startRotation2;
  28794. });
  28795. __getset(0,__proto,'startLifeTime',function(){
  28796. return this._startLifeTime;
  28797. });
  28798. __getset(0,__proto,'time',function(){
  28799. return this._time;
  28800. });
  28801. __getset(0,__proto,'startSpeed',function(){
  28802. return this._startSpeed;
  28803. });
  28804. __getset(0,__proto,'simulationWorldPostion',function(){
  28805. return this._simulationWorldPostion;
  28806. });
  28807. __getset(1,VertexShurikenParticleMesh,'vertexDeclaration',function(){
  28808. return VertexShurikenParticleMesh._vertexDeclaration;
  28809. },laya.d3.graphics.Vertex.VertexShuriKenParticle._$SET_vertexDeclaration);
  28810. __static(VertexShurikenParticleMesh,
  28811. ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(172,[
  28812. new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_POSITION0*/1),
  28813. new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_COLOR0*/2),
  28814. new VertexElement(28,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_TEXTURECOORDINATE0*/3),
  28815. new VertexElement(36,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_SHAPEPOSITIONSTARTLIFETIME*/4),
  28816. new VertexElement(52,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_DIRECTIONTIME*/5),
  28817. new VertexElement(68,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_STARTCOLOR0*/6),
  28818. new VertexElement(84,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_STARTSIZE*/8),
  28819. new VertexElement(96,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_STARTROTATION*/9),
  28820. new VertexElement(108,/*laya.d3.graphics.VertexElementFormat.Single*/"single",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_STARTSPEED*/10),
  28821. new VertexElement(112,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_RANDOM0*/11),
  28822. new VertexElement(128,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_RANDOM1*/12),
  28823. new VertexElement(144,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_SIMULATIONWORLDPOSTION*/13),
  28824. new VertexElement(156,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_SIMULATIONWORLDROTATION*/14)]);}
  28825. ]);
  28826. return VertexShurikenParticleMesh;
  28827. })(VertexShuriKenParticle)
  28828. /**
  28829. *<code>Sprite3D</code> 类用于实现3D精灵。
  28830. */
  28831. //class laya.d3.core.Sprite3D extends laya.display.Node
  28832. var Sprite3D=(function(_super){
  28833. function Sprite3D(name,isStatic){
  28834. /**@private */
  28835. //this._id=0;
  28836. /**@private */
  28837. //this._url=null;
  28838. /**@private */
  28839. //this._isStatic=false;
  28840. /**@private */
  28841. //this._layer=0;
  28842. /**@private */
  28843. //this._scripts=null;
  28844. /**@private */
  28845. //this._transform=null;
  28846. /**@private */
  28847. //this._hierarchyAnimator=null;
  28848. /**@private */
  28849. this._needProcessCollisions=false;
  28850. /**@private */
  28851. this._needProcessTriggers=false;
  28852. Sprite3D.__super.call(this);
  28853. (isStatic===void 0)&& (isStatic=false);
  28854. this._id=++Sprite3D._uniqueIDCounter;
  28855. this._transform=new Transform3D(this);
  28856. this._isStatic=isStatic;
  28857. this.layer=0;
  28858. this.name=name ? name :"New Sprite3D";
  28859. }
  28860. __class(Sprite3D,'laya.d3.core.Sprite3D',_super);
  28861. var __proto=Sprite3D.prototype;
  28862. Laya.imps(__proto,{"laya.resource.ICreateResource":true})
  28863. /**
  28864. *@private
  28865. */
  28866. __proto._setCreateURL=function(url){
  28867. this._url=URL.formatURL(url);
  28868. }
  28869. /**
  28870. *@private
  28871. */
  28872. __proto._changeAnimatorsToLinkSprite3D=function(sprite3D,isLink,path){
  28873. var animator=this.getComponent(Animator);
  28874. if (animator){
  28875. if (!animator.avatar)
  28876. sprite3D._changeAnimatorToLinkSprite3DNoAvatar(animator,isLink,path);
  28877. }
  28878. if (this._parent && (this._parent instanceof laya.d3.core.Sprite3D )){
  28879. path.unshift(this._parent.name);
  28880. var p=this._parent;
  28881. (p._hierarchyAnimator)&& (p._changeAnimatorsToLinkSprite3D(sprite3D,isLink,path));
  28882. }
  28883. }
  28884. /**
  28885. *@private
  28886. */
  28887. __proto._setHierarchyAnimator=function(animator,parentAnimator){
  28888. this._changeHierarchyAnimator(animator);
  28889. this._changeAnimatorAvatar(animator.avatar);
  28890. for (var i=0,n=this._children.length;i < n;i++){
  28891. var child=this._children[i];
  28892. (child._hierarchyAnimator==parentAnimator)&& (child._setHierarchyAnimator(animator,parentAnimator));
  28893. }
  28894. }
  28895. /**
  28896. *@private
  28897. */
  28898. __proto._clearHierarchyAnimator=function(animator,parentAnimator){
  28899. this._changeHierarchyAnimator(parentAnimator);
  28900. this._changeAnimatorAvatar(parentAnimator ? parentAnimator.avatar :null);
  28901. for (var i=0,n=this._children.length;i < n;i++){
  28902. var child=this._children[i];
  28903. (child._hierarchyAnimator==animator)&& (child._clearHierarchyAnimator(animator,parentAnimator));
  28904. }
  28905. }
  28906. /**
  28907. *@private
  28908. */
  28909. __proto._changeHierarchyAnimatorAvatar=function(animator,avatar){
  28910. this._changeAnimatorAvatar(avatar);
  28911. for (var i=0,n=this._children.length;i < n;i++){
  28912. var child=this._children[i];
  28913. (child._hierarchyAnimator==animator)&& (child._changeHierarchyAnimatorAvatar(animator,avatar));
  28914. }
  28915. }
  28916. /**
  28917. *@private
  28918. */
  28919. __proto._changeAnimatorToLinkSprite3DNoAvatar=function(animator,isLink,path){
  28920. animator._handleSpriteOwnersBySprite(isLink,path,this);
  28921. for (var i=0,n=this._children.length;i < n;i++){
  28922. var child=this._children[i];
  28923. var index=path.length;
  28924. path.push(child.name);
  28925. child._changeAnimatorToLinkSprite3DNoAvatar(animator,isLink,path);
  28926. path.splice(index,1);
  28927. }
  28928. }
  28929. /**
  28930. *@private
  28931. */
  28932. __proto._changeHierarchyAnimator=function(animator){
  28933. this._hierarchyAnimator=animator;
  28934. }
  28935. /**
  28936. *@private
  28937. */
  28938. __proto._changeAnimatorAvatar=function(avatar){}
  28939. /**
  28940. *@inheritDoc
  28941. */
  28942. __proto._onAdded=function(){
  28943. if ((this._parent instanceof laya.d3.core.Sprite3D )){
  28944. var parent3D=this._parent;
  28945. this.transform._setParent(parent3D.transform);
  28946. if (parent3D._hierarchyAnimator){
  28947. (!this._hierarchyAnimator)&& (this._setHierarchyAnimator(parent3D._hierarchyAnimator,null));
  28948. parent3D._changeAnimatorsToLinkSprite3D(this,true,/*new vector.<>*/[this.name]);
  28949. }
  28950. }
  28951. _super.prototype._onAdded.call(this);
  28952. }
  28953. /**
  28954. *@inheritDoc
  28955. */
  28956. __proto._onRemoved=function(){
  28957. _super.prototype._onRemoved.call(this);
  28958. if ((this._parent instanceof laya.d3.core.Sprite3D )){
  28959. var parent3D=this._parent;
  28960. this.transform._setParent(null);
  28961. if (parent3D._hierarchyAnimator){
  28962. (this._hierarchyAnimator==parent3D._hierarchyAnimator)&& (this._clearHierarchyAnimator(parent3D._hierarchyAnimator,null));
  28963. parent3D._changeAnimatorsToLinkSprite3D(this,false,/*new vector.<>*/[this.name]);
  28964. }
  28965. }
  28966. }
  28967. /**
  28968. *@inheritDoc
  28969. */
  28970. __proto._parse=function(data,spriteMap){
  28971. (data.isStatic!==undefined)&& (this._isStatic=data.isStatic);
  28972. (data.active!==undefined)&& (this.active=data.active);
  28973. (data.name !=undefined)&& (this.name=data.name);
  28974. if (data.position!==undefined){
  28975. var loccalPosition=this.transform.localPosition;
  28976. loccalPosition.fromArray(data.position);
  28977. this.transform.localPosition=loccalPosition;
  28978. }
  28979. if (data.rotationEuler!==undefined){
  28980. var localRotationEuler=this.transform.localRotationEuler;
  28981. localRotationEuler.fromArray(data.rotationEuler);
  28982. this.transform.localRotationEuler=localRotationEuler;
  28983. }
  28984. if (data.rotation!==undefined){
  28985. var localRotation=this.transform.localRotation;
  28986. localRotation.fromArray(data.rotation);
  28987. this.transform.localRotation=localRotation;
  28988. }
  28989. if (data.scale!==undefined){
  28990. var localScale=this.transform.localScale;
  28991. localScale.fromArray(data.scale);
  28992. this.transform.localScale=localScale;
  28993. }
  28994. (data.layer !=undefined)&& (this.layer=data.layer);
  28995. }
  28996. /**
  28997. *克隆。
  28998. *@param destObject 克隆源。
  28999. */
  29000. __proto._cloneTo=function(destObject,srcRoot,dstRoot){
  29001. if (this.destroyed)
  29002. throw new Error("Sprite3D: Can't be cloned if the Sprite3D has destroyed.");
  29003. var destSprite3D=destObject;
  29004. destSprite3D.name=this.name;
  29005. destSprite3D.destroyed=this.destroyed;
  29006. destSprite3D.active=this.active;
  29007. var destLocalPosition=destSprite3D.transform.localPosition;
  29008. this.transform.localPosition.cloneTo(destLocalPosition);
  29009. destSprite3D.transform.localPosition=destLocalPosition;
  29010. var destLocalRotation=destSprite3D.transform.localRotation;
  29011. this.transform.localRotation.cloneTo(destLocalRotation);
  29012. destSprite3D.transform.localRotation=destLocalRotation;
  29013. var destLocalScale=destSprite3D.transform.localScale;
  29014. this.transform.localScale.cloneTo(destLocalScale);
  29015. destSprite3D.transform.localScale=destLocalScale;
  29016. destSprite3D._isStatic=this._isStatic;
  29017. destSprite3D.layer=this.layer;
  29018. _super.prototype._cloneTo.call(this,destSprite3D,srcRoot,dstRoot);
  29019. }
  29020. /**
  29021. *克隆。
  29022. *@return 克隆副本。
  29023. */
  29024. __proto.clone=function(){
  29025. var dstSprite3D=Sprite3D._createSprite3DInstance(this);
  29026. Sprite3D._parseSprite3DInstance(this,dstSprite3D,this,dstSprite3D);
  29027. return dstSprite3D;
  29028. }
  29029. /**
  29030. *@inheritDoc
  29031. */
  29032. __proto.destroy=function(destroyChild){
  29033. (destroyChild===void 0)&& (destroyChild=true);
  29034. if (this.destroyed)
  29035. return;
  29036. _super.prototype.destroy.call(this,destroyChild);
  29037. this._transform=null;
  29038. this._scripts=null;
  29039. this._url && Loader.clearRes(this._url);
  29040. }
  29041. /**
  29042. *获取唯一标识ID。
  29043. *@return 唯一标识ID。
  29044. */
  29045. __getset(0,__proto,'id',function(){
  29046. return this._id;
  29047. });
  29048. /**
  29049. *获取资源的URL地址。
  29050. *@return URL地址。
  29051. */
  29052. __getset(0,__proto,'url',function(){
  29053. return this._url;
  29054. });
  29055. /**
  29056. *设置蒙版。
  29057. *@param value 蒙版。
  29058. */
  29059. /**
  29060. *获取蒙版。
  29061. *@return 蒙版。
  29062. */
  29063. __getset(0,__proto,'layer',function(){
  29064. return this._layer;
  29065. },function(value){
  29066. if (this._layer!==value){
  29067. if (value >=0 && value <=30){
  29068. this._layer=value;
  29069. }else {
  29070. throw new Error("Layer value must be 0-30.");
  29071. }
  29072. }
  29073. });
  29074. /**
  29075. *获取精灵变换。
  29076. *@return 精灵变换。
  29077. */
  29078. __getset(0,__proto,'transform',function(){
  29079. return this._transform;
  29080. });
  29081. /**
  29082. *获取是否为静态。
  29083. *@return 是否为静态。
  29084. */
  29085. __getset(0,__proto,'isStatic',function(){
  29086. return this._isStatic;
  29087. });
  29088. Sprite3D._parse=function(data,propertyParams,constructParams){
  29089. var json=data.data;
  29090. var outBatchSprits=[];
  29091. var sprite;
  29092. switch (data.version){
  29093. case "LAYAHIERARCHY:02":
  29094. sprite=Utils3D._createNodeByJson02(json,outBatchSprits);
  29095. break ;
  29096. default :
  29097. sprite=Utils3D._createNodeByJson(json,outBatchSprits);
  29098. }
  29099. StaticBatchManager.combine(sprite,outBatchSprits);
  29100. return sprite;
  29101. }
  29102. Sprite3D.__init__=function(){}
  29103. Sprite3D.instantiate=function(original,parent,worldPositionStays,position,rotation){
  29104. (worldPositionStays===void 0)&& (worldPositionStays=true);
  29105. var destSprite3D=original.clone();
  29106. (parent)&& (parent.addChild(destSprite3D));
  29107. var transform=destSprite3D.transform;
  29108. if (worldPositionStays){
  29109. var worldMatrix=transform.worldMatrix;
  29110. original.transform.worldMatrix.cloneTo(worldMatrix);
  29111. transform.worldMatrix=worldMatrix;
  29112. }else {
  29113. (position)&& (transform.position=position);
  29114. (rotation)&& (transform.rotation=rotation);
  29115. }
  29116. return destSprite3D;
  29117. }
  29118. Sprite3D.load=function(url,complete){
  29119. Laya.loader.create(url,complete,null,/*Laya3D.HIERARCHY*/"HIERARCHY");
  29120. }
  29121. Sprite3D._createSprite3DInstance=function(scrSprite){
  29122. var node=/*__JS__ */new scrSprite.constructor();
  29123. var children=scrSprite._children;
  29124. for (var i=0,n=children.length;i < n;i++){
  29125. var child=Sprite3D._createSprite3DInstance(children[i])
  29126. node.addChild(child);
  29127. }
  29128. return node;
  29129. }
  29130. Sprite3D._parseSprite3DInstance=function(srcRoot,dstRoot,scrSprite,dstSprite){
  29131. var srcChildren=scrSprite._children;
  29132. var dstChildren=dstSprite._children;
  29133. for (var i=0,n=srcChildren.length;i < n;i++)
  29134. Sprite3D._parseSprite3DInstance(srcRoot,dstRoot,srcChildren[i],dstChildren[i])
  29135. scrSprite._cloneTo(dstSprite,srcRoot,dstRoot);
  29136. }
  29137. Sprite3D._uniqueIDCounter=0;
  29138. __static(Sprite3D,
  29139. ['WORLDMATRIX',function(){return this.WORLDMATRIX=Shader3D.propertyNameToID("u_WorldMat");},'MVPMATRIX',function(){return this.MVPMATRIX=Shader3D.propertyNameToID("u_MvpMatrix");}
  29140. ]);
  29141. return Sprite3D;
  29142. })(Node)
  29143. /**
  29144. *<code>BaseMaterial</code> 类用于创建材质,抽象类,不允许实例。
  29145. */
  29146. //class laya.d3.core.material.BaseMaterial extends laya.resource.Resource
  29147. var BaseMaterial=(function(_super){
  29148. function BaseMaterial(){
  29149. /**@private */
  29150. //this._alphaTest=false;
  29151. /**@private */
  29152. //this._defineDatas=null;
  29153. /**@private */
  29154. //this._disablePublicDefineDatas=null;
  29155. /**@private */
  29156. //this._shader=null;
  29157. /**@private */
  29158. this._shaderValues=null;
  29159. /**所属渲染队列. */
  29160. //this.renderQueue=0;
  29161. BaseMaterial.__super.call(this);
  29162. this._defineDatas=new DefineDatas();
  29163. this._disablePublicDefineDatas=new DefineDatas();
  29164. this._shaderValues=new ShaderData(this);
  29165. this.renderQueue=/*CLASS CONST:laya.d3.core.material.BaseMaterial.RENDERQUEUE_OPAQUE*/2000;
  29166. this._alphaTest=false;
  29167. }
  29168. __class(BaseMaterial,'laya.d3.core.material.BaseMaterial',_super);
  29169. var __proto=BaseMaterial.prototype;
  29170. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  29171. /**
  29172. *@private
  29173. */
  29174. __proto._removeTetxureReference=function(){
  29175. var data=this._shaderValues.getData();
  29176. for (var k in data){
  29177. var value=data[k];
  29178. if (value && (value instanceof laya.resource.BaseTexture ))
  29179. (value)._removeReference();
  29180. }
  29181. }
  29182. /**
  29183. *@inheritDoc
  29184. */
  29185. __proto._addReference=function(count){
  29186. (count===void 0)&& (count=1);
  29187. _super.prototype._addReference.call(this,count);
  29188. var data=this._shaderValues.getData();
  29189. for (var k in data){
  29190. var value=data[k];
  29191. if (value && (value instanceof laya.resource.BaseTexture ))
  29192. (value)._addReference();
  29193. }
  29194. }
  29195. /**
  29196. *@inheritDoc
  29197. */
  29198. __proto._removeReference=function(count){
  29199. (count===void 0)&& (count=1);
  29200. _super.prototype._removeReference.call(this,count);
  29201. this._removeTetxureReference();
  29202. }
  29203. /**
  29204. *@inheritDoc
  29205. */
  29206. __proto._disposeResource=function(){
  29207. if (this._referenceCount > 0)
  29208. this._removeTetxureReference();
  29209. this._shaderValues=null;
  29210. }
  29211. /**
  29212. *设置使用Shader名字。
  29213. *@param name 名称。
  29214. */
  29215. __proto.setShaderName=function(name){
  29216. this._shader=Shader3D.find(name);
  29217. if (!this._shader)
  29218. throw new Error("BaseMaterial: unknown shader name.");
  29219. }
  29220. /**
  29221. *克隆。
  29222. *@param destObject 克隆源。
  29223. */
  29224. __proto.cloneTo=function(destObject){
  29225. var destBaseMaterial=destObject;
  29226. destBaseMaterial.name=this.name;
  29227. destBaseMaterial.renderQueue=this.renderQueue;
  29228. this._disablePublicDefineDatas.cloneTo(destBaseMaterial._disablePublicDefineDatas);
  29229. this._defineDatas.cloneTo(destBaseMaterial._defineDatas);
  29230. this._shaderValues.cloneTo(destBaseMaterial._shaderValues);
  29231. }
  29232. /**
  29233. *克隆。
  29234. *@return 克隆副本。
  29235. */
  29236. __proto.clone=function(){
  29237. var dest=/*__JS__ */new this.constructor();
  29238. this.cloneTo(dest);
  29239. return dest;
  29240. }
  29241. /**
  29242. *设置透明测试模式裁剪值。
  29243. *@param value 透明测试模式裁剪值。
  29244. */
  29245. /**
  29246. *获取透明测试模式裁剪值。
  29247. *@return 透明测试模式裁剪值。
  29248. */
  29249. __getset(0,__proto,'alphaTestValue',function(){
  29250. return this._shaderValues.getNumber(BaseMaterial.ALPHATESTVALUE);
  29251. },function(value){
  29252. this._shaderValues.setNumber(BaseMaterial.ALPHATESTVALUE,value);
  29253. });
  29254. /**
  29255. *设置是否透明裁剪。
  29256. *@param value 是否透明裁剪。
  29257. */
  29258. /**
  29259. *获取是否透明裁剪。
  29260. *@return 是否透明裁剪。
  29261. */
  29262. __getset(0,__proto,'alphaTest',function(){
  29263. return this._alphaTest;
  29264. },function(value){
  29265. this._alphaTest=value;
  29266. if (value)
  29267. this._defineDatas.add(laya.d3.core.material.BaseMaterial.SHADERDEFINE_ALPHATEST);
  29268. else
  29269. this._defineDatas.remove(laya.d3.core.material.BaseMaterial.SHADERDEFINE_ALPHATEST);
  29270. });
  29271. BaseMaterial.load=function(url,complete){
  29272. Laya.loader.create(url,complete,null,/*Laya3D.MATERIAL*/"MATERIAL");
  29273. }
  29274. BaseMaterial.__init__=function(){
  29275. BaseMaterial.SHADERDEFINE_ALPHATEST=BaseMaterial.shaderDefines.registerDefine("ALPHATEST");
  29276. }
  29277. BaseMaterial._parse=function(data,propertyParams,constructParams){
  29278. var jsonData=data;
  29279. var props=jsonData.props;
  29280. var material;
  29281. var classType=props.type;
  29282. var clasPaths=classType.split('.');
  29283. var clas=Browser.window;
  29284. clasPaths.forEach(function(cls){
  29285. clas=clas[cls];
  29286. });
  29287. if (typeof(clas)=='function')
  29288. material=new clas();
  29289. else
  29290. throw('_getSprite3DHierarchyInnerUrls 错误: '+data.type+' 不是类');
  29291. switch (jsonData.version){
  29292. case "LAYAMATERIAL:01":
  29293. case "LAYAMATERIAL:02":;
  29294. var i=0,n=0;
  29295. for (var key in props){
  29296. switch (key){
  29297. case "vectors":;
  29298. var vectors=props[key];
  29299. for (i=0,n=vectors.length;i < n;i++){
  29300. var vector=vectors[i];
  29301. var vectorValue=vector.value;
  29302. switch (vectorValue.length){
  29303. case 2:
  29304. material[vector.name]=new Vector2(vectorValue[0],vectorValue[1]);
  29305. break ;
  29306. case 3:
  29307. material[vector.name]=new Vector3(vectorValue[0],vectorValue[1],vectorValue[2]);
  29308. break ;
  29309. case 4:
  29310. material[vector.name]=new Vector4(vectorValue[0],vectorValue[1],vectorValue[2],vectorValue[3]);
  29311. break ;
  29312. default :
  29313. throw new Error("BaseMaterial:unkonwn color length.");
  29314. }
  29315. }
  29316. break ;
  29317. case "textures":;
  29318. var textures=props[key];
  29319. for (i=0,n=textures.length;i < n;i++){
  29320. var texture=textures[i];
  29321. var path=texture.path;
  29322. (path)&& (material[texture.name]=Loader.getRes(path));
  29323. }
  29324. break ;
  29325. case "defines":;
  29326. var defineNames=props[key];
  29327. for (i=0,n=defineNames.length;i < n;i++){
  29328. var define=material._shader.getSubShaderAt(0).getMaterialDefineByName(defineNames[i]);
  29329. material._defineDatas.add(define);
  29330. }
  29331. break ;
  29332. case "renderStates":;
  29333. var renderStatesData=props[key];
  29334. var renderStateData=renderStatesData[0];
  29335. var mat=material;
  29336. mat.blend=renderStateData.blend;
  29337. mat.cull=renderStateData.cull;
  29338. mat.depthTest=renderStateData.depthTest;
  29339. mat.depthWrite=renderStateData.depthWrite;
  29340. mat.blendSrc=renderStateData.srcBlend;
  29341. mat.blendDst=renderStateData.dstBlend;
  29342. break ;
  29343. case "cull":
  29344. (material).cull=props[key];
  29345. break ;
  29346. case "blend":
  29347. (material).blend=props[key];
  29348. break ;
  29349. case "depthWrite":
  29350. (material).depthWrite=props[key];
  29351. break ;
  29352. case "srcBlend":
  29353. (material).blendSrc=props[key];
  29354. break ;
  29355. case "dstBlend":
  29356. (material).blendDst=props[key];
  29357. break ;
  29358. default :
  29359. material[key]=props[key];
  29360. }
  29361. }
  29362. break ;
  29363. default :
  29364. throw new Error("BaseMaterial:unkonwn version.");
  29365. }
  29366. return material;
  29367. }
  29368. BaseMaterial.RENDERQUEUE_OPAQUE=2000;
  29369. BaseMaterial.RENDERQUEUE_ALPHATEST=2450;
  29370. BaseMaterial.RENDERQUEUE_TRANSPARENT=3000;
  29371. BaseMaterial.SHADERDEFINE_ALPHATEST=0;
  29372. __static(BaseMaterial,
  29373. ['ALPHATESTVALUE',function(){return this.ALPHATESTVALUE=Shader3D.propertyNameToID("u_AlphaTestValue");},'shaderDefines',function(){return this.shaderDefines=new ShaderDefines();}
  29374. ]);
  29375. return BaseMaterial;
  29376. })(Resource)
  29377. /**
  29378. *<code>ScreenQuad</code> 类用于创建全屏四边形。
  29379. */
  29380. //class laya.d3.core.render.ScreenQuad extends laya.resource.Resource
  29381. var ScreenQuad=(function(_super){
  29382. function ScreenQuad(){
  29383. /**@private */
  29384. this._vertexBuffer=null;
  29385. ScreenQuad.__super.call(this);
  29386. this._bufferState=new BufferState();
  29387. this._vertexBuffer=new VertexBuffer3D(16 *4,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,false);
  29388. this._vertexBuffer.vertexDeclaration=laya.d3.core.render.ScreenQuad._vertexDeclaration;
  29389. this._vertexBuffer.setData(ScreenQuad._vertices);
  29390. this._bufferState.bind();
  29391. this._bufferState.applyVertexBuffer(this._vertexBuffer);
  29392. this._bufferState.unBind();
  29393. this._setGPUMemory(this._vertexBuffer._byteLength);
  29394. }
  29395. __class(ScreenQuad,'laya.d3.core.render.ScreenQuad',_super);
  29396. var __proto=ScreenQuad.prototype;
  29397. /**
  29398. *@private
  29399. */
  29400. __proto.render=function(){
  29401. this._bufferState.bind();
  29402. LayaGL.instance.drawArrays(/*laya.webgl.WebGLContext.TRIANGLE_STRIP*/0x0005,0,4);
  29403. Stat.renderBatches++;
  29404. }
  29405. /**
  29406. *@inheritDoc
  29407. */
  29408. __proto.destroy=function(){
  29409. _super.prototype.destroy.call(this);
  29410. this._bufferState.destroy();
  29411. this._vertexBuffer.destroy();
  29412. this._setGPUMemory(0);
  29413. }
  29414. ScreenQuad.__init__=function(){
  29415. ScreenQuad.instance=new ScreenQuad();
  29416. ScreenQuad.instance.lock=true;
  29417. }
  29418. ScreenQuad.SCREENQUAD_POSITION_UV=0;
  29419. ScreenQuad.instance=null;
  29420. __static(ScreenQuad,
  29421. ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(16,[new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*CLASS CONST:laya.d3.core.render.ScreenQuad.SCREENQUAD_POSITION_UV*/0)]);},'_vertices',function(){return this._vertices=new Float32Array([1,1,1,0,1,-1,1,1,-1,1,0,0,-1,-1,0,1]);}
  29422. ]);
  29423. return ScreenQuad;
  29424. })(Resource)
  29425. /**
  29426. *<code>Avatar</code> 类用于创建Avatar。
  29427. */
  29428. //class laya.d3.core.Avatar extends laya.resource.Resource
  29429. var Avatar=(function(_super){
  29430. function Avatar(){
  29431. /**@private */
  29432. this._rootNode=null;
  29433. /**@private [NATIVE]*/
  29434. this._nativeNodeCount=0;
  29435. /**@private [NATIVE]*/
  29436. this._nativeCurCloneCount=0;
  29437. Avatar.__super.call(this);
  29438. }
  29439. __class(Avatar,'laya.d3.core.Avatar',_super);
  29440. var __proto=Avatar.prototype;
  29441. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  29442. /**
  29443. *@private
  29444. */
  29445. __proto._initCloneToAnimator=function(destNode,destAnimator){
  29446. destAnimator._avatarNodeMap[destNode.name]=destNode;
  29447. for (var i=0,n=destNode.getChildCount();i < n;i++)
  29448. this._initCloneToAnimator(destNode.getChildByIndex(i),destAnimator);
  29449. }
  29450. /**
  29451. *@private
  29452. */
  29453. __proto._parseNode=function(nodaData,node){
  29454. var name=nodaData.props.name;
  29455. node.name=name;
  29456. var props=nodaData.props;
  29457. var transform=node.transform;
  29458. var pos=transform.localPosition;
  29459. var rot=transform.localRotation;
  29460. var sca=transform.localScale;
  29461. pos.fromArray(props.translate);
  29462. rot.fromArray(props.rotation);
  29463. sca.fromArray(props.scale);
  29464. transform.localPosition=pos;
  29465. transform.localRotation=rot;
  29466. transform.localScale=sca;
  29467. var childrenData=nodaData.child;
  29468. for (var j=0,n=childrenData.length;j < n;j++){
  29469. var childData=childrenData[j];
  29470. var childBone=new AnimationNode(new Float32Array(3),new Float32Array(4),new Float32Array(3),new Float32Array(16));
  29471. node.addChild(childBone);
  29472. if (Render.supportWebGLPlusAnimation)
  29473. this._nativeNodeCount++;
  29474. this._parseNode(childData,childBone);
  29475. }
  29476. }
  29477. /**
  29478. *克隆数据到Avatr。
  29479. *@param destObject 克隆源。
  29480. */
  29481. __proto._cloneDatasToAnimator=function(destAnimator){
  29482. var destRoot;
  29483. destRoot=this._rootNode.clone();
  29484. var transform=this._rootNode.transform;
  29485. var destTransform=destRoot.transform;
  29486. var destPosition=destTransform.localPosition;
  29487. var destRotation=destTransform.localRotation;
  29488. var destScale=destTransform.localScale;
  29489. transform.localPosition.cloneTo(destPosition);
  29490. transform.localRotation.cloneTo(destRotation);
  29491. transform.localScale.cloneTo(destScale);
  29492. destTransform.localPosition=destPosition;
  29493. destTransform.localRotation=destRotation;
  29494. destTransform.localScale=destScale;
  29495. destAnimator._avatarNodeMap={};
  29496. this._initCloneToAnimator(destRoot,destAnimator);
  29497. }
  29498. /**
  29499. *克隆。
  29500. *@param destObject 克隆源。
  29501. */
  29502. __proto.cloneTo=function(destObject){
  29503. var destAvatar=destObject;
  29504. var destRoot=this._rootNode.clone();
  29505. destAvatar._rootNode=destRoot;
  29506. }
  29507. /**
  29508. *克隆。
  29509. *@return 克隆副本。
  29510. */
  29511. __proto.clone=function(){
  29512. var dest=/*__JS__ */new this.constructor();
  29513. this.cloneTo(dest);
  29514. return dest;
  29515. }
  29516. /**
  29517. *@private [NATIVE]
  29518. */
  29519. __proto._cloneDatasToAnimatorNative=function(destAnimator){
  29520. var animationNodeLocalPositions=new Float32Array(this._nativeNodeCount *3);
  29521. var animationNodeLocalRotations=new Float32Array(this._nativeNodeCount *4);
  29522. var animationNodeLocalScales=new Float32Array(this._nativeNodeCount *3);
  29523. var animationNodeWorldMatrixs=new Float32Array(this._nativeNodeCount *16);
  29524. var animationNodeParentIndices=new Int16Array(this._nativeNodeCount);
  29525. destAnimator._animationNodeLocalPositions=animationNodeLocalPositions;
  29526. destAnimator._animationNodeLocalRotations=animationNodeLocalRotations;
  29527. destAnimator._animationNodeLocalScales=animationNodeLocalScales;
  29528. destAnimator._animationNodeWorldMatrixs=animationNodeWorldMatrixs;
  29529. destAnimator._animationNodeParentIndices=animationNodeParentIndices;
  29530. this._nativeCurCloneCount=0;
  29531. var destRoot=this._rootNode._cloneNative(animationNodeLocalPositions,animationNodeLocalRotations,animationNodeLocalScales,animationNodeWorldMatrixs,animationNodeParentIndices,-1,this);
  29532. var transform=this._rootNode.transform;
  29533. var destTransform=destRoot.transform;
  29534. var destPosition=destTransform.localPosition;
  29535. var destRotation=destTransform.localRotation;
  29536. var destScale=destTransform.localScale;
  29537. transform.localPosition.cloneTo(destPosition);
  29538. transform.localRotation.cloneTo(destRotation);
  29539. transform.localScale.cloneTo(destScale);
  29540. destTransform.localPosition=destPosition;
  29541. destTransform.localRotation=destRotation;
  29542. destTransform.localScale=destScale;
  29543. destAnimator._avatarNodeMap={};
  29544. this._initCloneToAnimator(destRoot,destAnimator);
  29545. }
  29546. Avatar._parse=function(data,propertyParams,constructParams){
  29547. var avatar=new Avatar();
  29548. avatar._rootNode=new AnimationNode(new Float32Array(3),new Float32Array(4),new Float32Array(3),new Float32Array(16));
  29549. if (Render.supportWebGLPlusAnimation)
  29550. avatar._nativeNodeCount++;
  29551. if (data.version){
  29552. var rootNode=data.rootNode;
  29553. (rootNode)&& (avatar._parseNode(rootNode,avatar._rootNode));
  29554. }
  29555. return avatar;
  29556. }
  29557. Avatar.load=function(url,complete){
  29558. Laya.loader.create(url,complete,null,/*Laya3D.AVATAR*/"AVATAR");
  29559. }
  29560. return Avatar;
  29561. })(Resource)
  29562. /**
  29563. *<code>Mesh</code> 类用于创建文件网格数据模板。
  29564. */
  29565. //class laya.d3.resource.models.Mesh extends laya.resource.Resource
  29566. var Mesh=(function(_super){
  29567. function Mesh(){
  29568. /**@private */
  29569. this._nativeTriangleMesh=null;
  29570. /**@private */
  29571. this._bounds=null;
  29572. /**@private */
  29573. this._subMeshCount=0;
  29574. /**@private */
  29575. this._subMeshes=null;
  29576. /**@private */
  29577. this._vertexBuffers=null;
  29578. /**@private */
  29579. this._indexBuffer=null;
  29580. /**@private */
  29581. this._boneNames=null;
  29582. /**@private */
  29583. this._inverseBindPoses=null;
  29584. /**@private */
  29585. this._inverseBindPosesBuffer=null;
  29586. /**@private */
  29587. this._bindPoseIndices=null;
  29588. /**@private */
  29589. this._skinDataPathMarks=null;
  29590. /**@private */
  29591. this._vertexCount=0;
  29592. this._tempVector30=new Vector3()
  29593. this._tempVector31=new Vector3();
  29594. this._tempVector32=new Vector3();
  29595. this._bufferState=new BufferState();
  29596. this._instanceBufferState=new BufferState();
  29597. Mesh.__super.call(this);
  29598. this._subMeshes=[];
  29599. this._vertexBuffers=[];
  29600. this._skinDataPathMarks=[];
  29601. }
  29602. __class(Mesh,'laya.d3.resource.models.Mesh',_super);
  29603. var __proto=Mesh.prototype;
  29604. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  29605. /**
  29606. *@private
  29607. */
  29608. __proto._getPositionElement=function(vertexBuffer){
  29609. var vertexElements=vertexBuffer.vertexDeclaration.vertexElements;
  29610. for (var i=0,n=vertexElements.length;i < n;i++){
  29611. var vertexElement=vertexElements[i];
  29612. if (vertexElement.elementFormat===/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3" && vertexElement.elementUsage===/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0)
  29613. return vertexElement;
  29614. }
  29615. return null;
  29616. }
  29617. /**
  29618. *@private
  29619. */
  29620. __proto._generateBoundingObject=function(){
  29621. var min=this._tempVector30;
  29622. var max=this._tempVector31;
  29623. min.x=min.y=min.z=Number.MAX_VALUE;
  29624. max.x=max.y=max.z=-Number.MAX_VALUE;
  29625. var vertexBufferCount=this._vertexBuffers.length;
  29626. for (var i=0;i < vertexBufferCount;i++){
  29627. var vertexBuffer=this._vertexBuffers[i];
  29628. var positionElement=this._getPositionElement(vertexBuffer);
  29629. var verticesData=vertexBuffer.getData();
  29630. var floatCount=vertexBuffer.vertexDeclaration.vertexStride / 4;
  29631. var posOffset=positionElement.offset / 4;
  29632. for (var j=0,m=verticesData.length;j < m;j+=floatCount){
  29633. var ofset=j+posOffset;
  29634. var pX=verticesData[ofset];
  29635. var pY=verticesData[ofset+1];
  29636. var pZ=verticesData[ofset+2];
  29637. min.x=Math.min(min.x,pX);
  29638. min.y=Math.min(min.y,pY);
  29639. min.z=Math.min(min.z,pZ);
  29640. max.x=Math.max(max.x,pX);
  29641. max.y=Math.max(max.y,pY);
  29642. max.z=Math.max(max.z,pZ);
  29643. }
  29644. }
  29645. this._bounds=new Bounds(min,max);
  29646. }
  29647. /**
  29648. *@private
  29649. */
  29650. __proto._setSubMeshes=function(subMeshes){
  29651. this._subMeshes=subMeshes
  29652. this._subMeshCount=subMeshes.length;
  29653. for (var i=0;i < this._subMeshCount;i++)
  29654. subMeshes[i]._indexInMesh=i;
  29655. this._generateBoundingObject();
  29656. }
  29657. /**
  29658. *@inheritDoc
  29659. */
  29660. __proto._getSubMesh=function(index){
  29661. return this._subMeshes[index];
  29662. }
  29663. /**
  29664. *@private
  29665. */
  29666. __proto._setBuffer=function(vertexBuffers,indexBuffer){
  29667. var bufferState=this._bufferState;
  29668. bufferState.bind();
  29669. bufferState.applyVertexBuffers(vertexBuffers);
  29670. bufferState.applyIndexBuffer(indexBuffer);
  29671. bufferState.unBind();
  29672. var instanceBufferState=this._instanceBufferState;
  29673. instanceBufferState.bind();
  29674. instanceBufferState.applyVertexBuffers(vertexBuffers);
  29675. instanceBufferState.applyInstanceVertexBuffer(SubMeshInstanceBatch.instance.instanceWorldMatrixBuffer);
  29676. instanceBufferState.applyInstanceVertexBuffer(SubMeshInstanceBatch.instance.instanceMVPMatrixBuffer);
  29677. instanceBufferState.applyIndexBuffer(indexBuffer);
  29678. instanceBufferState.unBind();
  29679. }
  29680. /**
  29681. *@inheritDoc
  29682. */
  29683. __proto._disposeResource=function(){
  29684. for (var i=0,n=this._subMeshes.length;i < n;i++)
  29685. this._subMeshes[i].destroy();
  29686. this._nativeTriangleMesh && Laya3D._physics3D.destroy(this._nativeTriangleMesh);
  29687. for (i=0,n=this._vertexBuffers.length;i < n;i++)
  29688. this._vertexBuffers[i].destroy();
  29689. this._indexBuffer.destroy();
  29690. this._setCPUMemory(0);
  29691. this._setGPUMemory(0);
  29692. this._bufferState.destroy();
  29693. this._instanceBufferState.destroy();
  29694. this._bufferState=null;
  29695. this._instanceBufferState=null;
  29696. this._vertexBuffers=null;
  29697. this._indexBuffer=null;
  29698. this._subMeshes=null;
  29699. this._nativeTriangleMesh=null;
  29700. this._vertexBuffers=null;
  29701. this._indexBuffer=null;
  29702. this._boneNames=null;
  29703. this._inverseBindPoses=null;
  29704. }
  29705. /**
  29706. *@private
  29707. */
  29708. __proto._getPhysicMesh=function(){
  29709. if (!this._nativeTriangleMesh){
  29710. var physics3D=Laya3D._physics3D;
  29711. var triangleMesh=new physics3D.btTriangleMesh();
  29712. var nativePositio0=Mesh._nativeTempVector30;
  29713. var nativePositio1=Mesh._nativeTempVector31;
  29714. var nativePositio2=Mesh._nativeTempVector32;
  29715. var position0=this._tempVector30;
  29716. var position1=this._tempVector31;
  29717. var position2=this._tempVector32;
  29718. var vertexBuffer=this._vertexBuffers[0];
  29719. var positionElement=this._getPositionElement(vertexBuffer);
  29720. var verticesData=vertexBuffer.getData();
  29721. var floatCount=vertexBuffer.vertexDeclaration.vertexStride / 4;
  29722. var posOffset=positionElement.offset / 4;
  29723. var indices=this._indexBuffer.getData();
  29724. for (var i=0,n=indices.length;i < n;i+=3){
  29725. var p0Index=indices[i] *floatCount+posOffset;
  29726. var p1Index=indices[i+1] *floatCount+posOffset;
  29727. var p2Index=indices[i+2] *floatCount+posOffset;
  29728. position0.setValue(verticesData[p0Index],verticesData[p0Index+1],verticesData[p0Index+2]);
  29729. position1.setValue(verticesData[p1Index],verticesData[p1Index+1],verticesData[p1Index+2]);
  29730. position2.setValue(verticesData[p2Index],verticesData[p2Index+1],verticesData[p2Index+2]);
  29731. Utils3D._convertToBulletVec3(position0,nativePositio0,true);
  29732. Utils3D._convertToBulletVec3(position1,nativePositio1,true);
  29733. Utils3D._convertToBulletVec3(position2,nativePositio2,true);
  29734. triangleMesh.addTriangle(nativePositio0,nativePositio1,nativePositio2,true);
  29735. }
  29736. this._nativeTriangleMesh=triangleMesh;
  29737. }
  29738. return this._nativeTriangleMesh;
  29739. }
  29740. /**
  29741. *克隆。
  29742. *@param destObject 克隆源。
  29743. */
  29744. __proto.cloneTo=function(destObject){
  29745. var destMesh=destObject;
  29746. for (var i=0;i < this._vertexBuffers.length;i++){
  29747. var vb=this._vertexBuffers[i];
  29748. var destVB=new VertexBuffer3D(vb._byteLength,vb.bufferUsage,vb.canRead);
  29749. destVB.vertexDeclaration=vb.vertexDeclaration;
  29750. destVB.setData(vb.getData().slice());
  29751. destMesh._vertexBuffers.push(destVB);
  29752. destMesh._vertexCount+=destVB.vertexCount;
  29753. };
  29754. var ib=this._indexBuffer;
  29755. var destIB=new IndexBuffer3D(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",ib.indexCount,ib.bufferUsage,ib.canRead);
  29756. destIB.setData(ib.getData().slice());
  29757. destMesh._indexBuffer=destIB;
  29758. destMesh._setBuffer(destMesh._vertexBuffers,destIB);
  29759. destMesh._setCPUMemory(this.cpuMemory);
  29760. destMesh._setGPUMemory(this.gpuMemory);
  29761. var boneNames=this._boneNames;
  29762. var destBoneNames=destMesh._boneNames=__newvec(boneNames.length);
  29763. for (i=0;i < boneNames.length;i++)
  29764. destBoneNames[i]=boneNames[i];
  29765. var inverseBindPoses=this._inverseBindPoses;
  29766. var destInverseBindPoses=destMesh._inverseBindPoses=__newvec(inverseBindPoses.length);
  29767. for (i=0;i < inverseBindPoses.length;i++)
  29768. destInverseBindPoses[i]=inverseBindPoses[i];
  29769. destMesh._bindPoseIndices=new Uint16Array(this._bindPoseIndices);
  29770. for (i=0;i < this._skinDataPathMarks.length;i++)
  29771. destMesh._skinDataPathMarks[i]=this._skinDataPathMarks[i].slice();
  29772. for (i=0;i < this.subMeshCount;i++){
  29773. var subMesh=this._subMeshes[i];
  29774. var subIndexBufferStart=subMesh._subIndexBufferStart;
  29775. var subIndexBufferCount=subMesh._subIndexBufferCount;
  29776. var boneIndicesList=subMesh._boneIndicesList;
  29777. var destSubmesh=new SubMesh(destMesh);
  29778. destSubmesh._subIndexBufferStart.length=subIndexBufferStart.length;
  29779. destSubmesh._subIndexBufferCount.length=subIndexBufferCount.length;
  29780. destSubmesh._boneIndicesList.length=boneIndicesList.length;
  29781. for (var j=0;j < subIndexBufferStart.length;j++)
  29782. destSubmesh._subIndexBufferStart[j]=subIndexBufferStart[j];
  29783. for (j=0;j < subIndexBufferCount.length;j++)
  29784. destSubmesh._subIndexBufferCount[j]=subIndexBufferCount[j];
  29785. for (j=0;j < boneIndicesList.length;j++)
  29786. destSubmesh._boneIndicesList[j]=new Uint16Array(boneIndicesList[j]);
  29787. destSubmesh._indexBuffer=destIB;
  29788. destSubmesh._indexStart=subMesh._indexStart;
  29789. destSubmesh._indexCount=subMesh._indexCount;
  29790. destSubmesh._indices=new Uint16Array(destIB.getData().buffer,subMesh._indexStart *2,subMesh._indexCount);
  29791. var vertexBuffer=destMesh._vertexBuffers[0];
  29792. destSubmesh._vertexBuffer=vertexBuffer;
  29793. destMesh._subMeshes.push(destSubmesh);
  29794. }
  29795. destMesh._setSubMeshes(destMesh._subMeshes);
  29796. }
  29797. /**
  29798. *克隆。
  29799. *@return 克隆副本。
  29800. */
  29801. __proto.clone=function(){
  29802. var dest=/*__JS__ */new this.constructor();
  29803. this.cloneTo(dest);
  29804. return dest;
  29805. }
  29806. /**
  29807. *获取网格的全局默认绑定动作逆矩阵。
  29808. *@return 网格的全局默认绑定动作逆矩阵。
  29809. */
  29810. __getset(0,__proto,'inverseAbsoluteBindPoses',function(){
  29811. return this._inverseBindPoses;
  29812. });
  29813. /**
  29814. *获取顶点个数
  29815. */
  29816. __getset(0,__proto,'vertexCount',function(){
  29817. return this._vertexCount;
  29818. });
  29819. /**
  29820. *获取SubMesh的个数。
  29821. *@return SubMesh的个数。
  29822. */
  29823. __getset(0,__proto,'subMeshCount',function(){
  29824. return this._subMeshCount;
  29825. });
  29826. /**
  29827. *获取边界
  29828. *@return 边界。
  29829. */
  29830. __getset(0,__proto,'bounds',function(){
  29831. return this._bounds;
  29832. });
  29833. Mesh._parse=function(data,propertyParams,constructParams){
  29834. var mesh=new Mesh();
  29835. MeshReader.read(data,mesh,mesh._subMeshes);
  29836. return mesh;
  29837. }
  29838. Mesh.load=function(url,complete){
  29839. Laya.loader.create(url,complete,null,/*Laya3D.MESH*/"MESH");
  29840. }
  29841. __static(Mesh,
  29842. ['_nativeTempVector30',function(){return this._nativeTempVector30=new Laya3D._physics3D.btVector3(0,0,0);},'_nativeTempVector31',function(){return this._nativeTempVector31=new Laya3D._physics3D.btVector3(0,0,0);},'_nativeTempVector32',function(){return this._nativeTempVector32=new Laya3D._physics3D.btVector3(0,0,0);}
  29843. ]);
  29844. return Mesh;
  29845. })(Resource)
  29846. /**
  29847. *<code>TerrainHeightData</code> 类用于描述地形高度信息。
  29848. */
  29849. //class laya.d3.terrain.TerrainHeightData extends laya.resource.Resource
  29850. var TerrainHeightData=(function(_super){
  29851. function TerrainHeightData(width,height,bitType,value){
  29852. this._terrainHeightData=null;
  29853. this._width=0;
  29854. this._height=0;
  29855. this._bitType=0;
  29856. this._value=NaN;
  29857. TerrainHeightData.__super.call(this);
  29858. this._width=width;
  29859. this._height=height;
  29860. this._bitType=bitType;
  29861. this._value=value;
  29862. }
  29863. __class(TerrainHeightData,'laya.d3.terrain.TerrainHeightData',_super);
  29864. TerrainHeightData._pharse=function(data,propertyParams,constructParams){
  29865. var terrainHeightData=new TerrainHeightData(constructParams[0],constructParams[1],constructParams[2],constructParams[3]);
  29866. var buffer;
  29867. var ratio=NaN;
  29868. if (terrainHeightData._bitType==8){
  29869. buffer=new Uint8Array(data);
  29870. ratio=1.0 / 255.0;
  29871. }else if (terrainHeightData._bitType==16){
  29872. buffer=new Int16Array(data);
  29873. ratio=1.0 / 32766.0;
  29874. }
  29875. terrainHeightData._terrainHeightData=new Float32Array(terrainHeightData._height *terrainHeightData._width);
  29876. for (var i=0,n=terrainHeightData._height *terrainHeightData._width;i < n;i++){
  29877. terrainHeightData._terrainHeightData[i]=(buffer[i] *ratio *terrainHeightData._value)/ 2;
  29878. }
  29879. }
  29880. TerrainHeightData.load=function(url,complete,widht,height,bitType,value){
  29881. Laya.loader.create(url,complete,null,/*Laya3D.TERRAINHEIGHTDATA*/"TERRAINHEIGHTDATA",[widht,height,bitType,value],null,1,false);
  29882. }
  29883. return TerrainHeightData;
  29884. })(Resource)
  29885. /**
  29886. *<code>AnimationClip</code> 类用于动画片段资源。
  29887. */
  29888. //class laya.d3.animation.AnimationClip extends laya.resource.Resource
  29889. var AnimationClip=(function(_super){
  29890. function AnimationClip(){
  29891. /**@private */
  29892. //this._duration=NaN;
  29893. /**@private */
  29894. //this._frameRate=0;
  29895. /**@private */
  29896. //this._nodesDic=null;
  29897. /**@private */
  29898. //this._nodesMap=null;
  29899. /**@private */
  29900. //this._events=null;
  29901. /**是否循环。*/
  29902. //this.islooping=false;
  29903. AnimationClip.__super.call(this);
  29904. this._nodes=new KeyframeNodeList();
  29905. this._events=[];
  29906. }
  29907. __class(AnimationClip,'laya.d3.animation.AnimationClip',_super);
  29908. var __proto=AnimationClip.prototype;
  29909. /**
  29910. *获取动画片段时长。
  29911. */
  29912. __proto.duration=function(){
  29913. return this._duration;
  29914. }
  29915. /**
  29916. *@private
  29917. */
  29918. __proto._hermiteInterpolate=function(frame,nextFrame,t,dur){
  29919. var t0=frame.outTangent,t1=nextFrame.inTangent;
  29920. if (/*__JS__ */Number.isFinite(t0)&& Number.isFinite(t1)){
  29921. var t2=t *t;
  29922. var t3=t2 *t;
  29923. var a=2.0 *t3-3.0 *t2+1.0;
  29924. var b=t3-2.0 *t2+t;
  29925. var c=t3-t2;
  29926. var d=-2.0 *t3+3.0 *t2;
  29927. return a *frame.value+b *t0 *dur+c *t1 *dur+d *nextFrame.value;
  29928. }else
  29929. return frame.value;
  29930. }
  29931. /**
  29932. *@private
  29933. */
  29934. __proto._hermiteInterpolateVector3=function(frame,nextFrame,t,dur,out){
  29935. var p0=frame.value;
  29936. var tan0=frame.outTangent;
  29937. var p1=nextFrame.value;
  29938. var tan1=nextFrame.inTangent;
  29939. var t2=t *t;
  29940. var t3=t2 *t;
  29941. var a=2.0 *t3-3.0 *t2+1.0;
  29942. var b=t3-2.0 *t2+t;
  29943. var c=t3-t2;
  29944. var d=-2.0 *t3+3.0 *t2;
  29945. var t0=tan0.x,t1=tan1.x;
  29946. if (/*__JS__ */Number.isFinite(t0)&& Number.isFinite(t1))
  29947. out.x=a *p0.x+b *t0 *dur+c *t1 *dur+d *p1.x;
  29948. else
  29949. out.x=p0.x;
  29950. t0=tan0.y,t1=tan1.y;
  29951. if (/*__JS__ */Number.isFinite(t0)&& Number.isFinite(t1))
  29952. out.y=a *p0.y+b *t0 *dur+c *t1 *dur+d *p1.y;
  29953. else
  29954. out.y=p0.y;
  29955. t0=tan0.z,t1=tan1.z;
  29956. if (/*__JS__ */Number.isFinite(t0)&& Number.isFinite(t1))
  29957. out.z=a *p0.z+b *t0 *dur+c *t1 *dur+d *p1.z;
  29958. else
  29959. out.z=p0.z;
  29960. }
  29961. /**
  29962. *@private
  29963. */
  29964. __proto._hermiteInterpolateQuaternion=function(frame,nextFrame,t,dur,out){
  29965. var p0=frame.value;
  29966. var tan0=frame.outTangent;
  29967. var p1=nextFrame.value;
  29968. var tan1=nextFrame.inTangent;
  29969. var t2=t *t;
  29970. var t3=t2 *t;
  29971. var a=2.0 *t3-3.0 *t2+1.0;
  29972. var b=t3-2.0 *t2+t;
  29973. var c=t3-t2;
  29974. var d=-2.0 *t3+3.0 *t2;
  29975. var t0=tan0.x,t1=tan1.x;
  29976. if (/*__JS__ */Number.isFinite(t0)&& Number.isFinite(t1))
  29977. out.x=a *p0.x+b *t0 *dur+c *t1 *dur+d *p1.x;
  29978. else
  29979. out.x=p0.x;
  29980. t0=tan0.y,t1=tan1.y;
  29981. if (/*__JS__ */Number.isFinite(t0)&& Number.isFinite(t1))
  29982. out.y=a *p0.y+b *t0 *dur+c *t1 *dur+d *p1.y;
  29983. else
  29984. out.y=p0.y;
  29985. t0=tan0.z,t1=tan1.z;
  29986. if (/*__JS__ */Number.isFinite(t0)&& Number.isFinite(t1))
  29987. out.z=a *p0.z+b *t0 *dur+c *t1 *dur+d *p1.z;
  29988. else
  29989. out.z=p0.z;
  29990. t0=tan0.w,t1=tan1.w;
  29991. if (/*__JS__ */Number.isFinite(t0)&& Number.isFinite(t1))
  29992. out.w=a *p0.w+b *t0 *dur+c *t1 *dur+d *p1.w;
  29993. else
  29994. out.w=p0.w;
  29995. }
  29996. /**
  29997. *@private
  29998. */
  29999. __proto._evaluateClipDatasRealTime=function(nodes,playCurTime,realTimeCurrentFrameIndexes,addtive,frontPlay){
  30000. for (var i=0,n=nodes.count;i < n;i++){
  30001. var node=nodes.getNodeByIndex(i);
  30002. var type=node.type;
  30003. var nextFrameIndex=0;
  30004. var keyFrames=node._keyFrames;
  30005. var keyFramesCount=keyFrames.length;
  30006. var frameIndex=realTimeCurrentFrameIndexes[i];
  30007. if (frontPlay){
  30008. if ((frameIndex!==-1)&& (playCurTime < keyFrames[frameIndex].time)){
  30009. frameIndex=-1;
  30010. realTimeCurrentFrameIndexes[i]=frameIndex;
  30011. }
  30012. nextFrameIndex=frameIndex+1;
  30013. while (nextFrameIndex < keyFramesCount){
  30014. if (keyFrames[nextFrameIndex].time > playCurTime)
  30015. break ;
  30016. frameIndex++;
  30017. nextFrameIndex++;
  30018. realTimeCurrentFrameIndexes[i]=frameIndex;
  30019. }
  30020. }else {
  30021. nextFrameIndex=frameIndex+1;
  30022. if ((nextFrameIndex!==keyFramesCount)&& (playCurTime > keyFrames[nextFrameIndex].time)){
  30023. frameIndex=keyFramesCount-1;
  30024. realTimeCurrentFrameIndexes[i]=frameIndex;
  30025. }
  30026. nextFrameIndex=frameIndex+1;
  30027. while (frameIndex >-1){
  30028. if (keyFrames[frameIndex].time < playCurTime)
  30029. break ;
  30030. frameIndex--;
  30031. nextFrameIndex--;
  30032. realTimeCurrentFrameIndexes[i]=frameIndex;
  30033. }
  30034. };
  30035. var isEnd=nextFrameIndex===keyFramesCount;
  30036. switch (type){
  30037. case 0:
  30038. if (frameIndex!==-1){
  30039. var frame=keyFrames [frameIndex];
  30040. if (isEnd){
  30041. node.data=frame.value;
  30042. }else {
  30043. var nextFarme=keyFrames [nextFrameIndex];
  30044. var d=nextFarme.time-frame.time;
  30045. var t=NaN;
  30046. if (d!==0)
  30047. t=(playCurTime-frame.time)/ d;
  30048. else
  30049. t=0;
  30050. node.data=this._hermiteInterpolate(frame,nextFarme,t,d);
  30051. }
  30052. }else {
  30053. node.data=(keyFrames [0]).value;
  30054. }
  30055. if (addtive)
  30056. node.data-=(keyFrames [0]).value;
  30057. break ;
  30058. case 1:
  30059. case 4:;
  30060. var clipData=node.data;
  30061. this._evaluateFrameNodeVector3DatasRealTime(keyFrames,frameIndex,isEnd,playCurTime,clipData);
  30062. if (addtive){
  30063. var firstFrameValue=(keyFrames [0]).value;
  30064. clipData.x-=firstFrameValue.x;
  30065. clipData.y-=firstFrameValue.y;
  30066. clipData.z-=firstFrameValue.z;
  30067. }
  30068. break ;
  30069. case 2:;
  30070. var clipQuat=node.data;
  30071. this._evaluateFrameNodeQuaternionDatasRealTime(keyFrames,frameIndex,isEnd,playCurTime,clipQuat);
  30072. if (addtive){
  30073. var tempQuat=AnimationClip._tempQuaternion0;
  30074. var firstFrameValueQua=(keyFrames [0]).value;
  30075. Utils3D.quaternionConjugate(firstFrameValueQua,tempQuat);
  30076. Quaternion.multiply(tempQuat,clipQuat,clipQuat);
  30077. }
  30078. break ;
  30079. case 3:
  30080. clipData=node.data;
  30081. this._evaluateFrameNodeVector3DatasRealTime(keyFrames,frameIndex,isEnd,playCurTime,clipData);
  30082. if (addtive){
  30083. firstFrameValue=(keyFrames [0]).value;
  30084. clipData.x /=firstFrameValue.x;
  30085. clipData.y /=firstFrameValue.y;
  30086. clipData.z /=firstFrameValue.z;
  30087. }
  30088. break ;
  30089. default :
  30090. throw "AnimationClip:unknown node type.";
  30091. }
  30092. }
  30093. }
  30094. __proto._evaluateClipDatasRealTimeForNative=function(nodes,playCurTime,realTimeCurrentFrameIndexes,addtive){
  30095. LayaGL.instance.evaluateClipDatasRealTime(nodes._nativeObj,playCurTime,realTimeCurrentFrameIndexes,addtive);
  30096. }
  30097. /**
  30098. *@private
  30099. */
  30100. __proto._evaluateFrameNodeVector3DatasRealTime=function(keyFrames,frameIndex,isEnd,playCurTime,outDatas){
  30101. if (frameIndex!==-1){
  30102. var frame=keyFrames[frameIndex];
  30103. if (isEnd){
  30104. var frameData=frame.value;
  30105. outDatas.x=frameData.x;
  30106. outDatas.y=frameData.y;
  30107. outDatas.z=frameData.z;
  30108. }else {
  30109. var nextKeyFrame=keyFrames[frameIndex+1];
  30110. var t=NaN;
  30111. var startTime=frame.time;
  30112. var d=nextKeyFrame.time-startTime;
  30113. if (d!==0)
  30114. t=(playCurTime-startTime)/ d;
  30115. else
  30116. t=0;
  30117. this._hermiteInterpolateVector3(frame,nextKeyFrame,t,d,outDatas);
  30118. }
  30119. }else {
  30120. var firstFrameDatas=keyFrames[0].value;
  30121. outDatas.x=firstFrameDatas.x;
  30122. outDatas.y=firstFrameDatas.y;
  30123. outDatas.z=firstFrameDatas.z;
  30124. }
  30125. }
  30126. /**
  30127. *@private
  30128. */
  30129. __proto._evaluateFrameNodeQuaternionDatasRealTime=function(keyFrames,frameIndex,isEnd,playCurTime,outDatas){
  30130. if (frameIndex!==-1){
  30131. var frame=keyFrames[frameIndex];
  30132. if (isEnd){
  30133. var frameData=frame.value;
  30134. outDatas.x=frameData.x;
  30135. outDatas.y=frameData.y;
  30136. outDatas.z=frameData.z;
  30137. outDatas.w=frameData.w;
  30138. }else {
  30139. var nextKeyFrame=keyFrames[frameIndex+1];
  30140. var t=NaN;
  30141. var startTime=frame.time;
  30142. var d=nextKeyFrame.time-startTime;
  30143. if (d!==0)
  30144. t=(playCurTime-startTime)/ d;
  30145. else
  30146. t=0;
  30147. this._hermiteInterpolateQuaternion(frame,nextKeyFrame,t,d,outDatas);
  30148. }
  30149. }else {
  30150. var firstFrameDatas=keyFrames[0].value;
  30151. outDatas.x=firstFrameDatas.x;
  30152. outDatas.y=firstFrameDatas.y;
  30153. outDatas.z=firstFrameDatas.z;
  30154. outDatas.w=firstFrameDatas.w;
  30155. }
  30156. }
  30157. /**
  30158. *@private
  30159. */
  30160. __proto._binarySearchEventIndex=function(time){
  30161. var start=0;
  30162. var end=this._events.length-1;
  30163. var mid=0;
  30164. while (start <=end){
  30165. mid=Math.floor((start+end)/ 2);
  30166. var midValue=this._events[mid].time;
  30167. if (midValue==time)
  30168. return mid;
  30169. else if (midValue > time)
  30170. end=mid-1;
  30171. else
  30172. start=mid+1;
  30173. }
  30174. return start;
  30175. }
  30176. /**
  30177. *添加动画事件。
  30178. */
  30179. __proto.addEvent=function(event){
  30180. var index=this._binarySearchEventIndex(event.time);
  30181. this._events.splice(index,0,event);
  30182. }
  30183. /**
  30184. *@inheritDoc
  30185. */
  30186. __proto._disposeResource=function(){
  30187. this._nodes=null;
  30188. this._nodesMap=null;
  30189. }
  30190. AnimationClip._parse=function(data,propertyParams,constructParams){
  30191. var clip=new AnimationClip();
  30192. var reader=new Byte(data);
  30193. var version=reader.readUTFString();
  30194. switch (version){
  30195. case "LAYAANIMATION:03":
  30196. AnimationClipParser03.parse(clip,reader);
  30197. break ;
  30198. case "LAYAANIMATION:04":
  30199. case "LAYAANIMATION:COMPRESSION_04":
  30200. AnimationClipParser04.parse(clip,reader,version);
  30201. break ;
  30202. default :
  30203. throw "unknown animationClip version.";
  30204. }
  30205. return clip;
  30206. }
  30207. AnimationClip.load=function(url,complete){
  30208. Laya.loader.create(url,complete,null,/*Laya3D.ANIMATIONCLIP*/"ANIMATIONCLIP");
  30209. }
  30210. __static(AnimationClip,
  30211. ['_tempQuaternion0',function(){return this._tempQuaternion0=new Quaternion();}
  30212. ]);
  30213. return AnimationClip;
  30214. })(Resource)
  30215. /**
  30216. *@private
  30217. *<code>ShaderInstance</code> 类用于实现ShaderInstance。
  30218. */
  30219. //class laya.d3.shader.ShaderInstance extends laya.resource.Resource
  30220. var ShaderInstance=(function(_super){
  30221. function ShaderInstance(vs,ps,attributeMap,uniformMap,shaderPass){
  30222. /**@private */
  30223. //this._attributeMap=null;
  30224. /**@private */
  30225. //this._uniformMap=null;
  30226. /**@private */
  30227. //this._shaderPass=null;
  30228. /**@private */
  30229. //this._vs=null;
  30230. /**@private */
  30231. //this._ps=null;
  30232. /**@private */
  30233. //this._curActTexIndex=0;
  30234. /**@private */
  30235. //this._vshader=null;
  30236. /**@private */
  30237. //this._pshader=null;
  30238. /**@private */
  30239. //this._program=null;
  30240. /**@private */
  30241. //this._sceneUniformParamsMap=null;
  30242. /**@private */
  30243. //this._cameraUniformParamsMap=null;
  30244. /**@private */
  30245. //this._spriteUniformParamsMap=null;
  30246. /**@private */
  30247. //this._materialUniformParamsMap=null;
  30248. /**@private */
  30249. //this._customUniformParamsMap=null;
  30250. /**@private */
  30251. this._stateParamsMap=[];
  30252. /**@private */
  30253. this._uploadMark=-1;
  30254. /**@private */
  30255. //this._uploadMaterial=null;
  30256. /**@private */
  30257. //this._uploadRender=null;
  30258. /**@private */
  30259. this._uploadRenderType=-1;
  30260. /**@private */
  30261. //this._uploadCamera=null;
  30262. /**@private */
  30263. //this._uploadScene=null;
  30264. ShaderInstance.__super.call(this);
  30265. this._vs=vs;
  30266. this._ps=ps;
  30267. this._attributeMap=attributeMap;
  30268. this._uniformMap=uniformMap;
  30269. this._shaderPass=shaderPass;
  30270. this._create();
  30271. this.lock=true;
  30272. }
  30273. __class(ShaderInstance,'laya.d3.shader.ShaderInstance',_super);
  30274. var __proto=ShaderInstance.prototype;
  30275. /**
  30276. *@private
  30277. */
  30278. __proto._create=function(){
  30279. var gl=LayaGL.instance;
  30280. this._program=gl.createProgram();
  30281. this._vshader=this._createShader(gl,this._vs,/*laya.webgl.WebGLContext.VERTEX_SHADER*/0x8B31);
  30282. this._pshader=this._createShader(gl,this._ps,/*laya.webgl.WebGLContext.FRAGMENT_SHADER*/0x8B30);
  30283. gl.attachShader(this._program,this._vshader);
  30284. gl.attachShader(this._program,this._pshader);
  30285. for (var k in this._attributeMap)
  30286. gl.bindAttribLocation(this._program,this._attributeMap[k],k);
  30287. gl.linkProgram(this._program);
  30288. if (!Render.isConchApp && Shader3D.debugMode && !gl.getProgramParameter(this._program,/*laya.webgl.WebGLContext.LINK_STATUS*/0x8B82))
  30289. throw gl.getProgramInfoLog(this._program);
  30290. var sceneParms=[];
  30291. var cameraParms=[];
  30292. var spriteParms=[];
  30293. var materialParms=[];
  30294. var customParms=[];
  30295. this._customUniformParamsMap=[];
  30296. var nUniformNum=gl.getProgramParameter(this._program,/*laya.webgl.WebGLContext.ACTIVE_UNIFORMS*/0x8B86);
  30297. WebGLContext.useProgram(gl,this._program);
  30298. this._curActTexIndex=0;
  30299. var one,i=0,n=0;
  30300. for (i=0;i < nUniformNum;i++){
  30301. var uniformData=gl.getActiveUniform(this._program,i);
  30302. var uniName=uniformData.name;
  30303. one=new ShaderVariable();
  30304. one.location=gl.getUniformLocation(this._program,uniName);
  30305. if (uniName.indexOf('[0]')> 0){
  30306. one.name=uniName=uniName.substr(0,uniName.length-3);
  30307. one.isArray=true;
  30308. }else {
  30309. one.name=uniName;
  30310. one.isArray=false;
  30311. }
  30312. one.type=uniformData.type;
  30313. this._addShaderUnifiormFun(one);
  30314. var uniformPeriod=this._uniformMap[uniName];
  30315. if (uniformPeriod !=null){
  30316. one.dataOffset=Shader3D.propertyNameToID(uniName);
  30317. switch (uniformPeriod){
  30318. case /*laya.d3.shader.Shader3D.PERIOD_CUSTOM*/0:
  30319. customParms.push(one);
  30320. break ;
  30321. case /*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1:
  30322. materialParms.push(one);
  30323. break ;
  30324. case /*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2:
  30325. spriteParms.push(one);
  30326. break ;
  30327. case /*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3:
  30328. cameraParms.push(one);
  30329. break ;
  30330. case /*laya.d3.shader.Shader3D.PERIOD_SCENE*/4:
  30331. sceneParms.push(one);
  30332. break ;
  30333. default :
  30334. throw new Error("Shader3D: period is unkonw.");
  30335. }
  30336. }
  30337. }
  30338. this._sceneUniformParamsMap=LayaGL.instance.createCommandEncoder(sceneParms.length *4 *5+4,64,true);
  30339. for (i=0,n=sceneParms.length;i < n;i++)
  30340. this._sceneUniformParamsMap.addShaderUniform(sceneParms[i]);
  30341. this._cameraUniformParamsMap=LayaGL.instance.createCommandEncoder(cameraParms.length *4 *5+4,64,true);
  30342. for (i=0,n=cameraParms.length;i < n;i++)
  30343. this._cameraUniformParamsMap.addShaderUniform(cameraParms[i]);
  30344. this._spriteUniformParamsMap=LayaGL.instance.createCommandEncoder(spriteParms.length *4 *5+4,64,true);
  30345. for (i=0,n=spriteParms.length;i < n;i++)
  30346. this._spriteUniformParamsMap.addShaderUniform(spriteParms[i]);
  30347. this._materialUniformParamsMap=LayaGL.instance.createCommandEncoder(materialParms.length *4 *5+4,64,true);
  30348. for (i=0,n=materialParms.length;i < n;i++)
  30349. this._materialUniformParamsMap.addShaderUniform(materialParms[i]);
  30350. this._customUniformParamsMap.length=customParms.length;
  30351. for (i=0,n=customParms.length;i < n;i++){
  30352. var custom=customParms[i];
  30353. this._customUniformParamsMap[custom.dataOffset]=custom;
  30354. };
  30355. var stateMap=this._shaderPass._stateMap;
  30356. for (var s in stateMap)
  30357. this._stateParamsMap[stateMap[s]]=Shader3D.propertyNameToID(s);
  30358. }
  30359. /**
  30360. *@private
  30361. */
  30362. __proto._getRenderState=function(shaderDatas,stateIndex){
  30363. var stateID=this._stateParamsMap[stateIndex];
  30364. if (stateID==null)
  30365. return null;
  30366. else
  30367. return shaderDatas[stateID];
  30368. }
  30369. /**
  30370. *@inheritDoc
  30371. */
  30372. __proto._disposeResource=function(){
  30373. LayaGL.instance.deleteShader(this._vshader);
  30374. LayaGL.instance.deleteShader(this._pshader);
  30375. LayaGL.instance.deleteProgram(this._program);
  30376. this._vshader=this._pshader=this._program=null;
  30377. this._setGPUMemory(0);
  30378. this._curActTexIndex=0;
  30379. }
  30380. /**
  30381. *@private
  30382. */
  30383. __proto._addShaderUnifiormFun=function(one){
  30384. var gl=LayaGL.instance;
  30385. one.caller=this;
  30386. var isArray=one.isArray;
  30387. switch (one.type){
  30388. case /*laya.webgl.WebGLContext.BOOL*/0x8B56:
  30389. one.fun=this._uniform1i;
  30390. one.uploadedValue=new Array(1);
  30391. break ;
  30392. case /*laya.webgl.WebGLContext.INT*/0x1404:
  30393. one.fun=isArray ? this._uniform1iv :this._uniform1i;
  30394. one.uploadedValue=new Array(1);
  30395. break ;
  30396. case /*laya.webgl.WebGLContext.FLOAT*/0x1406:
  30397. one.fun=isArray ? this._uniform1fv :this._uniform1f;
  30398. one.uploadedValue=new Array(1);
  30399. break ;
  30400. case /*laya.webgl.WebGLContext.FLOAT_VEC2*/0x8B50:
  30401. one.fun=isArray ? this._uniform_vec2v :this._uniform_vec2;
  30402. one.uploadedValue=new Array(2);
  30403. break ;
  30404. case /*laya.webgl.WebGLContext.FLOAT_VEC3*/0x8B51:
  30405. one.fun=isArray ? this._uniform_vec3v :this._uniform_vec3;
  30406. one.uploadedValue=new Array(3);
  30407. break ;
  30408. case /*laya.webgl.WebGLContext.FLOAT_VEC4*/0x8B52:
  30409. one.fun=isArray ? this._uniform_vec4v :this._uniform_vec4;
  30410. one.uploadedValue=new Array(4);
  30411. break ;
  30412. case /*laya.webgl.WebGLContext.FLOAT_MAT2*/0x8B5A:
  30413. one.fun=this._uniformMatrix2fv;
  30414. break ;
  30415. case /*laya.webgl.WebGLContext.FLOAT_MAT3*/0x8B5B:
  30416. one.fun=this._uniformMatrix3fv;
  30417. break ;
  30418. case /*laya.webgl.WebGLContext.FLOAT_MAT4*/0x8B5C:
  30419. one.fun=isArray ? this._uniformMatrix4fv :this._uniformMatrix4f;
  30420. break ;
  30421. case /*laya.webgl.WebGLContext.SAMPLER_2D*/0x8B5E:
  30422. gl.uniform1i(one.location,this._curActTexIndex);
  30423. one.textureID=WebGLContext._glTextureIDs[this._curActTexIndex++];
  30424. one.fun=this._uniform_sampler2D;
  30425. break ;
  30426. case 0x8b5f:
  30427. gl.uniform1i(one.location,this._curActTexIndex);
  30428. one.textureID=WebGLContext._glTextureIDs[this._curActTexIndex++];
  30429. one.fun=this._uniform_sampler3D;
  30430. break ;
  30431. case /*laya.webgl.WebGLContext.SAMPLER_CUBE*/0x8B60:
  30432. gl.uniform1i(one.location,this._curActTexIndex);
  30433. one.textureID=WebGLContext._glTextureIDs[this._curActTexIndex++];
  30434. one.fun=this._uniform_samplerCube;
  30435. break ;
  30436. default :
  30437. throw new Error("compile shader err!");
  30438. break ;
  30439. }
  30440. }
  30441. /**
  30442. *@private
  30443. */
  30444. __proto._createShader=function(gl,str,type){
  30445. var shader=gl.createShader(type);
  30446. gl.shaderSource(shader,str);
  30447. gl.compileShader(shader);
  30448. if (Shader3D.debugMode && !gl.getShaderParameter(shader,/*laya.webgl.WebGLContext.COMPILE_STATUS*/0x8B81))
  30449. throw gl.getShaderInfoLog(shader);
  30450. return shader;
  30451. }
  30452. /**
  30453. *@private
  30454. */
  30455. __proto._uniform1f=function(one,value){
  30456. var uploadedValue=one.uploadedValue;
  30457. if (uploadedValue[0]!==value){
  30458. LayaGL.instance.uniform1f(one.location,uploadedValue[0]=value);
  30459. return 1;
  30460. }
  30461. return 0;
  30462. }
  30463. /**
  30464. *@private
  30465. */
  30466. __proto._uniform1fv=function(one,value){
  30467. if (value.length < 4){
  30468. var uploadedValue=one.uploadedValue;
  30469. if (uploadedValue[0]!==value[0] || uploadedValue[1]!==value[1] || uploadedValue[2]!==value[2] || uploadedValue[3]!==value[3]){
  30470. LayaGL.instance.uniform1fv(one.location,value);
  30471. uploadedValue[0]=value[0];
  30472. uploadedValue[1]=value[1];
  30473. uploadedValue[2]=value[2];
  30474. uploadedValue[3]=value[3];
  30475. return 1;
  30476. }
  30477. return 0;
  30478. }else {
  30479. LayaGL.instance.uniform1fv(one.location,value);
  30480. return 1;
  30481. }
  30482. }
  30483. /**
  30484. *@private
  30485. */
  30486. __proto._uniform_vec2=function(one,v){
  30487. var uploadedValue=one.uploadedValue;
  30488. if (uploadedValue[0]!==v.x || uploadedValue[1]!==v.y){
  30489. LayaGL.instance.uniform2f(one.location,uploadedValue[0]=v.x,uploadedValue[1]=v.y);
  30490. return 1;
  30491. }
  30492. return 0;
  30493. }
  30494. /**
  30495. *@private
  30496. */
  30497. __proto._uniform_vec2v=function(one,value){
  30498. if (value.length < 2){
  30499. var uploadedValue=one.uploadedValue;
  30500. if (uploadedValue[0]!==value[0] || uploadedValue[1]!==value[1] || uploadedValue[2]!==value[2] || uploadedValue[3]!==value[3]){
  30501. LayaGL.instance.uniform2fv(one.location,value);
  30502. uploadedValue[0]=value[0];
  30503. uploadedValue[1]=value[1];
  30504. uploadedValue[2]=value[2];
  30505. uploadedValue[3]=value[3];
  30506. return 1;
  30507. }
  30508. return 0;
  30509. }else {
  30510. LayaGL.instance.uniform2fv(one.location,value);
  30511. return 1;
  30512. }
  30513. }
  30514. /**
  30515. *@private
  30516. */
  30517. __proto._uniform_vec3=function(one,v){
  30518. var uploadedValue=one.uploadedValue;
  30519. if (uploadedValue[0]!==v.x || uploadedValue[1]!==v.y || uploadedValue[2]!==v.z){
  30520. LayaGL.instance.uniform3f(one.location,uploadedValue[0]=v.x,uploadedValue[1]=v.y,uploadedValue[2]=v.z);
  30521. return 1;
  30522. }
  30523. return 0;
  30524. }
  30525. /**
  30526. *@private
  30527. */
  30528. __proto._uniform_vec3v=function(one,v){
  30529. LayaGL.instance.uniform3fv(one.location,v);
  30530. return 1;
  30531. }
  30532. /**
  30533. *@private
  30534. */
  30535. __proto._uniform_vec4=function(one,v){
  30536. var uploadedValue=one.uploadedValue;
  30537. if (uploadedValue[0]!==v.x || uploadedValue[1]!==v.y || uploadedValue[2]!==v.z || uploadedValue[3]!==v.w){
  30538. LayaGL.instance.uniform4f(one.location,uploadedValue[0]=v.x,uploadedValue[1]=v.y,uploadedValue[2]=v.z,uploadedValue[3]=v.w);
  30539. return 1;
  30540. }
  30541. return 0;
  30542. }
  30543. /**
  30544. *@private
  30545. */
  30546. __proto._uniform_vec4v=function(one,v){
  30547. LayaGL.instance.uniform4fv(one.location,v);
  30548. return 1;
  30549. }
  30550. /**
  30551. *@private
  30552. */
  30553. __proto._uniformMatrix2fv=function(one,value){
  30554. LayaGL.instance.uniformMatrix2fv(one.location,false,value);
  30555. return 1;
  30556. }
  30557. /**
  30558. *@private
  30559. */
  30560. __proto._uniformMatrix3fv=function(one,value){
  30561. LayaGL.instance.uniformMatrix3fv(one.location,false,value);
  30562. return 1;
  30563. }
  30564. /**
  30565. *@private
  30566. */
  30567. __proto._uniformMatrix4f=function(one,m){
  30568. var value=m.elements;
  30569. LayaGL.instance.uniformMatrix4fv(one.location,false,value);
  30570. return 1;
  30571. }
  30572. /**
  30573. *@private
  30574. */
  30575. __proto._uniformMatrix4fv=function(one,m){
  30576. LayaGL.instance.uniformMatrix4fv(one.location,false,m);
  30577. return 1;
  30578. }
  30579. /**
  30580. *@private
  30581. */
  30582. __proto._uniform1i=function(one,value){
  30583. var uploadedValue=one.uploadedValue;
  30584. if (uploadedValue[0]!==value){
  30585. LayaGL.instance.uniform1i(one.location,uploadedValue[0]=value);
  30586. return 1;
  30587. }
  30588. return 0;
  30589. }
  30590. /**
  30591. *@private
  30592. */
  30593. __proto._uniform1iv=function(one,value){
  30594. LayaGL.instance.uniform1iv(one.location,value);
  30595. return 1;
  30596. }
  30597. /**
  30598. *@private
  30599. */
  30600. __proto._uniform_ivec2=function(one,value){
  30601. var uploadedValue=one.uploadedValue;
  30602. if (uploadedValue[0]!==value[0] || uploadedValue[1]!==value[1]){
  30603. LayaGL.instance.uniform2i(one.location,uploadedValue[0]=value[0],uploadedValue[1]=value[1]);
  30604. return 1;
  30605. }
  30606. return 0;
  30607. }
  30608. /**
  30609. *@private
  30610. */
  30611. __proto._uniform_ivec2v=function(one,value){
  30612. LayaGL.instance.uniform2iv(one.location,value);
  30613. return 1;
  30614. }
  30615. /**
  30616. *@private
  30617. */
  30618. __proto._uniform_vec3i=function(one,value){
  30619. var uploadedValue=one.uploadedValue;
  30620. if (uploadedValue[0]!==value[0] || uploadedValue[1]!==value[1] || uploadedValue[2]!==value[2]){
  30621. LayaGL.instance.uniform3i(one.location,uploadedValue[0]=value[0],uploadedValue[1]=value[1],uploadedValue[2]=value[2]);
  30622. return 1;
  30623. }
  30624. return 0;
  30625. }
  30626. /**
  30627. *@private
  30628. */
  30629. __proto._uniform_vec3vi=function(one,value){
  30630. LayaGL.instance.uniform3iv(one.location,value);
  30631. return 1;
  30632. }
  30633. /**
  30634. *@private
  30635. */
  30636. __proto._uniform_vec4i=function(one,value){
  30637. var uploadedValue=one.uploadedValue;
  30638. if (uploadedValue[0]!==value[0] || uploadedValue[1]!==value[1] || uploadedValue[2]!==value[2] || uploadedValue[3]!==value[3]){
  30639. LayaGL.instance.uniform4i(one.location,uploadedValue[0]=value[0],uploadedValue[1]=value[1],uploadedValue[2]=value[2],uploadedValue[3]=value[3]);
  30640. return 1;
  30641. }
  30642. return 0;
  30643. }
  30644. /**
  30645. *@private
  30646. */
  30647. __proto._uniform_vec4vi=function(one,value){
  30648. LayaGL.instance.uniform4iv(one.location,value);
  30649. return 1;
  30650. }
  30651. /**
  30652. *@private
  30653. */
  30654. __proto._uniform_sampler2D=function(one,texture){
  30655. var value=texture._getSource()|| texture.defaulteTexture._getSource();
  30656. var gl=LayaGL.instance;
  30657. WebGLContext.activeTexture(gl,one.textureID);
  30658. WebGLContext.bindTexture(gl,/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,value);
  30659. return 0;
  30660. }
  30661. __proto._uniform_sampler3D=function(one,texture){
  30662. var value=texture._getSource()|| texture.defaulteTexture._getSource();
  30663. var gl=LayaGL.instance;
  30664. WebGLContext.activeTexture(gl,one.textureID);
  30665. WebGLContext.bindTexture(gl,/*laya.webgl.WebGLContext.TEXTURE_3D*/0x806f,value);
  30666. return 0;
  30667. }
  30668. /**
  30669. *@private
  30670. */
  30671. __proto._uniform_samplerCube=function(one,texture){
  30672. var value=texture._getSource()|| texture.defaulteTexture._getSource();
  30673. var gl=LayaGL.instance;
  30674. WebGLContext.activeTexture(gl,one.textureID);
  30675. WebGLContext.bindTexture(gl,/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP*/0x8513,value);
  30676. return 0;
  30677. }
  30678. /**
  30679. *@private
  30680. */
  30681. __proto.bind=function(){
  30682. return WebGLContext.useProgram(LayaGL.instance,this._program);
  30683. }
  30684. /**
  30685. *@private
  30686. */
  30687. __proto.uploadUniforms=function(shaderUniform,shaderDatas,uploadUnTexture){
  30688. Stat.shaderCall+=LayaGLRunner.uploadShaderUniforms(LayaGL.instance,shaderUniform,shaderDatas,uploadUnTexture);
  30689. }
  30690. /**
  30691. *@private
  30692. */
  30693. __proto.uploadRenderStateBlendDepth=function(shaderDatas){
  30694. var gl=LayaGL.instance;
  30695. var renderState=this._shaderPass.renderState;
  30696. var datas=shaderDatas.getData();
  30697. var depthWrite=this._getRenderState(datas,/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_WRITE*/13);
  30698. var depthTest=this._getRenderState(datas,/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_TEST*/12);
  30699. var blend=this._getRenderState(datas,/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND*/1);
  30700. depthWrite==null && (depthWrite=renderState.depthWrite);
  30701. depthTest==null && (depthTest=renderState.depthTest);
  30702. blend==null && (blend=renderState.blend);
  30703. WebGLContext.setDepthMask(gl,depthWrite);
  30704. if (depthTest===/*laya.d3.core.material.RenderState.DEPTHTEST_OFF*/0)
  30705. WebGLContext.setDepthTest(gl,false);
  30706. else {
  30707. WebGLContext.setDepthTest(gl,true);
  30708. WebGLContext.setDepthFunc(gl,depthTest);
  30709. }
  30710. switch (blend){
  30711. case /*laya.d3.core.material.RenderState.BLEND_DISABLE*/0:
  30712. WebGLContext.setBlend(gl,false);
  30713. break ;
  30714. case /*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1:
  30715. WebGLContext.setBlend(gl,true);
  30716. var srcBlend=this._getRenderState(datas,/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_SRC*/2);
  30717. srcBlend==null && (srcBlend=renderState.srcBlend);
  30718. var dstBlend=this._getRenderState(datas,/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_DST*/3);
  30719. dstBlend==null && (dstBlend=renderState.dstBlend);
  30720. WebGLContext.setBlendFunc(gl,srcBlend,dstBlend);
  30721. break ;
  30722. case /*laya.d3.core.material.RenderState.BLEND_ENABLE_SEPERATE*/2:
  30723. WebGLContext.setBlend(gl,true);
  30724. var srcRGB=this._getRenderState(datas,/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_SRC_RGB*/4);
  30725. srcRGB==null && (srcRGB=renderState.srcBlendRGB);
  30726. var dstRGB=this._getRenderState(datas,/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_DST_RGB*/5);
  30727. dstRGB==null && (dstRGB=renderState.dstBlendRGB);
  30728. var srcAlpha=this._getRenderState(datas,/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_SRC_ALPHA*/6);
  30729. srcAlpha==null && (srcAlpha=renderState.srcBlendAlpha);
  30730. var dstAlpha=this._getRenderState(datas,/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_DST_ALPHA*/7);
  30731. dstAlpha==null && (dstAlpha=renderState.dstBlendAlpha);
  30732. WebGLContext.setBlendFuncSeperate(gl,srcRGB,dstRGB,srcAlpha,dstAlpha);
  30733. break ;
  30734. }
  30735. }
  30736. /**
  30737. *@private
  30738. */
  30739. __proto.uploadRenderStateFrontFace=function(shaderDatas,isTarget,transform){
  30740. var gl=LayaGL.instance;
  30741. var renderState=this._shaderPass.renderState;
  30742. var datas=shaderDatas.getData();
  30743. var cull=this._getRenderState(datas,/*laya.d3.shader.Shader3D.RENDER_STATE_CULL*/0);
  30744. cull==null && (cull=renderState.cull);
  30745. var forntFace=0;
  30746. switch (cull){
  30747. case /*laya.d3.core.material.RenderState.CULL_NONE*/0:
  30748. WebGLContext.setCullFace(gl,false);
  30749. break ;
  30750. case /*laya.d3.core.material.RenderState.CULL_FRONT*/1:
  30751. WebGLContext.setCullFace(gl,true);
  30752. if (isTarget){
  30753. if (transform && transform._isFrontFaceInvert)
  30754. forntFace=/*laya.webgl.WebGLContext.CCW*/0x0901;
  30755. else
  30756. forntFace=/*laya.webgl.WebGLContext.CW*/0x0900;
  30757. }else {
  30758. if (transform && transform._isFrontFaceInvert)
  30759. forntFace=/*laya.webgl.WebGLContext.CW*/0x0900;
  30760. else
  30761. forntFace=/*laya.webgl.WebGLContext.CCW*/0x0901;
  30762. }
  30763. WebGLContext.setFrontFace(gl,forntFace);
  30764. break ;
  30765. case /*laya.d3.core.material.RenderState.CULL_BACK*/2:
  30766. WebGLContext.setCullFace(gl,true);
  30767. if (isTarget){
  30768. if (transform && transform._isFrontFaceInvert)
  30769. forntFace=/*laya.webgl.WebGLContext.CW*/0x0900;
  30770. else
  30771. forntFace=/*laya.webgl.WebGLContext.CCW*/0x0901;
  30772. }else {
  30773. if (transform && transform._isFrontFaceInvert)
  30774. forntFace=/*laya.webgl.WebGLContext.CCW*/0x0901;
  30775. else
  30776. forntFace=/*laya.webgl.WebGLContext.CW*/0x0900;
  30777. }
  30778. WebGLContext.setFrontFace(gl,forntFace);
  30779. break ;
  30780. }
  30781. }
  30782. /**
  30783. *@private
  30784. */
  30785. __proto.uploadCustomUniform=function(index,data){
  30786. Stat.shaderCall+=LayaGLRunner.uploadCustomUniform(LayaGL.instance,this._customUniformParamsMap,index,data);
  30787. }
  30788. /**
  30789. *@private
  30790. *[NATIVE]
  30791. */
  30792. __proto._uniformMatrix2fvForNative=function(one,value){
  30793. LayaGL.instance.uniformMatrix2fvEx(one.location,false,value);
  30794. return 1;
  30795. }
  30796. /**
  30797. *@private
  30798. *[NATIVE]
  30799. */
  30800. __proto._uniformMatrix3fvForNative=function(one,value){
  30801. LayaGL.instance.uniformMatrix3fvEx(one.location,false,value);
  30802. return 1;
  30803. }
  30804. /**
  30805. *@private
  30806. *[NATIVE]
  30807. */
  30808. __proto._uniformMatrix4fvForNative=function(one,m){
  30809. LayaGL.instance.uniformMatrix4fvEx(one.location,false,m);
  30810. return 1;
  30811. }
  30812. return ShaderInstance;
  30813. })(Resource)
  30814. /**
  30815. *<code>TerrainRes</code> 类用于描述地形信息。
  30816. */
  30817. //class laya.d3.terrain.TerrainRes extends laya.resource.Resource
  30818. var TerrainRes=(function(_super){
  30819. function TerrainRes(){
  30820. this._version=NaN;
  30821. this._cameraCoordinateInverse=false;
  30822. this._gridSize=NaN;
  30823. this._chunkNumX=0;
  30824. this._chunkNumZ=0;
  30825. this._heightDataX=0;
  30826. this._heightDataZ=0;
  30827. this._heightDataBitType=0;
  30828. this._heightDataValue=NaN;
  30829. this._heightDataUrl=null;
  30830. this._detailTextureInfos=null;
  30831. this._chunkInfos=null;
  30832. this._heightData=null;
  30833. this._materialInfo=null;
  30834. this._alphaMaps=null;
  30835. this._normalMaps=null;
  30836. TerrainRes.__super.call(this);
  30837. }
  30838. __class(TerrainRes,'laya.d3.terrain.TerrainRes',_super);
  30839. var __proto=TerrainRes.prototype;
  30840. __proto.parseData=function(data){
  30841. var json=data[0];
  30842. var resouMap=data[1];
  30843. this._version=json.version;
  30844. if (this._version==1.0){
  30845. this._cameraCoordinateInverse=json.cameraCoordinateInverse;
  30846. this._gridSize=json.gridSize;
  30847. this._chunkNumX=json.chunkNumX;
  30848. this._chunkNumZ=json.chunkNumZ;
  30849. var heightData=json.heightData;
  30850. this._heightDataX=heightData.numX;
  30851. this._heightDataZ=heightData.numZ;
  30852. this._heightDataBitType=heightData.bitType;
  30853. this._heightDataValue=heightData.value;
  30854. this._heightDataUrl=resouMap[heightData.url];
  30855. this._materialInfo=new MaterialInfo();
  30856. if (json.material){
  30857. var ambient=json.material.ambient;
  30858. var diffuse=json.material.diffuse;
  30859. var specular=json.material.specular;
  30860. this._materialInfo.ambientColor=new Vector3(ambient[0],ambient[1],ambient[2]);
  30861. this._materialInfo.diffuseColor=new Vector3(diffuse[0],diffuse[1],diffuse[2]);
  30862. this._materialInfo.specularColor=new Vector4(specular[0],specular[1],specular[2],specular[3]);
  30863. };
  30864. var detailTextures=json.detailTexture;
  30865. this._detailTextureInfos=__newvec(detailTextures.length);
  30866. for (var i=0;i < detailTextures.length;i++){
  30867. var detail=detailTextures[i];
  30868. var info=new DetailTextureInfo();
  30869. info.diffuseTexture=resouMap[detail.diffuse];
  30870. info.normalTexture=detail.normal ? resouMap[detail.normal] :null;
  30871. if (detail.scale){
  30872. info.scale=new Vector2(detail.scale[0],detail.scale[1]);
  30873. }else {
  30874. info.scale=new Vector2(1,1);
  30875. }
  30876. if (detail.offset){
  30877. info.offset=new Vector2(detail.offset[0],detail.offset[1]);
  30878. }else {
  30879. info.offset=new Vector2(0,0);
  30880. }
  30881. this._detailTextureInfos[i]=info;
  30882. };
  30883. var alphaMaps=json.alphaMap;
  30884. this._alphaMaps=__newvec(alphaMaps.length);
  30885. for (i=0;i < this._alphaMaps.length;i++){
  30886. this._alphaMaps[i]=json.alphaMap[i];
  30887. };
  30888. var normalMaps=json.normalMap;
  30889. this._normalMaps=__newvec(normalMaps.length);
  30890. for (i=0;i < this._normalMaps.length;i++){
  30891. this._normalMaps[i]=json.normalMap[i];
  30892. };
  30893. var jchunks=json.chunkInfo;
  30894. if (this._chunkNumX *this._chunkNumZ !=jchunks.length){
  30895. alert("terrain data error");
  30896. return false;
  30897. }
  30898. this._chunkInfos=__newvec(jchunks.length);
  30899. for (i=0;i < jchunks.length;i++){
  30900. var jchunk=jchunks[i];
  30901. var chunkinfo=new ChunkInfo();
  30902. var nAlphaMapNum=jchunk.alphaMap.length;
  30903. var nDetailIDNum=jchunk.detailID.length;
  30904. if (nAlphaMapNum !=nDetailIDNum){
  30905. alert("terrain chunk data error");
  30906. return false;
  30907. }
  30908. chunkinfo.alphaMap=__newvec(nAlphaMapNum);
  30909. chunkinfo.detailID=__newvec(nDetailIDNum);
  30910. chunkinfo.normalMap=resouMap[this._normalMaps[jchunk.normalMap]];
  30911. for (var j=0;j < nAlphaMapNum;j++){
  30912. chunkinfo.alphaMap[j]=resouMap[this._alphaMaps[jchunk.alphaMap[j]]];
  30913. var jid=jchunk.detailID[j];
  30914. var nIDNum=jid.length;
  30915. chunkinfo.detailID[j]=new Uint8Array(nIDNum);
  30916. for (var k=0;k < nIDNum;k++){
  30917. chunkinfo.detailID[j][k]=jid[k];
  30918. }
  30919. }
  30920. this._chunkInfos[i]=chunkinfo;
  30921. }
  30922. this._heightData=Loader.getRes(this._heightDataUrl);
  30923. this.onLoadTerrainComplete(this._heightData);
  30924. }
  30925. return true;
  30926. }
  30927. __proto.onLoadTerrainComplete=function(heightData){}
  30928. TerrainRes._parse=function(data,propertyParams,constructParams){
  30929. var terrainRes=new TerrainRes();
  30930. terrainRes.parseData(data);
  30931. return terrainRes;
  30932. }
  30933. TerrainRes.load=function(url,complete){
  30934. Laya.loader.create(url,complete,null,/*Laya3D.TERRAINRES*/"TERRAIN",null,null,1,false);
  30935. }
  30936. return TerrainRes;
  30937. })(Resource)
  30938. /**
  30939. *<code>ShurikenParticleRender</code> 类用于创建3D粒子渲染器。
  30940. */
  30941. //class laya.d3.core.particleShuriKen.ShurikenParticleRenderer extends laya.d3.core.render.BaseRender
  30942. var ShurikenParticleRenderer=(function(_super){
  30943. function ShurikenParticleRenderer(owner){
  30944. /**@private */
  30945. //this._defaultBoundBox=null;
  30946. /**@private */
  30947. //this._renderMode=0;
  30948. /**@private */
  30949. //this._mesh=null;
  30950. /**拉伸广告牌模式摄像机速度缩放,暂不支持。*/
  30951. //this.stretchedBillboardCameraSpeedScale=NaN;
  30952. /**拉伸广告牌模式速度缩放。*/
  30953. //this.stretchedBillboardSpeedScale=NaN;
  30954. /**拉伸广告牌模式长度缩放。*/
  30955. //this.stretchedBillboardLengthScale=NaN;
  30956. this._finalGravity=new Vector3();
  30957. this._tempRotationMatrix=new Matrix4x4();
  30958. ShurikenParticleRenderer.__super.call(this,owner);
  30959. this._defaultBoundBox=new BoundBox(new Vector3(),new Vector3());
  30960. this._renderMode=-1;
  30961. this.stretchedBillboardCameraSpeedScale=0.0;
  30962. this.stretchedBillboardSpeedScale=0.0;
  30963. this.stretchedBillboardLengthScale=1.0;
  30964. }
  30965. __class(ShurikenParticleRenderer,'laya.d3.core.particleShuriKen.ShurikenParticleRenderer',_super);
  30966. var __proto=ShurikenParticleRenderer.prototype;
  30967. /**
  30968. *@inheritDoc
  30969. */
  30970. __proto._calculateBoundingBox=function(){
  30971. var min=this._bounds.getMin();
  30972. min.x=-Number.MAX_VALUE;
  30973. min.y=-Number.MAX_VALUE;
  30974. min.z=-Number.MAX_VALUE;
  30975. this._bounds.setMin(min);
  30976. var max=this._bounds.getMax();
  30977. max.x=Number.MAX_VALUE;
  30978. max.y=Number.MAX_VALUE;
  30979. max.z=Number.MAX_VALUE;
  30980. this._bounds.setMax(max);
  30981. if (Render.supportWebGLPlusCulling){
  30982. min=this._bounds.getMin();
  30983. max=this._bounds.getMax();
  30984. var buffer=FrustumCulling._cullingBuffer;
  30985. buffer[this._cullingBufferIndex+1]=min.x;
  30986. buffer[this._cullingBufferIndex+2]=min.y;
  30987. buffer[this._cullingBufferIndex+3]=min.z;
  30988. buffer[this._cullingBufferIndex+4]=max.x;
  30989. buffer[this._cullingBufferIndex+5]=max.y;
  30990. buffer[this._cullingBufferIndex+6]=max.z;
  30991. }
  30992. }
  30993. /**
  30994. *@inheritDoc
  30995. */
  30996. __proto._needRender=function(boundFrustum){
  30997. if (boundFrustum){
  30998. if (boundFrustum.containsBoundBox(this._bounds._getBoundBox())!==/*laya.d3.math.ContainmentType.Disjoint*/0){
  30999. if ((this._owner).particleSystem.isAlive)
  31000. return true;
  31001. else
  31002. return false;
  31003. }else {
  31004. return false;
  31005. }
  31006. }else {
  31007. return true;
  31008. }
  31009. }
  31010. /**
  31011. *@inheritDoc
  31012. */
  31013. __proto._renderUpdate=function(context,transfrom){
  31014. var particleSystem=(this._owner).particleSystem;
  31015. var sv=this._shaderValues;
  31016. var transform=this._owner.transform;
  31017. switch (particleSystem.simulationSpace){
  31018. case 0:
  31019. break ;
  31020. case 1:
  31021. sv.setVector3(ShuriKenParticle3D.WORLDPOSITION,transform.position);
  31022. sv.setQuaternion(ShuriKenParticle3D.WORLDROTATION,transform.rotation);
  31023. break ;
  31024. default :
  31025. throw new Error("ShurikenParticleMaterial: SimulationSpace value is invalid.");
  31026. }
  31027. switch (particleSystem.scaleMode){
  31028. case 0:;
  31029. var scale=transform.scale;
  31030. sv.setVector3(ShuriKenParticle3D.POSITIONSCALE,scale);
  31031. sv.setVector3(ShuriKenParticle3D.SIZESCALE,scale);
  31032. break ;
  31033. case 1:;
  31034. var localScale=transform.localScale;
  31035. sv.setVector3(ShuriKenParticle3D.POSITIONSCALE,localScale);
  31036. sv.setVector3(ShuriKenParticle3D.SIZESCALE,localScale);
  31037. break ;
  31038. case 2:
  31039. sv.setVector3(ShuriKenParticle3D.POSITIONSCALE,transform.scale);
  31040. sv.setVector3(ShuriKenParticle3D.SIZESCALE,Vector3._ONE);
  31041. break ;
  31042. }
  31043. Vector3.scale(Physics3DUtils.gravity,particleSystem.gravityModifier,this._finalGravity);
  31044. sv.setVector3(ShuriKenParticle3D.GRAVITY,this._finalGravity);
  31045. sv.setInt(ShuriKenParticle3D.SIMULATIONSPACE,particleSystem.simulationSpace);
  31046. sv.setBool(ShuriKenParticle3D.THREEDSTARTROTATION,particleSystem.threeDStartRotation);
  31047. sv.setInt(ShuriKenParticle3D.SCALINGMODE,particleSystem.scaleMode);
  31048. sv.setNumber(ShuriKenParticle3D.STRETCHEDBILLBOARDLENGTHSCALE,this.stretchedBillboardLengthScale);
  31049. sv.setNumber(ShuriKenParticle3D.STRETCHEDBILLBOARDSPEEDSCALE,this.stretchedBillboardSpeedScale);
  31050. sv.setNumber(ShuriKenParticle3D.CURRENTTIME,particleSystem._currentTime);
  31051. }
  31052. /**
  31053. *@inheritDoc
  31054. */
  31055. __proto._destroy=function(){
  31056. _super.prototype._destroy.call(this);
  31057. (this._mesh)&& (this._mesh._removeReference(),this._mesh=null);
  31058. }
  31059. /**
  31060. *设置渲染模式,0为BILLBOARD、1为STRETCHEDBILLBOARD、2为HORIZONTALBILLBOARD、3为VERTICALBILLBOARD、4为MESH。
  31061. *@param value 渲染模式。
  31062. */
  31063. /**
  31064. *获取渲染模式。
  31065. *@return 渲染模式。
  31066. */
  31067. __getset(0,__proto,'renderMode',function(){
  31068. return this._renderMode;
  31069. },function(value){
  31070. if (this._renderMode!==value){
  31071. var defineDatas=this._defineDatas;
  31072. switch (this._renderMode){
  31073. case 0:
  31074. defineDatas.remove(ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_BILLBOARD);
  31075. break ;
  31076. case 1:
  31077. defineDatas.remove(ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_STRETCHEDBILLBOARD);
  31078. break ;
  31079. case 2:
  31080. defineDatas.remove(ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_HORIZONTALBILLBOARD);
  31081. break ;
  31082. case 3:
  31083. defineDatas.remove(ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_VERTICALBILLBOARD);
  31084. break ;
  31085. case 4:
  31086. defineDatas.remove(ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_MESH);
  31087. break ;
  31088. }
  31089. this._renderMode=value;
  31090. switch (value){
  31091. case 0:
  31092. defineDatas.add(ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_BILLBOARD);
  31093. break ;
  31094. case 1:
  31095. defineDatas.add(ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_STRETCHEDBILLBOARD);
  31096. break ;
  31097. case 2:
  31098. defineDatas.add(ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_HORIZONTALBILLBOARD);
  31099. break ;
  31100. case 3:
  31101. defineDatas.add(ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_VERTICALBILLBOARD);
  31102. break ;
  31103. case 4:
  31104. defineDatas.add(ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_MESH);
  31105. break ;
  31106. default :
  31107. throw new Error("ShurikenParticleRender: unknown renderMode Value.");
  31108. }
  31109. (this._owner).particleSystem._initBufferDatas();
  31110. }
  31111. });
  31112. /**
  31113. *设置网格渲染模式所使用的Mesh,rendderMode为4时生效。
  31114. *@param value 网格模式所使用Mesh。
  31115. */
  31116. /**
  31117. *获取网格渲染模式所使用的Mesh,rendderMode为4时生效。
  31118. *@return 网格模式所使用Mesh。
  31119. */
  31120. __getset(0,__proto,'mesh',function(){
  31121. return this._mesh
  31122. },function(value){
  31123. if (this._mesh!==value){
  31124. (this._mesh)&& (this._mesh._removeReference());
  31125. this._mesh=value;
  31126. (value)&& (value._addReference());
  31127. (this._owner).particleSystem._initBufferDatas();
  31128. }
  31129. });
  31130. /**
  31131. *@inheritDoc
  31132. */
  31133. __getset(0,__proto,'bounds',function(){
  31134. if (this._boundsChange){
  31135. this._calculateBoundingBox();
  31136. this._boundsChange=false;
  31137. }
  31138. return this._bounds;
  31139. });
  31140. return ShurikenParticleRenderer;
  31141. })(BaseRender)
  31142. /**
  31143. *<code>PhysicsTriggerComponent</code> 类用于创建物理触发器组件。
  31144. */
  31145. //class laya.d3.physics.PhysicsTriggerComponent extends laya.d3.physics.PhysicsComponent
  31146. var PhysicsTriggerComponent=(function(_super){
  31147. function PhysicsTriggerComponent(collisionGroup,canCollideWith){
  31148. /**@private */
  31149. this._isTrigger=false;
  31150. PhysicsTriggerComponent.__super.call(this,collisionGroup,canCollideWith);
  31151. }
  31152. __class(PhysicsTriggerComponent,'laya.d3.physics.PhysicsTriggerComponent',_super);
  31153. var __proto=PhysicsTriggerComponent.prototype;
  31154. /**
  31155. *@inheritDoc
  31156. */
  31157. __proto._onAdded=function(){
  31158. _super.prototype._onAdded.call(this);
  31159. this.isTrigger=this._isTrigger;
  31160. }
  31161. /**
  31162. *@inheritDoc
  31163. */
  31164. __proto._cloneTo=function(dest){
  31165. _super.prototype._cloneTo.call(this,dest);
  31166. (dest).isTrigger=this._isTrigger;
  31167. }
  31168. /**
  31169. *设置是否为触发器。
  31170. *@param value 是否为触发器。
  31171. */
  31172. /**
  31173. *获取是否为触发器。
  31174. *@return 是否为触发器。
  31175. */
  31176. __getset(0,__proto,'isTrigger',function(){
  31177. return this._isTrigger;
  31178. },function(value){
  31179. this._isTrigger=value;
  31180. if (this._nativeColliderObject){
  31181. var flags=this._nativeColliderObject.getCollisionFlags();
  31182. if (value){
  31183. if ((flags & 4)===0)
  31184. this._nativeColliderObject.setCollisionFlags(flags | 4);
  31185. }else {
  31186. if ((flags & 4)!==0)
  31187. this._nativeColliderObject.setCollisionFlags(flags ^ 4);
  31188. }
  31189. }
  31190. });
  31191. return PhysicsTriggerComponent;
  31192. })(PhysicsComponent)
  31193. /**
  31194. *<code>CharacterController</code> 类用于创建角色控制器。
  31195. */
  31196. //class laya.d3.physics.CharacterController extends laya.d3.physics.PhysicsComponent
  31197. var CharacterController=(function(_super){
  31198. function CharacterController(stepheight,upAxis,collisionGroup,canCollideWith){
  31199. /**@private */
  31200. //this._stepHeight=NaN;
  31201. /**@private */
  31202. this._maxSlope=45.0;
  31203. /**@private */
  31204. this._jumpSpeed=10.0;
  31205. /**@private */
  31206. this._fallSpeed=55.0;
  31207. /**@private */
  31208. //this._nativeKinematicCharacter=null;
  31209. this._upAxis=new Vector3(0,1,0);
  31210. this._gravity=new Vector3(0,-9.8 *3,0);
  31211. (stepheight===void 0)&& (stepheight=0.1);
  31212. (collisionGroup===void 0)&& (collisionGroup=/*laya.d3.utils.Physics3DUtils.COLLISIONFILTERGROUP_DEFAULTFILTER*/0x1);
  31213. (canCollideWith===void 0)&& (canCollideWith=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  31214. this._stepHeight=stepheight;
  31215. (upAxis)&& (this._upAxis=upAxis);
  31216. CharacterController.__super.call(this,collisionGroup,canCollideWith);
  31217. }
  31218. __class(CharacterController,'laya.d3.physics.CharacterController',_super);
  31219. var __proto=CharacterController.prototype;
  31220. /**
  31221. *@private
  31222. */
  31223. __proto._constructCharacter=function(){
  31224. var physics3D=Laya3D._physics3D;
  31225. if (this._nativeKinematicCharacter)
  31226. physics3D.destroy(this._nativeKinematicCharacter);
  31227. var nativeUpAxis=CharacterController._nativeTempVector30;
  31228. nativeUpAxis.setValue(this._upAxis.x,this._upAxis.y,this._upAxis.z);
  31229. this._nativeKinematicCharacter=new physics3D.btKinematicCharacterController(this._nativeColliderObject,this._colliderShape._nativeShape,this._stepHeight,nativeUpAxis);
  31230. this.fallSpeed=this._fallSpeed;
  31231. this.maxSlope=this._maxSlope;
  31232. this.jumpSpeed=this._jumpSpeed;
  31233. this.gravity=this._gravity;
  31234. }
  31235. /**
  31236. *@inheritDoc
  31237. */
  31238. __proto._onShapeChange=function(colShape){
  31239. _super.prototype._onShapeChange.call(this,colShape);
  31240. this._constructCharacter();
  31241. }
  31242. /**
  31243. *@inheritDoc
  31244. */
  31245. __proto._onAdded=function(){
  31246. var physics3D=Laya3D._physics3D;
  31247. var ghostObject=new physics3D.btPairCachingGhostObject();
  31248. ghostObject.setUserIndex(this.id);
  31249. ghostObject.setCollisionFlags(16);
  31250. this._nativeColliderObject=ghostObject;
  31251. if (this._colliderShape)
  31252. this._constructCharacter();
  31253. _super.prototype._onAdded.call(this);
  31254. }
  31255. /**
  31256. *@inheritDoc
  31257. */
  31258. __proto._addToSimulation=function(){
  31259. this._simulation._characters.push(this);
  31260. this._simulation._addCharacter(this,this._collisionGroup,this._canCollideWith);
  31261. }
  31262. /**
  31263. *@inheritDoc
  31264. */
  31265. __proto._removeFromSimulation=function(){
  31266. this._simulation._removeCharacter(this);
  31267. var characters=this._simulation._characters;
  31268. characters.splice(characters.indexOf(this),1);
  31269. }
  31270. /**
  31271. *@inheritDoc
  31272. */
  31273. __proto._cloneTo=function(dest){
  31274. _super.prototype._cloneTo.call(this,dest);
  31275. var destCharacterController=dest;
  31276. destCharacterController.stepHeight=this._stepHeight;
  31277. destCharacterController.upAxis=this._upAxis;
  31278. destCharacterController.maxSlope=this._maxSlope;
  31279. destCharacterController.jumpSpeed=this._jumpSpeed;
  31280. destCharacterController.fallSpeed=this._fallSpeed;
  31281. destCharacterController.gravity=this._gravity;
  31282. }
  31283. /**
  31284. *@inheritDoc
  31285. */
  31286. __proto._onDestroy=function(){
  31287. Laya3D._physics3D.destroy(this._nativeKinematicCharacter);
  31288. _super.prototype._onDestroy.call(this);
  31289. this._nativeKinematicCharacter=null;
  31290. }
  31291. /**
  31292. *通过指定移动向量移动角色。
  31293. *@param movement 移动向量。
  31294. */
  31295. __proto.move=function(movement){
  31296. var nativeMovement=PhysicsComponent._nativeVector30;
  31297. nativeMovement.setValue(-movement.x,movement.y,movement.z);
  31298. this._nativeKinematicCharacter.setWalkDirection(nativeMovement);
  31299. }
  31300. /**
  31301. *跳跃。
  31302. *@param velocity 跳跃速度。
  31303. */
  31304. __proto.jump=function(velocity){
  31305. if (velocity){
  31306. var nativeVelocity=PhysicsComponent._nativeVector30;
  31307. Utils3D._convertToBulletVec3(velocity,nativeVelocity,true);
  31308. this._nativeKinematicCharacter.jump(nativeVelocity);
  31309. }else {
  31310. this._nativeKinematicCharacter.jump();
  31311. }
  31312. }
  31313. /**
  31314. *设置角色降落速度。
  31315. *@param value 角色降落速度。
  31316. */
  31317. /**
  31318. *获取角色降落速度。
  31319. *@return 角色降落速度。
  31320. */
  31321. __getset(0,__proto,'fallSpeed',function(){
  31322. return this._fallSpeed;
  31323. },function(value){
  31324. this._fallSpeed=value;
  31325. this._nativeKinematicCharacter.setFallSpeed(value);
  31326. });
  31327. /**
  31328. *设置角色行走的脚步高度,表示可跨越的最大高度。
  31329. *@param value 脚步高度。
  31330. */
  31331. /**
  31332. *获取角色行走的脚步高度,表示可跨越的最大高度。
  31333. *@return 脚步高度。
  31334. */
  31335. __getset(0,__proto,'stepHeight',function(){
  31336. return this._stepHeight;
  31337. },function(value){
  31338. this._stepHeight=value;
  31339. this._constructCharacter();
  31340. });
  31341. /**
  31342. *设置角色跳跃速度。
  31343. *@param value 角色跳跃速度。
  31344. */
  31345. /**
  31346. *获取角色跳跃速度。
  31347. *@return 角色跳跃速度。
  31348. */
  31349. __getset(0,__proto,'jumpSpeed',function(){
  31350. return this._jumpSpeed;
  31351. },function(value){
  31352. this._jumpSpeed=value;
  31353. this._nativeKinematicCharacter.setJumpSpeed(value);
  31354. });
  31355. /**
  31356. *设置重力。
  31357. *@param value 重力。
  31358. */
  31359. /**
  31360. *获取重力。
  31361. *@return 重力。
  31362. */
  31363. __getset(0,__proto,'gravity',function(){
  31364. return this._gravity;
  31365. },function(value){
  31366. this._gravity=value;
  31367. var nativeGravity=CharacterController._nativeTempVector30;
  31368. nativeGravity.setValue(-value.x,value.y,value.z);
  31369. this._nativeKinematicCharacter.setGravity(nativeGravity);
  31370. });
  31371. /**
  31372. *设置最大坡度。
  31373. *@param value 最大坡度。
  31374. */
  31375. /**
  31376. *获取最大坡度。
  31377. *@return 最大坡度。
  31378. */
  31379. __getset(0,__proto,'maxSlope',function(){
  31380. return this._maxSlope;
  31381. },function(value){
  31382. this._maxSlope=value;
  31383. this._nativeKinematicCharacter.setMaxSlope((value / 180)*Math.PI);
  31384. });
  31385. /**
  31386. *获取角色是否在地表。
  31387. */
  31388. __getset(0,__proto,'isGrounded',function(){
  31389. return this._nativeKinematicCharacter.onGround();
  31390. });
  31391. /**
  31392. *设置角色的Up轴。
  31393. *@return 角色的Up轴。
  31394. */
  31395. /**
  31396. *获取角色的Up轴。
  31397. *@return 角色的Up轴。
  31398. */
  31399. __getset(0,__proto,'upAxis',function(){
  31400. return this._upAxis;
  31401. },function(value){
  31402. this._upAxis=value;
  31403. this._constructCharacter();
  31404. });
  31405. CharacterController.UPAXIS_X=0;
  31406. CharacterController.UPAXIS_Y=1;
  31407. CharacterController.UPAXIS_Z=2;
  31408. __static(CharacterController,
  31409. ['_nativeTempVector30',function(){return this._nativeTempVector30=new Laya3D._physics3D.btVector3(0,0,0);}
  31410. ]);
  31411. return CharacterController;
  31412. })(PhysicsComponent)
  31413. /**
  31414. *<code>MeshRender</code> 类用于网格渲染器。
  31415. */
  31416. //class laya.d3.terrain.TerrainRender extends laya.d3.core.render.BaseRender
  31417. var TerrainRender=(function(_super){
  31418. function TerrainRender(owner){
  31419. /**@private */
  31420. this._terrainSprite3DOwner=null;
  31421. /**@private */
  31422. this._projectionViewWorldMatrix=null;
  31423. TerrainRender.__super.call(this,owner);
  31424. this._terrainSprite3DOwner=owner;
  31425. this._projectionViewWorldMatrix=new Matrix4x4();
  31426. }
  31427. __class(TerrainRender,'laya.d3.terrain.TerrainRender',_super);
  31428. var __proto=TerrainRender.prototype;
  31429. /**
  31430. *@inheritDoc
  31431. */
  31432. __proto._needRender=function(boundFrustum){
  31433. if (boundFrustum)
  31434. return boundFrustum.containsBoundBox(this._bounds._getBoundBox())!==/*laya.d3.math.ContainmentType.Disjoint*/0;
  31435. else
  31436. return true;
  31437. }
  31438. /**
  31439. *@inheritDoc
  31440. */
  31441. __proto._calculateBoundingBox=function(){}
  31442. /**
  31443. *@inheritDoc
  31444. */
  31445. __proto._renderUpdate=function(context,transform){
  31446. this._shaderValues.setMatrix4x4(Sprite3D.WORLDMATRIX,transform.worldMatrix);
  31447. }
  31448. /**
  31449. *@inheritDoc
  31450. */
  31451. __proto._renderUpdateWithCamera=function(context,transform){
  31452. var projectionView=context.projectionViewMatrix;
  31453. Matrix4x4.multiply(projectionView,transform.worldMatrix,this._projectionViewWorldMatrix);
  31454. this._shaderValues.setMatrix4x4(Sprite3D.MVPMATRIX,this._projectionViewWorldMatrix);
  31455. }
  31456. /**
  31457. *@private
  31458. */
  31459. __proto._destroy=function(){
  31460. _super.prototype._destroy.call(this);
  31461. this._terrainSprite3DOwner=null;
  31462. }
  31463. return TerrainRender;
  31464. })(BaseRender)
  31465. /**
  31466. *<code>MeshRenderer</code> 类用于网格渲染器。
  31467. */
  31468. //class laya.d3.core.MeshRenderer extends laya.d3.core.render.BaseRender
  31469. var MeshRenderer=(function(_super){
  31470. function MeshRenderer(owner){
  31471. /**@private */
  31472. //this._oriDefineValue=0;
  31473. /**@private */
  31474. //this._projectionViewWorldMatrix=null;
  31475. MeshRenderer.__super.call(this,owner);
  31476. this._projectionViewWorldMatrix=new Matrix4x4();
  31477. }
  31478. __class(MeshRenderer,'laya.d3.core.MeshRenderer',_super);
  31479. var __proto=MeshRenderer.prototype;
  31480. /**
  31481. *@private
  31482. */
  31483. __proto._onMeshChange=function(mesh){
  31484. this._boundsChange=true;
  31485. }
  31486. /**
  31487. *@inheritDoc
  31488. */
  31489. __proto._calculateBoundingBox=function(){
  31490. var sharedMesh=(this._owner).meshFilter.sharedMesh;
  31491. if (sharedMesh){
  31492. var worldMat=(this._owner).transform.worldMatrix;
  31493. sharedMesh.bounds._tranform(worldMat,this._bounds);
  31494. }
  31495. if (Render.supportWebGLPlusCulling){
  31496. var min=this._bounds.getMin();
  31497. var max=this._bounds.getMax();
  31498. var buffer=FrustumCulling._cullingBuffer;
  31499. buffer[this._cullingBufferIndex+1]=min.x;
  31500. buffer[this._cullingBufferIndex+2]=min.y;
  31501. buffer[this._cullingBufferIndex+3]=min.z;
  31502. buffer[this._cullingBufferIndex+4]=max.x;
  31503. buffer[this._cullingBufferIndex+5]=max.y;
  31504. buffer[this._cullingBufferIndex+6]=max.z;
  31505. }
  31506. }
  31507. /**
  31508. *@private
  31509. */
  31510. __proto._changeRenderObjectsByMesh=function(mesh){
  31511. var count=mesh.subMeshCount;
  31512. this._renderElements.length=count;
  31513. for (var i=0;i < count;i++){
  31514. var renderElement=this._renderElements[i];
  31515. if (!renderElement){
  31516. var material=this.sharedMaterials[i];
  31517. renderElement=this._renderElements[i]=new SubMeshRenderElement();
  31518. renderElement.setTransform(this._owner._transform);
  31519. renderElement.render=this;
  31520. renderElement.material=material ? material :BlinnPhongMaterial.defaultMaterial;
  31521. }
  31522. renderElement.setGeometry(mesh._getSubMesh(i));
  31523. }
  31524. }
  31525. /**
  31526. *@inheritDoc
  31527. */
  31528. __proto._needRender=function(boundFrustum){
  31529. if (boundFrustum)
  31530. return boundFrustum.containsBoundBox(this.bounds._getBoundBox())!==/*laya.d3.math.ContainmentType.Disjoint*/0;
  31531. else
  31532. return true;
  31533. }
  31534. /**
  31535. *@inheritDoc
  31536. */
  31537. __proto._renderUpdate=function(context,transform){
  31538. var element=context.renderElement;
  31539. switch (element.renderType){
  31540. case /*laya.d3.core.render.RenderElement.RENDERTYPE_NORMAL*/0:
  31541. this._shaderValues.setMatrix4x4(Sprite3D.WORLDMATRIX,transform.worldMatrix);
  31542. break ;
  31543. case /*laya.d3.core.render.RenderElement.RENDERTYPE_STATICBATCH*/1:
  31544. this._oriDefineValue=this._defineDatas.value;
  31545. if (transform)
  31546. this._shaderValues.setMatrix4x4(Sprite3D.WORLDMATRIX,transform.worldMatrix);
  31547. else
  31548. this._shaderValues.setMatrix4x4(Sprite3D.WORLDMATRIX,Matrix4x4.DEFAULT);
  31549. this._defineDatas.add(MeshSprite3D.SHADERDEFINE_UV1);
  31550. this._defineDatas.remove(RenderableSprite3D.SHADERDEFINE_SCALEOFFSETLIGHTINGMAPUV);
  31551. break ;
  31552. case /*laya.d3.core.render.RenderElement.RENDERTYPE_VERTEXBATCH*/3:
  31553. this._shaderValues.setMatrix4x4(Sprite3D.WORLDMATRIX,Matrix4x4.DEFAULT);
  31554. break ;
  31555. case /*laya.d3.core.render.RenderElement.RENDERTYPE_INSTANCEBATCH*/2:;
  31556. var worldMatrixData=SubMeshInstanceBatch.instance.instanceWorldMatrixData;
  31557. var insBatches=element.instanceBatchElementList;
  31558. var count=insBatches.length;
  31559. for (var i=0;i < count;i++)
  31560. worldMatrixData.set(insBatches[i]._transform.worldMatrix.elements,i *16);
  31561. SubMeshInstanceBatch.instance.instanceWorldMatrixBuffer.setData(worldMatrixData,0,0,count *16);
  31562. this._defineDatas.add(MeshSprite3D.SHADERDEFINE_GPU_INSTANCE);
  31563. break ;
  31564. }
  31565. }
  31566. /**
  31567. *@inheritDoc
  31568. */
  31569. __proto._renderUpdateWithCamera=function(context,transform){
  31570. var projectionView=context.projectionViewMatrix;
  31571. var element=context.renderElement;
  31572. switch (element.renderType){
  31573. case /*laya.d3.core.render.RenderElement.RENDERTYPE_NORMAL*/0:
  31574. case /*laya.d3.core.render.RenderElement.RENDERTYPE_STATICBATCH*/1:
  31575. case /*laya.d3.core.render.RenderElement.RENDERTYPE_VERTEXBATCH*/3:
  31576. if (transform){
  31577. Matrix4x4.multiply(projectionView,transform.worldMatrix,this._projectionViewWorldMatrix);
  31578. this._shaderValues.setMatrix4x4(Sprite3D.MVPMATRIX,this._projectionViewWorldMatrix);
  31579. }else {
  31580. this._shaderValues.setMatrix4x4(Sprite3D.MVPMATRIX,projectionView);
  31581. }
  31582. break ;
  31583. case /*laya.d3.core.render.RenderElement.RENDERTYPE_INSTANCEBATCH*/2:;
  31584. var mvpMatrixData=SubMeshInstanceBatch.instance.instanceMVPMatrixData;
  31585. var insBatches=element.instanceBatchElementList;
  31586. var count=insBatches.length;
  31587. for (var i=0;i < count;i++){
  31588. var worldMat=insBatches[i]._transform.worldMatrix;
  31589. Utils3D.mulMatrixByArray(projectionView.elements,0,worldMat.elements,0,mvpMatrixData,i *16);
  31590. }
  31591. SubMeshInstanceBatch.instance.instanceMVPMatrixBuffer.setData(mvpMatrixData,0,0,count *16);
  31592. break ;
  31593. }
  31594. }
  31595. /**
  31596. *@inheritDoc
  31597. */
  31598. __proto._renderUpdateWithCameraForNative=function(context,transform){
  31599. var projectionView=context.projectionViewMatrix;
  31600. var element=context.renderElement;
  31601. switch (element.renderType){
  31602. case /*laya.d3.core.render.RenderElement.RENDERTYPE_NORMAL*/0:
  31603. if (transform){
  31604. Matrix4x4.multiply(projectionView,transform.worldMatrix,this._projectionViewWorldMatrix);
  31605. this._shaderValues.setMatrix4x4(Sprite3D.MVPMATRIX,this._projectionViewWorldMatrix);
  31606. }else {
  31607. this._shaderValues.setMatrix4x4(Sprite3D.MVPMATRIX,projectionView);
  31608. }
  31609. break ;
  31610. case /*laya.d3.core.render.RenderElement.RENDERTYPE_STATICBATCH*/1:
  31611. case /*laya.d3.core.render.RenderElement.RENDERTYPE_VERTEXBATCH*/3:;
  31612. var noteValue=ShaderData._SET_RUNTIME_VALUE_MODE_REFERENCE_;
  31613. ShaderData.setRuntimeValueMode(false);
  31614. if (transform){
  31615. Matrix4x4.multiply(projectionView,transform.worldMatrix,this._projectionViewWorldMatrix);
  31616. this._shaderValues.setMatrix4x4(Sprite3D.MVPMATRIX,this._projectionViewWorldMatrix);
  31617. }else {
  31618. this._shaderValues.setMatrix4x4(Sprite3D.MVPMATRIX,projectionView);
  31619. }
  31620. ShaderData.setRuntimeValueMode(noteValue);
  31621. break ;
  31622. case /*laya.d3.core.render.RenderElement.RENDERTYPE_INSTANCEBATCH*/2:;
  31623. var mvpMatrixData=SubMeshInstanceBatch.instance.instanceMVPMatrixData;
  31624. var insBatches=element.instanceBatchElementList;
  31625. var count=insBatches.length;
  31626. for (var i=0;i < count;i++){
  31627. var worldMat=insBatches[i]._transform.worldMatrix;
  31628. Utils3D.mulMatrixByArray(projectionView.elements,0,worldMat.elements,0,mvpMatrixData,i *16);
  31629. }
  31630. SubMeshInstanceBatch.instance.instanceMVPMatrixBuffer.setData(mvpMatrixData,0,0,count *16);
  31631. break ;
  31632. }
  31633. }
  31634. /**
  31635. *@private
  31636. */
  31637. __proto._revertBatchRenderUpdate=function(context){
  31638. var element=context.renderElement;
  31639. switch (element.renderType){
  31640. case /*laya.d3.core.render.RenderElement.RENDERTYPE_STATICBATCH*/1:
  31641. this._defineDatas.value=this._oriDefineValue;
  31642. break ;
  31643. case /*laya.d3.core.render.RenderElement.RENDERTYPE_INSTANCEBATCH*/2:
  31644. this._defineDatas.remove(MeshSprite3D.SHADERDEFINE_GPU_INSTANCE);
  31645. break ;
  31646. }
  31647. }
  31648. /**
  31649. *@inheritDoc
  31650. */
  31651. __proto._destroy=function(){
  31652. (this._isPartOfStaticBatch)&& (MeshRenderStaticBatchManager.instance._destroyRenderSprite(this._owner));
  31653. _super.prototype._destroy.call(this);
  31654. }
  31655. __static(MeshRenderer,
  31656. ['_tempVector30',function(){return this._tempVector30=new Vector3();},'_tempVector31',function(){return this._tempVector31=new Vector3();}
  31657. ]);
  31658. return MeshRenderer;
  31659. })(BaseRender)
  31660. /**
  31661. *<code>TrailRenderer</code> 类用于创建拖尾渲染器。
  31662. */
  31663. //class laya.d3.core.trail.TrailRenderer extends laya.d3.core.render.BaseRender
  31664. var TrailRenderer=(function(_super){
  31665. function TrailRenderer(owner){
  31666. this._projectionViewWorldMatrix=new Matrix4x4();
  31667. TrailRenderer.__super.call(this,owner);
  31668. }
  31669. __class(TrailRenderer,'laya.d3.core.trail.TrailRenderer',_super);
  31670. var __proto=TrailRenderer.prototype;
  31671. /**
  31672. *@inheritDoc
  31673. */
  31674. __proto._calculateBoundingBox=function(){
  31675. var min=this._bounds.getMin();
  31676. min.x=-Number.MAX_VALUE;
  31677. min.y=-Number.MAX_VALUE;
  31678. min.z=-Number.MAX_VALUE;
  31679. this._bounds.setMin(min);
  31680. var max=this._bounds.getMax();
  31681. max.x=Number.MAX_VALUE;
  31682. max.y=Number.MAX_VALUE;
  31683. max.z=Number.MAX_VALUE;
  31684. this._bounds.setMax(max);
  31685. if (Render.supportWebGLPlusCulling){
  31686. min=this._bounds.getMin();
  31687. max=this._bounds.getMax();
  31688. var buffer=FrustumCulling._cullingBuffer;
  31689. buffer[this._cullingBufferIndex+1]=min.x;
  31690. buffer[this._cullingBufferIndex+2]=min.y;
  31691. buffer[this._cullingBufferIndex+3]=min.z;
  31692. buffer[this._cullingBufferIndex+4]=max.x;
  31693. buffer[this._cullingBufferIndex+5]=max.y;
  31694. buffer[this._cullingBufferIndex+6]=max.z;
  31695. }
  31696. }
  31697. /**
  31698. *@inheritDoc
  31699. */
  31700. __proto._needRender=function(boundFrustum){
  31701. return true;
  31702. }
  31703. /**
  31704. *@inheritDoc
  31705. */
  31706. __proto._renderUpdate=function(state,transform){
  31707. _super.prototype._renderUpdate.call(this,state,transform);
  31708. (this._owner).trailFilter._update(state);
  31709. }
  31710. /**
  31711. *@inheritDoc
  31712. */
  31713. __proto._renderUpdateWithCamera=function(context,transform){
  31714. var projectionView=context.projectionViewMatrix;
  31715. if (transform){
  31716. Matrix4x4.multiply(projectionView,transform.worldMatrix,this._projectionViewWorldMatrix);
  31717. this._shaderValues.setMatrix4x4(Sprite3D.MVPMATRIX,this._projectionViewWorldMatrix);
  31718. }else {
  31719. this._shaderValues.setMatrix4x4(Sprite3D.MVPMATRIX,projectionView);
  31720. }
  31721. }
  31722. return TrailRenderer;
  31723. })(BaseRender)
  31724. /**
  31725. *<code>PixelLineRenderer</code> 类用于线渲染器。
  31726. */
  31727. //class laya.d3.core.pixelLine.PixelLineRenderer extends laya.d3.core.render.BaseRender
  31728. var PixelLineRenderer=(function(_super){
  31729. function PixelLineRenderer(owner){
  31730. /**@private */
  31731. this._projectionViewWorldMatrix=null;
  31732. PixelLineRenderer.__super.call(this,owner);
  31733. this._projectionViewWorldMatrix=new Matrix4x4();
  31734. }
  31735. __class(PixelLineRenderer,'laya.d3.core.pixelLine.PixelLineRenderer',_super);
  31736. var __proto=PixelLineRenderer.prototype;
  31737. /**
  31738. *@inheritDoc
  31739. */
  31740. __proto._calculateBoundingBox=function(){
  31741. var min=this._bounds.getMin();
  31742. min.x=-Number.MAX_VALUE;
  31743. min.y=-Number.MAX_VALUE;
  31744. min.z=-Number.MAX_VALUE;
  31745. this._bounds.setMin(min);
  31746. var max=this._bounds.getMax();
  31747. max.x=Number.MAX_VALUE;
  31748. max.y=Number.MAX_VALUE;
  31749. max.z=Number.MAX_VALUE;
  31750. this._bounds.setMax(max);
  31751. if (Render.supportWebGLPlusCulling){
  31752. min=this._bounds.getMin();
  31753. max=this._bounds.getMax();
  31754. var buffer=FrustumCulling._cullingBuffer;
  31755. buffer[this._cullingBufferIndex+1]=min.x;
  31756. buffer[this._cullingBufferIndex+2]=min.y;
  31757. buffer[this._cullingBufferIndex+3]=min.z;
  31758. buffer[this._cullingBufferIndex+4]=max.x;
  31759. buffer[this._cullingBufferIndex+5]=max.y;
  31760. buffer[this._cullingBufferIndex+6]=max.z;
  31761. }
  31762. }
  31763. /**
  31764. *@inheritDoc
  31765. */
  31766. __proto._renderUpdateWithCamera=function(context,transform){
  31767. var projectionView=context.projectionViewMatrix;
  31768. var sv=this._shaderValues;
  31769. if (transform){
  31770. var worldMat=transform.worldMatrix;
  31771. sv.setMatrix4x4(Sprite3D.WORLDMATRIX,worldMat);
  31772. Matrix4x4.multiply(projectionView,worldMat,this._projectionViewWorldMatrix);
  31773. sv.setMatrix4x4(Sprite3D.MVPMATRIX,this._projectionViewWorldMatrix);
  31774. }else {
  31775. sv.setMatrix4x4(Sprite3D.WORLDMATRIX,Matrix4x4.DEFAULT);
  31776. sv.setMatrix4x4(Sprite3D.MVPMATRIX,projectionView);
  31777. }
  31778. }
  31779. return PixelLineRenderer;
  31780. })(BaseRender)
  31781. /**
  31782. *<code>Scene3D</code> 类用于实现场景。
  31783. */
  31784. //class laya.d3.core.scene.Scene3D extends laya.display.Sprite
  31785. var Scene3D=(function(_super){
  31786. function Scene3D(){
  31787. /**@private */
  31788. //this._url=null;
  31789. /**@private */
  31790. //this._group=null;
  31791. /**@private */
  31792. this._reflectionMode=1;
  31793. /**@private */
  31794. this._enableLightCount=3;
  31795. /**@private */
  31796. //this._renderTargetTexture=null;
  31797. /**@private */
  31798. //this._enableFog=false;
  31799. /**@private */
  31800. //this._physicsSimulation=null;
  31801. /**@private */
  31802. //this._octree=null;
  31803. /**@private */
  31804. //this._shaderValues=null;
  31805. /**@private */
  31806. //this._defineDatas=null;
  31807. /**是否启用灯光。*/
  31808. this.enableLight=true;
  31809. //阴影相关变量
  31810. //this.parallelSplitShadowMaps=null;
  31811. /**@private */
  31812. //this._debugTool=null;
  31813. this._time=0;
  31814. /**@private [NATIVE]*/
  31815. //this._cullingBufferIndices=null;
  31816. /**@private [NATIVE]*/
  31817. //this._cullingBufferResult=null;
  31818. Scene3D.__super.call(this);
  31819. this._lights=[];
  31820. this._lightmaps=[];
  31821. this._skyRenderer=new SkyRenderer();
  31822. this._input=new Input3D();
  31823. this._timer=Laya.timer;
  31824. this._collsionTestList=[];
  31825. this._renders=new SimpleSingletonList();
  31826. this._opaqueQueue=new RenderQueue(false);
  31827. this._transparentQueue=new RenderQueue(true);
  31828. this._cameraPool=[];
  31829. this._animatorPool=new SimpleSingletonList();
  31830. this._scriptPool=new SimpleSingletonList();
  31831. this._castShadowRenders=new CastShadowList();
  31832. this.currentCreationLayer=Math.pow(2,0);
  31833. this._key=new SubmitKey();
  31834. this._pickIdToSprite=new Object();
  31835. if (Laya3D._enbalePhysics)
  31836. this._physicsSimulation=new PhysicsSimulation(Laya3D.physicsSettings);
  31837. this._defineDatas=new DefineDatas();
  31838. this._shaderValues=new ShaderData(null);
  31839. this.parallelSplitShadowMaps=[];
  31840. this.enableFog=false;
  31841. this.fogStart=300;
  31842. this.fogRange=1000;
  31843. this.fogColor=new Vector3(0.7,0.7,0.7);
  31844. this.ambientColor=new Vector3(0.212,0.227,0.259);
  31845. this.reflectionIntensity=1.0;
  31846. (WebGL.shaderHighPrecision)&& (this._defineDatas.add(Shader3D.SHADERDEFINE_HIGHPRECISION));
  31847. if (Render.supportWebGLPlusCulling){
  31848. this._cullingBufferIndices=new Int32Array(1024);
  31849. this._cullingBufferResult=new Int32Array(1024);
  31850. }
  31851. this._shaderValues.setTexture(laya.d3.core.scene.Scene3D.RANGEATTENUATIONTEXTURE,ShaderInit3D._rangeAttenTex);
  31852. this._scene=this;
  31853. if (Laya3D._enbalePhysics && !PhysicsSimulation.disableSimulation)
  31854. this._input.__init__(Render.canvas,this);
  31855. var config=Laya3D._config;
  31856. if (config.octreeCulling){
  31857. this._octree=new BoundsOctree(config.octreeInitialSize,config.octreeInitialCenter,config.octreeMinNodeSize,config.octreeLooseness);
  31858. }
  31859. if (Laya3D._config.debugFrustumCulling){
  31860. this._debugTool=new PixelLineSprite3D();
  31861. var lineMaterial=new PixelLineMaterial();
  31862. lineMaterial.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_TRANSPARENT*/3000;
  31863. lineMaterial.alphaTest=false;
  31864. lineMaterial.depthWrite=false;
  31865. lineMaterial.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  31866. lineMaterial.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  31867. lineMaterial.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_SRC_ALPHA*/0x0302;
  31868. lineMaterial.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA*/0x0303;
  31869. lineMaterial.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  31870. this._debugTool.pixelLineRenderer.sharedMaterial=lineMaterial;
  31871. }
  31872. }
  31873. __class(Scene3D,'laya.d3.core.scene.Scene3D',_super);
  31874. var __proto=Scene3D.prototype;
  31875. Laya.imps(__proto,{"laya.webgl.submit.ISubmit":true,"laya.resource.ICreateResource":true})
  31876. /**
  31877. *@private
  31878. *[Editer]
  31879. */
  31880. __proto._allotPickColorByID=function(id,pickColor){
  31881. var pickColorR=Math.floor(id / (255 *255));
  31882. id-=pickColorR *255 *255;
  31883. var pickColorG=Math.floor(id / 255);
  31884. id-=pickColorG *255;
  31885. var pickColorB=id;
  31886. pickColor.x=pickColorR / 255;
  31887. pickColor.y=pickColorG / 255;
  31888. pickColor.z=pickColorB / 255;
  31889. pickColor.w=1.0;
  31890. }
  31891. /**
  31892. *@private
  31893. *[Editer]
  31894. */
  31895. __proto._searchIDByPickColor=function(pickColor){
  31896. var id=pickColor.x *255 *255+pickColor.y *255+pickColor.z;
  31897. return id;
  31898. }
  31899. /**
  31900. *@private
  31901. */
  31902. __proto._setLightmapToChildNode=function(sprite){
  31903. if ((sprite instanceof laya.d3.core.RenderableSprite3D ))
  31904. (sprite)._render._applyLightMapParams();
  31905. var children=sprite._children;
  31906. for (var i=0,n=children.length;i < n;i++)
  31907. this._setLightmapToChildNode(children[i]);
  31908. }
  31909. /**
  31910. *@private
  31911. */
  31912. __proto._update=function(){
  31913. var delta=this.timer._delta / 1000;
  31914. this._time+=delta;
  31915. this._shaderValues.setNumber(laya.d3.core.scene.Scene3D.TIME,this._time);
  31916. var simulation=this._physicsSimulation;
  31917. if (Laya3D._enbalePhysics && !PhysicsSimulation.disableSimulation){
  31918. simulation._updatePhysicsTransformFromRender();
  31919. PhysicsComponent._addUpdateList=false;
  31920. simulation._simulate(delta);
  31921. simulation._updateCharacters();
  31922. PhysicsComponent._addUpdateList=true;
  31923. simulation._updateCollisions();
  31924. simulation._eventScripts();
  31925. this._input._update();
  31926. }
  31927. this._updateScript();
  31928. Animator._update(this);
  31929. this._lateUpdateScript();
  31930. }
  31931. /**
  31932. *@private
  31933. */
  31934. __proto._binarySearchIndexInCameraPool=function(camera){
  31935. var start=0;
  31936. var end=this._cameraPool.length-1;
  31937. var mid=0;
  31938. while (start <=end){
  31939. mid=Math.floor((start+end)/ 2);
  31940. var midValue=this._cameraPool[mid]._renderingOrder;
  31941. if (midValue==camera._renderingOrder)
  31942. return mid;
  31943. else if (midValue > camera._renderingOrder)
  31944. end=mid-1;
  31945. else
  31946. start=mid+1;
  31947. }
  31948. return start;
  31949. }
  31950. /**
  31951. *@private
  31952. */
  31953. __proto._setCreateURL=function(url){
  31954. this._url=URL.formatURL(url);
  31955. }
  31956. /**
  31957. *@private
  31958. */
  31959. __proto._getGroup=function(){
  31960. return this._group;
  31961. }
  31962. /**
  31963. *@private
  31964. */
  31965. __proto._setGroup=function(value){
  31966. this._group=value;
  31967. }
  31968. /**
  31969. *@private
  31970. */
  31971. __proto._updateScript=function(){
  31972. var pool=this._scriptPool;
  31973. var elements=pool.elements;
  31974. for (var i=0,n=pool.length;i < n;i++){
  31975. var script=elements [i];
  31976. (script && script.enabled)&& (script.onUpdate());
  31977. }
  31978. }
  31979. /**
  31980. *@private
  31981. */
  31982. __proto._lateUpdateScript=function(){
  31983. var pool=this._scriptPool;
  31984. var elements=pool.elements;
  31985. for (var i=0,n=pool.length;i < n;i++){
  31986. var script=elements [i];
  31987. (script && script.enabled)&& (script.onLateUpdate());
  31988. }
  31989. }
  31990. /**
  31991. *@private
  31992. */
  31993. __proto._preRenderScript=function(){
  31994. var pool=this._scriptPool;
  31995. var elements=pool.elements;
  31996. for (var i=0,n=pool.length;i < n;i++){
  31997. var script=elements [i];
  31998. (script && script.enabled)&& (script.onPreRender());
  31999. }
  32000. }
  32001. /**
  32002. *@private
  32003. */
  32004. __proto._postRenderScript=function(){
  32005. var pool=this._scriptPool;
  32006. var elements=pool.elements;
  32007. for (var i=0,n=pool.length;i < n;i++){
  32008. var script=elements [i];
  32009. (script && script.enabled)&& (script.onPostRender());
  32010. }
  32011. }
  32012. /**
  32013. *@private
  32014. */
  32015. __proto._prepareSceneToRender=function(){
  32016. var lightCount=this._lights.length;
  32017. if (lightCount > 0){
  32018. var renderLightCount=0;
  32019. for (var i=0;i < lightCount;i++){
  32020. if (!this._lights[i]._prepareToScene())
  32021. continue ;
  32022. renderLightCount++;
  32023. if (renderLightCount >=this._enableLightCount)
  32024. break ;
  32025. }
  32026. }
  32027. }
  32028. /**
  32029. *@private
  32030. */
  32031. __proto._addCamera=function(camera){
  32032. var index=this._binarySearchIndexInCameraPool(camera);
  32033. var order=camera._renderingOrder;
  32034. var count=this._cameraPool.length;
  32035. while (index < count && this._cameraPool[index]._renderingOrder <=order)
  32036. index++;
  32037. this._cameraPool.splice(index,0,camera);
  32038. }
  32039. /**
  32040. *@private
  32041. */
  32042. __proto._removeCamera=function(camera){
  32043. this._cameraPool.splice(this._cameraPool.indexOf(camera),1);
  32044. }
  32045. /**
  32046. *@private
  32047. */
  32048. __proto._preCulling=function(context,camera){
  32049. FrustumCulling.renderObjectCulling(camera,this,context,this._renders);
  32050. }
  32051. /**
  32052. *@private
  32053. */
  32054. __proto._clear=function(gl,state){
  32055. var viewport=state.viewport;
  32056. var camera=state.camera;
  32057. var renderTarget=camera.getRenderTexture();
  32058. var vpW=viewport.width;
  32059. var vpH=viewport.height;
  32060. var vpX=viewport.x;
  32061. var vpY=camera._getCanvasHeight()-viewport.y-vpH;
  32062. gl.viewport(vpX,vpY,vpW,vpH);
  32063. var flag=0;
  32064. var clearFlag=camera.clearFlag;
  32065. if (clearFlag===/*laya.d3.core.BaseCamera.CLEARFLAG_SKY*/1 && !(camera.skyRenderer._isAvailable()|| this._skyRenderer._isAvailable()))
  32066. clearFlag=/*laya.d3.core.BaseCamera.CLEARFLAG_SOLIDCOLOR*/0;
  32067. switch (clearFlag){
  32068. case /*laya.d3.core.BaseCamera.CLEARFLAG_SOLIDCOLOR*/0:;
  32069. var clearColor=camera.clearColor;
  32070. gl.enable(/*laya.webgl.WebGLContext.SCISSOR_TEST*/0x0C11);
  32071. gl.scissor(vpX,vpY,vpW,vpH);
  32072. if (clearColor)
  32073. gl.clearColor(clearColor.x,clearColor.y,clearColor.z,clearColor.w);
  32074. else
  32075. gl.clearColor(0,0,0,0);
  32076. if (renderTarget){
  32077. flag=/*laya.webgl.WebGLContext.COLOR_BUFFER_BIT*/0x00004000;
  32078. switch (renderTarget.depthStencilFormat){
  32079. case /*laya.resource.BaseTexture.FORMAT_DEPTH_16*/0:
  32080. flag |=/*laya.webgl.WebGLContext.DEPTH_BUFFER_BIT*/0x00000100;
  32081. break ;
  32082. case /*laya.resource.BaseTexture.FORMAT_STENCIL_8*/1:
  32083. flag |=/*laya.webgl.WebGLContext.STENCIL_BUFFER_BIT*/0x00000400;
  32084. break ;
  32085. case /*laya.resource.BaseTexture.FORMAT_DEPTHSTENCIL_16_8*/2:
  32086. flag |=/*laya.webgl.WebGLContext.DEPTH_BUFFER_BIT*/0x00000100;
  32087. flag |=/*laya.webgl.WebGLContext.STENCIL_BUFFER_BIT*/0x00000400;
  32088. break ;
  32089. }
  32090. }else {
  32091. flag=/*laya.webgl.WebGLContext.COLOR_BUFFER_BIT*/0x00004000 | /*laya.webgl.WebGLContext.DEPTH_BUFFER_BIT*/0x00000100;
  32092. }
  32093. WebGLContext.setDepthMask(gl,true);
  32094. gl.clear(flag);
  32095. gl.disable(/*laya.webgl.WebGLContext.SCISSOR_TEST*/0x0C11);
  32096. break ;
  32097. case /*laya.d3.core.BaseCamera.CLEARFLAG_SKY*/1:
  32098. case /*laya.d3.core.BaseCamera.CLEARFLAG_DEPTHONLY*/2:
  32099. gl.enable(/*laya.webgl.WebGLContext.SCISSOR_TEST*/0x0C11);
  32100. gl.scissor(vpX,vpY,vpW,vpH);
  32101. if (renderTarget){
  32102. switch (renderTarget.depthStencilFormat){
  32103. case /*laya.resource.BaseTexture.FORMAT_DEPTH_16*/0:
  32104. flag=/*laya.webgl.WebGLContext.DEPTH_BUFFER_BIT*/0x00000100;
  32105. break ;
  32106. case /*laya.resource.BaseTexture.FORMAT_STENCIL_8*/1:
  32107. flag=/*laya.webgl.WebGLContext.STENCIL_BUFFER_BIT*/0x00000400;
  32108. break ;
  32109. case /*laya.resource.BaseTexture.FORMAT_DEPTHSTENCIL_16_8*/2:
  32110. flag=/*laya.webgl.WebGLContext.DEPTH_BUFFER_BIT*/0x00000100 | /*laya.webgl.WebGLContext.STENCIL_BUFFER_BIT*/0x00000400;
  32111. break ;
  32112. }
  32113. }else {
  32114. flag=/*laya.webgl.WebGLContext.DEPTH_BUFFER_BIT*/0x00000100;
  32115. }
  32116. WebGLContext.setDepthMask(gl,true);
  32117. gl.clear(flag);
  32118. gl.disable(/*laya.webgl.WebGLContext.SCISSOR_TEST*/0x0C11);
  32119. break ;
  32120. case /*laya.d3.core.BaseCamera.CLEARFLAG_NONE*/3:
  32121. break ;
  32122. default :
  32123. throw new Error("BaseScene:camera clearFlag invalid.");
  32124. }
  32125. }
  32126. /**
  32127. *@private
  32128. */
  32129. __proto._renderScene=function(gl,state,customShader,replacementTag){
  32130. var camera=state.camera;
  32131. var position=camera.transform.position;
  32132. camera.getRenderTexture()? this._opaqueQueue._render(state,true,customShader,replacementTag):this._opaqueQueue._render(state,false,customShader,replacementTag);
  32133. if (camera.clearFlag===/*laya.d3.core.BaseCamera.CLEARFLAG_SKY*/1){
  32134. if (camera.skyRenderer._isAvailable())
  32135. camera.skyRenderer._render(state);
  32136. else if (this._skyRenderer._isAvailable())
  32137. this._skyRenderer._render(state);
  32138. }
  32139. camera.getRenderTexture()? this._transparentQueue._render(state,true,customShader,replacementTag):this._transparentQueue._render(state,false,customShader,replacementTag);
  32140. camera._applyPostProcessCommandBuffers();
  32141. if (Laya3D._config.debugFrustumCulling){
  32142. var renderElements=this._debugTool._render._renderElements;
  32143. for (var i=0,n=renderElements.length;i < n;i++){
  32144. renderElements[i]._render(state,false,customShader,replacementTag);
  32145. }
  32146. }
  32147. }
  32148. /**
  32149. *@inheritDoc
  32150. */
  32151. __proto._parse=function(data,spriteMap){
  32152. var lightMapsData=data.lightmaps;
  32153. if (lightMapsData){
  32154. var lightMapCount=lightMapsData.length;
  32155. var lightmaps=__newvec(lightMapCount);
  32156. for (var i=0;i < lightMapCount;i++)
  32157. lightmaps[i]=Loader.getRes(lightMapsData[i].path);
  32158. this.setlightmaps(lightmaps);
  32159. };
  32160. var ambientColorData=data.ambientColor;
  32161. if (ambientColorData){
  32162. var ambCol=this.ambientColor;
  32163. ambCol.fromArray(ambientColorData);
  32164. this.ambientColor=ambCol;
  32165. };
  32166. var skyData=data.sky;
  32167. if (skyData){
  32168. this._skyRenderer.material=Loader.getRes(skyData.material.path);
  32169. switch (skyData.mesh){
  32170. case "SkyBox":
  32171. this._skyRenderer.mesh=SkyBox.instance;
  32172. break ;
  32173. case "SkyDome":
  32174. this._skyRenderer.mesh=SkyDome.instance;
  32175. break ;
  32176. default :
  32177. this.skyRenderer.mesh=SkyBox.instance;
  32178. }
  32179. };
  32180. var reflectionTextureData=data.reflectionTexture;
  32181. reflectionTextureData && (this.customReflection=Loader.getRes(reflectionTextureData));
  32182. this.enableFog=data.enableFog;
  32183. this.fogStart=data.fogStart;
  32184. this.fogRange=data.fogRange;
  32185. var fogColorData=data.fogColor;
  32186. if (fogColorData){
  32187. var fogCol=this.fogColor;
  32188. fogCol.fromArray(fogColorData);
  32189. this.fogColor=fogCol;
  32190. }
  32191. }
  32192. /**
  32193. *@inheritDoc
  32194. */
  32195. __proto._onActive=function(){
  32196. laya.display.Node.prototype._onActive.call(this);
  32197. Laya.stage._scene3Ds.push(this);
  32198. }
  32199. /**
  32200. *@inheritDoc
  32201. */
  32202. __proto._onInActive=function(){
  32203. laya.display.Node.prototype._onInActive.call(this);
  32204. var scenes=Laya.stage._scene3Ds;
  32205. scenes.splice(scenes.indexOf(this),1);
  32206. }
  32207. /**
  32208. *@private
  32209. */
  32210. __proto._addLight=function(light){
  32211. if (this._lights.indexOf(light)< 0)this._lights.push(light);
  32212. }
  32213. /**
  32214. *@private
  32215. */
  32216. __proto._removeLight=function(light){
  32217. var index=this._lights.indexOf(light);
  32218. index >=0 && (this._lights.splice(index,1));
  32219. }
  32220. /**
  32221. *@private
  32222. */
  32223. __proto._addRenderObject=function(render){
  32224. if (this._octree){
  32225. this._octree.add(render);
  32226. }else {
  32227. this._renders.add(render);
  32228. if (Render.supportWebGLPlusCulling){
  32229. var indexInList=render._getIndexInList();
  32230. var length=this._cullingBufferIndices.length;
  32231. if (indexInList >=length){
  32232. var tempIndices=this._cullingBufferIndices;
  32233. var tempResult=this._cullingBufferResult;
  32234. this._cullingBufferIndices=new Int32Array(length+1024);
  32235. this._cullingBufferResult=new Int32Array(length+1024);
  32236. this._cullingBufferIndices.set(tempIndices,0);
  32237. this._cullingBufferResult.set(tempResult,0);
  32238. }
  32239. this._cullingBufferIndices[indexInList]=render._cullingBufferIndex;
  32240. }
  32241. }
  32242. }
  32243. /**
  32244. *@private
  32245. */
  32246. __proto._removeRenderObject=function(render){
  32247. if (this._octree){
  32248. this._octree.remove(render);
  32249. }else {
  32250. var endRender;
  32251. if (Render.supportWebGLPlusCulling){
  32252. endRender=this._renders.elements [this._renders.length-1];
  32253. }
  32254. this._renders.remove(render);
  32255. if (Render.supportWebGLPlusCulling){
  32256. this._cullingBufferIndices[endRender._getIndexInList()]=endRender._cullingBufferIndex;
  32257. }
  32258. }
  32259. }
  32260. /**
  32261. *@private
  32262. */
  32263. __proto._addShadowCastRenderObject=function(render){
  32264. if (this._octree){
  32265. }else {
  32266. this._castShadowRenders.add(render);
  32267. }
  32268. }
  32269. /**
  32270. *@private
  32271. */
  32272. __proto._removeShadowCastRenderObject=function(render){
  32273. if (this._octree){
  32274. }else {
  32275. this._castShadowRenders.remove(render);
  32276. }
  32277. }
  32278. /**
  32279. *@private
  32280. */
  32281. __proto._getRenderQueue=function(index){
  32282. if (index <=2500)
  32283. return this._opaqueQueue;
  32284. else
  32285. return this._transparentQueue;
  32286. }
  32287. /**
  32288. *设置光照贴图。
  32289. *@param value 光照贴图。
  32290. */
  32291. __proto.setlightmaps=function(value){
  32292. var maps=this._lightmaps;
  32293. for (var i=0,n=maps.length;i < n;i++)
  32294. maps[i]._removeReference();
  32295. if (value){
  32296. var count=value.length;
  32297. maps.length=count;
  32298. for (i=0;i < count;i++){
  32299. var lightMap=value[i];
  32300. lightMap._addReference();
  32301. maps[i]=lightMap;
  32302. }
  32303. }else {
  32304. throw new Error("Scene3D: value value can't be null.");
  32305. }
  32306. for (i=0,n=this._children.length;i < n;i++)
  32307. this._setLightmapToChildNode(this._children[i]);
  32308. }
  32309. /**
  32310. *获取光照贴图浅拷贝列表。
  32311. *@return 获取光照贴图浅拷贝列表。
  32312. */
  32313. __proto.getlightmaps=function(){
  32314. return this._lightmaps.slice();
  32315. }
  32316. /**
  32317. *@inheritDoc
  32318. */
  32319. __proto.destroy=function(destroyChild){
  32320. (destroyChild===void 0)&& (destroyChild=true);
  32321. if (this.destroyed)
  32322. return;
  32323. _super.prototype.destroy.call(this,destroyChild);
  32324. this._skyRenderer.destroy();
  32325. this._skyRenderer=null;
  32326. this._lights=null;
  32327. this._lightmaps=null;
  32328. this._renderTargetTexture=null;
  32329. this._shaderValues=null;
  32330. this._renders=null;
  32331. this._castShadowRenders=null;
  32332. this._cameraPool=null;
  32333. this._octree=null;
  32334. this.parallelSplitShadowMaps=null;
  32335. this._physicsSimulation && this._physicsSimulation._destroy();
  32336. Loader.clearRes(this.url);
  32337. }
  32338. /**
  32339. *@inheritDoc
  32340. */
  32341. __proto.render=function(ctx,x,y){
  32342. ctx._curSubmit=Submit.RENDERBASE;
  32343. this._children.length > 0 && ctx.addRenderObject(this);
  32344. }
  32345. /**
  32346. *@private
  32347. */
  32348. __proto.renderSubmit=function(){
  32349. var gl=LayaGL.instance;
  32350. this._prepareSceneToRender();
  32351. var i=0,n=0,n1=0;
  32352. for (i=0,n=this._cameraPool.length,n1=n-1;i < n;i++){
  32353. if (Render.supportWebGLPlusRendering)
  32354. ShaderData.setRuntimeValueMode((i==n1)? true :false);
  32355. var camera=this._cameraPool [i];
  32356. camera.enableRender && camera.render();
  32357. }
  32358. Context.set2DRenderConfig();
  32359. return 1;
  32360. }
  32361. /**
  32362. *@private
  32363. */
  32364. __proto.getRenderType=function(){
  32365. return 0;
  32366. }
  32367. /**
  32368. *@private
  32369. */
  32370. __proto.releaseRender=function(){}
  32371. /**
  32372. *@private
  32373. */
  32374. __proto.reUse=function(context,pos){
  32375. return 0;
  32376. }
  32377. /**
  32378. *设置雾化颜色。
  32379. *@param value 雾化颜色。
  32380. */
  32381. /**
  32382. *获取雾化颜色。
  32383. *@return 雾化颜色。
  32384. */
  32385. __getset(0,__proto,'fogColor',function(){
  32386. return this._shaderValues.getVector(laya.d3.core.scene.Scene3D.FOGCOLOR);
  32387. },function(value){
  32388. this._shaderValues.setVector3(laya.d3.core.scene.Scene3D.FOGCOLOR,value);
  32389. });
  32390. /**
  32391. *设置是否允许雾化。
  32392. *@param value 是否允许雾化。
  32393. */
  32394. /**
  32395. *获取是否允许雾化。
  32396. *@return 是否允许雾化。
  32397. */
  32398. __getset(0,__proto,'enableFog',function(){
  32399. return this._enableFog;
  32400. },function(value){
  32401. if (this._enableFog!==value){
  32402. this._enableFog=value;
  32403. if (value){
  32404. this._defineDatas.add(laya.d3.core.scene.Scene3D.SHADERDEFINE_FOG);
  32405. }else
  32406. this._defineDatas.remove(laya.d3.core.scene.Scene3D.SHADERDEFINE_FOG);
  32407. }
  32408. });
  32409. /**
  32410. *获取资源的URL地址。
  32411. *@return URL地址。
  32412. */
  32413. __getset(0,__proto,'url',function(){
  32414. return this._url;
  32415. });
  32416. /**
  32417. *设置雾化起始位置。
  32418. *@param value 雾化起始位置。
  32419. */
  32420. /**
  32421. *获取雾化起始位置。
  32422. *@return 雾化起始位置。
  32423. */
  32424. __getset(0,__proto,'fogStart',function(){
  32425. return this._shaderValues.getNumber(laya.d3.core.scene.Scene3D.FOGSTART);
  32426. },function(value){
  32427. this._shaderValues.setNumber(laya.d3.core.scene.Scene3D.FOGSTART,value);
  32428. });
  32429. /**
  32430. *设置反射强度。
  32431. *@param 反射强度。
  32432. */
  32433. /**
  32434. *获取反射强度。
  32435. *@return 反射强度。
  32436. */
  32437. __getset(0,__proto,'reflectionIntensity',function(){
  32438. return this._shaderValues.getNumber(laya.d3.core.scene.Scene3D.REFLETIONINTENSITY);
  32439. },function(value){
  32440. value=Math.max(Math.min(value,1.0),0.0);
  32441. this._shaderValues.setNumber(laya.d3.core.scene.Scene3D.REFLETIONINTENSITY,value);
  32442. });
  32443. /**
  32444. *获取天空渲染器。
  32445. *@return 天空渲染器。
  32446. */
  32447. __getset(0,__proto,'skyRenderer',function(){
  32448. return this._skyRenderer;
  32449. });
  32450. /**
  32451. *设置雾化范围。
  32452. *@param value 雾化范围。
  32453. */
  32454. /**
  32455. *获取雾化范围。
  32456. *@return 雾化范围。
  32457. */
  32458. __getset(0,__proto,'fogRange',function(){
  32459. return this._shaderValues.getNumber(laya.d3.core.scene.Scene3D.FOGRANGE);
  32460. },function(value){
  32461. this._shaderValues.setNumber(laya.d3.core.scene.Scene3D.FOGRANGE,value);
  32462. });
  32463. /**
  32464. *设置环境光颜色。
  32465. *@param value 环境光颜色。
  32466. */
  32467. /**
  32468. *获取环境光颜色。
  32469. *@return 环境光颜色。
  32470. */
  32471. __getset(0,__proto,'ambientColor',function(){
  32472. return this._shaderValues.getVector(laya.d3.core.scene.Scene3D.AMBIENTCOLOR);
  32473. },function(value){
  32474. this._shaderValues.setVector3(laya.d3.core.scene.Scene3D.AMBIENTCOLOR,value);
  32475. });
  32476. /**
  32477. *设置反射贴图。
  32478. *@param 反射贴图。
  32479. */
  32480. /**
  32481. *获取反射贴图。
  32482. *@return 反射贴图。
  32483. */
  32484. __getset(0,__proto,'customReflection',function(){
  32485. return this._shaderValues.getTexture(laya.d3.core.scene.Scene3D.REFLECTIONTEXTURE);
  32486. },function(value){
  32487. this._shaderValues.setTexture(laya.d3.core.scene.Scene3D.REFLECTIONTEXTURE,value);
  32488. if (value)
  32489. this._defineDatas.add(laya.d3.core.scene.Scene3D.SHADERDEFINE_REFLECTMAP);
  32490. else
  32491. this._defineDatas.remove(laya.d3.core.scene.Scene3D.SHADERDEFINE_REFLECTMAP);
  32492. });
  32493. /**
  32494. *获取物理模拟器。
  32495. *@return 物理模拟器。
  32496. */
  32497. __getset(0,__proto,'physicsSimulation',function(){
  32498. return this._physicsSimulation;
  32499. });
  32500. /**
  32501. *设置反射模式。
  32502. *@param value 反射模式。
  32503. */
  32504. /**
  32505. *获取反射模式。
  32506. *@return 反射模式。
  32507. */
  32508. __getset(0,__proto,'reflectionMode',function(){
  32509. return this._reflectionMode;
  32510. },function(value){
  32511. this._reflectionMode=value;
  32512. });
  32513. /**
  32514. *设置场景时钟。
  32515. */
  32516. /**
  32517. *获取场景时钟。
  32518. */
  32519. __getset(0,__proto,'timer',function(){
  32520. return this._timer;
  32521. },function(value){
  32522. this._timer=value;
  32523. });
  32524. /**
  32525. *获取输入。
  32526. *@return 输入。
  32527. */
  32528. __getset(0,__proto,'input',function(){
  32529. return this._input;
  32530. });
  32531. Scene3D._parse=function(data,propertyParams,constructParams){
  32532. var json=data.data;
  32533. var outBatchSprits=[];
  32534. var scene;
  32535. switch (data.version){
  32536. case "LAYAHIERARCHY:02":
  32537. scene=Utils3D._createNodeByJson02(json,outBatchSprits);
  32538. break ;
  32539. default :
  32540. scene=Utils3D._createNodeByJson(json,outBatchSprits);
  32541. }
  32542. StaticBatchManager.combine(null,outBatchSprits);
  32543. return scene;
  32544. }
  32545. Scene3D.load=function(url,complete){
  32546. Laya.loader.create(url,complete,null,/*Laya3D.HIERARCHY*/"HIERARCHY");
  32547. }
  32548. Scene3D.REFLECTIONMODE_SKYBOX=0;
  32549. Scene3D.REFLECTIONMODE_CUSTOM=1;
  32550. Scene3D.SHADERDEFINE_FOG=0;
  32551. Scene3D.SHADERDEFINE_DIRECTIONLIGHT=0;
  32552. Scene3D.SHADERDEFINE_POINTLIGHT=0;
  32553. Scene3D.SHADERDEFINE_SPOTLIGHT=0;
  32554. Scene3D.SHADERDEFINE_CAST_SHADOW=0;
  32555. Scene3D.SHADERDEFINE_SHADOW_PSSM1=0;
  32556. Scene3D.SHADERDEFINE_SHADOW_PSSM2=0;
  32557. Scene3D.SHADERDEFINE_SHADOW_PSSM3=0;
  32558. Scene3D.SHADERDEFINE_SHADOW_PCF_NO=0;
  32559. Scene3D.SHADERDEFINE_SHADOW_PCF1=0;
  32560. Scene3D.SHADERDEFINE_SHADOW_PCF2=0;
  32561. Scene3D.SHADERDEFINE_SHADOW_PCF3=0;
  32562. Scene3D.SHADERDEFINE_REFLECTMAP=0;
  32563. __static(Scene3D,
  32564. ['FOGCOLOR',function(){return this.FOGCOLOR=Shader3D.propertyNameToID("u_FogColor");},'FOGSTART',function(){return this.FOGSTART=Shader3D.propertyNameToID("u_FogStart");},'FOGRANGE',function(){return this.FOGRANGE=Shader3D.propertyNameToID("u_FogRange");},'LIGHTDIRECTION',function(){return this.LIGHTDIRECTION=Shader3D.propertyNameToID("u_DirectionLight.Direction");},'LIGHTDIRCOLOR',function(){return this.LIGHTDIRCOLOR=Shader3D.propertyNameToID("u_DirectionLight.Color");},'POINTLIGHTPOS',function(){return this.POINTLIGHTPOS=Shader3D.propertyNameToID("u_PointLight.Position");},'POINTLIGHTRANGE',function(){return this.POINTLIGHTRANGE=Shader3D.propertyNameToID("u_PointLight.Range");},'POINTLIGHTATTENUATION',function(){return this.POINTLIGHTATTENUATION=Shader3D.propertyNameToID("u_PointLight.Attenuation");},'POINTLIGHTCOLOR',function(){return this.POINTLIGHTCOLOR=Shader3D.propertyNameToID("u_PointLight.Color");},'SPOTLIGHTPOS',function(){return this.SPOTLIGHTPOS=Shader3D.propertyNameToID("u_SpotLight.Position");},'SPOTLIGHTDIRECTION',function(){return this.SPOTLIGHTDIRECTION=Shader3D.propertyNameToID("u_SpotLight.Direction");},'SPOTLIGHTSPOTANGLE',function(){return this.SPOTLIGHTSPOTANGLE=Shader3D.propertyNameToID("u_SpotLight.Spot");},'SPOTLIGHTRANGE',function(){return this.SPOTLIGHTRANGE=Shader3D.propertyNameToID("u_SpotLight.Range");},'SPOTLIGHTCOLOR',function(){return this.SPOTLIGHTCOLOR=Shader3D.propertyNameToID("u_SpotLight.Color");},'SHADOWDISTANCE',function(){return this.SHADOWDISTANCE=Shader3D.propertyNameToID("u_shadowPSSMDistance");},'SHADOWLIGHTVIEWPROJECT',function(){return this.SHADOWLIGHTVIEWPROJECT=Shader3D.propertyNameToID("u_lightShadowVP");},'SHADOWMAPPCFOFFSET',function(){return this.SHADOWMAPPCFOFFSET=Shader3D.propertyNameToID("u_shadowPCFoffset");},'SHADOWMAPTEXTURE1',function(){return this.SHADOWMAPTEXTURE1=Shader3D.propertyNameToID("u_shadowMap1");},'SHADOWMAPTEXTURE2',function(){return this.SHADOWMAPTEXTURE2=Shader3D.propertyNameToID("u_shadowMap2");},'SHADOWMAPTEXTURE3',function(){return this.SHADOWMAPTEXTURE3=Shader3D.propertyNameToID("u_shadowMap3");},'AMBIENTCOLOR',function(){return this.AMBIENTCOLOR=Shader3D.propertyNameToID("u_AmbientColor");},'REFLECTIONTEXTURE',function(){return this.REFLECTIONTEXTURE=Shader3D.propertyNameToID("u_ReflectTexture");},'REFLETIONINTENSITY',function(){return this.REFLETIONINTENSITY=Shader3D.propertyNameToID("u_ReflectIntensity");},'TIME',function(){return this.TIME=Shader3D.propertyNameToID("u_Time");},'ANGLEATTENUATIONTEXTURE',function(){return this.ANGLEATTENUATIONTEXTURE=Shader3D.propertyNameToID("u_AngleTexture");},'RANGEATTENUATIONTEXTURE',function(){return this.RANGEATTENUATIONTEXTURE=Shader3D.propertyNameToID("u_RangeTexture");},'POINTLIGHTMATRIX',function(){return this.POINTLIGHTMATRIX=Shader3D.propertyNameToID("u_PointLightMatrix");},'SPOTLIGHTMATRIX',function(){return this.SPOTLIGHTMATRIX=Shader3D.propertyNameToID("u_SpotLightMatrix");}
  32565. ]);
  32566. return Scene3D;
  32567. })(Sprite)
  32568. /**
  32569. *<code>RenderableSprite3D</code> 类用于可渲染3D精灵的父类,抽象类不允许实例。
  32570. */
  32571. //class laya.d3.core.RenderableSprite3D extends laya.d3.core.Sprite3D
  32572. var RenderableSprite3D=(function(_super){
  32573. function RenderableSprite3D(name){
  32574. this.pickColor=null;
  32575. /**@private */
  32576. this._render=null;
  32577. RenderableSprite3D.__super.call(this,name);
  32578. }
  32579. __class(RenderableSprite3D,'laya.d3.core.RenderableSprite3D',_super);
  32580. var __proto=RenderableSprite3D.prototype;
  32581. /**
  32582. *@inheritDoc
  32583. */
  32584. __proto._onInActive=function(){
  32585. laya.display.Node.prototype._onInActive.call(this);
  32586. var scene3D=this._scene;
  32587. scene3D._removeRenderObject(this._render);
  32588. (this._render.castShadow)&& (scene3D._removeShadowCastRenderObject(this._render));
  32589. }
  32590. /**
  32591. *@inheritDoc
  32592. */
  32593. __proto._onActive=function(){
  32594. laya.display.Node.prototype._onActive.call(this);
  32595. var scene3D=this._scene;
  32596. scene3D._addRenderObject(this._render);
  32597. (this._render.castShadow)&& (scene3D._addShadowCastRenderObject(this._render));
  32598. }
  32599. /**
  32600. *@inheritDoc
  32601. */
  32602. __proto._onActiveInScene=function(){
  32603. laya.display.Node.prototype._onActiveInScene.call(this);
  32604. if (Laya3D._editerEnvironment){
  32605. var scene=this._scene;
  32606. var pickColor=new Vector4();
  32607. scene._allotPickColorByID(this.id,pickColor);
  32608. scene._pickIdToSprite[this.id]=this;
  32609. this._render._shaderValues.setVector(laya.d3.core.RenderableSprite3D.PICKCOLOR,pickColor);
  32610. }
  32611. }
  32612. /**
  32613. *@private
  32614. */
  32615. __proto._addToInitStaticBatchManager=function(){}
  32616. /**
  32617. *@inheritDoc
  32618. */
  32619. __proto._setBelongScene=function(scene){
  32620. laya.display.Node.prototype._setBelongScene.call(this,scene);
  32621. this._render._setBelongScene(scene);
  32622. }
  32623. /**
  32624. *@inheritDoc
  32625. */
  32626. __proto._setUnBelongScene=function(){
  32627. this._render._defineDatas.remove(laya.d3.core.RenderableSprite3D.SAHDERDEFINE_LIGHTMAP);
  32628. laya.display.Node.prototype._setUnBelongScene.call(this);
  32629. }
  32630. /**
  32631. *@inheritDoc
  32632. */
  32633. __proto._changeHierarchyAnimator=function(animator){
  32634. if (this._hierarchyAnimator){
  32635. var renderableSprites=this._hierarchyAnimator._renderableSprites;
  32636. renderableSprites.splice(renderableSprites.indexOf(this),1);
  32637. }
  32638. if (animator)
  32639. animator._renderableSprites.push(this);
  32640. _super.prototype._changeHierarchyAnimator.call(this,animator);
  32641. }
  32642. /**
  32643. *@inheritDoc
  32644. */
  32645. __proto.destroy=function(destroyChild){
  32646. (destroyChild===void 0)&& (destroyChild=true);
  32647. _super.prototype.destroy.call(this,destroyChild);
  32648. this._render._destroy();
  32649. this._render=null;
  32650. }
  32651. RenderableSprite3D.__init__=function(){
  32652. RenderableSprite3D.SHADERDEFINE_RECEIVE_SHADOW=RenderableSprite3D.shaderDefines.registerDefine("RECEIVESHADOW");
  32653. RenderableSprite3D.SHADERDEFINE_SCALEOFFSETLIGHTINGMAPUV=RenderableSprite3D.shaderDefines.registerDefine("SCALEOFFSETLIGHTINGMAPUV");
  32654. RenderableSprite3D.SAHDERDEFINE_LIGHTMAP=RenderableSprite3D.shaderDefines.registerDefine("LIGHTMAP");
  32655. }
  32656. RenderableSprite3D.SHADERDEFINE_RECEIVE_SHADOW=0;
  32657. RenderableSprite3D.SHADERDEFINE_SCALEOFFSETLIGHTINGMAPUV=0;
  32658. RenderableSprite3D.SAHDERDEFINE_LIGHTMAP=0;
  32659. __static(RenderableSprite3D,
  32660. ['LIGHTMAPSCALEOFFSET',function(){return this.LIGHTMAPSCALEOFFSET=Shader3D.propertyNameToID("u_LightmapScaleOffset");},'LIGHTMAP',function(){return this.LIGHTMAP=Shader3D.propertyNameToID("u_LightMap");},'PICKCOLOR',function(){return this.PICKCOLOR=Shader3D.propertyNameToID("u_PickColor");},'shaderDefines',function(){return this.shaderDefines=new ShaderDefines();}
  32661. ]);
  32662. return RenderableSprite3D;
  32663. })(Sprite3D)
  32664. /**
  32665. *<code>UnlitMaterial</code> 类用于实现不受光照影响的材质。
  32666. */
  32667. //class laya.d3.core.material.UnlitMaterial extends laya.d3.core.material.BaseMaterial
  32668. var UnlitMaterial=(function(_super){
  32669. function UnlitMaterial(){
  32670. /**@private */
  32671. this._albedoIntensity=1.0;
  32672. /**@private */
  32673. this._enableVertexColor=false;
  32674. this._albedoColor=new Vector4(1.0,1.0,1.0,1.0);
  32675. UnlitMaterial.__super.call(this);
  32676. this.setShaderName("Unlit");
  32677. this._shaderValues.setVector(UnlitMaterial.ALBEDOCOLOR,new Vector4(1.0,1.0,1.0,1.0));
  32678. this.renderMode=0;
  32679. }
  32680. __class(UnlitMaterial,'laya.d3.core.material.UnlitMaterial',_super);
  32681. var __proto=UnlitMaterial.prototype;
  32682. /**
  32683. *@private
  32684. */
  32685. /**
  32686. *@private
  32687. */
  32688. __getset(0,__proto,'_ColorB',function(){
  32689. return this._albedoColor.z;
  32690. },function(value){
  32691. this._albedoColor.z=value;
  32692. this.albedoColor=this._albedoColor;
  32693. });
  32694. /**
  32695. *@private
  32696. */
  32697. /**
  32698. *@private
  32699. */
  32700. __getset(0,__proto,'_ColorR',function(){
  32701. return this._albedoColor.x;
  32702. },function(value){
  32703. this._albedoColor.x=value;
  32704. this.albedoColor=this._albedoColor;
  32705. });
  32706. /**
  32707. *设置反照率颜色alpha分量。
  32708. *@param value 反照率颜色alpha分量。
  32709. */
  32710. /**
  32711. *获取反照率颜色Z分量。
  32712. *@return 反照率颜色Z分量。
  32713. */
  32714. __getset(0,__proto,'albedoColorA',function(){
  32715. return this._ColorA;
  32716. },function(value){
  32717. this._ColorA=value;
  32718. });
  32719. /**
  32720. *@private
  32721. */
  32722. /**
  32723. *@private
  32724. */
  32725. __getset(0,__proto,'_MainTex_STX',function(){
  32726. return this._shaderValues.getVector(UnlitMaterial.TILINGOFFSET).x;
  32727. },function(x){
  32728. var tilOff=this._shaderValues.getVector(UnlitMaterial.TILINGOFFSET);
  32729. tilOff.x=x;
  32730. this.tilingOffset=tilOff;
  32731. });
  32732. /**
  32733. *@private
  32734. */
  32735. /**
  32736. *@private
  32737. */
  32738. __getset(0,__proto,'_ColorG',function(){
  32739. return this._albedoColor.y;
  32740. },function(value){
  32741. this._albedoColor.y=value;
  32742. this.albedoColor=this._albedoColor;
  32743. });
  32744. /**
  32745. *@private
  32746. */
  32747. /**@private */
  32748. __getset(0,__proto,'_ColorA',function(){
  32749. return this._albedoColor.w;
  32750. },function(value){
  32751. this._albedoColor.w=value;
  32752. this.albedoColor=this._albedoColor;
  32753. });
  32754. /**
  32755. *@private
  32756. */
  32757. /**
  32758. *@private
  32759. */
  32760. __getset(0,__proto,'_AlbedoIntensity',function(){
  32761. return this._albedoIntensity;
  32762. },function(value){
  32763. if (this._albedoIntensity!==value){
  32764. var finalAlbedo=this._shaderValues.getVector(UnlitMaterial.ALBEDOCOLOR);
  32765. Vector4.scale(this._albedoColor,value,finalAlbedo);
  32766. this._albedoIntensity=value;
  32767. this._shaderValues.setVector(UnlitMaterial.ALBEDOCOLOR,finalAlbedo);
  32768. }
  32769. });
  32770. /**
  32771. *@private
  32772. */
  32773. /**
  32774. *@private
  32775. */
  32776. __getset(0,__proto,'_MainTex_STZ',function(){
  32777. return this._shaderValues.getVector(UnlitMaterial.TILINGOFFSET).z;
  32778. },function(z){
  32779. var tilOff=this._shaderValues.getVector(UnlitMaterial.TILINGOFFSET);
  32780. tilOff.z=z;
  32781. this.tilingOffset=tilOff;
  32782. });
  32783. /**
  32784. *@private
  32785. */
  32786. /**
  32787. *@private
  32788. */
  32789. __getset(0,__proto,'_MainTex_STY',function(){
  32790. return this._shaderValues.getVector(UnlitMaterial.TILINGOFFSET).y;
  32791. },function(y){
  32792. var tilOff=this._shaderValues.getVector(UnlitMaterial.TILINGOFFSET);
  32793. tilOff.y=y;
  32794. this.tilingOffset=tilOff;
  32795. });
  32796. /**
  32797. *@private
  32798. */
  32799. /**
  32800. *@private
  32801. */
  32802. __getset(0,__proto,'_Cutoff',function(){
  32803. return this.alphaTestValue;
  32804. },function(value){
  32805. this.alphaTestValue=value;
  32806. });
  32807. /**
  32808. *@private
  32809. */
  32810. /**
  32811. *@private
  32812. */
  32813. __getset(0,__proto,'_MainTex_STW',function(){
  32814. return this._shaderValues.getVector(UnlitMaterial.TILINGOFFSET).w;
  32815. },function(w){
  32816. var tilOff=this._shaderValues.getVector(UnlitMaterial.TILINGOFFSET);
  32817. tilOff.w=w;
  32818. this.tilingOffset=tilOff;
  32819. });
  32820. /**
  32821. *设置反照率颜色R分量。
  32822. *@param value 反照率颜色R分量。
  32823. */
  32824. /**
  32825. *获取反照率颜色R分量。
  32826. *@return 反照率颜色R分量。
  32827. */
  32828. __getset(0,__proto,'albedoColorR',function(){
  32829. return this._ColorR;
  32830. },function(value){
  32831. this._ColorR=value;
  32832. });
  32833. /**
  32834. *设置反照率颜色G分量。
  32835. *@param value 反照率颜色G分量。
  32836. */
  32837. /**
  32838. *获取反照率颜色G分量。
  32839. *@return 反照率颜色G分量。
  32840. */
  32841. __getset(0,__proto,'albedoColorG',function(){
  32842. return this._ColorG;
  32843. },function(value){
  32844. this._ColorG=value;
  32845. });
  32846. /**
  32847. *设置反照率颜色B分量。
  32848. *@param value 反照率颜色B分量。
  32849. */
  32850. /**
  32851. *获取反照率颜色B分量。
  32852. *@return 反照率颜色B分量。
  32853. */
  32854. __getset(0,__proto,'albedoColorB',function(){
  32855. return this._ColorB;
  32856. },function(value){
  32857. this._ColorB=value;
  32858. });
  32859. /**
  32860. *获取纹理平铺和偏移X分量。
  32861. *@param x 纹理平铺和偏移X分量。
  32862. */
  32863. /**
  32864. *获取纹理平铺和偏移X分量。
  32865. *@return 纹理平铺和偏移X分量。
  32866. */
  32867. __getset(0,__proto,'tilingOffsetX',function(){
  32868. return this._MainTex_STX;
  32869. },function(x){
  32870. this._MainTex_STX=x;
  32871. });
  32872. /**
  32873. *设置反照率颜色。
  32874. *@param value 反照率颜色。
  32875. */
  32876. /**
  32877. *获取反照率颜色。
  32878. *@return 反照率颜色。
  32879. */
  32880. __getset(0,__proto,'albedoColor',function(){
  32881. return this._albedoColor;
  32882. },function(value){
  32883. var finalAlbedo=this._shaderValues.getVector(UnlitMaterial.ALBEDOCOLOR);
  32884. Vector4.scale(value,this._albedoIntensity,finalAlbedo);
  32885. this._albedoColor=value;
  32886. this._shaderValues.setVector(UnlitMaterial.ALBEDOCOLOR,finalAlbedo);
  32887. });
  32888. /**
  32889. *设置反照率强度。
  32890. *@param value 反照率强度。
  32891. */
  32892. /**
  32893. *获取反照率强度。
  32894. *@return 反照率强度。
  32895. */
  32896. __getset(0,__proto,'albedoIntensity',function(){
  32897. return this._albedoIntensity;
  32898. },function(value){
  32899. this._AlbedoIntensity=value;
  32900. });
  32901. /**
  32902. *设置是否支持顶点色。
  32903. *@param value 是否支持顶点色。
  32904. */
  32905. /**
  32906. *获取是否支持顶点色。
  32907. *@return 是否支持顶点色。
  32908. */
  32909. __getset(0,__proto,'enableVertexColor',function(){
  32910. return this._enableVertexColor;
  32911. },function(value){
  32912. this._enableVertexColor=value;
  32913. if (value)
  32914. this._defineDatas.add(laya.d3.core.material.UnlitMaterial.SHADERDEFINE_ENABLEVERTEXCOLOR);
  32915. else
  32916. this._defineDatas.remove(laya.d3.core.material.UnlitMaterial.SHADERDEFINE_ENABLEVERTEXCOLOR);
  32917. });
  32918. /**
  32919. *设置反照率贴图。
  32920. *@param value 反照率贴图。
  32921. */
  32922. /**
  32923. *获取反照率贴图。
  32924. *@return 反照率贴图。
  32925. */
  32926. __getset(0,__proto,'albedoTexture',function(){
  32927. return this._shaderValues.getTexture(UnlitMaterial.ALBEDOTEXTURE);
  32928. },function(value){
  32929. if (value)
  32930. this._defineDatas.add(laya.d3.core.material.UnlitMaterial.SHADERDEFINE_ALBEDOTEXTURE);
  32931. else
  32932. this._defineDatas.remove(laya.d3.core.material.UnlitMaterial.SHADERDEFINE_ALBEDOTEXTURE);
  32933. this._shaderValues.setTexture(UnlitMaterial.ALBEDOTEXTURE,value);
  32934. });
  32935. /**
  32936. *获取纹理平铺和偏移Y分量。
  32937. *@param y 纹理平铺和偏移Y分量。
  32938. */
  32939. /**
  32940. *获取纹理平铺和偏移Y分量。
  32941. *@return 纹理平铺和偏移Y分量。
  32942. */
  32943. __getset(0,__proto,'tilingOffsetY',function(){
  32944. return this._MainTex_STY;
  32945. },function(y){
  32946. this._MainTex_STY=y;
  32947. });
  32948. /**
  32949. *获取纹理平铺和偏移Z分量。
  32950. *@param z 纹理平铺和偏移Z分量。
  32951. */
  32952. /**
  32953. *获取纹理平铺和偏移Z分量。
  32954. *@return 纹理平铺和偏移Z分量。
  32955. */
  32956. __getset(0,__proto,'tilingOffsetZ',function(){
  32957. return this._MainTex_STZ;
  32958. },function(z){
  32959. this._MainTex_STZ=z;
  32960. });
  32961. /**
  32962. *设置混合源。
  32963. *@param value 混合源
  32964. */
  32965. /**
  32966. *获取混合源。
  32967. *@return 混合源。
  32968. */
  32969. __getset(0,__proto,'blendSrc',function(){
  32970. return this._shaderValues.getInt(UnlitMaterial.BLEND_SRC);
  32971. },function(value){
  32972. this._shaderValues.setInt(UnlitMaterial.BLEND_SRC,value);
  32973. });
  32974. /**
  32975. *获取纹理平铺和偏移W分量。
  32976. *@param w 纹理平铺和偏移W分量。
  32977. */
  32978. /**
  32979. *获取纹理平铺和偏移W分量。
  32980. *@return 纹理平铺和偏移W分量。
  32981. */
  32982. __getset(0,__proto,'tilingOffsetW',function(){
  32983. return this._MainTex_STW;
  32984. },function(w){
  32985. this._MainTex_STW=w;
  32986. });
  32987. /**
  32988. *获取纹理平铺和偏移。
  32989. *@param value 纹理平铺和偏移。
  32990. */
  32991. /**
  32992. *获取纹理平铺和偏移。
  32993. *@return 纹理平铺和偏移。
  32994. */
  32995. __getset(0,__proto,'tilingOffset',function(){
  32996. return this._shaderValues.getVector(UnlitMaterial.TILINGOFFSET);
  32997. },function(value){
  32998. if (value){
  32999. if (value.x !=1 || value.y !=1 || value.z !=0 || value.w !=0)
  33000. this._defineDatas.add(laya.d3.core.material.UnlitMaterial.SHADERDEFINE_TILINGOFFSET);
  33001. else
  33002. this._defineDatas.remove(laya.d3.core.material.UnlitMaterial.SHADERDEFINE_TILINGOFFSET);
  33003. }else {
  33004. this._defineDatas.remove(laya.d3.core.material.UnlitMaterial.SHADERDEFINE_TILINGOFFSET);
  33005. }
  33006. this._shaderValues.setVector(UnlitMaterial.TILINGOFFSET,value);
  33007. });
  33008. /**
  33009. *设置渲染模式。
  33010. *@return 渲染模式。
  33011. */
  33012. __getset(0,__proto,'renderMode',null,function(value){
  33013. switch (value){
  33014. case 0:
  33015. this.alphaTest=false;
  33016. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_OPAQUE*/2000;
  33017. this.depthWrite=true;
  33018. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  33019. this.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  33020. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  33021. break ;
  33022. case 1:
  33023. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_ALPHATEST*/2450;
  33024. this.alphaTest=true;
  33025. this.depthWrite=true;
  33026. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  33027. this.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  33028. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  33029. break ;
  33030. case 2:
  33031. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_TRANSPARENT*/3000;
  33032. this.alphaTest=false;
  33033. this.depthWrite=false;
  33034. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  33035. this.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  33036. this.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_SRC_ALPHA*/0x0302;
  33037. this.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA*/0x0303;
  33038. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  33039. break ;
  33040. default :
  33041. throw new Error("UnlitMaterial : renderMode value error.");
  33042. }
  33043. });
  33044. /**
  33045. *设置是否写入深度。
  33046. *@param value 是否写入深度。
  33047. */
  33048. /**
  33049. *获取是否写入深度。
  33050. *@return 是否写入深度。
  33051. */
  33052. __getset(0,__proto,'depthWrite',function(){
  33053. return this._shaderValues.getBool(UnlitMaterial.DEPTH_WRITE);
  33054. },function(value){
  33055. this._shaderValues.setBool(UnlitMaterial.DEPTH_WRITE,value);
  33056. });
  33057. /**
  33058. *设置剔除方式。
  33059. *@param value 剔除方式。
  33060. */
  33061. /**
  33062. *获取剔除方式。
  33063. *@return 剔除方式。
  33064. */
  33065. __getset(0,__proto,'cull',function(){
  33066. return this._shaderValues.getInt(UnlitMaterial.CULL);
  33067. },function(value){
  33068. this._shaderValues.setInt(UnlitMaterial.CULL,value);
  33069. });
  33070. /**
  33071. *设置混合方式。
  33072. *@param value 混合方式。
  33073. */
  33074. /**
  33075. *获取混合方式。
  33076. *@return 混合方式。
  33077. */
  33078. __getset(0,__proto,'blend',function(){
  33079. return this._shaderValues.getInt(UnlitMaterial.BLEND);
  33080. },function(value){
  33081. this._shaderValues.setInt(UnlitMaterial.BLEND,value);
  33082. });
  33083. /**
  33084. *设置混合目标。
  33085. *@param value 混合目标
  33086. */
  33087. /**
  33088. *获取混合目标。
  33089. *@return 混合目标。
  33090. */
  33091. __getset(0,__proto,'blendDst',function(){
  33092. return this._shaderValues.getInt(UnlitMaterial.BLEND_DST);
  33093. },function(value){
  33094. this._shaderValues.setInt(UnlitMaterial.BLEND_DST,value);
  33095. });
  33096. /**
  33097. *设置深度测试方式。
  33098. *@param value 深度测试方式
  33099. */
  33100. /**
  33101. *获取深度测试方式。
  33102. *@return 深度测试方式。
  33103. */
  33104. __getset(0,__proto,'depthTest',function(){
  33105. return this._shaderValues.getInt(UnlitMaterial.DEPTH_TEST);
  33106. },function(value){
  33107. this._shaderValues.setInt(UnlitMaterial.DEPTH_TEST,value);
  33108. });
  33109. UnlitMaterial.__init__=function(){
  33110. UnlitMaterial.SHADERDEFINE_ALBEDOTEXTURE=UnlitMaterial.shaderDefines.registerDefine("ALBEDOTEXTURE");
  33111. UnlitMaterial.SHADERDEFINE_TILINGOFFSET=UnlitMaterial.shaderDefines.registerDefine("TILINGOFFSET");
  33112. UnlitMaterial.SHADERDEFINE_ENABLEVERTEXCOLOR=UnlitMaterial.shaderDefines.registerDefine("ENABLEVERTEXCOLOR");
  33113. }
  33114. UnlitMaterial.RENDERMODE_OPAQUE=0;
  33115. UnlitMaterial.RENDERMODE_CUTOUT=1;
  33116. UnlitMaterial.RENDERMODE_TRANSPARENT=2;
  33117. UnlitMaterial.RENDERMODE_ADDTIVE=3;
  33118. UnlitMaterial.SHADERDEFINE_ALBEDOTEXTURE=0;
  33119. UnlitMaterial.SHADERDEFINE_TILINGOFFSET=0;
  33120. UnlitMaterial.SHADERDEFINE_ENABLEVERTEXCOLOR=0;
  33121. __static(UnlitMaterial,
  33122. ['ALBEDOTEXTURE',function(){return this.ALBEDOTEXTURE=Shader3D.propertyNameToID("u_AlbedoTexture");},'ALBEDOCOLOR',function(){return this.ALBEDOCOLOR=Shader3D.propertyNameToID("u_AlbedoColor");},'TILINGOFFSET',function(){return this.TILINGOFFSET=Shader3D.propertyNameToID("u_TilingOffset");},'CULL',function(){return this.CULL=Shader3D.propertyNameToID("s_Cull");},'BLEND',function(){return this.BLEND=Shader3D.propertyNameToID("s_Blend");},'BLEND_SRC',function(){return this.BLEND_SRC=Shader3D.propertyNameToID("s_BlendSrc");},'BLEND_DST',function(){return this.BLEND_DST=Shader3D.propertyNameToID("s_BlendDst");},'DEPTH_TEST',function(){return this.DEPTH_TEST=Shader3D.propertyNameToID("s_DepthTest");},'DEPTH_WRITE',function(){return this.DEPTH_WRITE=Shader3D.propertyNameToID("s_DepthWrite");},'defaultMaterial',function(){return this.defaultMaterial=new UnlitMaterial();},'shaderDefines',function(){return this.shaderDefines=new ShaderDefines(BaseMaterial.shaderDefines);}
  33123. ]);
  33124. return UnlitMaterial;
  33125. })(BaseMaterial)
  33126. /**
  33127. *<code>LightSprite</code> 类用于创建灯光的父类。
  33128. */
  33129. //class laya.d3.core.light.LightSprite extends laya.d3.core.Sprite3D
  33130. var LightSprite=(function(_super){
  33131. function LightSprite(){
  33132. /**@private */
  33133. this._intensityColor=null;
  33134. /**@private */
  33135. this._intensity=NaN;
  33136. /**@private */
  33137. this._shadow=false;
  33138. /**@private */
  33139. this._shadowFarPlane=0;
  33140. /**@private */
  33141. this._shadowMapSize=0;
  33142. /**@private */
  33143. this._shadowMapCount=0;
  33144. /**@private */
  33145. this._shadowMapPCFType=0;
  33146. /**@private */
  33147. this._parallelSplitShadowMap=null;
  33148. /**@private */
  33149. this._lightmapBakedType=0;
  33150. /**灯光颜色。 */
  33151. this.color=null;
  33152. LightSprite.__super.call(this);
  33153. this._intensity=1.0;
  33154. this._intensityColor=new Vector3();
  33155. this.color=new Vector3(1.0,1.0,1.0);
  33156. this._shadow=false;
  33157. this._shadowFarPlane=8;
  33158. this._shadowMapSize=512;
  33159. this._shadowMapCount=1;
  33160. this._shadowMapPCFType=0;
  33161. this._lightmapBakedType=LightSprite.LIGHTMAPBAKEDTYPE_REALTIME;
  33162. }
  33163. __class(LightSprite,'laya.d3.core.light.LightSprite',_super);
  33164. var __proto=LightSprite.prototype;
  33165. /**
  33166. *@inheritDoc
  33167. */
  33168. __proto._parse=function(data,spriteMap){
  33169. _super.prototype._parse.call(this,data,spriteMap);
  33170. var colorData=data.color;
  33171. this.color.fromArray(colorData);
  33172. this.intensity=data.intensity;
  33173. this.lightmapBakedType=data.lightmapBakedType;
  33174. }
  33175. /**
  33176. *@inheritDoc
  33177. */
  33178. __proto._onActive=function(){
  33179. laya.display.Node.prototype._onActive.call(this);
  33180. (this.lightmapBakedType!==LightSprite.LIGHTMAPBAKEDTYPE_BAKED)&& ((this._scene)._addLight(this));
  33181. }
  33182. /**
  33183. *@inheritDoc
  33184. */
  33185. __proto._onInActive=function(){
  33186. laya.display.Node.prototype._onInActive.call(this);
  33187. (this.lightmapBakedType!==LightSprite.LIGHTMAPBAKEDTYPE_BAKED)&& ((this._scene)._removeLight(this));
  33188. }
  33189. /**
  33190. *更新灯光相关渲染状态参数。
  33191. *@param state 渲染状态参数。
  33192. */
  33193. __proto._prepareToScene=function(){
  33194. return false;
  33195. }
  33196. /**
  33197. *设置灯光烘培类型。
  33198. */
  33199. /**
  33200. *获取灯光烘培类型。
  33201. */
  33202. __getset(0,__proto,'lightmapBakedType',function(){
  33203. return this._lightmapBakedType;
  33204. },function(value){
  33205. if (this._lightmapBakedType!==value){
  33206. this._lightmapBakedType=value;
  33207. if (this.activeInHierarchy){
  33208. if (value!==LightSprite.LIGHTMAPBAKEDTYPE_BAKED)
  33209. (this._scene)._addLight(this);
  33210. else
  33211. (this._scene)._removeLight(this);
  33212. }
  33213. }
  33214. });
  33215. /**
  33216. *设置阴影PCF类型。
  33217. *@param value PCF类型。
  33218. */
  33219. /**
  33220. *获取阴影PCF类型。
  33221. *@return PCF类型。
  33222. */
  33223. __getset(0,__proto,'shadowPCFType',function(){
  33224. return this._shadowMapPCFType;
  33225. },function(value){
  33226. this._shadowMapPCFType=value;
  33227. (this._parallelSplitShadowMap)&& (this._parallelSplitShadowMap.setPCFType(value));
  33228. });
  33229. /**
  33230. *设置灯光强度。
  33231. *@param value 灯光强度
  33232. */
  33233. /**
  33234. *获取灯光强度。
  33235. *@return 灯光强度
  33236. */
  33237. __getset(0,__proto,'intensity',function(){
  33238. return this._intensity;
  33239. },function(value){
  33240. this._intensity=value;
  33241. });
  33242. /**
  33243. *设置是否产生阴影。
  33244. *@param value 是否产生阴影。
  33245. */
  33246. /**
  33247. *获取是否产生阴影。
  33248. *@return 是否产生阴影。
  33249. */
  33250. __getset(0,__proto,'shadow',function(){
  33251. return this._shadow;
  33252. },function(value){
  33253. throw new Error("LightSprite: must override it.");
  33254. });
  33255. /**
  33256. *设置阴影最远范围。
  33257. *@param value 阴影最远范围。
  33258. */
  33259. /**
  33260. *获取阴影最远范围。
  33261. *@return 阴影最远范围。
  33262. */
  33263. __getset(0,__proto,'shadowDistance',function(){
  33264. return this._shadowFarPlane;
  33265. },function(value){
  33266. this._shadowFarPlane=value;
  33267. (this._parallelSplitShadowMap)&& (this._parallelSplitShadowMap.setFarDistance(value));
  33268. });
  33269. /**
  33270. *设置阴影分段数。
  33271. *@param value 阴影分段数。
  33272. */
  33273. /**
  33274. *获取阴影分段数。
  33275. *@return 阴影分段数。
  33276. */
  33277. __getset(0,__proto,'shadowPSSMCount',function(){
  33278. return this._shadowMapCount;
  33279. },function(value){
  33280. this._shadowMapCount=value;
  33281. (this._parallelSplitShadowMap)&& (this._parallelSplitShadowMap.shadowMapCount=value);
  33282. });
  33283. /**
  33284. *设置阴影贴图尺寸。
  33285. *@param value 阴影贴图尺寸。
  33286. */
  33287. /**
  33288. *获取阴影贴图尺寸。
  33289. *@return 阴影贴图尺寸。
  33290. */
  33291. __getset(0,__proto,'shadowResolution',function(){
  33292. return this._shadowMapSize;
  33293. },function(value){
  33294. this._shadowMapSize=value;
  33295. (this._parallelSplitShadowMap)&& (this._parallelSplitShadowMap.setShadowMapTextureSize(value));
  33296. });
  33297. /**
  33298. *设置灯光的漫反射颜色。
  33299. *@param value 灯光的漫反射颜色。
  33300. */
  33301. /**
  33302. *获取灯光的漫反射颜色。
  33303. *@return 灯光的漫反射颜色。
  33304. */
  33305. __getset(0,__proto,'diffuseColor',function(){
  33306. console.log("LightSprite: discard property,please use color property instead.");
  33307. return this.color;
  33308. },function(value){
  33309. console.log("LightSprite: discard property,please use color property instead.");
  33310. this.color=value;
  33311. });
  33312. LightSprite.LIGHTMAPBAKEDTYPE_REALTIME=0;
  33313. LightSprite.LIGHTMAPBAKEDTYPE_MIXED=1;
  33314. LightSprite.LIGHTMAPBAKEDTYPE_BAKED=2;
  33315. return LightSprite;
  33316. })(Sprite3D)
  33317. /**
  33318. *<code>Terrain</code> 类用于创建地块。
  33319. */
  33320. //class laya.d3.terrain.Terrain extends laya.d3.core.Sprite3D
  33321. var Terrain=(function(_super){
  33322. function Terrain(terrainRes){
  33323. //地形资源
  33324. this._terrainRes=null;
  33325. this._lightmapScaleOffset=null;
  33326. Terrain.__super.call(this);
  33327. this._lightmapScaleOffset=new Vector4(1,1,0,0);
  33328. if (terrainRes){
  33329. this._terrainRes=terrainRes;
  33330. this.buildTerrain(terrainRes);
  33331. }
  33332. }
  33333. __class(Terrain,'laya.d3.terrain.Terrain',_super);
  33334. var __proto=Terrain.prototype;
  33335. /**
  33336. *@inheritDoc
  33337. */
  33338. __proto._parse=function(data,spriteMap){
  33339. _super.prototype._parse.call(this,data,spriteMap);
  33340. this.terrainRes=Loader.getRes(data.dataPath);
  33341. var lightmapIndex=data.lightmapIndex;
  33342. if (lightmapIndex !=null)
  33343. this.setLightmapIndex(lightmapIndex);
  33344. var lightmapScaleOffsetArray=data.lightmapScaleOffset;
  33345. if (lightmapScaleOffsetArray)
  33346. this.setLightmapScaleOffset(new Vector4(lightmapScaleOffsetArray[0],lightmapScaleOffsetArray[1],lightmapScaleOffsetArray[2],lightmapScaleOffsetArray[3]));
  33347. }
  33348. __proto.setLightmapIndex=function(value){
  33349. for (var i=0;i < this._children.length;i++){
  33350. var terrainChunk=this._children[i];
  33351. terrainChunk.terrainRender.lightmapIndex=value;
  33352. }
  33353. }
  33354. __proto.setLightmapScaleOffset=function(value){
  33355. if (!value)return;
  33356. value.cloneTo(this._lightmapScaleOffset);
  33357. for (var i=0;i < this._children.length;i++){
  33358. var terrainChunk=this._children[i];
  33359. terrainChunk.terrainRender.lightmapScaleOffset=this._lightmapScaleOffset;
  33360. }
  33361. }
  33362. __proto.disableLight=function(){
  33363. for (var i=0,n=this._children.length;i < n;i++){
  33364. var terrainChunk=this._children[i];
  33365. for (var j=0,m=terrainChunk._render.sharedMaterials.length;j < m;j++){
  33366. var terrainMaterial=terrainChunk._render.sharedMaterials [j];
  33367. terrainMaterial.disableLight();
  33368. }
  33369. }
  33370. }
  33371. //建筑地形
  33372. __proto.buildTerrain=function(terrainRes){
  33373. var chunkNumX=terrainRes._chunkNumX;
  33374. var chunkNumZ=terrainRes._chunkNumZ;
  33375. var heightData=terrainRes._heightData;
  33376. var n=0;
  33377. for (var i=0;i < chunkNumZ;i++){
  33378. for (var j=0;j < chunkNumX;j++){
  33379. var terrainChunk=new TerrainChunk(j,i,terrainRes._gridSize,heightData._terrainHeightData,heightData._width,heightData._height,terrainRes._cameraCoordinateInverse);
  33380. var chunkInfo=terrainRes._chunkInfos[n++];
  33381. for (var k=0;k < chunkInfo.alphaMap.length;k++){
  33382. var nNum=chunkInfo.detailID[k].length;
  33383. var sDetialTextureUrl1=(nNum > 0)? terrainRes._detailTextureInfos[chunkInfo.detailID[k][0]].diffuseTexture :null;
  33384. var sDetialTextureUrl2=(nNum > 1)? terrainRes._detailTextureInfos[chunkInfo.detailID[k][1]].diffuseTexture :null;
  33385. var sDetialTextureUrl3=(nNum > 2)? terrainRes._detailTextureInfos[chunkInfo.detailID[k][2]].diffuseTexture :null;
  33386. var sDetialTextureUrl4=(nNum > 3)? terrainRes._detailTextureInfos[chunkInfo.detailID[k][3]].diffuseTexture :null;
  33387. var detialScale1=(nNum > 0)? terrainRes._detailTextureInfos[chunkInfo.detailID[k][0]].scale :null;
  33388. var detialScale2=(nNum > 1)? terrainRes._detailTextureInfos[chunkInfo.detailID[k][1]].scale :null;
  33389. var detialScale3=(nNum > 2)? terrainRes._detailTextureInfos[chunkInfo.detailID[k][2]].scale :null;
  33390. var detialScale4=(nNum > 3)? terrainRes._detailTextureInfos[chunkInfo.detailID[k][3]].scale :null;
  33391. terrainChunk.buildRenderElementAndMaterial(nNum,chunkInfo.normalMap,chunkInfo.alphaMap[k],sDetialTextureUrl1,sDetialTextureUrl2,sDetialTextureUrl3,sDetialTextureUrl4,terrainRes._materialInfo.ambientColor,terrainRes._materialInfo.diffuseColor,terrainRes._materialInfo.specularColor,detialScale1 ? detialScale1.x :1,detialScale1 ? detialScale1.y :1,detialScale2 ? detialScale2.x :1,detialScale2 ? detialScale2.y :1,detialScale3 ? detialScale3.x :1,detialScale3 ? detialScale3.y :1,detialScale4 ? detialScale4.x :1,detialScale4 ? detialScale4.y :1);
  33392. }
  33393. terrainChunk.terrainRender.receiveShadow=true;
  33394. terrainChunk.terrainRender.lightmapScaleOffset=this._lightmapScaleOffset;
  33395. this.addChild(terrainChunk);
  33396. }
  33397. }
  33398. }
  33399. /**
  33400. *获取地形X轴长度。
  33401. *@return 地形X轴长度。
  33402. */
  33403. __proto.width=function(){
  33404. return this._terrainRes._chunkNumX *TerrainLeaf.CHUNK_GRID_NUM *this._terrainRes._gridSize;
  33405. }
  33406. /**
  33407. *获取地形Z轴长度。
  33408. *@return 地形Z轴长度。
  33409. */
  33410. __proto.depth=function(){
  33411. return this._terrainRes._chunkNumZ *TerrainLeaf.CHUNK_GRID_NUM *this._terrainRes._gridSize;
  33412. }
  33413. /**
  33414. *获取地形高度。
  33415. *@param x X轴坐标。
  33416. *@param z Z轴坐标。
  33417. */
  33418. __proto.getHeightXZ=function(x,z){
  33419. if (!this._terrainRes)
  33420. return NaN;
  33421. x-=this.transform.position.x;
  33422. z-=this.transform.position.z;
  33423. if (!Terrain.__VECTOR3__){
  33424. Terrain.__VECTOR3__=new Vector3();
  33425. }
  33426. Terrain.__VECTOR3__.x=x;
  33427. Terrain.__VECTOR3__.y=0;
  33428. Terrain.__VECTOR3__.z=z;
  33429. Vector3.transformV3ToV3(Terrain.__VECTOR3__,TerrainLeaf.__ADAPT_MATRIX_INV__,Terrain.__VECTOR3__);
  33430. x=Terrain.__VECTOR3__.x;
  33431. z=Terrain.__VECTOR3__.z;
  33432. if (x < 0 || x > this.width()|| z < 0 || z > this.depth())
  33433. return NaN;
  33434. var gridSize=this._terrainRes._gridSize;
  33435. var nIndexX=parseInt(""+x / gridSize);
  33436. var nIndexZ=parseInt(""+z / gridSize);
  33437. var offsetX=x-nIndexX *gridSize;
  33438. var offsetZ=z-nIndexZ *gridSize;
  33439. var h1=NaN;
  33440. var h2=NaN;
  33441. var h3=NaN;
  33442. var u=NaN;
  33443. var v=NaN;
  33444. var heightData=this._terrainRes._heightData;
  33445. if (offsetX+offsetZ > gridSize){
  33446. h1=heightData._terrainHeightData[(nIndexZ+1-1)*heightData._width+nIndexX+1];
  33447. h2=heightData._terrainHeightData[(nIndexZ+1-1)*heightData._width+nIndexX];
  33448. h3=heightData._terrainHeightData[(nIndexZ-1)*heightData._width+nIndexX+1];
  33449. u=(gridSize-offsetX)/ gridSize;
  33450. v=(gridSize-offsetZ)/ gridSize;
  33451. return h1+(h2-h1)*u+(h3-h1)*v;
  33452. }else {
  33453. h1=heightData._terrainHeightData[Math.max(0.0,nIndexZ-1)*heightData._width+nIndexX];
  33454. h2=heightData._terrainHeightData[Math.min(heightData._width *heightData._height-1,(nIndexZ+1-1)*heightData._width+nIndexX)];
  33455. h3=heightData._terrainHeightData[Math.min(heightData._width *heightData._height-1,Math.max(0.0,nIndexZ-1)*heightData._width+nIndexX+1)];
  33456. u=offsetX / gridSize;
  33457. v=offsetZ / gridSize;
  33458. return h1+(h2-h1)*v+(h3-h1)*u;
  33459. }
  33460. }
  33461. __getset(0,__proto,'terrainRes',null,function(value){
  33462. if (value){
  33463. this._terrainRes=value;
  33464. this.buildTerrain(value);
  33465. }
  33466. });
  33467. Terrain.load=function(url){
  33468. Laya.loader.create(url,null,null,/*Laya3D.TERRAINRES*/"TERRAIN",null,null,1,false);
  33469. }
  33470. Terrain.RENDER_LINE_MODEL=false;
  33471. Terrain.LOD_TOLERANCE_VALUE=4;
  33472. Terrain.LOD_DISTANCE_FACTOR=2.0;
  33473. Terrain.__VECTOR3__=null;
  33474. return Terrain;
  33475. })(Sprite3D)
  33476. /**
  33477. *<code>TrailMaterial</code> 类用于实现拖尾材质。
  33478. */
  33479. //class laya.d3.core.trail.TrailMaterial extends laya.d3.core.material.BaseMaterial
  33480. var TrailMaterial=(function(_super){
  33481. function TrailMaterial(){
  33482. /**@private */
  33483. this._color=null;
  33484. TrailMaterial.__super.call(this);
  33485. this.setShaderName("Trail");
  33486. this._color=new Vector4(1.0,1.0,1.0,1.0);
  33487. this._shaderValues.setVector(TrailMaterial.TINTCOLOR,new Vector4(1.0,1.0,1.0,1.0));
  33488. this.renderMode=0;
  33489. }
  33490. __class(TrailMaterial,'laya.d3.core.trail.TrailMaterial',_super);
  33491. var __proto=TrailMaterial.prototype;
  33492. /**
  33493. *@private
  33494. */
  33495. /**
  33496. *@private
  33497. */
  33498. __getset(0,__proto,'_TintColorB',function(){
  33499. return this._color.z;
  33500. },function(value){
  33501. this._color.z=value;
  33502. this.color=this._color;
  33503. });
  33504. /**
  33505. *@private
  33506. */
  33507. /**
  33508. *@private
  33509. */
  33510. __getset(0,__proto,'_MainTex_STZ',function(){
  33511. return this._shaderValues.getVector(TrailMaterial.TILINGOFFSET).z;
  33512. },function(z){
  33513. var tilOff=this._shaderValues.getVector(TrailMaterial.TILINGOFFSET);
  33514. tilOff.z=z;
  33515. this.tilingOffset=tilOff;
  33516. });
  33517. /**
  33518. *设置贴图。
  33519. *@param value 贴图。
  33520. */
  33521. /**
  33522. *获取贴图。
  33523. *@return 贴图。
  33524. */
  33525. __getset(0,__proto,'texture',function(){
  33526. return this._shaderValues.getTexture(TrailMaterial.MAINTEXTURE);
  33527. },function(value){
  33528. if (value)
  33529. this._defineDatas.add(laya.d3.core.trail.TrailMaterial.SHADERDEFINE_MAINTEXTURE);
  33530. else
  33531. this._defineDatas.remove(laya.d3.core.trail.TrailMaterial.SHADERDEFINE_MAINTEXTURE);
  33532. this._shaderValues.setTexture(TrailMaterial.MAINTEXTURE,value);
  33533. });
  33534. /**
  33535. *@private
  33536. */
  33537. /**
  33538. *@private
  33539. */
  33540. __getset(0,__proto,'_TintColorR',function(){
  33541. return this._color.x;
  33542. },function(value){
  33543. this._color.x=value;
  33544. this.color=this._color;
  33545. });
  33546. /**
  33547. *@private
  33548. */
  33549. /**
  33550. *@private
  33551. */
  33552. __getset(0,__proto,'_MainTex_STW',function(){
  33553. return this._shaderValues.getVector(TrailMaterial.TILINGOFFSET).w;
  33554. },function(w){
  33555. var tilOff=this._shaderValues.getVector(TrailMaterial.TILINGOFFSET);
  33556. tilOff.w=w;
  33557. this.tilingOffset=tilOff;
  33558. });
  33559. /**
  33560. *@private
  33561. */
  33562. /**
  33563. *@private
  33564. */
  33565. __getset(0,__proto,'_TintColorG',function(){
  33566. return this._color.y;
  33567. },function(value){
  33568. this._color.y=value;
  33569. this.color=this._color;
  33570. });
  33571. /**
  33572. *@private
  33573. */
  33574. /**@private */
  33575. __getset(0,__proto,'_TintColorA',function(){
  33576. return this._color.w;
  33577. },function(value){
  33578. this._color.w=value;
  33579. this.color=this._color;
  33580. });
  33581. /**
  33582. *@private
  33583. */
  33584. /**
  33585. *@private
  33586. */
  33587. __getset(0,__proto,'_MainTex_STY',function(){
  33588. return this._shaderValues.getVector(TrailMaterial.TILINGOFFSET).y;
  33589. },function(y){
  33590. var tilOff=this._shaderValues.getVector(TrailMaterial.TILINGOFFSET);
  33591. tilOff.y=y;
  33592. this.tilingOffset=tilOff;
  33593. });
  33594. /**
  33595. *设置渲染模式。
  33596. *@return 渲染模式。
  33597. */
  33598. __getset(0,__proto,'renderMode',null,function(value){
  33599. switch (value){
  33600. case 1:
  33601. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_TRANSPARENT*/3000;
  33602. this.alphaTest=false;
  33603. this.depthWrite=false;
  33604. this.cull=/*laya.d3.core.material.RenderState.CULL_NONE*/0;
  33605. this.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  33606. this.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_SRC_ALPHA*/0x0302;
  33607. this.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE*/1;
  33608. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  33609. this._defineDatas.add(TrailMaterial.SHADERDEFINE_ADDTIVEFOG);
  33610. break ;
  33611. case 0:
  33612. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_TRANSPARENT*/3000;
  33613. this.alphaTest=false;
  33614. this.depthWrite=false;
  33615. this.cull=/*laya.d3.core.material.RenderState.CULL_NONE*/0;
  33616. this.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  33617. this.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_SRC_ALPHA*/0x0302;
  33618. this.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA*/0x0303;
  33619. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  33620. this._defineDatas.remove(TrailMaterial.SHADERDEFINE_ADDTIVEFOG);
  33621. break ;
  33622. default :
  33623. throw new Error("TrailMaterial : renderMode value error.");
  33624. }
  33625. });
  33626. /**
  33627. *@private
  33628. */
  33629. /**
  33630. *@private
  33631. */
  33632. __getset(0,__proto,'_MainTex_STX',function(){
  33633. return this._shaderValues.getVector(TrailMaterial.TILINGOFFSET).x;
  33634. },function(x){
  33635. var tilOff=this._shaderValues.getVector(TrailMaterial.TILINGOFFSET);
  33636. tilOff.x=x;
  33637. this.tilingOffset=tilOff;
  33638. });
  33639. /**
  33640. *设置颜色R分量。
  33641. *@param value 颜色R分量。
  33642. */
  33643. /**
  33644. *获取颜色R分量。
  33645. *@return 颜色R分量。
  33646. */
  33647. __getset(0,__proto,'colorR',function(){
  33648. return this._TintColorR;
  33649. },function(value){
  33650. this._TintColorR=value;
  33651. });
  33652. /**
  33653. *设置颜色G分量。
  33654. *@param value 颜色G分量。
  33655. */
  33656. /**
  33657. *获取颜色G分量。
  33658. *@return 颜色G分量。
  33659. */
  33660. __getset(0,__proto,'colorG',function(){
  33661. return this._TintColorG;
  33662. },function(value){
  33663. this._TintColorG=value;
  33664. });
  33665. /**
  33666. *设置颜色B分量。
  33667. *@param value 颜色B分量。
  33668. */
  33669. /**
  33670. *获取颜色B分量。
  33671. *@return 颜色B分量。
  33672. */
  33673. __getset(0,__proto,'colorB',function(){
  33674. return this._TintColorB;
  33675. },function(value){
  33676. this._TintColorB=value;
  33677. });
  33678. /**
  33679. *设置颜色alpha分量。
  33680. *@param value 颜色alpha分量。
  33681. */
  33682. /**
  33683. *获取颜色Z分量。
  33684. *@return 颜色Z分量。
  33685. */
  33686. __getset(0,__proto,'colorA',function(){
  33687. return this._TintColorA;
  33688. },function(value){
  33689. this._TintColorA=value;
  33690. });
  33691. /**
  33692. *设置混合方式。
  33693. *@param value 混合方式。
  33694. */
  33695. /**
  33696. *获取混合方式。
  33697. *@return 混合方式。
  33698. */
  33699. __getset(0,__proto,'blend',function(){
  33700. return this._shaderValues.getInt(TrailMaterial.BLEND);
  33701. },function(value){
  33702. this._shaderValues.setInt(TrailMaterial.BLEND,value);
  33703. });
  33704. /**
  33705. *设置颜色。
  33706. *@param value 颜色。
  33707. */
  33708. /**
  33709. *获取颜色。
  33710. *@return 颜色。
  33711. */
  33712. __getset(0,__proto,'color',function(){
  33713. return this._shaderValues.getVector(TrailMaterial.TINTCOLOR);
  33714. },function(value){
  33715. this._shaderValues.setVector(TrailMaterial.TINTCOLOR,value);
  33716. });
  33717. /**
  33718. *获取纹理平铺和偏移X分量。
  33719. *@param x 纹理平铺和偏移X分量。
  33720. */
  33721. /**
  33722. *获取纹理平铺和偏移X分量。
  33723. *@return 纹理平铺和偏移X分量。
  33724. */
  33725. __getset(0,__proto,'tilingOffsetX',function(){
  33726. return this._MainTex_STX;
  33727. },function(x){
  33728. this._MainTex_STX=x;
  33729. });
  33730. /**
  33731. *获取纹理平铺和偏移Y分量。
  33732. *@param y 纹理平铺和偏移Y分量。
  33733. */
  33734. /**
  33735. *获取纹理平铺和偏移Y分量。
  33736. *@return 纹理平铺和偏移Y分量。
  33737. */
  33738. __getset(0,__proto,'tilingOffsetY',function(){
  33739. return this._MainTex_STY;
  33740. },function(y){
  33741. this._MainTex_STY=y;
  33742. });
  33743. /**
  33744. *获取纹理平铺和偏移Z分量。
  33745. *@param z 纹理平铺和偏移Z分量。
  33746. */
  33747. /**
  33748. *获取纹理平铺和偏移Z分量。
  33749. *@return 纹理平铺和偏移Z分量。
  33750. */
  33751. __getset(0,__proto,'tilingOffsetZ',function(){
  33752. return this._MainTex_STZ;
  33753. },function(z){
  33754. this._MainTex_STZ=z;
  33755. });
  33756. /**
  33757. *设置混合源。
  33758. *@param value 混合源
  33759. */
  33760. /**
  33761. *获取混合源。
  33762. *@return 混合源。
  33763. */
  33764. __getset(0,__proto,'blendSrc',function(){
  33765. return this._shaderValues.getInt(TrailMaterial.BLEND_SRC);
  33766. },function(value){
  33767. this._shaderValues.setInt(TrailMaterial.BLEND_SRC,value);
  33768. });
  33769. /**
  33770. *获取纹理平铺和偏移W分量。
  33771. *@param w 纹理平铺和偏移W分量。
  33772. */
  33773. /**
  33774. *获取纹理平铺和偏移W分量。
  33775. *@return 纹理平铺和偏移W分量。
  33776. */
  33777. __getset(0,__proto,'tilingOffsetW',function(){
  33778. return this._MainTex_STW;
  33779. },function(w){
  33780. this._MainTex_STW=w;
  33781. });
  33782. /**
  33783. *设置纹理平铺和偏移。
  33784. *@param value 纹理平铺和偏移。
  33785. */
  33786. /**
  33787. *获取纹理平铺和偏移。
  33788. *@return 纹理平铺和偏移。
  33789. */
  33790. __getset(0,__proto,'tilingOffset',function(){
  33791. return this._shaderValues.getVector(TrailMaterial.TILINGOFFSET);
  33792. },function(value){
  33793. if (value){
  33794. if (value.x !=1 || value.y !=1 || value.z !=0 || value.w !=0)
  33795. this._defineDatas.add(laya.d3.core.trail.TrailMaterial.SHADERDEFINE_TILINGOFFSET);
  33796. else
  33797. this._defineDatas.remove(laya.d3.core.trail.TrailMaterial.SHADERDEFINE_TILINGOFFSET);
  33798. }else {
  33799. this._defineDatas.remove(laya.d3.core.trail.TrailMaterial.SHADERDEFINE_TILINGOFFSET);
  33800. }
  33801. this._shaderValues.setVector(TrailMaterial.TILINGOFFSET,value);
  33802. });
  33803. /**
  33804. *设置是否写入深度。
  33805. *@param value 是否写入深度。
  33806. */
  33807. /**
  33808. *获取是否写入深度。
  33809. *@return 是否写入深度。
  33810. */
  33811. __getset(0,__proto,'depthWrite',function(){
  33812. return this._shaderValues.getBool(TrailMaterial.DEPTH_WRITE);
  33813. },function(value){
  33814. this._shaderValues.setBool(TrailMaterial.DEPTH_WRITE,value);
  33815. });
  33816. /**
  33817. *设置剔除方式。
  33818. *@param value 剔除方式。
  33819. */
  33820. /**
  33821. *获取剔除方式。
  33822. *@return 剔除方式。
  33823. */
  33824. __getset(0,__proto,'cull',function(){
  33825. return this._shaderValues.getInt(TrailMaterial.CULL);
  33826. },function(value){
  33827. this._shaderValues.setInt(TrailMaterial.CULL,value);
  33828. });
  33829. /**
  33830. *设置混合目标。
  33831. *@param value 混合目标
  33832. */
  33833. /**
  33834. *获取混合目标。
  33835. *@return 混合目标。
  33836. */
  33837. __getset(0,__proto,'blendDst',function(){
  33838. return this._shaderValues.getInt(TrailMaterial.BLEND_DST);
  33839. },function(value){
  33840. this._shaderValues.setInt(TrailMaterial.BLEND_DST,value);
  33841. });
  33842. /**
  33843. *设置深度测试方式。
  33844. *@param value 深度测试方式
  33845. */
  33846. /**
  33847. *获取深度测试方式。
  33848. *@return 深度测试方式。
  33849. */
  33850. __getset(0,__proto,'depthTest',function(){
  33851. return this._shaderValues.getInt(TrailMaterial.DEPTH_TEST);
  33852. },function(value){
  33853. this._shaderValues.setInt(TrailMaterial.DEPTH_TEST,value);
  33854. });
  33855. TrailMaterial.__init__=function(){
  33856. TrailMaterial.SHADERDEFINE_MAINTEXTURE=TrailMaterial.shaderDefines.registerDefine("MAINTEXTURE");
  33857. TrailMaterial.SHADERDEFINE_TILINGOFFSET=TrailMaterial.shaderDefines.registerDefine("TILINGOFFSET");
  33858. TrailMaterial.SHADERDEFINE_ADDTIVEFOG=TrailMaterial.shaderDefines.registerDefine("ADDTIVEFOG");
  33859. }
  33860. TrailMaterial.RENDERMODE_ALPHABLENDED=0;
  33861. TrailMaterial.RENDERMODE_ADDTIVE=1;
  33862. TrailMaterial.SHADERDEFINE_MAINTEXTURE=0;
  33863. TrailMaterial.SHADERDEFINE_TILINGOFFSET=0;
  33864. TrailMaterial.SHADERDEFINE_ADDTIVEFOG=0;
  33865. __static(TrailMaterial,
  33866. ['defaultMaterial',function(){return this.defaultMaterial=new TrailMaterial();},'MAINTEXTURE',function(){return this.MAINTEXTURE=Shader3D.propertyNameToID("u_MainTexture");},'TINTCOLOR',function(){return this.TINTCOLOR=Shader3D.propertyNameToID("u_MainColor");},'TILINGOFFSET',function(){return this.TILINGOFFSET=Shader3D.propertyNameToID("u_TilingOffset");},'CULL',function(){return this.CULL=Shader3D.propertyNameToID("s_Cull");},'BLEND',function(){return this.BLEND=Shader3D.propertyNameToID("s_Blend");},'BLEND_SRC',function(){return this.BLEND_SRC=Shader3D.propertyNameToID("s_BlendSrc");},'BLEND_DST',function(){return this.BLEND_DST=Shader3D.propertyNameToID("s_BlendDst");},'DEPTH_TEST',function(){return this.DEPTH_TEST=Shader3D.propertyNameToID("s_DepthTest");},'DEPTH_WRITE',function(){return this.DEPTH_WRITE=Shader3D.propertyNameToID("s_DepthWrite");},'shaderDefines',function(){return this.shaderDefines=new ShaderDefines(BaseMaterial.shaderDefines);}
  33867. ]);
  33868. return TrailMaterial;
  33869. })(BaseMaterial)
  33870. /**
  33871. *<code>SkyProceduralMaterial</code> 类用于实现SkyProceduralMaterial材质。
  33872. */
  33873. //class laya.d3.core.material.SkyProceduralMaterial extends laya.d3.core.material.BaseMaterial
  33874. var SkyProceduralMaterial=(function(_super){
  33875. function SkyProceduralMaterial(){
  33876. /**@private */
  33877. this._sunDisk=0;
  33878. SkyProceduralMaterial.__super.call(this);
  33879. this.setShaderName("SkyBoxProcedural");
  33880. this.sunDisk=1;
  33881. this.sunSize=0.04;
  33882. this.sunSizeConvergence=5;
  33883. this.atmosphereThickness=1.0;
  33884. this.skyTint=new Vector4(0.5,0.5,0.5,1.0);
  33885. this.groundTint=new Vector4(0.369,0.349,0.341,1.0);
  33886. this.exposure=1.3;
  33887. }
  33888. __class(SkyProceduralMaterial,'laya.d3.core.material.SkyProceduralMaterial',_super);
  33889. var __proto=SkyProceduralMaterial.prototype;
  33890. /**
  33891. *设置曝光强度,范围是0到8。
  33892. *@param value 曝光强度。
  33893. */
  33894. /**
  33895. *获取曝光强度,范围是0到8。
  33896. *@return 曝光强度。
  33897. */
  33898. __getset(0,__proto,'exposure',function(){
  33899. return this._shaderValues.getNumber(SkyProceduralMaterial.EXPOSURE);
  33900. },function(value){
  33901. value=Math.min(Math.max(0.0,value),8.0);
  33902. this._shaderValues.setNumber(SkyProceduralMaterial.EXPOSURE,value);
  33903. });
  33904. /**
  33905. *设置太阳尺寸,范围是0到1。
  33906. *@param value 太阳尺寸。
  33907. */
  33908. /**
  33909. *获取太阳尺寸,范围是0到1。
  33910. *@return 太阳尺寸。
  33911. */
  33912. __getset(0,__proto,'sunSize',function(){
  33913. return this._shaderValues.getNumber(SkyProceduralMaterial.SUNSIZE);
  33914. },function(value){
  33915. value=Math.min(Math.max(0.0,value),1.0);
  33916. this._shaderValues.setNumber(SkyProceduralMaterial.SUNSIZE,value);
  33917. });
  33918. /**
  33919. *设置太阳状态。
  33920. *@param value 太阳状态。
  33921. */
  33922. /**
  33923. *获取太阳状态。
  33924. *@return 太阳状态。
  33925. */
  33926. __getset(0,__proto,'sunDisk',function(){
  33927. return this._sunDisk;
  33928. },function(value){
  33929. switch (value){
  33930. case 1:
  33931. this._defineDatas.remove(SkyProceduralMaterial.SHADERDEFINE_SUN_SIMPLE);
  33932. this._defineDatas.add(SkyProceduralMaterial.SHADERDEFINE_SUN_HIGH_QUALITY);
  33933. break ;
  33934. case 2:
  33935. this._defineDatas.remove(SkyProceduralMaterial.SHADERDEFINE_SUN_HIGH_QUALITY);
  33936. this._defineDatas.add(SkyProceduralMaterial.SHADERDEFINE_SUN_SIMPLE);
  33937. break ;
  33938. case 0:
  33939. this._defineDatas.remove(SkyProceduralMaterial.SHADERDEFINE_SUN_HIGH_QUALITY);
  33940. this._defineDatas.remove(SkyProceduralMaterial.SHADERDEFINE_SUN_SIMPLE);
  33941. break ;
  33942. default :
  33943. throw "SkyBoxProceduralMaterial: unknown sun value.";
  33944. }
  33945. this._sunDisk=value;
  33946. });
  33947. /**
  33948. *设置太阳尺寸收缩,范围是0到20。
  33949. *@param value 太阳尺寸收缩。
  33950. */
  33951. /**
  33952. *获取太阳尺寸收缩,范围是0到20。
  33953. *@return 太阳尺寸收缩。
  33954. */
  33955. __getset(0,__proto,'sunSizeConvergence',function(){
  33956. return this._shaderValues.getNumber(SkyProceduralMaterial.SUNSIZECONVERGENCE);
  33957. },function(value){
  33958. value=Math.min(Math.max(0.0,value),20.0);
  33959. this._shaderValues.setNumber(SkyProceduralMaterial.SUNSIZECONVERGENCE,value);
  33960. });
  33961. /**
  33962. *设置大气厚度,范围是0到5。
  33963. *@param value 大气厚度。
  33964. */
  33965. /**
  33966. *获取大气厚度,范围是0到5。
  33967. *@return 大气厚度。
  33968. */
  33969. __getset(0,__proto,'atmosphereThickness',function(){
  33970. return this._shaderValues.getNumber(SkyProceduralMaterial.ATMOSPHERETHICKNESS);
  33971. },function(value){
  33972. value=Math.min(Math.max(0.0,value),5.0);
  33973. this._shaderValues.setNumber(SkyProceduralMaterial.ATMOSPHERETHICKNESS,value);
  33974. });
  33975. /**
  33976. *设置地面颜色。
  33977. *@param value 地面颜色。
  33978. */
  33979. /**
  33980. *获取地面颜色。
  33981. *@return 地面颜色。
  33982. */
  33983. __getset(0,__proto,'groundTint',function(){
  33984. return this._shaderValues.getVector(SkyProceduralMaterial.GROUNDTINT);
  33985. },function(value){
  33986. this._shaderValues.setVector(SkyProceduralMaterial.GROUNDTINT,value);
  33987. });
  33988. /**
  33989. *设置天空颜色。
  33990. *@param value 天空颜色。
  33991. */
  33992. /**
  33993. *获取天空颜色。
  33994. *@return 天空颜色。
  33995. */
  33996. __getset(0,__proto,'skyTint',function(){
  33997. return this._shaderValues.getVector(SkyProceduralMaterial.SKYTINT);
  33998. },function(value){
  33999. this._shaderValues.setVector(SkyProceduralMaterial.SKYTINT,value);
  34000. });
  34001. SkyProceduralMaterial.__init__=function(){
  34002. SkyProceduralMaterial.SHADERDEFINE_SUN_HIGH_QUALITY=SkyProceduralMaterial.shaderDefines.registerDefine("SUN_HIGH_QUALITY");
  34003. SkyProceduralMaterial.SHADERDEFINE_SUN_SIMPLE=SkyProceduralMaterial.shaderDefines.registerDefine("SUN_SIMPLE");
  34004. }
  34005. SkyProceduralMaterial.SUN_NODE=0;
  34006. SkyProceduralMaterial.SUN_HIGH_QUALITY=1;
  34007. SkyProceduralMaterial.SUN_SIMPLE=2;
  34008. SkyProceduralMaterial.SHADERDEFINE_SUN_HIGH_QUALITY=0;
  34009. SkyProceduralMaterial.SHADERDEFINE_SUN_SIMPLE=0;
  34010. __static(SkyProceduralMaterial,
  34011. ['SUNSIZE',function(){return this.SUNSIZE=Shader3D.propertyNameToID("u_SunSize");},'SUNSIZECONVERGENCE',function(){return this.SUNSIZECONVERGENCE=Shader3D.propertyNameToID("u_SunSizeConvergence");},'ATMOSPHERETHICKNESS',function(){return this.ATMOSPHERETHICKNESS=Shader3D.propertyNameToID("u_AtmosphereThickness");},'SKYTINT',function(){return this.SKYTINT=Shader3D.propertyNameToID("u_SkyTint");},'GROUNDTINT',function(){return this.GROUNDTINT=Shader3D.propertyNameToID("u_GroundTint");},'EXPOSURE',function(){return this.EXPOSURE=Shader3D.propertyNameToID("u_Exposure");},'defaultMaterial',function(){return this.defaultMaterial=new SkyProceduralMaterial();},'shaderDefines',function(){return this.shaderDefines=new ShaderDefines(BaseMaterial.shaderDefines);}
  34012. ]);
  34013. return SkyProceduralMaterial;
  34014. })(BaseMaterial)
  34015. /**
  34016. *...
  34017. *@author
  34018. */
  34019. //class laya.d3.core.pixelLine.PixelLineMaterial extends laya.d3.core.material.BaseMaterial
  34020. var PixelLineMaterial=(function(_super){
  34021. function PixelLineMaterial(){
  34022. PixelLineMaterial.__super.call(this);
  34023. this.setShaderName("LineShader");
  34024. this._shaderValues.setVector(PixelLineMaterial.COLOR,new Vector4(1.0,1.0,1.0,1.0));
  34025. }
  34026. __class(PixelLineMaterial,'laya.d3.core.pixelLine.PixelLineMaterial',_super);
  34027. var __proto=PixelLineMaterial.prototype;
  34028. /**
  34029. *设置混合方式。
  34030. *@param value 混合方式。
  34031. */
  34032. /**
  34033. *获取混合方式。
  34034. *@return 混合方式。
  34035. */
  34036. __getset(0,__proto,'blend',function(){
  34037. return this._shaderValues.getInt(PixelLineMaterial.BLEND);
  34038. },function(value){
  34039. this._shaderValues.setInt(PixelLineMaterial.BLEND,value);
  34040. });
  34041. /**
  34042. *设置颜色。
  34043. *@param value 颜色。
  34044. */
  34045. /**
  34046. *获取颜色。
  34047. *@return 颜色。
  34048. */
  34049. __getset(0,__proto,'color',function(){
  34050. return this._shaderValues.getVector(PixelLineMaterial.COLOR);
  34051. },function(value){
  34052. this._shaderValues.setVector(PixelLineMaterial.COLOR,value);
  34053. });
  34054. /**
  34055. *设置剔除方式。
  34056. *@param value 剔除方式。
  34057. */
  34058. /**
  34059. *获取剔除方式。
  34060. *@return 剔除方式。
  34061. */
  34062. __getset(0,__proto,'cull',function(){
  34063. return this._shaderValues.getInt(PixelLineMaterial.CULL);
  34064. },function(value){
  34065. this._shaderValues.setInt(PixelLineMaterial.CULL,value);
  34066. });
  34067. /**
  34068. *设置是否写入深度。
  34069. *@param value 是否写入深度。
  34070. */
  34071. /**
  34072. *获取是否写入深度。
  34073. *@return 是否写入深度。
  34074. */
  34075. __getset(0,__proto,'depthWrite',function(){
  34076. return this._shaderValues.getBool(PixelLineMaterial.DEPTH_WRITE);
  34077. },function(value){
  34078. this._shaderValues.setBool(PixelLineMaterial.DEPTH_WRITE,value);
  34079. });
  34080. /**
  34081. *设置混合源。
  34082. *@param value 混合源
  34083. */
  34084. /**
  34085. *获取混合源。
  34086. *@return 混合源。
  34087. */
  34088. __getset(0,__proto,'blendSrc',function(){
  34089. return this._shaderValues.getInt(PixelLineMaterial.BLEND_SRC);
  34090. },function(value){
  34091. this._shaderValues.setInt(PixelLineMaterial.BLEND_SRC,value);
  34092. });
  34093. /**
  34094. *设置混合目标。
  34095. *@param value 混合目标
  34096. */
  34097. /**
  34098. *获取混合目标。
  34099. *@return 混合目标。
  34100. */
  34101. __getset(0,__proto,'blendDst',function(){
  34102. return this._shaderValues.getInt(PixelLineMaterial.BLEND_DST);
  34103. },function(value){
  34104. this._shaderValues.setInt(PixelLineMaterial.BLEND_DST,value);
  34105. });
  34106. /**
  34107. *设置深度测试方式。
  34108. *@param value 深度测试方式
  34109. */
  34110. /**
  34111. *获取深度测试方式。
  34112. *@return 深度测试方式。
  34113. */
  34114. __getset(0,__proto,'depthTest',function(){
  34115. return this._shaderValues.getInt(PixelLineMaterial.DEPTH_TEST);
  34116. },function(value){
  34117. this._shaderValues.setInt(PixelLineMaterial.DEPTH_TEST,value);
  34118. });
  34119. __static(PixelLineMaterial,
  34120. ['COLOR',function(){return this.COLOR=Shader3D.propertyNameToID("u_Color");},'defaultMaterial',function(){return this.defaultMaterial=new PixelLineMaterial();},'shaderDefines',function(){return this.shaderDefines=new ShaderDefines(BaseMaterial.shaderDefines);},'CULL',function(){return this.CULL=Shader3D.propertyNameToID("s_Cull");},'BLEND',function(){return this.BLEND=Shader3D.propertyNameToID("s_Blend");},'BLEND_SRC',function(){return this.BLEND_SRC=Shader3D.propertyNameToID("s_BlendSrc");},'BLEND_DST',function(){return this.BLEND_DST=Shader3D.propertyNameToID("s_BlendDst");},'DEPTH_TEST',function(){return this.DEPTH_TEST=Shader3D.propertyNameToID("s_DepthTest");},'DEPTH_WRITE',function(){return this.DEPTH_WRITE=Shader3D.propertyNameToID("s_DepthWrite");}
  34121. ]);
  34122. return PixelLineMaterial;
  34123. })(BaseMaterial)
  34124. /**
  34125. *<code>BaseCamera</code> 类用于创建摄像机的父类。
  34126. */
  34127. //class laya.d3.core.BaseCamera extends laya.d3.core.Sprite3D
  34128. var BaseCamera=(function(_super){
  34129. function BaseCamera(nearPlane,farPlane){
  34130. /**@private 渲染顺序。*/
  34131. //this._renderingOrder=0;
  34132. /**@private 近裁剪面。*/
  34133. //this._nearPlane=NaN;
  34134. /**@private 远裁剪面。*/
  34135. //this._farPlane=NaN;
  34136. /**@private 视野。*/
  34137. //this._fieldOfView=NaN;
  34138. /**@private 正交投影的垂直尺寸。*/
  34139. //this._orthographicVerticalSize=NaN;
  34140. /**@private */
  34141. //this._orthographic=false;
  34142. /**@private 是否使用用户自定义投影矩阵,如果使用了用户投影矩阵,摄像机投影矩阵相关的参数改变则不改变投影矩阵的值,需调用ResetProjectionMatrix方法。*/
  34143. //this._useUserProjectionMatrix=false;
  34144. /**@private */
  34145. //this._shaderValues=null;
  34146. /**清楚标记。*/
  34147. //this.clearFlag=0;
  34148. /**可视层位标记遮罩值,支持混合 例:cullingMask=Math.pow(2,0)|Math.pow(2,1)为第0层和第1层可见。*/
  34149. //this.cullingMask=0;
  34150. /**渲染时是否用遮挡剔除。 */
  34151. //this.useOcclusionCulling=false;
  34152. BaseCamera.__super.call(this);
  34153. this._skyRenderer=new SkyRenderer();
  34154. this._forward=new Vector3();
  34155. this._up=new Vector3();
  34156. this.clearColor=new Vector4(100 / 255,149 / 255,237 / 255,255 / 255);
  34157. (nearPlane===void 0)&& (nearPlane=0.3);
  34158. (farPlane===void 0)&& (farPlane=1000);
  34159. this._shaderValues=new ShaderData(null);
  34160. this._fieldOfView=60;
  34161. this._useUserProjectionMatrix=false;
  34162. this._orthographic=false;
  34163. this._orthographicVerticalSize=10;
  34164. this.renderingOrder=0;
  34165. this._nearPlane=nearPlane;
  34166. this._farPlane=farPlane;
  34167. this.cullingMask=2147483647;
  34168. this.clearFlag=/*CLASS CONST:laya.d3.core.BaseCamera.CLEARFLAG_SOLIDCOLOR*/0;
  34169. this.useOcclusionCulling=true;
  34170. this._calculateProjectionMatrix();
  34171. Laya.stage.on(/*laya.events.Event.RESIZE*/"resize",this,this._onScreenSizeChanged);
  34172. }
  34173. __class(BaseCamera,'laya.d3.core.BaseCamera',_super);
  34174. var __proto=BaseCamera.prototype;
  34175. /**
  34176. *通过RenderingOrder属性对摄像机机型排序。
  34177. */
  34178. __proto._sortCamerasByRenderingOrder=function(){
  34179. if (this.displayedInStage){
  34180. var cameraPool=this.scene._cameraPool;
  34181. var n=cameraPool.length-1;
  34182. for (var i=0;i < n;i++){
  34183. if (cameraPool[i].renderingOrder > cameraPool[n].renderingOrder){
  34184. var tempCamera=cameraPool[i];
  34185. cameraPool[i]=cameraPool[n];
  34186. cameraPool[n]=tempCamera;
  34187. }
  34188. }
  34189. }
  34190. }
  34191. /**
  34192. *@private
  34193. */
  34194. __proto._calculateProjectionMatrix=function(){}
  34195. /**
  34196. *@private
  34197. */
  34198. __proto._onScreenSizeChanged=function(){
  34199. this._calculateProjectionMatrix();
  34200. }
  34201. /**
  34202. *@private
  34203. */
  34204. __proto._prepareCameraToRender=function(){
  34205. this.transform.getForward(this._forward);
  34206. this.transform.getUp(this._up);
  34207. var cameraSV=this._shaderValues;
  34208. cameraSV.setVector3(laya.d3.core.BaseCamera.CAMERAPOS,this.transform.position);
  34209. cameraSV.setVector3(laya.d3.core.BaseCamera.CAMERADIRECTION,this._forward);
  34210. cameraSV.setVector3(laya.d3.core.BaseCamera.CAMERAUP,this._up);
  34211. }
  34212. /**
  34213. *@private
  34214. */
  34215. __proto._prepareCameraViewProject=function(vieMat,proMat,viewProject,vieProNoTraSca){
  34216. var shaderData=this._shaderValues;
  34217. shaderData.setMatrix4x4(laya.d3.core.BaseCamera.VIEWMATRIX,vieMat);
  34218. shaderData.setMatrix4x4(laya.d3.core.BaseCamera.PROJECTMATRIX,proMat);
  34219. shaderData.setMatrix4x4(laya.d3.core.BaseCamera.VIEWPROJECTMATRIX,viewProject);
  34220. this.transform.worldMatrix.cloneTo(BaseCamera._tempMatrix4x40);
  34221. BaseCamera._tempMatrix4x40.transpose();
  34222. Matrix4x4.multiply(proMat,BaseCamera._tempMatrix4x40,vieProNoTraSca);
  34223. shaderData.setMatrix4x4(laya.d3.core.BaseCamera.VPMATRIX_NO_TRANSLATE,vieProNoTraSca);
  34224. }
  34225. /**
  34226. *相机渲染。
  34227. *@param shader 着色器。
  34228. *@param replacementTag 着色器替换标记。
  34229. */
  34230. __proto.render=function(shader,replacementTag){}
  34231. /**
  34232. *增加可视图层,layer值为0到31层。
  34233. *@param layer 图层。
  34234. */
  34235. __proto.addLayer=function(layer){
  34236. this.cullingMask |=Math.pow(2,layer);
  34237. }
  34238. /**
  34239. *移除可视图层,layer值为0到31层。
  34240. *@param layer 图层。
  34241. */
  34242. __proto.removeLayer=function(layer){
  34243. this.cullingMask &=~Math.pow(2,layer);
  34244. }
  34245. /**
  34246. *增加所有图层。
  34247. */
  34248. __proto.addAllLayers=function(){
  34249. this.cullingMask=2147483647;
  34250. }
  34251. /**
  34252. *移除所有图层。
  34253. */
  34254. __proto.removeAllLayers=function(){
  34255. this.cullingMask=0;
  34256. }
  34257. __proto.resetProjectionMatrix=function(){
  34258. this._useUserProjectionMatrix=false;
  34259. this._calculateProjectionMatrix();
  34260. }
  34261. /**
  34262. *@inheritDoc
  34263. */
  34264. __proto._onActive=function(){
  34265. (this._scene)._addCamera(this);
  34266. laya.display.Node.prototype._onActive.call(this);
  34267. }
  34268. /**
  34269. *@inheritDoc
  34270. */
  34271. __proto._onInActive=function(){
  34272. (this._scene)._removeCamera(this);
  34273. laya.display.Node.prototype._onInActive.call(this);
  34274. }
  34275. /**
  34276. *@inheritDoc
  34277. */
  34278. __proto._parse=function(data,spriteMap){
  34279. _super.prototype._parse.call(this,data,spriteMap);
  34280. var clearFlagData=data.clearFlag;
  34281. (clearFlagData!==undefined)&& (this.clearFlag=clearFlagData);
  34282. this.orthographic=data.orthographic;
  34283. this.fieldOfView=data.fieldOfView;
  34284. this.nearPlane=data.nearPlane;
  34285. this.farPlane=data.farPlane;
  34286. var color=data.clearColor;
  34287. this.clearColor=new Vector4(color[0],color[1],color[2],color[3]);
  34288. var skyboxMaterial=data.skyboxMaterial;
  34289. if (skyboxMaterial){
  34290. this._skyRenderer.material=Loader.getRes(skyboxMaterial.path);
  34291. }
  34292. }
  34293. /**
  34294. *@inheritDoc
  34295. */
  34296. __proto.destroy=function(destroyChild){
  34297. (destroyChild===void 0)&& (destroyChild=true);
  34298. this._skyRenderer.destroy();
  34299. this._skyRenderer=null;
  34300. Laya.stage.off(/*laya.events.Event.RESIZE*/"resize",this,this._onScreenSizeChanged);
  34301. _super.prototype.destroy.call(this,destroyChild);
  34302. }
  34303. __getset(0,__proto,'renderingOrder',function(){
  34304. return this._renderingOrder;
  34305. },function(value){
  34306. this._renderingOrder=value;
  34307. this._sortCamerasByRenderingOrder();
  34308. });
  34309. /**
  34310. *获取天空渲染器。
  34311. *@return 天空渲染器。
  34312. */
  34313. __getset(0,__proto,'skyRenderer',function(){
  34314. return this._skyRenderer;
  34315. });
  34316. /**
  34317. *设置是否正交投影矩阵。
  34318. *@param 是否正交投影矩阵。
  34319. */
  34320. /**
  34321. *获取是否正交投影矩阵。
  34322. *@return 是否正交投影矩阵。
  34323. */
  34324. __getset(0,__proto,'orthographic',function(){
  34325. return this._orthographic;
  34326. },function(vaule){
  34327. this._orthographic=vaule;
  34328. this._calculateProjectionMatrix();
  34329. });
  34330. /**
  34331. *设置视野。
  34332. *@param value 视野。
  34333. */
  34334. /**
  34335. *获取视野。
  34336. *@return 视野。
  34337. */
  34338. __getset(0,__proto,'fieldOfView',function(){
  34339. return this._fieldOfView;
  34340. },function(value){
  34341. this._fieldOfView=value;
  34342. this._calculateProjectionMatrix();
  34343. });
  34344. /**
  34345. *设置近裁面。
  34346. *@param value 近裁面。
  34347. */
  34348. /**
  34349. *获取近裁面。
  34350. *@return 近裁面。
  34351. */
  34352. __getset(0,__proto,'nearPlane',function(){
  34353. return this._nearPlane;
  34354. },function(value){
  34355. this._nearPlane=value;
  34356. this._calculateProjectionMatrix();
  34357. });
  34358. /**
  34359. *设置远裁面。
  34360. *@param value 远裁面。
  34361. */
  34362. /**
  34363. *获取远裁面。
  34364. *@return 远裁面。
  34365. */
  34366. __getset(0,__proto,'farPlane',function(){
  34367. return this._farPlane;
  34368. },function(vaule){
  34369. this._farPlane=vaule;
  34370. this._calculateProjectionMatrix();
  34371. });
  34372. /**
  34373. *设置正交投影垂直矩阵尺寸。
  34374. *@param 正交投影垂直矩阵尺寸。
  34375. */
  34376. /**
  34377. *获取正交投影垂直矩阵尺寸。
  34378. *@return 正交投影垂直矩阵尺寸。
  34379. */
  34380. __getset(0,__proto,'orthographicVerticalSize',function(){
  34381. return this._orthographicVerticalSize;
  34382. },function(vaule){
  34383. this._orthographicVerticalSize=vaule;
  34384. this._calculateProjectionMatrix();
  34385. });
  34386. BaseCamera.RENDERINGTYPE_DEFERREDLIGHTING="DEFERREDLIGHTING";
  34387. BaseCamera.RENDERINGTYPE_FORWARDRENDERING="FORWARDRENDERING";
  34388. BaseCamera.CLEARFLAG_SOLIDCOLOR=0;
  34389. BaseCamera.CLEARFLAG_SKY=1;
  34390. BaseCamera.CLEARFLAG_DEPTHONLY=2;
  34391. BaseCamera.CLEARFLAG_NONE=3;
  34392. __static(BaseCamera,
  34393. ['_tempMatrix4x40',function(){return this._tempMatrix4x40=new Matrix4x4();},'CAMERAPOS',function(){return this.CAMERAPOS=Shader3D.propertyNameToID("u_CameraPos");},'VIEWMATRIX',function(){return this.VIEWMATRIX=Shader3D.propertyNameToID("u_View");},'PROJECTMATRIX',function(){return this.PROJECTMATRIX=Shader3D.propertyNameToID("u_Projection");},'VIEWPROJECTMATRIX',function(){return this.VIEWPROJECTMATRIX=Shader3D.propertyNameToID("u_ViewProjection");},'VPMATRIX_NO_TRANSLATE',function(){return this.VPMATRIX_NO_TRANSLATE=Shader3D.propertyNameToID("u_MvpMatrix");},'CAMERADIRECTION',function(){return this.CAMERADIRECTION=Shader3D.propertyNameToID("u_CameraDirection");},'CAMERAUP',function(){return this.CAMERAUP=Shader3D.propertyNameToID("u_CameraUp");},'_invertYScaleMatrix',function(){return this._invertYScaleMatrix=new Matrix4x4(1,0,0,0,0,-1,0,0,0,0,1,0,0,0,0,1);},'_invertYProjectionMatrix',function(){return this._invertYProjectionMatrix=new Matrix4x4();},'_invertYProjectionViewMatrix',function(){return this._invertYProjectionViewMatrix=new Matrix4x4();}
  34394. ]);
  34395. return BaseCamera;
  34396. })(Sprite3D)
  34397. /**
  34398. *<code>PBRStandardMaterial</code> 类用于实现PBR(Standard)材质。
  34399. */
  34400. //class laya.d3.core.material.PBRStandardMaterial extends laya.d3.core.material.BaseMaterial
  34401. var PBRStandardMaterial=(function(_super){
  34402. function PBRStandardMaterial(){
  34403. /**@private */
  34404. this._albedoColor=null;
  34405. /**@private */
  34406. this._emissionColor=null;
  34407. PBRStandardMaterial.__super.call(this);
  34408. this.setShaderName("PBRStandard");
  34409. this._albedoColor=new Vector4(1.0,1.0,1.0,1.0);
  34410. this._shaderValues.setVector(PBRStandardMaterial.ALBEDOCOLOR,new Vector4(1.0,1.0,1.0,1.0));
  34411. this._emissionColor=new Vector4(0.0,0.0,0.0,0.0);
  34412. this._shaderValues.setVector(PBRStandardMaterial.EMISSIONCOLOR,new Vector4(0.0,0.0,0.0,0.0));
  34413. this._shaderValues.setNumber(PBRStandardMaterial.METALLIC,0.0);
  34414. this._shaderValues.setNumber(PBRStandardMaterial.SMOOTHNESS,0.5);
  34415. this._shaderValues.setNumber(PBRStandardMaterial.SMOOTHNESSSCALE,1.0);
  34416. this._shaderValues.setNumber(PBRStandardMaterial.SMOOTHNESSSOURCE,0);
  34417. this._shaderValues.setNumber(PBRStandardMaterial.OCCLUSIONSTRENGTH,1.0);
  34418. this._shaderValues.setNumber(PBRStandardMaterial.NORMALSCALE,1.0);
  34419. this._shaderValues.setNumber(PBRStandardMaterial.PARALLAXSCALE,0.001);
  34420. this._shaderValues.setBool(PBRStandardMaterial.ENABLEEMISSION,false);
  34421. this._shaderValues.setBool(PBRStandardMaterial.ENABLEREFLECT,true);
  34422. this._shaderValues.setNumber(BaseMaterial.ALPHATESTVALUE,0.5);
  34423. this._disablePublicDefineDatas.remove(Scene3D.SHADERDEFINE_REFLECTMAP);
  34424. this.renderMode=0;
  34425. }
  34426. __class(PBRStandardMaterial,'laya.d3.core.material.PBRStandardMaterial',_super);
  34427. var __proto=PBRStandardMaterial.prototype;
  34428. /**
  34429. *@inheritDoc
  34430. */
  34431. __proto.cloneTo=function(destObject){
  34432. _super.prototype.cloneTo.call(this,destObject);
  34433. var destMaterial=destObject;
  34434. this._albedoColor.cloneTo(destMaterial._albedoColor);
  34435. this._emissionColor.cloneTo(destMaterial._emissionColor);
  34436. }
  34437. /**
  34438. *@private
  34439. */
  34440. /**@private */
  34441. __getset(0,__proto,'_Parallax',function(){
  34442. return this._shaderValues.getNumber(PBRStandardMaterial.PARALLAXSCALE);
  34443. },function(value){
  34444. this._shaderValues.setNumber(PBRStandardMaterial.PARALLAXSCALE,value);
  34445. });
  34446. /**
  34447. *@private
  34448. */
  34449. /**
  34450. *@private
  34451. */
  34452. __getset(0,__proto,'_ColorB',function(){
  34453. return this._albedoColor.z;
  34454. },function(value){
  34455. this._albedoColor.z=value;
  34456. this.albedoColor=this._albedoColor;
  34457. });
  34458. /**
  34459. *@private
  34460. */
  34461. /**
  34462. *@private
  34463. */
  34464. __getset(0,__proto,'_ColorR',function(){
  34465. return this._albedoColor.x;
  34466. },function(value){
  34467. this._albedoColor.x=value;
  34468. this.albedoColor=this._albedoColor;
  34469. });
  34470. /**
  34471. *@private
  34472. */
  34473. /**
  34474. *@private
  34475. */
  34476. __getset(0,__proto,'_ColorG',function(){
  34477. return this._albedoColor.y;
  34478. },function(value){
  34479. this._albedoColor.y=value;
  34480. this.albedoColor=this._albedoColor;
  34481. });
  34482. /**
  34483. *设置金属度。
  34484. *@param value 金属度,范围为0到1。
  34485. */
  34486. /**
  34487. *获取金属度。
  34488. *@return 金属度,范围为0到1。
  34489. */
  34490. __getset(0,__proto,'metallic',function(){
  34491. return this._Metallic;
  34492. },function(value){
  34493. this._Metallic=Math.max(0.0,Math.min(1.0,value));
  34494. });
  34495. /**
  34496. *@private
  34497. */
  34498. /**
  34499. *@private
  34500. */
  34501. __getset(0,__proto,'_GlossMapScale',function(){
  34502. return this._shaderValues.getNumber(PBRStandardMaterial.SMOOTHNESSSCALE);
  34503. },function(value){
  34504. this._shaderValues.setNumber(PBRStandardMaterial.SMOOTHNESSSCALE,value);
  34505. });
  34506. /**
  34507. *@private
  34508. */
  34509. /**
  34510. *@private
  34511. */
  34512. __getset(0,__proto,'_Glossiness',function(){
  34513. return this._shaderValues.getNumber(PBRStandardMaterial.SMOOTHNESS);
  34514. },function(value){
  34515. this._shaderValues.setNumber(PBRStandardMaterial.SMOOTHNESS,value);
  34516. });
  34517. /**
  34518. *@private
  34519. */
  34520. /**
  34521. *@private
  34522. */
  34523. __getset(0,__proto,'_ColorA',function(){
  34524. return this._albedoColor.w;
  34525. },function(value){
  34526. this._albedoColor.w=value;
  34527. this.albedoColor=this._albedoColor;
  34528. });
  34529. /**
  34530. *设置是否开启反射。
  34531. *@param value 是否开启反射。
  34532. */
  34533. /**
  34534. *获取是否开启反射。
  34535. *@return 是否开启反射。
  34536. */
  34537. __getset(0,__proto,'enableReflection',function(){
  34538. return this._shaderValues.getBool(PBRStandardMaterial.ENABLEREFLECT);
  34539. },function(value){
  34540. this._shaderValues.setBool(PBRStandardMaterial.ENABLEREFLECT,true);
  34541. if (value){
  34542. this._disablePublicDefineDatas.remove(Scene3D.SHADERDEFINE_REFLECTMAP);
  34543. }else {
  34544. this._disablePublicDefineDatas.add(Scene3D.SHADERDEFINE_REFLECTMAP);
  34545. }
  34546. });
  34547. /**
  34548. *@private
  34549. */
  34550. /**
  34551. *@private
  34552. */
  34553. __getset(0,__proto,'_Metallic',function(){
  34554. return this._shaderValues.getNumber(PBRStandardMaterial.METALLIC);
  34555. },function(value){
  34556. this._shaderValues.setNumber(PBRStandardMaterial.METALLIC,value);
  34557. });
  34558. /**
  34559. *@private
  34560. */
  34561. /**
  34562. *@private
  34563. */
  34564. __getset(0,__proto,'_BumpScale',function(){
  34565. return this._shaderValues.getNumber(PBRStandardMaterial.NORMALSCALE);
  34566. },function(value){
  34567. this._shaderValues.setNumber(PBRStandardMaterial.NORMALSCALE,value);
  34568. });
  34569. /**
  34570. *@private
  34571. */
  34572. /**@private */
  34573. __getset(0,__proto,'_OcclusionStrength',function(){
  34574. return this._shaderValues.getNumber(PBRStandardMaterial.OCCLUSIONSTRENGTH);
  34575. },function(value){
  34576. this._shaderValues.setNumber(PBRStandardMaterial.OCCLUSIONSTRENGTH,value);
  34577. });
  34578. /**
  34579. *@private
  34580. */
  34581. /**
  34582. *@private
  34583. */
  34584. __getset(0,__proto,'_EmissionColorR',function(){
  34585. return this._emissionColor.x;
  34586. },function(value){
  34587. this._emissionColor.x=value;
  34588. this.emissionColor=this._emissionColor;
  34589. });
  34590. /**
  34591. *获取纹理平铺和偏移。
  34592. *@param value 纹理平铺和偏移。
  34593. */
  34594. /**
  34595. *获取纹理平铺和偏移。
  34596. *@return 纹理平铺和偏移。
  34597. */
  34598. __getset(0,__proto,'tilingOffset',function(){
  34599. return this._shaderValues.getVector(PBRStandardMaterial.TILINGOFFSET);
  34600. },function(value){
  34601. if (value){
  34602. if (value.x !=1 || value.y !=1 || value.z !=0 || value.w !=0){
  34603. this._defineDatas.add(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_TILINGOFFSET);
  34604. }else {
  34605. this._defineDatas.remove(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_TILINGOFFSET);
  34606. }
  34607. }else {
  34608. this._defineDatas.remove(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_TILINGOFFSET);
  34609. }
  34610. this._shaderValues.setVector(PBRStandardMaterial.TILINGOFFSET,value);
  34611. });
  34612. /**
  34613. *@private
  34614. */
  34615. /**
  34616. *@private
  34617. */
  34618. __getset(0,__proto,'_EmissionColorG',function(){
  34619. return this._emissionColor.y;
  34620. },function(value){
  34621. this._emissionColor.y=value;
  34622. this.emissionColor=this._emissionColor;
  34623. });
  34624. /**
  34625. *设置混合源。
  34626. *@param value 混合源
  34627. */
  34628. /**
  34629. *获取混合源。
  34630. *@return 混合源。
  34631. */
  34632. __getset(0,__proto,'blendSrc',function(){
  34633. return this._shaderValues.getInt(PBRStandardMaterial.BLEND_SRC);
  34634. },function(value){
  34635. this._shaderValues.setInt(PBRStandardMaterial.BLEND_SRC,value);
  34636. });
  34637. /**
  34638. *获取纹理平铺和偏移W分量。
  34639. *@param w 纹理平铺和偏移W分量。
  34640. */
  34641. /**
  34642. *获取纹理平铺和偏移W分量。
  34643. *@return 纹理平铺和偏移W分量。
  34644. */
  34645. __getset(0,__proto,'tilingOffsetW',function(){
  34646. return this._MainTex_STW;
  34647. },function(w){
  34648. this._MainTex_STW=w;
  34649. });
  34650. /**
  34651. *@private
  34652. */
  34653. /**
  34654. *@private
  34655. */
  34656. __getset(0,__proto,'_EmissionColorB',function(){
  34657. return this._emissionColor.z;
  34658. },function(value){
  34659. this._emissionColor.z=value;
  34660. this.emissionColor=this._emissionColor;
  34661. });
  34662. /**
  34663. *@private
  34664. */
  34665. /**
  34666. *@private
  34667. */
  34668. __getset(0,__proto,'_EmissionColorA',function(){
  34669. return this._emissionColor.w;
  34670. },function(value){
  34671. this._emissionColor.w=value;
  34672. this.emissionColor=this._emissionColor;
  34673. });
  34674. /**
  34675. *设置反射率颜色alpha分量。
  34676. *@param value 反射率颜色alpha分量。
  34677. */
  34678. /**
  34679. *获取反射率颜色Z分量。
  34680. *@return 反射率颜色Z分量。
  34681. */
  34682. __getset(0,__proto,'albedoColorA',function(){
  34683. return this._ColorA;
  34684. },function(value){
  34685. this._ColorA=value;
  34686. });
  34687. /**
  34688. *@private
  34689. */
  34690. /**
  34691. *@private
  34692. */
  34693. __getset(0,__proto,'_MainTex_STX',function(){
  34694. return this._shaderValues.getVector(PBRStandardMaterial.TILINGOFFSET).x;
  34695. },function(x){
  34696. var tilOff=this._shaderValues.getVector(PBRStandardMaterial.TILINGOFFSET);
  34697. tilOff.x=x;
  34698. this.tilingOffset=tilOff;
  34699. });
  34700. /**
  34701. *@private
  34702. */
  34703. /**
  34704. *@private
  34705. */
  34706. __getset(0,__proto,'_MainTex_STY',function(){
  34707. return this._shaderValues.getVector(PBRStandardMaterial.TILINGOFFSET).y;
  34708. },function(y){
  34709. var tilOff=this._shaderValues.getVector(PBRStandardMaterial.TILINGOFFSET);
  34710. tilOff.y=y;
  34711. this.tilingOffset=tilOff;
  34712. });
  34713. /**
  34714. *@private
  34715. */
  34716. /**
  34717. *@private
  34718. */
  34719. __getset(0,__proto,'_MainTex_STZ',function(){
  34720. return this._shaderValues.getVector(PBRStandardMaterial.TILINGOFFSET).z;
  34721. },function(z){
  34722. var tilOff=this._shaderValues.getVector(PBRStandardMaterial.TILINGOFFSET);
  34723. tilOff.z=z;
  34724. this.tilingOffset=tilOff;
  34725. });
  34726. /**
  34727. *@private
  34728. */
  34729. /**
  34730. *@private
  34731. */
  34732. __getset(0,__proto,'_Cutoff',function(){
  34733. return this.alphaTestValue;
  34734. },function(value){
  34735. this.alphaTestValue=value;
  34736. });
  34737. /**
  34738. *@private
  34739. */
  34740. /**
  34741. *@private
  34742. */
  34743. __getset(0,__proto,'_MainTex_STW',function(){
  34744. return this._shaderValues.getVector(PBRStandardMaterial.TILINGOFFSET).w;
  34745. },function(w){
  34746. var tilOff=this._shaderValues.getVector(PBRStandardMaterial.TILINGOFFSET);
  34747. tilOff.w=w;
  34748. this.tilingOffset=tilOff;
  34749. });
  34750. /**
  34751. *设置反射率颜色R分量。
  34752. *@param value 反射率颜色R分量。
  34753. */
  34754. /**
  34755. *获取反射率颜色R分量。
  34756. *@return 反射率颜色R分量。
  34757. */
  34758. __getset(0,__proto,'albedoColorR',function(){
  34759. return this._ColorR;
  34760. },function(value){
  34761. this._ColorR=value;
  34762. });
  34763. /**
  34764. *设置反射率颜色G分量。
  34765. *@param value 反射率颜色G分量。
  34766. */
  34767. /**
  34768. *获取反射率颜色G分量。
  34769. *@return 反射率颜色G分量。
  34770. */
  34771. __getset(0,__proto,'albedoColorG',function(){
  34772. return this._ColorG;
  34773. },function(value){
  34774. this._ColorG=value;
  34775. });
  34776. /**
  34777. *设置反射率颜色B分量。
  34778. *@param value 反射率颜色B分量。
  34779. */
  34780. /**
  34781. *获取反射率颜色B分量。
  34782. *@return 反射率颜色B分量。
  34783. */
  34784. __getset(0,__proto,'albedoColorB',function(){
  34785. return this._ColorB;
  34786. },function(value){
  34787. this._ColorB=value;
  34788. });
  34789. /**
  34790. *获取纹理平铺和偏移X分量。
  34791. *@param x 纹理平铺和偏移X分量。
  34792. */
  34793. /**
  34794. *获取纹理平铺和偏移X分量。
  34795. *@return 纹理平铺和偏移X分量。
  34796. */
  34797. __getset(0,__proto,'tilingOffsetX',function(){
  34798. return this._MainTex_STX;
  34799. },function(x){
  34800. this._MainTex_STX=x;
  34801. });
  34802. /**
  34803. *设置漫反射颜色。
  34804. *@param value 漫反射颜色。
  34805. */
  34806. /**
  34807. *获取漫反射颜色。
  34808. *@return 漫反射颜色。
  34809. */
  34810. __getset(0,__proto,'albedoColor',function(){
  34811. return this._albedoColor;
  34812. },function(value){
  34813. this._albedoColor=value;
  34814. this._shaderValues.setVector(PBRStandardMaterial.ALBEDOCOLOR,value);
  34815. });
  34816. /**
  34817. *设置漫反射贴图。
  34818. *@param value 漫反射贴图。
  34819. */
  34820. /**
  34821. *获取漫反射贴图。
  34822. *@return 漫反射贴图。
  34823. */
  34824. __getset(0,__proto,'albedoTexture',function(){
  34825. return this._shaderValues.getTexture(PBRStandardMaterial.ALBEDOTEXTURE);
  34826. },function(value){
  34827. if (value){
  34828. this._defineDatas.add(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_ALBEDOTEXTURE);
  34829. }else {
  34830. this._defineDatas.remove(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_ALBEDOTEXTURE);
  34831. }
  34832. this._shaderValues.setTexture(PBRStandardMaterial.ALBEDOTEXTURE,value);
  34833. });
  34834. /**
  34835. *设置剔除方式。
  34836. *@param value 剔除方式。
  34837. */
  34838. /**
  34839. *获取剔除方式。
  34840. *@return 剔除方式。
  34841. */
  34842. __getset(0,__proto,'cull',function(){
  34843. return this._shaderValues.getInt(PBRStandardMaterial.CULL);
  34844. },function(value){
  34845. this._shaderValues.setInt(PBRStandardMaterial.CULL,value);
  34846. });
  34847. /**
  34848. *设置视差贴图。
  34849. *@param value 视察贴图。
  34850. */
  34851. /**
  34852. *获取视差贴图。
  34853. *@return 视察贴图。
  34854. */
  34855. __getset(0,__proto,'parallaxTexture',function(){
  34856. return this._shaderValues.getTexture(PBRStandardMaterial.PARALLAXTEXTURE);
  34857. },function(value){
  34858. if (value){
  34859. this._defineDatas.add(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_PARALLAXTEXTURE);
  34860. }else {
  34861. this._defineDatas.remove(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_PARALLAXTEXTURE);
  34862. }
  34863. this._shaderValues.setTexture(PBRStandardMaterial.PARALLAXTEXTURE,value);
  34864. });
  34865. /**
  34866. *设置法线贴图。
  34867. *@param value 法线贴图。
  34868. */
  34869. /**
  34870. *获取法线贴图。
  34871. *@return 法线贴图。
  34872. */
  34873. __getset(0,__proto,'normalTexture',function(){
  34874. return this._shaderValues.getTexture(PBRStandardMaterial.NORMALTEXTURE);
  34875. },function(value){
  34876. if (value){
  34877. this._defineDatas.add(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_NORMALTEXTURE);
  34878. }else {
  34879. this._defineDatas.remove(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_NORMALTEXTURE);
  34880. }
  34881. this._shaderValues.setTexture(PBRStandardMaterial.NORMALTEXTURE,value);
  34882. });
  34883. /**
  34884. *设置放射颜色。
  34885. *@param value 放射颜色。
  34886. */
  34887. /**
  34888. *获取放射颜色。
  34889. *@return 放射颜色。
  34890. */
  34891. __getset(0,__proto,'emissionColor',function(){
  34892. return this._shaderValues.getVector(PBRStandardMaterial.EMISSIONCOLOR);
  34893. },function(value){
  34894. this._shaderValues.setVector(PBRStandardMaterial.EMISSIONCOLOR,value);
  34895. });
  34896. /**
  34897. *设置视差贴图缩放系数。
  34898. *@param value 视差缩放系数。
  34899. */
  34900. /**
  34901. *获取视差贴图缩放系数。
  34902. *@return 视差缩放系数。
  34903. */
  34904. __getset(0,__proto,'parallaxTextureScale',function(){
  34905. return this._Parallax;
  34906. },function(value){
  34907. this._Parallax=Math.max(0.005,Math.min(0.08,value));
  34908. });
  34909. /**
  34910. *设置法线贴图缩放系数。
  34911. *@param value 法线贴图缩放系数。
  34912. */
  34913. /**
  34914. *获取法线贴图缩放系数。
  34915. *@return 法线贴图缩放系数。
  34916. */
  34917. __getset(0,__proto,'normalTextureScale',function(){
  34918. return this._BumpScale;
  34919. },function(value){
  34920. this._BumpScale=value;
  34921. });
  34922. /**
  34923. *获取纹理平铺和偏移Z分量。
  34924. *@param z 纹理平铺和偏移Z分量。
  34925. */
  34926. /**
  34927. *获取纹理平铺和偏移Z分量。
  34928. *@return 纹理平铺和偏移Z分量。
  34929. */
  34930. __getset(0,__proto,'tilingOffsetZ',function(){
  34931. return this._MainTex_STZ;
  34932. },function(z){
  34933. this._MainTex_STZ=z;
  34934. });
  34935. /**
  34936. *设置遮挡贴图。
  34937. *@param value 遮挡贴图。
  34938. */
  34939. /**
  34940. *获取遮挡贴图。
  34941. *@return 遮挡贴图。
  34942. */
  34943. __getset(0,__proto,'occlusionTexture',function(){
  34944. return this._shaderValues.getTexture(PBRStandardMaterial.OCCLUSIONTEXTURE);
  34945. },function(value){
  34946. if (value){
  34947. this._defineDatas.add(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_OCCLUSIONTEXTURE);
  34948. }else {
  34949. this._defineDatas.remove(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_OCCLUSIONTEXTURE);
  34950. }
  34951. this._shaderValues.setTexture(PBRStandardMaterial.OCCLUSIONTEXTURE,value);
  34952. });
  34953. /**
  34954. *设置遮挡贴图强度。
  34955. *@param value 遮挡贴图强度,范围为0到1。
  34956. */
  34957. /**
  34958. *获取遮挡贴图强度。
  34959. *@return 遮挡贴图强度,范围为0到1。
  34960. */
  34961. __getset(0,__proto,'occlusionTextureStrength',function(){
  34962. return this._OcclusionStrength;
  34963. },function(value){
  34964. this._OcclusionStrength=Math.max(0.0,Math.min(1.0,value));
  34965. });
  34966. /**
  34967. *设置是否激活放射属性。
  34968. *@param value 是否激活放射属性
  34969. */
  34970. /**
  34971. *获取是否激活放射属性。
  34972. *@return 是否激活放射属性。
  34973. */
  34974. __getset(0,__proto,'enableEmission',function(){
  34975. return this._shaderValues.getBool(PBRStandardMaterial.ENABLEEMISSION);
  34976. },function(value){
  34977. if (value){
  34978. this._defineDatas.add(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_EMISSION);
  34979. }else {
  34980. this._defineDatas.remove(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_EMISSION);
  34981. }
  34982. this._shaderValues.setBool(PBRStandardMaterial.ENABLEEMISSION,value);
  34983. });
  34984. /**
  34985. *设置金属光滑度贴图。
  34986. *@param value 金属光滑度贴图。
  34987. */
  34988. /**
  34989. *获取金属光滑度贴图。
  34990. *@return 金属光滑度贴图。
  34991. */
  34992. __getset(0,__proto,'metallicGlossTexture',function(){
  34993. return this._shaderValues.getTexture(PBRStandardMaterial.METALLICGLOSSTEXTURE);
  34994. },function(value){
  34995. if (value){
  34996. this._defineDatas.add(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_METALLICGLOSSTEXTURE);
  34997. }else {
  34998. this._defineDatas.remove(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_METALLICGLOSSTEXTURE);
  34999. }
  35000. this._shaderValues.setTexture(PBRStandardMaterial.METALLICGLOSSTEXTURE,value);
  35001. });
  35002. /**
  35003. *设置放射颜色A分量。
  35004. *@param value 放射颜色A分量。
  35005. */
  35006. /**
  35007. *获取放射颜色A分量。
  35008. *@return 放射颜色A分量。
  35009. */
  35010. __getset(0,__proto,'emissionColorA',function(){
  35011. return this._EmissionColorA;
  35012. },function(value){
  35013. this._EmissionColorA=value;
  35014. });
  35015. /**
  35016. *设置光滑度。
  35017. *@param value 光滑度,范围为0到1。
  35018. */
  35019. /**
  35020. *获取光滑度。
  35021. *@return 光滑度,范围为0到1。
  35022. */
  35023. __getset(0,__proto,'smoothness',function(){
  35024. return this._Glossiness;
  35025. },function(value){
  35026. this._Glossiness=Math.max(0.0,Math.min(1.0,value));
  35027. });
  35028. /**
  35029. *设置混合目标。
  35030. *@param value 混合目标
  35031. */
  35032. /**
  35033. *获取混合目标。
  35034. *@return 混合目标。
  35035. */
  35036. __getset(0,__proto,'blendDst',function(){
  35037. return this._shaderValues.getInt(PBRStandardMaterial.BLEND_DST);
  35038. },function(value){
  35039. this._shaderValues.setInt(PBRStandardMaterial.BLEND_DST,value);
  35040. });
  35041. /**
  35042. *设置光滑度缩放系数。
  35043. *@param value 光滑度缩放系数,范围为0到1。
  35044. */
  35045. /**
  35046. *获取光滑度缩放系数。
  35047. *@return 光滑度缩放系数,范围为0到1。
  35048. */
  35049. __getset(0,__proto,'smoothnessTextureScale',function(){
  35050. return this._GlossMapScale;
  35051. },function(value){
  35052. this._GlossMapScale=Math.max(0.0,Math.min(1.0,value));
  35053. });
  35054. /**
  35055. *设置是否写入深度。
  35056. *@param value 是否写入深度。
  35057. */
  35058. /**
  35059. *获取是否写入深度。
  35060. *@return 是否写入深度。
  35061. */
  35062. __getset(0,__proto,'depthWrite',function(){
  35063. return this._shaderValues.getBool(PBRStandardMaterial.DEPTH_WRITE);
  35064. },function(value){
  35065. this._shaderValues.setBool(PBRStandardMaterial.DEPTH_WRITE,value);
  35066. });
  35067. /**
  35068. *设置光滑度数据源。
  35069. *@param value 光滑滑度数据源,0或1。
  35070. */
  35071. /**
  35072. *获取光滑度数据源
  35073. *@return 光滑滑度数据源,0或1。
  35074. */
  35075. __getset(0,__proto,'smoothnessSource',function(){
  35076. return this._shaderValues.getInt(PBRStandardMaterial.SMOOTHNESSSOURCE);
  35077. },function(value){
  35078. if (value){
  35079. this._defineDatas.add(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA);
  35080. this._shaderValues.setInt(PBRStandardMaterial.SMOOTHNESSSOURCE,1);
  35081. }else {
  35082. this._defineDatas.remove(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA);
  35083. this._shaderValues.setInt(PBRStandardMaterial.SMOOTHNESSSOURCE,0);
  35084. }
  35085. });
  35086. /**
  35087. *设置放射颜色R分量。
  35088. *@param value 放射颜色R分量。
  35089. */
  35090. /**
  35091. *获取放射颜色R分量。
  35092. *@return 放射颜色R分量。
  35093. */
  35094. __getset(0,__proto,'emissionColorR',function(){
  35095. return this._EmissionColorR;
  35096. },function(value){
  35097. this._EmissionColorR=value;
  35098. });
  35099. /**
  35100. *设置放射颜色G分量。
  35101. *@param value 放射颜色G分量。
  35102. */
  35103. /**
  35104. *获取放射颜色G分量。
  35105. *@return 放射颜色G分量。
  35106. */
  35107. __getset(0,__proto,'emissionColorG',function(){
  35108. return this._EmissionColorG;
  35109. },function(value){
  35110. this._EmissionColorG=value;
  35111. });
  35112. /**
  35113. *设置放射颜色B分量。
  35114. *@param value 放射颜色B分量。
  35115. */
  35116. /**
  35117. *获取放射颜色B分量。
  35118. *@return 放射颜色B分量。
  35119. */
  35120. __getset(0,__proto,'emissionColorB',function(){
  35121. return this._EmissionColorB;
  35122. },function(value){
  35123. this._EmissionColorB=value;
  35124. });
  35125. /**
  35126. *设置放射贴图。
  35127. *@param value 放射贴图。
  35128. */
  35129. /**
  35130. *获取放射贴图。
  35131. *@return 放射贴图。
  35132. */
  35133. __getset(0,__proto,'emissionTexture',function(){
  35134. return this._shaderValues.getTexture(PBRStandardMaterial.EMISSIONTEXTURE);
  35135. },function(value){
  35136. if (value){
  35137. this._defineDatas.add(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_EMISSIONTEXTURE);
  35138. }else {
  35139. this._defineDatas.remove(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_EMISSIONTEXTURE);
  35140. }
  35141. this._shaderValues.setTexture(PBRStandardMaterial.EMISSIONTEXTURE,value);
  35142. });
  35143. /**
  35144. *获取纹理平铺和偏移Y分量。
  35145. *@param y 纹理平铺和偏移Y分量。
  35146. */
  35147. /**
  35148. *获取纹理平铺和偏移Y分量。
  35149. *@return 纹理平铺和偏移Y分量。
  35150. */
  35151. __getset(0,__proto,'tilingOffsetY',function(){
  35152. return this._MainTex_STY;
  35153. },function(y){
  35154. this._MainTex_STY=y;
  35155. });
  35156. /**
  35157. *设置渲染模式。
  35158. *@return 渲染模式。
  35159. */
  35160. __getset(0,__proto,'renderMode',null,function(value){
  35161. switch (value){
  35162. case 0:
  35163. this.alphaTest=false;
  35164. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_OPAQUE*/2000;
  35165. this.depthWrite=true;
  35166. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  35167. this.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  35168. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  35169. this._defineDatas.remove(PBRStandardMaterial.SHADERDEFINE_ALPHAPREMULTIPLY);
  35170. break ;
  35171. case 1:
  35172. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_ALPHATEST*/2450;
  35173. this.alphaTest=true;
  35174. this.depthWrite=true;
  35175. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  35176. this.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  35177. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  35178. this._defineDatas.remove(PBRStandardMaterial.SHADERDEFINE_ALPHAPREMULTIPLY);
  35179. break ;
  35180. case 2:
  35181. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_TRANSPARENT*/3000;
  35182. this.alphaTest=false;
  35183. this.depthWrite=false;
  35184. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  35185. this.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  35186. this.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_SRC_ALPHA*/0x0302;
  35187. this.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA*/0x0303;
  35188. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  35189. this._defineDatas.remove(PBRStandardMaterial.SHADERDEFINE_ALPHAPREMULTIPLY);
  35190. break ;
  35191. break ;
  35192. case 3:
  35193. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_TRANSPARENT*/3000;
  35194. this.alphaTest=false;
  35195. this.depthWrite=false;
  35196. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  35197. this.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  35198. this.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE*/1;
  35199. this.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA*/0x0303;
  35200. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  35201. this._defineDatas.add(PBRStandardMaterial.SHADERDEFINE_ALPHAPREMULTIPLY);
  35202. break ;
  35203. default :
  35204. throw new Error("PBRSpecularMaterial : renderMode value error.");
  35205. }
  35206. });
  35207. /**
  35208. *设置混合方式。
  35209. *@param value 混合方式。
  35210. */
  35211. /**
  35212. *获取混合方式。
  35213. *@return 混合方式。
  35214. */
  35215. __getset(0,__proto,'blend',function(){
  35216. return this._shaderValues.getInt(PBRStandardMaterial.BLEND);
  35217. },function(value){
  35218. this._shaderValues.setInt(PBRStandardMaterial.BLEND,value);
  35219. });
  35220. /**
  35221. *设置深度测试方式。
  35222. *@param value 深度测试方式
  35223. */
  35224. /**
  35225. *获取深度测试方式。
  35226. *@return 深度测试方式。
  35227. */
  35228. __getset(0,__proto,'depthTest',function(){
  35229. return this._shaderValues.getInt(PBRStandardMaterial.DEPTH_TEST);
  35230. },function(value){
  35231. this._shaderValues.setInt(PBRStandardMaterial.DEPTH_TEST,value);
  35232. });
  35233. PBRStandardMaterial.__init__=function(){
  35234. PBRStandardMaterial.SHADERDEFINE_ALBEDOTEXTURE=PBRStandardMaterial.shaderDefines.registerDefine("ALBEDOTEXTURE");
  35235. PBRStandardMaterial.SHADERDEFINE_METALLICGLOSSTEXTURE=PBRStandardMaterial.shaderDefines.registerDefine("METALLICGLOSSTEXTURE");
  35236. PBRStandardMaterial.SHADERDEFINE_SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA=PBRStandardMaterial.shaderDefines.registerDefine("SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA");
  35237. PBRStandardMaterial.SHADERDEFINE_NORMALTEXTURE=PBRStandardMaterial.shaderDefines.registerDefine("NORMALTEXTURE");
  35238. PBRStandardMaterial.SHADERDEFINE_PARALLAXTEXTURE=PBRStandardMaterial.shaderDefines.registerDefine("PARALLAXTEXTURE");
  35239. PBRStandardMaterial.SHADERDEFINE_OCCLUSIONTEXTURE=PBRStandardMaterial.shaderDefines.registerDefine("OCCLUSIONTEXTURE");
  35240. PBRStandardMaterial.SHADERDEFINE_EMISSION=PBRStandardMaterial.shaderDefines.registerDefine("EMISSION");
  35241. PBRStandardMaterial.SHADERDEFINE_EMISSIONTEXTURE=PBRStandardMaterial.shaderDefines.registerDefine("EMISSIONTEXTURE");
  35242. PBRStandardMaterial.SHADERDEFINE_REFLECTMAP=PBRStandardMaterial.shaderDefines.registerDefine("REFLECTMAP");
  35243. PBRStandardMaterial.SHADERDEFINE_TILINGOFFSET=PBRStandardMaterial.shaderDefines.registerDefine("TILINGOFFSET");
  35244. PBRStandardMaterial.SHADERDEFINE_ALPHAPREMULTIPLY=PBRStandardMaterial.shaderDefines.registerDefine("ALPHAPREMULTIPLY");
  35245. }
  35246. PBRStandardMaterial.SmoothnessSource_MetallicGlossTexture_Alpha=0;
  35247. PBRStandardMaterial.SmoothnessSource_AlbedoTexture_Alpha=1;
  35248. PBRStandardMaterial.RENDERMODE_OPAQUE=0;
  35249. PBRStandardMaterial.RENDERMODE_CUTOUT=1;
  35250. PBRStandardMaterial.RENDERMODE_FADE=2;
  35251. PBRStandardMaterial.RENDERMODE_TRANSPARENT=3;
  35252. PBRStandardMaterial.SHADERDEFINE_ALBEDOTEXTURE=0;
  35253. PBRStandardMaterial.SHADERDEFINE_NORMALTEXTURE=0;
  35254. PBRStandardMaterial.SHADERDEFINE_SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA=0;
  35255. PBRStandardMaterial.SHADERDEFINE_METALLICGLOSSTEXTURE=0;
  35256. PBRStandardMaterial.SHADERDEFINE_OCCLUSIONTEXTURE=0;
  35257. PBRStandardMaterial.SHADERDEFINE_PARALLAXTEXTURE=0;
  35258. PBRStandardMaterial.SHADERDEFINE_EMISSION=0;
  35259. PBRStandardMaterial.SHADERDEFINE_EMISSIONTEXTURE=0;
  35260. PBRStandardMaterial.SHADERDEFINE_REFLECTMAP=0;
  35261. PBRStandardMaterial.SHADERDEFINE_TILINGOFFSET=0;
  35262. PBRStandardMaterial.SHADERDEFINE_ALPHAPREMULTIPLY=0;
  35263. PBRStandardMaterial.SMOOTHNESSSOURCE=-1;
  35264. PBRStandardMaterial.ENABLEEMISSION=-1;
  35265. PBRStandardMaterial.ENABLEREFLECT=-1;
  35266. __static(PBRStandardMaterial,
  35267. ['ALBEDOTEXTURE',function(){return this.ALBEDOTEXTURE=Shader3D.propertyNameToID("u_AlbedoTexture");},'METALLICGLOSSTEXTURE',function(){return this.METALLICGLOSSTEXTURE=Shader3D.propertyNameToID("u_MetallicGlossTexture");},'NORMALTEXTURE',function(){return this.NORMALTEXTURE=Shader3D.propertyNameToID("u_NormalTexture");},'PARALLAXTEXTURE',function(){return this.PARALLAXTEXTURE=Shader3D.propertyNameToID("u_ParallaxTexture");},'OCCLUSIONTEXTURE',function(){return this.OCCLUSIONTEXTURE=Shader3D.propertyNameToID("u_OcclusionTexture");},'EMISSIONTEXTURE',function(){return this.EMISSIONTEXTURE=Shader3D.propertyNameToID("u_EmissionTexture");},'ALBEDOCOLOR',function(){return this.ALBEDOCOLOR=Shader3D.propertyNameToID("u_AlbedoColor");},'EMISSIONCOLOR',function(){return this.EMISSIONCOLOR=Shader3D.propertyNameToID("u_EmissionColor");},'METALLIC',function(){return this.METALLIC=Shader3D.propertyNameToID("u_metallic");},'SMOOTHNESS',function(){return this.SMOOTHNESS=Shader3D.propertyNameToID("u_smoothness");},'SMOOTHNESSSCALE',function(){return this.SMOOTHNESSSCALE=Shader3D.propertyNameToID("u_smoothnessScale");},'OCCLUSIONSTRENGTH',function(){return this.OCCLUSIONSTRENGTH=Shader3D.propertyNameToID("u_occlusionStrength");},'NORMALSCALE',function(){return this.NORMALSCALE=Shader3D.propertyNameToID("u_normalScale");},'PARALLAXSCALE',function(){return this.PARALLAXSCALE=Shader3D.propertyNameToID("u_parallaxScale");},'TILINGOFFSET',function(){return this.TILINGOFFSET=Shader3D.propertyNameToID("u_TilingOffset");},'CULL',function(){return this.CULL=Shader3D.propertyNameToID("s_Cull");},'BLEND',function(){return this.BLEND=Shader3D.propertyNameToID("s_Blend");},'BLEND_SRC',function(){return this.BLEND_SRC=Shader3D.propertyNameToID("s_BlendSrc");},'BLEND_DST',function(){return this.BLEND_DST=Shader3D.propertyNameToID("s_BlendDst");},'DEPTH_TEST',function(){return this.DEPTH_TEST=Shader3D.propertyNameToID("s_DepthTest");},'DEPTH_WRITE',function(){return this.DEPTH_WRITE=Shader3D.propertyNameToID("s_DepthWrite");},'defaultMaterial',function(){return this.defaultMaterial=new PBRStandardMaterial();},'shaderDefines',function(){return this.shaderDefines=new ShaderDefines(BaseMaterial.shaderDefines);}
  35268. ]);
  35269. return PBRStandardMaterial;
  35270. })(BaseMaterial)
  35271. /**
  35272. *<code>ShurikenParticleMaterial</code> 类用于实现粒子材质。
  35273. */
  35274. //class laya.d3.core.particleShuriKen.ShurikenParticleMaterial extends laya.d3.core.material.BaseMaterial
  35275. var ShurikenParticleMaterial=(function(_super){
  35276. function ShurikenParticleMaterial(){
  35277. /**@private */
  35278. //this._color=null;
  35279. ShurikenParticleMaterial.__super.call(this);
  35280. this.setShaderName("PARTICLESHURIKEN");
  35281. this._color=new Vector4(1.0,1.0,1.0,1.0);
  35282. this.renderMode=0;
  35283. }
  35284. __class(ShurikenParticleMaterial,'laya.d3.core.particleShuriKen.ShurikenParticleMaterial',_super);
  35285. var __proto=ShurikenParticleMaterial.prototype;
  35286. /**
  35287. *@private
  35288. */
  35289. /**
  35290. *@private
  35291. */
  35292. __getset(0,__proto,'_TintColorB',function(){
  35293. return this._color.z;
  35294. },function(value){
  35295. this._color.z=value;
  35296. this.color=this._color;
  35297. });
  35298. /**
  35299. *@private
  35300. */
  35301. /**
  35302. *@private
  35303. */
  35304. __getset(0,__proto,'_MainTex_STZ',function(){
  35305. return this._shaderValues.getVector(ShurikenParticleMaterial.TILINGOFFSET).z;
  35306. },function(z){
  35307. var tilOff=this._shaderValues.getVector(ShurikenParticleMaterial.TILINGOFFSET);
  35308. tilOff.z=z;
  35309. this.tilingOffset=tilOff;
  35310. });
  35311. /**
  35312. *设置漫反射贴图。
  35313. *@param value 漫反射贴图。
  35314. */
  35315. /**
  35316. *获取漫反射贴图。
  35317. *@return 漫反射贴图。
  35318. */
  35319. __getset(0,__proto,'texture',function(){
  35320. return this._shaderValues.getTexture(ShurikenParticleMaterial.DIFFUSETEXTURE);
  35321. },function(value){
  35322. if (value)
  35323. this._defineDatas.add(laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SHADERDEFINE_DIFFUSEMAP);
  35324. else
  35325. this._defineDatas.remove(laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SHADERDEFINE_DIFFUSEMAP);
  35326. this._shaderValues.setTexture(ShurikenParticleMaterial.DIFFUSETEXTURE,value);
  35327. });
  35328. /**
  35329. *@private
  35330. */
  35331. /**
  35332. *@private
  35333. */
  35334. __getset(0,__proto,'_TintColorR',function(){
  35335. return this._color.x;
  35336. },function(value){
  35337. this._color.x=value;
  35338. this.color=this._color;
  35339. });
  35340. /**
  35341. *@private
  35342. */
  35343. /**
  35344. *@private
  35345. */
  35346. __getset(0,__proto,'_MainTex_STW',function(){
  35347. return this._shaderValues.getVector(ShurikenParticleMaterial.TILINGOFFSET).w;
  35348. },function(w){
  35349. var tilOff=this._shaderValues.getVector(ShurikenParticleMaterial.TILINGOFFSET);
  35350. tilOff.w=w;
  35351. this.tilingOffset=tilOff;
  35352. });
  35353. /**
  35354. *@private
  35355. */
  35356. /**
  35357. *@private
  35358. */
  35359. __getset(0,__proto,'_TintColorG',function(){
  35360. return this._color.y;
  35361. },function(value){
  35362. this._color.y=value;
  35363. this.color=this._color;
  35364. });
  35365. /**
  35366. *@private
  35367. */
  35368. /**@private */
  35369. __getset(0,__proto,'_TintColorA',function(){
  35370. return this._color.w;
  35371. },function(value){
  35372. this._color.w=value;
  35373. this.color=this._color;
  35374. });
  35375. /**
  35376. *@private
  35377. */
  35378. /**
  35379. *@private
  35380. */
  35381. __getset(0,__proto,'_MainTex_STY',function(){
  35382. return this._shaderValues.getVector(ShurikenParticleMaterial.TILINGOFFSET).y;
  35383. },function(y){
  35384. var tilOff=this._shaderValues.getVector(ShurikenParticleMaterial.TILINGOFFSET);
  35385. tilOff.y=y;
  35386. this.tilingOffset=tilOff;
  35387. });
  35388. /**
  35389. *设置渲染模式。
  35390. *@return 渲染模式。
  35391. */
  35392. __getset(0,__proto,'renderMode',null,function(value){
  35393. switch (value){
  35394. case 1:
  35395. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_TRANSPARENT*/3000;
  35396. this.depthWrite=false;
  35397. this.cull=/*laya.d3.core.material.RenderState.CULL_NONE*/0;
  35398. this.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  35399. this.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_SRC_ALPHA*/0x0302;
  35400. this.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE*/1;
  35401. this.alphaTest=false;
  35402. this._defineDatas.add(ShurikenParticleMaterial.SHADERDEFINE_ADDTIVEFOG);
  35403. break ;
  35404. case 0:
  35405. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_TRANSPARENT*/3000;
  35406. this.depthWrite=false;
  35407. this.cull=/*laya.d3.core.material.RenderState.CULL_NONE*/0;
  35408. this.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  35409. this.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_SRC_ALPHA*/0x0302;
  35410. this.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA*/0x0303;
  35411. this.alphaTest=false;
  35412. this._defineDatas.remove(ShurikenParticleMaterial.SHADERDEFINE_ADDTIVEFOG);
  35413. break ;
  35414. default :
  35415. throw new Error("ShurikenParticleMaterial : renderMode value error.");
  35416. }
  35417. });
  35418. /**
  35419. *@private
  35420. */
  35421. /**
  35422. *@private
  35423. */
  35424. __getset(0,__proto,'_MainTex_STX',function(){
  35425. return this._shaderValues.getVector(ShurikenParticleMaterial.TILINGOFFSET).x;
  35426. },function(x){
  35427. var tilOff=this._shaderValues.getVector(ShurikenParticleMaterial.TILINGOFFSET);
  35428. tilOff.x=x;
  35429. this.tilingOffset=tilOff;
  35430. });
  35431. /**
  35432. *设置颜色R分量。
  35433. *@param value 颜色R分量。
  35434. */
  35435. /**
  35436. *获取颜色R分量。
  35437. *@return 颜色R分量。
  35438. */
  35439. __getset(0,__proto,'colorR',function(){
  35440. return this._TintColorR;
  35441. },function(value){
  35442. this._TintColorR=value;
  35443. });
  35444. /**
  35445. *设置颜色G分量。
  35446. *@param value 颜色G分量。
  35447. */
  35448. /**
  35449. *获取颜色G分量。
  35450. *@return 颜色G分量。
  35451. */
  35452. __getset(0,__proto,'colorG',function(){
  35453. return this._TintColorG;
  35454. },function(value){
  35455. this._TintColorG=value;
  35456. });
  35457. /**
  35458. *设置颜色B分量。
  35459. *@param value 颜色B分量。
  35460. */
  35461. /**
  35462. *获取颜色B分量。
  35463. *@return 颜色B分量。
  35464. */
  35465. __getset(0,__proto,'colorB',function(){
  35466. return this._TintColorB;
  35467. },function(value){
  35468. this._TintColorB=value;
  35469. });
  35470. /**
  35471. *设置颜色alpha分量。
  35472. *@param value 颜色alpha分量。
  35473. */
  35474. /**
  35475. *获取颜色Z分量。
  35476. *@return 颜色Z分量。
  35477. */
  35478. __getset(0,__proto,'colorA',function(){
  35479. return this._TintColorA;
  35480. },function(value){
  35481. this._TintColorA=value;
  35482. });
  35483. /**
  35484. *设置混合方式。
  35485. *@param value 混合方式。
  35486. */
  35487. /**
  35488. *获取混合方式。
  35489. *@return 混合方式。
  35490. */
  35491. __getset(0,__proto,'blend',function(){
  35492. return this._shaderValues.getInt(ShurikenParticleMaterial.BLEND);
  35493. },function(value){
  35494. this._shaderValues.setInt(ShurikenParticleMaterial.BLEND,value);
  35495. });
  35496. /**
  35497. *设置颜色。
  35498. *@param value 颜色。
  35499. */
  35500. /**
  35501. *获取颜色。
  35502. *@return 颜色。
  35503. */
  35504. __getset(0,__proto,'color',function(){
  35505. return this._shaderValues.getVector(ShurikenParticleMaterial.TINTCOLOR);
  35506. },function(value){
  35507. if (value)
  35508. this._defineDatas.add(laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SHADERDEFINE_TINTCOLOR);
  35509. else
  35510. this._defineDatas.remove(laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SHADERDEFINE_TINTCOLOR);
  35511. this._shaderValues.setVector(ShurikenParticleMaterial.TINTCOLOR,value);
  35512. });
  35513. /**
  35514. *获取纹理平铺和偏移X分量。
  35515. *@param x 纹理平铺和偏移X分量。
  35516. */
  35517. /**
  35518. *获取纹理平铺和偏移X分量。
  35519. *@return 纹理平铺和偏移X分量。
  35520. */
  35521. __getset(0,__proto,'tilingOffsetX',function(){
  35522. return this._MainTex_STX;
  35523. },function(x){
  35524. this._MainTex_STX=x;
  35525. });
  35526. /**
  35527. *获取纹理平铺和偏移Y分量。
  35528. *@param y 纹理平铺和偏移Y分量。
  35529. */
  35530. /**
  35531. *获取纹理平铺和偏移Y分量。
  35532. *@return 纹理平铺和偏移Y分量。
  35533. */
  35534. __getset(0,__proto,'tilingOffsetY',function(){
  35535. return this._MainTex_STY;
  35536. },function(y){
  35537. this._MainTex_STY=y;
  35538. });
  35539. /**
  35540. *获取纹理平铺和偏移Z分量。
  35541. *@param z 纹理平铺和偏移Z分量。
  35542. */
  35543. /**
  35544. *获取纹理平铺和偏移Z分量。
  35545. *@return 纹理平铺和偏移Z分量。
  35546. */
  35547. __getset(0,__proto,'tilingOffsetZ',function(){
  35548. return this._MainTex_STZ;
  35549. },function(z){
  35550. this._MainTex_STZ=z;
  35551. });
  35552. /**
  35553. *设置混合源。
  35554. *@param value 混合源
  35555. */
  35556. /**
  35557. *获取混合源。
  35558. *@return 混合源。
  35559. */
  35560. __getset(0,__proto,'blendSrc',function(){
  35561. return this._shaderValues.getInt(ShurikenParticleMaterial.BLEND_SRC);
  35562. },function(value){
  35563. this._shaderValues.setInt(ShurikenParticleMaterial.BLEND_SRC,value);
  35564. });
  35565. /**
  35566. *获取纹理平铺和偏移W分量。
  35567. *@param w 纹理平铺和偏移W分量。
  35568. */
  35569. /**
  35570. *获取纹理平铺和偏移W分量。
  35571. *@return 纹理平铺和偏移W分量。
  35572. */
  35573. __getset(0,__proto,'tilingOffsetW',function(){
  35574. return this._MainTex_STW;
  35575. },function(w){
  35576. this._MainTex_STW=w;
  35577. });
  35578. /**
  35579. *获取纹理平铺和偏移。
  35580. *@param value 纹理平铺和偏移。
  35581. */
  35582. /**
  35583. *获取纹理平铺和偏移。
  35584. *@return 纹理平铺和偏移。
  35585. */
  35586. __getset(0,__proto,'tilingOffset',function(){
  35587. return this._shaderValues.getVector(ShurikenParticleMaterial.TILINGOFFSET);
  35588. },function(value){
  35589. if (value){
  35590. if (value.x !=1 || value.y !=1 || value.z !=0 || value.w !=0)
  35591. this._defineDatas.add(laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SHADERDEFINE_TILINGOFFSET);
  35592. else
  35593. this._defineDatas.remove(laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SHADERDEFINE_TILINGOFFSET);
  35594. }else {
  35595. this._defineDatas.remove(laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SHADERDEFINE_TILINGOFFSET);
  35596. }
  35597. this._shaderValues.setVector(ShurikenParticleMaterial.TILINGOFFSET,value);
  35598. });
  35599. /**
  35600. *设置是否写入深度。
  35601. *@param value 是否写入深度。
  35602. */
  35603. /**
  35604. *获取是否写入深度。
  35605. *@return 是否写入深度。
  35606. */
  35607. __getset(0,__proto,'depthWrite',function(){
  35608. return this._shaderValues.getBool(ShurikenParticleMaterial.DEPTH_WRITE);
  35609. },function(value){
  35610. this._shaderValues.setBool(ShurikenParticleMaterial.DEPTH_WRITE,value);
  35611. });
  35612. /**
  35613. *设置剔除方式。
  35614. *@param value 剔除方式。
  35615. */
  35616. /**
  35617. *获取剔除方式。
  35618. *@return 剔除方式。
  35619. */
  35620. __getset(0,__proto,'cull',function(){
  35621. return this._shaderValues.getInt(ShurikenParticleMaterial.CULL);
  35622. },function(value){
  35623. this._shaderValues.setInt(ShurikenParticleMaterial.CULL,value);
  35624. });
  35625. /**
  35626. *设置混合目标。
  35627. *@param value 混合目标
  35628. */
  35629. /**
  35630. *获取混合目标。
  35631. *@return 混合目标。
  35632. */
  35633. __getset(0,__proto,'blendDst',function(){
  35634. return this._shaderValues.getInt(ShurikenParticleMaterial.BLEND_DST);
  35635. },function(value){
  35636. this._shaderValues.setInt(ShurikenParticleMaterial.BLEND_DST,value);
  35637. });
  35638. /**
  35639. *设置深度测试方式。
  35640. *@param value 深度测试方式
  35641. */
  35642. /**
  35643. *获取深度测试方式。
  35644. *@return 深度测试方式。
  35645. */
  35646. __getset(0,__proto,'depthTest',function(){
  35647. return this._shaderValues.getInt(ShurikenParticleMaterial.DEPTH_TEST);
  35648. },function(value){
  35649. this._shaderValues.setInt(ShurikenParticleMaterial.DEPTH_TEST,value);
  35650. });
  35651. ShurikenParticleMaterial.__init__=function(){
  35652. ShurikenParticleMaterial.SHADERDEFINE_DIFFUSEMAP=ShurikenParticleMaterial.shaderDefines.registerDefine("DIFFUSEMAP");
  35653. ShurikenParticleMaterial.SHADERDEFINE_TINTCOLOR=ShurikenParticleMaterial.shaderDefines.registerDefine("TINTCOLOR");
  35654. ShurikenParticleMaterial.SHADERDEFINE_ADDTIVEFOG=ShurikenParticleMaterial.shaderDefines.registerDefine("ADDTIVEFOG");
  35655. ShurikenParticleMaterial.SHADERDEFINE_TILINGOFFSET=ShurikenParticleMaterial.shaderDefines.registerDefine("TILINGOFFSET");
  35656. }
  35657. ShurikenParticleMaterial.RENDERMODE_ALPHABLENDED=0;
  35658. ShurikenParticleMaterial.RENDERMODE_ADDTIVE=1;
  35659. ShurikenParticleMaterial.SHADERDEFINE_DIFFUSEMAP=0;
  35660. ShurikenParticleMaterial.SHADERDEFINE_TINTCOLOR=0;
  35661. ShurikenParticleMaterial.SHADERDEFINE_TILINGOFFSET=0;
  35662. ShurikenParticleMaterial.SHADERDEFINE_ADDTIVEFOG=0;
  35663. __static(ShurikenParticleMaterial,
  35664. ['DIFFUSETEXTURE',function(){return this.DIFFUSETEXTURE=Shader3D.propertyNameToID("u_texture");},'TINTCOLOR',function(){return this.TINTCOLOR=Shader3D.propertyNameToID("u_Tintcolor");},'TILINGOFFSET',function(){return this.TILINGOFFSET=Shader3D.propertyNameToID("u_TilingOffset");},'CULL',function(){return this.CULL=Shader3D.propertyNameToID("s_Cull");},'BLEND',function(){return this.BLEND=Shader3D.propertyNameToID("s_Blend");},'BLEND_SRC',function(){return this.BLEND_SRC=Shader3D.propertyNameToID("s_BlendSrc");},'BLEND_DST',function(){return this.BLEND_DST=Shader3D.propertyNameToID("s_BlendDst");},'DEPTH_TEST',function(){return this.DEPTH_TEST=Shader3D.propertyNameToID("s_DepthTest");},'DEPTH_WRITE',function(){return this.DEPTH_WRITE=Shader3D.propertyNameToID("s_DepthWrite");},'defaultMaterial',function(){return this.defaultMaterial=new ShurikenParticleMaterial();},'shaderDefines',function(){return this.shaderDefines=new ShaderDefines(BaseMaterial.shaderDefines);}
  35665. ]);
  35666. return ShurikenParticleMaterial;
  35667. })(BaseMaterial)
  35668. /**
  35669. *<code>EffectMaterial</code> 类用于实现Mesh特效材质。
  35670. */
  35671. //class laya.d3.core.material.EffectMaterial extends laya.d3.core.material.BaseMaterial
  35672. var EffectMaterial=(function(_super){
  35673. function EffectMaterial(){
  35674. /**@private */
  35675. this._color=null;
  35676. EffectMaterial.__super.call(this);
  35677. this.setShaderName("Effect");
  35678. this._color=new Vector4(1.0,1.0,1.0,1.0);
  35679. this._shaderValues.setVector(EffectMaterial.TINTCOLOR,new Vector4(1.0,1.0,1.0,1.0));
  35680. this.renderMode=0;
  35681. }
  35682. __class(EffectMaterial,'laya.d3.core.material.EffectMaterial',_super);
  35683. var __proto=EffectMaterial.prototype;
  35684. /**
  35685. *@private
  35686. */
  35687. /**
  35688. *@private
  35689. */
  35690. __getset(0,__proto,'_TintColorB',function(){
  35691. return this._color.z;
  35692. },function(value){
  35693. this._color.z=value;
  35694. this.color=this._color;
  35695. });
  35696. /**
  35697. *@private
  35698. */
  35699. /**
  35700. *@private
  35701. */
  35702. __getset(0,__proto,'_MainTex_STZ',function(){
  35703. return this._shaderValues.getVector(EffectMaterial.TILINGOFFSET).z;
  35704. },function(z){
  35705. var tilOff=this._shaderValues.getVector(EffectMaterial.TILINGOFFSET);
  35706. tilOff.z=z;
  35707. this.tilingOffset=tilOff;
  35708. });
  35709. /**
  35710. *设置贴图。
  35711. *@param value 贴图。
  35712. */
  35713. /**
  35714. *获取贴图。
  35715. *@return 贴图。
  35716. */
  35717. __getset(0,__proto,'texture',function(){
  35718. return this._shaderValues.getTexture(EffectMaterial.MAINTEXTURE);
  35719. },function(value){
  35720. if (value)
  35721. this._defineDatas.add(laya.d3.core.material.EffectMaterial.SHADERDEFINE_MAINTEXTURE);
  35722. else
  35723. this._defineDatas.remove(laya.d3.core.material.EffectMaterial.SHADERDEFINE_MAINTEXTURE);
  35724. this._shaderValues.setTexture(EffectMaterial.MAINTEXTURE,value);
  35725. });
  35726. /**
  35727. *@private
  35728. */
  35729. /**
  35730. *@private
  35731. */
  35732. __getset(0,__proto,'_TintColorR',function(){
  35733. return this._color.x;
  35734. },function(value){
  35735. this._color.x=value;
  35736. this.color=this._color;
  35737. });
  35738. /**
  35739. *@private
  35740. */
  35741. /**
  35742. *@private
  35743. */
  35744. __getset(0,__proto,'_MainTex_STW',function(){
  35745. return this._shaderValues.getVector(EffectMaterial.TILINGOFFSET).w;
  35746. },function(w){
  35747. var tilOff=this._shaderValues.getVector(EffectMaterial.TILINGOFFSET);
  35748. tilOff.w=w;
  35749. this.tilingOffset=tilOff;
  35750. });
  35751. /**
  35752. *@private
  35753. */
  35754. /**
  35755. *@private
  35756. */
  35757. __getset(0,__proto,'_TintColorG',function(){
  35758. return this._color.y;
  35759. },function(value){
  35760. this._color.y=value;
  35761. this.color=this._color;
  35762. });
  35763. /**
  35764. *@private
  35765. */
  35766. /**@private */
  35767. __getset(0,__proto,'_TintColorA',function(){
  35768. return this._color.w;
  35769. },function(value){
  35770. this._color.w=value;
  35771. this.color=this._color;
  35772. });
  35773. /**
  35774. *@private
  35775. */
  35776. /**
  35777. *@private
  35778. */
  35779. __getset(0,__proto,'_MainTex_STY',function(){
  35780. return this._shaderValues.getVector(EffectMaterial.TILINGOFFSET).y;
  35781. },function(y){
  35782. var tilOff=this._shaderValues.getVector(EffectMaterial.TILINGOFFSET);
  35783. tilOff.y=y;
  35784. this.tilingOffset=tilOff;
  35785. });
  35786. /**
  35787. *设置渲染模式。
  35788. *@return 渲染模式。
  35789. */
  35790. __getset(0,__proto,'renderMode',null,function(value){
  35791. switch (value){
  35792. case 0:
  35793. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_TRANSPARENT*/3000;
  35794. this.alphaTest=false;
  35795. this.depthWrite=false;
  35796. this.cull=/*laya.d3.core.material.RenderState.CULL_NONE*/0;
  35797. this.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  35798. this.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_SRC_ALPHA*/0x0302;
  35799. this.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE*/1;
  35800. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  35801. this._defineDatas.add(EffectMaterial.SHADERDEFINE_ADDTIVEFOG);
  35802. break ;
  35803. case 1:
  35804. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_TRANSPARENT*/3000;
  35805. this.alphaTest=false;
  35806. this.depthWrite=false;
  35807. this.cull=/*laya.d3.core.material.RenderState.CULL_NONE*/0;
  35808. this.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  35809. this.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_SRC_ALPHA*/0x0302;
  35810. this.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA*/0x0303;
  35811. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  35812. this._defineDatas.remove(EffectMaterial.SHADERDEFINE_ADDTIVEFOG);
  35813. break ;
  35814. default :
  35815. throw new Error("MeshEffectMaterial : renderMode value error.");
  35816. }
  35817. });
  35818. /**
  35819. *@private
  35820. */
  35821. /**
  35822. *@private
  35823. */
  35824. __getset(0,__proto,'_MainTex_STX',function(){
  35825. return this._shaderValues.getVector(EffectMaterial.TILINGOFFSET).x;
  35826. },function(x){
  35827. var tilOff=this._shaderValues.getVector(EffectMaterial.TILINGOFFSET);
  35828. tilOff.x=x;
  35829. this.tilingOffset=tilOff;
  35830. });
  35831. /**
  35832. *设置颜色R分量。
  35833. *@param value 颜色R分量。
  35834. */
  35835. /**
  35836. *获取颜色R分量。
  35837. *@return 颜色R分量。
  35838. */
  35839. __getset(0,__proto,'colorR',function(){
  35840. return this._TintColorR;
  35841. },function(value){
  35842. this._TintColorR=value;
  35843. });
  35844. /**
  35845. *设置颜色G分量。
  35846. *@param value 颜色G分量。
  35847. */
  35848. /**
  35849. *获取颜色G分量。
  35850. *@return 颜色G分量。
  35851. */
  35852. __getset(0,__proto,'colorG',function(){
  35853. return this._TintColorG;
  35854. },function(value){
  35855. this._TintColorG=value;
  35856. });
  35857. /**
  35858. *设置颜色B分量。
  35859. *@param value 颜色B分量。
  35860. */
  35861. /**
  35862. *获取颜色B分量。
  35863. *@return 颜色B分量。
  35864. */
  35865. __getset(0,__proto,'colorB',function(){
  35866. return this._TintColorB;
  35867. },function(value){
  35868. this._TintColorB=value;
  35869. });
  35870. /**
  35871. *设置颜色alpha分量。
  35872. *@param value 颜色alpha分量。
  35873. */
  35874. /**
  35875. *获取颜色Z分量。
  35876. *@return 颜色Z分量。
  35877. */
  35878. __getset(0,__proto,'colorA',function(){
  35879. return this._TintColorA;
  35880. },function(value){
  35881. this._TintColorA=value;
  35882. });
  35883. /**
  35884. *设置混合方式。
  35885. *@param value 混合方式。
  35886. */
  35887. /**
  35888. *获取混合方式。
  35889. *@return 混合方式。
  35890. */
  35891. __getset(0,__proto,'blend',function(){
  35892. return this._shaderValues.getInt(EffectMaterial.BLEND);
  35893. },function(value){
  35894. this._shaderValues.setInt(EffectMaterial.BLEND,value);
  35895. });
  35896. /**
  35897. *设置颜色。
  35898. *@param value 颜色。
  35899. */
  35900. /**
  35901. *获取颜色。
  35902. *@return 颜色。
  35903. */
  35904. __getset(0,__proto,'color',function(){
  35905. return this._shaderValues.getVector(EffectMaterial.TINTCOLOR);
  35906. },function(value){
  35907. this._shaderValues.setVector(EffectMaterial.TINTCOLOR,value);
  35908. });
  35909. /**
  35910. *获取纹理平铺和偏移X分量。
  35911. *@param x 纹理平铺和偏移X分量。
  35912. */
  35913. /**
  35914. *获取纹理平铺和偏移X分量。
  35915. *@return 纹理平铺和偏移X分量。
  35916. */
  35917. __getset(0,__proto,'tilingOffsetX',function(){
  35918. return this._MainTex_STX;
  35919. },function(x){
  35920. this._MainTex_STX=x;
  35921. });
  35922. /**
  35923. *获取纹理平铺和偏移Y分量。
  35924. *@param y 纹理平铺和偏移Y分量。
  35925. */
  35926. /**
  35927. *获取纹理平铺和偏移Y分量。
  35928. *@return 纹理平铺和偏移Y分量。
  35929. */
  35930. __getset(0,__proto,'tilingOffsetY',function(){
  35931. return this._MainTex_STY;
  35932. },function(y){
  35933. this._MainTex_STY=y;
  35934. });
  35935. /**
  35936. *获取纹理平铺和偏移Z分量。
  35937. *@param z 纹理平铺和偏移Z分量。
  35938. */
  35939. /**
  35940. *获取纹理平铺和偏移Z分量。
  35941. *@return 纹理平铺和偏移Z分量。
  35942. */
  35943. __getset(0,__proto,'tilingOffsetZ',function(){
  35944. return this._MainTex_STZ;
  35945. },function(z){
  35946. this._MainTex_STZ=z;
  35947. });
  35948. /**
  35949. *设置混合源。
  35950. *@param value 混合源
  35951. */
  35952. /**
  35953. *获取混合源。
  35954. *@return 混合源。
  35955. */
  35956. __getset(0,__proto,'blendSrc',function(){
  35957. return this._shaderValues.getInt(EffectMaterial.BLEND_SRC);
  35958. },function(value){
  35959. this._shaderValues.setInt(EffectMaterial.BLEND_SRC,value);
  35960. });
  35961. /**
  35962. *获取纹理平铺和偏移W分量。
  35963. *@param w 纹理平铺和偏移W分量。
  35964. */
  35965. /**
  35966. *获取纹理平铺和偏移W分量。
  35967. *@return 纹理平铺和偏移W分量。
  35968. */
  35969. __getset(0,__proto,'tilingOffsetW',function(){
  35970. return this._MainTex_STW;
  35971. },function(w){
  35972. this._MainTex_STW=w;
  35973. });
  35974. /**
  35975. *设置纹理平铺和偏移。
  35976. *@param value 纹理平铺和偏移。
  35977. */
  35978. /**
  35979. *获取纹理平铺和偏移。
  35980. *@return 纹理平铺和偏移。
  35981. */
  35982. __getset(0,__proto,'tilingOffset',function(){
  35983. return this._shaderValues.getVector(EffectMaterial.TILINGOFFSET);
  35984. },function(value){
  35985. if (value){
  35986. if (value.x !=1 || value.y !=1 || value.z !=0 || value.w !=0)
  35987. this._defineDatas.add(laya.d3.core.material.EffectMaterial.SHADERDEFINE_TILINGOFFSET);
  35988. else
  35989. this._defineDatas.remove(laya.d3.core.material.EffectMaterial.SHADERDEFINE_TILINGOFFSET);
  35990. }else {
  35991. this._defineDatas.remove(laya.d3.core.material.EffectMaterial.SHADERDEFINE_TILINGOFFSET);
  35992. }
  35993. this._shaderValues.setVector(EffectMaterial.TILINGOFFSET,value);
  35994. });
  35995. /**
  35996. *设置是否写入深度。
  35997. *@param value 是否写入深度。
  35998. */
  35999. /**
  36000. *获取是否写入深度。
  36001. *@return 是否写入深度。
  36002. */
  36003. __getset(0,__proto,'depthWrite',function(){
  36004. return this._shaderValues.getBool(EffectMaterial.DEPTH_WRITE);
  36005. },function(value){
  36006. this._shaderValues.setBool(EffectMaterial.DEPTH_WRITE,value);
  36007. });
  36008. /**
  36009. *设置剔除方式。
  36010. *@param value 剔除方式。
  36011. */
  36012. /**
  36013. *获取剔除方式。
  36014. *@return 剔除方式。
  36015. */
  36016. __getset(0,__proto,'cull',function(){
  36017. return this._shaderValues.getInt(EffectMaterial.CULL);
  36018. },function(value){
  36019. this._shaderValues.setInt(EffectMaterial.CULL,value);
  36020. });
  36021. /**
  36022. *设置混合目标。
  36023. *@param value 混合目标
  36024. */
  36025. /**
  36026. *获取混合目标。
  36027. *@return 混合目标。
  36028. */
  36029. __getset(0,__proto,'blendDst',function(){
  36030. return this._shaderValues.getInt(EffectMaterial.BLEND_DST);
  36031. },function(value){
  36032. this._shaderValues.setInt(EffectMaterial.BLEND_DST,value);
  36033. });
  36034. /**
  36035. *设置深度测试方式。
  36036. *@param value 深度测试方式
  36037. */
  36038. /**
  36039. *获取深度测试方式。
  36040. *@return 深度测试方式。
  36041. */
  36042. __getset(0,__proto,'depthTest',function(){
  36043. return this._shaderValues.getInt(EffectMaterial.DEPTH_TEST);
  36044. },function(value){
  36045. this._shaderValues.setInt(EffectMaterial.DEPTH_TEST,value);
  36046. });
  36047. EffectMaterial.__init__=function(){
  36048. EffectMaterial.SHADERDEFINE_MAINTEXTURE=EffectMaterial.shaderDefines.registerDefine("MAINTEXTURE");
  36049. EffectMaterial.SHADERDEFINE_TILINGOFFSET=EffectMaterial.shaderDefines.registerDefine("TILINGOFFSET");
  36050. EffectMaterial.SHADERDEFINE_ADDTIVEFOG=EffectMaterial.shaderDefines.registerDefine("ADDTIVEFOG");
  36051. }
  36052. EffectMaterial.RENDERMODE_ADDTIVE=0;
  36053. EffectMaterial.RENDERMODE_ALPHABLENDED=1;
  36054. EffectMaterial.SHADERDEFINE_MAINTEXTURE=0;
  36055. EffectMaterial.SHADERDEFINE_TILINGOFFSET=0;
  36056. EffectMaterial.SHADERDEFINE_ADDTIVEFOG=0;
  36057. __static(EffectMaterial,
  36058. ['defaultMaterial',function(){return this.defaultMaterial=new EffectMaterial();},'MAINTEXTURE',function(){return this.MAINTEXTURE=Shader3D.propertyNameToID("u_AlbedoTexture");},'TINTCOLOR',function(){return this.TINTCOLOR=Shader3D.propertyNameToID("u_AlbedoColor");},'TILINGOFFSET',function(){return this.TILINGOFFSET=Shader3D.propertyNameToID("u_TilingOffset");},'CULL',function(){return this.CULL=Shader3D.propertyNameToID("s_Cull");},'BLEND',function(){return this.BLEND=Shader3D.propertyNameToID("s_Blend");},'BLEND_SRC',function(){return this.BLEND_SRC=Shader3D.propertyNameToID("s_BlendSrc");},'BLEND_DST',function(){return this.BLEND_DST=Shader3D.propertyNameToID("s_BlendDst");},'DEPTH_TEST',function(){return this.DEPTH_TEST=Shader3D.propertyNameToID("s_DepthTest");},'DEPTH_WRITE',function(){return this.DEPTH_WRITE=Shader3D.propertyNameToID("s_DepthWrite");},'shaderDefines',function(){return this.shaderDefines=new ShaderDefines(BaseMaterial.shaderDefines);}
  36059. ]);
  36060. return EffectMaterial;
  36061. })(BaseMaterial)
  36062. /**
  36063. *...
  36064. *@author
  36065. */
  36066. //class laya.d3.core.material.WaterPrimaryMaterial extends laya.d3.core.material.BaseMaterial
  36067. var WaterPrimaryMaterial=(function(_super){
  36068. function WaterPrimaryMaterial(){
  36069. WaterPrimaryMaterial.__super.call(this);
  36070. this.setShaderName("WaterPrimary");
  36071. this._shaderValues.setVector(WaterPrimaryMaterial.HORIZONCOLOR,new Vector4(0.172 ,0.463 ,0.435 ,0));
  36072. this._shaderValues.setNumber(WaterPrimaryMaterial.WAVESCALE,0.15);
  36073. this._shaderValues.setVector(WaterPrimaryMaterial.WAVESPEED,new Vector4(19,9,-16,-7));
  36074. }
  36075. __class(WaterPrimaryMaterial,'laya.d3.core.material.WaterPrimaryMaterial',_super);
  36076. var __proto=WaterPrimaryMaterial.prototype;
  36077. /**
  36078. *设置波动速率。
  36079. *@param value 波动速率。
  36080. */
  36081. /**
  36082. *获取波动速率。
  36083. *@return 波动速率。
  36084. */
  36085. __getset(0,__proto,'waveSpeed',function(){
  36086. return this._shaderValues.getVector(WaterPrimaryMaterial.WAVESPEED);
  36087. },function(value){
  36088. this._shaderValues.setVector(WaterPrimaryMaterial.WAVESPEED,value);
  36089. });
  36090. /**
  36091. *设置地平线颜色。
  36092. *@param value 地平线颜色。
  36093. */
  36094. /**
  36095. *获取地平线颜色。
  36096. *@return 地平线颜色。
  36097. */
  36098. __getset(0,__proto,'horizonColor',function(){
  36099. return this._shaderValues.getVector(WaterPrimaryMaterial.HORIZONCOLOR);
  36100. },function(value){
  36101. this._shaderValues.setVector(WaterPrimaryMaterial.HORIZONCOLOR,value);
  36102. });
  36103. /**
  36104. *设置主贴图。
  36105. *@param value 主贴图。
  36106. */
  36107. /**
  36108. *获取主贴图。
  36109. *@return 主贴图。
  36110. */
  36111. __getset(0,__proto,'mainTexture',function(){
  36112. return this._shaderValues.getTexture(WaterPrimaryMaterial.MAINTEXTURE);
  36113. },function(value){
  36114. if (value)
  36115. this._defineDatas.add(laya.d3.core.material.WaterPrimaryMaterial.SHADERDEFINE_MAINTEXTURE);
  36116. else
  36117. this._defineDatas.remove(laya.d3.core.material.WaterPrimaryMaterial.SHADERDEFINE_MAINTEXTURE);
  36118. this._shaderValues.setTexture(WaterPrimaryMaterial.MAINTEXTURE,value);
  36119. });
  36120. /**
  36121. *设置法线贴图。
  36122. *@param value 法线贴图。
  36123. */
  36124. /**
  36125. *获取法线贴图。
  36126. *@return 法线贴图。
  36127. */
  36128. __getset(0,__proto,'normalTexture',function(){
  36129. return this._shaderValues.getTexture(WaterPrimaryMaterial.NORMALTEXTURE);
  36130. },function(value){
  36131. if (value)
  36132. this._defineDatas.add(laya.d3.core.material.WaterPrimaryMaterial.SHADERDEFINE_NORMALTEXTURE);
  36133. else
  36134. this._defineDatas.remove(laya.d3.core.material.WaterPrimaryMaterial.SHADERDEFINE_NORMALTEXTURE);
  36135. this._shaderValues.setTexture(WaterPrimaryMaterial.NORMALTEXTURE,value);
  36136. });
  36137. /**
  36138. *设置波动缩放系数。
  36139. *@param value 波动缩放系数。
  36140. */
  36141. /**
  36142. *获取波动缩放系数。
  36143. *@return 波动缩放系数。
  36144. */
  36145. __getset(0,__proto,'waveScale',function(){
  36146. return this._shaderValues.getNumber(WaterPrimaryMaterial.WAVESCALE);
  36147. },function(value){
  36148. this._shaderValues.setNumber(WaterPrimaryMaterial.WAVESCALE,value);
  36149. });
  36150. WaterPrimaryMaterial.__init__=function(){
  36151. WaterPrimaryMaterial.SHADERDEFINE_MAINTEXTURE=WaterPrimaryMaterial.shaderDefines.registerDefine("MAINTEXTURE");
  36152. WaterPrimaryMaterial.SHADERDEFINE_NORMALTEXTURE=WaterPrimaryMaterial.shaderDefines.registerDefine("NORMALTEXTURE");
  36153. }
  36154. WaterPrimaryMaterial.SHADERDEFINE_MAINTEXTURE=0;
  36155. WaterPrimaryMaterial.SHADERDEFINE_NORMALTEXTURE=0;
  36156. __static(WaterPrimaryMaterial,
  36157. ['HORIZONCOLOR',function(){return this.HORIZONCOLOR=Shader3D.propertyNameToID("u_HorizonColor");},'MAINTEXTURE',function(){return this.MAINTEXTURE=Shader3D.propertyNameToID("u_MainTexture");},'NORMALTEXTURE',function(){return this.NORMALTEXTURE=Shader3D.propertyNameToID("u_NormalTexture");},'WAVESCALE',function(){return this.WAVESCALE=Shader3D.propertyNameToID("u_WaveScale");},'WAVESPEED',function(){return this.WAVESPEED=Shader3D.propertyNameToID("u_WaveSpeed");},'defaultMaterial',function(){return this.defaultMaterial=new WaterPrimaryMaterial();},'shaderDefines',function(){return this.shaderDefines=new ShaderDefines(BaseMaterial.shaderDefines);}
  36158. ]);
  36159. return WaterPrimaryMaterial;
  36160. })(BaseMaterial)
  36161. /**
  36162. *...
  36163. *@author ...
  36164. */
  36165. //class laya.d3.core.material.ExtendTerrainMaterial extends laya.d3.core.material.BaseMaterial
  36166. var ExtendTerrainMaterial=(function(_super){
  36167. function ExtendTerrainMaterial(){
  36168. /**@private */
  36169. this._enableLighting=true;
  36170. ExtendTerrainMaterial.__super.call(this);
  36171. this.setShaderName("ExtendTerrain");
  36172. this.renderMode=1;
  36173. }
  36174. __class(ExtendTerrainMaterial,'laya.d3.core.material.ExtendTerrainMaterial',_super);
  36175. var __proto=ExtendTerrainMaterial.prototype;
  36176. __proto._setDetailNum=function(value){
  36177. switch (value){
  36178. case 1:
  36179. this._defineDatas.add(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM1);
  36180. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM2);
  36181. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM3);
  36182. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM4);
  36183. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM5);
  36184. break ;
  36185. case 2:
  36186. this._defineDatas.add(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM2);
  36187. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM1);
  36188. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM3);
  36189. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM4);
  36190. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM5);
  36191. break ;
  36192. case 3:
  36193. this._defineDatas.add(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM3);
  36194. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM1);
  36195. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM2);
  36196. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM4);
  36197. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM5);
  36198. break ;
  36199. case 4:
  36200. this._defineDatas.add(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM4);
  36201. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM1);
  36202. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM2);
  36203. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM3);
  36204. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM5);
  36205. break ;
  36206. case 5:
  36207. this._defineDatas.add(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM5);
  36208. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM1);
  36209. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM2);
  36210. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM3);
  36211. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM4);
  36212. break ;
  36213. }
  36214. }
  36215. __getset(0,__proto,'diffuseScaleOffset2',null,function(scaleOffset2){
  36216. this._shaderValues.setVector(ExtendTerrainMaterial.DIFFUSESCALEOFFSET2,scaleOffset2);
  36217. });
  36218. /**
  36219. *设置splatAlpha贴图。
  36220. *@param value splatAlpha贴图。
  36221. */
  36222. /**
  36223. *获取splatAlpha贴图。
  36224. *@return splatAlpha贴图。
  36225. */
  36226. __getset(0,__proto,'splatAlphaTexture',function(){
  36227. return this._shaderValues.getTexture(ExtendTerrainMaterial.SPLATALPHATEXTURE);
  36228. },function(value){
  36229. this._shaderValues.setTexture(ExtendTerrainMaterial.SPLATALPHATEXTURE,value);
  36230. });
  36231. __getset(0,__proto,'diffuseScaleOffset3',null,function(scaleOffset3){
  36232. this._shaderValues.setVector(ExtendTerrainMaterial.DIFFUSESCALEOFFSET3,scaleOffset3);
  36233. });
  36234. /**
  36235. *设置第一层贴图。
  36236. *@param value 第一层贴图。
  36237. */
  36238. __getset(0,__proto,'diffuseTexture1',null,function(value){
  36239. this._shaderValues.setTexture(ExtendTerrainMaterial.DIFFUSETEXTURE1,value);
  36240. this._setDetailNum(1);
  36241. });
  36242. /**
  36243. *设置渲染模式。
  36244. *@return 渲染模式。
  36245. */
  36246. __getset(0,__proto,'renderMode',null,function(value){
  36247. switch (value){
  36248. case 1:
  36249. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_OPAQUE*/2000;
  36250. this.depthWrite=true;
  36251. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  36252. this.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  36253. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  36254. break ;
  36255. case 2:
  36256. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_OPAQUE*/2000;
  36257. this.depthWrite=false;
  36258. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  36259. this.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  36260. this.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_SRC_ALPHA*/0x0302;
  36261. this.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA*/0x0303;
  36262. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LEQUAL*/0x0203;
  36263. break ;
  36264. default :
  36265. throw new Error("ExtendTerrainMaterial:renderMode value error.");
  36266. }
  36267. });
  36268. /**
  36269. *设置第二层贴图。
  36270. *@param value 第二层贴图。
  36271. */
  36272. /**
  36273. *获取第二层贴图。
  36274. *@return 第二层贴图。
  36275. */
  36276. __getset(0,__proto,'diffuseTexture2',function(){
  36277. return this._shaderValues.getTexture(ExtendTerrainMaterial.DIFFUSETEXTURE2);
  36278. },function(value){
  36279. this._shaderValues.setTexture(ExtendTerrainMaterial.DIFFUSETEXTURE2,value);
  36280. this._setDetailNum(2);
  36281. });
  36282. __getset(0,__proto,'diffuseScaleOffset1',null,function(scaleOffset1){
  36283. this._shaderValues.setVector(ExtendTerrainMaterial.DIFFUSESCALEOFFSET1,scaleOffset1);
  36284. });
  36285. /**
  36286. *设置第三层贴图。
  36287. *@param value 第三层贴图。
  36288. */
  36289. /**
  36290. *获取第三层贴图。
  36291. *@return 第三层贴图。
  36292. */
  36293. __getset(0,__proto,'diffuseTexture3',function(){
  36294. return this._shaderValues.getTexture(ExtendTerrainMaterial.DIFFUSETEXTURE3);
  36295. },function(value){
  36296. this._shaderValues.setTexture(ExtendTerrainMaterial.DIFFUSETEXTURE3,value);
  36297. this._setDetailNum(3);
  36298. });
  36299. /**
  36300. *设置第四层贴图。
  36301. *@param value 第四层贴图。
  36302. */
  36303. /**
  36304. *获取第四层贴图。
  36305. *@return 第四层贴图。
  36306. */
  36307. __getset(0,__proto,'diffuseTexture4',function(){
  36308. return this._shaderValues.getTexture(ExtendTerrainMaterial.DIFFUSETEXTURE4);
  36309. },function(value){
  36310. this._shaderValues.setTexture(ExtendTerrainMaterial.DIFFUSETEXTURE4,value);
  36311. this._setDetailNum(4);
  36312. });
  36313. /**
  36314. *设置第五层贴图。
  36315. *@param value 第五层贴图。
  36316. */
  36317. /**
  36318. *获取第五层贴图。
  36319. *@return 第五层贴图。
  36320. */
  36321. __getset(0,__proto,'diffuseTexture5',function(){
  36322. return this._shaderValues.getTexture(ExtendTerrainMaterial.DIFFUSETEXTURE5);
  36323. },function(value){
  36324. this._shaderValues.setTexture(ExtendTerrainMaterial.DIFFUSETEXTURE5,value);
  36325. this._setDetailNum(5);
  36326. });
  36327. __getset(0,__proto,'diffuseScaleOffset4',null,function(scaleOffset4){
  36328. this._shaderValues.setVector(ExtendTerrainMaterial.DIFFUSESCALEOFFSET4,scaleOffset4);
  36329. });
  36330. __getset(0,__proto,'diffuseScaleOffset5',null,function(scaleOffset5){
  36331. this._shaderValues.setVector(ExtendTerrainMaterial.DIFFUSESCALEOFFSET5,scaleOffset5);
  36332. });
  36333. /**
  36334. *设置混合源。
  36335. *@param value 混合源
  36336. */
  36337. /**
  36338. *获取混合源。
  36339. *@return 混合源。
  36340. */
  36341. __getset(0,__proto,'blendSrc',function(){
  36342. return this._shaderValues.getInt(ExtendTerrainMaterial.BLEND_SRC);
  36343. },function(value){
  36344. this._shaderValues.setInt(ExtendTerrainMaterial.BLEND_SRC,value);
  36345. });
  36346. /**
  36347. *设置是否启用光照。
  36348. *@param value 是否启用光照。
  36349. */
  36350. /**
  36351. *获取是否启用光照。
  36352. *@return 是否启用光照。
  36353. */
  36354. __getset(0,__proto,'enableLighting',function(){
  36355. return this._enableLighting;
  36356. },function(value){
  36357. if (this._enableLighting!==value){
  36358. if (value)
  36359. this._disablePublicDefineDatas.remove(Scene3D.SHADERDEFINE_POINTLIGHT | Scene3D.SHADERDEFINE_SPOTLIGHT | Scene3D.SHADERDEFINE_DIRECTIONLIGHT);
  36360. else
  36361. this._disablePublicDefineDatas.add(Scene3D.SHADERDEFINE_POINTLIGHT | Scene3D.SHADERDEFINE_SPOTLIGHT | Scene3D.SHADERDEFINE_DIRECTIONLIGHT);
  36362. this._enableLighting=value;
  36363. }
  36364. });
  36365. /**
  36366. *设置是否写入深度。
  36367. *@param value 是否写入深度。
  36368. */
  36369. /**
  36370. *获取是否写入深度。
  36371. *@return 是否写入深度。
  36372. */
  36373. __getset(0,__proto,'depthWrite',function(){
  36374. return this._shaderValues.getBool(ExtendTerrainMaterial.DEPTH_WRITE);
  36375. },function(value){
  36376. this._shaderValues.setBool(ExtendTerrainMaterial.DEPTH_WRITE,value);
  36377. });
  36378. /**
  36379. *设置剔除方式。
  36380. *@param value 剔除方式。
  36381. */
  36382. /**
  36383. *获取剔除方式。
  36384. *@return 剔除方式。
  36385. */
  36386. __getset(0,__proto,'cull',function(){
  36387. return this._shaderValues.getInt(ExtendTerrainMaterial.CULL);
  36388. },function(value){
  36389. this._shaderValues.setInt(ExtendTerrainMaterial.CULL,value);
  36390. });
  36391. /**
  36392. *设置混合方式。
  36393. *@param value 混合方式。
  36394. */
  36395. /**
  36396. *获取混合方式。
  36397. *@return 混合方式。
  36398. */
  36399. __getset(0,__proto,'blend',function(){
  36400. return this._shaderValues.getInt(ExtendTerrainMaterial.BLEND);
  36401. },function(value){
  36402. this._shaderValues.setInt(ExtendTerrainMaterial.BLEND,value);
  36403. });
  36404. /**
  36405. *设置混合目标。
  36406. *@param value 混合目标
  36407. */
  36408. /**
  36409. *获取混合目标。
  36410. *@return 混合目标。
  36411. */
  36412. __getset(0,__proto,'blendDst',function(){
  36413. return this._shaderValues.getInt(ExtendTerrainMaterial.BLEND_DST);
  36414. },function(value){
  36415. this._shaderValues.setInt(ExtendTerrainMaterial.BLEND_DST,value);
  36416. });
  36417. /**
  36418. *设置深度测试方式。
  36419. *@param value 深度测试方式
  36420. */
  36421. /**
  36422. *获取深度测试方式。
  36423. *@return 深度测试方式。
  36424. */
  36425. __getset(0,__proto,'depthTest',function(){
  36426. return this._shaderValues.getInt(ExtendTerrainMaterial.DEPTH_TEST);
  36427. },function(value){
  36428. this._shaderValues.setInt(ExtendTerrainMaterial.DEPTH_TEST,value);
  36429. });
  36430. ExtendTerrainMaterial.__init__=function(){
  36431. ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM1=ExtendTerrainMaterial.shaderDefines.registerDefine("ExtendTerrain_DETAIL_NUM1");
  36432. ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM2=ExtendTerrainMaterial.shaderDefines.registerDefine("ExtendTerrain_DETAIL_NUM2");
  36433. ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM3=ExtendTerrainMaterial.shaderDefines.registerDefine("ExtendTerrain_DETAIL_NUM3");
  36434. ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM4=ExtendTerrainMaterial.shaderDefines.registerDefine("ExtendTerrain_DETAIL_NUM4");
  36435. ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM5=ExtendTerrainMaterial.shaderDefines.registerDefine("ExtendTerrain_DETAIL_NUM5");
  36436. }
  36437. ExtendTerrainMaterial.RENDERMODE_OPAQUE=1;
  36438. ExtendTerrainMaterial.RENDERMODE_TRANSPARENT=2;
  36439. ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM1=0;
  36440. ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM2=0;
  36441. ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM3=0;
  36442. ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM4=0;
  36443. ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM5=0;
  36444. __static(ExtendTerrainMaterial,
  36445. ['SPLATALPHATEXTURE',function(){return this.SPLATALPHATEXTURE=Shader3D.propertyNameToID("u_SplatAlphaTexture");},'DIFFUSETEXTURE1',function(){return this.DIFFUSETEXTURE1=Shader3D.propertyNameToID("u_DiffuseTexture1");},'DIFFUSETEXTURE2',function(){return this.DIFFUSETEXTURE2=Shader3D.propertyNameToID("u_DiffuseTexture2");},'DIFFUSETEXTURE3',function(){return this.DIFFUSETEXTURE3=Shader3D.propertyNameToID("u_DiffuseTexture3");},'DIFFUSETEXTURE4',function(){return this.DIFFUSETEXTURE4=Shader3D.propertyNameToID("u_DiffuseTexture4");},'DIFFUSETEXTURE5',function(){return this.DIFFUSETEXTURE5=Shader3D.propertyNameToID("u_DiffuseTexture5");},'DIFFUSESCALEOFFSET1',function(){return this.DIFFUSESCALEOFFSET1=Shader3D.propertyNameToID("u_DiffuseScaleOffset1");},'DIFFUSESCALEOFFSET2',function(){return this.DIFFUSESCALEOFFSET2=Shader3D.propertyNameToID("u_DiffuseScaleOffset2");},'DIFFUSESCALEOFFSET3',function(){return this.DIFFUSESCALEOFFSET3=Shader3D.propertyNameToID("u_DiffuseScaleOffset3");},'DIFFUSESCALEOFFSET4',function(){return this.DIFFUSESCALEOFFSET4=Shader3D.propertyNameToID("u_DiffuseScaleOffset4");},'DIFFUSESCALEOFFSET5',function(){return this.DIFFUSESCALEOFFSET5=Shader3D.propertyNameToID("u_DiffuseScaleOffset5");},'CULL',function(){return this.CULL=Shader3D.propertyNameToID("s_Cull");},'BLEND',function(){return this.BLEND=Shader3D.propertyNameToID("s_Blend");},'BLEND_SRC',function(){return this.BLEND_SRC=Shader3D.propertyNameToID("s_BlendSrc");},'BLEND_DST',function(){return this.BLEND_DST=Shader3D.propertyNameToID("s_BlendDst");},'DEPTH_TEST',function(){return this.DEPTH_TEST=Shader3D.propertyNameToID("s_DepthTest");},'DEPTH_WRITE',function(){return this.DEPTH_WRITE=Shader3D.propertyNameToID("s_DepthWrite");},'shaderDefines',function(){return this.shaderDefines=new ShaderDefines(BaseMaterial.shaderDefines);}
  36446. ]);
  36447. return ExtendTerrainMaterial;
  36448. })(BaseMaterial)
  36449. /**
  36450. *<code>BlinnPhongMaterial</code> 类用于实现Blinn-Phong材质。
  36451. */
  36452. //class laya.d3.core.material.BlinnPhongMaterial extends laya.d3.core.material.BaseMaterial
  36453. var BlinnPhongMaterial=(function(_super){
  36454. function BlinnPhongMaterial(){
  36455. /**@private */
  36456. //this._albedoColor=null;
  36457. /**@private */
  36458. //this._albedoIntensity=NaN;
  36459. /**@private */
  36460. //this._enableLighting=false;
  36461. /**@private */
  36462. this._enableVertexColor=false;
  36463. BlinnPhongMaterial.__super.call(this);
  36464. this.setShaderName("BLINNPHONG");
  36465. this._albedoIntensity=1.0;
  36466. this._albedoColor=new Vector4(1.0,1.0,1.0,1.0);
  36467. var sv=this._shaderValues;
  36468. sv.setVector(BlinnPhongMaterial.ALBEDOCOLOR,new Vector4(1.0,1.0,1.0,1.0));
  36469. sv.setVector(BlinnPhongMaterial.MATERIALSPECULAR,new Vector4(1.0,1.0,1.0,1.0));
  36470. sv.setNumber(BlinnPhongMaterial.SHININESS,0.078125);
  36471. sv.setNumber(BaseMaterial.ALPHATESTVALUE,0.5);
  36472. sv.setVector(BlinnPhongMaterial.TILINGOFFSET,new Vector4(1.0,1.0,0.0,0.0));
  36473. this._enableLighting=true;
  36474. this.renderMode=0;
  36475. }
  36476. __class(BlinnPhongMaterial,'laya.d3.core.material.BlinnPhongMaterial',_super);
  36477. var __proto=BlinnPhongMaterial.prototype;
  36478. /**
  36479. *禁用雾化。
  36480. */
  36481. __proto.disableFog=function(){
  36482. this._disablePublicDefineDatas.add(Scene3D.SHADERDEFINE_FOG);
  36483. }
  36484. /**
  36485. *@inheritDoc
  36486. */
  36487. __proto.cloneTo=function(destObject){
  36488. _super.prototype.cloneTo.call(this,destObject);
  36489. var destMaterial=destObject;
  36490. destMaterial._enableLighting=this._enableLighting;
  36491. destMaterial._albedoIntensity=this._albedoIntensity;
  36492. destMaterial._enableVertexColor=this._enableVertexColor;
  36493. this._albedoColor.cloneTo(destMaterial._albedoColor);
  36494. }
  36495. /**
  36496. *@private
  36497. */
  36498. /**
  36499. *@private
  36500. */
  36501. __getset(0,__proto,'_SpecColorG',function(){
  36502. return this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).y;
  36503. },function(value){
  36504. this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).y=value;
  36505. });
  36506. /**
  36507. *@private
  36508. */
  36509. /**
  36510. *@private
  36511. */
  36512. __getset(0,__proto,'_ColorB',function(){
  36513. return this._albedoColor.z;
  36514. },function(value){
  36515. this._albedoColor.z=value;
  36516. this.albedoColor=this._albedoColor;
  36517. });
  36518. /**
  36519. *@private
  36520. */
  36521. /**
  36522. *@private
  36523. */
  36524. __getset(0,__proto,'_ColorR',function(){
  36525. return this._albedoColor.x;
  36526. },function(value){
  36527. this._albedoColor.x=value;
  36528. this.albedoColor=this._albedoColor;
  36529. });
  36530. /**
  36531. *设置反照率颜色alpha分量。
  36532. *@param value 反照率颜色alpha分量。
  36533. */
  36534. /**
  36535. *获取反照率颜色Z分量。
  36536. *@return 反照率颜色Z分量。
  36537. */
  36538. __getset(0,__proto,'albedoColorA',function(){
  36539. return this._ColorA;
  36540. },function(value){
  36541. this._ColorA=value;
  36542. });
  36543. /**
  36544. *@private
  36545. */
  36546. /**
  36547. *@private
  36548. */
  36549. __getset(0,__proto,'_MainTex_STX',function(){
  36550. return this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET).x;
  36551. },function(x){
  36552. var tilOff=this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET);
  36553. tilOff.x=x;
  36554. this.tilingOffset=tilOff;
  36555. });
  36556. /**
  36557. *@private
  36558. */
  36559. /**
  36560. *@private
  36561. */
  36562. __getset(0,__proto,'_SpecColorB',function(){
  36563. return this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).z;
  36564. },function(value){
  36565. this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).z=value;
  36566. });
  36567. /**
  36568. *设置渲染模式。
  36569. *@return 渲染模式。
  36570. */
  36571. __getset(0,__proto,'renderMode',null,function(value){
  36572. switch (value){
  36573. case 0:
  36574. this.alphaTest=false;
  36575. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_OPAQUE*/2000;
  36576. this.depthWrite=true;
  36577. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  36578. this.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  36579. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  36580. break ;
  36581. case 1:
  36582. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_ALPHATEST*/2450;
  36583. this.alphaTest=true;
  36584. this.depthWrite=true;
  36585. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  36586. this.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  36587. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  36588. break ;
  36589. case 2:
  36590. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_TRANSPARENT*/3000;
  36591. this.alphaTest=false;
  36592. this.depthWrite=false;
  36593. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  36594. this.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  36595. this.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_SRC_ALPHA*/0x0302;
  36596. this.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA*/0x0303;
  36597. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  36598. break ;
  36599. default :
  36600. throw new Error("Material:renderMode value error.");
  36601. }
  36602. });
  36603. /**
  36604. *@private
  36605. */
  36606. /**
  36607. *@private
  36608. */
  36609. __getset(0,__proto,'_SpecColorR',function(){
  36610. return this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).x;
  36611. },function(value){
  36612. this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).x=value;
  36613. });
  36614. /**
  36615. *@private
  36616. */
  36617. /**
  36618. *@private
  36619. */
  36620. __getset(0,__proto,'_ColorG',function(){
  36621. return this._albedoColor.y;
  36622. },function(value){
  36623. this._albedoColor.y=value;
  36624. this.albedoColor=this._albedoColor;
  36625. });
  36626. /**
  36627. *@private
  36628. */
  36629. /**@private */
  36630. __getset(0,__proto,'_ColorA',function(){
  36631. return this._albedoColor.w;
  36632. },function(value){
  36633. this._albedoColor.w=value;
  36634. this.albedoColor=this._albedoColor;
  36635. });
  36636. /**
  36637. *设置高光颜色。
  36638. *@param value 高光颜色。
  36639. */
  36640. /**
  36641. *获取高光颜色。
  36642. *@return 高光颜色。
  36643. */
  36644. __getset(0,__proto,'specularColor',function(){
  36645. return this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR);
  36646. },function(value){
  36647. this._shaderValues.setVector(BlinnPhongMaterial.MATERIALSPECULAR,value);
  36648. });
  36649. /**
  36650. *设置反照率颜色B分量。
  36651. *@param value 反照率颜色B分量。
  36652. */
  36653. /**
  36654. *获取反照率颜色B分量。
  36655. *@return 反照率颜色B分量。
  36656. */
  36657. __getset(0,__proto,'albedoColorB',function(){
  36658. return this._ColorB;
  36659. },function(value){
  36660. this._ColorB=value;
  36661. });
  36662. /**
  36663. *@private
  36664. */
  36665. /**
  36666. *@private
  36667. */
  36668. __getset(0,__proto,'_SpecColorA',function(){
  36669. return this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).w;
  36670. },function(value){
  36671. this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).w=value;
  36672. });
  36673. /**
  36674. *@private
  36675. */
  36676. /**
  36677. *@private
  36678. */
  36679. __getset(0,__proto,'_MainTex_STZ',function(){
  36680. return this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET).z;
  36681. },function(z){
  36682. var tilOff=this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET);
  36683. tilOff.z=z;
  36684. this.tilingOffset=tilOff;
  36685. });
  36686. /**
  36687. *@private
  36688. */
  36689. /**
  36690. *@private
  36691. */
  36692. __getset(0,__proto,'_AlbedoIntensity',function(){
  36693. return this._albedoIntensity;
  36694. },function(value){
  36695. if (this._albedoIntensity!==value){
  36696. var finalAlbedo=this._shaderValues.getVector(BlinnPhongMaterial.ALBEDOCOLOR);
  36697. Vector4.scale(this._albedoColor,value,finalAlbedo);
  36698. this._albedoIntensity=value;
  36699. this._shaderValues.setVector(BlinnPhongMaterial.ALBEDOCOLOR,finalAlbedo);
  36700. }
  36701. });
  36702. /**
  36703. *设置高光颜色A分量。
  36704. *@param value 高光颜色A分量。
  36705. */
  36706. /**
  36707. *获取高光颜色A分量。
  36708. *@return 高光颜色A分量。
  36709. */
  36710. __getset(0,__proto,'specularColorA',function(){
  36711. return this._SpecColorA;
  36712. },function(value){
  36713. this._SpecColorA=value;
  36714. });
  36715. /**
  36716. *@private
  36717. */
  36718. /**
  36719. *@private
  36720. */
  36721. __getset(0,__proto,'_Shininess',function(){
  36722. return this._shaderValues.getNumber(BlinnPhongMaterial.SHININESS);
  36723. },function(value){
  36724. value=Math.max(0.0,Math.min(1.0,value));
  36725. this._shaderValues.setNumber(BlinnPhongMaterial.SHININESS,value);
  36726. });
  36727. /**
  36728. *@private
  36729. */
  36730. /**
  36731. *@private
  36732. */
  36733. __getset(0,__proto,'_MainTex_STY',function(){
  36734. return this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET).y;
  36735. },function(y){
  36736. var tilOff=this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET);
  36737. tilOff.y=y;
  36738. this.tilingOffset=tilOff;
  36739. });
  36740. /**
  36741. *@private
  36742. */
  36743. /**
  36744. *@private
  36745. */
  36746. __getset(0,__proto,'_Cutoff',function(){
  36747. return this.alphaTestValue;
  36748. },function(value){
  36749. this.alphaTestValue=value;
  36750. });
  36751. /**
  36752. *@private
  36753. */
  36754. /**
  36755. *@private
  36756. */
  36757. __getset(0,__proto,'_MainTex_STW',function(){
  36758. return this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET).w;
  36759. },function(w){
  36760. var tilOff=this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET);
  36761. tilOff.w=w;
  36762. this.tilingOffset=tilOff;
  36763. });
  36764. /**
  36765. *设置反照率贴图。
  36766. *@param value 反照率贴图。
  36767. */
  36768. /**
  36769. *获取反照率贴图。
  36770. *@return 反照率贴图。
  36771. */
  36772. __getset(0,__proto,'albedoTexture',function(){
  36773. return this._shaderValues.getTexture(BlinnPhongMaterial.ALBEDOTEXTURE);
  36774. },function(value){
  36775. if (value)
  36776. this._defineDatas.add(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_DIFFUSEMAP);
  36777. else
  36778. this._defineDatas.remove(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_DIFFUSEMAP);
  36779. this._shaderValues.setTexture(BlinnPhongMaterial.ALBEDOTEXTURE,value);
  36780. });
  36781. /**
  36782. *设置是否支持顶点色。
  36783. *@param value 是否支持顶点色。
  36784. */
  36785. /**
  36786. *获取是否支持顶点色。
  36787. *@return 是否支持顶点色。
  36788. */
  36789. __getset(0,__proto,'enableVertexColor',function(){
  36790. return this._enableVertexColor;
  36791. },function(value){
  36792. this._enableVertexColor=value;
  36793. if (value)
  36794. this._defineDatas.add(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_ENABLEVERTEXCOLOR);
  36795. else
  36796. this._defineDatas.remove(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_ENABLEVERTEXCOLOR);
  36797. });
  36798. /**
  36799. *设置反照率颜色。
  36800. *@param value 反照率颜色。
  36801. */
  36802. /**
  36803. *获取反照率颜色。
  36804. *@return 反照率颜色。
  36805. */
  36806. __getset(0,__proto,'albedoColor',function(){
  36807. return this._albedoColor;
  36808. },function(value){
  36809. var finalAlbedo=this._shaderValues.getVector(BlinnPhongMaterial.ALBEDOCOLOR);
  36810. Vector4.scale(value,this._albedoIntensity,finalAlbedo);
  36811. this._albedoColor=value;
  36812. this._shaderValues.setVector(BlinnPhongMaterial.ALBEDOCOLOR,finalAlbedo);
  36813. });
  36814. /**
  36815. *获取纹理平铺和偏移X分量。
  36816. *@param x 纹理平铺和偏移X分量。
  36817. */
  36818. /**
  36819. *获取纹理平铺和偏移X分量。
  36820. *@return 纹理平铺和偏移X分量。
  36821. */
  36822. __getset(0,__proto,'tilingOffsetX',function(){
  36823. return this._MainTex_STX;
  36824. },function(x){
  36825. this._MainTex_STX=x;
  36826. });
  36827. /**
  36828. *获取纹理平铺和偏移Y分量。
  36829. *@param y 纹理平铺和偏移Y分量。
  36830. */
  36831. /**
  36832. *获取纹理平铺和偏移Y分量。
  36833. *@return 纹理平铺和偏移Y分量。
  36834. */
  36835. __getset(0,__proto,'tilingOffsetY',function(){
  36836. return this._MainTex_STY;
  36837. },function(y){
  36838. this._MainTex_STY=y;
  36839. });
  36840. /**
  36841. *获取纹理平铺和偏移Z分量。
  36842. *@param z 纹理平铺和偏移Z分量。
  36843. */
  36844. /**
  36845. *获取纹理平铺和偏移Z分量。
  36846. *@return 纹理平铺和偏移Z分量。
  36847. */
  36848. __getset(0,__proto,'tilingOffsetZ',function(){
  36849. return this._MainTex_STZ;
  36850. },function(z){
  36851. this._MainTex_STZ=z;
  36852. });
  36853. /**
  36854. *设置混合源。
  36855. *@param value 混合源
  36856. */
  36857. /**
  36858. *获取混合源。
  36859. *@return 混合源。
  36860. */
  36861. __getset(0,__proto,'blendSrc',function(){
  36862. return this._shaderValues.getInt(BlinnPhongMaterial.BLEND_SRC);
  36863. },function(value){
  36864. this._shaderValues.setInt(BlinnPhongMaterial.BLEND_SRC,value);
  36865. });
  36866. /**
  36867. *设置是否启用光照。
  36868. *@param value 是否启用光照。
  36869. */
  36870. /**
  36871. *获取是否启用光照。
  36872. *@return 是否启用光照。
  36873. */
  36874. __getset(0,__proto,'enableLighting',function(){
  36875. return this._enableLighting;
  36876. },function(value){
  36877. if (this._enableLighting!==value){
  36878. if (value)
  36879. this._disablePublicDefineDatas.remove(Scene3D.SHADERDEFINE_POINTLIGHT | Scene3D.SHADERDEFINE_SPOTLIGHT | Scene3D.SHADERDEFINE_DIRECTIONLIGHT);
  36880. else
  36881. this._disablePublicDefineDatas.add(Scene3D.SHADERDEFINE_POINTLIGHT | Scene3D.SHADERDEFINE_SPOTLIGHT | Scene3D.SHADERDEFINE_DIRECTIONLIGHT);
  36882. this._enableLighting=value;
  36883. }
  36884. });
  36885. /**
  36886. *获取纹理平铺和偏移W分量。
  36887. *@param w 纹理平铺和偏移W分量。
  36888. */
  36889. /**
  36890. *获取纹理平铺和偏移W分量。
  36891. *@return 纹理平铺和偏移W分量。
  36892. */
  36893. __getset(0,__proto,'tilingOffsetW',function(){
  36894. return this._MainTex_STW;
  36895. },function(w){
  36896. this._MainTex_STW=w;
  36897. });
  36898. /**
  36899. *获取纹理平铺和偏移。
  36900. *@param value 纹理平铺和偏移。
  36901. */
  36902. /**
  36903. *获取纹理平铺和偏移。
  36904. *@return 纹理平铺和偏移。
  36905. */
  36906. __getset(0,__proto,'tilingOffset',function(){
  36907. return this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET);
  36908. },function(value){
  36909. if (value){
  36910. if (value.x !=1 || value.y !=1 || value.z !=0 || value.w !=0)
  36911. this._defineDatas.add(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_TILINGOFFSET);
  36912. else
  36913. this._defineDatas.remove(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_TILINGOFFSET);
  36914. }else {
  36915. this._defineDatas.remove(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_TILINGOFFSET);
  36916. }
  36917. this._shaderValues.setVector(BlinnPhongMaterial.TILINGOFFSET,value);
  36918. });
  36919. /**
  36920. *设置反照率颜色R分量。
  36921. *@param value 反照率颜色R分量。
  36922. */
  36923. /**
  36924. *获取反照率颜色R分量。
  36925. *@return 反照率颜色R分量。
  36926. */
  36927. __getset(0,__proto,'albedoColorR',function(){
  36928. return this._ColorR;
  36929. },function(value){
  36930. this._ColorR=value;
  36931. });
  36932. /**
  36933. *设置反照率颜色G分量。
  36934. *@param value 反照率颜色G分量。
  36935. */
  36936. /**
  36937. *获取反照率颜色G分量。
  36938. *@return 反照率颜色G分量。
  36939. */
  36940. __getset(0,__proto,'albedoColorG',function(){
  36941. return this._ColorG;
  36942. },function(value){
  36943. this._ColorG=value;
  36944. });
  36945. /**
  36946. *设置反照率强度。
  36947. *@param value 反照率强度。
  36948. */
  36949. /**
  36950. *获取反照率强度。
  36951. *@return 反照率强度。
  36952. */
  36953. __getset(0,__proto,'albedoIntensity',function(){
  36954. return this._albedoIntensity;
  36955. },function(value){
  36956. this._AlbedoIntensity=value;
  36957. });
  36958. /**
  36959. *设置高光颜色R分量。
  36960. *@param value 高光颜色R分量。
  36961. */
  36962. /**
  36963. *获取高光颜色R轴分量。
  36964. *@return 高光颜色R轴分量。
  36965. */
  36966. __getset(0,__proto,'specularColorR',function(){
  36967. return this._SpecColorR;
  36968. },function(value){
  36969. this._SpecColorR=value;
  36970. });
  36971. /**
  36972. *设置高光颜色G分量。
  36973. *@param value 高光颜色G分量。
  36974. */
  36975. /**
  36976. *获取高光颜色G分量。
  36977. *@return 高光颜色G分量。
  36978. */
  36979. __getset(0,__proto,'specularColorG',function(){
  36980. return this._SpecColorG;
  36981. },function(value){
  36982. this._SpecColorG=value;
  36983. });
  36984. /**
  36985. *设置高光颜色B分量。
  36986. *@param value 高光颜色B分量。
  36987. */
  36988. /**
  36989. *获取高光颜色B分量。
  36990. *@return 高光颜色B分量。
  36991. */
  36992. __getset(0,__proto,'specularColorB',function(){
  36993. return this._SpecColorB;
  36994. },function(value){
  36995. this._SpecColorB=value;
  36996. });
  36997. /**
  36998. *设置混合目标。
  36999. *@param value 混合目标
  37000. */
  37001. /**
  37002. *获取混合目标。
  37003. *@return 混合目标。
  37004. */
  37005. __getset(0,__proto,'blendDst',function(){
  37006. return this._shaderValues.getInt(BlinnPhongMaterial.BLEND_DST);
  37007. },function(value){
  37008. this._shaderValues.setInt(BlinnPhongMaterial.BLEND_DST,value);
  37009. });
  37010. /**
  37011. *设置高光强度,范围为0到1。
  37012. *@param value 高光强度。
  37013. */
  37014. /**
  37015. *获取高光强度,范围为0到1。
  37016. *@return 高光强度。
  37017. */
  37018. __getset(0,__proto,'shininess',function(){
  37019. return this._Shininess;
  37020. },function(value){
  37021. this._Shininess=value;
  37022. });
  37023. /**
  37024. *设置剔除方式。
  37025. *@param value 剔除方式。
  37026. */
  37027. /**
  37028. *获取剔除方式。
  37029. *@return 剔除方式。
  37030. */
  37031. __getset(0,__proto,'cull',function(){
  37032. return this._shaderValues.getInt(BlinnPhongMaterial.CULL);
  37033. },function(value){
  37034. this._shaderValues.setInt(BlinnPhongMaterial.CULL,value);
  37035. });
  37036. /**
  37037. *设置法线贴图。
  37038. *@param value 法线贴图。
  37039. */
  37040. /**
  37041. *获取法线贴图。
  37042. *@return 法线贴图。
  37043. */
  37044. __getset(0,__proto,'normalTexture',function(){
  37045. return this._shaderValues.getTexture(BlinnPhongMaterial.NORMALTEXTURE);
  37046. },function(value){
  37047. if (value)
  37048. this._defineDatas.add(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_NORMALMAP);
  37049. else
  37050. this._defineDatas.remove(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_NORMALMAP);
  37051. this._shaderValues.setTexture(BlinnPhongMaterial.NORMALTEXTURE,value);
  37052. });
  37053. /**
  37054. *设置高光贴图,高光强度则从该贴图RGB值中获取,如果该值为空则从漫反射贴图的Alpha通道获取。
  37055. *@param value 高光贴图。
  37056. */
  37057. /**
  37058. *获取高光贴图。
  37059. *@return 高光贴图。
  37060. */
  37061. __getset(0,__proto,'specularTexture',function(){
  37062. return this._shaderValues.getTexture(BlinnPhongMaterial.SPECULARTEXTURE);
  37063. },function(value){
  37064. if (value)
  37065. this._defineDatas.add(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_SPECULARMAP);
  37066. else
  37067. this._defineDatas.remove(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_SPECULARMAP);
  37068. this._shaderValues.setTexture(BlinnPhongMaterial.SPECULARTEXTURE,value);
  37069. });
  37070. /**
  37071. *设置是否写入深度。
  37072. *@param value 是否写入深度。
  37073. */
  37074. /**
  37075. *获取是否写入深度。
  37076. *@return 是否写入深度。
  37077. */
  37078. __getset(0,__proto,'depthWrite',function(){
  37079. return this._shaderValues.getBool(BlinnPhongMaterial.DEPTH_WRITE);
  37080. },function(value){
  37081. this._shaderValues.setBool(BlinnPhongMaterial.DEPTH_WRITE,value);
  37082. });
  37083. /**
  37084. *设置混合方式。
  37085. *@param value 混合方式。
  37086. */
  37087. /**
  37088. *获取混合方式。
  37089. *@return 混合方式。
  37090. */
  37091. __getset(0,__proto,'blend',function(){
  37092. return this._shaderValues.getInt(BlinnPhongMaterial.BLEND);
  37093. },function(value){
  37094. this._shaderValues.setInt(BlinnPhongMaterial.BLEND,value);
  37095. });
  37096. /**
  37097. *设置深度测试方式。
  37098. *@param value 深度测试方式
  37099. */
  37100. /**
  37101. *获取深度测试方式。
  37102. *@return 深度测试方式。
  37103. */
  37104. __getset(0,__proto,'depthTest',function(){
  37105. return this._shaderValues.getInt(BlinnPhongMaterial.DEPTH_TEST);
  37106. },function(value){
  37107. this._shaderValues.setInt(BlinnPhongMaterial.DEPTH_TEST,value);
  37108. });
  37109. BlinnPhongMaterial.__init__=function(){
  37110. BlinnPhongMaterial.SHADERDEFINE_DIFFUSEMAP=BlinnPhongMaterial.shaderDefines.registerDefine("DIFFUSEMAP");
  37111. BlinnPhongMaterial.SHADERDEFINE_NORMALMAP=BlinnPhongMaterial.shaderDefines.registerDefine("NORMALMAP");
  37112. BlinnPhongMaterial.SHADERDEFINE_SPECULARMAP=BlinnPhongMaterial.shaderDefines.registerDefine("SPECULARMAP");
  37113. BlinnPhongMaterial.SHADERDEFINE_TILINGOFFSET=BlinnPhongMaterial.shaderDefines.registerDefine("TILINGOFFSET");
  37114. BlinnPhongMaterial.SHADERDEFINE_ENABLEVERTEXCOLOR=BlinnPhongMaterial.shaderDefines.registerDefine("ENABLEVERTEXCOLOR");
  37115. }
  37116. BlinnPhongMaterial.SPECULARSOURCE_DIFFUSEMAPALPHA=0;
  37117. BlinnPhongMaterial.SPECULARSOURCE_SPECULARMAP=0;
  37118. BlinnPhongMaterial.RENDERMODE_OPAQUE=0;
  37119. BlinnPhongMaterial.RENDERMODE_CUTOUT=1;
  37120. BlinnPhongMaterial.RENDERMODE_TRANSPARENT=2;
  37121. BlinnPhongMaterial.SHADERDEFINE_DIFFUSEMAP=0;
  37122. BlinnPhongMaterial.SHADERDEFINE_NORMALMAP=0;
  37123. BlinnPhongMaterial.SHADERDEFINE_SPECULARMAP=0;
  37124. BlinnPhongMaterial.SHADERDEFINE_TILINGOFFSET=0;
  37125. BlinnPhongMaterial.SHADERDEFINE_ENABLEVERTEXCOLOR=0;
  37126. __static(BlinnPhongMaterial,
  37127. ['ALBEDOTEXTURE',function(){return this.ALBEDOTEXTURE=Shader3D.propertyNameToID("u_DiffuseTexture");},'NORMALTEXTURE',function(){return this.NORMALTEXTURE=Shader3D.propertyNameToID("u_NormalTexture");},'SPECULARTEXTURE',function(){return this.SPECULARTEXTURE=Shader3D.propertyNameToID("u_SpecularTexture");},'ALBEDOCOLOR',function(){return this.ALBEDOCOLOR=Shader3D.propertyNameToID("u_DiffuseColor");},'MATERIALSPECULAR',function(){return this.MATERIALSPECULAR=Shader3D.propertyNameToID("u_MaterialSpecular");},'SHININESS',function(){return this.SHININESS=Shader3D.propertyNameToID("u_Shininess");},'TILINGOFFSET',function(){return this.TILINGOFFSET=Shader3D.propertyNameToID("u_TilingOffset");},'CULL',function(){return this.CULL=Shader3D.propertyNameToID("s_Cull");},'BLEND',function(){return this.BLEND=Shader3D.propertyNameToID("s_Blend");},'BLEND_SRC',function(){return this.BLEND_SRC=Shader3D.propertyNameToID("s_BlendSrc");},'BLEND_DST',function(){return this.BLEND_DST=Shader3D.propertyNameToID("s_BlendDst");},'DEPTH_TEST',function(){return this.DEPTH_TEST=Shader3D.propertyNameToID("s_DepthTest");},'DEPTH_WRITE',function(){return this.DEPTH_WRITE=Shader3D.propertyNameToID("s_DepthWrite");},'defaultMaterial',function(){return this.defaultMaterial=new BlinnPhongMaterial();},'shaderDefines',function(){return this.shaderDefines=new ShaderDefines(BaseMaterial.shaderDefines);}
  37128. ]);
  37129. return BlinnPhongMaterial;
  37130. })(BaseMaterial)
  37131. /**
  37132. *...
  37133. *@author ...
  37134. */
  37135. //class laya.d3.core.material.TerrainMaterial extends laya.d3.core.material.BaseMaterial
  37136. var TerrainMaterial=(function(_super){
  37137. function TerrainMaterial(){
  37138. this._diffuseScale1=null;
  37139. this._diffuseScale2=null;
  37140. this._diffuseScale3=null;
  37141. this._diffuseScale4=null;
  37142. TerrainMaterial.__super.call(this);
  37143. this.setShaderName("Terrain");
  37144. this.renderMode=1;
  37145. this._diffuseScale1=new Vector2();
  37146. this._diffuseScale2=new Vector2();
  37147. this._diffuseScale3=new Vector2();
  37148. this._diffuseScale4=new Vector2();
  37149. this.ambientColor=new Vector3(0.6,0.6,0.6);
  37150. this.diffuseColor=new Vector3(1.0,1.0,1.0);
  37151. this.specularColor=new Vector4(0.2,0.2,0.2,32.0);
  37152. }
  37153. __class(TerrainMaterial,'laya.d3.core.material.TerrainMaterial',_super);
  37154. var __proto=TerrainMaterial.prototype;
  37155. __proto.setDiffuseScale1=function(x,y){
  37156. this._diffuseScale1.x=x;
  37157. this._diffuseScale1.y=y;
  37158. this._shaderValues.setVector2(6,this._diffuseScale1);
  37159. }
  37160. __proto.setDiffuseScale2=function(x,y){
  37161. this._diffuseScale2.x=x;
  37162. this._diffuseScale2.y=y;
  37163. this._shaderValues.setVector2(7,this._diffuseScale2);
  37164. }
  37165. __proto.setDiffuseScale3=function(x,y){
  37166. this._diffuseScale3.x=x;
  37167. this._diffuseScale3.y=y;
  37168. this._shaderValues.setVector2(8,this._diffuseScale3);
  37169. }
  37170. __proto.setDiffuseScale4=function(x,y){
  37171. this._diffuseScale4.x=x;
  37172. this._diffuseScale4.y=y;
  37173. this._shaderValues.setVector2(9,this._diffuseScale4);
  37174. }
  37175. __proto.setDetailNum=function(value){
  37176. switch (value){
  37177. case 1:
  37178. this._defineDatas.add(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM1);
  37179. this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM2);
  37180. this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM3);
  37181. this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM4);
  37182. break ;
  37183. case 2:
  37184. this._defineDatas.add(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM2);
  37185. this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM1);
  37186. this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM3);
  37187. this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM4);
  37188. break ;
  37189. case 3:
  37190. this._defineDatas.add(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM3);
  37191. this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM1);
  37192. this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM2);
  37193. this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM4);
  37194. break ;
  37195. case 4:
  37196. this._defineDatas.add(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM4);
  37197. this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM1);
  37198. this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM2);
  37199. this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM3);
  37200. break ;
  37201. }
  37202. }
  37203. __proto.disableLight=function(){
  37204. this._disablePublicDefineDatas.add(Scene3D.SHADERDEFINE_POINTLIGHT | Scene3D.SHADERDEFINE_SPOTLIGHT | Scene3D.SHADERDEFINE_DIRECTIONLIGHT);
  37205. }
  37206. /**
  37207. *@inheritDoc
  37208. */
  37209. __proto.setShaderName=function(name){
  37210. _super.prototype.setShaderName.call(this,name);
  37211. }
  37212. /**
  37213. *设置渲染模式。
  37214. *@return 渲染模式。
  37215. */
  37216. __getset(0,__proto,'renderMode',null,function(value){
  37217. switch (value){
  37218. case 1:
  37219. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_OPAQUE*/2000;
  37220. this.depthWrite=true;
  37221. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  37222. this.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  37223. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  37224. break ;
  37225. case 2:
  37226. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_OPAQUE*/2000;
  37227. this.depthWrite=false;
  37228. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  37229. this.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  37230. this.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_SRC_ALPHA*/0x0302;
  37231. this.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA*/0x0303;
  37232. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LEQUAL*/0x0203;
  37233. break ;
  37234. default :
  37235. throw new Error("TerrainMaterial:renderMode value error.");
  37236. }
  37237. });
  37238. /**
  37239. *设置第二层贴图。
  37240. *@param value 第二层贴图。
  37241. */
  37242. /**
  37243. *获取第二层贴图。
  37244. *@return 第二层贴图。
  37245. */
  37246. __getset(0,__proto,'diffuseTexture2',function(){
  37247. return this._shaderValues.getTexture(3);
  37248. },function(value){
  37249. this._shaderValues.setTexture(3,value);
  37250. });
  37251. __getset(0,__proto,'ambientColor',function(){
  37252. return this._shaderValues.getVector(10);
  37253. },function(value){
  37254. this._shaderValues.setVector3(10,value);
  37255. });
  37256. /**
  37257. *设置第四层贴图。
  37258. *@param value 第四层贴图。
  37259. */
  37260. /**
  37261. *获取第四层贴图。
  37262. *@return 第四层贴图。
  37263. */
  37264. __getset(0,__proto,'diffuseTexture4',function(){
  37265. return this._shaderValues.getTexture(5);
  37266. },function(value){
  37267. this._shaderValues.setTexture(5,value);
  37268. });
  37269. __getset(0,__proto,'diffuseColor',function(){
  37270. return this._shaderValues.getVector(11);
  37271. },function(value){
  37272. this._shaderValues.setVector3(11,value);
  37273. });
  37274. /**
  37275. *设置第一层贴图。
  37276. *@param value 第一层贴图。
  37277. */
  37278. /**
  37279. *获取第一层贴图。
  37280. *@return 第一层贴图。
  37281. */
  37282. __getset(0,__proto,'diffuseTexture1',function(){
  37283. return this._shaderValues.getTexture(2);
  37284. },function(value){
  37285. this._shaderValues.setTexture(2,value);
  37286. });
  37287. __getset(0,__proto,'specularColor',function(){
  37288. return this._shaderValues.getVector(12);
  37289. },function(value){
  37290. this._shaderValues.setVector(12,value);
  37291. });
  37292. /**
  37293. *设置第三层贴图。
  37294. *@param value 第三层贴图。
  37295. */
  37296. /**
  37297. *获取第三层贴图。
  37298. *@return 第三层贴图。
  37299. */
  37300. __getset(0,__proto,'diffuseTexture3',function(){
  37301. return this._shaderValues.getTexture(4);
  37302. },function(value){
  37303. this._shaderValues.setTexture(4,value);
  37304. });
  37305. /**
  37306. *设置splatAlpha贴图。
  37307. *@param value splatAlpha贴图。
  37308. */
  37309. /**
  37310. *获取splatAlpha贴图。
  37311. *@return splatAlpha贴图。
  37312. */
  37313. __getset(0,__proto,'splatAlphaTexture',function(){
  37314. return this._shaderValues.getTexture(0);
  37315. },function(value){
  37316. this._shaderValues.setTexture(0,value);
  37317. });
  37318. /**
  37319. *设置剔除方式。
  37320. *@param value 剔除方式。
  37321. */
  37322. /**
  37323. *获取剔除方式。
  37324. *@return 剔除方式。
  37325. */
  37326. __getset(0,__proto,'cull',function(){
  37327. return this._shaderValues.getInt(TerrainMaterial.CULL);
  37328. },function(value){
  37329. this._shaderValues.setInt(TerrainMaterial.CULL,value);
  37330. });
  37331. __getset(0,__proto,'normalTexture',function(){
  37332. return this._shaderValues.getTexture(1);
  37333. },function(value){
  37334. this._shaderValues.setTexture(1,value);
  37335. });
  37336. /**
  37337. *设置是否写入深度。
  37338. *@param value 是否写入深度。
  37339. */
  37340. /**
  37341. *获取是否写入深度。
  37342. *@return 是否写入深度。
  37343. */
  37344. __getset(0,__proto,'depthWrite',function(){
  37345. return this._shaderValues.getBool(TerrainMaterial.DEPTH_WRITE);
  37346. },function(value){
  37347. this._shaderValues.setBool(TerrainMaterial.DEPTH_WRITE,value);
  37348. });
  37349. /**
  37350. *设置混合方式。
  37351. *@param value 混合方式。
  37352. */
  37353. /**
  37354. *获取混合方式。
  37355. *@return 混合方式。
  37356. */
  37357. __getset(0,__proto,'blend',function(){
  37358. return this._shaderValues.getInt(TerrainMaterial.BLEND);
  37359. },function(value){
  37360. this._shaderValues.setInt(TerrainMaterial.BLEND,value);
  37361. });
  37362. /**
  37363. *设置混合源。
  37364. *@param value 混合源
  37365. */
  37366. /**
  37367. *获取混合源。
  37368. *@return 混合源。
  37369. */
  37370. __getset(0,__proto,'blendSrc',function(){
  37371. return this._shaderValues.getInt(TerrainMaterial.BLEND_SRC);
  37372. },function(value){
  37373. this._shaderValues.setInt(TerrainMaterial.BLEND_SRC,value);
  37374. });
  37375. /**
  37376. *设置混合目标。
  37377. *@param value 混合目标
  37378. */
  37379. /**
  37380. *获取混合目标。
  37381. *@return 混合目标。
  37382. */
  37383. __getset(0,__proto,'blendDst',function(){
  37384. return this._shaderValues.getInt(TerrainMaterial.BLEND_DST);
  37385. },function(value){
  37386. this._shaderValues.setInt(TerrainMaterial.BLEND_DST,value);
  37387. });
  37388. /**
  37389. *设置深度测试方式。
  37390. *@param value 深度测试方式
  37391. */
  37392. /**
  37393. *获取深度测试方式。
  37394. *@return 深度测试方式。
  37395. */
  37396. __getset(0,__proto,'depthTest',function(){
  37397. return this._shaderValues.getInt(TerrainMaterial.DEPTH_TEST);
  37398. },function(value){
  37399. this._shaderValues.setInt(TerrainMaterial.DEPTH_TEST,value);
  37400. });
  37401. TerrainMaterial.__init__=function(){
  37402. TerrainMaterial.SHADERDEFINE_DETAIL_NUM1=TerrainMaterial.shaderDefines.registerDefine("DETAIL_NUM1");
  37403. TerrainMaterial.SHADERDEFINE_DETAIL_NUM2=TerrainMaterial.shaderDefines.registerDefine("DETAIL_NUM2");
  37404. TerrainMaterial.SHADERDEFINE_DETAIL_NUM4=TerrainMaterial.shaderDefines.registerDefine("DETAIL_NUM4");
  37405. TerrainMaterial.SHADERDEFINE_DETAIL_NUM3=TerrainMaterial.shaderDefines.registerDefine("DETAIL_NUM3");
  37406. }
  37407. TerrainMaterial.RENDERMODE_OPAQUE=1;
  37408. TerrainMaterial.RENDERMODE_TRANSPARENT=2;
  37409. TerrainMaterial.SPLATALPHATEXTURE=0;
  37410. TerrainMaterial.NORMALTEXTURE=1;
  37411. TerrainMaterial.DIFFUSETEXTURE1=2;
  37412. TerrainMaterial.DIFFUSETEXTURE2=3;
  37413. TerrainMaterial.DIFFUSETEXTURE3=4;
  37414. TerrainMaterial.DIFFUSETEXTURE4=5;
  37415. TerrainMaterial.DIFFUSESCALE1=6;
  37416. TerrainMaterial.DIFFUSESCALE2=7;
  37417. TerrainMaterial.DIFFUSESCALE3=8;
  37418. TerrainMaterial.DIFFUSESCALE4=9;
  37419. TerrainMaterial.MATERIALAMBIENT=10;
  37420. TerrainMaterial.MATERIALDIFFUSE=11;
  37421. TerrainMaterial.MATERIALSPECULAR=12;
  37422. TerrainMaterial.SHADERDEFINE_DETAIL_NUM1=0;
  37423. TerrainMaterial.SHADERDEFINE_DETAIL_NUM2=0;
  37424. TerrainMaterial.SHADERDEFINE_DETAIL_NUM3=0;
  37425. TerrainMaterial.SHADERDEFINE_DETAIL_NUM4=0;
  37426. __static(TerrainMaterial,
  37427. ['CULL',function(){return this.CULL=Shader3D.propertyNameToID("s_Cull");},'BLEND',function(){return this.BLEND=Shader3D.propertyNameToID("s_Blend");},'BLEND_SRC',function(){return this.BLEND_SRC=Shader3D.propertyNameToID("s_BlendSrc");},'BLEND_DST',function(){return this.BLEND_DST=Shader3D.propertyNameToID("s_BlendDst");},'DEPTH_TEST',function(){return this.DEPTH_TEST=Shader3D.propertyNameToID("s_DepthTest");},'DEPTH_WRITE',function(){return this.DEPTH_WRITE=Shader3D.propertyNameToID("s_DepthWrite");},'defaultMaterial',function(){return this.defaultMaterial=new TerrainMaterial();},'shaderDefines',function(){return this.shaderDefines=new ShaderDefines(BaseMaterial.shaderDefines);}
  37428. ]);
  37429. return TerrainMaterial;
  37430. })(BaseMaterial)
  37431. /**
  37432. *<code>SkyBoxMaterial</code> 类用于实现SkyBoxMaterial材质。
  37433. */
  37434. //class laya.d3.core.material.SkyBoxMaterial extends laya.d3.core.material.BaseMaterial
  37435. var SkyBoxMaterial=(function(_super){
  37436. /**
  37437. *创建一个 <code>SkyBoxMaterial</code> 实例。
  37438. */
  37439. function SkyBoxMaterial(){
  37440. SkyBoxMaterial.__super.call(this);
  37441. this.setShaderName("SkyBox");
  37442. }
  37443. __class(SkyBoxMaterial,'laya.d3.core.material.SkyBoxMaterial',_super);
  37444. var __proto=SkyBoxMaterial.prototype;
  37445. /**
  37446. *设置颜色。
  37447. *@param value 颜色。
  37448. */
  37449. /**
  37450. *获取颜色。
  37451. *@return 颜色。
  37452. */
  37453. __getset(0,__proto,'tintColor',function(){
  37454. return this._shaderValues.getVector(SkyBoxMaterial.TINTCOLOR);
  37455. },function(value){
  37456. this._shaderValues.setVector(SkyBoxMaterial.TINTCOLOR,value);
  37457. });
  37458. /**
  37459. *设置曝光强度。
  37460. *@param value 曝光强度。
  37461. */
  37462. /**
  37463. *获取曝光强度。
  37464. *@return 曝光强度。
  37465. */
  37466. __getset(0,__proto,'exposure',function(){
  37467. return this._shaderValues.getNumber(SkyBoxMaterial.EXPOSURE);
  37468. },function(value){
  37469. this._shaderValues.setNumber(SkyBoxMaterial.EXPOSURE,value);
  37470. });
  37471. /**
  37472. *设置曝光强度。
  37473. *@param value 曝光强度。
  37474. */
  37475. /**
  37476. *获取曝光强度。
  37477. *@return 曝光强度。
  37478. */
  37479. __getset(0,__proto,'rotation',function(){
  37480. return this._shaderValues.getNumber(SkyBoxMaterial.ROTATION);
  37481. },function(value){
  37482. this._shaderValues.setNumber(SkyBoxMaterial.ROTATION,value);
  37483. });
  37484. /**
  37485. *设置天空盒纹理。
  37486. */
  37487. /**
  37488. *获取天空盒纹理。
  37489. */
  37490. __getset(0,__proto,'textureCube',function(){
  37491. return this._shaderValues.getTexture(SkyBoxMaterial.TEXTURECUBE);
  37492. },function(value){
  37493. this._shaderValues.setTexture(SkyBoxMaterial.TEXTURECUBE,value);
  37494. });
  37495. __static(SkyBoxMaterial,
  37496. ['TINTCOLOR',function(){return this.TINTCOLOR=Shader3D.propertyNameToID("u_TintColor");},'EXPOSURE',function(){return this.EXPOSURE=Shader3D.propertyNameToID("u_Exposure");},'ROTATION',function(){return this.ROTATION=Shader3D.propertyNameToID("u_Rotation");},'TEXTURECUBE',function(){return this.TEXTURECUBE=Shader3D.propertyNameToID("u_CubeTexture");},'defaultMaterial',function(){return this.defaultMaterial=new SkyBoxMaterial();}
  37497. ]);
  37498. return SkyBoxMaterial;
  37499. })(BaseMaterial)
  37500. /**
  37501. *<code>PBRSpecularMaterial</code> 类用于实现PBR(Specular)材质。
  37502. */
  37503. //class laya.d3.core.material.PBRSpecularMaterial extends laya.d3.core.material.BaseMaterial
  37504. var PBRSpecularMaterial=(function(_super){
  37505. function PBRSpecularMaterial(){
  37506. /**@private */
  37507. this._albedoColor=null;
  37508. /**@private */
  37509. this._specularColor=null;
  37510. /**@private */
  37511. this._emissionColor=null;
  37512. PBRSpecularMaterial.__super.call(this);
  37513. this.setShaderName("PBRSpecular");
  37514. this._albedoColor=new Vector4(1.0,1.0,1.0,1.0);
  37515. this._shaderValues.setVector(PBRSpecularMaterial.ALBEDOCOLOR,new Vector4(1.0,1.0,1.0,1.0));
  37516. this._emissionColor=new Vector4(0.0,0.0,0.0,0.0);
  37517. this._shaderValues.setVector(PBRSpecularMaterial.EMISSIONCOLOR,new Vector4(0.0,0.0,0.0,0.0));
  37518. this._specularColor=new Vector4(0.2,0.2,0.2,0.2);
  37519. this._shaderValues.setVector(PBRSpecularMaterial.SPECULARCOLOR,new Vector4(0.2,0.2,0.2,0.2));
  37520. this._shaderValues.setNumber(PBRSpecularMaterial.SMOOTHNESS,0.5);
  37521. this._shaderValues.setNumber(PBRSpecularMaterial.SMOOTHNESSSCALE,1.0);
  37522. this._shaderValues.setNumber(PBRSpecularMaterial.SMOOTHNESSSOURCE,0);
  37523. this._shaderValues.setNumber(PBRSpecularMaterial.OCCLUSIONSTRENGTH,1.0);
  37524. this._shaderValues.setNumber(PBRSpecularMaterial.NORMALSCALE,1.0);
  37525. this._shaderValues.setNumber(PBRSpecularMaterial.PARALLAXSCALE,0.001);
  37526. this._shaderValues.setBool(PBRSpecularMaterial.ENABLEEMISSION,false);
  37527. this._shaderValues.setNumber(BaseMaterial.ALPHATESTVALUE,0.5);
  37528. this.renderMode=0;
  37529. }
  37530. __class(PBRSpecularMaterial,'laya.d3.core.material.PBRSpecularMaterial',_super);
  37531. var __proto=PBRSpecularMaterial.prototype;
  37532. /**
  37533. *@inheritDoc
  37534. */
  37535. __proto.cloneTo=function(destObject){
  37536. _super.prototype.cloneTo.call(this,destObject);
  37537. var destMaterial=destObject;
  37538. this._albedoColor.cloneTo(destMaterial._albedoColor);
  37539. this._specularColor.cloneTo(destMaterial._specularColor);
  37540. this._emissionColor.cloneTo(destMaterial._emissionColor);
  37541. }
  37542. /**
  37543. *设置放射贴图。
  37544. *@param value 放射贴图。
  37545. */
  37546. /**
  37547. *获取放射贴图。
  37548. *@return 放射贴图。
  37549. */
  37550. __getset(0,__proto,'emissionTexture',function(){
  37551. return this._shaderValues.getTexture(PBRSpecularMaterial.EMISSIONTEXTURE);
  37552. },function(value){
  37553. if (value)
  37554. this._defineDatas.add(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_EMISSIONTEXTURE);
  37555. else
  37556. this._defineDatas.remove(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_EMISSIONTEXTURE);
  37557. this._shaderValues.setTexture(PBRSpecularMaterial.EMISSIONTEXTURE,value);
  37558. });
  37559. /**
  37560. *@private
  37561. */
  37562. /**
  37563. *@private
  37564. */
  37565. __getset(0,__proto,'_SpecColorG',function(){
  37566. return this._specularColor.y;
  37567. },function(value){
  37568. this._specularColor.y=value;
  37569. this.specularColor=this._specularColor;
  37570. });
  37571. /**
  37572. *@private
  37573. */
  37574. /**
  37575. *@private
  37576. */
  37577. __getset(0,__proto,'_ColorB',function(){
  37578. return this._albedoColor.z;
  37579. },function(value){
  37580. this._albedoColor.z=value;
  37581. this.albedoColor=this._albedoColor;
  37582. });
  37583. /**
  37584. *@private
  37585. */
  37586. /**
  37587. *@private
  37588. */
  37589. __getset(0,__proto,'_ColorR',function(){
  37590. return this._albedoColor.x;
  37591. },function(value){
  37592. this._albedoColor.x=value;
  37593. this.albedoColor=this._albedoColor;
  37594. });
  37595. /**
  37596. *设置反射率颜色A分量。
  37597. *@param value 反射率颜色A分量。
  37598. */
  37599. /**
  37600. *获取反射率颜色A分量。
  37601. *@return 反射率颜色A分量。
  37602. */
  37603. __getset(0,__proto,'albedoColorA',function(){
  37604. return this._ColorA;
  37605. },function(value){
  37606. this._ColorA=value;
  37607. });
  37608. /**
  37609. *@private
  37610. */
  37611. /**
  37612. *@private
  37613. */
  37614. __getset(0,__proto,'_MainTex_STX',function(){
  37615. return this._shaderValues.getVector(PBRSpecularMaterial.TILINGOFFSET).x;
  37616. },function(x){
  37617. var tilOff=this._shaderValues.getVector(PBRSpecularMaterial.TILINGOFFSET);
  37618. tilOff.x=x;
  37619. this.tilingOffset=tilOff;
  37620. });
  37621. /**
  37622. *@private
  37623. */
  37624. /**
  37625. *@private
  37626. */
  37627. __getset(0,__proto,'_SpecColorB',function(){
  37628. return this._specularColor.z;
  37629. },function(value){
  37630. this._specularColor.z=value;
  37631. this.specularColor=this._specularColor;
  37632. });
  37633. /**
  37634. *设置渲染模式。
  37635. *@return 渲染模式。
  37636. */
  37637. __getset(0,__proto,'renderMode',null,function(value){
  37638. switch (value){
  37639. case 0:
  37640. this.alphaTest=false;
  37641. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_OPAQUE*/2000;
  37642. this.depthWrite=true;
  37643. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  37644. this.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  37645. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  37646. this._defineDatas.remove(PBRSpecularMaterial.SHADERDEFINE_ALPHAPREMULTIPLY);
  37647. break ;
  37648. case 1:
  37649. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_ALPHATEST*/2450;
  37650. this.alphaTest=true;
  37651. this.depthWrite=true;
  37652. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  37653. this.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  37654. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  37655. this._defineDatas.remove(PBRSpecularMaterial.SHADERDEFINE_ALPHAPREMULTIPLY);
  37656. break ;
  37657. case 2:
  37658. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_TRANSPARENT*/3000;
  37659. this.alphaTest=false;
  37660. this.depthWrite=false;
  37661. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  37662. this.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  37663. this.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_SRC_ALPHA*/0x0302;
  37664. this.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA*/0x0303;
  37665. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  37666. this._defineDatas.remove(PBRSpecularMaterial.SHADERDEFINE_ALPHAPREMULTIPLY);
  37667. break ;
  37668. break ;
  37669. case 3:
  37670. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_TRANSPARENT*/3000;
  37671. this.alphaTest=false;
  37672. this.depthWrite=false;
  37673. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  37674. this.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  37675. this.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE*/1;
  37676. this.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA*/0x0303;
  37677. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  37678. this._defineDatas.add(PBRSpecularMaterial.SHADERDEFINE_ALPHAPREMULTIPLY);
  37679. break ;
  37680. default :
  37681. throw new Error("PBRSpecularMaterial : renderMode value error.");
  37682. }
  37683. });
  37684. /**
  37685. *@private
  37686. */
  37687. /**
  37688. *@private
  37689. */
  37690. __getset(0,__proto,'_SpecColorR',function(){
  37691. return this._specularColor.x;
  37692. },function(value){
  37693. this._specularColor.x=value;
  37694. this.specularColor=this._specularColor;
  37695. });
  37696. /**
  37697. *@private
  37698. */
  37699. /**
  37700. *@private
  37701. */
  37702. __getset(0,__proto,'_ColorG',function(){
  37703. return this._albedoColor.y;
  37704. },function(value){
  37705. this._albedoColor.y=value;
  37706. this.albedoColor=this._albedoColor;
  37707. });
  37708. /**
  37709. *@private
  37710. */
  37711. /**
  37712. *@private
  37713. */
  37714. __getset(0,__proto,'_Glossiness',function(){
  37715. return this._shaderValues.getNumber(PBRSpecularMaterial.SMOOTHNESS);
  37716. },function(value){
  37717. this._shaderValues.setNumber(PBRSpecularMaterial.SMOOTHNESS,value);
  37718. });
  37719. /**
  37720. *@private
  37721. */
  37722. /**
  37723. *@private
  37724. */
  37725. __getset(0,__proto,'_ColorA',function(){
  37726. return this._albedoColor.w;
  37727. },function(value){
  37728. this._albedoColor.w=value;
  37729. this.albedoColor=this._albedoColor;
  37730. });
  37731. /**
  37732. *设置高光颜色。
  37733. *@param value 高光颜色。
  37734. */
  37735. /**
  37736. *获取高光颜色。
  37737. *@return 高光颜色。
  37738. */
  37739. __getset(0,__proto,'specularColor',function(){
  37740. return this._shaderValues.getVector(PBRSpecularMaterial.SPECULARCOLOR);
  37741. },function(value){
  37742. this._shaderValues.setVector(PBRSpecularMaterial.SPECULARCOLOR,value);
  37743. });
  37744. /**
  37745. *设置反射率颜色B分量。
  37746. *@param value 反射率颜色B分量。
  37747. */
  37748. /**
  37749. *获取反射率颜色B分量。
  37750. *@return 反射率颜色B分量。
  37751. */
  37752. __getset(0,__proto,'albedoColorB',function(){
  37753. return this._ColorB;
  37754. },function(value){
  37755. this._ColorB=value;
  37756. });
  37757. /**
  37758. *@private
  37759. */
  37760. /**
  37761. *@private
  37762. */
  37763. __getset(0,__proto,'_SpecColorA',function(){
  37764. return this._specularColor.w;
  37765. },function(value){
  37766. this._specularColor.w=value;
  37767. this.specularColor=this._specularColor;
  37768. });
  37769. /**
  37770. *@private
  37771. */
  37772. /**
  37773. *@private
  37774. */
  37775. __getset(0,__proto,'_GlossMapScale',function(){
  37776. return this._shaderValues.getNumber(PBRSpecularMaterial.SMOOTHNESSSCALE);
  37777. },function(value){
  37778. this._shaderValues.setNumber(PBRSpecularMaterial.SMOOTHNESSSCALE,value);
  37779. });
  37780. /**
  37781. *@private
  37782. */
  37783. /**
  37784. *@private
  37785. */
  37786. __getset(0,__proto,'_BumpScale',function(){
  37787. return this._shaderValues.getNumber(PBRSpecularMaterial.NORMALSCALE);
  37788. },function(value){
  37789. this._shaderValues.setNumber(PBRSpecularMaterial.NORMALSCALE,value);
  37790. });
  37791. /**
  37792. *@private
  37793. */
  37794. /**@private */
  37795. __getset(0,__proto,'_Parallax',function(){
  37796. return this._shaderValues.getNumber(PBRSpecularMaterial.PARALLAXSCALE);
  37797. },function(value){
  37798. this._shaderValues.setNumber(PBRSpecularMaterial.PARALLAXSCALE,value);
  37799. });
  37800. /**
  37801. *@private
  37802. */
  37803. /**@private */
  37804. __getset(0,__proto,'_OcclusionStrength',function(){
  37805. return this._shaderValues.getNumber(PBRSpecularMaterial.OCCLUSIONSTRENGTH);
  37806. },function(value){
  37807. this._shaderValues.setNumber(PBRSpecularMaterial.OCCLUSIONSTRENGTH,value);
  37808. });
  37809. /**
  37810. *@private
  37811. */
  37812. /**
  37813. *@private
  37814. */
  37815. __getset(0,__proto,'_EmissionColorR',function(){
  37816. return this._emissionColor.x;
  37817. },function(value){
  37818. this._emissionColor.x=value;
  37819. this.emissionColor=this._emissionColor;
  37820. });
  37821. /**
  37822. *获取纹理平铺和偏移。
  37823. *@param value 纹理平铺和偏移。
  37824. */
  37825. /**
  37826. *获取纹理平铺和偏移。
  37827. *@return 纹理平铺和偏移。
  37828. */
  37829. __getset(0,__proto,'tilingOffset',function(){
  37830. return this._shaderValues.getVector(PBRSpecularMaterial.TILINGOFFSET);
  37831. },function(value){
  37832. if (value){
  37833. if (value.x !=1 || value.y !=1 || value.z !=0 || value.w !=0)
  37834. this._defineDatas.add(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_TILINGOFFSET);
  37835. else
  37836. this._defineDatas.remove(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_TILINGOFFSET);
  37837. }else {
  37838. this._defineDatas.remove(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_TILINGOFFSET);
  37839. }
  37840. this._shaderValues.setVector(PBRSpecularMaterial.TILINGOFFSET,value);
  37841. });
  37842. /**
  37843. *@private
  37844. */
  37845. /**
  37846. *@private
  37847. */
  37848. __getset(0,__proto,'_EmissionColorG',function(){
  37849. return this._emissionColor.y;
  37850. },function(value){
  37851. this._emissionColor.y=value;
  37852. this.emissionColor=this._emissionColor;
  37853. });
  37854. /**
  37855. *设置混合源。
  37856. *@param value 混合源
  37857. */
  37858. /**
  37859. *获取混合源。
  37860. *@return 混合源。
  37861. */
  37862. __getset(0,__proto,'blendSrc',function(){
  37863. return this._shaderValues.getInt(PBRSpecularMaterial.BLEND_SRC);
  37864. },function(value){
  37865. this._shaderValues.setInt(PBRSpecularMaterial.BLEND_SRC,value);
  37866. });
  37867. /**
  37868. *获取纹理平铺和偏移W分量。
  37869. *@param w 纹理平铺和偏移W分量。
  37870. */
  37871. /**
  37872. *获取纹理平铺和偏移W分量。
  37873. *@return 纹理平铺和偏移W分量。
  37874. */
  37875. __getset(0,__proto,'tilingOffsetW',function(){
  37876. return this._MainTex_STW;
  37877. },function(w){
  37878. this._MainTex_STW=w;
  37879. });
  37880. /**
  37881. *@private
  37882. */
  37883. /**
  37884. *@private
  37885. */
  37886. __getset(0,__proto,'_EmissionColorB',function(){
  37887. return this._emissionColor.z;
  37888. },function(value){
  37889. this._emissionColor.z=value;
  37890. this.emissionColor=this._emissionColor;
  37891. });
  37892. /**
  37893. *@private
  37894. */
  37895. /**
  37896. *@private
  37897. */
  37898. __getset(0,__proto,'_EmissionColorA',function(){
  37899. return this._emissionColor.w;
  37900. },function(value){
  37901. this._emissionColor.w=value;
  37902. this.emissionColor=this._emissionColor;
  37903. });
  37904. /**
  37905. *@private
  37906. */
  37907. /**
  37908. *@private
  37909. */
  37910. __getset(0,__proto,'_MainTex_STY',function(){
  37911. return this._shaderValues.getVector(PBRSpecularMaterial.TILINGOFFSET).y;
  37912. },function(y){
  37913. var tilOff=this._shaderValues.getVector(PBRSpecularMaterial.TILINGOFFSET);
  37914. tilOff.y=y;
  37915. this.tilingOffset=tilOff;
  37916. });
  37917. /**
  37918. *@private
  37919. */
  37920. /**
  37921. *@private
  37922. */
  37923. __getset(0,__proto,'_MainTex_STZ',function(){
  37924. return this._shaderValues.getVector(PBRSpecularMaterial.TILINGOFFSET).z;
  37925. },function(z){
  37926. var tilOff=this._shaderValues.getVector(PBRSpecularMaterial.TILINGOFFSET);
  37927. tilOff.z=z;
  37928. this.tilingOffset=tilOff;
  37929. });
  37930. /**
  37931. *@private
  37932. */
  37933. /**
  37934. *@private
  37935. */
  37936. __getset(0,__proto,'_Cutoff',function(){
  37937. return this.alphaTestValue;
  37938. },function(value){
  37939. this.alphaTestValue=value;
  37940. });
  37941. /**
  37942. *@private
  37943. */
  37944. /**
  37945. *@private
  37946. */
  37947. __getset(0,__proto,'_MainTex_STW',function(){
  37948. return this._shaderValues.getVector(PBRSpecularMaterial.TILINGOFFSET).w;
  37949. },function(w){
  37950. var tilOff=this._shaderValues.getVector(PBRSpecularMaterial.TILINGOFFSET);
  37951. tilOff.w=w;
  37952. this.tilingOffset=tilOff;
  37953. });
  37954. /**
  37955. *设置反射率颜色R分量。
  37956. *@param value 反射率颜色R分量。
  37957. */
  37958. /**
  37959. *获取反射率颜色R分量。
  37960. *@return 反射率颜色R分量。
  37961. */
  37962. __getset(0,__proto,'albedoColorR',function(){
  37963. return this._ColorR;
  37964. },function(value){
  37965. this._ColorR=value;
  37966. });
  37967. /**
  37968. *设置反射率颜色G分量。
  37969. *@param value 反射率颜色G分量。
  37970. */
  37971. /**
  37972. *获取反射率颜色G分量。
  37973. *@return 反射率颜色G分量。
  37974. */
  37975. __getset(0,__proto,'albedoColorG',function(){
  37976. return this._ColorG;
  37977. },function(value){
  37978. this._ColorG=value;
  37979. });
  37980. /**
  37981. *获取纹理平铺和偏移X分量。
  37982. *@param x 纹理平铺和偏移X分量。
  37983. */
  37984. /**
  37985. *获取纹理平铺和偏移X分量。
  37986. *@return 纹理平铺和偏移X分量。
  37987. */
  37988. __getset(0,__proto,'tilingOffsetX',function(){
  37989. return this._MainTex_STX;
  37990. },function(x){
  37991. this._MainTex_STX=x;
  37992. });
  37993. /**
  37994. *设置反射率颜色。
  37995. *@param value 反射率颜色。
  37996. */
  37997. /**
  37998. *获取反射率颜色。
  37999. *@return 反射率颜色。
  38000. */
  38001. __getset(0,__proto,'albedoColor',function(){
  38002. return this._albedoColor;
  38003. },function(value){
  38004. this._albedoColor=value;
  38005. this._shaderValues.setVector(PBRSpecularMaterial.ALBEDOCOLOR,value);
  38006. });
  38007. /**
  38008. *设置漫反射贴图。
  38009. *@param value 漫反射贴图。
  38010. */
  38011. /**
  38012. *获取漫反射贴图。
  38013. *@return 漫反射贴图。
  38014. */
  38015. __getset(0,__proto,'albedoTexture',function(){
  38016. return this._shaderValues.getTexture(PBRSpecularMaterial.ALBEDOTEXTURE);
  38017. },function(value){
  38018. if (value){
  38019. this._defineDatas.add(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_ALBEDOTEXTURE);
  38020. }else {
  38021. this._defineDatas.remove(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_ALBEDOTEXTURE);
  38022. }
  38023. this._shaderValues.setTexture(PBRSpecularMaterial.ALBEDOTEXTURE,value);
  38024. });
  38025. /**
  38026. *设置剔除方式。
  38027. *@param value 剔除方式。
  38028. */
  38029. /**
  38030. *获取剔除方式。
  38031. *@return 剔除方式。
  38032. */
  38033. __getset(0,__proto,'cull',function(){
  38034. return this._shaderValues.getInt(PBRSpecularMaterial.CULL);
  38035. },function(value){
  38036. this._shaderValues.setInt(PBRSpecularMaterial.CULL,value);
  38037. });
  38038. /**
  38039. *设置视差贴图。
  38040. *@param value 视察贴图。
  38041. */
  38042. /**
  38043. *获取视差贴图。
  38044. *@return 视察贴图。
  38045. */
  38046. __getset(0,__proto,'parallaxTexture',function(){
  38047. return this._shaderValues.getTexture(PBRSpecularMaterial.PARALLAXTEXTURE);
  38048. },function(value){
  38049. if (value){
  38050. this._defineDatas.add(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_PARALLAXTEXTURE);
  38051. }else {
  38052. this._defineDatas.remove(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_PARALLAXTEXTURE);
  38053. }
  38054. this._shaderValues.setTexture(PBRSpecularMaterial.PARALLAXTEXTURE,value);
  38055. });
  38056. /**
  38057. *设置法线贴图。
  38058. *@param value 法线贴图。
  38059. */
  38060. /**
  38061. *获取法线贴图。
  38062. *@return 法线贴图。
  38063. */
  38064. __getset(0,__proto,'normalTexture',function(){
  38065. return this._shaderValues.getTexture(PBRSpecularMaterial.NORMALTEXTURE);
  38066. },function(value){
  38067. if (value){
  38068. this._defineDatas.add(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_NORMALTEXTURE);
  38069. }else {
  38070. this._defineDatas.remove(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_NORMALTEXTURE);
  38071. }
  38072. this._shaderValues.setTexture(PBRSpecularMaterial.NORMALTEXTURE,value);
  38073. });
  38074. /**
  38075. *设置放射颜色。
  38076. *@param value 放射颜色。
  38077. */
  38078. /**
  38079. *获取放射颜色。
  38080. *@return 放射颜色。
  38081. */
  38082. __getset(0,__proto,'emissionColor',function(){
  38083. return this._shaderValues.getVector(PBRSpecularMaterial.EMISSIONCOLOR);
  38084. },function(value){
  38085. this._shaderValues.setVector(PBRSpecularMaterial.EMISSIONCOLOR,value);
  38086. });
  38087. /**
  38088. *设置视差贴图缩放系数。
  38089. *@param value 视差缩放系数。
  38090. */
  38091. /**
  38092. *获取视差贴图缩放系数。
  38093. *@return 视差缩放系数。
  38094. */
  38095. __getset(0,__proto,'parallaxTextureScale',function(){
  38096. return this._Parallax;
  38097. },function(value){
  38098. this._Parallax=Math.max(0.005,Math.min(0.08,value));
  38099. });
  38100. /**
  38101. *设置法线贴图缩放系数。
  38102. *@param value 法线贴图缩放系数。
  38103. */
  38104. /**
  38105. *获取法线贴图缩放系数。
  38106. *@return 法线贴图缩放系数。
  38107. */
  38108. __getset(0,__proto,'normalTextureScale',function(){
  38109. return this._BumpScale;
  38110. },function(value){
  38111. this._BumpScale=value;
  38112. });
  38113. /**
  38114. *获取纹理平铺和偏移Z分量。
  38115. *@param z 纹理平铺和偏移Z分量。
  38116. */
  38117. /**
  38118. *获取纹理平铺和偏移Z分量。
  38119. *@return 纹理平铺和偏移Z分量。
  38120. */
  38121. __getset(0,__proto,'tilingOffsetZ',function(){
  38122. return this._MainTex_STZ;
  38123. },function(z){
  38124. this._MainTex_STZ=z;
  38125. });
  38126. /**
  38127. *设置遮挡贴图。
  38128. *@param value 遮挡贴图。
  38129. */
  38130. /**
  38131. *获取遮挡贴图。
  38132. *@return 遮挡贴图。
  38133. */
  38134. __getset(0,__proto,'occlusionTexture',function(){
  38135. return this._shaderValues.getTexture(PBRSpecularMaterial.OCCLUSIONTEXTURE);
  38136. },function(value){
  38137. if (value){
  38138. this._defineDatas.add(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_OCCLUSIONTEXTURE);
  38139. }else {
  38140. this._defineDatas.remove(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_OCCLUSIONTEXTURE);
  38141. }
  38142. this._shaderValues.setTexture(PBRSpecularMaterial.OCCLUSIONTEXTURE,value);
  38143. });
  38144. /**
  38145. *设置遮挡贴图强度。
  38146. *@param value 遮挡贴图强度,范围为0到1。
  38147. */
  38148. /**
  38149. *获取遮挡贴图强度。
  38150. *@return 遮挡贴图强度,范围为0到1。
  38151. */
  38152. __getset(0,__proto,'occlusionTextureStrength',function(){
  38153. return this._OcclusionStrength;
  38154. },function(value){
  38155. this._OcclusionStrength=Math.max(0.0,Math.min(1.0,value));
  38156. });
  38157. /**
  38158. *设置高光贴图。
  38159. *@param value 高光贴图。
  38160. */
  38161. /**
  38162. *获取高光贴图。
  38163. *@return 高光贴图。
  38164. */
  38165. __getset(0,__proto,'specularTexture',function(){
  38166. return this._shaderValues.getTexture(PBRSpecularMaterial.SPECULARTEXTURE);
  38167. },function(value){
  38168. if (value){
  38169. this._defineDatas.add(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_SPECULARTEXTURE);
  38170. }else {
  38171. this._defineDatas.remove(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_SPECULARTEXTURE);
  38172. }
  38173. this._shaderValues.setTexture(PBRSpecularMaterial.SPECULARTEXTURE,value);
  38174. });
  38175. /**
  38176. *设置高光颜色R分量。
  38177. *@param value 高光颜色R分量。
  38178. */
  38179. /**
  38180. *获取高光颜色R分量。
  38181. *@return 高光颜色R分量。
  38182. */
  38183. __getset(0,__proto,'specularColorR',function(){
  38184. return this._SpecColorR;
  38185. },function(value){
  38186. this._SpecColorR=value;
  38187. });
  38188. /**
  38189. *设置光滑度。
  38190. *@param value 光滑度,范围为0到1。
  38191. */
  38192. /**
  38193. *获取光滑度。
  38194. *@return 光滑度,范围为0到1。
  38195. */
  38196. __getset(0,__proto,'smoothness',function(){
  38197. return this._Glossiness;
  38198. },function(value){
  38199. this._Glossiness=Math.max(0.0,Math.min(1.0,value));
  38200. });
  38201. /**
  38202. *设置高光颜色G分量。
  38203. *@param value 高光颜色G分量。
  38204. */
  38205. /**
  38206. *获取高光颜色G分量。
  38207. *@return 高光颜色G分量。
  38208. */
  38209. __getset(0,__proto,'specularColorG',function(){
  38210. return this._SpecColorG;
  38211. },function(value){
  38212. this._SpecColorG=value;
  38213. });
  38214. /**
  38215. *设置高光颜色B分量。
  38216. *@param value 高光颜色B分量。
  38217. */
  38218. /**
  38219. *获取高光颜色B分量。
  38220. *@return 高光颜色B分量。
  38221. */
  38222. __getset(0,__proto,'specularColorB',function(){
  38223. return this._SpecColorB;
  38224. },function(value){
  38225. this._SpecColorB=value;
  38226. });
  38227. /**
  38228. *设置高光颜色A分量。
  38229. *@param value 高光颜色A分量。
  38230. */
  38231. /**
  38232. *获取高光颜色A分量。
  38233. *@return 高光颜色A分量。
  38234. */
  38235. __getset(0,__proto,'specularColorA',function(){
  38236. return this._SpecColorA;
  38237. },function(value){
  38238. this._SpecColorA=value;
  38239. });
  38240. /**
  38241. *设置混合目标。
  38242. *@param value 混合目标
  38243. */
  38244. /**
  38245. *获取混合目标。
  38246. *@return 混合目标。
  38247. */
  38248. __getset(0,__proto,'blendDst',function(){
  38249. return this._shaderValues.getInt(PBRSpecularMaterial.BLEND_DST);
  38250. },function(value){
  38251. this._shaderValues.setInt(PBRSpecularMaterial.BLEND_DST,value);
  38252. });
  38253. /**
  38254. *设置光滑度缩放系数。
  38255. *@param value 光滑度缩放系数,范围为0到1。
  38256. */
  38257. /**
  38258. *获取光滑度缩放系数。
  38259. *@return 光滑度缩放系数,范围为0到1。
  38260. */
  38261. __getset(0,__proto,'smoothnessTextureScale',function(){
  38262. return this._GlossMapScale;
  38263. },function(value){
  38264. this._GlossMapScale=Math.max(0.0,Math.min(1.0,value));
  38265. });
  38266. /**
  38267. *设置是否写入深度。
  38268. *@param value 是否写入深度。
  38269. */
  38270. /**
  38271. *获取是否写入深度。
  38272. *@return 是否写入深度。
  38273. */
  38274. __getset(0,__proto,'depthWrite',function(){
  38275. return this._shaderValues.getBool(PBRSpecularMaterial.DEPTH_WRITE);
  38276. },function(value){
  38277. this._shaderValues.setBool(PBRSpecularMaterial.DEPTH_WRITE,value);
  38278. });
  38279. /**
  38280. *设置光滑度数据源。
  38281. *@param value 光滑滑度数据源,0或1。
  38282. */
  38283. /**
  38284. *获取光滑度数据源
  38285. *@return 光滑滑度数据源,0或1。
  38286. */
  38287. __getset(0,__proto,'smoothnessSource',function(){
  38288. return this._shaderValues.getInt(PBRSpecularMaterial.SMOOTHNESSSOURCE);
  38289. },function(value){
  38290. if (value){
  38291. this._defineDatas.add(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA);
  38292. this._shaderValues.setInt(PBRSpecularMaterial.SMOOTHNESSSOURCE,1);
  38293. }else {
  38294. this._defineDatas.remove(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA);
  38295. this._shaderValues.setInt(PBRSpecularMaterial.SMOOTHNESSSOURCE,0);
  38296. }
  38297. });
  38298. /**
  38299. *设置是否激活放射属性。
  38300. *@param value 是否激活放射属性
  38301. */
  38302. /**
  38303. *获取是否激活放射属性。
  38304. *@return 是否激活放射属性。
  38305. */
  38306. __getset(0,__proto,'enableEmission',function(){
  38307. return this._shaderValues.getBool(PBRSpecularMaterial.ENABLEEMISSION);
  38308. },function(value){
  38309. if (value)
  38310. this._defineDatas.add(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_EMISSION);
  38311. else {
  38312. this._defineDatas.remove(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_EMISSION);
  38313. }
  38314. this._shaderValues.setBool(PBRSpecularMaterial.ENABLEEMISSION,value);
  38315. });
  38316. /**
  38317. *设置是否开启反射。
  38318. *@param value 是否开启反射。
  38319. */
  38320. /**
  38321. *获取是否开启反射。
  38322. *@return 是否开启反射。
  38323. */
  38324. __getset(0,__proto,'enableReflection',function(){
  38325. return this._shaderValues.getBool(PBRSpecularMaterial.ENABLEREFLECT);
  38326. },function(value){
  38327. this._shaderValues.setBool(PBRSpecularMaterial.ENABLEREFLECT,true);
  38328. if (value)
  38329. this._disablePublicDefineDatas.remove(Scene3D.SHADERDEFINE_REFLECTMAP);
  38330. else
  38331. this._disablePublicDefineDatas.add(Scene3D.SHADERDEFINE_REFLECTMAP);
  38332. });
  38333. /**
  38334. *获取纹理平铺和偏移Y分量。
  38335. *@param y 纹理平铺和偏移Y分量。
  38336. */
  38337. /**
  38338. *获取纹理平铺和偏移Y分量。
  38339. *@return 纹理平铺和偏移Y分量。
  38340. */
  38341. __getset(0,__proto,'tilingOffsetY',function(){
  38342. return this._MainTex_STY;
  38343. },function(y){
  38344. this._MainTex_STY=y;
  38345. });
  38346. /**
  38347. *设置混合方式。
  38348. *@param value 混合方式。
  38349. */
  38350. /**
  38351. *获取混合方式。
  38352. *@return 混合方式。
  38353. */
  38354. __getset(0,__proto,'blend',function(){
  38355. return this._shaderValues.getInt(PBRSpecularMaterial.BLEND);
  38356. },function(value){
  38357. this._shaderValues.setInt(PBRSpecularMaterial.BLEND,value);
  38358. });
  38359. /**
  38360. *设置深度测试方式。
  38361. *@param value 深度测试方式
  38362. */
  38363. /**
  38364. *获取深度测试方式。
  38365. *@return 深度测试方式。
  38366. */
  38367. __getset(0,__proto,'depthTest',function(){
  38368. return this._shaderValues.getInt(PBRSpecularMaterial.DEPTH_TEST);
  38369. },function(value){
  38370. this._shaderValues.setInt(PBRSpecularMaterial.DEPTH_TEST,value);
  38371. });
  38372. PBRSpecularMaterial.__init__=function(){
  38373. PBRSpecularMaterial.SHADERDEFINE_ALBEDOTEXTURE=PBRSpecularMaterial.shaderDefines.registerDefine("ALBEDOTEXTURE");
  38374. PBRSpecularMaterial.SHADERDEFINE_SPECULARTEXTURE=PBRSpecularMaterial.shaderDefines.registerDefine("SPECULARTEXTURE");
  38375. PBRSpecularMaterial.SHADERDEFINE_SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA=PBRSpecularMaterial.shaderDefines.registerDefine("SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA");
  38376. PBRSpecularMaterial.SHADERDEFINE_NORMALTEXTURE=PBRSpecularMaterial.shaderDefines.registerDefine("NORMALTEXTURE");
  38377. PBRSpecularMaterial.SHADERDEFINE_PARALLAXTEXTURE=PBRSpecularMaterial.shaderDefines.registerDefine("PARALLAXTEXTURE");
  38378. PBRSpecularMaterial.SHADERDEFINE_OCCLUSIONTEXTURE=PBRSpecularMaterial.shaderDefines.registerDefine("OCCLUSIONTEXTURE");
  38379. PBRSpecularMaterial.SHADERDEFINE_EMISSION=PBRSpecularMaterial.shaderDefines.registerDefine("EMISSION");
  38380. PBRSpecularMaterial.SHADERDEFINE_EMISSIONTEXTURE=PBRSpecularMaterial.shaderDefines.registerDefine("EMISSIONTEXTURE");
  38381. PBRSpecularMaterial.SHADERDEFINE_TILINGOFFSET=PBRSpecularMaterial.shaderDefines.registerDefine("TILINGOFFSET");
  38382. PBRSpecularMaterial.SHADERDEFINE_ALPHAPREMULTIPLY=PBRSpecularMaterial.shaderDefines.registerDefine("ALPHAPREMULTIPLY");
  38383. }
  38384. PBRSpecularMaterial.SmoothnessSource_SpecularTexture_Alpha=0;
  38385. PBRSpecularMaterial.SmoothnessSource_AlbedoTexture_Alpha=1;
  38386. PBRSpecularMaterial.RENDERMODE_OPAQUE=0;
  38387. PBRSpecularMaterial.RENDERMODE_CUTOUT=1;
  38388. PBRSpecularMaterial.RENDERMODE_FADE=2;
  38389. PBRSpecularMaterial.RENDERMODE_TRANSPARENT=3;
  38390. PBRSpecularMaterial.SHADERDEFINE_ALBEDOTEXTURE=0;
  38391. PBRSpecularMaterial.SHADERDEFINE_NORMALTEXTURE=0;
  38392. PBRSpecularMaterial.SHADERDEFINE_SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA=0;
  38393. PBRSpecularMaterial.SHADERDEFINE_SPECULARTEXTURE=0;
  38394. PBRSpecularMaterial.SHADERDEFINE_OCCLUSIONTEXTURE=0;
  38395. PBRSpecularMaterial.SHADERDEFINE_PARALLAXTEXTURE=0;
  38396. PBRSpecularMaterial.SHADERDEFINE_EMISSION=0;
  38397. PBRSpecularMaterial.SHADERDEFINE_EMISSIONTEXTURE=0;
  38398. PBRSpecularMaterial.SHADERDEFINE_TILINGOFFSET=0;
  38399. PBRSpecularMaterial.SHADERDEFINE_ALPHAPREMULTIPLY=0;
  38400. PBRSpecularMaterial.SMOOTHNESSSOURCE=-1;
  38401. PBRSpecularMaterial.ENABLEEMISSION=-1;
  38402. PBRSpecularMaterial.ENABLEREFLECT=-1;
  38403. __static(PBRSpecularMaterial,
  38404. ['ALBEDOTEXTURE',function(){return this.ALBEDOTEXTURE=Shader3D.propertyNameToID("u_AlbedoTexture");},'SPECULARTEXTURE',function(){return this.SPECULARTEXTURE=Shader3D.propertyNameToID("u_SpecularTexture");},'NORMALTEXTURE',function(){return this.NORMALTEXTURE=Shader3D.propertyNameToID("u_NormalTexture");},'PARALLAXTEXTURE',function(){return this.PARALLAXTEXTURE=Shader3D.propertyNameToID("u_ParallaxTexture");},'OCCLUSIONTEXTURE',function(){return this.OCCLUSIONTEXTURE=Shader3D.propertyNameToID("u_OcclusionTexture");},'EMISSIONTEXTURE',function(){return this.EMISSIONTEXTURE=Shader3D.propertyNameToID("u_EmissionTexture");},'ALBEDOCOLOR',function(){return this.ALBEDOCOLOR=Shader3D.propertyNameToID("u_AlbedoColor");},'SPECULARCOLOR',function(){return this.SPECULARCOLOR=Shader3D.propertyNameToID("u_SpecularColor");},'EMISSIONCOLOR',function(){return this.EMISSIONCOLOR=Shader3D.propertyNameToID("u_EmissionColor");},'SMOOTHNESS',function(){return this.SMOOTHNESS=Shader3D.propertyNameToID("u_smoothness");},'SMOOTHNESSSCALE',function(){return this.SMOOTHNESSSCALE=Shader3D.propertyNameToID("u_smoothnessScale");},'OCCLUSIONSTRENGTH',function(){return this.OCCLUSIONSTRENGTH=Shader3D.propertyNameToID("u_occlusionStrength");},'NORMALSCALE',function(){return this.NORMALSCALE=Shader3D.propertyNameToID("u_normalScale");},'PARALLAXSCALE',function(){return this.PARALLAXSCALE=Shader3D.propertyNameToID("u_parallaxScale");},'TILINGOFFSET',function(){return this.TILINGOFFSET=Shader3D.propertyNameToID("u_TilingOffset");},'CULL',function(){return this.CULL=Shader3D.propertyNameToID("s_Cull");},'BLEND',function(){return this.BLEND=Shader3D.propertyNameToID("s_Blend");},'BLEND_SRC',function(){return this.BLEND_SRC=Shader3D.propertyNameToID("s_BlendSrc");},'BLEND_DST',function(){return this.BLEND_DST=Shader3D.propertyNameToID("s_BlendDst");},'DEPTH_TEST',function(){return this.DEPTH_TEST=Shader3D.propertyNameToID("s_DepthTest");},'DEPTH_WRITE',function(){return this.DEPTH_WRITE=Shader3D.propertyNameToID("s_DepthWrite");},'defaultMaterial',function(){return this.defaultMaterial=new PBRSpecularMaterial();},'shaderDefines',function(){return this.shaderDefines=new ShaderDefines(BaseMaterial.shaderDefines);}
  38405. ]);
  38406. return PBRSpecularMaterial;
  38407. })(BaseMaterial)
  38408. /**
  38409. *<code>Rigidbody3D</code> 类用于创建刚体碰撞器。
  38410. */
  38411. //class laya.d3.physics.Rigidbody3D extends laya.d3.physics.PhysicsTriggerComponent
  38412. var Rigidbody3D=(function(_super){
  38413. function Rigidbody3D(collisionGroup,canCollideWith){
  38414. /**@private */
  38415. //this._nativeMotionState=null;
  38416. /**@private */
  38417. this._isKinematic=false;
  38418. /**@private */
  38419. this._mass=1.0;
  38420. /**@private */
  38421. this._angularDamping=0.0;
  38422. /**@private */
  38423. this._linearDamping=0.0;
  38424. /**@private */
  38425. this._overrideGravity=false;
  38426. /**@private */
  38427. this._detectCollisions=true;
  38428. this._gravity=new Vector3(0,-10,0);
  38429. this._totalTorque=new Vector3(0,0,0);
  38430. this._linearVelocity=new Vector3();
  38431. this._angularVelocity=new Vector3();
  38432. this._linearFactor=new Vector3(1,1,1);
  38433. this._angularFactor=new Vector3(1,1,1);
  38434. (collisionGroup===void 0)&& (collisionGroup=/*laya.d3.utils.Physics3DUtils.COLLISIONFILTERGROUP_DEFAULTFILTER*/0x1);
  38435. (canCollideWith===void 0)&& (canCollideWith=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  38436. Rigidbody3D.__super.call(this,collisionGroup,canCollideWith);
  38437. }
  38438. __class(Rigidbody3D,'laya.d3.physics.Rigidbody3D',_super);
  38439. var __proto=Rigidbody3D.prototype;
  38440. /**
  38441. *@private
  38442. */
  38443. __proto._updateMass=function(mass){
  38444. if (this._nativeColliderObject && this._colliderShape){
  38445. this._colliderShape._nativeShape.calculateLocalInertia(mass,Rigidbody3D._nativeInertia);
  38446. this._nativeColliderObject.setMassProps(mass,Rigidbody3D._nativeInertia);
  38447. this._nativeColliderObject.updateInertiaTensor();
  38448. }
  38449. }
  38450. /**
  38451. *@private
  38452. *Dynamic刚体,初始化时调用一次。
  38453. *Kinematic刚体,每次物理tick时调用(如果未进入睡眠状态),让物理引擎知道刚体位置。
  38454. */
  38455. __proto._delegateMotionStateGetWorldTransform=function(worldTransPointer){}
  38456. /**
  38457. *@private
  38458. *Dynamic刚体,物理引擎每帧调用一次,用于更新渲染矩阵。
  38459. */
  38460. __proto._delegateMotionStateSetWorldTransform=function(worldTransPointer){
  38461. var rigidBody=/*__JS__ */this._rigidbody;
  38462. rigidBody._simulation._updatedRigidbodies++;
  38463. var physics3D=Laya3D._physics3D;
  38464. var worldTrans=physics3D.wrapPointer(worldTransPointer,physics3D.btTransform);
  38465. rigidBody._updateTransformComponent(worldTrans);
  38466. }
  38467. /**
  38468. *@private
  38469. *Dynamic刚体,初始化时调用一次。
  38470. *Kinematic刚体,每次物理tick时调用(如果未进入睡眠状态),让物理引擎知道刚体位置。
  38471. *该函数只有在runtime下调用
  38472. */
  38473. __proto._delegateMotionStateGetWorldTransformNative=function(ridgidBody3D,worldTransPointer){}
  38474. /**
  38475. *@private
  38476. *Dynamic刚体,物理引擎每帧调用一次,用于更新渲染矩阵。
  38477. *该函数只有在runtime下调用
  38478. */
  38479. __proto._delegateMotionStateSetWorldTransformNative=function(rigidBody3D,worldTransPointer){
  38480. var rigidBody=rigidBody3D;
  38481. rigidBody._simulation._updatedRigidbodies++;
  38482. var physics3D=Laya3D._physics3D;
  38483. var worldTrans=physics3D.wrapPointer(worldTransPointer,physics3D.btTransform);
  38484. rigidBody._updateTransformComponent(worldTrans);
  38485. }
  38486. /**
  38487. *@inheritDoc
  38488. */
  38489. __proto._onScaleChange=function(scale){
  38490. laya.d3.physics.PhysicsComponent.prototype._onScaleChange.call(this,scale);
  38491. this._updateMass(this._isKinematic ? 0 :this._mass);
  38492. }
  38493. /**
  38494. *@private
  38495. */
  38496. __proto._delegateMotionStateClear=function(){
  38497. /*__JS__ */this._rigidbody=null;
  38498. }
  38499. /**
  38500. *@inheritDoc
  38501. */
  38502. __proto._onAdded=function(){
  38503. var physics3D=Laya3D._physics3D;
  38504. var motionState=new physics3D.LayaMotionState();
  38505. var isConchApp=/*__JS__ */(window.conch !=null);
  38506. if (isConchApp && physics3D.LayaMotionState.prototype.setRigidbody){
  38507. motionState.setRigidbody(this);
  38508. motionState.setNativeGetWorldTransform(this._delegateMotionStateGetWorldTransformNative);
  38509. motionState.setNativeSetWorldTransform(this._delegateMotionStateSetWorldTransformNative);
  38510. }else {
  38511. motionState.getWorldTransform=this._delegateMotionStateGetWorldTransform;
  38512. motionState.setWorldTransform=this._delegateMotionStateSetWorldTransform;
  38513. }
  38514. motionState.clear=this._delegateMotionStateClear;
  38515. motionState._rigidbody=this;
  38516. this._nativeMotionState=motionState;
  38517. var constructInfo=new physics3D.btRigidBodyConstructionInfo(0.0,motionState,null,Rigidbody3D._nativeVector3Zero);
  38518. var btRigid=new physics3D.btRigidBody(constructInfo);
  38519. btRigid.setUserIndex(this.id);
  38520. this._nativeColliderObject=btRigid;
  38521. _super.prototype._onAdded.call(this);
  38522. this.mass=this._mass;
  38523. this.linearFactor=this._linearFactor;
  38524. this.angularFactor=this._angularFactor;
  38525. this.linearDamping=this._linearDamping;
  38526. this.angularDamping=this._angularDamping;
  38527. this.overrideGravity=this._overrideGravity;
  38528. this.gravity=this._gravity;
  38529. this.isKinematic=this._isKinematic;
  38530. physics3D.destroy(constructInfo);
  38531. }
  38532. /**
  38533. *@inheritDoc
  38534. */
  38535. __proto._onShapeChange=function(colShape){
  38536. laya.d3.physics.PhysicsComponent.prototype._onShapeChange.call(this,colShape);
  38537. if (this._isKinematic){
  38538. this._updateMass(0);
  38539. }else {
  38540. this._nativeColliderObject.setCenterOfMassTransform(this._nativeColliderObject.getWorldTransform());
  38541. this._updateMass(this._mass);
  38542. }
  38543. }
  38544. /**
  38545. *@inheritDoc
  38546. */
  38547. __proto._parse=function(data){
  38548. (data.friction !=null)&& (this.friction=data.friction);
  38549. (data.rollingFriction !=null)&& (this.rollingFriction=data.rollingFriction);
  38550. (data.restitution !=null)&& (this.restitution=data.restitution);
  38551. (data.isTrigger !=null)&& (this.isTrigger=data.isTrigger);
  38552. (data.mass !=null)&& (this.mass=data.mass);
  38553. (data.isKinematic !=null)&& (this.isKinematic=data.isKinematic);
  38554. (data.linearDamping !=null)&& (this.linearDamping=data.linearDamping);
  38555. (data.angularDamping !=null)&& (this.angularDamping=data.angularDamping);
  38556. (data.overrideGravity !=null)&& (this.overrideGravity=data.overrideGravity);
  38557. if (data.gravity){
  38558. this.gravity.fromArray(data.gravity);
  38559. this.gravity=this.gravity;
  38560. }
  38561. laya.d3.physics.PhysicsComponent.prototype._parse.call(this,data);
  38562. this._parseShape(data.shapes);
  38563. }
  38564. /**
  38565. *@inheritDoc
  38566. */
  38567. __proto._onDestroy=function(){
  38568. var physics3D=Laya3D._physics3D;
  38569. this._nativeMotionState.clear();
  38570. physics3D.destroy(this._nativeMotionState);
  38571. laya.d3.physics.PhysicsComponent.prototype._onDestroy.call(this);
  38572. this._nativeMotionState=null;
  38573. this._gravity=null;
  38574. this._totalTorque=null;
  38575. this._linearVelocity=null;
  38576. this._angularVelocity=null;
  38577. this._linearFactor=null;
  38578. this._angularFactor=null;
  38579. }
  38580. /**
  38581. *@inheritDoc
  38582. */
  38583. __proto._addToSimulation=function(){
  38584. this._simulation._addRigidBody(this,this._collisionGroup,this._detectCollisions ? this._canCollideWith :0);
  38585. }
  38586. /**
  38587. *@inheritDoc
  38588. */
  38589. __proto._removeFromSimulation=function(){
  38590. this._simulation._removeRigidBody(this);
  38591. }
  38592. /**
  38593. *@inheritDoc
  38594. */
  38595. __proto._cloneTo=function(dest){
  38596. _super.prototype._cloneTo.call(this,dest);
  38597. var destRigidbody3D=dest;
  38598. destRigidbody3D.isKinematic=this._isKinematic;
  38599. destRigidbody3D.mass=this._mass;
  38600. destRigidbody3D.gravity=this._gravity;
  38601. destRigidbody3D.angularDamping=this._angularDamping;
  38602. destRigidbody3D.linearDamping=this._linearDamping;
  38603. destRigidbody3D.overrideGravity=this._overrideGravity;
  38604. destRigidbody3D.linearVelocity=this._linearVelocity;
  38605. destRigidbody3D.angularVelocity=this._angularVelocity;
  38606. destRigidbody3D.linearFactor=this._linearFactor;
  38607. destRigidbody3D.angularFactor=this._angularFactor;
  38608. destRigidbody3D.detectCollisions=this._detectCollisions;
  38609. }
  38610. /**
  38611. *应用作用力。
  38612. *@param force 作用力。
  38613. *@param localOffset 偏移,如果为null则为中心点
  38614. */
  38615. __proto.applyForce=function(force,localOffset){
  38616. if (this._nativeColliderObject==null)
  38617. throw "Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";
  38618. var nativeForce=Rigidbody3D._nativeTempVector30;
  38619. nativeForce.setValue(-force.x,force.y,force.z);
  38620. if (localOffset){
  38621. var nativeOffset=Rigidbody3D._nativeTempVector31;
  38622. nativeOffset.setValue(-localOffset.x,localOffset.y,localOffset.z);
  38623. this._nativeColliderObject.applyForce(nativeForce,nativeOffset);
  38624. }else {
  38625. this._nativeColliderObject.applyCentralForce(nativeForce);
  38626. }
  38627. }
  38628. /**
  38629. *应用扭转力。
  38630. *@param torque 扭转力。
  38631. */
  38632. __proto.applyTorque=function(torque){
  38633. if (this._nativeColliderObject==null)
  38634. throw "Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";
  38635. var nativeTorque=Rigidbody3D._nativeTempVector30;
  38636. nativeTorque.setValue(-torque.x,torque.y,torque.z);
  38637. this._nativeColliderObject.applyTorque(nativeTorque);
  38638. }
  38639. /**
  38640. *应用冲量。
  38641. *@param impulse 冲量。
  38642. *@param localOffset 偏移,如果为null则为中心点。
  38643. */
  38644. __proto.applyImpulse=function(impulse,localOffset){
  38645. if (this._nativeColliderObject==null)
  38646. throw "Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";
  38647. Rigidbody3D._nativeImpulse.setValue(-impulse.x,impulse.y,impulse.z);
  38648. if (localOffset){
  38649. Rigidbody3D._nativeImpulseOffset.setValue(-localOffset.x,localOffset.y,localOffset.z);
  38650. this._nativeColliderObject.applyImpulse(Rigidbody3D._nativeImpulse,Rigidbody3D._nativeImpulseOffset);
  38651. }else {
  38652. this._nativeColliderObject.applyCentralImpulse(Rigidbody3D._nativeImpulse);
  38653. }
  38654. }
  38655. /**
  38656. *应用扭转冲量。
  38657. *@param torqueImpulse
  38658. */
  38659. __proto.applyTorqueImpulse=function(torqueImpulse){
  38660. if (this._nativeColliderObject==null)
  38661. throw "Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";
  38662. var nativeTorqueImpulse=Rigidbody3D._nativeTempVector30;
  38663. nativeTorqueImpulse.setValue(-torqueImpulse.x,torqueImpulse.y,torqueImpulse.z);
  38664. this._nativeColliderObject.applyTorqueImpulse(nativeTorqueImpulse);
  38665. }
  38666. /**
  38667. *唤醒刚体。
  38668. */
  38669. __proto.wakeUp=function(){
  38670. this._nativeColliderObject && (this._nativeColliderObject.activate(false));
  38671. }
  38672. /**
  38673. *清除应用到刚体上的所有力。
  38674. */
  38675. __proto.clearForces=function(){
  38676. var rigidBody=this._nativeColliderObject;
  38677. if (rigidBody==null)
  38678. throw "Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";
  38679. rigidBody.clearForces();
  38680. var nativeZero=Rigidbody3D._nativeVector3Zero;
  38681. rigidBody.setInterpolationAngularVelocity(nativeZero);
  38682. rigidBody.setLinearVelocity(nativeZero);
  38683. rigidBody.setInterpolationAngularVelocity(nativeZero);
  38684. rigidBody.setAngularVelocity(nativeZero);
  38685. }
  38686. /**
  38687. *设置刚体的角阻力。
  38688. *@param value 角阻力。
  38689. */
  38690. /**
  38691. *获取刚体的角阻力。
  38692. *@return 角阻力。
  38693. */
  38694. __getset(0,__proto,'angularDamping',function(){
  38695. return this._angularDamping;
  38696. },function(value){
  38697. this._angularDamping=value;
  38698. if (this._nativeColliderObject)
  38699. this._nativeColliderObject.setDamping(this._linearDamping,value);
  38700. });
  38701. /**
  38702. *设置质量。
  38703. *@param value 质量。
  38704. */
  38705. /**
  38706. *获取质量。
  38707. *@return 质量。
  38708. */
  38709. __getset(0,__proto,'mass',function(){
  38710. return this._mass;
  38711. },function(value){
  38712. value=Math.max(value,1e-07);
  38713. this._mass=value;
  38714. (this._isKinematic)|| (this._updateMass(value));
  38715. });
  38716. /**
  38717. *设置刚体的线阻力。
  38718. *@param value 线阻力。
  38719. */
  38720. /**
  38721. *获取刚体的线阻力。
  38722. *@return 线阻力。
  38723. */
  38724. __getset(0,__proto,'linearDamping',function(){
  38725. return this._linearDamping;
  38726. },function(value){
  38727. this._linearDamping=value;
  38728. if (this._nativeColliderObject)
  38729. this._nativeColliderObject.setDamping(value,this._angularDamping);
  38730. });
  38731. /**
  38732. *设置是否为运动物体,如果为true仅可通过transform属性移动物体,而非其他力相关属性。
  38733. *@param value 是否为运动物体。
  38734. */
  38735. /**
  38736. *获取是否为运动物体,如果为true仅可通过transform属性移动物体,而非其他力相关属性。
  38737. *@return 是否为运动物体。
  38738. */
  38739. __getset(0,__proto,'isKinematic',function(){
  38740. return this._isKinematic;
  38741. },function(value){
  38742. this._isKinematic=value;
  38743. var canInSimulation=!!(this._simulation && this._enabled && this._colliderShape);
  38744. canInSimulation && this._removeFromSimulation();
  38745. var natColObj=this._nativeColliderObject;
  38746. var flags=natColObj.getCollisionFlags();
  38747. if (value){
  38748. flags=flags | 2;
  38749. natColObj.setCollisionFlags(flags);
  38750. this._nativeColliderObject.forceActivationState(4);
  38751. this._enableProcessCollisions=false;
  38752. this._updateMass(0);
  38753. }else {
  38754. if ((flags & 2)> 0)
  38755. flags=flags ^ 2;
  38756. natColObj.setCollisionFlags(flags);
  38757. this._nativeColliderObject.setActivationState(1);
  38758. this._enableProcessCollisions=true;
  38759. this._updateMass(this._mass);
  38760. };
  38761. var nativeZero=Rigidbody3D._nativeVector3Zero;
  38762. natColObj.setInterpolationLinearVelocity(nativeZero);
  38763. natColObj.setLinearVelocity(nativeZero);
  38764. natColObj.setInterpolationAngularVelocity(nativeZero);
  38765. natColObj.setAngularVelocity(nativeZero);
  38766. canInSimulation && this._addToSimulation();
  38767. });
  38768. /**
  38769. *设置重力。
  38770. *@param value 重力。
  38771. */
  38772. /**
  38773. *获取重力。
  38774. *@return 重力。
  38775. */
  38776. __getset(0,__proto,'gravity',function(){
  38777. return this._gravity;
  38778. },function(value){
  38779. this._gravity=value;
  38780. Rigidbody3D._nativeGravity.setValue(-value.x,value.y,value.z);
  38781. this._nativeColliderObject.setGravity(Rigidbody3D._nativeGravity);
  38782. });
  38783. /**
  38784. *设置是否重载重力。
  38785. *@param value 是否重载重力。
  38786. */
  38787. /**
  38788. *获取是否重载重力。
  38789. *@return 是否重载重力。
  38790. */
  38791. __getset(0,__proto,'overrideGravity',function(){
  38792. return this._overrideGravity;
  38793. },function(value){
  38794. this._overrideGravity=value;
  38795. if (this._nativeColliderObject){
  38796. var flag=this._nativeColliderObject.getFlags();
  38797. if (value){
  38798. if ((flag & 1)===0)
  38799. this._nativeColliderObject.setFlags(flag | 1);
  38800. }else {
  38801. if ((flag & 1)> 0)
  38802. this._nativeColliderObject.setFlags(flag ^ 1);
  38803. }
  38804. }
  38805. });
  38806. /**
  38807. *获取总力。
  38808. */
  38809. __getset(0,__proto,'totalForce',function(){
  38810. if (this._nativeColliderObject)
  38811. return this._nativeColliderObject.getTotalForce();
  38812. return null;
  38813. });
  38814. /**
  38815. *设置线速度。
  38816. *@param 线速度。
  38817. */
  38818. /**
  38819. *获取线速度
  38820. *@return 线速度
  38821. */
  38822. __getset(0,__proto,'linearVelocity',function(){
  38823. if (this._nativeColliderObject)
  38824. Utils3D._convertToLayaVec3(this._nativeColliderObject.getLinearVelocity(),this._linearVelocity,true);
  38825. return this._linearVelocity;
  38826. },function(value){
  38827. this._linearVelocity=value;
  38828. if (this._nativeColliderObject){
  38829. var nativeValue=Rigidbody3D._nativeTempVector30;
  38830. Utils3D._convertToBulletVec3(value,nativeValue,true);
  38831. (this.isSleeping)&& (this.wakeUp());
  38832. this._nativeColliderObject.setLinearVelocity(nativeValue);
  38833. }
  38834. });
  38835. /**
  38836. *设置是否进行碰撞检测。
  38837. *@param value 是否进行碰撞检测。
  38838. */
  38839. /**
  38840. *获取是否进行碰撞检测。
  38841. *@return 是否进行碰撞检测。
  38842. */
  38843. __getset(0,__proto,'detectCollisions',function(){
  38844. return this._detectCollisions;
  38845. },function(value){
  38846. if (this._detectCollisions!==value){
  38847. this._detectCollisions=value;
  38848. if (this._colliderShape && this._enabled && this._simulation){
  38849. this._simulation._removeRigidBody(this);
  38850. this._simulation._addRigidBody(this,this._collisionGroup,value ? this._canCollideWith :0);
  38851. }
  38852. }
  38853. });
  38854. /**
  38855. *设置性因子。
  38856. */
  38857. /**
  38858. *获取性因子。
  38859. */
  38860. __getset(0,__proto,'linearFactor',function(){
  38861. if (this._nativeColliderObject)
  38862. return this._linearFactor;
  38863. return null;
  38864. },function(value){
  38865. this._linearFactor=value;
  38866. if (this._nativeColliderObject){
  38867. var nativeValue=Rigidbody3D._nativeTempVector30;
  38868. Utils3D._convertToBulletVec3(value,nativeValue,false);
  38869. this._nativeColliderObject.setLinearFactor(nativeValue);
  38870. }
  38871. });
  38872. /**
  38873. *设置角因子。
  38874. */
  38875. /**
  38876. *获取角因子。
  38877. */
  38878. __getset(0,__proto,'angularFactor',function(){
  38879. if (this._nativeColliderObject)
  38880. return this._angularFactor;
  38881. return null;
  38882. },function(value){
  38883. this._angularFactor=value;
  38884. if (this._nativeColliderObject){
  38885. var nativeValue=Rigidbody3D._nativeTempVector30;
  38886. Utils3D._convertToBulletVec3(value,nativeValue,false);
  38887. this._nativeColliderObject.setAngularFactor(nativeValue);
  38888. }
  38889. });
  38890. /**
  38891. *设置角速度。
  38892. *@param 角速度
  38893. */
  38894. /**
  38895. *获取角速度。
  38896. *@return 角速度。
  38897. */
  38898. __getset(0,__proto,'angularVelocity',function(){
  38899. if (this._nativeColliderObject)
  38900. Utils3D._convertToLayaVec3(this._nativeColliderObject.getAngularVelocity(),this._angularVelocity,true);
  38901. return this._angularVelocity;
  38902. },function(value){
  38903. this._angularVelocity=value;
  38904. if (this._nativeColliderObject){
  38905. var nativeValue=Rigidbody3D._nativeTempVector30;
  38906. Utils3D._convertToBulletVec3(value,nativeValue,true);
  38907. (this.isSleeping)&& (this.wakeUp());
  38908. this._nativeColliderObject.setAngularVelocity(nativeValue);
  38909. }
  38910. });
  38911. /**
  38912. *获取刚体所有扭力。
  38913. */
  38914. __getset(0,__proto,'totalTorque',function(){
  38915. if (this._nativeColliderObject){
  38916. var nativeTotalTorque=this._nativeColliderObject.getTotalTorque();
  38917. var totalTorque=this._totalTorque;
  38918. totalTorque.x=-nativeTotalTorque.x;
  38919. totalTorque.y=nativeTotalTorque.y;
  38920. totalTorque.z=nativeTotalTorque.z;
  38921. }
  38922. return null;
  38923. });
  38924. /**
  38925. *获取是否处于睡眠状态。
  38926. *@return 是否处于睡眠状态。
  38927. */
  38928. __getset(0,__proto,'isSleeping',function(){
  38929. if (this._nativeColliderObject)
  38930. return this._nativeColliderObject.getActivationState()===/*laya.d3.physics.PhysicsComponent.ACTIVATIONSTATE_ISLAND_SLEEPING*/2;
  38931. return false;
  38932. });
  38933. /**
  38934. *设置刚体睡眠的线速度阈值。
  38935. *@param value 刚体睡眠的线速度阈值。
  38936. */
  38937. /**
  38938. *获取刚体睡眠的线速度阈值。
  38939. *@return 刚体睡眠的线速度阈值。
  38940. */
  38941. __getset(0,__proto,'sleepLinearVelocity',function(){
  38942. return this._nativeColliderObject.getLinearSleepingThreshold();
  38943. },function(value){
  38944. this._nativeColliderObject.setSleepingThresholds(value,this._nativeColliderObject.getAngularSleepingThreshold());
  38945. });
  38946. /**
  38947. *设置刚体睡眠的角速度阈值。
  38948. *@param value 刚体睡眠的角速度阈值。
  38949. */
  38950. /**
  38951. *获取刚体睡眠的角速度阈值。
  38952. *@return 刚体睡眠的角速度阈值。
  38953. */
  38954. __getset(0,__proto,'sleepAngularVelocity',function(){
  38955. return this._nativeColliderObject.getAngularSleepingThreshold();
  38956. },function(value){
  38957. this._nativeColliderObject.setSleepingThresholds(this._nativeColliderObject.getLinearSleepingThreshold(),value);
  38958. });
  38959. Rigidbody3D.TYPE_STATIC=0;
  38960. Rigidbody3D.TYPE_DYNAMIC=1;
  38961. Rigidbody3D.TYPE_KINEMATIC=2;
  38962. Rigidbody3D._BT_DISABLE_WORLD_GRAVITY=1;
  38963. Rigidbody3D._BT_ENABLE_GYROPSCOPIC_FORCE=2;
  38964. __static(Rigidbody3D,
  38965. ['_nativeTempVector30',function(){return this._nativeTempVector30=new Laya3D._physics3D.btVector3(0,0,0);},'_nativeTempVector31',function(){return this._nativeTempVector31=new Laya3D._physics3D.btVector3(0,0,0);},'_nativeVector3Zero',function(){return this._nativeVector3Zero=new Laya3D._physics3D.btVector3(0,0,0);},'_nativeInertia',function(){return this._nativeInertia=new Laya3D._physics3D.btVector3(0,0,0);},'_nativeImpulse',function(){return this._nativeImpulse=new Laya3D._physics3D.btVector3(0,0,0);},'_nativeImpulseOffset',function(){return this._nativeImpulseOffset=new Laya3D._physics3D.btVector3(0,0,0);},'_nativeGravity',function(){return this._nativeGravity=new Laya3D._physics3D.btVector3(0,0,0);}
  38966. ]);
  38967. return Rigidbody3D;
  38968. })(PhysicsTriggerComponent)
  38969. /**
  38970. *<code>PhysicsCollider</code> 类用于创建物理碰撞器。
  38971. */
  38972. //class laya.d3.physics.PhysicsCollider extends laya.d3.physics.PhysicsTriggerComponent
  38973. var PhysicsCollider=(function(_super){
  38974. /**
  38975. *创建一个 <code>PhysicsCollider</code> 实例。
  38976. *@param collisionGroup 所属碰撞组。
  38977. *@param canCollideWith 可产生碰撞的碰撞组。
  38978. */
  38979. function PhysicsCollider(collisionGroup,canCollideWith){
  38980. (collisionGroup===void 0)&& (collisionGroup=/*laya.d3.utils.Physics3DUtils.COLLISIONFILTERGROUP_DEFAULTFILTER*/0x1);
  38981. (canCollideWith===void 0)&& (canCollideWith=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  38982. PhysicsCollider.__super.call(this,collisionGroup,canCollideWith);
  38983. }
  38984. __class(PhysicsCollider,'laya.d3.physics.PhysicsCollider',_super);
  38985. var __proto=PhysicsCollider.prototype;
  38986. /**
  38987. *@inheritDoc
  38988. */
  38989. __proto._addToSimulation=function(){
  38990. this._simulation._addPhysicsCollider(this,this._collisionGroup,this._canCollideWith);
  38991. }
  38992. /**
  38993. *@inheritDoc
  38994. */
  38995. __proto._removeFromSimulation=function(){
  38996. this._simulation._removePhysicsCollider(this);
  38997. }
  38998. /**
  38999. *@inheritDoc
  39000. */
  39001. __proto._onTransformChanged=function(flag){
  39002. flag &=/*laya.d3.core.Transform3D.TRANSFORM_WORLDPOSITION*/0x08 | /*laya.d3.core.Transform3D.TRANSFORM_WORLDQUATERNION*/0x10 | /*laya.d3.core.Transform3D.TRANSFORM_WORLDSCALE*/0x20;
  39003. if (flag){
  39004. this._transformFlag |=flag;
  39005. if (this._isValid()&& this._inPhysicUpdateListIndex===-1)
  39006. this._simulation._physicsUpdateList.add(this);
  39007. }
  39008. }
  39009. /**
  39010. *@inheritDoc
  39011. */
  39012. __proto._parse=function(data){
  39013. (data.friction !=null)&& (this.friction=data.friction);
  39014. (data.rollingFriction !=null)&& (this.rollingFriction=data.rollingFriction);
  39015. (data.restitution !=null)&& (this.restitution=data.restitution);
  39016. (data.isTrigger !=null)&& (this.isTrigger=data.isTrigger);
  39017. laya.d3.physics.PhysicsComponent.prototype._parse.call(this,data);
  39018. this._parseShape(data.shapes);
  39019. }
  39020. /**
  39021. *@inheritDoc
  39022. */
  39023. __proto._onAdded=function(){
  39024. var physics3D=Laya3D._physics3D;
  39025. var btColObj=new physics3D.btCollisionObject();
  39026. btColObj.setUserIndex(this.id);
  39027. btColObj.forceActivationState(5);
  39028. var flags=btColObj.getCollisionFlags();
  39029. if ((this.owner).isStatic){
  39030. if ((flags & 2)> 0)
  39031. flags=flags ^ 2;
  39032. flags=flags | 1;
  39033. }else {
  39034. if ((flags & 1)> 0)
  39035. flags=flags ^ 1;
  39036. flags=flags | 2;
  39037. }
  39038. btColObj.setCollisionFlags(flags);
  39039. this._nativeColliderObject=btColObj;
  39040. _super.prototype._onAdded.call(this);
  39041. }
  39042. return PhysicsCollider;
  39043. })(PhysicsTriggerComponent)
  39044. /**
  39045. *<code>SkinMeshRenderer</code> 类用于蒙皮渲染器。
  39046. */
  39047. //class laya.d3.core.SkinnedMeshRenderer extends laya.d3.core.MeshRenderer
  39048. var SkinnedMeshRenderer=(function(_super){
  39049. function SkinnedMeshRenderer(owner){
  39050. /**@private */
  39051. //this._cacheMesh=null;
  39052. /**@private */
  39053. //this._skinnedData=null;
  39054. /**@private */
  39055. //this._cacheAnimator=null;
  39056. /**@private */
  39057. //this._cacheRootBone=null;
  39058. /**@private */
  39059. //this._rootBone=null;
  39060. /**@private */
  39061. //this._cacheAvatar=null;
  39062. /**@private */
  39063. //this._cacheRootAnimationNode=null;
  39064. /**@private [NATIVE]*/
  39065. //this._cacheAnimationNodeIndices=null;
  39066. this._bones=[];
  39067. this._skinnedDataLoopMarks=[];
  39068. this._localBounds=new Bounds(Vector3._ZERO,Vector3._ZERO);
  39069. this._cacheAnimationNode=[];
  39070. SkinnedMeshRenderer.__super.call(this,owner);
  39071. }
  39072. __class(SkinnedMeshRenderer,'laya.d3.core.SkinnedMeshRenderer',_super);
  39073. var __proto=SkinnedMeshRenderer.prototype;
  39074. /**
  39075. *@private
  39076. */
  39077. __proto._computeSkinnedData=function(){
  39078. if (this._cacheMesh && this._cacheAvatar || this._cacheMesh && this._cacheRootBone){
  39079. var bindPoses=this._cacheMesh._inverseBindPoses;
  39080. var meshBindPoseIndices=this._cacheMesh._bindPoseIndices;
  39081. var pathMarks=this._cacheMesh._skinDataPathMarks;
  39082. for (var i=0,n=this._cacheMesh.subMeshCount;i < n;i++){
  39083. var subMeshBoneIndices=(this._cacheMesh._getSubMesh(i))._boneIndicesList;
  39084. var subData=this._skinnedData[i];
  39085. for (var j=0,m=subMeshBoneIndices.length;j < m;j++){
  39086. var boneIndices=subMeshBoneIndices[j];
  39087. if (Render.supportWebGLPlusAnimation)
  39088. this._computeSubSkinnedDataNative(this._cacheAnimator._animationNodeWorldMatrixs,this._cacheAnimationNodeIndices,this._cacheMesh._inverseBindPosesBuffer,boneIndices,meshBindPoseIndices,subData[j]);
  39089. else
  39090. this._computeSubSkinnedData(bindPoses,boneIndices,meshBindPoseIndices,subData[j],pathMarks);
  39091. }
  39092. }
  39093. }
  39094. }
  39095. /**
  39096. *@private
  39097. */
  39098. __proto._computeSubSkinnedData=function(bindPoses,boneIndices,meshBindPoseInices,data,pathMarks){
  39099. for (var k=0,q=boneIndices.length;k < q;k++){
  39100. var index=boneIndices[k];
  39101. if (this._skinnedDataLoopMarks[index]===Stat.loopCount){
  39102. var p=pathMarks[index];
  39103. var preData=this._skinnedData[p[0]][p[1]];
  39104. var srcIndex=p[2] *16;
  39105. var dstIndex=k *16;
  39106. for (var d=0;d < 16;d++)
  39107. data[dstIndex+d]=preData[srcIndex+d];
  39108. }else {
  39109. if (this._cacheRootBone){
  39110. var boneIndex=meshBindPoseInices[index];
  39111. Utils3D._mulMatrixArray(this._bones[boneIndex].transform.worldMatrix.elements,bindPoses[boneIndex],data,k *16);
  39112. }
  39113. else{
  39114. Utils3D._mulMatrixArray(this._cacheAnimationNode[index].transform.getWorldMatrix(),bindPoses[meshBindPoseInices[index]],data,k *16);
  39115. }
  39116. this._skinnedDataLoopMarks[index]=Stat.loopCount;
  39117. }
  39118. }
  39119. }
  39120. /**
  39121. *@private
  39122. */
  39123. __proto._boundChange=function(){
  39124. this._boundsChange=true;
  39125. }
  39126. /**
  39127. *@private
  39128. */
  39129. __proto._onMeshChange=function(value){
  39130. _super.prototype._onMeshChange.call(this,value);
  39131. this._cacheMesh=value;
  39132. var subMeshCount=value.subMeshCount;
  39133. this._skinnedData=__newvec(subMeshCount);
  39134. this._skinnedDataLoopMarks.length=(value)._bindPoseIndices.length;
  39135. for (var i=0;i < subMeshCount;i++){
  39136. var subBoneIndices=(value._getSubMesh(i))._boneIndicesList;
  39137. var subCount=subBoneIndices.length;
  39138. var subData=this._skinnedData[i]=__newvec(subCount);
  39139. for (var j=0;j < subCount;j++)
  39140. subData[j]=new Float32Array(subBoneIndices[j].length *16);
  39141. }
  39142. if (!this._bones)
  39143. (this._cacheAvatar && value)&& (this._getCacheAnimationNodes());
  39144. }
  39145. /**
  39146. *@private
  39147. */
  39148. __proto._setCacheAnimator=function(animator){
  39149. this._cacheAnimator=animator;
  39150. this._defineDatas.add(SkinnedMeshSprite3D.SHADERDEFINE_BONE);
  39151. this._setRootNode();
  39152. }
  39153. /**
  39154. *@inheritDoc
  39155. */
  39156. __proto._calculateBoundingBox=function(){
  39157. if (this._cacheRootBone){
  39158. this._localBounds._tranform(this._cacheRootBone.transform.worldMatrix,this._bounds);
  39159. }else {
  39160. if (this._cacheAnimator && this._rootBone){
  39161. var worldMat=SkinnedMeshRenderer._tempMatrix4x4;
  39162. Utils3D.matrix4x4MultiplyMFM((this._cacheAnimator.owner).transform.worldMatrix,this._cacheRootAnimationNode.transform.getWorldMatrix(),worldMat);
  39163. this._localBounds._tranform(worldMat,this._bounds);
  39164. }else {
  39165. _super.prototype._calculateBoundingBox.call(this);
  39166. }
  39167. }
  39168. if (Render.supportWebGLPlusCulling){
  39169. var min=this._bounds.getMin();
  39170. var max=this._bounds.getMax();
  39171. var buffer=FrustumCulling._cullingBuffer;
  39172. buffer[this._cullingBufferIndex+1]=min.x;
  39173. buffer[this._cullingBufferIndex+2]=min.y;
  39174. buffer[this._cullingBufferIndex+3]=min.z;
  39175. buffer[this._cullingBufferIndex+4]=max.x;
  39176. buffer[this._cullingBufferIndex+5]=max.y;
  39177. buffer[this._cullingBufferIndex+6]=max.z;
  39178. }
  39179. }
  39180. /**
  39181. *@inheritDoc
  39182. */
  39183. __proto._changeRenderObjectsByMesh=function(mesh){
  39184. var count=mesh.subMeshCount;
  39185. this._renderElements.length=count;
  39186. for (var i=0;i < count;i++){
  39187. var renderElement=this._renderElements[i];
  39188. if (!renderElement){
  39189. var material=this.sharedMaterials[i];
  39190. renderElement=this._renderElements[i]=new RenderElement();
  39191. renderElement.setTransform(this._owner._transform);
  39192. renderElement.render=this;
  39193. renderElement.material=material ? material :BlinnPhongMaterial.defaultMaterial;
  39194. }
  39195. renderElement.setGeometry(mesh._getSubMesh(i));
  39196. }
  39197. }
  39198. /**
  39199. *@inheritDoc
  39200. */
  39201. __proto._renderUpdate=function(context,transform){
  39202. if (this._cacheAnimator){
  39203. this._computeSkinnedData();
  39204. if (this._cacheRootBone){
  39205. this._shaderValues.setMatrix4x4(Sprite3D.WORLDMATRIX,Matrix4x4.DEFAULT);
  39206. }else {
  39207. var aniOwnerTrans=(this._cacheAnimator.owner)._transform;
  39208. this._shaderValues.setMatrix4x4(Sprite3D.WORLDMATRIX,aniOwnerTrans.worldMatrix);
  39209. }
  39210. }else {
  39211. this._shaderValues.setMatrix4x4(Sprite3D.WORLDMATRIX,transform.worldMatrix);
  39212. }
  39213. }
  39214. /**
  39215. *@inheritDoc
  39216. */
  39217. __proto._renderUpdateWithCamera=function(context,transform){
  39218. var projectionView=context.projectionViewMatrix;
  39219. if (this._cacheRootBone){
  39220. this._shaderValues.setMatrix4x4(Sprite3D.MVPMATRIX,projectionView);
  39221. }else {
  39222. if (this._cacheAnimator){
  39223. var aniOwnerTrans=(this._cacheAnimator.owner)._transform;
  39224. Matrix4x4.multiply(projectionView,aniOwnerTrans.worldMatrix,this._projectionViewWorldMatrix);
  39225. }else {
  39226. Matrix4x4.multiply(projectionView,transform.worldMatrix,this._projectionViewWorldMatrix);
  39227. }
  39228. this._shaderValues.setMatrix4x4(Sprite3D.MVPMATRIX,this._projectionViewWorldMatrix);
  39229. }
  39230. }
  39231. /**
  39232. *@inheritDoc
  39233. */
  39234. __proto._destroy=function(){
  39235. _super.prototype._destroy.call(this);
  39236. if (this._cacheRootBone){
  39237. this._cacheRootBone.transform.off(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this,this._boundChange);
  39238. }else {
  39239. if (this._cacheRootAnimationNode)
  39240. this._cacheRootAnimationNode.transform.off(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this,this._boundChange);
  39241. }
  39242. }
  39243. /**
  39244. *@private
  39245. */
  39246. __proto._setRootBone=function(name){
  39247. this._rootBone=name;
  39248. this._setRootNode();
  39249. }
  39250. /**
  39251. *@private
  39252. */
  39253. __proto._setRootNode=function(){
  39254. var rootNode;
  39255. if (this._cacheAnimator && this._rootBone && this._cacheAvatar)
  39256. rootNode=this._cacheAnimator._avatarNodeMap[this._rootBone];
  39257. else
  39258. rootNode=null;
  39259. if (this._cacheRootAnimationNode !=rootNode){
  39260. this._boundChange();
  39261. if (this._cacheRootAnimationNode)
  39262. this._cacheRootAnimationNode.transform.off(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this,this._boundChange);
  39263. (rootNode)&&(rootNode.transform.on(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this,this._boundChange));
  39264. this._cacheRootAnimationNode=rootNode;
  39265. }
  39266. }
  39267. /**
  39268. *@private
  39269. */
  39270. __proto._getCacheAnimationNodes=function(){
  39271. var meshBoneNames=this._cacheMesh._boneNames;
  39272. var bindPoseIndices=this._cacheMesh._bindPoseIndices;
  39273. var innerBindPoseCount=bindPoseIndices.length;
  39274. if (!Render.supportWebGLPlusAnimation){
  39275. this._cacheAnimationNode.length=innerBindPoseCount;
  39276. var nodeMap=this._cacheAnimator._avatarNodeMap;
  39277. for (var i=0;i < innerBindPoseCount;i++){
  39278. var node=nodeMap[meshBoneNames[bindPoseIndices[i]]];
  39279. this._cacheAnimationNode[i]=node;
  39280. }
  39281. }else {
  39282. this._cacheAnimationNodeIndices=new Uint16Array(innerBindPoseCount);
  39283. var nodeMapC=this._cacheAnimator._avatarNodeMap;
  39284. for (i=0;i < innerBindPoseCount;i++){
  39285. var nodeC=nodeMapC[meshBoneNames[bindPoseIndices[i]]];
  39286. this._cacheAnimationNodeIndices[i]=nodeC._worldMatrixIndex;
  39287. }
  39288. }
  39289. }
  39290. /**
  39291. *@private
  39292. */
  39293. __proto._setCacheAvatar=function(value){
  39294. if (this._cacheAvatar!==value){
  39295. if (this._cacheMesh){
  39296. this._cacheAvatar=value;
  39297. if (value){
  39298. this._defineDatas.add(SkinnedMeshSprite3D.SHADERDEFINE_BONE);
  39299. this._getCacheAnimationNodes();
  39300. }
  39301. }else {
  39302. this._cacheAvatar=value;
  39303. }
  39304. this._setRootNode();
  39305. }
  39306. }
  39307. /**
  39308. *@private [NATIVE]
  39309. */
  39310. __proto._computeSubSkinnedDataNative=function(worldMatrixs,cacheAnimationNodeIndices,inverseBindPosesBuffer,boneIndices,bindPoseInices,data){
  39311. LayaGL.instance.computeSubSkinnedData(worldMatrixs,cacheAnimationNodeIndices,inverseBindPosesBuffer,boneIndices,bindPoseInices,data);
  39312. }
  39313. /**
  39314. *设置局部边界。
  39315. *@param value 边界
  39316. */
  39317. /**
  39318. *获取局部边界。
  39319. *@return 边界。
  39320. */
  39321. __getset(0,__proto,'localBounds',function(){
  39322. return this._localBounds;
  39323. },function(value){
  39324. this._localBounds=value;
  39325. });
  39326. /**
  39327. *设置根节点。
  39328. *@param value 根节点。
  39329. */
  39330. /**
  39331. *获取根节点。
  39332. *@return 根节点。
  39333. */
  39334. __getset(0,__proto,'rootBone',function(){
  39335. return this._cacheRootBone;
  39336. },function(value){
  39337. if (this._cacheRootBone !=value){
  39338. if (this._cacheRootBone)
  39339. this._cacheRootBone.transform.off(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this,this._boundChange);
  39340. value.transform.on(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this,this._boundChange);
  39341. this._cacheRootBone=value;
  39342. this._boundChange();
  39343. }
  39344. });
  39345. /**
  39346. *用于蒙皮的骨骼。
  39347. */
  39348. __getset(0,__proto,'bones',function(){
  39349. return this._bones;
  39350. });
  39351. __static(SkinnedMeshRenderer,
  39352. ['_tempMatrix4x4',function(){return this._tempMatrix4x4=new Matrix4x4();}
  39353. ]);
  39354. return SkinnedMeshRenderer;
  39355. })(MeshRenderer)
  39356. /**
  39357. //*<code>RenderTexture</code> 类用于创建渲染目标。
  39358. */
  39359. //class laya.d3.resource.RenderTexture extends laya.resource.BaseTexture
  39360. var RenderTexture=(function(_super){
  39361. function RenderTexture(width,height,format,depthStencilFormat){
  39362. /**@private */
  39363. //this._frameBuffer=null;
  39364. /**@private */
  39365. //this._depthStencilBuffer=null;
  39366. /**@private */
  39367. //this._depthStencilFormat=0;
  39368. (format===void 0)&& (format=0);
  39369. (depthStencilFormat===void 0)&& (depthStencilFormat=/*laya.resource.BaseTexture.FORMAT_DEPTH_16*/0);
  39370. RenderTexture.__super.call(this,format,false);
  39371. this._glTextureType=/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1;
  39372. this._width=width;
  39373. this._height=height;
  39374. this._depthStencilFormat=depthStencilFormat;
  39375. this._create(width,height);
  39376. }
  39377. __class(RenderTexture,'laya.d3.resource.RenderTexture',_super);
  39378. var __proto=RenderTexture.prototype;
  39379. /**
  39380. *@private
  39381. */
  39382. __proto._create=function(width,height){
  39383. var gl=LayaGL.instance;
  39384. this._frameBuffer=gl.createFramebuffer();
  39385. WebGLContext.bindTexture(gl,this._glTextureType,this._glTexture);
  39386. var glFormat=this._getGLFormat();
  39387. gl.texImage2D(this._glTextureType,0,glFormat,width,height,0,glFormat,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,null);
  39388. this._setGPUMemory(width *height *4);
  39389. gl.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,this._frameBuffer);
  39390. gl.framebufferTexture2D(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,/*laya.webgl.WebGLContext.COLOR_ATTACHMENT0*/0x8CE0,/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,this._glTexture,0);
  39391. if (this._depthStencilFormat!==/*laya.resource.BaseTexture.FORMAT_DEPTHSTENCIL_NONE*/3){
  39392. this._depthStencilBuffer=gl.createRenderbuffer();
  39393. gl.bindRenderbuffer(/*laya.webgl.WebGLContext.RENDERBUFFER*/0x8D41,this._depthStencilBuffer);
  39394. switch (this._depthStencilFormat){
  39395. case /*laya.resource.BaseTexture.FORMAT_DEPTH_16*/0:
  39396. gl.renderbufferStorage(/*laya.webgl.WebGLContext.RENDERBUFFER*/0x8D41,/*laya.webgl.WebGLContext.DEPTH_COMPONENT16*/0x81A5,width,height);
  39397. gl.framebufferRenderbuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,/*laya.webgl.WebGLContext.DEPTH_ATTACHMENT*/0x8D00,/*laya.webgl.WebGLContext.RENDERBUFFER*/0x8D41,this._depthStencilBuffer);
  39398. break ;
  39399. case /*laya.resource.BaseTexture.FORMAT_STENCIL_8*/1:
  39400. gl.renderbufferStorage(/*laya.webgl.WebGLContext.RENDERBUFFER*/0x8D41,/*laya.webgl.WebGLContext.STENCIL_INDEX8*/0x8D48,width,height);
  39401. gl.framebufferRenderbuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,/*laya.webgl.WebGLContext.STENCIL_ATTACHMENT*/0x8D20,/*laya.webgl.WebGLContext.RENDERBUFFER*/0x8D41,this._depthStencilBuffer);
  39402. break ;
  39403. case /*laya.resource.BaseTexture.FORMAT_DEPTHSTENCIL_16_8*/2:
  39404. gl.renderbufferStorage(/*laya.webgl.WebGLContext.RENDERBUFFER*/0x8D41,/*laya.webgl.WebGLContext.DEPTH_STENCIL*/0x84F9,width,height);
  39405. gl.framebufferRenderbuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,/*laya.webgl.WebGLContext.DEPTH_STENCIL_ATTACHMENT*/0x821A,/*laya.webgl.WebGLContext.RENDERBUFFER*/0x8D41,this._depthStencilBuffer);
  39406. break ;
  39407. default :
  39408. throw "RenderTexture: unkonw depth format.";
  39409. }
  39410. }
  39411. gl.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,null);
  39412. gl.bindRenderbuffer(/*laya.webgl.WebGLContext.RENDERBUFFER*/0x8D41,null);
  39413. this._setWarpMode(/*laya.webgl.WebGLContext.TEXTURE_WRAP_S*/0x2802,this._wrapModeU);
  39414. this._setWarpMode(/*laya.webgl.WebGLContext.TEXTURE_WRAP_T*/0x2803,this._wrapModeV);
  39415. this._setFilterMode(this._filterMode);
  39416. this._setAnisotropy(this._anisoLevel);
  39417. this._readyed=true;
  39418. this._activeResource();
  39419. }
  39420. /**
  39421. *@private
  39422. */
  39423. __proto._start=function(){
  39424. LayaGL.instance.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,this._frameBuffer);
  39425. RenderTexture._currentActive=this;
  39426. this._readyed=false;
  39427. }
  39428. /**
  39429. *@private
  39430. */
  39431. __proto._end=function(){
  39432. LayaGL.instance.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,null);
  39433. RenderTexture._currentActive=null;
  39434. this._readyed=true;
  39435. }
  39436. /**
  39437. *获得像素数据。
  39438. *@param x X像素坐标。
  39439. *@param y Y像素坐标。
  39440. *@param width 宽度。
  39441. *@param height 高度。
  39442. *@return 像素数据。
  39443. */
  39444. __proto.getData=function(x,y,width,height,out){
  39445. if (Render.isConchApp && /*__JS__ */conchConfig.threadMode==2){
  39446. throw "native 2 thread mode use getDataAsync";
  39447. };
  39448. var gl=LayaGL.instance;
  39449. gl.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,this._frameBuffer);
  39450. var canRead=(gl.checkFramebufferStatus(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40)===/*laya.webgl.WebGLContext.FRAMEBUFFER_COMPLETE*/0x8CD5);
  39451. if (!canRead){
  39452. gl.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,null);
  39453. return null;
  39454. }
  39455. gl.readPixels(x,y,width,height,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,out);
  39456. gl.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,null);
  39457. return out;
  39458. }
  39459. /**
  39460. *native多线程
  39461. */
  39462. __proto.getDataAsync=function(x,y,width,height,callBack){
  39463. var gl=LayaGL.instance;
  39464. gl.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,this._frameBuffer);
  39465. gl.readPixelsAsync(x,y,width,height,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,function(data){
  39466. /*__JS__ */callBack(new Uint8Array(data));
  39467. });
  39468. gl.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,null);
  39469. }
  39470. /**
  39471. *@inheritDoc
  39472. */
  39473. __proto._disposeResource=function(){
  39474. if (this._frameBuffer){
  39475. var gl=LayaGL.instance;
  39476. gl.deleteTexture(this._glTexture);
  39477. gl.deleteFramebuffer(this._frameBuffer);
  39478. gl.deleteRenderbuffer(this._depthStencilBuffer);
  39479. this._glTexture=null;
  39480. this._frameBuffer=null;
  39481. this._depthStencilBuffer=null;
  39482. this._setGPUMemory(0);
  39483. }
  39484. }
  39485. /**
  39486. *获取深度格式。
  39487. *@return 深度格式。
  39488. */
  39489. __getset(0,__proto,'depthStencilFormat',function(){
  39490. return this._depthStencilFormat;
  39491. });
  39492. /**
  39493. *@inheritDoc
  39494. */
  39495. __getset(0,__proto,'defaulteTexture',function(){
  39496. return Texture2D.grayTexture;
  39497. });
  39498. /**
  39499. *获取当前激活的Rendertexture。
  39500. */
  39501. __getset(1,RenderTexture,'currentActive',function(){
  39502. return RenderTexture._currentActive;
  39503. },laya.resource.BaseTexture._$SET_currentActive);
  39504. RenderTexture.getTemporary=function(width,height,format,depthStencilFormat,filterMode){
  39505. (format===void 0)&& (format=/*laya.resource.BaseTexture.FORMAT_R8G8B8*/0);
  39506. (depthStencilFormat===void 0)&& (depthStencilFormat=/*laya.resource.BaseTexture.FORMAT_DEPTH_16*/0);
  39507. (filterMode===void 0)&& (filterMode=/*laya.resource.BaseTexture.FILTERMODE_BILINEAR*/1);
  39508. var key=filterMode *10000000+depthStencilFormat *1000000+format *100000+10000 *height+width;
  39509. var textures=RenderTexture._temporaryMap[key];
  39510. if (!textures || textures && textures.length===0){
  39511. var renderTexture=new RenderTexture(width,height,format,depthStencilFormat);
  39512. renderTexture.filterMode=filterMode;
  39513. return renderTexture;
  39514. }else {
  39515. return textures.pop();
  39516. }
  39517. }
  39518. RenderTexture.setReleaseTemporary=function(renderTexture){
  39519. var key=renderTexture.filterMode *10000000+renderTexture.depthStencilFormat *1000000+renderTexture.format *100000+10000 *renderTexture.height+renderTexture.width;
  39520. var textures=RenderTexture._temporaryMap[key];
  39521. (textures)|| (RenderTexture._temporaryMap[key]=textures=[]);
  39522. textures.push(renderTexture);
  39523. }
  39524. RenderTexture._temporaryMap={};
  39525. RenderTexture._currentActive=null;
  39526. return RenderTexture;
  39527. })(BaseTexture)
  39528. /**
  39529. *<code>TextureCube</code> 类用于生成立方体纹理。
  39530. */
  39531. //class laya.d3.resource.TextureCube extends laya.resource.BaseTexture
  39532. var TextureCube=(function(_super){
  39533. function TextureCube(format,mipmap){
  39534. /**@private */
  39535. //this._premultiplyAlpha=0;
  39536. (format===void 0)&& (format=0);
  39537. (mipmap===void 0)&& (mipmap=false);
  39538. TextureCube.__super.call(this,format,mipmap);
  39539. this._glTextureType=/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP*/0x8513;
  39540. }
  39541. __class(TextureCube,'laya.d3.resource.TextureCube',_super);
  39542. var __proto=TextureCube.prototype;
  39543. /**
  39544. *通过六张图片源填充纹理。
  39545. *@param 图片源数组。
  39546. */
  39547. __proto.setSixSideImageSources=function(source,premultiplyAlpha){
  39548. (premultiplyAlpha===void 0)&& (premultiplyAlpha=false);
  39549. var width=0;
  39550. var height=0;
  39551. for (var i=0;i < 6;i++){
  39552. var img=source[i];
  39553. if (!img){
  39554. console.log("TextureCube: image Source can't be null.");
  39555. return;
  39556. };
  39557. var nextWidth=img.width;
  39558. var nextHeight=img.height;
  39559. if (i > 0){
  39560. if (width!==nextWidth){
  39561. console.log("TextureCube: each side image's width and height must same.");
  39562. return;
  39563. }
  39564. }
  39565. width=nextWidth;
  39566. height=nextHeight;
  39567. if (width!==height){
  39568. console.log("TextureCube: each side image's width and height must same.");
  39569. return;
  39570. }
  39571. }
  39572. this._width=width;
  39573. this._height=height;
  39574. var gl=LayaGL.instance;
  39575. WebGLContext.bindTexture(gl,this._glTextureType,this._glTexture);
  39576. var glFormat=this._getGLFormat();
  39577. if (!Render.isConchApp){
  39578. (premultiplyAlpha)&& (gl.pixelStorei(/*laya.webgl.WebGLContext.UNPACK_PREMULTIPLY_ALPHA_WEBGL*/0x9241,true));
  39579. gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_POSITIVE_Z*/0x8519,0,glFormat,glFormat,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,source[0]);
  39580. gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_NEGATIVE_Z*/0x851A,0,glFormat,glFormat,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,source[1]);
  39581. gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_POSITIVE_X*/0x8515,0,glFormat,glFormat,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,source[2]);
  39582. gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_NEGATIVE_X*/0x8516,0,glFormat,glFormat,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,source[3]);
  39583. gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_POSITIVE_Y*/0x8517,0,glFormat,glFormat,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,source[4]);
  39584. gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_NEGATIVE_Y*/0x8518,0,glFormat,glFormat,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,source[5]);
  39585. (premultiplyAlpha)&& (gl.pixelStorei(/*laya.webgl.WebGLContext.UNPACK_PREMULTIPLY_ALPHA_WEBGL*/0x9241,false));
  39586. }else {
  39587. if (premultiplyAlpha==true){
  39588. for (var j=0;j < 6;j++)
  39589. source[j].setPremultiplyAlpha(premultiplyAlpha);
  39590. }
  39591. gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_POSITIVE_Z*/0x8519,0,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,source[0]);
  39592. gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_NEGATIVE_Z*/0x851A,0,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,source[1]);
  39593. gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_POSITIVE_X*/0x8515,0,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,source[2]);
  39594. gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_NEGATIVE_X*/0x8516,0,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,source[3]);
  39595. gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_POSITIVE_Y*/0x8517,0,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,source[4]);
  39596. gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_NEGATIVE_Y*/0x8518,0,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,source[5]);
  39597. }
  39598. if (this._mipmap && this._isPot(width)&& this._isPot(height)){
  39599. gl.generateMipmap(this._glTextureType);
  39600. this._setGPUMemory(width *height *4 *(1+1 / 3)*6);
  39601. }else {
  39602. this._setGPUMemory(width *height *4 *6);
  39603. }
  39604. this._setWarpMode(/*laya.webgl.WebGLContext.TEXTURE_WRAP_S*/0x2802,this._wrapModeU);
  39605. this._setWarpMode(/*laya.webgl.WebGLContext.TEXTURE_WRAP_T*/0x2803,this._wrapModeV);
  39606. this._setFilterMode(this._filterMode);
  39607. this._readyed=true;
  39608. this._activeResource();
  39609. }
  39610. /**
  39611. *通过六张图片源填充纹理。
  39612. *@param 图片源数组。
  39613. */
  39614. __proto.setSixSidePixels=function(width,height,pixels){
  39615. if (width <=0 || height <=0)
  39616. throw new Error("TextureCube:width or height must large than 0.");
  39617. if (!pixels)
  39618. throw new Error("TextureCube:pixels can't be null.");
  39619. this._width=width;
  39620. this._height=height;
  39621. var gl=LayaGL.instance;
  39622. WebGLContext.bindTexture(gl,this._glTextureType,this._glTexture);
  39623. var glFormat=this._getGLFormat();
  39624. gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_POSITIVE_Z*/0x8519,0,glFormat,width,height,0,glFormat,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,pixels[0]);
  39625. gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_NEGATIVE_Z*/0x851A,0,glFormat,width,height,0,glFormat,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,pixels[1]);
  39626. gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_POSITIVE_X*/0x8515,0,glFormat,width,height,0,glFormat,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,pixels[2]);
  39627. gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_NEGATIVE_X*/0x8516,0,glFormat,width,height,0,glFormat,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,pixels[3]);
  39628. gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_POSITIVE_Y*/0x8517,0,glFormat,width,height,0,glFormat,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,pixels[4]);
  39629. gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_NEGATIVE_Y*/0x8518,0,glFormat,width,height,0,glFormat,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,pixels[5]);
  39630. if (this._mipmap && this._isPot(width)&& this._isPot(height)){
  39631. gl.generateMipmap(this._glTextureType);
  39632. this._setGPUMemory(width *height *4 *(1+1 / 3)*6);
  39633. }else {
  39634. this._setGPUMemory(width *height *4 *6);
  39635. }
  39636. this._setWarpMode(/*laya.webgl.WebGLContext.TEXTURE_WRAP_S*/0x2802,this._wrapModeU);
  39637. this._setWarpMode(/*laya.webgl.WebGLContext.TEXTURE_WRAP_T*/0x2803,this._wrapModeV);
  39638. this._setFilterMode(this._filterMode);
  39639. this._readyed=true;
  39640. this._activeResource();
  39641. }
  39642. /**
  39643. *@inheritDoc
  39644. */
  39645. __proto._recoverResource=function(){}
  39646. /**
  39647. *@inheritDoc
  39648. */
  39649. __getset(0,__proto,'defaulteTexture',function(){
  39650. return TextureCube.grayTexture;
  39651. });
  39652. TextureCube.__init__=function(){
  39653. var pixels=new Uint8Array(3);
  39654. pixels[0]=128;
  39655. pixels[1]=128;
  39656. pixels[2]=128;
  39657. TextureCube.grayTexture=new TextureCube(0,false);
  39658. TextureCube.grayTexture.setSixSidePixels(1,1,[pixels,pixels,pixels,pixels,pixels,pixels]);
  39659. TextureCube.grayTexture.lock=true;
  39660. }
  39661. TextureCube._parse=function(data,propertyParams,constructParams){
  39662. var texture=constructParams ? new TextureCube(constructParams[0],constructParams[1]):new TextureCube();
  39663. texture.setSixSideImageSources(data);
  39664. return texture;
  39665. }
  39666. TextureCube.load=function(url,complete){
  39667. Laya.loader.create(url,complete,null,/*Laya3D.TEXTURECUBE*/"TEXTURECUBE");
  39668. }
  39669. TextureCube.grayTexture=null;
  39670. return TextureCube;
  39671. })(BaseTexture)
  39672. /**
  39673. *<code>MeshSprite3D</code> 类用于创建网格。
  39674. */
  39675. //class laya.d3.core.MeshSprite3D extends laya.d3.core.RenderableSprite3D
  39676. var MeshSprite3D=(function(_super){
  39677. function MeshSprite3D(mesh,name){
  39678. /**@private */
  39679. //this._meshFilter=null;
  39680. MeshSprite3D.__super.call(this,name);
  39681. this._meshFilter=new MeshFilter(this);
  39682. this._render=new MeshRenderer(this);
  39683. (mesh)&& (this._meshFilter.sharedMesh=mesh);
  39684. }
  39685. __class(MeshSprite3D,'laya.d3.core.MeshSprite3D',_super);
  39686. var __proto=MeshSprite3D.prototype;
  39687. /**
  39688. *@inheritDoc
  39689. */
  39690. __proto._parse=function(data,spriteMap){
  39691. laya.d3.core.Sprite3D.prototype._parse.call(this,data,spriteMap);
  39692. var render=this.meshRenderer;
  39693. var lightmapIndex=data.lightmapIndex;
  39694. (lightmapIndex !=null)&& (render.lightmapIndex=lightmapIndex);
  39695. var lightmapScaleOffsetArray=data.lightmapScaleOffset;
  39696. (lightmapScaleOffsetArray)&& (render.lightmapScaleOffset=new Vector4(lightmapScaleOffsetArray[0],lightmapScaleOffsetArray[1],lightmapScaleOffsetArray[2],lightmapScaleOffsetArray[3]));
  39697. (data.meshPath !=undefined)&& (this.meshFilter.sharedMesh=Loader.getRes(data.meshPath));
  39698. (data.enableRender !=undefined)&& (this.meshRenderer.enable=data.enableRender);
  39699. var materials=data.materials;
  39700. if (materials){
  39701. var sharedMaterials=render.sharedMaterials;
  39702. var materialCount=materials.length;
  39703. sharedMaterials.length=materialCount;
  39704. for (var i=0;i < materialCount;i++){
  39705. sharedMaterials[i]=Loader.getRes(materials[i].path);
  39706. }
  39707. render.sharedMaterials=sharedMaterials;
  39708. }
  39709. }
  39710. /**
  39711. *@inheritDoc
  39712. */
  39713. __proto._addToInitStaticBatchManager=function(){
  39714. MeshRenderStaticBatchManager.instance._addBatchSprite(this);
  39715. }
  39716. /**
  39717. *@inheritDoc
  39718. */
  39719. __proto._cloneTo=function(destObject,rootSprite,dstSprite){
  39720. var meshSprite3D=destObject;
  39721. meshSprite3D._meshFilter.sharedMesh=this._meshFilter.sharedMesh;
  39722. var meshRender=this._render;
  39723. var destMeshRender=meshSprite3D._render;
  39724. destMeshRender.enable=meshRender.enable;
  39725. destMeshRender.sharedMaterials=meshRender.sharedMaterials;
  39726. destMeshRender.castShadow=meshRender.castShadow;
  39727. var lightmapScaleOffset=meshRender.lightmapScaleOffset;
  39728. lightmapScaleOffset && (destMeshRender.lightmapScaleOffset=lightmapScaleOffset.clone());
  39729. destMeshRender.lightmapIndex=meshRender.lightmapIndex;
  39730. destMeshRender.receiveShadow=meshRender.receiveShadow;
  39731. destMeshRender.sortingFudge=meshRender.sortingFudge;
  39732. laya.d3.core.Sprite3D.prototype._cloneTo.call(this,destObject,rootSprite,dstSprite);
  39733. }
  39734. /**
  39735. *@inheritDoc
  39736. */
  39737. __proto.destroy=function(destroyChild){
  39738. (destroyChild===void 0)&& (destroyChild=true);
  39739. if (this.destroyed)
  39740. return;
  39741. _super.prototype.destroy.call(this,destroyChild);
  39742. this._meshFilter.destroy();
  39743. }
  39744. /**
  39745. *获取网格过滤器。
  39746. *@return 网格过滤器。
  39747. */
  39748. __getset(0,__proto,'meshFilter',function(){
  39749. return this._meshFilter;
  39750. });
  39751. /**
  39752. *获取网格渲染器。
  39753. *@return 网格渲染器。
  39754. */
  39755. __getset(0,__proto,'meshRenderer',function(){
  39756. return this._render;
  39757. });
  39758. MeshSprite3D.__init__=function(){
  39759. MeshSprite3D.SHADERDEFINE_UV0=MeshSprite3D.shaderDefines.registerDefine("UV");
  39760. MeshSprite3D.SHADERDEFINE_COLOR=MeshSprite3D.shaderDefines.registerDefine("COLOR");
  39761. MeshSprite3D.SHADERDEFINE_UV1=MeshSprite3D.shaderDefines.registerDefine("UV1");
  39762. MeshSprite3D.SHADERDEFINE_GPU_INSTANCE=MeshSprite3D.shaderDefines.registerDefine("GPU_INSTANCE");
  39763. StaticBatchManager._registerManager(MeshRenderStaticBatchManager.instance);
  39764. DynamicBatchManager._registerManager(MeshRenderDynamicBatchManager.instance);
  39765. }
  39766. MeshSprite3D.SHADERDEFINE_UV0=0;
  39767. MeshSprite3D.SHADERDEFINE_COLOR=0;
  39768. MeshSprite3D.SHADERDEFINE_UV1=0;
  39769. MeshSprite3D.SHADERDEFINE_GPU_INSTANCE=0;
  39770. __static(MeshSprite3D,
  39771. ['shaderDefines',function(){return this.shaderDefines=new ShaderDefines(RenderableSprite3D.shaderDefines);}
  39772. ]);
  39773. return MeshSprite3D;
  39774. })(RenderableSprite3D)
  39775. /**
  39776. *<code>SpotLight</code> 类用于创建聚光。
  39777. */
  39778. //class laya.d3.core.light.SpotLight extends laya.d3.core.light.LightSprite
  39779. var SpotLight=(function(_super){
  39780. function SpotLight(){
  39781. /**@private */
  39782. this._direction=null;
  39783. /**@private */
  39784. this._spotAngle=NaN;
  39785. /**@private */
  39786. this._range=NaN;
  39787. SpotLight.__super.call(this);
  39788. this._spotAngle=30.0;
  39789. this._range=10.0;
  39790. this._direction=new Vector3();
  39791. }
  39792. __class(SpotLight,'laya.d3.core.light.SpotLight',_super);
  39793. var __proto=SpotLight.prototype;
  39794. /**
  39795. *@inheritDoc
  39796. */
  39797. __proto._onActive=function(){
  39798. _super.prototype._onActive.call(this);
  39799. (this._lightmapBakedType!==LightSprite.LIGHTMAPBAKEDTYPE_BAKED)&&((this.scene)._defineDatas.add(Scene3D.SHADERDEFINE_SPOTLIGHT));
  39800. }
  39801. /**
  39802. *@inheritDoc
  39803. */
  39804. __proto._onInActive=function(){
  39805. _super.prototype._onInActive.call(this);
  39806. (this._lightmapBakedType!==LightSprite.LIGHTMAPBAKEDTYPE_BAKED)&&((this.scene)._defineDatas.remove(Scene3D.SHADERDEFINE_SPOTLIGHT));
  39807. }
  39808. /**
  39809. *更新聚光相关渲染状态参数。
  39810. *@param state 渲染状态参数。
  39811. */
  39812. __proto._prepareToScene=function(){
  39813. var scene=this._scene;
  39814. if (scene.enableLight && this.activeInHierarchy){
  39815. var defineDatas=scene._defineDatas;
  39816. var shaderValue=scene._shaderValues;
  39817. Vector3.scale(this.color,this._intensity,this._intensityColor);
  39818. shaderValue.setVector3(Scene3D.SPOTLIGHTCOLOR,this._intensityColor);
  39819. shaderValue.setVector3(Scene3D.SPOTLIGHTPOS,this.transform.position);
  39820. this.transform.worldMatrix.getForward(this._direction);
  39821. Vector3.normalize(this._direction,this._direction);
  39822. shaderValue.setVector3(Scene3D.SPOTLIGHTDIRECTION,this._direction);
  39823. shaderValue.setNumber(Scene3D.SPOTLIGHTRANGE,this.range);
  39824. shaderValue.setNumber(Scene3D.SPOTLIGHTSPOTANGLE,this.spotAngle *Math.PI / 180);
  39825. return true;
  39826. }else {
  39827. return false;
  39828. }
  39829. }
  39830. /**
  39831. *@inheritDoc
  39832. */
  39833. __proto._parse=function(data,spriteMap){
  39834. _super.prototype._parse.call(this,data,spriteMap);
  39835. this.range=data.range;
  39836. this.spotAngle=data.spotAngle;
  39837. }
  39838. /**
  39839. *设置聚光灯的锥形角度。
  39840. *@param value 聚光灯的锥形角度。
  39841. */
  39842. /**
  39843. *获取聚光灯的锥形角度。
  39844. *@return 聚光灯的锥形角度。
  39845. */
  39846. __getset(0,__proto,'spotAngle',function(){
  39847. return this._spotAngle;
  39848. },function(value){
  39849. this._spotAngle=Math.max(Math.min(value,180),0);
  39850. });
  39851. /**
  39852. *设置聚光的范围。
  39853. *@param value 聚光的范围值。
  39854. */
  39855. /**
  39856. *获取聚光的范围。
  39857. *@return 聚光的范围值。
  39858. */
  39859. __getset(0,__proto,'range',function(){
  39860. return this._range;
  39861. },function(value){
  39862. this._range=value;
  39863. });
  39864. __static(SpotLight,
  39865. ['_tempMatrix0',function(){return this._tempMatrix0=new Matrix4x4();},'_tempMatrix1',function(){return this._tempMatrix1=new Matrix4x4();}
  39866. ]);
  39867. return SpotLight;
  39868. })(LightSprite)
  39869. /**
  39870. *<code>DirectionLight</code> 类用于创建平行光。
  39871. */
  39872. //class laya.d3.core.light.DirectionLight extends laya.d3.core.light.LightSprite
  39873. var DirectionLight=(function(_super){
  39874. function DirectionLight(){
  39875. /**@private */
  39876. this._direction=null;
  39877. DirectionLight.__super.call(this);
  39878. this._direction=new Vector3();
  39879. }
  39880. __class(DirectionLight,'laya.d3.core.light.DirectionLight',_super);
  39881. var __proto=DirectionLight.prototype;
  39882. /**
  39883. *@private
  39884. */
  39885. __proto._initShadow=function(){
  39886. if (this._shadow){
  39887. this._parallelSplitShadowMap=new ParallelSplitShadowMap();
  39888. this.scene.parallelSplitShadowMaps.push(this._parallelSplitShadowMap);
  39889. this.transform.worldMatrix.getForward(this._direction);
  39890. Vector3.normalize(this._direction,this._direction);
  39891. this._parallelSplitShadowMap.setInfo(this.scene,this._shadowFarPlane,this._direction,this._shadowMapSize,this._shadowMapCount,this._shadowMapPCFType);
  39892. }else {
  39893. var defineDatas=(this._scene)._defineDatas;
  39894. var parallelSplitShadowMaps=this.scene.parallelSplitShadowMaps;
  39895. parallelSplitShadowMaps.splice(parallelSplitShadowMaps.indexOf(this._parallelSplitShadowMap),1);
  39896. this._parallelSplitShadowMap.disposeAllRenderTarget();
  39897. this._parallelSplitShadowMap=null;
  39898. defineDatas.remove(Scene3D.SHADERDEFINE_SHADOW_PSSM1);
  39899. defineDatas.remove(Scene3D.SHADERDEFINE_SHADOW_PSSM2);
  39900. defineDatas.remove(Scene3D.SHADERDEFINE_SHADOW_PSSM3);
  39901. }
  39902. }
  39903. /**
  39904. *@inheritDoc
  39905. */
  39906. __proto._onActive=function(){
  39907. _super.prototype._onActive.call(this);
  39908. this._shadow && (this._initShadow());
  39909. (this._lightmapBakedType!==LightSprite.LIGHTMAPBAKEDTYPE_BAKED)&&((this._scene)._defineDatas.add(Scene3D.SHADERDEFINE_DIRECTIONLIGHT));
  39910. }
  39911. /**
  39912. *@inheritDoc
  39913. */
  39914. __proto._onInActive=function(){
  39915. _super.prototype._onInActive.call(this);
  39916. (this._lightmapBakedType!==LightSprite.LIGHTMAPBAKEDTYPE_BAKED)&&((this._scene)._defineDatas.remove(Scene3D.SHADERDEFINE_DIRECTIONLIGHT));
  39917. }
  39918. /**
  39919. *更新平行光相关渲染状态参数。
  39920. *@param state 渲染状态参数。
  39921. */
  39922. __proto._prepareToScene=function(){
  39923. var scene=this._scene;
  39924. if (scene.enableLight && this.activeInHierarchy){
  39925. var defineDatas=scene._defineDatas;
  39926. var shaderValue=scene._shaderValues;
  39927. Vector3.scale(this.color,this._intensity,this._intensityColor);
  39928. shaderValue.setVector3(Scene3D.LIGHTDIRCOLOR,this._intensityColor);
  39929. this.transform.worldMatrix.getForward(this._direction);
  39930. Vector3.normalize(this._direction,this._direction);
  39931. shaderValue.setVector3(Scene3D.LIGHTDIRECTION,this._direction);
  39932. return true;
  39933. }else {
  39934. return false;
  39935. }
  39936. }
  39937. /**
  39938. *@inheritDoc
  39939. */
  39940. __getset(0,__proto,'shadow',_super.prototype._$get_shadow,function(value){
  39941. if (this._shadow!==value){
  39942. this._shadow=value;
  39943. (this.scene)&& (this._initShadow());
  39944. }
  39945. });
  39946. return DirectionLight;
  39947. })(LightSprite)
  39948. /**
  39949. *<code>TrailSprite3D</code> 类用于创建拖尾渲染精灵。
  39950. */
  39951. //class laya.d3.core.trail.TrailSprite3D extends laya.d3.core.RenderableSprite3D
  39952. var TrailSprite3D=(function(_super){
  39953. function TrailSprite3D(){
  39954. /**@private */
  39955. //this._geometryFilter=null;
  39956. TrailSprite3D.__super.call(this,this.name);
  39957. this._render=new TrailRenderer(this);
  39958. this._geometryFilter=new TrailFilter(this);
  39959. }
  39960. __class(TrailSprite3D,'laya.d3.core.trail.TrailSprite3D',_super);
  39961. var __proto=TrailSprite3D.prototype;
  39962. /**
  39963. *@inheritDoc
  39964. */
  39965. __proto._parse=function(data,spriteMap){
  39966. laya.d3.core.Sprite3D.prototype._parse.call(this,data,spriteMap);
  39967. var render=this._render;
  39968. var filter=this._geometryFilter;
  39969. var i=0,j=0;
  39970. var materials=data.materials;
  39971. if (materials){
  39972. var sharedMaterials=render.sharedMaterials;
  39973. var materialCount=materials.length;
  39974. sharedMaterials.length=materialCount;
  39975. for (i=0;i < materialCount;i++)
  39976. sharedMaterials[i]=Loader.getRes(materials[i].path);
  39977. render.sharedMaterials=sharedMaterials;
  39978. }
  39979. filter.time=data.time;
  39980. filter.minVertexDistance=data.minVertexDistance;
  39981. filter.widthMultiplier=data.widthMultiplier;
  39982. filter.textureMode=data.textureMode;
  39983. (data.alignment !=null)&& (filter.alignment=data.alignment);
  39984. var widthCurve=[];
  39985. var widthCurveData=data.widthCurve;
  39986. for (i=0,j=widthCurveData.length;i < j;i++){
  39987. var trailkeyframe=new FloatKeyframe();
  39988. trailkeyframe.time=widthCurveData[i].time;
  39989. trailkeyframe.inTangent=widthCurveData[i].inTangent;
  39990. trailkeyframe.outTangent=widthCurveData[i].outTangent;
  39991. trailkeyframe.value=widthCurveData[i].value;
  39992. widthCurve.push(trailkeyframe);
  39993. }
  39994. filter.widthCurve=widthCurve;
  39995. var colorGradientData=data.colorGradient;
  39996. var colorKeys=colorGradientData.colorKeys;
  39997. var alphaKeys=colorGradientData.alphaKeys;
  39998. var colorGradient=new Gradient(colorKeys.length,alphaKeys.length);
  39999. colorGradient.mode=colorGradientData.mode;
  40000. for (i=0,j=colorKeys.length;i < j;i++){
  40001. var colorKey=colorKeys[i];
  40002. colorGradient.addColorRGB(colorKey.time,new Color(colorKey.value[0],colorKey.value[1],colorKey.value[2],1.0));
  40003. }
  40004. for (i=0,j=alphaKeys.length;i < j;i++){
  40005. var alphaKey=alphaKeys[i];
  40006. colorGradient.addColorAlpha(alphaKey.time,alphaKey.value);
  40007. }
  40008. filter.colorGradient=colorGradient;
  40009. }
  40010. /**
  40011. *@inheritDoc
  40012. */
  40013. __proto._onActive=function(){
  40014. _super.prototype._onActive.call(this);
  40015. this._transform.position.cloneTo(this._geometryFilter._lastPosition);
  40016. }
  40017. /**
  40018. *@inheritDoc
  40019. */
  40020. __proto._cloneTo=function(destObject,srcSprite,dstSprite){
  40021. laya.d3.core.Sprite3D.prototype._cloneTo.call(this,destObject,srcSprite,dstSprite);
  40022. var i=0,j=0;
  40023. var destTrailSprite3D=destObject;
  40024. var destTrailFilter=destTrailSprite3D.trailFilter;
  40025. destTrailFilter.time=this.trailFilter.time;
  40026. destTrailFilter.minVertexDistance=this.trailFilter.minVertexDistance;
  40027. destTrailFilter.widthMultiplier=this.trailFilter.widthMultiplier;
  40028. destTrailFilter.textureMode=this.trailFilter.textureMode;
  40029. var widthCurveData=this.trailFilter.widthCurve;
  40030. var widthCurve=[];
  40031. for (i=0,j=widthCurveData.length;i < j;i++){
  40032. var keyFrame=new FloatKeyframe();
  40033. widthCurveData[i].cloneTo(keyFrame);
  40034. widthCurve.push(keyFrame);
  40035. }
  40036. destTrailFilter.widthCurve=widthCurve;
  40037. var destColorGradient=new Gradient(this.trailFilter.colorGradient.maxColorRGBKeysCount,this.trailFilter.colorGradient.maxColorAlphaKeysCount);
  40038. this.trailFilter.colorGradient.cloneTo(destColorGradient);
  40039. destTrailFilter.colorGradient=destColorGradient;
  40040. var destTrailRender=destTrailSprite3D.trailRenderer;
  40041. destTrailRender.sharedMaterial=this.trailRenderer.sharedMaterial;
  40042. }
  40043. /**
  40044. *<p>销毁此对象。</p>
  40045. *@param destroyChild 是否同时销毁子节点,若值为true,则销毁子节点,否则不销毁子节点。
  40046. */
  40047. __proto.destroy=function(destroyChild){
  40048. (destroyChild===void 0)&& (destroyChild=true);
  40049. if (this.destroyed)
  40050. return;
  40051. _super.prototype.destroy.call(this,destroyChild);
  40052. (this._geometryFilter).destroy();
  40053. this._geometryFilter=null;
  40054. }
  40055. /**
  40056. *获取Trail过滤器。
  40057. *@return Trail过滤器。
  40058. */
  40059. __getset(0,__proto,'trailFilter',function(){
  40060. return this._geometryFilter;
  40061. });
  40062. /**
  40063. *获取Trail渲染器。
  40064. *@return Trail渲染器。
  40065. */
  40066. __getset(0,__proto,'trailRenderer',function(){
  40067. return this._render;
  40068. });
  40069. TrailSprite3D.__init__=function(){
  40070. TrailSprite3D.SHADERDEFINE_GRADIENTMODE_BLEND=TrailSprite3D.shaderDefines.registerDefine("GRADIENTMODE_BLEND");
  40071. }
  40072. TrailSprite3D.SHADERDEFINE_GRADIENTMODE_BLEND=0;
  40073. __static(TrailSprite3D,
  40074. ['CURTIME',function(){return this.CURTIME=Shader3D.propertyNameToID("u_CurTime");},'LIFETIME',function(){return this.LIFETIME=Shader3D.propertyNameToID("u_LifeTime");},'WIDTHCURVE',function(){return this.WIDTHCURVE=Shader3D.propertyNameToID("u_WidthCurve");},'WIDTHCURVEKEYLENGTH',function(){return this.WIDTHCURVEKEYLENGTH=Shader3D.propertyNameToID("u_WidthCurveKeyLength");},'GRADIENTCOLORKEY',function(){return this.GRADIENTCOLORKEY=Shader3D.propertyNameToID("u_GradientColorkey");},'GRADIENTALPHAKEY',function(){return this.GRADIENTALPHAKEY=Shader3D.propertyNameToID("u_GradientAlphakey");},'shaderDefines',function(){return this.shaderDefines=new ShaderDefines(RenderableSprite3D.shaderDefines);}
  40075. ]);
  40076. return TrailSprite3D;
  40077. })(RenderableSprite3D)
  40078. /**
  40079. *<code>ShuriKenParticle3D</code> 3D粒子。
  40080. */
  40081. //class laya.d3.core.particleShuriKen.ShuriKenParticle3D extends laya.d3.core.RenderableSprite3D
  40082. var ShuriKenParticle3D=(function(_super){
  40083. function ShuriKenParticle3D(){
  40084. /**@private */
  40085. //this._particleSystem=null;
  40086. ShuriKenParticle3D.__super.call(this,null);
  40087. this._render=new ShurikenParticleRenderer(this);
  40088. this._particleSystem=new ShurikenParticleSystem(this);
  40089. var elements=this._render._renderElements;
  40090. var element=elements[0]=new RenderElement();
  40091. element.setTransform(this._transform);
  40092. element.render=this._render;
  40093. element.setGeometry(this._particleSystem);
  40094. element.material=ShurikenParticleMaterial.defaultMaterial;
  40095. }
  40096. __class(ShuriKenParticle3D,'laya.d3.core.particleShuriKen.ShuriKenParticle3D',_super);
  40097. var __proto=ShuriKenParticle3D.prototype;
  40098. /**
  40099. *@private
  40100. */
  40101. __proto._initParticleVelocity=function(gradientData){
  40102. var gradient=new GradientDataNumber();
  40103. var velocitysData=gradientData.velocitys;
  40104. for (var i=0,n=velocitysData.length;i < n;i++){
  40105. var valueData=velocitysData[i];
  40106. gradient.add(valueData.key,valueData.value);
  40107. }
  40108. return gradient;
  40109. }
  40110. /**
  40111. *@private
  40112. */
  40113. __proto._initParticleColor=function(gradientColorData){
  40114. var gradientColor=new Gradient(4,4);
  40115. var alphasData=gradientColorData.alphas;
  40116. var i=0,n=0;
  40117. for (i=0,n=alphasData.length;i < n;i++){
  40118. var alphaData=alphasData[i];
  40119. if ((i===3)&& ((alphaData.key!==1))){
  40120. alphaData.key=1;
  40121. console.log("GradientDataColor warning:the forth key is be force set to 1.");
  40122. }
  40123. gradientColor.addColorAlpha(alphaData.key,alphaData.value);
  40124. };
  40125. var rgbsData=gradientColorData.rgbs;
  40126. for (i=0,n=rgbsData.length;i < n;i++){
  40127. var rgbData=rgbsData[i];
  40128. var rgbValue=rgbData.value;
  40129. if ((i===3)&& ((rgbData.key!==1))){
  40130. rgbData.key=1;
  40131. console.log("GradientDataColor warning:the forth key is be force set to 1.");
  40132. }
  40133. gradientColor.addColorRGB(rgbData.key,new Color(rgbValue[0],rgbValue[1],rgbValue[2],1.0));
  40134. }
  40135. return gradientColor;
  40136. }
  40137. /**
  40138. *@private
  40139. */
  40140. __proto._initParticleSize=function(gradientSizeData){
  40141. var gradientSize=new GradientDataNumber();
  40142. var sizesData=gradientSizeData.sizes;
  40143. for (var i=0,n=sizesData.length;i < n;i++){
  40144. var valueData=sizesData[i];
  40145. gradientSize.add(valueData.key,valueData.value);
  40146. }
  40147. return gradientSize;
  40148. }
  40149. /**
  40150. *@private
  40151. */
  40152. __proto._initParticleRotation=function(gradientData){
  40153. var gradient=new GradientDataNumber();
  40154. var angularVelocitysData=gradientData.angularVelocitys;
  40155. for (var i=0,n=angularVelocitysData.length;i < n;i++){
  40156. var valueData=angularVelocitysData[i];
  40157. gradient.add(valueData.key,valueData.value / 180.0 *Math.PI);
  40158. }
  40159. return gradient;
  40160. }
  40161. /**
  40162. *@private
  40163. */
  40164. __proto._initParticleFrame=function(overTimeFramesData){
  40165. var overTimeFrame=new GradientDataInt();
  40166. var framesData=overTimeFramesData.frames;
  40167. for (var i=0,n=framesData.length;i < n;i++){
  40168. var frameData=framesData[i];
  40169. overTimeFrame.add(frameData.key,frameData.value);
  40170. }
  40171. return overTimeFrame;
  40172. }
  40173. /**
  40174. *@inheritDoc
  40175. */
  40176. __proto._parse=function(data,spriteMap){
  40177. laya.d3.core.Sprite3D.prototype._parse.call(this,data,spriteMap);
  40178. var anglelToRad=Math.PI / 180.0;
  40179. var i=0,n=0;
  40180. var particleRender=this.particleRenderer;
  40181. var material;
  40182. var materialData=data.material;
  40183. (materialData)&& (material=Loader.getRes(materialData.path));
  40184. particleRender.sharedMaterial=material;
  40185. var meshPath=data.meshPath;
  40186. (meshPath)&& (particleRender.mesh=Loader.getRes(meshPath));
  40187. particleRender.renderMode=data.renderMode;
  40188. particleRender.stretchedBillboardCameraSpeedScale=data.stretchedBillboardCameraSpeedScale;
  40189. particleRender.stretchedBillboardSpeedScale=data.stretchedBillboardSpeedScale;
  40190. particleRender.stretchedBillboardLengthScale=data.stretchedBillboardLengthScale;
  40191. particleRender.sortingFudge=data.sortingFudge ? data.sortingFudge :0.0;
  40192. var particleSystem=this.particleSystem;
  40193. particleSystem.isPerformanceMode=data.isPerformanceMode;
  40194. particleSystem.duration=data.duration;
  40195. particleSystem.looping=data.looping;
  40196. particleSystem.prewarm=data.prewarm;
  40197. particleSystem.startDelayType=data.startDelayType;
  40198. particleSystem.startDelay=data.startDelay;
  40199. particleSystem.startDelayMin=data.startDelayMin;
  40200. particleSystem.startDelayMax=data.startDelayMax;
  40201. particleSystem.startLifetimeType=data.startLifetimeType;
  40202. particleSystem.startLifetimeConstant=data.startLifetimeConstant;
  40203. particleSystem.startLifeTimeGradient=ShuriKenParticle3D._initStartLife(data.startLifetimeGradient);
  40204. particleSystem.startLifetimeConstantMin=data.startLifetimeConstantMin;
  40205. particleSystem.startLifetimeConstantMax=data.startLifetimeConstantMax;
  40206. particleSystem.startLifeTimeGradientMin=ShuriKenParticle3D._initStartLife(data.startLifetimeGradientMin);
  40207. particleSystem.startLifeTimeGradientMax=ShuriKenParticle3D._initStartLife(data.startLifetimeGradientMax);
  40208. particleSystem.startSpeedType=data.startSpeedType;
  40209. particleSystem.startSpeedConstant=data.startSpeedConstant;
  40210. particleSystem.startSpeedConstantMin=data.startSpeedConstantMin;
  40211. particleSystem.startSpeedConstantMax=data.startSpeedConstantMax;
  40212. particleSystem.threeDStartSize=data.threeDStartSize;
  40213. particleSystem.startSizeType=data.startSizeType;
  40214. particleSystem.startSizeConstant=data.startSizeConstant;
  40215. var startSizeConstantSeparateArray=data.startSizeConstantSeparate;
  40216. var startSizeConstantSeparateElement=particleSystem.startSizeConstantSeparate;
  40217. startSizeConstantSeparateElement.x=startSizeConstantSeparateArray[0];
  40218. startSizeConstantSeparateElement.y=startSizeConstantSeparateArray[1];
  40219. startSizeConstantSeparateElement.z=startSizeConstantSeparateArray[2];
  40220. particleSystem.startSizeConstantMin=data.startSizeConstantMin;
  40221. particleSystem.startSizeConstantMax=data.startSizeConstantMax;
  40222. var startSizeConstantMinSeparateArray=data.startSizeConstantMinSeparate;
  40223. var startSizeConstantMinSeparateElement=particleSystem.startSizeConstantMinSeparate;
  40224. startSizeConstantMinSeparateElement.x=startSizeConstantMinSeparateArray[0];
  40225. startSizeConstantMinSeparateElement.y=startSizeConstantMinSeparateArray[1];
  40226. startSizeConstantMinSeparateElement.z=startSizeConstantMinSeparateArray[2];
  40227. var startSizeConstantMaxSeparateArray=data.startSizeConstantMaxSeparate;
  40228. var startSizeConstantMaxSeparateElement=particleSystem.startSizeConstantMaxSeparate;
  40229. startSizeConstantMaxSeparateElement.x=startSizeConstantMaxSeparateArray[0];
  40230. startSizeConstantMaxSeparateElement.y=startSizeConstantMaxSeparateArray[1];
  40231. startSizeConstantMaxSeparateElement.z=startSizeConstantMaxSeparateArray[2];
  40232. particleSystem.threeDStartRotation=data.threeDStartRotation;
  40233. particleSystem.startRotationType=data.startRotationType;
  40234. particleSystem.startRotationConstant=data.startRotationConstant *anglelToRad;
  40235. var startRotationConstantSeparateArray=data.startRotationConstantSeparate;
  40236. var startRotationConstantSeparateElement=particleSystem.startRotationConstantSeparate;
  40237. startRotationConstantSeparateElement.x=startRotationConstantSeparateArray[0] *anglelToRad;
  40238. startRotationConstantSeparateElement.y=startRotationConstantSeparateArray[1] *anglelToRad;
  40239. startRotationConstantSeparateElement.z=startRotationConstantSeparateArray[2] *anglelToRad;
  40240. particleSystem.startRotationConstantMin=data.startRotationConstantMin *anglelToRad;
  40241. particleSystem.startRotationConstantMax=data.startRotationConstantMax *anglelToRad;
  40242. var startRotationConstantMinSeparateArray=data.startRotationConstantMinSeparate;
  40243. var startRotationConstantMinSeparateElement=particleSystem.startRotationConstantMinSeparate;
  40244. startRotationConstantMinSeparateElement.x=startRotationConstantMinSeparateArray[0] *anglelToRad;
  40245. startRotationConstantMinSeparateElement.y=startRotationConstantMinSeparateArray[1] *anglelToRad;
  40246. startRotationConstantMinSeparateElement.z=startRotationConstantMinSeparateArray[2] *anglelToRad;
  40247. var startRotationConstantMaxSeparateArray=data.startRotationConstantMaxSeparate;
  40248. var startRotationConstantMaxSeparateElement=particleSystem.startRotationConstantMaxSeparate;
  40249. startRotationConstantMaxSeparateElement.x=startRotationConstantMaxSeparateArray[0] *anglelToRad;
  40250. startRotationConstantMaxSeparateElement.y=startRotationConstantMaxSeparateArray[1] *anglelToRad;
  40251. startRotationConstantMaxSeparateElement.z=startRotationConstantMaxSeparateArray[2] *anglelToRad;
  40252. particleSystem.randomizeRotationDirection=data.randomizeRotationDirection;
  40253. particleSystem.startColorType=data.startColorType;
  40254. var startColorConstantArray=data.startColorConstant;
  40255. var startColorConstantElement=particleSystem.startColorConstant;
  40256. startColorConstantElement.x=startColorConstantArray[0];
  40257. startColorConstantElement.y=startColorConstantArray[1];
  40258. startColorConstantElement.z=startColorConstantArray[2];
  40259. startColorConstantElement.w=startColorConstantArray[3];
  40260. var startColorConstantMinArray=data.startColorConstantMin;
  40261. var startColorConstantMinElement=particleSystem.startColorConstantMin;
  40262. startColorConstantMinElement.x=startColorConstantMinArray[0];
  40263. startColorConstantMinElement.y=startColorConstantMinArray[1];
  40264. startColorConstantMinElement.z=startColorConstantMinArray[2];
  40265. startColorConstantMinElement.w=startColorConstantMinArray[3];
  40266. var startColorConstantMaxArray=data.startColorConstantMax;
  40267. var startColorConstantMaxElement=particleSystem.startColorConstantMax;
  40268. startColorConstantMaxElement.x=startColorConstantMaxArray[0];
  40269. startColorConstantMaxElement.y=startColorConstantMaxArray[1];
  40270. startColorConstantMaxElement.z=startColorConstantMaxArray[2];
  40271. startColorConstantMaxElement.w=startColorConstantMaxArray[3];
  40272. particleSystem.gravityModifier=data.gravityModifier;
  40273. particleSystem.simulationSpace=data.simulationSpace;
  40274. particleSystem.scaleMode=data.scaleMode;
  40275. particleSystem.playOnAwake=data.playOnAwake;
  40276. particleSystem.maxParticles=data.maxParticles;
  40277. var autoRandomSeed=data.autoRandomSeed;
  40278. (autoRandomSeed !=null)&& (particleSystem.autoRandomSeed=autoRandomSeed);
  40279. var randomSeed=data.randomSeed;
  40280. (randomSeed !=null)&& (particleSystem.randomSeed[0]=randomSeed);
  40281. var emissionData=data.emission;
  40282. var emission=particleSystem.emission;
  40283. if (emissionData){
  40284. emission.emissionRate=emissionData.emissionRate;
  40285. var burstsData=emissionData.bursts;
  40286. if (burstsData)
  40287. for (i=0,n=burstsData.length;i < n;i++){
  40288. var brust=burstsData[i];
  40289. emission.addBurst(new Burst(brust.time,brust.min,brust.max));
  40290. }
  40291. emission.enbale=emissionData.enable;
  40292. }else {
  40293. emission.enbale=false;
  40294. };
  40295. var shapeData=data.shape;
  40296. if (shapeData){
  40297. var shape;
  40298. switch (shapeData.shapeType){
  40299. case 0:;
  40300. var sphereShape;
  40301. shape=sphereShape=new SphereShape();
  40302. sphereShape.radius=shapeData.sphereRadius;
  40303. sphereShape.emitFromShell=shapeData.sphereEmitFromShell;
  40304. sphereShape.randomDirection=shapeData.sphereRandomDirection;
  40305. break ;
  40306. case 1:;
  40307. var hemiSphereShape;
  40308. shape=hemiSphereShape=new HemisphereShape();
  40309. hemiSphereShape.radius=shapeData.hemiSphereRadius;
  40310. hemiSphereShape.emitFromShell=shapeData.hemiSphereEmitFromShell;
  40311. hemiSphereShape.randomDirection=shapeData.hemiSphereRandomDirection;
  40312. break ;
  40313. case 2:;
  40314. var coneShape;
  40315. shape=coneShape=new ConeShape();
  40316. coneShape.angle=shapeData.coneAngle *anglelToRad;
  40317. coneShape.radius=shapeData.coneRadius;
  40318. coneShape.length=shapeData.coneLength;
  40319. coneShape.emitType=shapeData.coneEmitType;
  40320. coneShape.randomDirection=shapeData.coneRandomDirection;
  40321. break ;
  40322. case 3:;
  40323. var boxShape;
  40324. shape=boxShape=new BoxShape();
  40325. boxShape.x=shapeData.boxX;
  40326. boxShape.y=shapeData.boxY;
  40327. boxShape.z=shapeData.boxZ;
  40328. boxShape.randomDirection=shapeData.boxRandomDirection;
  40329. break ;
  40330. case 7:;
  40331. var circleShape;
  40332. shape=circleShape=new CircleShape();
  40333. circleShape.radius=shapeData.circleRadius;
  40334. circleShape.arc=shapeData.circleArc *anglelToRad;
  40335. circleShape.emitFromEdge=shapeData.circleEmitFromEdge;
  40336. circleShape.randomDirection=shapeData.circleRandomDirection;
  40337. break ;
  40338. default :;
  40339. var tempShape;
  40340. shape=tempShape=new CircleShape();
  40341. tempShape.radius=shapeData.circleRadius;
  40342. tempShape.arc=shapeData.circleArc *anglelToRad;
  40343. tempShape.emitFromEdge=shapeData.circleEmitFromEdge;
  40344. tempShape.randomDirection=shapeData.circleRandomDirection;
  40345. break ;
  40346. }
  40347. shape.enable=shapeData.enable;
  40348. particleSystem.shape=shape;
  40349. };
  40350. var velocityOverLifetimeData=data.velocityOverLifetime;
  40351. if (velocityOverLifetimeData){
  40352. var velocityData=velocityOverLifetimeData.velocity;
  40353. var velocity;
  40354. switch (velocityData.type){
  40355. case 0:;
  40356. var constantData=velocityData.constant;
  40357. velocity=GradientVelocity.createByConstant(new Vector3(constantData[0],constantData[1],constantData[2]));
  40358. break ;
  40359. case 1:
  40360. velocity=GradientVelocity.createByGradient(this._initParticleVelocity(velocityData.gradientX),this._initParticleVelocity(velocityData.gradientY),this._initParticleVelocity(velocityData.gradientZ));
  40361. break ;
  40362. case 2:;
  40363. var constantMinData=velocityData.constantMin;
  40364. var constantMaxData=velocityData.constantMax;
  40365. velocity=GradientVelocity.createByRandomTwoConstant(new Vector3(constantMinData[0],constantMinData[1],constantMinData[2]),new Vector3(constantMaxData[0],constantMaxData[1],constantMaxData[2]));
  40366. break ;
  40367. case 3:
  40368. velocity=GradientVelocity.createByRandomTwoGradient(this._initParticleVelocity(velocityData.gradientXMin),this._initParticleVelocity(velocityData.gradientXMax),this._initParticleVelocity(velocityData.gradientYMin),this._initParticleVelocity(velocityData.gradientYMax),this._initParticleVelocity(velocityData.gradientZMin),this._initParticleVelocity(velocityData.gradientZMax));
  40369. break ;
  40370. };
  40371. var velocityOverLifetime=new VelocityOverLifetime(velocity);
  40372. velocityOverLifetime.space=velocityOverLifetimeData.space;
  40373. velocityOverLifetime.enbale=velocityOverLifetimeData.enable;
  40374. particleSystem.velocityOverLifetime=velocityOverLifetime;
  40375. };
  40376. var colorOverLifetimeData=data.colorOverLifetime;
  40377. if (colorOverLifetimeData){
  40378. var colorData=colorOverLifetimeData.color;
  40379. var color;
  40380. switch (colorData.type){
  40381. case 0:;
  40382. var constColorData=colorData.constant;
  40383. color=GradientColor.createByConstant(new Vector4(constColorData[0],constColorData[1],constColorData[2],constColorData[3]));
  40384. break ;
  40385. case 1:
  40386. color=GradientColor.createByGradient(this._initParticleColor(colorData.gradient));
  40387. break ;
  40388. case 2:;
  40389. var minConstColorData=colorData.constantMin;
  40390. var maxConstColorData=colorData.constantMax;
  40391. color=GradientColor.createByRandomTwoConstant(new Vector4(minConstColorData[0],minConstColorData[1],minConstColorData[2],minConstColorData[3]),new Vector4(maxConstColorData[0],maxConstColorData[1],maxConstColorData[2],maxConstColorData[3]));
  40392. break ;
  40393. case 3:
  40394. color=GradientColor.createByRandomTwoGradient(this._initParticleColor(colorData.gradientMin),this._initParticleColor(colorData.gradientMax));
  40395. break ;
  40396. };
  40397. var colorOverLifetime=new ColorOverLifetime(color);
  40398. colorOverLifetime.enbale=colorOverLifetimeData.enable;
  40399. particleSystem.colorOverLifetime=colorOverLifetime;
  40400. };
  40401. var sizeOverLifetimeData=data.sizeOverLifetime;
  40402. if (sizeOverLifetimeData){
  40403. var sizeData=sizeOverLifetimeData.size;
  40404. var size;
  40405. switch (sizeData.type){
  40406. case 0:
  40407. if (sizeData.separateAxes){
  40408. size=GradientSize.createByGradientSeparate(this._initParticleSize(sizeData.gradientX),this._initParticleSize(sizeData.gradientY),this._initParticleSize(sizeData.gradientZ));
  40409. }else {
  40410. size=GradientSize.createByGradient(this._initParticleSize(sizeData.gradient));
  40411. }
  40412. break ;
  40413. case 1:
  40414. if (sizeData.separateAxes){
  40415. var constantMinSeparateData=sizeData.constantMinSeparate;
  40416. var constantMaxSeparateData=sizeData.constantMaxSeparate;
  40417. size=GradientSize.createByRandomTwoConstantSeparate(new Vector3(constantMinSeparateData[0],constantMinSeparateData[1],constantMinSeparateData[2]),new Vector3(constantMaxSeparateData[0],constantMaxSeparateData[1],constantMaxSeparateData[2]));
  40418. }else {
  40419. size=GradientSize.createByRandomTwoConstant(sizeData.constantMin,sizeData.constantMax);
  40420. }
  40421. break ;
  40422. case 2:
  40423. if (sizeData.separateAxes){
  40424. size=GradientSize.createByRandomTwoGradientSeparate(this._initParticleSize(sizeData.gradientXMin),this._initParticleSize(sizeData.gradientYMin),this._initParticleSize(sizeData.gradientZMin),this._initParticleSize(sizeData.gradientXMax),this._initParticleSize(sizeData.gradientYMax),this._initParticleSize(sizeData.gradientZMax));
  40425. }else {
  40426. size=GradientSize.createByRandomTwoGradient(this._initParticleSize(sizeData.gradientMin),this._initParticleSize(sizeData.gradientMax));
  40427. }
  40428. break ;
  40429. };
  40430. var sizeOverLifetime=new SizeOverLifetime(size);
  40431. sizeOverLifetime.enbale=sizeOverLifetimeData.enable;
  40432. particleSystem.sizeOverLifetime=sizeOverLifetime;
  40433. };
  40434. var rotationOverLifetimeData=data.rotationOverLifetime;
  40435. if (rotationOverLifetimeData){
  40436. var angularVelocityData=rotationOverLifetimeData.angularVelocity;
  40437. var angularVelocity;
  40438. switch (angularVelocityData.type){
  40439. case 0:
  40440. if (angularVelocityData.separateAxes){
  40441. var conSep=angularVelocityData.constantSeparate;
  40442. angularVelocity=GradientAngularVelocity.createByConstantSeparate(new Vector3(conSep[0]*anglelToRad,conSep[1]*anglelToRad,conSep[2]*anglelToRad));
  40443. }else {
  40444. angularVelocity=GradientAngularVelocity.createByConstant(angularVelocityData.constant *anglelToRad);
  40445. }
  40446. break ;
  40447. case 1:
  40448. if (angularVelocityData.separateAxes){
  40449. angularVelocity=GradientAngularVelocity.createByGradientSeparate(this._initParticleRotation(angularVelocityData.gradientX),this._initParticleRotation(angularVelocityData.gradientY),this._initParticleRotation(angularVelocityData.gradientZ));
  40450. }else {
  40451. angularVelocity=GradientAngularVelocity.createByGradient(this._initParticleRotation(angularVelocityData.gradient));
  40452. }
  40453. break ;
  40454. case 2:
  40455. if (angularVelocityData.separateAxes){
  40456. var minSep=angularVelocityData.constantMinSeparate;
  40457. var maxSep=angularVelocityData.constantMaxSeparate;
  40458. angularVelocity=GradientAngularVelocity.createByRandomTwoConstantSeparate(new Vector3(minSep[0] *anglelToRad,minSep[1] *anglelToRad,minSep[2] *anglelToRad),new Vector3(maxSep[0] *anglelToRad,maxSep[1] *anglelToRad,maxSep[2] *anglelToRad));
  40459. }else {
  40460. angularVelocity=GradientAngularVelocity.createByRandomTwoConstant(angularVelocityData.constantMin *anglelToRad,angularVelocityData.constantMax *anglelToRad);
  40461. }
  40462. break ;
  40463. case 3:
  40464. if (angularVelocityData.separateAxes){
  40465. }else {
  40466. angularVelocity=GradientAngularVelocity.createByRandomTwoGradient(this._initParticleRotation(angularVelocityData.gradientMin),this._initParticleRotation(angularVelocityData.gradientMax));
  40467. }
  40468. break ;
  40469. };
  40470. var rotationOverLifetime=new RotationOverLifetime(angularVelocity);
  40471. rotationOverLifetime.enbale=rotationOverLifetimeData.enable;
  40472. particleSystem.rotationOverLifetime=rotationOverLifetime;
  40473. };
  40474. var textureSheetAnimationData=data.textureSheetAnimation;
  40475. if (textureSheetAnimationData){
  40476. var frameData=textureSheetAnimationData.frame;
  40477. var frameOverTime;
  40478. switch (frameData.type){
  40479. case 0:
  40480. frameOverTime=FrameOverTime.createByConstant(frameData.constant);
  40481. break ;
  40482. case 1:
  40483. frameOverTime=FrameOverTime.createByOverTime(this._initParticleFrame(frameData.overTime));
  40484. break ;
  40485. case 2:
  40486. frameOverTime=FrameOverTime.createByRandomTwoConstant(frameData.constantMin,frameData.constantMax);
  40487. break ;
  40488. case 3:
  40489. frameOverTime=FrameOverTime.createByRandomTwoOverTime(this._initParticleFrame(frameData.overTimeMin),this._initParticleFrame(frameData.overTimeMax));
  40490. break ;
  40491. };
  40492. var startFrameData=textureSheetAnimationData.startFrame;
  40493. var startFrame;
  40494. switch (startFrameData.type){
  40495. case 0:
  40496. startFrame=StartFrame.createByConstant(startFrameData.constant);
  40497. break ;
  40498. case 1:
  40499. startFrame=StartFrame.createByRandomTwoConstant(startFrameData.constantMin,startFrameData.constantMax);
  40500. break ;
  40501. };
  40502. var textureSheetAnimation=new TextureSheetAnimation(frameOverTime,startFrame);
  40503. textureSheetAnimation.enable=textureSheetAnimationData.enable;
  40504. var tilesData=textureSheetAnimationData.tiles;
  40505. textureSheetAnimation.tiles=new Vector2(tilesData[0],tilesData[1]);
  40506. textureSheetAnimation.type=textureSheetAnimationData.type;
  40507. textureSheetAnimation.randomRow=textureSheetAnimationData.randomRow;
  40508. var rowIndex=textureSheetAnimationData.rowIndex;
  40509. (rowIndex!==undefined)&& (textureSheetAnimation.rowIndex=rowIndex);
  40510. textureSheetAnimation.cycles=textureSheetAnimationData.cycles;
  40511. particleSystem.textureSheetAnimation=textureSheetAnimation;
  40512. }
  40513. }
  40514. /**
  40515. *@inheritDoc
  40516. */
  40517. __proto._activeHierarchy=function(activeChangeComponents){
  40518. laya.display.Node.prototype._activeHierarchy.call(this,activeChangeComponents);
  40519. (this.particleSystem.playOnAwake)&& (this.particleSystem.play());
  40520. }
  40521. /**
  40522. *@inheritDoc
  40523. */
  40524. __proto._inActiveHierarchy=function(activeChangeComponents){
  40525. laya.display.Node.prototype._inActiveHierarchy.call(this,activeChangeComponents);
  40526. (this.particleSystem.isAlive)&& (this.particleSystem.simulate(0,true));
  40527. }
  40528. /**
  40529. *@private
  40530. */
  40531. __proto._cloneTo=function(destObject,srcSprite,dstSprite){
  40532. var destShuriKenParticle3D=destObject;
  40533. var destParticleSystem=destShuriKenParticle3D._particleSystem;
  40534. this._particleSystem.cloneTo(destParticleSystem);
  40535. var destParticleRender=destShuriKenParticle3D._render;
  40536. var particleRender=this._render;
  40537. destParticleRender.sharedMaterials=particleRender.sharedMaterials;
  40538. destParticleRender.enable=particleRender.enable;
  40539. destParticleRender.renderMode=particleRender.renderMode;
  40540. destParticleRender.mesh=particleRender.mesh;
  40541. destParticleRender.stretchedBillboardCameraSpeedScale=particleRender.stretchedBillboardCameraSpeedScale;
  40542. destParticleRender.stretchedBillboardSpeedScale=particleRender.stretchedBillboardSpeedScale;
  40543. destParticleRender.stretchedBillboardLengthScale=particleRender.stretchedBillboardLengthScale;
  40544. destParticleRender.sortingFudge=particleRender.sortingFudge;
  40545. laya.d3.core.Sprite3D.prototype._cloneTo.call(this,destObject,srcSprite,dstSprite);
  40546. }
  40547. /**
  40548. *<p>销毁此对象。</p>
  40549. *@param destroyChild 是否同时销毁子节点,若值为true,则销毁子节点,否则不销毁子节点。
  40550. */
  40551. __proto.destroy=function(destroyChild){
  40552. (destroyChild===void 0)&& (destroyChild=true);
  40553. if (this.destroyed)
  40554. return;
  40555. _super.prototype.destroy.call(this,destroyChild);
  40556. this._particleSystem.destroy();
  40557. this._particleSystem=null;
  40558. }
  40559. /**
  40560. *获取粒子系统。
  40561. *@return 粒子系统。
  40562. */
  40563. __getset(0,__proto,'particleSystem',function(){
  40564. return this._particleSystem;
  40565. });
  40566. /**
  40567. *获取粒子渲染器。
  40568. *@return 粒子渲染器。
  40569. */
  40570. __getset(0,__proto,'particleRenderer',function(){
  40571. return this._render;
  40572. });
  40573. ShuriKenParticle3D.__init__=function(){
  40574. ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_BILLBOARD=ShuriKenParticle3D.shaderDefines.registerDefine("SPHERHBILLBOARD");
  40575. ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_STRETCHEDBILLBOARD=ShuriKenParticle3D.shaderDefines.registerDefine("STRETCHEDBILLBOARD");
  40576. ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_HORIZONTALBILLBOARD=ShuriKenParticle3D.shaderDefines.registerDefine("HORIZONTALBILLBOARD");
  40577. ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_VERTICALBILLBOARD=ShuriKenParticle3D.shaderDefines.registerDefine("VERTICALBILLBOARD");
  40578. ShuriKenParticle3D.SHADERDEFINE_COLOROVERLIFETIME=ShuriKenParticle3D.shaderDefines.registerDefine("COLOROVERLIFETIME");
  40579. ShuriKenParticle3D.SHADERDEFINE_RANDOMCOLOROVERLIFETIME=ShuriKenParticle3D.shaderDefines.registerDefine("RANDOMCOLOROVERLIFETIME");
  40580. ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMECONSTANT=ShuriKenParticle3D.shaderDefines.registerDefine("VELOCITYOVERLIFETIMECONSTANT");
  40581. ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMECURVE=ShuriKenParticle3D.shaderDefines.registerDefine("VELOCITYOVERLIFETIMECURVE");
  40582. ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCONSTANT=ShuriKenParticle3D.shaderDefines.registerDefine("VELOCITYOVERLIFETIMERANDOMCONSTANT");
  40583. ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCURVE=ShuriKenParticle3D.shaderDefines.registerDefine("VELOCITYOVERLIFETIMERANDOMCURVE");
  40584. ShuriKenParticle3D.SHADERDEFINE_TEXTURESHEETANIMATIONCURVE=ShuriKenParticle3D.shaderDefines.registerDefine("TEXTURESHEETANIMATIONCURVE");
  40585. ShuriKenParticle3D.SHADERDEFINE_TEXTURESHEETANIMATIONRANDOMCURVE=ShuriKenParticle3D.shaderDefines.registerDefine("TEXTURESHEETANIMATIONRANDOMCURVE");
  40586. ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIME=ShuriKenParticle3D.shaderDefines.registerDefine("ROTATIONOVERLIFETIME");
  40587. ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE=ShuriKenParticle3D.shaderDefines.registerDefine("ROTATIONOVERLIFETIMESEPERATE");
  40588. ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT=ShuriKenParticle3D.shaderDefines.registerDefine("ROTATIONOVERLIFETIMECONSTANT");
  40589. ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE=ShuriKenParticle3D.shaderDefines.registerDefine("ROTATIONOVERLIFETIMECURVE");
  40590. ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS=ShuriKenParticle3D.shaderDefines.registerDefine("ROTATIONOVERLIFETIMERANDOMCONSTANTS");
  40591. ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES=ShuriKenParticle3D.shaderDefines.registerDefine("ROTATIONOVERLIFETIMERANDOMCURVES");
  40592. ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMECURVE=ShuriKenParticle3D.shaderDefines.registerDefine("SIZEOVERLIFETIMECURVE");
  40593. ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMECURVESEPERATE=ShuriKenParticle3D.shaderDefines.registerDefine("SIZEOVERLIFETIMECURVESEPERATE");
  40594. ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVES=ShuriKenParticle3D.shaderDefines.registerDefine("SIZEOVERLIFETIMERANDOMCURVES");
  40595. ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVESSEPERATE=ShuriKenParticle3D.shaderDefines.registerDefine("SIZEOVERLIFETIMERANDOMCURVESSEPERATE");
  40596. ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_MESH=ShuriKenParticle3D.shaderDefines.registerDefine("RENDERMODE_MESH");
  40597. ShuriKenParticle3D.SHADERDEFINE_SHAPE=ShuriKenParticle3D.shaderDefines.registerDefine("SHAPE");
  40598. }
  40599. ShuriKenParticle3D._initStartLife=function(gradientData){
  40600. var gradient=new GradientDataNumber();
  40601. var startLifetimesData=gradientData.startLifetimes;
  40602. for (var i=0,n=startLifetimesData.length;i < n;i++){
  40603. var valueData=startLifetimesData[i];
  40604. gradient.add(valueData.key,valueData.value);
  40605. }
  40606. return gradient
  40607. }
  40608. ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_BILLBOARD=0;
  40609. ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_STRETCHEDBILLBOARD=0;
  40610. ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_HORIZONTALBILLBOARD=0;
  40611. ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_VERTICALBILLBOARD=0;
  40612. ShuriKenParticle3D.SHADERDEFINE_COLOROVERLIFETIME=0;
  40613. ShuriKenParticle3D.SHADERDEFINE_RANDOMCOLOROVERLIFETIME=0;
  40614. ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMECONSTANT=0;
  40615. ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMECURVE=0;
  40616. ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCONSTANT=0;
  40617. ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCURVE=0;
  40618. ShuriKenParticle3D.SHADERDEFINE_TEXTURESHEETANIMATIONCURVE=0;
  40619. ShuriKenParticle3D.SHADERDEFINE_TEXTURESHEETANIMATIONRANDOMCURVE=0;
  40620. ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIME=0;
  40621. ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE=0;
  40622. ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT=0;
  40623. ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE=0;
  40624. ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS=0;
  40625. ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES=0;
  40626. ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMECURVE=0;
  40627. ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMECURVESEPERATE=0;
  40628. ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVES=0;
  40629. ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVESSEPERATE=0;
  40630. ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_MESH=0;
  40631. ShuriKenParticle3D.SHADERDEFINE_SHAPE=0;
  40632. __static(ShuriKenParticle3D,
  40633. ['WORLDPOSITION',function(){return this.WORLDPOSITION=Shader3D.propertyNameToID("u_WorldPosition");},'WORLDROTATION',function(){return this.WORLDROTATION=Shader3D.propertyNameToID("u_WorldRotation");},'POSITIONSCALE',function(){return this.POSITIONSCALE=Shader3D.propertyNameToID("u_PositionScale");},'SIZESCALE',function(){return this.SIZESCALE=Shader3D.propertyNameToID("u_SizeScale");},'SCALINGMODE',function(){return this.SCALINGMODE=Shader3D.propertyNameToID("u_ScalingMode");},'GRAVITY',function(){return this.GRAVITY=Shader3D.propertyNameToID("u_Gravity");},'THREEDSTARTROTATION',function(){return this.THREEDSTARTROTATION=Shader3D.propertyNameToID("u_ThreeDStartRotation");},'STRETCHEDBILLBOARDLENGTHSCALE',function(){return this.STRETCHEDBILLBOARDLENGTHSCALE=Shader3D.propertyNameToID("u_StretchedBillboardLengthScale");},'STRETCHEDBILLBOARDSPEEDSCALE',function(){return this.STRETCHEDBILLBOARDSPEEDSCALE=Shader3D.propertyNameToID("u_StretchedBillboardSpeedScale");},'SIMULATIONSPACE',function(){return this.SIMULATIONSPACE=Shader3D.propertyNameToID("u_SimulationSpace");},'CURRENTTIME',function(){return this.CURRENTTIME=Shader3D.propertyNameToID("u_CurrentTime");},'VOLVELOCITYCONST',function(){return this.VOLVELOCITYCONST=Shader3D.propertyNameToID("u_VOLVelocityConst");},'VOLVELOCITYGRADIENTX',function(){return this.VOLVELOCITYGRADIENTX=Shader3D.propertyNameToID("u_VOLVelocityGradientX");},'VOLVELOCITYGRADIENTY',function(){return this.VOLVELOCITYGRADIENTY=Shader3D.propertyNameToID("u_VOLVelocityGradientY");},'VOLVELOCITYGRADIENTZ',function(){return this.VOLVELOCITYGRADIENTZ=Shader3D.propertyNameToID("u_VOLVelocityGradientZ");},'VOLVELOCITYCONSTMAX',function(){return this.VOLVELOCITYCONSTMAX=Shader3D.propertyNameToID("u_VOLVelocityConstMax");},'VOLVELOCITYGRADIENTXMAX',function(){return this.VOLVELOCITYGRADIENTXMAX=Shader3D.propertyNameToID("u_VOLVelocityGradientMaxX");},'VOLVELOCITYGRADIENTYMAX',function(){return this.VOLVELOCITYGRADIENTYMAX=Shader3D.propertyNameToID("u_VOLVelocityGradientMaxY");},'VOLVELOCITYGRADIENTZMAX',function(){return this.VOLVELOCITYGRADIENTZMAX=Shader3D.propertyNameToID("u_VOLVelocityGradientMaxZ");},'VOLSPACETYPE',function(){return this.VOLSPACETYPE=Shader3D.propertyNameToID("u_VOLSpaceType");},'COLOROVERLIFEGRADIENTALPHAS',function(){return this.COLOROVERLIFEGRADIENTALPHAS=Shader3D.propertyNameToID("u_ColorOverLifeGradientAlphas");},'COLOROVERLIFEGRADIENTCOLORS',function(){return this.COLOROVERLIFEGRADIENTCOLORS=Shader3D.propertyNameToID("u_ColorOverLifeGradientColors");},'MAXCOLOROVERLIFEGRADIENTALPHAS',function(){return this.MAXCOLOROVERLIFEGRADIENTALPHAS=Shader3D.propertyNameToID("u_MaxColorOverLifeGradientAlphas");},'MAXCOLOROVERLIFEGRADIENTCOLORS',function(){return this.MAXCOLOROVERLIFEGRADIENTCOLORS=Shader3D.propertyNameToID("u_MaxColorOverLifeGradientColors");},'SOLSIZEGRADIENT',function(){return this.SOLSIZEGRADIENT=Shader3D.propertyNameToID("u_SOLSizeGradient");},'SOLSIZEGRADIENTX',function(){return this.SOLSIZEGRADIENTX=Shader3D.propertyNameToID("u_SOLSizeGradientX");},'SOLSIZEGRADIENTY',function(){return this.SOLSIZEGRADIENTY=Shader3D.propertyNameToID("u_SOLSizeGradientY");},'SOLSizeGradientZ',function(){return this.SOLSizeGradientZ=Shader3D.propertyNameToID("u_SOLSizeGradientZ");},'SOLSizeGradientMax',function(){return this.SOLSizeGradientMax=Shader3D.propertyNameToID("u_SOLSizeGradientMax");},'SOLSIZEGRADIENTXMAX',function(){return this.SOLSIZEGRADIENTXMAX=Shader3D.propertyNameToID("u_SOLSizeGradientMaxX");},'SOLSIZEGRADIENTYMAX',function(){return this.SOLSIZEGRADIENTYMAX=Shader3D.propertyNameToID("u_SOLSizeGradientMaxY");},'SOLSizeGradientZMAX',function(){return this.SOLSizeGradientZMAX=Shader3D.propertyNameToID("u_SOLSizeGradientMaxZ");},'ROLANGULARVELOCITYCONST',function(){return this.ROLANGULARVELOCITYCONST=Shader3D.propertyNameToID("u_ROLAngularVelocityConst");},'ROLANGULARVELOCITYCONSTSEPRARATE',function(){return this.ROLANGULARVELOCITYCONSTSEPRARATE=Shader3D.propertyNameToID("u_ROLAngularVelocityConstSeprarate");},'ROLANGULARVELOCITYGRADIENT',function(){return this.ROLANGULARVELOCITYGRADIENT=Shader3D.propertyNameToID("u_ROLAngularVelocityGradient");},'ROLANGULARVELOCITYGRADIENTX',function(){return this.ROLANGULARVELOCITYGRADIENTX=Shader3D.propertyNameToID("u_ROLAngularVelocityGradientX");},'ROLANGULARVELOCITYGRADIENTY',function(){return this.ROLANGULARVELOCITYGRADIENTY=Shader3D.propertyNameToID("u_ROLAngularVelocityGradientY");},'ROLANGULARVELOCITYGRADIENTZ',function(){return this.ROLANGULARVELOCITYGRADIENTZ=Shader3D.propertyNameToID("u_ROLAngularVelocityGradientZ");},'ROLANGULARVELOCITYCONSTMAX',function(){return this.ROLANGULARVELOCITYCONSTMAX=Shader3D.propertyNameToID("u_ROLAngularVelocityConstMax");},'ROLANGULARVELOCITYCONSTMAXSEPRARATE',function(){return this.ROLANGULARVELOCITYCONSTMAXSEPRARATE=Shader3D.propertyNameToID("u_ROLAngularVelocityConstMaxSeprarate");},'ROLANGULARVELOCITYGRADIENTMAX',function(){return this.ROLANGULARVELOCITYGRADIENTMAX=Shader3D.propertyNameToID("u_ROLAngularVelocityGradientMax");},'ROLANGULARVELOCITYGRADIENTXMAX',function(){return this.ROLANGULARVELOCITYGRADIENTXMAX=Shader3D.propertyNameToID("u_ROLAngularVelocityGradientMaxX");},'ROLANGULARVELOCITYGRADIENTYMAX',function(){return this.ROLANGULARVELOCITYGRADIENTYMAX=Shader3D.propertyNameToID("u_ROLAngularVelocityGradientMaxY");},'ROLANGULARVELOCITYGRADIENTZMAX',function(){return this.ROLANGULARVELOCITYGRADIENTZMAX=Shader3D.propertyNameToID("u_ROLAngularVelocityGradientMaxZ");},'ROLANGULARVELOCITYGRADIENTWMAX',function(){return this.ROLANGULARVELOCITYGRADIENTWMAX=Shader3D.propertyNameToID("u_ROLAngularVelocityGradientMaxW");},'TEXTURESHEETANIMATIONCYCLES',function(){return this.TEXTURESHEETANIMATIONCYCLES=Shader3D.propertyNameToID("u_TSACycles");},'TEXTURESHEETANIMATIONSUBUVLENGTH',function(){return this.TEXTURESHEETANIMATIONSUBUVLENGTH=Shader3D.propertyNameToID("u_TSASubUVLength");},'TEXTURESHEETANIMATIONGRADIENTUVS',function(){return this.TEXTURESHEETANIMATIONGRADIENTUVS=Shader3D.propertyNameToID("u_TSAGradientUVs");},'TEXTURESHEETANIMATIONGRADIENTMAXUVS',function(){return this.TEXTURESHEETANIMATIONGRADIENTMAXUVS=Shader3D.propertyNameToID("u_TSAMaxGradientUVs");},'shaderDefines',function(){return this.shaderDefines=new ShaderDefines(RenderableSprite3D.shaderDefines);}
  40634. ]);
  40635. return ShuriKenParticle3D;
  40636. })(RenderableSprite3D)
  40637. /**
  40638. *<code>PixelLineSprite3D</code> 类用于像素线渲染精灵。
  40639. */
  40640. //class laya.d3.core.pixelLine.PixelLineSprite3D extends laya.d3.core.RenderableSprite3D
  40641. var PixelLineSprite3D=(function(_super){
  40642. function PixelLineSprite3D(maxCount,name){
  40643. /**@private */
  40644. this._geometryFilter=null;
  40645. (maxCount===void 0)&& (maxCount=2);
  40646. PixelLineSprite3D.__super.call(this,name);
  40647. this._geometryFilter=new PixelLineFilter(this,maxCount);
  40648. this._render=new PixelLineRenderer(this);
  40649. this._changeRenderObjects(this._render,0,PixelLineMaterial.defaultMaterial);
  40650. }
  40651. __class(PixelLineSprite3D,'laya.d3.core.pixelLine.PixelLineSprite3D',_super);
  40652. var __proto=PixelLineSprite3D.prototype;
  40653. /**
  40654. *@inheritDoc
  40655. */
  40656. __proto._changeRenderObjects=function(sender,index,material){
  40657. var renderObjects=this._render._renderElements;
  40658. (material)|| (material=PixelLineMaterial.defaultMaterial);
  40659. var renderElement=renderObjects[index];
  40660. (renderElement)|| (renderElement=renderObjects[index]=new RenderElement());
  40661. renderElement.setTransform(this._transform);
  40662. renderElement.setGeometry(this._geometryFilter);
  40663. renderElement.render=this._render;
  40664. renderElement.material=material;
  40665. }
  40666. /**
  40667. *增加一条线。
  40668. *@param startPosition 初始点位置
  40669. *@param endPosition 结束点位置
  40670. *@param startColor 初始点颜色
  40671. *@param endColor 结束点颜色
  40672. */
  40673. __proto.addLine=function(startPosition,endPosition,startColor,endColor){
  40674. if (this._geometryFilter._lineCount!==this._geometryFilter._maxLineCount)
  40675. this._geometryFilter._updateLineData(this._geometryFilter._lineCount++,startPosition,endPosition,startColor,endColor);
  40676. else
  40677. throw "PixelLineSprite3D: lineCount has equal with maxLineCount.";
  40678. }
  40679. /**
  40680. *添加多条线段。
  40681. *@param lines 线段数据
  40682. */
  40683. __proto.addLines=function(lines){
  40684. var lineCount=this._geometryFilter._lineCount;
  40685. var addCount=lines.length;
  40686. if (lineCount+addCount > this._geometryFilter._maxLineCount){
  40687. throw "PixelLineSprite3D: lineCount plus lines count must less than maxLineCount.";
  40688. }else {
  40689. this._geometryFilter._updateLineDatas(lineCount,lines);
  40690. this._geometryFilter._lineCount+=addCount;
  40691. }
  40692. }
  40693. /**
  40694. *移除一条线段。
  40695. *@param index 索引。
  40696. */
  40697. __proto.removeLine=function(index){
  40698. if (index < this._geometryFilter._lineCount)
  40699. this._geometryFilter._removeLineData(index);
  40700. else
  40701. throw "PixelLineSprite3D: index must less than lineCount.";
  40702. }
  40703. /**
  40704. *更新线
  40705. *@param index 索引
  40706. *@param startPosition 初始点位置
  40707. *@param endPosition 结束点位置
  40708. *@param startColor 初始点颜色
  40709. *@param endColor 结束点颜色
  40710. */
  40711. __proto.setLine=function(index,startPosition,endPosition,startColor,endColor){
  40712. if (index < this._geometryFilter._lineCount)
  40713. this._geometryFilter._updateLineData(index,startPosition,endPosition,startColor,endColor);
  40714. else
  40715. throw "PixelLineSprite3D: index must less than lineCount.";
  40716. }
  40717. /**
  40718. *获取线段数据
  40719. *@param out 线段数据。
  40720. */
  40721. __proto.getLine=function(index,out){
  40722. if (index < this.lineCount)
  40723. this._geometryFilter._getLineData(index,out);
  40724. else
  40725. throw "PixelLineSprite3D: index must less than lineCount.";
  40726. }
  40727. /**
  40728. *清除所有线段。
  40729. */
  40730. __proto.clear=function(){
  40731. this._geometryFilter._lineCount=0;
  40732. }
  40733. /**
  40734. *设置最大线数量
  40735. *@param value 最大线数量。
  40736. */
  40737. /**
  40738. *获取最大线数量
  40739. *@return 最大线数量。
  40740. */
  40741. __getset(0,__proto,'maxLineCount',function(){
  40742. return this._geometryFilter._maxLineCount;
  40743. },function(value){
  40744. this._geometryFilter._resizeLineData(value);
  40745. this._geometryFilter._lineCount=Math.min(this._geometryFilter._lineCount,value);
  40746. });
  40747. /**
  40748. *获取line渲染器。
  40749. *@return line渲染器。
  40750. */
  40751. __getset(0,__proto,'pixelLineRenderer',function(){
  40752. return this._render;
  40753. });
  40754. /**
  40755. *设置获取线数量。
  40756. *@param value 线段数量。
  40757. */
  40758. /**
  40759. *获取线数量。
  40760. *@return 线段数量。
  40761. */
  40762. __getset(0,__proto,'lineCount',function(){
  40763. return this._geometryFilter._lineCount;
  40764. },function(value){
  40765. if (value > this.maxLineCount)
  40766. throw "PixelLineSprite3D: lineCount can't large than maxLineCount";
  40767. else
  40768. this._geometryFilter._lineCount=value;
  40769. });
  40770. return PixelLineSprite3D;
  40771. })(RenderableSprite3D)
  40772. /**
  40773. *<code>SkinnedMeshSprite3D</code> 类用于创建网格。
  40774. */
  40775. //class laya.d3.core.SkinnedMeshSprite3D extends laya.d3.core.RenderableSprite3D
  40776. var SkinnedMeshSprite3D=(function(_super){
  40777. function SkinnedMeshSprite3D(mesh,name){
  40778. /**@private */
  40779. //this._meshFilter=null;
  40780. SkinnedMeshSprite3D.__super.call(this,name);
  40781. this._meshFilter=new MeshFilter(this);
  40782. this._render=new SkinnedMeshRenderer(this);
  40783. (mesh)&& (this._meshFilter.sharedMesh=mesh);
  40784. }
  40785. __class(SkinnedMeshSprite3D,'laya.d3.core.SkinnedMeshSprite3D',_super);
  40786. var __proto=SkinnedMeshSprite3D.prototype;
  40787. /**
  40788. *@inheritDoc
  40789. */
  40790. __proto._parse=function(data,spriteMap){
  40791. laya.d3.core.Sprite3D.prototype._parse.call(this,data,spriteMap);
  40792. var render=this.skinnedMeshRenderer;
  40793. var lightmapIndex=data.lightmapIndex;
  40794. (lightmapIndex !=null)&& (render.lightmapIndex=lightmapIndex);
  40795. var lightmapScaleOffsetArray=data.lightmapScaleOffset;
  40796. (lightmapScaleOffsetArray)&& (render.lightmapScaleOffset=new Vector4(lightmapScaleOffsetArray[0],lightmapScaleOffsetArray[1],lightmapScaleOffsetArray[2],lightmapScaleOffsetArray[3]));
  40797. var meshPath;
  40798. meshPath=data.meshPath;
  40799. if (meshPath){
  40800. var mesh=Loader.getRes(meshPath);
  40801. (mesh)&& (this.meshFilter.sharedMesh=mesh);
  40802. };
  40803. var materials=data.materials;
  40804. if (materials){
  40805. var sharedMaterials=render.sharedMaterials;
  40806. var materialCount=materials.length;
  40807. sharedMaterials.length=materialCount;
  40808. for (var i=0;i < materialCount;i++){
  40809. sharedMaterials[i]=Loader.getRes(materials[i].path);
  40810. }
  40811. render.sharedMaterials=sharedMaterials;
  40812. };
  40813. var boundBox=data.boundBox;
  40814. var min=boundBox.min;
  40815. var max=boundBox.max;
  40816. render.localBounds.setMin(new Vector3(min[0],min[1],min[2]));
  40817. render.localBounds.setMax(new Vector3(max[0],max[1],max[2]));
  40818. if (spriteMap){
  40819. var rootBoneData=data.rootBone;
  40820. render.rootBone=spriteMap[rootBoneData];
  40821. var bonesData=data.bones;
  40822. var n=0;
  40823. for (i=0,n=bonesData.length;i < n;i++)
  40824. render.bones.push(spriteMap[bonesData[i]]);
  40825. }else {
  40826. (data.rootBone)&& (render._setRootBone(data.rootBone));
  40827. }
  40828. }
  40829. /**
  40830. *@inheritDoc
  40831. */
  40832. __proto._changeHierarchyAnimator=function(animator){
  40833. _super.prototype._changeHierarchyAnimator.call(this,animator);
  40834. this.skinnedMeshRenderer._setCacheAnimator(animator);
  40835. }
  40836. /**
  40837. *@inheritDoc
  40838. */
  40839. __proto._changeAnimatorAvatar=function(avatar){
  40840. this.skinnedMeshRenderer._setCacheAvatar(avatar);
  40841. }
  40842. /**
  40843. *@inheritDoc
  40844. */
  40845. __proto._cloneTo=function(destObject,srcRoot,dstRoot){
  40846. var meshSprite3D=destObject;
  40847. meshSprite3D.meshFilter.sharedMesh=this.meshFilter.sharedMesh;
  40848. var meshRender=this._render;
  40849. var destMeshRender=meshSprite3D._render;
  40850. destMeshRender.enable=meshRender.enable;
  40851. destMeshRender.sharedMaterials=meshRender.sharedMaterials;
  40852. destMeshRender.castShadow=meshRender.castShadow;
  40853. var lightmapScaleOffset=meshRender.lightmapScaleOffset;
  40854. lightmapScaleOffset && (destMeshRender.lightmapScaleOffset=lightmapScaleOffset.clone());
  40855. destMeshRender.receiveShadow=meshRender.receiveShadow;
  40856. destMeshRender.sortingFudge=meshRender.sortingFudge;
  40857. destMeshRender._rootBone=meshRender._rootBone;
  40858. var bones=meshRender.bones;
  40859. var destBones=destMeshRender.bones;
  40860. var bonesCount=bones.length;
  40861. destBones.length=bonesCount;
  40862. var rootBone=meshRender.rootBone;
  40863. if (rootBone){
  40864. var pathes=Utils3D._getHierarchyPath(srcRoot,rootBone,SkinnedMeshSprite3D._tempArray0);
  40865. if (pathes)
  40866. destMeshRender.rootBone=Utils3D._getNodeByHierarchyPath(dstRoot,pathes);
  40867. else
  40868. destMeshRender.rootBone=rootBone;
  40869. }
  40870. for (var i=0;i < bones.length;i++){
  40871. pathes=Utils3D._getHierarchyPath(srcRoot,bones[i],SkinnedMeshSprite3D._tempArray0);
  40872. if (pathes)
  40873. destBones[i]=Utils3D._getNodeByHierarchyPath(dstRoot,pathes);
  40874. else
  40875. destBones[i]=bones[i];
  40876. };
  40877. var lbb=meshRender.localBounds;
  40878. (lbb)&& (lbb.cloneTo(destMeshRender.localBounds));
  40879. laya.d3.core.Sprite3D.prototype._cloneTo.call(this,destObject,srcRoot,dstRoot);
  40880. }
  40881. /**
  40882. *@inheritDoc
  40883. */
  40884. __proto.destroy=function(destroyChild){
  40885. (destroyChild===void 0)&& (destroyChild=true);
  40886. if (this.destroyed)
  40887. return;
  40888. _super.prototype.destroy.call(this,destroyChild);
  40889. this._meshFilter.destroy();
  40890. }
  40891. /**
  40892. *获取网格过滤器。
  40893. *@return 网格过滤器。
  40894. */
  40895. __getset(0,__proto,'meshFilter',function(){
  40896. return this._meshFilter;
  40897. });
  40898. /**
  40899. *获取网格渲染器。
  40900. *@return 网格渲染器。
  40901. */
  40902. __getset(0,__proto,'skinnedMeshRenderer',function(){
  40903. return this._render;
  40904. });
  40905. SkinnedMeshSprite3D.__init__=function(){
  40906. SkinnedMeshSprite3D.SHADERDEFINE_BONE=SkinnedMeshSprite3D.shaderDefines.registerDefine("BONE");
  40907. }
  40908. SkinnedMeshSprite3D._tempArray0=[];
  40909. SkinnedMeshSprite3D.SHADERDEFINE_BONE=0;
  40910. __static(SkinnedMeshSprite3D,
  40911. ['BONES',function(){return this.BONES=Shader3D.propertyNameToID("u_Bones");},'shaderDefines',function(){return this.shaderDefines=new ShaderDefines(MeshSprite3D.shaderDefines);}
  40912. ]);
  40913. return SkinnedMeshSprite3D;
  40914. })(RenderableSprite3D)
  40915. /**
  40916. *<code>PointLight</code> 类用于创建点光。
  40917. */
  40918. //class laya.d3.core.light.PointLight extends laya.d3.core.light.LightSprite
  40919. var PointLight=(function(_super){
  40920. function PointLight(){
  40921. /**@private */
  40922. this._range=NaN;
  40923. this._lightMatrix=new Matrix4x4();
  40924. PointLight.__super.call(this);
  40925. this._range=6.0;
  40926. }
  40927. __class(PointLight,'laya.d3.core.light.PointLight',_super);
  40928. var __proto=PointLight.prototype;
  40929. /**
  40930. *@inheritDoc
  40931. */
  40932. __proto._onActive=function(){
  40933. _super.prototype._onActive.call(this);
  40934. (this._lightmapBakedType!==LightSprite.LIGHTMAPBAKEDTYPE_BAKED)&&((this._scene)._defineDatas.add(Scene3D.SHADERDEFINE_POINTLIGHT));
  40935. }
  40936. /**
  40937. *@inheritDoc
  40938. */
  40939. __proto._onInActive=function(){
  40940. _super.prototype._onInActive.call(this);
  40941. (this._lightmapBakedType!==LightSprite.LIGHTMAPBAKEDTYPE_BAKED)&&((this._scene)._defineDatas.remove(Scene3D.SHADERDEFINE_POINTLIGHT));
  40942. }
  40943. /**
  40944. *更新点光相关渲染状态参数。
  40945. *@param state 渲染状态参数。
  40946. */
  40947. __proto._prepareToScene=function(){
  40948. var scene=this._scene;
  40949. if (scene.enableLight && this.activeInHierarchy){
  40950. var defineDatas=scene._defineDatas;
  40951. var shaderValue=scene._shaderValues;
  40952. Vector3.scale(this.color,this._intensity,this._intensityColor);
  40953. shaderValue.setVector3(Scene3D.POINTLIGHTCOLOR,this._intensityColor);
  40954. shaderValue.setVector3(Scene3D.POINTLIGHTPOS,this.transform.position);
  40955. shaderValue.setNumber(Scene3D.POINTLIGHTRANGE,this.range);
  40956. var lightMatrix=this._lightMatrix;
  40957. var lightMatrixE=lightMatrix.elements;
  40958. lightMatrix.identity();
  40959. lightMatrixE[0]=lightMatrixE[5]=lightMatrixE[10]=1.0 / this._range;
  40960. var toLightMatrix=PointLight._tempMatrix0;
  40961. this.transform.worldMatrix.invert(toLightMatrix);
  40962. Matrix4x4.multiply(lightMatrix,toLightMatrix,lightMatrix);
  40963. shaderValue.setMatrix4x4(Scene3D.POINTLIGHTMATRIX,lightMatrix);
  40964. return true;
  40965. }else {
  40966. return false;
  40967. }
  40968. }
  40969. /**
  40970. *@inheritDoc
  40971. */
  40972. __proto._parse=function(data,spriteMap){
  40973. _super.prototype._parse.call(this,data,spriteMap);
  40974. this.range=data.range;
  40975. }
  40976. /**
  40977. *设置点光的范围。
  40978. *@param value 点光的范围。
  40979. */
  40980. /**
  40981. *获取点光的范围。
  40982. *@return 点光的范围。
  40983. */
  40984. __getset(0,__proto,'range',function(){
  40985. return this._range;
  40986. },function(value){
  40987. this._range=value;
  40988. });
  40989. __static(PointLight,
  40990. ['_tempMatrix0',function(){return this._tempMatrix0=new Matrix4x4();}
  40991. ]);
  40992. return PointLight;
  40993. })(LightSprite)
  40994. /**
  40995. *<code>TerrainChunk</code> 类用于创建地块。
  40996. */
  40997. //class laya.d3.terrain.TerrainChunk extends laya.d3.core.RenderableSprite3D
  40998. var TerrainChunk=(function(_super){
  40999. function TerrainChunk(chunkOffsetX,chunkOffsetZ,girdSize,terrainHeightData,heightDataWidth,heightDataHeight,cameraCoordinateInverse,name){
  41000. /**@private */
  41001. this._terrainFilter=null;
  41002. TerrainChunk.__super.call(this,name);
  41003. this._terrainFilter=new TerrainFilter(this,chunkOffsetX,chunkOffsetZ,girdSize,terrainHeightData,heightDataWidth,heightDataHeight,cameraCoordinateInverse);
  41004. this._render=new TerrainRender(this);
  41005. }
  41006. __class(TerrainChunk,'laya.d3.terrain.TerrainChunk',_super);
  41007. var __proto=TerrainChunk.prototype;
  41008. __proto.buildRenderElementAndMaterial=function(detailNum,normalMap,alphaMapUrl,detailUrl1,detailUrl2,detailUrl3,detailUrl4,ambientColor,diffuseColor,specularColor,sx1,sy1,sx2,sy2,sx3,sy3,sx4,sy4){
  41009. (sx1===void 0)&& (sx1=1);
  41010. (sy1===void 0)&& (sy1=1);
  41011. (sx2===void 0)&& (sx2=1);
  41012. (sy2===void 0)&& (sy2=1);
  41013. (sx3===void 0)&& (sx3=1);
  41014. (sy3===void 0)&& (sy3=1);
  41015. (sx4===void 0)&& (sx4=1);
  41016. (sy4===void 0)&& (sy4=1);
  41017. var terrainMaterial=new TerrainMaterial();
  41018. if (diffuseColor)terrainMaterial.diffuseColor=diffuseColor;
  41019. if (ambientColor)terrainMaterial.ambientColor=ambientColor;
  41020. if (specularColor)terrainMaterial.specularColor=specularColor;
  41021. terrainMaterial.splatAlphaTexture=Loader.getRes(alphaMapUrl);
  41022. terrainMaterial.normalTexture=normalMap ? Loader.getRes(normalMap):null;
  41023. terrainMaterial.diffuseTexture1=detailUrl1 ? Loader.getRes(detailUrl1):null;
  41024. terrainMaterial.diffuseTexture2=detailUrl2 ? Loader.getRes(detailUrl2):null;
  41025. terrainMaterial.diffuseTexture3=detailUrl3 ? Loader.getRes(detailUrl3):null;
  41026. terrainMaterial.diffuseTexture4=detailUrl4 ? Loader.getRes(detailUrl4):null;
  41027. terrainMaterial.setDiffuseScale1(sx1,sy1);
  41028. terrainMaterial.setDiffuseScale2(sx2,sy2);
  41029. terrainMaterial.setDiffuseScale3(sx3,sy3);
  41030. terrainMaterial.setDiffuseScale4(sx4,sy4);
  41031. terrainMaterial.setDetailNum(detailNum);
  41032. if (this._render._renderElements.length !=0){
  41033. terrainMaterial.renderMode=/*laya.d3.core.material.TerrainMaterial.RENDERMODE_TRANSPARENT*/2;
  41034. };
  41035. var renderElement=new RenderElement();
  41036. renderElement.setTransform(this._transform);
  41037. renderElement.render=this._render;
  41038. renderElement.setGeometry(this._terrainFilter);
  41039. this._render._renderElements.push(renderElement);
  41040. this._render.sharedMaterial=terrainMaterial;
  41041. }
  41042. __proto._cloneTo=function(destObject,srcSprite,dstSprite){
  41043. console.log("Terrain Chunk can't clone");
  41044. }
  41045. __proto.destroy=function(destroyChild){
  41046. (destroyChild===void 0)&& (destroyChild=true);
  41047. if (this.destroyed)
  41048. return;
  41049. _super.prototype.destroy.call(this,destroyChild);
  41050. this._terrainFilter.destroy();
  41051. this._terrainFilter=null;
  41052. }
  41053. /**
  41054. *获取地形过滤器。
  41055. *@return 地形过滤器。
  41056. */
  41057. __getset(0,__proto,'terrainFilter',function(){
  41058. return this._terrainFilter;
  41059. });
  41060. /**
  41061. *获取地形渲染器。
  41062. *@return 地形渲染器。
  41063. */
  41064. __getset(0,__proto,'terrainRender',function(){
  41065. return this._render;
  41066. });
  41067. return TerrainChunk;
  41068. })(RenderableSprite3D)
  41069. /**
  41070. *<code>Camera</code> 类用于创建摄像机。
  41071. */
  41072. //class laya.d3.core.Camera extends laya.d3.core.BaseCamera
  41073. var Camera=(function(_super){
  41074. function Camera(aspectRatio,nearPlane,farPlane){
  41075. /**@private */
  41076. //this._aspectRatio=NaN;
  41077. /**@private */
  41078. //this._viewport=null;
  41079. /**@private */
  41080. //this._normalizedViewport=null;
  41081. /**@private */
  41082. //this._viewMatrix=null;
  41083. /**@private */
  41084. //this._projectionMatrix=null;
  41085. /**@private */
  41086. //this._projectionViewMatrix=null;
  41087. /**@private */
  41088. //this._projectionViewMatrixNoTranslateScale=null;
  41089. /**@private */
  41090. //this._boundFrustum=null;
  41091. /**@private */
  41092. this._updateViewMatrix=true;
  41093. /**@private 渲染目标。*/
  41094. this._offScreenRenderTexture=null;
  41095. /**@private */
  41096. this._alwaysUseRenderTexture=false;
  41097. /**@private */
  41098. this._renderTexture=null;
  41099. /**@private */
  41100. this._postProcess=null;
  41101. /**是否允许渲染。*/
  41102. this.enableRender=true;
  41103. /**@private [NATIVE]*/
  41104. //this._boundFrustumBuffer=null;
  41105. this._screenShaderData=new ShaderData();
  41106. this._postProcessCommandBuffers=[];
  41107. (aspectRatio===void 0)&& (aspectRatio=0);
  41108. (nearPlane===void 0)&& (nearPlane=0.3);
  41109. (farPlane===void 0)&& (farPlane=1000);
  41110. this._viewMatrix=new Matrix4x4();
  41111. this._projectionMatrix=new Matrix4x4();
  41112. this._projectionViewMatrix=new Matrix4x4();
  41113. this._projectionViewMatrixNoTranslateScale=new Matrix4x4();
  41114. this._viewport=new Viewport(0,0,0,0);
  41115. this._normalizedViewport=new Viewport(0,0,1,1);
  41116. this._aspectRatio=aspectRatio;
  41117. this._boundFrustum=new BoundFrustum(Matrix4x4.DEFAULT);
  41118. if (Render.supportWebGLPlusCulling)
  41119. this._boundFrustumBuffer=new Float32Array(24);
  41120. Camera.__super.call(this,nearPlane,farPlane);
  41121. this.transform.on(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this,this._onTransformChanged);
  41122. }
  41123. __class(Camera,'laya.d3.core.Camera',_super);
  41124. var __proto=Camera.prototype;
  41125. /**
  41126. *通过蒙版值获取蒙版是否显示。
  41127. *@param layer 层。
  41128. *@return 是否显示。
  41129. */
  41130. __proto._isLayerVisible=function(layer){
  41131. return (Math.pow(2,layer)& this.cullingMask)!=0;
  41132. }
  41133. /**
  41134. *@private
  41135. */
  41136. __proto._onTransformChanged=function(flag){
  41137. flag &=/*laya.d3.core.Transform3D.TRANSFORM_WORLDMATRIX*/0x40;
  41138. (flag)&& (this._updateViewMatrix=true);
  41139. }
  41140. /**
  41141. *@private
  41142. */
  41143. __proto._calculationViewport=function(normalizedViewport,width,height){
  41144. var lx=normalizedViewport.x *width;
  41145. var ly=normalizedViewport.y *height;
  41146. var rx=lx+Math.max(normalizedViewport.width *width,0);
  41147. var ry=ly+Math.max(normalizedViewport.height *height,0);
  41148. var ceilLeftX=Math.ceil(lx);
  41149. var ceilLeftY=Math.ceil(ly);
  41150. var floorRightX=Math.floor(rx);
  41151. var floorRightY=Math.floor(ry);
  41152. var pixelLeftX=ceilLeftX-lx >=0.5 ? Math.floor(lx):ceilLeftX;
  41153. var pixelLeftY=ceilLeftY-ly >=0.5 ? Math.floor(ly):ceilLeftY;
  41154. var pixelRightX=rx-floorRightX >=0.5 ? Math.ceil(rx):floorRightX;
  41155. var pixelRightY=ry-floorRightY >=0.5 ? Math.ceil(ry):floorRightY;
  41156. this._viewport.x=pixelLeftX;
  41157. this._viewport.y=pixelLeftY;
  41158. this._viewport.width=pixelRightX-pixelLeftX;
  41159. this._viewport.height=pixelRightY-pixelLeftY;
  41160. }
  41161. /**
  41162. *@inheritDoc
  41163. */
  41164. __proto._parse=function(data,spriteMap){
  41165. _super.prototype._parse.call(this,data,spriteMap);
  41166. var viewport=data.viewport;
  41167. this.normalizedViewport=new Viewport(viewport[0],viewport[1],viewport[2],viewport[3]);
  41168. }
  41169. /**
  41170. *@inheritDoc
  41171. */
  41172. __proto._calculateProjectionMatrix=function(){
  41173. if (!this._useUserProjectionMatrix){
  41174. if (this._orthographic){
  41175. var halfWidth=this.orthographicVerticalSize *this.aspectRatio *0.5;
  41176. var halfHeight=this.orthographicVerticalSize *0.5;
  41177. Matrix4x4.createOrthoOffCenter(-halfWidth,halfWidth,-halfHeight,halfHeight,this.nearPlane,this.farPlane,this._projectionMatrix);
  41178. }else {
  41179. Matrix4x4.createPerspective(3.1416 *this.fieldOfView / 180.0,this.aspectRatio,this.nearPlane,this.farPlane,this._projectionMatrix);
  41180. }
  41181. }
  41182. }
  41183. /**
  41184. *@private
  41185. */
  41186. __proto._getCanvasHeight=function(){
  41187. if (this._offScreenRenderTexture)
  41188. return this._offScreenRenderTexture.height;
  41189. else
  41190. return RenderContext3D.clientHeight;
  41191. }
  41192. /**
  41193. *@private
  41194. */
  41195. __proto._applyPostProcessCommandBuffers=function(){
  41196. for (var i=0,n=this._postProcessCommandBuffers.length;i < n;i++)
  41197. this._postProcessCommandBuffers[i]._apply();
  41198. }
  41199. /**
  41200. *@private
  41201. */
  41202. __proto._needForceSetRenderTexture=function(){
  41203. return this._alwaysUseRenderTexture && !this._offScreenRenderTexture;
  41204. }
  41205. /**
  41206. *@inheritDoc
  41207. */
  41208. __proto.render=function(shader,replacementTag){
  41209. if (!this._scene)
  41210. return;
  41211. var forceSetRenderTexture=this._needForceSetRenderTexture();
  41212. if (forceSetRenderTexture)
  41213. this._renderTexture=RenderTexture.getTemporary(RenderContext3D.clientWidth,RenderContext3D.clientHeight,/*laya.resource.BaseTexture.FORMAT_R8G8B8*/0,/*laya.resource.BaseTexture.FORMAT_DEPTH_16*/0,/*laya.resource.BaseTexture.FILTERMODE_BILINEAR*/1);
  41214. var gl=LayaGL.instance;
  41215. var context=RenderContext3D._instance;
  41216. var scene=context.scene=this._scene;
  41217. if (scene.parallelSplitShadowMaps[0]){
  41218. ShaderData.setRuntimeValueMode(false);
  41219. var parallelSplitShadowMap=scene.parallelSplitShadowMaps[0];
  41220. parallelSplitShadowMap._calcAllLightCameraInfo(this);
  41221. scene._defineDatas.add(Scene3D.SHADERDEFINE_CAST_SHADOW);
  41222. for (var i=0,n=parallelSplitShadowMap.shadowMapCount;i < n;i++){
  41223. var smCamera=parallelSplitShadowMap.cameras[i];
  41224. context.camera=smCamera;
  41225. context.projectionViewMatrix=smCamera.projectionViewMatrix;
  41226. FrustumCulling.renderObjectCulling(smCamera,scene,context,scene._castShadowRenders);
  41227. var shadowMap=parallelSplitShadowMap.cameras[i+1].renderTarget;
  41228. shadowMap._start();
  41229. context.camera=smCamera;
  41230. context.viewport=smCamera.viewport;
  41231. smCamera._prepareCameraToRender();
  41232. smCamera._prepareCameraViewProject(smCamera.viewMatrix,smCamera.projectionMatrix,context.projectionViewMatrix,smCamera._projectionViewMatrixNoTranslateScale);
  41233. scene._clear(gl,context);
  41234. var queue=scene._opaqueQueue;
  41235. queue._render(context,false);
  41236. shadowMap._end();
  41237. }
  41238. scene._defineDatas.remove(Scene3D.SHADERDEFINE_CAST_SHADOW);
  41239. ShaderData.setRuntimeValueMode(true);
  41240. }
  41241. context.camera=this;
  41242. scene._preRenderScript();
  41243. var viewMat,projectMat;
  41244. viewMat=context.viewMatrix=this.viewMatrix;
  41245. var renderTar=this._renderTexture;
  41246. if (renderTar){
  41247. renderTar._start();
  41248. Matrix4x4.multiply(BaseCamera._invertYScaleMatrix,this._projectionMatrix,BaseCamera._invertYProjectionMatrix);
  41249. Matrix4x4.multiply(BaseCamera._invertYScaleMatrix,this.projectionViewMatrix,BaseCamera._invertYProjectionViewMatrix);
  41250. projectMat=context.projectionMatrix=BaseCamera._invertYProjectionMatrix;
  41251. context.projectionViewMatrix=BaseCamera._invertYProjectionViewMatrix;
  41252. }else {
  41253. projectMat=context.projectionMatrix=this._projectionMatrix;
  41254. context.projectionViewMatrix=this.projectionViewMatrix;
  41255. }
  41256. context.viewport=this.viewport;
  41257. this._prepareCameraToRender();
  41258. this._prepareCameraViewProject(viewMat,projectMat,context.projectionViewMatrix,this._projectionViewMatrixNoTranslateScale);
  41259. scene._preCulling(context,this);
  41260. scene._clear(gl,context);
  41261. scene._renderScene(gl,context,shader,replacementTag);
  41262. scene._postRenderScript();
  41263. (renderTar)&& (renderTar._end());
  41264. (this._postProcess)&& (this._postProcess._render());
  41265. if (forceSetRenderTexture){
  41266. var blit=BlitCMD.create(this._renderTexture,null,CommandBuffer.screenShader,this._screenShaderData);
  41267. blit.run();
  41268. blit.recover();
  41269. RenderTexture.setReleaseTemporary(this._renderTexture);
  41270. }
  41271. }
  41272. /**
  41273. *计算从屏幕空间生成的射线。
  41274. *@param point 屏幕空间的位置位置。
  41275. *@return out 输出射线。
  41276. */
  41277. __proto.viewportPointToRay=function(point,out){
  41278. Picker.calculateCursorRay(point,this.viewport,this._projectionMatrix,this.viewMatrix,null,out);
  41279. }
  41280. /**
  41281. *计算从裁切空间生成的射线。
  41282. *@param point 裁切空间的位置。。
  41283. *@return out 输出射线。
  41284. */
  41285. __proto.normalizedViewportPointToRay=function(point,out){
  41286. var finalPoint=Camera._tempVector20;
  41287. var vp=this.viewport;
  41288. finalPoint.x=point.x *vp.width;
  41289. finalPoint.y=point.y *vp.height;
  41290. Picker.calculateCursorRay(finalPoint,this.viewport,this._projectionMatrix,this.viewMatrix,null,out);
  41291. }
  41292. /**
  41293. *计算从世界空间准换三维坐标到屏幕空间。
  41294. *@param position 世界空间的位置。
  41295. *@return out 输出位置。
  41296. */
  41297. __proto.worldToViewportPoint=function(position,out){
  41298. Matrix4x4.multiply(this._projectionMatrix,this._viewMatrix,this._projectionViewMatrix);
  41299. this.viewport.project(position,this._projectionViewMatrix,out);
  41300. out.x=out.x / Laya.stage.clientScaleX;
  41301. out.y=out.y / Laya.stage.clientScaleY;
  41302. }
  41303. /**
  41304. *计算从世界空间准换三维坐标到裁切空间。
  41305. *@param position 世界空间的位置。
  41306. *@return out 输出位置。
  41307. */
  41308. __proto.worldToNormalizedViewportPoint=function(position,out){
  41309. Matrix4x4.multiply(this._projectionMatrix,this._viewMatrix,this._projectionViewMatrix);
  41310. this.normalizedViewport.project(position,this._projectionViewMatrix,out);
  41311. out.x=out.x / Laya.stage.clientScaleX;
  41312. out.y=out.y / Laya.stage.clientScaleY;
  41313. }
  41314. /**
  41315. *转换2D屏幕坐标系统到3D正交投影下的坐标系统,注:只有正交模型下有效。
  41316. *@param source 源坐标。
  41317. *@param out 输出坐标。
  41318. *@return 是否转换成功。
  41319. */
  41320. __proto.convertScreenCoordToOrthographicCoord=function(source,out){
  41321. if (this._orthographic){
  41322. var clientWidth=RenderContext3D.clientWidth;
  41323. var clientHeight=RenderContext3D.clientHeight;
  41324. var ratioX=this.orthographicVerticalSize *this.aspectRatio / clientWidth;
  41325. var ratioY=this.orthographicVerticalSize / clientHeight;
  41326. out.x=(-clientWidth / 2+source.x)*ratioX;
  41327. out.y=(clientHeight / 2-source.y)*ratioY;
  41328. out.z=(this.nearPlane-this.farPlane)*(source.z+1)/ 2-this.nearPlane;
  41329. Vector3.transformCoordinate(out,this.transform.worldMatrix,out);
  41330. return true;
  41331. }else {
  41332. return false;
  41333. }
  41334. }
  41335. /**
  41336. *@inheritDoc
  41337. */
  41338. __proto.destroy=function(destroyChild){
  41339. (destroyChild===void 0)&& (destroyChild=true);
  41340. this._offScreenRenderTexture=null;
  41341. this.transform.off(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this,this._onTransformChanged);
  41342. _super.prototype.destroy.call(this,destroyChild);
  41343. }
  41344. /**
  41345. *在特定渲染管线阶段添加指令缓存。
  41346. */
  41347. __proto.addCommandBuffer=function(event,commandBuffer){
  41348. switch (event){
  41349. case 0:
  41350. this._postProcessCommandBuffers.push(commandBuffer);
  41351. break ;
  41352. default :
  41353. throw "Camera:unknown event.";
  41354. }
  41355. }
  41356. /**
  41357. *在特定渲染管线阶段移除指令缓存。
  41358. */
  41359. __proto.removeCommandBuffer=function(event,commandBuffer){
  41360. switch (event){
  41361. case 0:;
  41362. var index=this._postProcessCommandBuffers.indexOf(commandBuffer);
  41363. if (index!==-1)
  41364. this._postProcessCommandBuffers.splice(index,1);
  41365. break ;
  41366. default :
  41367. throw "Camera:unknown event.";
  41368. }
  41369. }
  41370. /**
  41371. *在特定渲染管线阶段移除所有指令缓存。
  41372. */
  41373. __proto.removeCommandBuffers=function(event){
  41374. switch (event){
  41375. case 0:
  41376. this._postProcessCommandBuffers.length=0;
  41377. break ;
  41378. default :
  41379. throw "Camera:unknown event.";
  41380. }
  41381. }
  41382. /**
  41383. *获取渲染结果纹理。
  41384. *@return 渲染结果纹理。
  41385. */
  41386. __proto.getRenderTexture=function(){
  41387. return this._renderTexture;
  41388. }
  41389. /**
  41390. *设置自定义渲染场景的渲染目标。
  41391. *@param value 自定义渲染场景的渲染目标。
  41392. */
  41393. /**
  41394. *获取自定义渲染场景的渲染目标。
  41395. *@return 自定义渲染场景的渲染目标。
  41396. */
  41397. __getset(0,__proto,'renderTarget',function(){
  41398. return this._offScreenRenderTexture;
  41399. },function(value){
  41400. if (this._offScreenRenderTexture!==value){
  41401. this._offScreenRenderTexture=value;
  41402. this._renderTexture=value;
  41403. this._calculateProjectionMatrix();
  41404. }
  41405. });
  41406. /**
  41407. *获取视图投影矩阵。
  41408. *@return 视图投影矩阵。
  41409. */
  41410. __getset(0,__proto,'projectionViewMatrix',function(){
  41411. Matrix4x4.multiply(this.projectionMatrix,this.viewMatrix,this._projectionViewMatrix);
  41412. return this._projectionViewMatrix;
  41413. });
  41414. /**
  41415. *设置横纵比。
  41416. *@param value 横纵比。
  41417. */
  41418. /**
  41419. *获取横纵比。
  41420. *@return 横纵比。
  41421. */
  41422. __getset(0,__proto,'aspectRatio',function(){
  41423. if (this._aspectRatio===0){
  41424. var vp=this.viewport;
  41425. return vp.width / vp.height;
  41426. }
  41427. return this._aspectRatio;
  41428. },function(value){
  41429. if (value < 0)
  41430. throw new Error("Camera: the aspect ratio has to be a positive real number.");
  41431. this._aspectRatio=value;
  41432. this._calculateProjectionMatrix();
  41433. });
  41434. /**
  41435. *获取摄像机视锥。
  41436. */
  41437. __getset(0,__proto,'boundFrustum',function(){
  41438. this._boundFrustum.matrix=this.projectionViewMatrix;
  41439. if (Render.supportWebGLPlusCulling){
  41440. var near=this._boundFrustum.near;
  41441. var far=this._boundFrustum.far;
  41442. var left=this._boundFrustum.left;
  41443. var right=this._boundFrustum.right;
  41444. var top=this._boundFrustum.top;
  41445. var bottom=this._boundFrustum.bottom;
  41446. var nearNE=near.normal;
  41447. var farNE=far.normal;
  41448. var leftNE=left.normal;
  41449. var rightNE=right.normal;
  41450. var topNE=top.normal;
  41451. var bottomNE=bottom.normal;
  41452. var buffer=this._boundFrustumBuffer;
  41453. buffer[0]=nearNE.x,buffer[1]=nearNE.y,buffer[2]=nearNE.z,buffer[3]=near.distance;
  41454. buffer[4]=farNE.x,buffer[5]=farNE.y,buffer[6]=farNE.z,buffer[7]=far.distance;
  41455. buffer[8]=leftNE.x,buffer[9]=leftNE.y,buffer[10]=leftNE.z,buffer[11]=left.distance;
  41456. buffer[12]=rightNE.x,buffer[13]=rightNE.y,buffer[14]=rightNE.z,buffer[15]=right.distance;
  41457. buffer[16]=topNE.x,buffer[17]=topNE.y,buffer[18]=topNE.z,buffer[19]=top.distance;
  41458. buffer[20]=bottomNE.x,buffer[21]=bottomNE.y,buffer[22]=bottomNE.z,buffer[23]=bottom.distance;
  41459. }
  41460. return this._boundFrustum;
  41461. });
  41462. /**
  41463. *设置屏幕像素坐标的视口。
  41464. *@param 屏幕像素坐标的视口。
  41465. */
  41466. /**
  41467. *获取屏幕像素坐标的视口。
  41468. *@return 屏幕像素坐标的视口。
  41469. */
  41470. __getset(0,__proto,'viewport',function(){
  41471. if (this._offScreenRenderTexture)
  41472. this._calculationViewport(this._normalizedViewport,this._offScreenRenderTexture.width,this._offScreenRenderTexture.height);
  41473. else
  41474. this._calculationViewport(this._normalizedViewport,RenderContext3D.clientWidth,RenderContext3D.clientHeight);
  41475. return this._viewport;
  41476. },function(value){
  41477. var width=0;
  41478. var height=0;
  41479. if (this._offScreenRenderTexture){
  41480. width=this._offScreenRenderTexture.width;
  41481. height=this._offScreenRenderTexture.height;
  41482. }else {
  41483. width=RenderContext3D.clientWidth;
  41484. height=RenderContext3D.clientHeight;
  41485. }
  41486. this._normalizedViewport.x=value.x / width;
  41487. this._normalizedViewport.y=value.y / height;
  41488. this._normalizedViewport.width=value.width / width;
  41489. this._normalizedViewport.height=value.height / height;
  41490. this._calculationViewport(this._normalizedViewport,width,height);
  41491. this._calculateProjectionMatrix();
  41492. });
  41493. /**
  41494. *设置是否始终使用渲染纹理,在某些渲染配置下会直接将渲染结果渲染到屏幕上,getRenderTexture()方法的返回值为空,如需使用getRenderTexture()可开启此属性。
  41495. *@param value 渲染纹理。
  41496. */
  41497. /**
  41498. *获取是否始终使用渲染纹理,在某些渲染配置下会直接将渲染结果渲染到屏幕上,getRenderTexture()方法的返回值为空,如需使用getRenderTexture()可开启此属性。
  41499. *@return 渲染纹理。
  41500. */
  41501. __getset(0,__proto,'alwaysUseRenderTexture',function(){
  41502. return this._alwaysUseRenderTexture;
  41503. },function(value){
  41504. this._alwaysUseRenderTexture=value;
  41505. });
  41506. /**
  41507. *设置裁剪空间的视口。
  41508. *@return 裁剪空间的视口。
  41509. */
  41510. /**
  41511. *获取裁剪空间的视口。
  41512. *@return 裁剪空间的视口。
  41513. */
  41514. __getset(0,__proto,'normalizedViewport',function(){
  41515. return this._normalizedViewport;
  41516. },function(value){
  41517. var width=0;
  41518. var height=0;
  41519. if (this._offScreenRenderTexture){
  41520. width=this._offScreenRenderTexture.width;
  41521. height=this._offScreenRenderTexture.height;
  41522. }else {
  41523. width=RenderContext3D.clientWidth;
  41524. height=RenderContext3D.clientHeight;
  41525. }
  41526. if (this._normalizedViewport!==value)
  41527. value.cloneTo(this._normalizedViewport);
  41528. this._calculationViewport(value,width,height);
  41529. this._calculateProjectionMatrix();
  41530. });
  41531. /**设置投影矩阵。*/
  41532. /**获取投影矩阵。*/
  41533. __getset(0,__proto,'projectionMatrix',function(){
  41534. return this._projectionMatrix;
  41535. },function(value){
  41536. this._projectionMatrix=value;
  41537. this._useUserProjectionMatrix=true;
  41538. });
  41539. /**
  41540. *获取视图矩阵。
  41541. *@return 视图矩阵。
  41542. */
  41543. __getset(0,__proto,'viewMatrix',function(){
  41544. if (this._updateViewMatrix){
  41545. var scale=this.transform.scale;
  41546. var scaleX=scale.x;
  41547. var scaleY=scale.y;
  41548. var scaleZ=scale.z;
  41549. var viewMatE=this._viewMatrix.elements;
  41550. this.transform.worldMatrix.cloneTo(this._viewMatrix)
  41551. viewMatE[0] /=scaleX;
  41552. viewMatE[1] /=scaleX;
  41553. viewMatE[2] /=scaleX;
  41554. viewMatE[4] /=scaleY;
  41555. viewMatE[5] /=scaleY;
  41556. viewMatE[6] /=scaleY;
  41557. viewMatE[8] /=scaleZ;
  41558. viewMatE[9] /=scaleZ;
  41559. viewMatE[10] /=scaleZ;
  41560. this._viewMatrix.invert(this._viewMatrix);
  41561. this._updateViewMatrix=false;
  41562. }
  41563. return this._viewMatrix;
  41564. });
  41565. /**
  41566. *设置后期处理。
  41567. *@param value 后期处理。
  41568. */
  41569. /**
  41570. *获取后期处理。
  41571. *@return 后期处理。
  41572. */
  41573. __getset(0,__proto,'postProcess',function(){
  41574. return this._postProcess;
  41575. },function(value){
  41576. this._postProcess=value;
  41577. this.alwaysUseRenderTexture=true;
  41578. var postProcessCommandBuffer=new CommandBuffer();
  41579. this.addCommandBuffer(/*CLASS CONST:laya.d3.core.Camera.CAMERAEVENT_POSTPROCESS*/0,postProcessCommandBuffer);
  41580. value._init(this,postProcessCommandBuffer);
  41581. });
  41582. Camera.CAMERAEVENT_POSTPROCESS=0;
  41583. Camera._updateMark=0;
  41584. __static(Camera,
  41585. ['_tempVector20',function(){return this._tempVector20=new Vector2();}
  41586. ]);
  41587. return Camera;
  41588. })(BaseCamera)
  41589. /**
  41590. *<code>TerrainMeshSprite3D</code> 类用于创建网格。
  41591. */
  41592. //class laya.d3.core.MeshTerrainSprite3D extends laya.d3.core.MeshSprite3D
  41593. var MeshTerrainSprite3D=(function(_super){
  41594. function MeshTerrainSprite3D(mesh,heightMap,name){
  41595. /**@private */
  41596. this._minX=NaN;
  41597. /**@private */
  41598. this._minZ=NaN;
  41599. /**@private */
  41600. this._cellSize=null;
  41601. /**@private */
  41602. this._heightMap=null;
  41603. MeshTerrainSprite3D.__super.call(this,mesh,name);
  41604. this._heightMap=heightMap;
  41605. this._cellSize=new Vector2();
  41606. }
  41607. __class(MeshTerrainSprite3D,'laya.d3.core.MeshTerrainSprite3D',_super);
  41608. var __proto=MeshTerrainSprite3D.prototype;
  41609. /**
  41610. *@private
  41611. */
  41612. __proto._disableRotation=function(){
  41613. var rotation=this.transform.rotation;
  41614. rotation.x=0;
  41615. rotation.y=0;
  41616. rotation.z=0;
  41617. rotation.w=1;
  41618. this.transform.rotation=rotation;
  41619. }
  41620. /**
  41621. *@private
  41622. */
  41623. __proto._getScaleX=function(){
  41624. var worldMat=this.transform.worldMatrix;
  41625. var worldMatE=worldMat.elements;
  41626. var m11=worldMatE[0];
  41627. var m12=worldMatE[1];
  41628. var m13=worldMatE[2];
  41629. return Math.sqrt((m11 *m11)+(m12 *m12)+(m13 *m13));
  41630. }
  41631. /**
  41632. *@private
  41633. */
  41634. __proto._getScaleZ=function(){
  41635. var worldMat=this.transform.worldMatrix;
  41636. var worldMatE=worldMat.elements;
  41637. var m31=worldMatE[8];
  41638. var m32=worldMatE[9];
  41639. var m33=worldMatE[10];
  41640. return Math.sqrt((m31 *m31)+(m32 *m32)+(m33 *m33));
  41641. }
  41642. /**
  41643. *@private
  41644. */
  41645. __proto._initCreateFromMesh=function(heightMapWidth,heightMapHeight){
  41646. this._heightMap=HeightMap.creatFromMesh(this.meshFilter.sharedMesh,heightMapWidth,heightMapHeight,this._cellSize);
  41647. var boundingBox=this.meshFilter.sharedMesh.bounds;
  41648. var min=boundingBox.getMin();
  41649. var max=boundingBox.getMax();
  41650. this._minX=min.x;
  41651. this._minZ=min.z;
  41652. }
  41653. /**
  41654. *@private
  41655. */
  41656. __proto._initCreateFromMeshHeightMap=function(texture,minHeight,maxHeight){
  41657. var boundingBox=this.meshFilter.sharedMesh.bounds;
  41658. this._heightMap=HeightMap.createFromImage(texture,minHeight,maxHeight);
  41659. this._computeCellSize(boundingBox);
  41660. var min=boundingBox.getMin();
  41661. var max=boundingBox.getMax();
  41662. this._minX=min.x;
  41663. this._minZ=min.z;
  41664. }
  41665. /**
  41666. *@private
  41667. */
  41668. __proto._computeCellSize=function(boundingBox){
  41669. var min=boundingBox.getMin();
  41670. var max=boundingBox.getMax();
  41671. var minX=min.x;
  41672. var minZ=min.z;
  41673. var maxX=max.x;
  41674. var maxZ=max.z;
  41675. var widthSize=maxX-minX;
  41676. var heightSize=maxZ-minZ;
  41677. this._cellSize.x=widthSize / (this._heightMap.width-1);
  41678. this._cellSize.y=heightSize / (this._heightMap.height-1);
  41679. }
  41680. /**
  41681. *@private
  41682. */
  41683. __proto._update=function(state){
  41684. this._disableRotation();
  41685. }
  41686. /**
  41687. *获取地形高度。
  41688. *@param x X轴坐标。
  41689. *@param z Z轴坐标。
  41690. */
  41691. __proto.getHeight=function(x,z){
  41692. MeshTerrainSprite3D._tempVector3.x=x;
  41693. MeshTerrainSprite3D._tempVector3.y=0;
  41694. MeshTerrainSprite3D._tempVector3.z=z;
  41695. this._disableRotation();
  41696. var worldMat=this.transform.worldMatrix;
  41697. worldMat.invert(MeshTerrainSprite3D._tempMatrix4x4);
  41698. Vector3.transformCoordinate(MeshTerrainSprite3D._tempVector3,MeshTerrainSprite3D._tempMatrix4x4,MeshTerrainSprite3D._tempVector3);
  41699. x=MeshTerrainSprite3D._tempVector3.x;
  41700. z=MeshTerrainSprite3D._tempVector3.z;
  41701. var c=(x-this._minX)/ this._cellSize.x;
  41702. var d=(z-this._minZ)/ this._cellSize.y;
  41703. var row=Math.floor(d);
  41704. var col=Math.floor(c);
  41705. var s=c-col;
  41706. var t=d-row;
  41707. var uy=NaN;
  41708. var vy=NaN;
  41709. var worldMatE=worldMat.elements;
  41710. var m21=worldMatE[4];
  41711. var m22=worldMatE[5];
  41712. var m23=worldMatE[6];
  41713. var scaleY=Math.sqrt((m21 *m21)+(m22 *m22)+(m23 *m23));
  41714. var translateY=worldMatE[13];
  41715. var h01=this._heightMap.getHeight(row,col+1);
  41716. var h10=this._heightMap.getHeight((row+1),col);
  41717. if (isNaN(h01)|| isNaN(h10))
  41718. return NaN;
  41719. if (s+t <=1.0){
  41720. var h00=this._heightMap.getHeight(row,col);
  41721. if (isNaN(h00))
  41722. return NaN;
  41723. uy=h01-h00;
  41724. vy=h10-h00;
  41725. return (h00+s *uy+t *vy)*scaleY+translateY;
  41726. }else {
  41727. var h11=this._heightMap.getHeight((row+1),col+1);
  41728. if (isNaN(h11))
  41729. return NaN;
  41730. uy=h10-h11;
  41731. vy=h01-h11;
  41732. return (h11+(1.0-s)*uy+(1.0-t)*vy)*scaleY+translateY;
  41733. }
  41734. }
  41735. /**
  41736. *获取地形X轴最小位置。
  41737. *@return 地形X轴最小位置。
  41738. */
  41739. __getset(0,__proto,'minX',function(){
  41740. var worldMat=this.transform.worldMatrix;
  41741. var worldMatE=worldMat.elements;
  41742. return this._minX *this._getScaleX()+worldMatE[12];
  41743. });
  41744. /**
  41745. *获取地形X轴长度。
  41746. *@return 地形X轴长度。
  41747. */
  41748. __getset(0,__proto,'width',function(){
  41749. return (this._heightMap.width-1)*this._cellSize.x *this._getScaleX();
  41750. });
  41751. /**
  41752. *获取地形Z轴最小位置。
  41753. *@return 地形X轴最小位置。
  41754. */
  41755. __getset(0,__proto,'minZ',function(){
  41756. var worldMat=this.transform.worldMatrix;
  41757. var worldMatE=worldMat.elements;
  41758. return this._minZ *this._getScaleZ()+worldMatE[14];
  41759. });
  41760. /**
  41761. *获取地形Z轴长度。
  41762. *@return 地形Z轴长度。
  41763. */
  41764. __getset(0,__proto,'depth',function(){
  41765. return (this._heightMap.height-1)*this._cellSize.y *this._getScaleZ();
  41766. });
  41767. MeshTerrainSprite3D.createFromMesh=function(mesh,heightMapWidth,heightMapHeight,name){
  41768. var meshTerrainSprite3D=new MeshTerrainSprite3D(mesh,null,name);
  41769. meshTerrainSprite3D._initCreateFromMesh(heightMapWidth,heightMapHeight);
  41770. return meshTerrainSprite3D;
  41771. }
  41772. MeshTerrainSprite3D.createFromMeshAndHeightMap=function(mesh,texture,minHeight,maxHeight,name){
  41773. var meshTerrainSprite3D=new MeshTerrainSprite3D(mesh,null,name);
  41774. meshTerrainSprite3D._initCreateFromMeshHeightMap(texture,minHeight,maxHeight);
  41775. return meshTerrainSprite3D;
  41776. }
  41777. __static(MeshTerrainSprite3D,
  41778. ['_tempVector3',function(){return this._tempVector3=new Vector3();},'_tempMatrix4x4',function(){return this._tempMatrix4x4=new Matrix4x4();}
  41779. ]);
  41780. return MeshTerrainSprite3D;
  41781. })(MeshSprite3D)
  41782. })(window,document,Laya);