laya.d3.js 1.5 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708
  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>Vector4</code> 类用于创建四维向量。
  18. */
  19. //class laya.d3.math.Native.ConchVector4
  20. var ConchVector4=(function(){
  21. function ConchVector4(x,y,z,w){
  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=0);
  28. var v=this.elements=new Float32Array(4);
  29. v[0]=x;
  30. v[1]=y;
  31. v[2]=z;
  32. v[3]=w;
  33. }
  34. __class(ConchVector4,'laya.d3.math.Native.ConchVector4');
  35. var __proto=ConchVector4.prototype;
  36. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  37. /**
  38. *从Array数组拷贝值。
  39. *@param array 数组。
  40. *@param offset 数组偏移。
  41. */
  42. __proto.fromArray=function(array,offset){
  43. (offset===void 0)&& (offset=0);
  44. this.elements[0]=array[offset+0];
  45. this.elements[1]=array[offset+1];
  46. this.elements[2]=array[offset+2];
  47. this.elements[3]=array[offset+3];
  48. }
  49. /**
  50. *克隆。
  51. *@param destObject 克隆源。
  52. */
  53. __proto.cloneTo=function(destObject){
  54. var destVector4=destObject;
  55. var destE=destVector4.elements;
  56. var s=this.elements;
  57. destE[0]=s[0];
  58. destE[1]=s[1];
  59. destE[2]=s[2];
  60. destE[3]=s[3];
  61. }
  62. /**
  63. *克隆。
  64. *@return 克隆副本。
  65. */
  66. __proto.clone=function(){
  67. var destVector4=/*__JS__ */new this.constructor();
  68. this.cloneTo(destVector4);
  69. return destVector4;
  70. }
  71. /**
  72. *求四维向量的长度。
  73. *@return 长度。
  74. */
  75. __proto.length=function(){
  76. return Math.sqrt(this.x *this.x+this.y *this.y+this.z *this.z+this.w *this.w);
  77. }
  78. /**
  79. *求四维向量长度的平方。
  80. *@return 长度的平方。
  81. */
  82. __proto.lengthSquared=function(){
  83. return this.x *this.x+this.y *this.y+this.z *this.z+this.w *this.w;
  84. }
  85. /**
  86. *设置X轴坐标。
  87. *@param value X轴坐标。
  88. */
  89. /**
  90. *获取X轴坐标。
  91. *@return X轴坐标。
  92. */
  93. __getset(0,__proto,'x',function(){
  94. return this.elements[0];
  95. },function(value){
  96. this.elements[0]=value;
  97. });
  98. /**
  99. *设置Y轴坐标。
  100. *@param value Y轴坐标。
  101. */
  102. /**
  103. *获取Y轴坐标。
  104. *@return Y轴坐标。
  105. */
  106. __getset(0,__proto,'y',function(){
  107. return this.elements[1];
  108. },function(value){
  109. this.elements[1]=value;
  110. });
  111. /**
  112. *设置Z轴坐标。
  113. *@param value Z轴坐标。
  114. */
  115. /**
  116. *获取Z轴坐标。
  117. *@return Z轴坐标。
  118. */
  119. __getset(0,__proto,'z',function(){
  120. return this.elements[2];
  121. },function(value){
  122. this.elements[2]=value;
  123. });
  124. /**
  125. *设置W轴坐标。
  126. *@param value W轴坐标。
  127. */
  128. /**
  129. *获取W轴坐标。
  130. *@return W轴坐标。
  131. */
  132. __getset(0,__proto,'w',function(){
  133. return this.elements[3];
  134. },function(value){
  135. this.elements[3]=value;
  136. });
  137. ConchVector4.lerp=function(a,b,t,out){
  138. var e=out.elements;
  139. var f=a.elements;
  140. var g=b.elements;
  141. var ax=f[0],ay=f[1],az=f[2],aw=f[3];
  142. e[0]=ax+t *(g[0]-ax);
  143. e[1]=ay+t *(g[1]-ay);
  144. e[2]=az+t *(g[2]-az);
  145. e[3]=aw+t *(g[3]-aw);
  146. }
  147. ConchVector4.transformByM4x4=function(vector4,m4x4,out){
  148. var ve=vector4.elements;
  149. var vx=ve[0];
  150. var vy=ve[1];
  151. var vz=ve[2];
  152. var vw=ve[3];
  153. var me=m4x4.elements;
  154. var oe=out.elements;
  155. oe[0]=vx *me[0]+vy *me[4]+vz *me[8]+vw *me[12];
  156. oe[1]=vx *me[1]+vy *me[5]+vz *me[9]+vw *me[13];
  157. oe[2]=vx *me[2]+vy *me[6]+vz *me[10]+vw *me[14];
  158. oe[3]=vx *me[3]+vy *me[7]+vz *me[11]+vw *me[15];
  159. }
  160. ConchVector4.equals=function(a,b){
  161. var ae=a.elements;
  162. var be=b.elements;
  163. 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]));
  164. }
  165. ConchVector4.normalize=function(s,out){
  166. var se=s.elements;
  167. var oe=out.elements;
  168. var len=/*if err,please use iflash.method.xmlLength()*/s.length();
  169. if (len > 0){
  170. oe[0]=se[0] *len;
  171. oe[1]=se[1] *len;
  172. oe[2]=se[2] *len;
  173. oe[3]=se[3] *len;
  174. }
  175. }
  176. ConchVector4.add=function(a,b,out){
  177. var oe=out.elements;
  178. var ae=a.elements;
  179. var be=b.elements;
  180. oe[0]=ae[0]+be[0];
  181. oe[1]=ae[1]+be[1];
  182. oe[2]=ae[2]+be[2];
  183. oe[3]=ae[3]+be[3];
  184. }
  185. ConchVector4.subtract=function(a,b,out){
  186. var oe=out.elements;
  187. var ae=a.elements;
  188. var be=b.elements;
  189. oe[0]=ae[0]-be[0];
  190. oe[1]=ae[1]-be[1];
  191. oe[2]=ae[2]-be[2];
  192. oe[3]=ae[3]-be[3];
  193. }
  194. ConchVector4.multiply=function(a,b,out){
  195. var oe=out.elements;
  196. var ae=a.elements;
  197. var be=b.elements;
  198. oe[0]=ae[0] *be[0];
  199. oe[1]=ae[1] *be[1];
  200. oe[2]=ae[2] *be[2];
  201. oe[3]=ae[3] *be[3];
  202. }
  203. ConchVector4.scale=function(a,b,out){
  204. var oe=out.elements;
  205. var ae=a.elements;
  206. oe[0]=ae[0] *b;
  207. oe[1]=ae[1] *b;
  208. oe[2]=ae[2] *b;
  209. oe[3]=ae[3] *b;
  210. }
  211. ConchVector4.Clamp=function(value,min,max,out){
  212. var valuee=value.elements;
  213. var x=valuee[0];
  214. var y=valuee[1];
  215. var z=valuee[2];
  216. var w=valuee[3];
  217. var mine=min.elements;
  218. var mineX=mine[0];
  219. var mineY=mine[1];
  220. var mineZ=mine[2];
  221. var mineW=mine[3];
  222. var maxe=max.elements;
  223. var maxeX=maxe[0];
  224. var maxeY=maxe[1];
  225. var maxeZ=maxe[2];
  226. var maxeW=maxe[3];
  227. var oute=out.elements;
  228. x=(x > maxeX)? maxeX :x;
  229. x=(x < mineX)? mineX :x;
  230. y=(y > maxeY)? maxeY :y;
  231. y=(y < mineY)? mineY :y;
  232. z=(z > maxeZ)? maxeZ :z;
  233. z=(z < mineZ)? mineZ :z;
  234. w=(w > maxeW)? maxeW :w;
  235. w=(w < mineW)? mineW :w;
  236. oute[0]=x;
  237. oute[1]=y;
  238. oute[2]=z;
  239. oute[3]=w;
  240. }
  241. ConchVector4.distanceSquared=function(value1,value2){
  242. var value1e=value1.elements;
  243. var value2e=value2.elements;
  244. var x=value1e[0]-value2e[0];
  245. var y=value1e[1]-value2e[1];
  246. var z=value1e[2]-value2e[2];
  247. var w=value1e[3]-value2e[3];
  248. return (x *x)+(y *y)+(z *z)+(w *w);
  249. }
  250. ConchVector4.distance=function(value1,value2){
  251. var value1e=value1.elements;
  252. var value2e=value2.elements;
  253. var x=value1e[0]-value2e[0];
  254. var y=value1e[1]-value2e[1];
  255. var z=value1e[2]-value2e[2];
  256. var w=value1e[3]-value2e[3];
  257. return Math.sqrt((x *x)+(y *y)+(z *z)+(w *w));
  258. }
  259. ConchVector4.dot=function(a,b){
  260. var ae=a.elements;
  261. var be=b.elements;
  262. var r=(ae[0] *be[0])+(ae[1] *be[1])+(ae[2] *be[2])+(ae[3] *be[3]);
  263. return r;
  264. }
  265. ConchVector4.min=function(a,b,out){
  266. var e=out.elements;
  267. var f=a.elements;
  268. var g=b.elements
  269. e[0]=Math.min(f[0],g[0]);
  270. e[1]=Math.min(f[1],g[1]);
  271. e[2]=Math.min(f[2],g[2]);
  272. e[3]=Math.min(f[3],g[3]);
  273. }
  274. ConchVector4.max=function(a,b,out){
  275. var e=out.elements;
  276. var f=a.elements;
  277. var g=b.elements
  278. e[0]=Math.max(f[0],g[0]);
  279. e[1]=Math.max(f[1],g[1]);
  280. e[2]=Math.max(f[2],g[2]);
  281. e[3]=Math.max(f[3],g[3]);
  282. }
  283. __static(ConchVector4,
  284. ['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);}
  285. ]);
  286. return ConchVector4;
  287. })()
  288. /**
  289. *<code>Vector3</code> 类用于创建三维向量。
  290. */
  291. //class laya.d3.math.Native.ConchVector3
  292. var ConchVector3=(function(){
  293. function ConchVector3(x,y,z,nativeElements){
  294. /**[只读]向量元素集合。*/
  295. this.elements=null;
  296. (x===void 0)&& (x=0);
  297. (y===void 0)&& (y=0);
  298. (z===void 0)&& (z=0);
  299. var v;
  300. if (nativeElements){
  301. v=nativeElements;
  302. }else {
  303. v=new Float32Array(3);
  304. }
  305. this.elements=v;
  306. v[0]=x;
  307. v[1]=y;
  308. v[2]=z;
  309. }
  310. __class(ConchVector3,'laya.d3.math.Native.ConchVector3');
  311. var __proto=ConchVector3.prototype;
  312. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  313. /**
  314. *设置xyz值。
  315. *@param x X值。
  316. *@param y Y值。
  317. *@param z Z值。
  318. */
  319. __proto.setValue=function(x,y,z){
  320. this.elements[0]=x;
  321. this.elements[1]=y;
  322. this.elements[2]=z;
  323. }
  324. /**
  325. *从Array数组拷贝值。
  326. *@param array 数组。
  327. *@param offset 数组偏移。
  328. */
  329. __proto.fromArray=function(array,offset){
  330. (offset===void 0)&& (offset=0);
  331. this.elements[0]=array[offset+0];
  332. this.elements[1]=array[offset+1];
  333. this.elements[2]=array[offset+2];
  334. }
  335. /**
  336. *克隆。
  337. *@param destObject 克隆源。
  338. */
  339. __proto.cloneTo=function(destObject){
  340. var destVector3=destObject;
  341. var destE=destVector3.elements;
  342. var s=this.elements;
  343. destE[0]=s[0];
  344. destE[1]=s[1];
  345. destE[2]=s[2];
  346. }
  347. /**
  348. *克隆。
  349. *@return 克隆副本。
  350. */
  351. __proto.clone=function(){
  352. var destVector3=/*__JS__ */new this.constructor();
  353. this.cloneTo(destVector3);
  354. return destVector3;
  355. }
  356. __proto.toDefault=function(){
  357. this.elements[0]=0;
  358. this.elements[1]=0;
  359. this.elements[2]=0;
  360. }
  361. /**
  362. *设置X轴坐标。
  363. *@param value X轴坐标。
  364. */
  365. /**
  366. *获取X轴坐标。
  367. *@return X轴坐标。
  368. */
  369. __getset(0,__proto,'x',function(){
  370. return this.elements[0];
  371. },function(value){
  372. this.elements[0]=value;
  373. });
  374. /**
  375. *设置Y轴坐标。
  376. *@param value Y轴坐标。
  377. */
  378. /**
  379. *获取Y轴坐标。
  380. *@return Y轴坐标。
  381. */
  382. __getset(0,__proto,'y',function(){
  383. return this.elements[1];
  384. },function(value){
  385. this.elements[1]=value;
  386. });
  387. /**
  388. *设置Z轴坐标。
  389. *@param value Z轴坐标。
  390. */
  391. /**
  392. *获取Z轴坐标。
  393. *@return Z轴坐标。
  394. */
  395. __getset(0,__proto,'z',function(){
  396. return this.elements[2];
  397. },function(value){
  398. this.elements[2]=value;
  399. });
  400. ConchVector3.distanceSquared=function(value1,value2){
  401. var value1e=value1.elements;
  402. var value2e=value2.elements;
  403. var x=value1e[0]-value2e[0];
  404. var y=value1e[1]-value2e[1];
  405. var z=value1e[2]-value2e[2];
  406. return (x *x)+(y *y)+(z *z);
  407. }
  408. ConchVector3.distance=function(value1,value2){
  409. var value1e=value1.elements;
  410. var value2e=value2.elements;
  411. var x=value1e[0]-value2e[0];
  412. var y=value1e[1]-value2e[1];
  413. var z=value1e[2]-value2e[2];
  414. return Math.sqrt((x *x)+(y *y)+(z *z));
  415. }
  416. ConchVector3.min=function(a,b,out){
  417. var e=out.elements;
  418. var f=a.elements;
  419. var g=b.elements
  420. e[0]=Math.min(f[0],g[0]);
  421. e[1]=Math.min(f[1],g[1]);
  422. e[2]=Math.min(f[2],g[2]);
  423. }
  424. ConchVector3.max=function(a,b,out){
  425. var e=out.elements;
  426. var f=a.elements;
  427. var g=b.elements
  428. e[0]=Math.max(f[0],g[0]);
  429. e[1]=Math.max(f[1],g[1]);
  430. e[2]=Math.max(f[2],g[2]);
  431. }
  432. ConchVector3.transformQuat=function(source,rotation,out){
  433. var destination=out.elements;
  434. var se=source.elements;
  435. var re=rotation.elements;
  436. var x=se[0],y=se[1],z=se[2],qx=re[0],qy=re[1],qz=re[2],qw=re[3],
  437. 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;
  438. destination[0]=ix *qw+iw *-qx+iy *-qz-iz *-qy;
  439. destination[1]=iy *qw+iw *-qy+iz *-qx-ix *-qz;
  440. destination[2]=iz *qw+iw *-qz+ix *-qy-iy *-qx;
  441. }
  442. ConchVector3.scalarLength=function(a){
  443. var f=a.elements;
  444. var x=f[0],y=f[1],z=f[2];
  445. return Math.sqrt(x *x+y *y+z *z);
  446. }
  447. ConchVector3.scalarLengthSquared=function(a){
  448. var f=a.elements;
  449. var x=f[0],y=f[1],z=f[2];
  450. return x *x+y *y+z *z;
  451. }
  452. ConchVector3.normalize=function(s,out){
  453. var se=s.elements;
  454. var oe=out.elements;
  455. var x=se[0],y=se[1],z=se[2];
  456. var len=x *x+y *y+z *z;
  457. if (len > 0){
  458. len=1 / Math.sqrt(len);
  459. oe[0]=se[0] *len;
  460. oe[1]=se[1] *len;
  461. oe[2]=se[2] *len;
  462. }
  463. }
  464. ConchVector3.multiply=function(a,b,out){
  465. var e=out.elements;
  466. var f=a.elements;
  467. var g=b.elements
  468. e[0]=f[0] *g[0];
  469. e[1]=f[1] *g[1];
  470. e[2]=f[2] *g[2];
  471. }
  472. ConchVector3.scale=function(a,b,out){
  473. var e=out.elements;
  474. var f=a.elements;
  475. e[0]=f[0] *b;
  476. e[1]=f[1] *b;
  477. e[2]=f[2] *b;
  478. }
  479. ConchVector3.lerp=function(a,b,t,out){
  480. var e=out.elements;
  481. var f=a.elements;
  482. var g=b.elements;
  483. var ax=f[0],ay=f[1],az=f[2];
  484. e[0]=ax+t *(g[0]-ax);
  485. e[1]=ay+t *(g[1]-ay);
  486. e[2]=az+t *(g[2]-az);
  487. }
  488. ConchVector3.transformV3ToV3=function(vector,transform,result){
  489. var intermediate=ConchVector3._tempVector4;
  490. ConchVector3.transformV3ToV4(vector,transform,intermediate);
  491. var intermediateElem=intermediate.elements;
  492. var resultElem=result.elements;
  493. resultElem[0]=intermediateElem[0];
  494. resultElem[1]=intermediateElem[1];
  495. resultElem[2]=intermediateElem[2];
  496. }
  497. ConchVector3.transformV3ToV4=function(vector,transform,result){
  498. var vectorElem=vector.elements;
  499. var vectorX=vectorElem[0];
  500. var vectorY=vectorElem[1];
  501. var vectorZ=vectorElem[2];
  502. var transformElem=transform.elements;
  503. var resultElem=result.elements;
  504. resultElem[0]=(vectorX *transformElem[0])+(vectorY *transformElem[4])+(vectorZ *transformElem[8])+transformElem[12];
  505. resultElem[1]=(vectorX *transformElem[1])+(vectorY *transformElem[5])+(vectorZ *transformElem[9])+transformElem[13];
  506. resultElem[2]=(vectorX *transformElem[2])+(vectorY *transformElem[6])+(vectorZ *transformElem[10])+transformElem[14];
  507. resultElem[3]=(vectorX *transformElem[3])+(vectorY *transformElem[7])+(vectorZ *transformElem[11])+transformElem[15];
  508. }
  509. ConchVector3.TransformNormal=function(normal,transform,result){
  510. var normalElem=normal.elements;
  511. var normalX=normalElem[0];
  512. var normalY=normalElem[1];
  513. var normalZ=normalElem[2];
  514. var transformElem=transform.elements;
  515. var resultElem=result.elements;
  516. resultElem[0]=(normalX *transformElem[0])+(normalY *transformElem[4])+(normalZ *transformElem[8]);
  517. resultElem[1]=(normalX *transformElem[1])+(normalY *transformElem[5])+(normalZ *transformElem[9]);
  518. resultElem[2]=(normalX *transformElem[2])+(normalY *transformElem[6])+(normalZ *transformElem[10]);
  519. }
  520. ConchVector3.transformCoordinate=function(coordinate,transform,result){
  521. var coordinateElem=coordinate.elements;
  522. var coordinateX=coordinateElem[0];
  523. var coordinateY=coordinateElem[1];
  524. var coordinateZ=coordinateElem[2];
  525. var transformElem=transform.elements;
  526. var w=((coordinateX *transformElem[3])+(coordinateY *transformElem[7])+(coordinateZ *transformElem[11])+transformElem[15]);
  527. var resultElem=result.elements;
  528. resultElem[0]=(coordinateX *transformElem[0])+(coordinateY *transformElem[4])+(coordinateZ *transformElem[8])+transformElem[12] / w;
  529. resultElem[1]=(coordinateX *transformElem[1])+(coordinateY *transformElem[5])+(coordinateZ *transformElem[9])+transformElem[13] / w;
  530. resultElem[2]=(coordinateX *transformElem[2])+(coordinateY *transformElem[6])+(coordinateZ *transformElem[10])+transformElem[14] / w;
  531. }
  532. ConchVector3.Clamp=function(value,min,max,out){
  533. var valuee=value.elements;
  534. var x=valuee[0];
  535. var y=valuee[1];
  536. var z=valuee[2];
  537. var mine=min.elements;
  538. var mineX=mine[0];
  539. var mineY=mine[1];
  540. var mineZ=mine[2];
  541. var maxe=max.elements;
  542. var maxeX=maxe[0];
  543. var maxeY=maxe[1];
  544. var maxeZ=maxe[2];
  545. var oute=out.elements;
  546. x=(x > maxeX)? maxeX :x;
  547. x=(x < mineX)? mineX :x;
  548. y=(y > maxeY)? maxeY :y;
  549. y=(y < mineY)? mineY :y;
  550. z=(z > maxeZ)? maxeZ :z;
  551. z=(z < mineZ)? mineZ :z;
  552. oute[0]=x;
  553. oute[1]=y;
  554. oute[2]=z;
  555. }
  556. ConchVector3.add=function(a,b,out){
  557. var e=out.elements;
  558. var f=a.elements;
  559. var g=b.elements
  560. e[0]=f[0]+g[0];
  561. e[1]=f[1]+g[1];
  562. e[2]=f[2]+g[2];
  563. }
  564. ConchVector3.subtract=function(a,b,o){
  565. var oe=o.elements;
  566. var ae=a.elements;
  567. var be=b.elements;
  568. oe[0]=ae[0]-be[0];
  569. oe[1]=ae[1]-be[1];
  570. oe[2]=ae[2]-be[2];
  571. }
  572. ConchVector3.cross=function(a,b,o){
  573. var ae=a.elements;
  574. var be=b.elements;
  575. var oe=o.elements;
  576. var ax=ae[0],ay=ae[1],az=ae[2],bx=be[0],by=be[1],bz=be[2];
  577. oe[0]=ay *bz-az *by;
  578. oe[1]=az *bx-ax *bz;
  579. oe[2]=ax *by-ay *bx;
  580. }
  581. ConchVector3.dot=function(a,b){
  582. var ae=a.elements;
  583. var be=b.elements;
  584. var r=(ae[0] *be[0])+(ae[1] *be[1])+(ae[2] *be[2]);
  585. return r;
  586. }
  587. ConchVector3.equals=function(a,b){
  588. var ae=a.elements;
  589. var be=b.elements;
  590. return MathUtils3D.nearEqual(ae[0],be[0])&& MathUtils3D.nearEqual(ae[1],be[1])&& MathUtils3D.nearEqual(ae[2],be[2]);
  591. }
  592. ConchVector3.ZERO=new ConchVector3(0.0,0.0,0.0);
  593. ConchVector3.ONE=new ConchVector3(1.0,1.0,1.0);
  594. ConchVector3.NegativeUnitX=new ConchVector3(-1,0,0);
  595. ConchVector3.UnitX=new ConchVector3(1,0,0);
  596. ConchVector3.UnitY=new ConchVector3(0,1,0);
  597. ConchVector3.UnitZ=new ConchVector3(0,0,1);
  598. ConchVector3.ForwardRH=new ConchVector3(0,0,-1);
  599. ConchVector3.ForwardLH=new ConchVector3(0,0,1);
  600. ConchVector3.Up=new ConchVector3(0,1,0);
  601. ConchVector3.NAN=new ConchVector3(NaN,NaN,NaN);
  602. __static(ConchVector3,
  603. ['_tempVector4',function(){return this._tempVector4=new ConchVector4();}
  604. ]);
  605. return ConchVector3;
  606. })()
  607. /**
  608. *<code>Quaternion</code> 类用于创建四元数。
  609. */
  610. //class laya.d3.math.Native.ConchQuaternion
  611. var ConchQuaternion=(function(){
  612. function ConchQuaternion(x,y,z,w,nativeElements){
  613. /**四元数元素数组*/
  614. //this.elements=null;
  615. (x===void 0)&& (x=0);
  616. (y===void 0)&& (y=0);
  617. (z===void 0)&& (z=0);
  618. (w===void 0)&& (w=1);
  619. var v;
  620. if (nativeElements){
  621. v=nativeElements;
  622. }else {
  623. v=new Float32Array(4);
  624. }
  625. v[0]=x;
  626. v[1]=y;
  627. v[2]=z;
  628. v[3]=w;
  629. this.elements=v;
  630. }
  631. __class(ConchQuaternion,'laya.d3.math.Native.ConchQuaternion');
  632. var __proto=ConchQuaternion.prototype;
  633. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  634. /**
  635. *根据缩放值缩放四元数
  636. *@param scale 缩放值
  637. *@param out 输出四元数
  638. */
  639. __proto.scaling=function(scaling,out){
  640. var e=out.elements;
  641. var f=this.elements;
  642. e[0]=f[0] *scaling;
  643. e[1]=f[1] *scaling;
  644. e[2]=f[2] *scaling;
  645. e[3]=f[3] *scaling;
  646. }
  647. /**
  648. *归一化四元数
  649. *@param out 输出四元数
  650. */
  651. __proto.normalize=function(out){
  652. ConchQuaternion._normalizeArray(this.elements,out.elements);
  653. }
  654. /**
  655. *计算四元数的长度
  656. *@return 长度
  657. */
  658. __proto.length=function(){
  659. var f=this.elements;
  660. var x=f[0],y=f[1],z=f[2],w=f[3];
  661. return Math.sqrt(x *x+y *y+z *z+w *w);
  662. }
  663. /**
  664. *根据绕X轴的角度旋转四元数
  665. *@param rad 角度
  666. *@param out 输出四元数
  667. */
  668. __proto.rotateX=function(rad,out){
  669. var e=out.elements;
  670. var f=this.elements;
  671. rad *=0.5;
  672. var ax=f[0],ay=f[1],az=f[2],aw=f[3];
  673. var bx=Math.sin(rad),bw=Math.cos(rad);
  674. e[0]=ax *bw+aw *bx;
  675. e[1]=ay *bw+az *bx;
  676. e[2]=az *bw-ay *bx;
  677. e[3]=aw *bw-ax *bx;
  678. }
  679. /**
  680. *根据绕Y轴的制定角度旋转四元数
  681. *@param rad 角度
  682. *@param out 输出四元数
  683. */
  684. __proto.rotateY=function(rad,out){
  685. var e=out.elements;
  686. var f=this.elements;
  687. rad *=0.5;
  688. var ax=f[0],ay=f[1],az=f[2],aw=f[3],by=Math.sin(rad),bw=Math.cos(rad);
  689. e[0]=ax *bw-az *by;
  690. e[1]=ay *bw+aw *by;
  691. e[2]=az *bw+ax *by;
  692. e[3]=aw *bw-ay *by;
  693. }
  694. /**
  695. *根据绕Z轴的制定角度旋转四元数
  696. *@param rad 角度
  697. *@param out 输出四元数
  698. */
  699. __proto.rotateZ=function(rad,out){
  700. var e=out.elements;
  701. var f=this.elements;
  702. rad *=0.5;
  703. var ax=f[0],ay=f[1],az=f[2],aw=f[3],bz=Math.sin(rad),bw=Math.cos(rad);
  704. e[0]=ax *bw+ay *bz;
  705. e[1]=ay *bw-ax *bz;
  706. e[2]=az *bw+aw *bz;
  707. e[3]=aw *bw-az *bz;
  708. }
  709. /**
  710. *分解四元数到欧拉角(顺序为Yaw、Pitch、Roll),参考自http://xboxforums.create.msdn.com/forums/p/4574/23988.aspx#23988,问题绕X轴翻转超过±90度时有,会产生瞬间反转
  711. *@param quaternion 源四元数
  712. *@param out 欧拉角值
  713. */
  714. __proto.getYawPitchRoll=function(out){
  715. ConchVector3.transformQuat(ConchVector3.ForwardRH,this,ConchQuaternion.TEMPVector31);
  716. ConchVector3.transformQuat(ConchVector3.Up,this,ConchQuaternion.TEMPVector32);
  717. var upe=ConchQuaternion.TEMPVector32.elements;
  718. ConchQuaternion.angleTo(ConchVector3.ZERO,ConchQuaternion.TEMPVector31,ConchQuaternion.TEMPVector33);
  719. var anglee=ConchQuaternion.TEMPVector33.elements;
  720. if (anglee[0]==Math.PI / 2){
  721. anglee[1]=ConchQuaternion.arcTanAngle(upe[2],upe[0]);
  722. anglee[2]=0;
  723. }else if (anglee[0]==-Math.PI / 2){
  724. anglee[1]=ConchQuaternion.arcTanAngle(-upe[2],-upe[0]);
  725. anglee[2]=0;
  726. }else {
  727. Matrix4x4.createRotationY(-anglee[1],ConchQuaternion.TEMPMatrix0);
  728. Matrix4x4.createRotationX(-anglee[0],ConchQuaternion.TEMPMatrix1);
  729. ConchVector3.transformCoordinate(ConchQuaternion.TEMPVector32,ConchQuaternion.TEMPMatrix0,ConchQuaternion.TEMPVector32);
  730. ConchVector3.transformCoordinate(ConchQuaternion.TEMPVector32,ConchQuaternion.TEMPMatrix1,ConchQuaternion.TEMPVector32);
  731. anglee[2]=ConchQuaternion.arcTanAngle(upe[1],-upe[0]);
  732. }
  733. if (anglee[1] <=-Math.PI)
  734. anglee[1]=Math.PI;
  735. if (anglee[2] <=-Math.PI)
  736. anglee[2]=Math.PI;
  737. if (anglee[1] >=Math.PI && anglee[2] >=Math.PI){
  738. anglee[1]=0;
  739. anglee[2]=0;
  740. anglee[0]=Math.PI-anglee[0];
  741. };
  742. var oe=out.elements;
  743. oe[0]=anglee[1];
  744. oe[1]=anglee[0];
  745. oe[2]=anglee[2];
  746. }
  747. /**
  748. *求四元数的逆
  749. *@param out 输出四元数
  750. */
  751. __proto.invert=function(out){
  752. var e=out.elements;
  753. var f=this.elements;
  754. var a0=f[0],a1=f[1],a2=f[2],a3=f[3];
  755. var dot=a0 *a0+a1 *a1+a2 *a2+a3 *a3;
  756. var invDot=dot ? 1.0 / dot :0;
  757. e[0]=-a0 *invDot;
  758. e[1]=-a1 *invDot;
  759. e[2]=-a2 *invDot;
  760. e[3]=a3 *invDot;
  761. }
  762. /**
  763. *设置四元数为单位算数
  764. *@param out 输出四元数
  765. */
  766. __proto.identity=function(){
  767. var e=this.elements;
  768. e[0]=0;
  769. e[1]=0;
  770. e[2]=0;
  771. e[3]=1;
  772. }
  773. /**
  774. *从Array数组拷贝值。
  775. *@param array 数组。
  776. *@param offset 数组偏移。
  777. */
  778. __proto.fromArray=function(array,offset){
  779. (offset===void 0)&& (offset=0);
  780. this.elements[0]=array[offset+0];
  781. this.elements[1]=array[offset+1];
  782. this.elements[2]=array[offset+2];
  783. this.elements[3]=array[offset+3];
  784. }
  785. /**
  786. *克隆。
  787. *@param destObject 克隆源。
  788. */
  789. __proto.cloneTo=function(destObject){
  790. var i,s,d;
  791. s=this.elements;
  792. d=destObject.elements;
  793. if (s===d){
  794. return;
  795. }
  796. for (i=0;i < 4;++i){
  797. d[i]=s[i];
  798. }
  799. }
  800. /**
  801. *克隆。
  802. *@return 克隆副本。
  803. */
  804. __proto.clone=function(){
  805. var dest=/*__JS__ */new this.constructor();
  806. this.cloneTo(dest);
  807. return dest;
  808. }
  809. __proto.equals=function(b){
  810. var ae=this.elements;
  811. var be=b.elements;
  812. 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]);
  813. }
  814. /**
  815. *计算长度的平方。
  816. *@return 长度的平方。
  817. */
  818. __proto.lengthSquared=function(){
  819. var x=this.elements[0];
  820. var y=this.elements[1];
  821. var z=this.elements[2];
  822. var w=this.elements[3];
  823. return (x *x)+(y *y)+(z *z)+(w *w);
  824. }
  825. /**
  826. *设置四元数的x值
  827. */
  828. /**
  829. *获取四元数的x值
  830. */
  831. __getset(0,__proto,'x',function(){
  832. return this.elements[0];
  833. },function(value){
  834. this.elements[0]=value;
  835. });
  836. /**
  837. *设置四元数的y值
  838. */
  839. /**
  840. *获取四元数的y值
  841. */
  842. __getset(0,__proto,'y',function(){
  843. return this.elements[1];
  844. },function(value){
  845. this.elements[1]=value;
  846. });
  847. /**
  848. *设置四元数的z值
  849. */
  850. /**
  851. *获取四元数的z值
  852. */
  853. __getset(0,__proto,'z',function(){
  854. return this.elements[2];
  855. },function(value){
  856. this.elements[2]=value;
  857. });
  858. /**
  859. *设置四元数的w值
  860. */
  861. /**
  862. *获取四元数的w值
  863. */
  864. __getset(0,__proto,'w',function(){
  865. return this.elements[3];
  866. },function(value){
  867. this.elements[3]=value;
  868. });
  869. ConchQuaternion._dotArray=function(l,r){
  870. return l[0] *r[0]+l[1] *r[1]+l[2] *r[2]+l[3] *r[3];
  871. }
  872. ConchQuaternion._normalizeArray=function(f,o){
  873. var x=f[0],y=f[1],z=f[2],w=f[3];
  874. var len=x *x+y *y+z *z+w *w;
  875. if (len > 0){
  876. len=1 / Math.sqrt(len);
  877. o[0]=x *len;
  878. o[1]=y *len;
  879. o[2]=z *len;
  880. o[3]=w *len;
  881. }
  882. }
  883. ConchQuaternion._lerpArray=function(l,r,amount,o){
  884. var inverse=1.0-amount;
  885. if (ConchQuaternion._dotArray(l,r)>=0){
  886. o[0]=(inverse *l[0])+(amount *r[0]);
  887. o[1]=(inverse *l[1])+(amount *r[1]);
  888. o[2]=(inverse *l[2])+(amount *r[2]);
  889. o[3]=(inverse *l[3])+(amount *r[3]);
  890. }else {
  891. o[0]=(inverse *l[0])-(amount *r[0]);
  892. o[1]=(inverse *l[1])-(amount *r[1]);
  893. o[2]=(inverse *l[2])-(amount *r[2]);
  894. o[3]=(inverse *l[3])-(amount *r[3]);
  895. }
  896. ConchQuaternion._normalizeArray(o,o);
  897. }
  898. ConchQuaternion.createFromYawPitchRoll=function(yaw,pitch,roll,out){
  899. var halfRoll=roll *0.5;
  900. var halfPitch=pitch *0.5;
  901. var halfYaw=yaw *0.5;
  902. var sinRoll=Math.sin(halfRoll);
  903. var cosRoll=Math.cos(halfRoll);
  904. var sinPitch=Math.sin(halfPitch);
  905. var cosPitch=Math.cos(halfPitch);
  906. var sinYaw=Math.sin(halfYaw);
  907. var cosYaw=Math.cos(halfYaw);
  908. var oe=out.elements;
  909. oe[0]=(cosYaw *sinPitch *cosRoll)+(sinYaw *cosPitch *sinRoll);
  910. oe[1]=(sinYaw *cosPitch *cosRoll)-(cosYaw *sinPitch *sinRoll);
  911. oe[2]=(cosYaw *cosPitch *sinRoll)-(sinYaw *sinPitch *cosRoll);
  912. oe[3]=(cosYaw *cosPitch *cosRoll)+(sinYaw *sinPitch *sinRoll);
  913. }
  914. ConchQuaternion.multiply=function(left,right,out){
  915. var le=left.elements;
  916. var re=right.elements;
  917. var oe=out.elements;
  918. var lx=le[0];
  919. var ly=le[1];
  920. var lz=le[2];
  921. var lw=le[3];
  922. var rx=re[0];
  923. var ry=re[1];
  924. var rz=re[2];
  925. var rw=re[3];
  926. var a=(ly *rz-lz *ry);
  927. var b=(lz *rx-lx *rz);
  928. var c=(lx *ry-ly *rx);
  929. var d=(lx *rx+ly *ry+lz *rz);
  930. oe[0]=(lx *rw+rx *lw)+a;
  931. oe[1]=(ly *rw+ry *lw)+b;
  932. oe[2]=(lz *rw+rz *lw)+c;
  933. oe[3]=lw *rw-d;
  934. }
  935. ConchQuaternion.arcTanAngle=function(x,y){
  936. if (x==0){
  937. if (y==1)
  938. return Math.PI / 2;
  939. return-Math.PI / 2;
  940. }
  941. if (x > 0)
  942. return Math.atan(y / x);
  943. if (x < 0){
  944. if (y > 0)
  945. return Math.atan(y / x)+Math.PI;
  946. return Math.atan(y / x)-Math.PI;
  947. }
  948. return 0;
  949. }
  950. ConchQuaternion.angleTo=function(from,location,angle){
  951. ConchVector3.subtract(location,from,ConchQuaternion.TEMPVector30);
  952. ConchVector3.normalize(ConchQuaternion.TEMPVector30,ConchQuaternion.TEMPVector30);
  953. angle.elements[0]=Math.asin(ConchQuaternion.TEMPVector30.y);
  954. angle.elements[1]=ConchQuaternion.arcTanAngle(-ConchQuaternion.TEMPVector30.z,-ConchQuaternion.TEMPVector30.x);
  955. }
  956. ConchQuaternion.createFromAxisAngle=function(axis,rad,out){
  957. var e=out.elements;
  958. var f=axis.elements;
  959. rad=rad *0.5;
  960. var s=Math.sin(rad);
  961. e[0]=s *f[0];
  962. e[1]=s *f[1];
  963. e[2]=s *f[2];
  964. e[3]=Math.cos(rad);
  965. }
  966. ConchQuaternion.createFromMatrix3x3=function(sou,out){
  967. var e=out.elements;
  968. var f=sou.elements;
  969. var fTrace=f[0]+f[4]+f[8];
  970. var fRoot;
  971. if (fTrace > 0.0){
  972. fRoot=Math.sqrt(fTrace+1.0);
  973. e[3]=0.5 *fRoot;
  974. fRoot=0.5 / fRoot;
  975. e[0]=(f[5]-f[7])*fRoot;
  976. e[1]=(f[6]-f[2])*fRoot;
  977. e[2]=(f[1]-f[3])*fRoot;
  978. }else {
  979. var i=0;
  980. if (f[4] > f[0])
  981. i=1;
  982. if (f[8] > f[i *3+i])
  983. i=2;
  984. var j=(i+1)% 3;
  985. var k=(i+2)% 3;
  986. fRoot=Math.sqrt(f[i *3+i]-f[j *3+j]-f[k *3+k]+1.0);
  987. e[i]=0.5 *fRoot;
  988. fRoot=0.5 / fRoot;
  989. e[3]=(f[j *3+k]-f[k *3+j])*fRoot;
  990. e[j]=(f[j *3+i]+f[i *3+j])*fRoot;
  991. e[k]=(f[k *3+i]+f[i *3+k])*fRoot;
  992. }
  993. return;
  994. }
  995. ConchQuaternion.createFromMatrix4x4=function(mat,out){
  996. var me=mat.elements;
  997. var oe=out.elements;
  998. var sqrt;
  999. var half;
  1000. var scale=me[0]+me[5]+me[10];
  1001. if (scale > 0.0){
  1002. sqrt=Math.sqrt(scale+1.0);
  1003. oe[3]=sqrt *0.5;
  1004. sqrt=0.5 / sqrt;
  1005. oe[0]=(me[6]-me[9])*sqrt;
  1006. oe[1]=(me[8]-me[2])*sqrt;
  1007. oe[2]=(me[1]-me[4])*sqrt;
  1008. }else if ((me[0] >=me[5])&& (me[0] >=me[10])){
  1009. sqrt=Math.sqrt(1.0+me[0]-me[5]-me[10]);
  1010. half=0.5 / sqrt;
  1011. oe[0]=0.5 *sqrt;
  1012. oe[1]=(me[1]+me[4])*half;
  1013. oe[2]=(me[2]+me[8])*half;
  1014. oe[3]=(me[6]-me[9])*half;
  1015. }else if (me[5] > me[10]){
  1016. sqrt=Math.sqrt(1.0+me[5]-me[0]-me[10]);
  1017. half=0.5 / sqrt;
  1018. oe[0]=(me[4]+me[1])*half;
  1019. oe[1]=0.5 *sqrt;
  1020. oe[2]=(me[9]+me[6])*half;
  1021. oe[3]=(me[8]-me[2])*half;
  1022. }else {
  1023. sqrt=Math.sqrt(1.0+me[10]-me[0]-me[5]);
  1024. half=0.5 / sqrt;
  1025. oe[0]=(me[8]+me[2])*half;
  1026. oe[1]=(me[9]+me[6])*half;
  1027. oe[2]=0.5 *sqrt;
  1028. oe[3]=(me[1]-me[4])*half;
  1029. }
  1030. }
  1031. ConchQuaternion.slerp=function(left,right,t,out){
  1032. var a=left.elements;
  1033. var b=right.elements;
  1034. var oe=out.elements;
  1035. 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];
  1036. var omega,cosom,sinom,scale0,scale1;
  1037. cosom=ax *bx+ay *by+az *bz+aw *bw;
  1038. if (cosom < 0.0){
  1039. cosom=-cosom;
  1040. bx=-bx;
  1041. by=-by;
  1042. bz=-bz;
  1043. bw=-bw;
  1044. }
  1045. if ((1.0-cosom)> 0.000001){
  1046. omega=Math.acos(cosom);
  1047. sinom=Math.sin(omega);
  1048. scale0=Math.sin((1.0-t)*omega)/ sinom;
  1049. scale1=Math.sin(t *omega)/ sinom;
  1050. }else {
  1051. scale0=1.0-t;
  1052. scale1=t;
  1053. }
  1054. oe[0]=scale0 *ax+scale1 *bx;
  1055. oe[1]=scale0 *ay+scale1 *by;
  1056. oe[2]=scale0 *az+scale1 *bz;
  1057. oe[3]=scale0 *aw+scale1 *bw;
  1058. return oe;
  1059. }
  1060. ConchQuaternion.lerp=function(left,right,amount,out){
  1061. ConchQuaternion._lerpArray(left.elements,right.elements,amount,out.elements);
  1062. }
  1063. ConchQuaternion.add=function(left,right,out){
  1064. var e=out.elements;
  1065. var f=left.elements;
  1066. var g=right.elements;
  1067. e[0]=f[0]+g[0];
  1068. e[1]=f[1]+g[1];
  1069. e[2]=f[2]+g[2];
  1070. e[3]=f[3]+g[3];
  1071. }
  1072. ConchQuaternion.dot=function(left,right){
  1073. return ConchQuaternion._dotArray(left.elements,right.elements);
  1074. }
  1075. ConchQuaternion.rotationLookAt=function(forward,up,out){
  1076. ConchQuaternion.lookAt(ConchVector3.ZERO,forward,up,out);
  1077. }
  1078. ConchQuaternion.lookAt=function(eye,target,up,out){
  1079. Matrix3x3.lookAt(eye,target,up,ConchQuaternion._tempMatrix3x3);
  1080. ConchQuaternion.rotationMatrix(ConchQuaternion._tempMatrix3x3,out);
  1081. }
  1082. ConchQuaternion.invert=function(value,out){
  1083. var vE=value.elements;
  1084. var oE=out.elements;
  1085. var lengthSq=value.lengthSquared();
  1086. if (!MathUtils3D.isZero(lengthSq)){
  1087. lengthSq=1.0 / lengthSq;
  1088. oE[0]=-vE[0] *lengthSq;
  1089. oE[1]=-vE[1] *lengthSq;
  1090. oE[2]=-vE[2] *lengthSq;
  1091. oE[3]=vE[3] *lengthSq;
  1092. }
  1093. }
  1094. ConchQuaternion.rotationMatrix=function(matrix3x3,out){
  1095. var me=matrix3x3.elements;
  1096. var m11=me[0];
  1097. var m12=me[1];
  1098. var m13=me[2];
  1099. var m21=me[3];
  1100. var m22=me[4];
  1101. var m23=me[5];
  1102. var m31=me[6];
  1103. var m32=me[7];
  1104. var m33=me[8];
  1105. var oe=out.elements;
  1106. var sqrt=NaN,half=NaN;
  1107. var scale=m11+m22+m33;
  1108. if (scale > 0){
  1109. sqrt=Math.sqrt(scale+1);
  1110. oe[3]=sqrt *0.5;
  1111. sqrt=0.5 / sqrt;
  1112. oe[0]=(m23-m32)*sqrt;
  1113. oe[1]=(m31-m13)*sqrt;
  1114. oe[2]=(m12-m21)*sqrt;
  1115. }else if ((m11 >=m22)&& (m11 >=m33)){
  1116. sqrt=Math.sqrt(1+m11-m22-m33);
  1117. half=0.5 / sqrt;
  1118. oe[0]=0.5 *sqrt;
  1119. oe[1]=(m12+m21)*half;
  1120. oe[2]=(m13+m31)*half;
  1121. oe[3]=(m23-m32)*half;
  1122. }else if (m22 > m33){
  1123. sqrt=Math.sqrt(1+m22-m11-m33);
  1124. half=0.5 / sqrt;
  1125. oe[0]=(m21+m12)*half;
  1126. oe[1]=0.5 *sqrt;
  1127. oe[2]=(m32+m23)*half;
  1128. oe[3]=(m31-m13)*half;
  1129. }else {
  1130. sqrt=Math.sqrt(1+m33-m11-m22);
  1131. half=0.5 / sqrt;
  1132. oe[0]=(m31+m13)*half;
  1133. oe[1]=(m32+m23)*half;
  1134. oe[2]=0.5 *sqrt;
  1135. oe[3]=(m12-m21)*half;
  1136. }
  1137. }
  1138. ConchQuaternion.DEFAULT=new ConchQuaternion();
  1139. __static(ConchQuaternion,
  1140. ['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);}
  1141. ]);
  1142. return ConchQuaternion;
  1143. })()
  1144. /**
  1145. *<code>Matrix3x3</code> 类用于创建3x3矩阵。
  1146. */
  1147. //class laya.d3.math.Matrix3x3
  1148. var Matrix3x3=(function(){
  1149. function Matrix3x3(){
  1150. /**矩阵元素数组*/
  1151. //this.elements=null;
  1152. var e=this.elements=new Float32Array(9);
  1153. e[0]=1;
  1154. e[1]=0;
  1155. e[2]=0;
  1156. e[3]=0;
  1157. e[4]=1;
  1158. e[5]=0;
  1159. e[6]=0;
  1160. e[7]=0;
  1161. e[8]=1;
  1162. }
  1163. __class(Matrix3x3,'laya.d3.math.Matrix3x3');
  1164. var __proto=Matrix3x3.prototype;
  1165. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  1166. /**
  1167. *计算3x3矩阵的行列式
  1168. *@return 矩阵的行列式
  1169. */
  1170. __proto.determinant=function(){
  1171. var f=this.elements;
  1172. var a00=f[0],a01=f[1],a02=f[2];
  1173. var a10=f[3],a11=f[4],a12=f[5];
  1174. var a20=f[6],a21=f[7],a22=f[8];
  1175. return a00 *(a22 *a11-a12 *a21)+a01 *(-a22 *a10+a12 *a20)+a02 *(a21 *a10-a11 *a20);
  1176. }
  1177. /**
  1178. *通过一个二维向量转换3x3矩阵
  1179. *@param tra 转换向量
  1180. *@param out 输出矩阵
  1181. */
  1182. __proto.translate=function(trans,out){
  1183. var e=out.elements;
  1184. var f=this.elements;
  1185. var a00=f[0],a01=f[1],a02=f[2];
  1186. var a10=f[3],a11=f[4],a12=f[5];
  1187. var a20=f[6],a21=f[7],a22=f[8];
  1188. var x=trans.x,y=trans.y;
  1189. e[0]=a00;
  1190. e[1]=a01;
  1191. e[2]=a02;
  1192. e[3]=a10;
  1193. e[4]=a11;
  1194. e[5]=a12;
  1195. e[6]=x *a00+y *a10+a20;
  1196. e[7]=x *a01+y *a11+a21;
  1197. e[8]=x *a02+y *a12+a22;
  1198. }
  1199. /**
  1200. *根据指定角度旋转3x3矩阵
  1201. *@param rad 旋转角度
  1202. *@param out 输出矩阵
  1203. */
  1204. __proto.rotate=function(rad,out){
  1205. var e=out.elements;
  1206. var f=this.elements;
  1207. var a00=f[0],a01=f[1],a02=f[2];
  1208. var a10=f[3],a11=f[4],a12=f[5];
  1209. var a20=f[6],a21=f[7],a22=f[8];
  1210. var s=Math.sin(rad);
  1211. var c=Math.cos(rad);
  1212. e[0]=c *a00+s *a10;
  1213. e[1]=c *a01+s *a11;
  1214. e[2]=c *a02+s *a12;
  1215. e[3]=c *a10-s *a00;
  1216. e[4]=c *a11-s *a01;
  1217. e[5]=c *a12-s *a02;
  1218. e[6]=a20;
  1219. e[7]=a21;
  1220. e[8]=a22;
  1221. }
  1222. /**
  1223. *根据制定缩放3x3矩阵
  1224. *@param scale 缩放值
  1225. *@param out 输出矩阵
  1226. */
  1227. __proto.scale=function(scale,out){
  1228. var e=out.elements;
  1229. var f=this.elements;
  1230. var x=scale.x,y=scale.y;
  1231. e[0]=x *f[0];
  1232. e[1]=x *f[1];
  1233. e[2]=x *f[2];
  1234. e[3]=y *f[3];
  1235. e[4]=y *f[4];
  1236. e[5]=y *f[5];
  1237. e[6]=f[6];
  1238. e[7]=f[7];
  1239. e[8]=f[8];
  1240. }
  1241. /**
  1242. *计算3x3矩阵的逆矩阵
  1243. *@param out 输出的逆矩阵
  1244. */
  1245. __proto.invert=function(out){
  1246. var e=out.elements;
  1247. var f=this.elements;
  1248. var a00=f[0],a01=f[1],a02=f[2];
  1249. var a10=f[3],a11=f[4],a12=f[5];
  1250. var a20=f[6],a21=f[7],a22=f[8];
  1251. var b01=a22 *a11-a12 *a21;
  1252. var b11=-a22 *a10+a12 *a20;
  1253. var b21=a21 *a10-a11 *a20;
  1254. var det=a00 *b01+a01 *b11+a02 *b21;
  1255. if (!det){
  1256. out=null;
  1257. }
  1258. det=1.0 / det;
  1259. e[0]=b01 *det;
  1260. e[1]=(-a22 *a01+a02 *a21)*det;
  1261. e[2]=(a12 *a01-a02 *a11)*det;
  1262. e[3]=b11 *det;
  1263. e[4]=(a22 *a00-a02 *a20)*det;
  1264. e[5]=(-a12 *a00+a02 *a10)*det;
  1265. e[6]=b21 *det;
  1266. e[7]=(-a21 *a00+a01 *a20)*det;
  1267. e[8]=(a11 *a00-a01 *a10)*det;
  1268. }
  1269. /**
  1270. *计算3x3矩阵的转置矩阵
  1271. *@param out 输出矩阵
  1272. */
  1273. __proto.transpose=function(out){
  1274. var e=out.elements;
  1275. var f=this.elements;
  1276. if (out===this){
  1277. var a01=f[1],a02=f[2],a12=f[5];
  1278. e[1]=f[3];
  1279. e[2]=f[6];
  1280. e[3]=a01;
  1281. e[5]=f[7];
  1282. e[6]=a02;
  1283. e[7]=a12;
  1284. }else {
  1285. e[0]=f[0];
  1286. e[1]=f[3];
  1287. e[2]=f[6];
  1288. e[3]=f[1];
  1289. e[4]=f[4];
  1290. e[5]=f[7];
  1291. e[6]=f[2];
  1292. e[7]=f[5];
  1293. e[8]=f[8];
  1294. }
  1295. }
  1296. /**设置已有的矩阵为单位矩阵*/
  1297. __proto.identity=function(){
  1298. var e=this.elements;
  1299. e[0]=1;
  1300. e[1]=0;
  1301. e[2]=0;
  1302. e[3]=0;
  1303. e[4]=1;
  1304. e[5]=0;
  1305. e[6]=0;
  1306. e[7]=0;
  1307. e[8]=1;
  1308. }
  1309. /**
  1310. *克隆。
  1311. *@param destObject 克隆源。
  1312. */
  1313. __proto.cloneTo=function(destObject){
  1314. var i,s,d;
  1315. s=this.elements;
  1316. d=destObject.elements;
  1317. if (s===d){
  1318. return;
  1319. }
  1320. for (i=0;i < 9;++i){
  1321. d[i]=s[i];
  1322. }
  1323. }
  1324. /**
  1325. *克隆。
  1326. *@return 克隆副本。
  1327. */
  1328. __proto.clone=function(){
  1329. var dest=/*__JS__ */new this.constructor();
  1330. this.cloneTo(dest);
  1331. return dest;
  1332. }
  1333. Matrix3x3.createFromTranslation=function(trans,out){
  1334. var e=out.elements;
  1335. out[0]=1;
  1336. out[1]=0;
  1337. out[2]=0;
  1338. out[3]=0;
  1339. out[4]=1;
  1340. out[5]=0;
  1341. out[6]=trans.x;
  1342. out[7]=trans.y;
  1343. out[8]=1;
  1344. }
  1345. Matrix3x3.createFromRotation=function(rad,out){
  1346. var e=out.elements;
  1347. var s=Math.sin(rad),c=Math.cos(rad);
  1348. e[0]=c;
  1349. e[1]=s;
  1350. e[2]=0;
  1351. e[3]=-s;
  1352. e[4]=c;
  1353. e[5]=0;
  1354. e[6]=0;
  1355. e[7]=0;
  1356. e[8]=1;
  1357. }
  1358. Matrix3x3.createFromScaling=function(scale,out){
  1359. var e=out.elements;
  1360. e[0]=scale.x;
  1361. e[1]=0;
  1362. e[2]=0;
  1363. e[3]=0;
  1364. e[4]=scale.y;
  1365. e[5]=0;
  1366. e[6]=0;
  1367. e[7]=0;
  1368. e[8]=1;
  1369. }
  1370. Matrix3x3.createFromMatrix4x4=function(sou,out){
  1371. out[0]=sou[0];
  1372. out[1]=sou[1];
  1373. out[2]=sou[2];
  1374. out[3]=sou[4];
  1375. out[4]=sou[5];
  1376. out[5]=sou[6];
  1377. out[6]=sou[8];
  1378. out[7]=sou[9];
  1379. out[8]=sou[10];
  1380. }
  1381. Matrix3x3.multiply=function(left,right,out){
  1382. var e=out.elements;
  1383. var f=left.elements;
  1384. var g=right.elements;
  1385. var a00=f[0],a01=f[1],a02=f[2];
  1386. var a10=f[3],a11=f[4],a12=f[5];
  1387. var a20=f[6],a21=f[7],a22=f[8];
  1388. var b00=g[0],b01=g[1],b02=g[2];
  1389. var b10=g[3],b11=g[4],b12=g[5];
  1390. var b20=g[6],b21=g[7],b22=g[8];
  1391. e[0]=b00 *a00+b01 *a10+b02 *a20;
  1392. e[1]=b00 *a01+b01 *a11+b02 *a21;
  1393. e[2]=b00 *a02+b01 *a12+b02 *a22;
  1394. e[3]=b10 *a00+b11 *a10+b12 *a20;
  1395. e[4]=b10 *a01+b11 *a11+b12 *a21;
  1396. e[5]=b10 *a02+b11 *a12+b12 *a22;
  1397. e[6]=b20 *a00+b21 *a10+b22 *a20;
  1398. e[7]=b20 *a01+b21 *a11+b22 *a21;
  1399. e[8]=b20 *a02+b21 *a12+b22 *a22;
  1400. }
  1401. Matrix3x3.lookAt=function(eye,target,up,out){
  1402. Vector3.subtract(eye,target,Matrix3x3._tempV30);
  1403. Vector3.normalize(Matrix3x3._tempV30,Matrix3x3._tempV30);
  1404. Vector3.cross(up,Matrix3x3._tempV30,Matrix3x3._tempV31);
  1405. Vector3.normalize(Matrix3x3._tempV31,Matrix3x3._tempV31);
  1406. Vector3.cross(Matrix3x3._tempV30,Matrix3x3._tempV31,Matrix3x3._tempV32);
  1407. var v0=Matrix3x3._tempV30;
  1408. var v1=Matrix3x3._tempV31;
  1409. var v2=Matrix3x3._tempV32;
  1410. var me=out.elements;
  1411. me[0]=v1.x;
  1412. me[3]=v1.y;
  1413. me[6]=v1.z;
  1414. me[1]=v2.x;
  1415. me[4]=v2.y;
  1416. me[7]=v2.z;
  1417. me[2]=v0.x;
  1418. me[5]=v0.y;
  1419. me[8]=v0.z;
  1420. }
  1421. Matrix3x3.DEFAULT=new Matrix3x3();
  1422. __static(Matrix3x3,
  1423. ['_tempV30',function(){return this._tempV30=new Vector3();},'_tempV31',function(){return this._tempV31=new Vector3();},'_tempV32',function(){return this._tempV32=new Vector3();}
  1424. ]);
  1425. return Matrix3x3;
  1426. })()
  1427. /**
  1428. *<code>Color</code> 类用于创建颜色实例。
  1429. */
  1430. //class laya.d3.math.Color
  1431. var Color=(function(){
  1432. function Color(r,g,b,a){
  1433. /**red分量*/
  1434. this.r=NaN;
  1435. /**green分量*/
  1436. this.g=NaN;
  1437. /**blue分量*/
  1438. this.b=NaN;
  1439. /**alpha分量*/
  1440. this.a=NaN;
  1441. (r===void 0)&& (r=1);
  1442. (g===void 0)&& (g=1);
  1443. (b===void 0)&& (b=1);
  1444. (a===void 0)&& (a=1);
  1445. this.r=r;
  1446. this.g=g;
  1447. this.b=b;
  1448. this.a=a;
  1449. }
  1450. __class(Color,'laya.d3.math.Color');
  1451. var __proto=Color.prototype;
  1452. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  1453. /**
  1454. *Gamma空间转换到线性空间。
  1455. *@param linear 线性空间颜色。
  1456. */
  1457. __proto.toLinear=function(out){
  1458. out.r=Utils3D.gammaToLinearSpace(this.r);
  1459. out.g=Utils3D.gammaToLinearSpace(this.g);
  1460. out.b=Utils3D.gammaToLinearSpace(this.b);
  1461. }
  1462. /**
  1463. *线性空间转换到Gamma空间。
  1464. *@param gamma Gamma空间颜色。
  1465. */
  1466. __proto.toGamma=function(out){
  1467. out.r=Utils3D.linearToGammaSpace(this.r);
  1468. out.g=Utils3D.linearToGammaSpace(this.g);
  1469. out.b=Utils3D.linearToGammaSpace(this.b);
  1470. }
  1471. /**
  1472. *克隆。
  1473. *@param destObject 克隆源。
  1474. */
  1475. __proto.cloneTo=function(destObject){
  1476. var destColor=destObject;
  1477. destColor.r=this.r;
  1478. destColor.g=this.g;
  1479. destColor.b=this.b;
  1480. destColor.a=this.a;
  1481. }
  1482. /**
  1483. *克隆。
  1484. *@return 克隆副本。
  1485. */
  1486. __proto.clone=function(){
  1487. var dest=/*__JS__ */new this.constructor();
  1488. this.cloneTo(dest);
  1489. return dest;
  1490. }
  1491. __proto.forNativeElement=function(nativeElements){
  1492. if (nativeElements){
  1493. /*__JS__ */this.elements=nativeElements;
  1494. /*__JS__ */this.elements[0]=this.r;
  1495. /*__JS__ */this.elements[1]=this.g;
  1496. /*__JS__ */this.elements[2]=this.b;
  1497. /*__JS__ */this.elements[3]=this.a;
  1498. }else {
  1499. /*__JS__ */this.elements=new Float32Array([this.r,this.g,this.b,this.a]);
  1500. }
  1501. Vector2.rewriteNumProperty(this,"r",0);
  1502. Vector2.rewriteNumProperty(this,"g",1);
  1503. Vector2.rewriteNumProperty(this,"b",2);
  1504. Vector2.rewriteNumProperty(this,"a",3);
  1505. }
  1506. __static(Color,
  1507. ['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);}
  1508. ]);
  1509. return Color;
  1510. })()
  1511. /**
  1512. *<code>SkyRenderer</code> 类用于实现天空渲染器。
  1513. */
  1514. //class laya.d3.resource.models.SkyRenderer
  1515. var SkyRenderer=(function(){
  1516. function SkyRenderer(){
  1517. /**@private */
  1518. this._material=null;
  1519. this._mesh=SkyBox.instance;
  1520. }
  1521. __class(SkyRenderer,'laya.d3.resource.models.SkyRenderer');
  1522. var __proto=SkyRenderer.prototype;
  1523. /**
  1524. *@private
  1525. *是否可用。
  1526. */
  1527. __proto._isAvailable=function(){
  1528. return this._material && this._mesh;
  1529. }
  1530. /**
  1531. *@private
  1532. */
  1533. __proto._render=function(state){
  1534. if (this._material && this._mesh){
  1535. var gl=LayaGL.instance;
  1536. var scene=state.scene;
  1537. var camera=state.camera;
  1538. WebGLContext.setCullFace(gl,false);
  1539. WebGLContext.setDepthFunc(gl,/*laya.webgl.WebGLContext.LEQUAL*/0x0203);
  1540. WebGLContext.setDepthMask(gl,false);
  1541. var shader=state.shader=this._material._shader.getSubShaderAt(0)._passes[0].withCompile(0,0,this._material._defineDatas.value);
  1542. var switchShader=shader.bind();
  1543. var switchShaderLoop=(Stat.loopCount!==shader._uploadMark);
  1544. var uploadScene=(shader._uploadScene!==scene)|| switchShaderLoop;
  1545. if (uploadScene || switchShader){
  1546. shader.uploadUniforms(shader._sceneUniformParamsMap,scene._shaderValues,uploadScene);
  1547. shader._uploadScene=scene;
  1548. };
  1549. var uploadCamera=(shader._uploadCamera!==camera)|| switchShaderLoop;
  1550. if (uploadCamera || switchShader){
  1551. shader.uploadUniforms(shader._cameraUniformParamsMap,camera._shaderValues,uploadCamera);
  1552. shader._uploadCamera=camera;
  1553. };
  1554. var uploadMaterial=(shader._uploadMaterial!==this._material)|| switchShaderLoop;
  1555. if (uploadMaterial || switchShader){
  1556. shader.uploadUniforms(shader._materialUniformParamsMap,this._material._shaderValues,uploadMaterial);
  1557. shader._uploadMaterial=this._material;
  1558. }
  1559. this._mesh._bufferState.bind();
  1560. this._mesh._render(state);
  1561. WebGLContext.setDepthFunc(gl,/*laya.webgl.WebGLContext.LESS*/0x0201);
  1562. WebGLContext.setDepthMask(gl,true);
  1563. }
  1564. }
  1565. /**
  1566. *@private
  1567. */
  1568. __proto.destroy=function(){
  1569. if (this._material){
  1570. this._material._removeReference();
  1571. this._material=null;
  1572. }
  1573. }
  1574. /**
  1575. *设置材质。
  1576. *@param 材质。
  1577. */
  1578. /**
  1579. *获取材质。
  1580. *@return 材质。
  1581. */
  1582. __getset(0,__proto,'material',function(){
  1583. return this._material;
  1584. },function(value){
  1585. if (this._material!==value){
  1586. (this._material)&& (this._material._removeReference());
  1587. (value)&& (value._addReference());
  1588. this._material=value;
  1589. }
  1590. });
  1591. /**
  1592. *设置网格。
  1593. *@param 网格。
  1594. */
  1595. /**
  1596. *获取网格。
  1597. *@return 网格。
  1598. */
  1599. __getset(0,__proto,'mesh',function(){
  1600. return this._mesh;
  1601. },function(value){
  1602. if (this._mesh!==value){
  1603. this._mesh=value;
  1604. }
  1605. });
  1606. return SkyRenderer;
  1607. })()
  1608. /**
  1609. *<code>MeshFilter</code> 类用于创建网格过滤器。
  1610. */
  1611. //class laya.d3.core.MeshFilter
  1612. var MeshFilter=(function(){
  1613. function MeshFilter(owner){
  1614. /**@private */
  1615. this._owner=null;
  1616. /**@private */
  1617. this._sharedMesh=null;
  1618. this._owner=owner;
  1619. }
  1620. __class(MeshFilter,'laya.d3.core.MeshFilter');
  1621. var __proto=MeshFilter.prototype;
  1622. /**
  1623. *@private
  1624. */
  1625. __proto._getMeshDefine=function(mesh){
  1626. var define=0;
  1627. for (var i=0,n=mesh._subMeshCount;i < n;i++){
  1628. var subMesh=mesh._getSubMesh(i);
  1629. var vertexElements=subMesh._vertexBuffer._vertexDeclaration.vertexElements;
  1630. for (var j=0,m=vertexElements.length;j < m;j++){
  1631. var vertexElement=vertexElements[j];
  1632. var name=vertexElement.elementUsage;
  1633. switch (name){
  1634. case /*laya.d3.graphics.Vertex.VertexMesh.MESH_COLOR0*/1:
  1635. define |=MeshSprite3D.SHADERDEFINE_COLOR;
  1636. break
  1637. case /*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE0*/2:
  1638. define |=MeshSprite3D.SHADERDEFINE_UV0;
  1639. break ;
  1640. case /*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE1*/7:
  1641. define |=MeshSprite3D.SHADERDEFINE_UV1;
  1642. break ;
  1643. }
  1644. }
  1645. }
  1646. return define;
  1647. }
  1648. /**
  1649. *@inheritDoc
  1650. */
  1651. __proto.destroy=function(){
  1652. this._owner=null;
  1653. (this._sharedMesh)&& (this._sharedMesh._removeReference(),this._sharedMesh=null);
  1654. }
  1655. /**
  1656. *设置共享网格。
  1657. *@return value 共享网格。
  1658. */
  1659. /**
  1660. *获取共享网格。
  1661. *@return 共享网格。
  1662. */
  1663. __getset(0,__proto,'sharedMesh',function(){
  1664. return this._sharedMesh;
  1665. },function(value){
  1666. if (this._sharedMesh!==value){
  1667. var defineDatas=this._owner._render._defineDatas;
  1668. var lastValue=this._sharedMesh;
  1669. if (lastValue){
  1670. lastValue._removeReference();
  1671. defineDatas.remove(this._getMeshDefine(lastValue));
  1672. }
  1673. value._addReference();
  1674. this._sharedMesh=value;
  1675. defineDatas.add(this._getMeshDefine(value));
  1676. (this._owner._render)._changeRenderObjectsByMesh(value);
  1677. }
  1678. (this._owner._render)._onMeshChange(value);
  1679. });
  1680. return MeshFilter;
  1681. })()
  1682. /**
  1683. *<code>VertexElement</code> 类用于创建顶点结构分配。
  1684. */
  1685. //class laya.d3.graphics.VertexElement
  1686. var VertexElement=(function(){
  1687. function VertexElement(offset,elementFormat,elementUsage){
  1688. this.offset=0;
  1689. this.elementFormat=null;
  1690. this.elementUsage=0;
  1691. this.offset=offset;
  1692. this.elementFormat=elementFormat;
  1693. this.elementUsage=elementUsage;
  1694. }
  1695. __class(VertexElement,'laya.d3.graphics.VertexElement');
  1696. return VertexElement;
  1697. })()
  1698. /**
  1699. *...
  1700. *@author ...
  1701. */
  1702. //class laya.d3.graphics.Vertex.VertexShuriKenParticle
  1703. var VertexShuriKenParticle=(function(){
  1704. function VertexShuriKenParticle(){}
  1705. __class(VertexShuriKenParticle,'laya.d3.graphics.Vertex.VertexShuriKenParticle');
  1706. VertexShuriKenParticle.PARTICLE_CORNERTEXTURECOORDINATE0=0;
  1707. VertexShuriKenParticle.PARTICLE_POSITION0=1;
  1708. VertexShuriKenParticle.PARTICLE_COLOR0=2;
  1709. VertexShuriKenParticle.PARTICLE_TEXTURECOORDINATE0=3;
  1710. VertexShuriKenParticle.PARTICLE_SHAPEPOSITIONSTARTLIFETIME=4;
  1711. VertexShuriKenParticle.PARTICLE_DIRECTIONTIME=5;
  1712. VertexShuriKenParticle.PARTICLE_STARTCOLOR0=6;
  1713. VertexShuriKenParticle.PARTICLE_ENDCOLOR0=7;
  1714. VertexShuriKenParticle.PARTICLE_STARTSIZE=8;
  1715. VertexShuriKenParticle.PARTICLE_STARTROTATION=9;
  1716. VertexShuriKenParticle.PARTICLE_STARTSPEED=10;
  1717. VertexShuriKenParticle.PARTICLE_RANDOM0=11;
  1718. VertexShuriKenParticle.PARTICLE_RANDOM1=12;
  1719. VertexShuriKenParticle.PARTICLE_SIMULATIONWORLDPOSTION=13;
  1720. VertexShuriKenParticle.PARTICLE_SIMULATIONWORLDROTATION=14;
  1721. return VertexShuriKenParticle;
  1722. })()
  1723. /**
  1724. *<code>TerrainLeaf</code> Terrain的叶子节点
  1725. */
  1726. //class laya.d3.terrain.TerrainLeaf
  1727. var TerrainLeaf=(function(){
  1728. function TerrainLeaf(){
  1729. this._boundingSphere=null;
  1730. this._boundingBox=null;
  1731. this._sizeOfY=null;
  1732. this._currentLODLevel=0;
  1733. this._lastDistanceToEye=NaN;
  1734. this._originalBoundingSphere=null;
  1735. this._originalBoundingBox=null;
  1736. this._originalBoundingBoxCorners=null;
  1737. this._bUseStrip=false;
  1738. this._gridSize=NaN;
  1739. this._beginGridX=0;
  1740. //针对整个大地形的偏移
  1741. this._beginGridZ=0;
  1742. //针对整个大地形的偏移
  1743. this._LODError=null;
  1744. TerrainLeaf.__init__();
  1745. this._currentLODLevel=0;
  1746. }
  1747. __class(TerrainLeaf,'laya.d3.terrain.TerrainLeaf');
  1748. var __proto=TerrainLeaf.prototype;
  1749. __proto.calcVertextNorml=function(x,z,terrainHeightData,heighDataWidth,heightDataHeight,normal){
  1750. var dZ=0,dX=0;
  1751. dX=TerrainLeaf.getHeightFromTerrainHeightData(x-1,z-1,terrainHeightData,heighDataWidth,heightDataHeight)*-1.0;
  1752. dX+=TerrainLeaf.getHeightFromTerrainHeightData(x-1,z,terrainHeightData,heighDataWidth,heightDataHeight)*-1.0;
  1753. dX+=TerrainLeaf.getHeightFromTerrainHeightData(x-1,z+1,terrainHeightData,heighDataWidth,heightDataHeight)*-1.0;
  1754. dX+=TerrainLeaf.getHeightFromTerrainHeightData(x+1,z-1,terrainHeightData,heighDataWidth,heightDataHeight)*1.0;
  1755. dX+=TerrainLeaf.getHeightFromTerrainHeightData(x+1,z,terrainHeightData,heighDataWidth,heightDataHeight)*1.0;
  1756. dX+=TerrainLeaf.getHeightFromTerrainHeightData(x+1,z+1,terrainHeightData,heighDataWidth,heightDataHeight)*1.0;
  1757. dZ=TerrainLeaf.getHeightFromTerrainHeightData(x-1,z-1,terrainHeightData,heighDataWidth,heightDataHeight)*-1.0;
  1758. dZ+=TerrainLeaf.getHeightFromTerrainHeightData(x,z-1,terrainHeightData,heighDataWidth,heightDataHeight)*-1.0;
  1759. dZ+=TerrainLeaf.getHeightFromTerrainHeightData(x+1,z-1,terrainHeightData,heighDataWidth,heightDataHeight)*-1.0;
  1760. dZ+=TerrainLeaf.getHeightFromTerrainHeightData(x-1,z+1,terrainHeightData,heighDataWidth,heightDataHeight)*1.0;
  1761. dZ+=TerrainLeaf.getHeightFromTerrainHeightData(x,z+1,terrainHeightData,heighDataWidth,heightDataHeight)*1.0;
  1762. dZ+=TerrainLeaf.getHeightFromTerrainHeightData(x+1,z+1,terrainHeightData,heighDataWidth,heightDataHeight)*1.0;
  1763. normal.x=-dX;
  1764. normal.y=6;
  1765. normal.z=-dZ;
  1766. Vector3.normalize(normal,normal);
  1767. }
  1768. __proto.calcVertextNormlUV=function(x,z,terrainWidth,terrainHeight,normal){
  1769. normal.x=x / terrainWidth;
  1770. normal.y=z / terrainHeight;
  1771. normal.z=z / terrainHeight;
  1772. }
  1773. __proto.calcVertextBuffer=function(offsetChunkX,offsetChunkZ,beginX,beginZ,girdSize,vertextBuffer,offset,strideSize,terrainHeightData,heighDataWidth,heightDataHeight,cameraCoordinateInverse){
  1774. if (cameraCoordinateInverse==true && !TerrainLeaf.__ADAPT_MATRIX__){
  1775. TerrainLeaf.__ADAPT_MATRIX__=new Matrix4x4();
  1776. var mat=new Matrix4x4();
  1777. Matrix4x4.createRotationY(Math.PI,TerrainLeaf.__ADAPT_MATRIX__);
  1778. Matrix4x4.createTranslate(new Vector3(0,0,(heightDataHeight-1)*girdSize),mat);
  1779. Matrix4x4.multiply(mat,TerrainLeaf.__ADAPT_MATRIX__,TerrainLeaf.__ADAPT_MATRIX__);
  1780. TerrainLeaf.__ADAPT_MATRIX_INV__=new Matrix4x4();
  1781. TerrainLeaf.__ADAPT_MATRIX__.invert(TerrainLeaf.__ADAPT_MATRIX_INV__);
  1782. }
  1783. this._gridSize=girdSize;
  1784. this._beginGridX=offsetChunkX *TerrainLeaf.CHUNK_GRID_NUM+beginX;
  1785. this._beginGridZ=offsetChunkZ *TerrainLeaf.CHUNK_GRID_NUM+beginZ;
  1786. var nNum=offset *strideSize;
  1787. var minY=2147483647;
  1788. var maxY=-2147483648;
  1789. var normal=new Vector3();
  1790. for (var i=0,s=TerrainLeaf.LEAF_GRID_NUM+1;i < s;i++){
  1791. for (var j=0,s1=TerrainLeaf.LEAF_GRID_NUM+1;j < s1;j++){
  1792. TerrainLeaf.__VECTOR3__.x=(this._beginGridX+j)*this._gridSize;
  1793. TerrainLeaf.__VECTOR3__.z=(this._beginGridZ+i)*this._gridSize;
  1794. TerrainLeaf.__VECTOR3__.y=terrainHeightData[(this._beginGridZ+i)*(heighDataWidth)+(this._beginGridX+j)];
  1795. minY=TerrainLeaf.__VECTOR3__.y < minY ? TerrainLeaf.__VECTOR3__.y :minY;
  1796. maxY=TerrainLeaf.__VECTOR3__.y > maxY ? TerrainLeaf.__VECTOR3__.y :maxY;
  1797. if (TerrainLeaf.__ADAPT_MATRIX__){
  1798. Vector3.transformV3ToV3(TerrainLeaf.__VECTOR3__,TerrainLeaf.__ADAPT_MATRIX__,TerrainLeaf.__VECTOR3__);
  1799. }
  1800. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.x;
  1801. nNum++;
  1802. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.y;
  1803. nNum++;
  1804. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.z;
  1805. nNum++;
  1806. this.calcVertextNormlUV(this._beginGridX+j,this._beginGridZ+i,heighDataWidth,heightDataHeight,normal);
  1807. vertextBuffer[nNum]=normal.x;
  1808. nNum++;
  1809. vertextBuffer[nNum]=normal.y;
  1810. nNum++;
  1811. vertextBuffer[nNum]=normal.z;
  1812. nNum++;
  1813. vertextBuffer[nNum]=(beginX+j)/ TerrainLeaf.CHUNK_GRID_NUM;
  1814. nNum++;
  1815. vertextBuffer[nNum]=(beginZ+i)/ TerrainLeaf.CHUNK_GRID_NUM;
  1816. nNum++;
  1817. vertextBuffer[nNum]=this._beginGridX+j;
  1818. nNum++;
  1819. vertextBuffer[nNum]=this._beginGridZ+i;
  1820. nNum++;
  1821. }
  1822. }
  1823. this._sizeOfY=new Vector2(minY-1,maxY+1);
  1824. this.calcLODErrors(terrainHeightData,heighDataWidth,heightDataHeight);
  1825. this.calcOriginalBoudingBoxAndSphere();
  1826. }
  1827. __proto.calcSkirtVertextBuffer=function(offsetChunkX,offsetChunkZ,beginX,beginZ,girdSize,vertextBuffer,offset,strideSize,terrainHeightData,heighDataWidth,heightDataHeight){
  1828. this._gridSize=girdSize;
  1829. this._beginGridX=offsetChunkX *TerrainLeaf.CHUNK_GRID_NUM+beginX;
  1830. this._beginGridZ=offsetChunkZ *TerrainLeaf.CHUNK_GRID_NUM+beginZ;
  1831. var nNum=offset *strideSize;
  1832. var i=0,j=0,s=TerrainLeaf.LEAF_GRID_NUM+1;
  1833. var normal=new Vector3();
  1834. var hZIndex=0;
  1835. var hXIndex=0;
  1836. var h=0;
  1837. var zh=0;
  1838. var xh=0;
  1839. for (i=0;i < 2;i++){
  1840. for (j=0;j < s;j++){
  1841. TerrainLeaf.__VECTOR3__.x=(this._beginGridX+j)*this._gridSize;
  1842. TerrainLeaf.__VECTOR3__.y=(i==1 ? terrainHeightData[this._beginGridZ *heighDataWidth+(this._beginGridX+j)] :-this._gridSize);
  1843. TerrainLeaf.__VECTOR3__.z=(this._beginGridZ+0)*this._gridSize;
  1844. if (TerrainLeaf.__ADAPT_MATRIX__){
  1845. Vector3.transformV3ToV3(TerrainLeaf.__VECTOR3__,TerrainLeaf.__ADAPT_MATRIX__,TerrainLeaf.__VECTOR3__);
  1846. }
  1847. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.x;
  1848. nNum++;
  1849. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.y;
  1850. nNum++;
  1851. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.z;
  1852. nNum++;
  1853. if (i==0){
  1854. hZIndex=(this._beginGridZ-1);
  1855. }else {
  1856. hZIndex=this._beginGridZ;
  1857. }
  1858. this.calcVertextNormlUV(this._beginGridX+j,hZIndex,heighDataWidth,heightDataHeight,normal);
  1859. vertextBuffer[nNum]=normal.x;
  1860. nNum++;
  1861. vertextBuffer[nNum]=normal.y;
  1862. nNum++;
  1863. vertextBuffer[nNum]=normal.z;
  1864. nNum++;
  1865. vertextBuffer[nNum]=(beginX+j)/ TerrainLeaf.CHUNK_GRID_NUM;
  1866. nNum++;
  1867. vertextBuffer[nNum]=(beginZ+0)/ TerrainLeaf.CHUNK_GRID_NUM;
  1868. nNum++;
  1869. vertextBuffer[nNum]=this._beginGridX+j;
  1870. nNum++;
  1871. vertextBuffer[nNum]=hZIndex;
  1872. nNum++;
  1873. }
  1874. }
  1875. for (i=0;i < 2;i++){
  1876. for (j=0;j < s;j++){
  1877. TerrainLeaf.__VECTOR3__.x=(this._beginGridX+j)*this._gridSize;
  1878. TerrainLeaf.__VECTOR3__.y=(i==0 ? terrainHeightData[(this._beginGridZ+TerrainLeaf.LEAF_GRID_NUM)*(heighDataWidth)+(this._beginGridX+j)] :-this._gridSize);
  1879. TerrainLeaf.__VECTOR3__.z=(this._beginGridZ+TerrainLeaf.LEAF_GRID_NUM)*this._gridSize;
  1880. if (TerrainLeaf.__ADAPT_MATRIX__){
  1881. Vector3.transformV3ToV3(TerrainLeaf.__VECTOR3__,TerrainLeaf.__ADAPT_MATRIX__,TerrainLeaf.__VECTOR3__);
  1882. }
  1883. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.x;
  1884. nNum++;
  1885. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.y;
  1886. nNum++;
  1887. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.z;
  1888. nNum++;
  1889. if (i==0){
  1890. hZIndex=this._beginGridZ+TerrainLeaf.LEAF_GRID_NUM;
  1891. }else {
  1892. hZIndex=(this._beginGridZ+TerrainLeaf.LEAF_GRID_NUM+1);
  1893. }
  1894. this.calcVertextNormlUV(this._beginGridX+j,hZIndex,heighDataWidth,heightDataHeight,normal);
  1895. vertextBuffer[nNum]=normal.x;
  1896. nNum++;
  1897. vertextBuffer[nNum]=normal.y;
  1898. nNum++;
  1899. vertextBuffer[nNum]=normal.z;
  1900. nNum++;
  1901. vertextBuffer[nNum]=(beginX+j)/ TerrainLeaf.CHUNK_GRID_NUM;
  1902. nNum++;
  1903. vertextBuffer[nNum]=(beginZ+TerrainLeaf.LEAF_GRID_NUM)/ TerrainLeaf.CHUNK_GRID_NUM;
  1904. nNum++;
  1905. vertextBuffer[nNum]=this._beginGridX+j;
  1906. nNum++;
  1907. vertextBuffer[nNum]=hZIndex;
  1908. nNum++;
  1909. }
  1910. }
  1911. for (i=0;i < 2;i++){
  1912. for (j=0;j < s;j++){
  1913. TerrainLeaf.__VECTOR3__.x=(this._beginGridX+0)*this._gridSize;
  1914. TerrainLeaf.__VECTOR3__.y=(i==0 ? terrainHeightData[(this._beginGridZ+j)*(heighDataWidth)+(this._beginGridX+0)] :-this._gridSize);
  1915. TerrainLeaf.__VECTOR3__.z=(this._beginGridZ+j)*this._gridSize;
  1916. if (TerrainLeaf.__ADAPT_MATRIX__){
  1917. Vector3.transformV3ToV3(TerrainLeaf.__VECTOR3__,TerrainLeaf.__ADAPT_MATRIX__,TerrainLeaf.__VECTOR3__);
  1918. }
  1919. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.x;
  1920. nNum++;
  1921. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.y;
  1922. nNum++;
  1923. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.z;
  1924. nNum++;
  1925. if (i==0){
  1926. hXIndex=this._beginGridX;
  1927. }else {
  1928. hXIndex=(this._beginGridX-1);
  1929. }
  1930. this.calcVertextNormlUV(hXIndex,this._beginGridZ+j,heighDataWidth,heightDataHeight,normal);
  1931. vertextBuffer[nNum]=normal.x;
  1932. nNum++;
  1933. vertextBuffer[nNum]=normal.y;
  1934. nNum++;
  1935. vertextBuffer[nNum]=normal.z;
  1936. nNum++;
  1937. vertextBuffer[nNum]=(beginX+0)/ TerrainLeaf.CHUNK_GRID_NUM;
  1938. nNum++;
  1939. vertextBuffer[nNum]=(beginZ+j)/ TerrainLeaf.CHUNK_GRID_NUM;
  1940. nNum++;
  1941. vertextBuffer[nNum]=hXIndex;
  1942. nNum++;
  1943. vertextBuffer[nNum]=this._beginGridZ+j;
  1944. nNum++;
  1945. }
  1946. }
  1947. for (i=0;i < 2;i++){
  1948. for (j=0;j < s;j++){
  1949. TerrainLeaf.__VECTOR3__.x=(this._beginGridX+TerrainLeaf.LEAF_GRID_NUM)*this._gridSize;
  1950. TerrainLeaf.__VECTOR3__.y=(i==1 ? terrainHeightData[(this._beginGridZ+j)*(heighDataWidth)+(this._beginGridX+TerrainLeaf.LEAF_GRID_NUM)] :-this._gridSize);
  1951. TerrainLeaf.__VECTOR3__.z=(this._beginGridZ+j)*this._gridSize;
  1952. if (TerrainLeaf.__ADAPT_MATRIX__){
  1953. Vector3.transformV3ToV3(TerrainLeaf.__VECTOR3__,TerrainLeaf.__ADAPT_MATRIX__,TerrainLeaf.__VECTOR3__);
  1954. }
  1955. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.x;
  1956. nNum++;
  1957. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.y;
  1958. nNum++;
  1959. vertextBuffer[nNum]=TerrainLeaf.__VECTOR3__.z;
  1960. nNum++;
  1961. if (i==0){
  1962. hXIndex=this._beginGridX+TerrainLeaf.LEAF_GRID_NUM+1;
  1963. }else {
  1964. hXIndex=this._beginGridX+TerrainLeaf.LEAF_GRID_NUM;
  1965. }
  1966. this.calcVertextNormlUV(hXIndex,this._beginGridZ+j,heighDataWidth,heightDataHeight,normal);
  1967. vertextBuffer[nNum]=normal.x;
  1968. nNum++;
  1969. vertextBuffer[nNum]=normal.y;
  1970. nNum++;
  1971. vertextBuffer[nNum]=normal.z;
  1972. nNum++;
  1973. vertextBuffer[nNum]=(beginX+TerrainLeaf.LEAF_GRID_NUM)/ TerrainLeaf.CHUNK_GRID_NUM;
  1974. nNum++;
  1975. vertextBuffer[nNum]=(beginZ+j)/ TerrainLeaf.CHUNK_GRID_NUM;
  1976. nNum++;
  1977. vertextBuffer[nNum]=hXIndex;
  1978. nNum++;
  1979. vertextBuffer[nNum]=this._beginGridZ+j;
  1980. nNum++;
  1981. }
  1982. }
  1983. }
  1984. __proto.calcOriginalBoudingBoxAndSphere=function(){
  1985. var min=new Vector3(this._beginGridX *this._gridSize,this._sizeOfY.x,this._beginGridZ *this._gridSize);
  1986. var max=new Vector3((this._beginGridX+TerrainLeaf.LEAF_GRID_NUM)*this._gridSize,this._sizeOfY.y,(this._beginGridZ+TerrainLeaf.LEAF_GRID_NUM)*this._gridSize);
  1987. if (TerrainLeaf.__ADAPT_MATRIX__){
  1988. Vector3.transformV3ToV3(min,TerrainLeaf.__ADAPT_MATRIX__,min);
  1989. Vector3.transformV3ToV3(max,TerrainLeaf.__ADAPT_MATRIX__,max);
  1990. }
  1991. this._originalBoundingBox=new BoundBox(min,max);
  1992. var size=new Vector3();
  1993. Vector3.subtract(max,min,size);
  1994. Vector3.scale(size,0.5,size);
  1995. var center=new Vector3();
  1996. Vector3.add(min,size,center);
  1997. this._originalBoundingSphere=new BoundSphere(center,Vector3.scalarLength(size));
  1998. this._originalBoundingBoxCorners=__newvec(8,null);
  1999. this._originalBoundingBox.getCorners(this._originalBoundingBoxCorners);
  2000. this._boundingBox=new BoundBox(new Vector3(-0.5,-0.5,-0.5),new Vector3(0.5,0.5,0.5));
  2001. this._boundingSphere=new BoundSphere(new Vector3(0,0,0),1);
  2002. }
  2003. __proto.calcLeafBoudingBox=function(worldMatrix){
  2004. for (var i=0;i < 8;i++){
  2005. Vector3.transformCoordinate(this._originalBoundingBoxCorners[i],worldMatrix,BaseRender._tempBoundBoxCorners[i]);
  2006. }
  2007. BoundBox.createfromPoints(BaseRender._tempBoundBoxCorners,this._boundingBox);
  2008. }
  2009. __proto.calcLeafBoudingSphere=function(worldMatrix,maxScale){
  2010. Vector3.transformCoordinate(this._originalBoundingSphere.center,worldMatrix,this._boundingSphere.center);
  2011. this._boundingSphere.radius=this._originalBoundingSphere.radius *maxScale;
  2012. }
  2013. __proto.calcLODErrors=function(terrainHeightData,heighDataWidth,heightDataHeight){
  2014. this._LODError=new Float32Array(TerrainLeaf._maxLODLevel+1);
  2015. var step=1;
  2016. for (var i=0,n=TerrainLeaf._maxLODLevel+1;i < n;i++){
  2017. var maxError=0;
  2018. for (var y=0,n1=TerrainLeaf.LEAF_GRID_NUM;y < n1;y+=step){
  2019. for (var x=0,n2=TerrainLeaf.LEAF_GRID_NUM;x < n2;x+=step){
  2020. var z00=terrainHeightData[(this._beginGridZ+y)*heighDataWidth+(this._beginGridX+x)];
  2021. var z10=terrainHeightData[(this._beginGridZ+y)*heighDataWidth+(this._beginGridX+x)+step];
  2022. var z01=terrainHeightData[(this._beginGridZ+y+step)*heighDataWidth+(this._beginGridX+x)];
  2023. var z11=terrainHeightData[(this._beginGridZ+y+step)*heighDataWidth+(this._beginGridX+x)+step];
  2024. for (var j=0;j < step;j++){
  2025. var ys=j / step;
  2026. for (var k=0;k < step;k++){
  2027. var xs=k / step;
  2028. var z=terrainHeightData[(this._beginGridZ+y+j)*heighDataWidth+(this._beginGridX+x)+k];
  2029. var iz=(xs+ys <=1)? (z00+(z10-z00)*xs+(z01-z00)*ys):(z11+(z01-z11)*(1-xs)+(z10-z11)*(1-ys));
  2030. var error=Math.abs(iz-z);
  2031. maxError=Math.max(maxError,error);
  2032. }
  2033. }
  2034. }
  2035. }
  2036. step *=2;
  2037. this._LODError[i]=maxError;
  2038. }
  2039. }
  2040. __proto.determineLod=function(eyePos,perspectiveFactor,tolerance,tolerAndPerspectiveChanged){
  2041. var nDistanceToEye=Vector3.distance(eyePos,this._boundingSphere.center);
  2042. var n=TerrainLeaf._maxLODLevel;
  2043. if (!tolerAndPerspectiveChanged){
  2044. if (this._lastDistanceToEye==nDistanceToEye){
  2045. return this._currentLODLevel;
  2046. }else if (this._lastDistanceToEye > nDistanceToEye){
  2047. n=this._currentLODLevel;
  2048. }
  2049. }
  2050. for (var i=n;i >=1;i--){
  2051. if (Terrain.LOD_DISTANCE_FACTOR *this._LODError[i] / nDistanceToEye *perspectiveFactor < tolerance){
  2052. this._currentLODLevel=i;
  2053. break ;
  2054. }
  2055. }
  2056. this._lastDistanceToEye=nDistanceToEye;
  2057. return this._currentLODLevel;
  2058. }
  2059. TerrainLeaf.__init__=function(){
  2060. if (!TerrainLeaf._bInit){
  2061. var nLeafNum=(TerrainLeaf.CHUNK_GRID_NUM / TerrainLeaf.LEAF_GRID_NUM)*(TerrainLeaf.CHUNK_GRID_NUM / TerrainLeaf.LEAF_GRID_NUM);
  2062. TerrainLeaf._planeLODIndex=__newvec(nLeafNum);
  2063. var i=0,j=0,k=0,n=0,n1=0,nOffset=0;
  2064. var nOriginIndexArray=null,nTempIndex=null;
  2065. for (i=0;i < nLeafNum;i++){
  2066. TerrainLeaf._planeLODIndex[i]=new Array(TerrainLeaf._maxLODLevel+1);
  2067. }
  2068. for (i=0,n=TerrainLeaf._maxLODLevel+1;i < n;i++){
  2069. TerrainLeaf._planeLODIndex[0][i]=TerrainLeaf.calcPlaneLODIndex(i);
  2070. }
  2071. for (i=1;i < nLeafNum;i++){
  2072. nOffset=i *TerrainLeaf.LEAF_PLANE_VERTEXT_COUNT;
  2073. for (j=0,n1=TerrainLeaf._maxLODLevel+1;j < n1;j++){
  2074. nOriginIndexArray=TerrainLeaf._planeLODIndex[0][j];
  2075. nTempIndex=new Uint16Array(nOriginIndexArray.length);
  2076. for (k=0;k < nOriginIndexArray.length;k++){
  2077. nTempIndex[k]=nOriginIndexArray[k]+nOffset;
  2078. }
  2079. TerrainLeaf._planeLODIndex[i][j]=nTempIndex;
  2080. }
  2081. }
  2082. TerrainLeaf._skirtLODIndex=__newvec(nLeafNum);
  2083. for (i=0;i < nLeafNum;i++){
  2084. TerrainLeaf._skirtLODIndex[i]=new Array(TerrainLeaf._maxLODLevel+1);
  2085. }
  2086. for (i=0,n=TerrainLeaf._maxLODLevel+1;i < n;i++){
  2087. TerrainLeaf._skirtLODIndex[0][i]=TerrainLeaf.calcSkirtLODIndex(i);
  2088. }
  2089. for (i=1;i < nLeafNum;i++){
  2090. nOffset=i *TerrainLeaf.LEAF_SKIRT_VERTEXT_COUNT;
  2091. for (j=0,n1=TerrainLeaf._maxLODLevel+1;j < n1;j++){
  2092. nOriginIndexArray=TerrainLeaf._skirtLODIndex[0][j];
  2093. nTempIndex=new Uint16Array(nOriginIndexArray.length);
  2094. for (k=0;k < nOriginIndexArray.length;k++){
  2095. nTempIndex[k]=nOriginIndexArray[k]+nOffset;
  2096. }
  2097. TerrainLeaf._skirtLODIndex[i][j]=nTempIndex;
  2098. }
  2099. }
  2100. TerrainLeaf._bInit=true;
  2101. }
  2102. }
  2103. TerrainLeaf.getPlaneLODIndex=function(leafIndex,LODLevel){
  2104. return TerrainLeaf._planeLODIndex[leafIndex][LODLevel];
  2105. }
  2106. TerrainLeaf.getSkirtLODIndex=function(leafIndex,LODLevel){
  2107. return TerrainLeaf._skirtLODIndex[leafIndex][LODLevel];
  2108. }
  2109. TerrainLeaf.calcPlaneLODIndex=function(level){
  2110. if (level > TerrainLeaf._maxLODLevel)level=TerrainLeaf._maxLODLevel;
  2111. var nGridNumAddOne=TerrainLeaf.LEAF_GRID_NUM+1;
  2112. var nNum=0;
  2113. var indexBuffer=null;
  2114. var nLODGridNum=laya.d3.terrain.TerrainLeaf.LEAF_GRID_NUM / Math.pow(2,level);
  2115. indexBuffer=new Uint16Array(nLODGridNum *nLODGridNum *6);
  2116. var nGridSpace=laya.d3.terrain.TerrainLeaf.LEAF_GRID_NUM / nLODGridNum;
  2117. for (var i=0;i < TerrainLeaf.LEAF_GRID_NUM;i+=nGridSpace){
  2118. for (var j=0;j < TerrainLeaf.LEAF_GRID_NUM;j+=nGridSpace){
  2119. indexBuffer[nNum]=(i+nGridSpace)*nGridNumAddOne+j;
  2120. nNum++;
  2121. indexBuffer[nNum]=i *nGridNumAddOne+j;
  2122. nNum++;
  2123. indexBuffer[nNum]=i *nGridNumAddOne+j+nGridSpace;
  2124. nNum++;
  2125. indexBuffer[nNum]=i *nGridNumAddOne+j+nGridSpace;
  2126. nNum++;
  2127. indexBuffer[nNum]=(i+nGridSpace)*nGridNumAddOne+j+nGridSpace;
  2128. nNum++;
  2129. indexBuffer[nNum]=(i+nGridSpace)*nGridNumAddOne+j;
  2130. nNum++;
  2131. }
  2132. }
  2133. return indexBuffer;
  2134. }
  2135. TerrainLeaf.calcSkirtLODIndex=function(level){
  2136. if (level > TerrainLeaf._maxLODLevel)level=TerrainLeaf._maxLODLevel;
  2137. var nSkirtIndexOffset=(TerrainLeaf.CHUNK_GRID_NUM / TerrainLeaf.LEAF_GRID_NUM)*(TerrainLeaf.CHUNK_GRID_NUM / TerrainLeaf.LEAF_GRID_NUM)*TerrainLeaf.LEAF_PLANE_VERTEXT_COUNT;
  2138. var nGridNumAddOne=TerrainLeaf.LEAF_GRID_NUM+1;
  2139. var nNum=0;
  2140. var indexBuffer=null;
  2141. var nLODGridNum=laya.d3.terrain.TerrainLeaf.LEAF_GRID_NUM / Math.pow(2,level);
  2142. indexBuffer=new Uint16Array(nLODGridNum *4 *6);
  2143. var nGridSpace=laya.d3.terrain.TerrainLeaf.LEAF_GRID_NUM / nLODGridNum;
  2144. for (var j=0;j < 4;j++){
  2145. for (var i=0;i < TerrainLeaf.LEAF_GRID_NUM;i+=nGridSpace){
  2146. indexBuffer[nNum]=nSkirtIndexOffset+nGridNumAddOne+i;
  2147. nNum++;
  2148. indexBuffer[nNum]=nSkirtIndexOffset+i;
  2149. nNum++;
  2150. indexBuffer[nNum]=nSkirtIndexOffset+i+nGridSpace;
  2151. nNum++;
  2152. indexBuffer[nNum]=nSkirtIndexOffset+i+nGridSpace;
  2153. nNum++;
  2154. indexBuffer[nNum]=nSkirtIndexOffset+nGridNumAddOne+i+nGridSpace;
  2155. nNum++;
  2156. indexBuffer[nNum]=nSkirtIndexOffset+nGridNumAddOne+i;
  2157. nNum++;
  2158. }
  2159. nSkirtIndexOffset+=nGridNumAddOne *2;
  2160. }
  2161. return indexBuffer;
  2162. }
  2163. TerrainLeaf.getHeightFromTerrainHeightData=function(x,z,terrainHeightData,heighDataWidth,heightDataHeight){
  2164. x=x < 0 ? 0 :x;
  2165. x=(x >=heighDataWidth)? heighDataWidth-1 :x;
  2166. z=z < 0 ? 0 :z;
  2167. z=(z >=heightDataHeight)? heightDataHeight-1 :z;
  2168. return terrainHeightData[z *heighDataWidth+x];
  2169. }
  2170. TerrainLeaf.CHUNK_GRID_NUM=64;
  2171. TerrainLeaf.LEAF_GRID_NUM=32;
  2172. TerrainLeaf.__ADAPT_MATRIX__=null;
  2173. TerrainLeaf.__ADAPT_MATRIX_INV__=null;
  2174. TerrainLeaf._planeLODIndex=null;
  2175. TerrainLeaf._skirtLODIndex=null;
  2176. TerrainLeaf._bInit=false;
  2177. __static(TerrainLeaf,
  2178. ['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);}
  2179. ]);
  2180. return TerrainLeaf;
  2181. })()
  2182. /**
  2183. *<code>Matrix4x4</code> 类用于创建4x4矩阵。
  2184. */
  2185. //class laya.d3.math.Matrix4x4
  2186. var Matrix4x4=(function(){
  2187. function Matrix4x4(m11,m12,m13,m14,m21,m22,m23,m24,m31,m32,m33,m34,m41,m42,m43,m44,elements){
  2188. /**矩阵元素数组*/
  2189. //this.elements=null;
  2190. (m11===void 0)&& (m11=1);
  2191. (m12===void 0)&& (m12=0);
  2192. (m13===void 0)&& (m13=0);
  2193. (m14===void 0)&& (m14=0);
  2194. (m21===void 0)&& (m21=0);
  2195. (m22===void 0)&& (m22=1);
  2196. (m23===void 0)&& (m23=0);
  2197. (m24===void 0)&& (m24=0);
  2198. (m31===void 0)&& (m31=0);
  2199. (m32===void 0)&& (m32=0);
  2200. (m33===void 0)&& (m33=1);
  2201. (m34===void 0)&& (m34=0);
  2202. (m41===void 0)&& (m41=0);
  2203. (m42===void 0)&& (m42=0);
  2204. (m43===void 0)&& (m43=0);
  2205. (m44===void 0)&& (m44=1);
  2206. var e=elements ? this.elements=elements :this.elements=new Float32Array(16);
  2207. e[0]=m11;
  2208. e[1]=m12;
  2209. e[2]=m13;
  2210. e[3]=m14;
  2211. e[4]=m21;
  2212. e[5]=m22;
  2213. e[6]=m23;
  2214. e[7]=m24;
  2215. e[8]=m31;
  2216. e[9]=m32;
  2217. e[10]=m33;
  2218. e[11]=m34;
  2219. e[12]=m41;
  2220. e[13]=m42;
  2221. e[14]=m43;
  2222. e[15]=m44;
  2223. }
  2224. __class(Matrix4x4,'laya.d3.math.Matrix4x4');
  2225. var __proto=Matrix4x4.prototype;
  2226. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  2227. __proto.setRotation=function(rotation){
  2228. var rotationX=rotation.x;
  2229. var rotationY=rotation.y;
  2230. var rotationZ=rotation.z;
  2231. var rotationW=rotation.w;
  2232. var xx=rotationX *rotationX;
  2233. var yy=rotationY *rotationY;
  2234. var zz=rotationZ *rotationZ;
  2235. var xy=rotationX *rotationY;
  2236. var zw=rotationZ *rotationW;
  2237. var zx=rotationZ *rotationX;
  2238. var yw=rotationY *rotationW;
  2239. var yz=rotationY *rotationZ;
  2240. var xw=rotationX *rotationW;
  2241. var e=this.elements;
  2242. e[0]=1.0-(2.0 *(yy+zz));
  2243. e[1]=2.0 *(xy+zw);
  2244. e[2]=2.0 *(zx-yw);
  2245. e[4]=2.0 *(xy-zw);
  2246. e[5]=1.0-(2.0 *(zz+xx));
  2247. e[6]=2.0 *(yz+xw);
  2248. e[8]=2.0 *(zx+yw);
  2249. e[9]=2.0 *(yz-xw);
  2250. e[10]=1.0-(2.0 *(yy+xx));
  2251. }
  2252. __proto.setPosition=function(position){
  2253. var e=this.elements;
  2254. e[12]=position.x;
  2255. e[13]=position.y;
  2256. e[14]=position.z;
  2257. }
  2258. __proto.getElementByRowColumn=function(row,column){
  2259. if (row < 0 || row > 3)
  2260. throw new Error("row","Rows and columns for matrices run from 0 to 3, inclusive.");
  2261. if (column < 0 || column > 3)
  2262. throw new Error("column","Rows and columns for matrices run from 0 to 3, inclusive.");
  2263. return this.elements[(row *4)+column];
  2264. }
  2265. __proto.setElementByRowColumn=function(row,column,value){
  2266. if (row < 0 || row > 3)
  2267. throw new Error("row","Rows and columns for matrices run from 0 to 3, inclusive.");
  2268. if (column < 0 || column > 3)
  2269. throw new Error("column","Rows and columns for matrices run from 0 to 3, inclusive.");
  2270. this.elements[(row *4)+column]=value;
  2271. }
  2272. /**
  2273. *判断两个4x4矩阵的值是否相等。
  2274. *@param other 4x4矩阵
  2275. */
  2276. __proto.equalsOtherMatrix=function(other){
  2277. var e=this.elements;
  2278. var oe=other.elements;
  2279. 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]));
  2280. }
  2281. /**
  2282. *分解矩阵为平移向量、旋转四元数、缩放向量。
  2283. *@param translation 平移向量。
  2284. *@param rotation 旋转四元数。
  2285. *@param scale 缩放向量。
  2286. *@return 是否分解成功。
  2287. */
  2288. __proto.decomposeTransRotScale=function(translation,rotation,scale){
  2289. var rotationMatrix=Matrix4x4._tempMatrix4x4;
  2290. if (this.decomposeTransRotMatScale(translation,rotationMatrix,scale)){
  2291. Quaternion.createFromMatrix4x4(rotationMatrix,rotation);
  2292. return true;
  2293. }else {
  2294. rotation.identity();
  2295. return false;
  2296. }
  2297. }
  2298. /**
  2299. *分解矩阵为平移向量、旋转矩阵、缩放向量。
  2300. *@param translation 平移向量。
  2301. *@param rotationMatrix 旋转矩阵。
  2302. *@param scale 缩放向量。
  2303. *@return 是否分解成功。
  2304. */
  2305. __proto.decomposeTransRotMatScale=function(translation,rotationMatrix,scale){
  2306. var e=this.elements;
  2307. var te=translation;
  2308. var re=rotationMatrix.elements;
  2309. var se=scale;
  2310. te.x=e[12];
  2311. te.y=e[13];
  2312. te.z=e[14];
  2313. var m11=e[0],m12=e[1],m13=e[2];
  2314. var m21=e[4],m22=e[5],m23=e[6];
  2315. var m31=e[8],m32=e[9],m33=e[10];
  2316. var sX=se.x=Math.sqrt((m11 *m11)+(m12 *m12)+(m13 *m13));
  2317. var sY=se.y=Math.sqrt((m21 *m21)+(m22 *m22)+(m23 *m23));
  2318. var sZ=se.z=Math.sqrt((m31 *m31)+(m32 *m32)+(m33 *m33));
  2319. if (MathUtils3D.isZero(sX)|| MathUtils3D.isZero(sY)|| MathUtils3D.isZero(sZ)){
  2320. 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;
  2321. re[0]=re[5]=re[10]=re[15]=1;
  2322. return false;
  2323. };
  2324. var at=Matrix4x4._tempVector0;
  2325. at.x=m31 / sZ;
  2326. at.y=m32 / sZ;
  2327. at.z=m33 / sZ;
  2328. var tempRight=Matrix4x4._tempVector1;
  2329. tempRight.x=m11 / sX;
  2330. tempRight.y=m12 / sX;
  2331. tempRight.z=m13 / sX;
  2332. var up=Matrix4x4._tempVector2;
  2333. Vector3.cross(at,tempRight,up);
  2334. var right=Matrix4x4._tempVector1;
  2335. Vector3.cross(up,at,right);
  2336. re[3]=re[7]=re[11]=re[12]=re[13]=re[14]=0;
  2337. re[15]=1;
  2338. re[0]=right.x;
  2339. re[1]=right.y;
  2340. re[2]=right.z;
  2341. re[4]=up.x;
  2342. re[5]=up.y;
  2343. re[6]=up.z;
  2344. re[8]=at.x;
  2345. re[9]=at.y;
  2346. re[10]=at.z;
  2347. ((re[0] *m11+re[1] *m12+re[2] *m13)< 0.0)&& (se[0]=-sX);
  2348. ((re[4] *m21+re[5] *m22+re[6] *m23)< 0.0)&& (se[1]=-sY);
  2349. ((re[8] *m31+re[9] *m32+re[10] *m33)< 0.0)&& (se[2]=-sZ);
  2350. return true;
  2351. }
  2352. /**
  2353. *分解旋转矩阵的旋转为YawPitchRoll欧拉角。
  2354. *@param out float yaw
  2355. *@param out float pitch
  2356. *@param out float roll
  2357. *@return
  2358. */
  2359. __proto.decomposeYawPitchRoll=function(yawPitchRoll){
  2360. var pitch=Math.asin(-this.elements[9]);
  2361. yawPitchRoll.y=pitch;
  2362. var test=Math.cos(pitch);
  2363. if (test > MathUtils3D.zeroTolerance){
  2364. yawPitchRoll.z=Math.atan2(this.elements[1],this.elements[5]);
  2365. yawPitchRoll.x=Math.atan2(this.elements[8],this.elements[10]);
  2366. }else {
  2367. yawPitchRoll.z=Math.atan2(-this.elements[4],this.elements[0]);
  2368. yawPitchRoll.x=0.0;
  2369. }
  2370. }
  2371. /**归一化矩阵 */
  2372. __proto.normalize=function(){
  2373. var v=this.elements;
  2374. var c=v[0],d=v[1],e=v[2],g=Math.sqrt(c *c+d *d+e *e);
  2375. if (g){
  2376. if (g==1)
  2377. return;
  2378. }else {
  2379. v[0]=0;
  2380. v[1]=0;
  2381. v[2]=0;
  2382. return;
  2383. }
  2384. g=1 / g;
  2385. v[0]=c *g;
  2386. v[1]=d *g;
  2387. v[2]=e *g;
  2388. }
  2389. /**计算矩阵的转置矩阵*/
  2390. __proto.transpose=function(){
  2391. var e,t;
  2392. e=this.elements;
  2393. t=e[1];
  2394. e[1]=e[4];
  2395. e[4]=t;
  2396. t=e[2];
  2397. e[2]=e[8];
  2398. e[8]=t;
  2399. t=e[3];
  2400. e[3]=e[12];
  2401. e[12]=t;
  2402. t=e[6];
  2403. e[6]=e[9];
  2404. e[9]=t;
  2405. t=e[7];
  2406. e[7]=e[13];
  2407. e[13]=t;
  2408. t=e[11];
  2409. e[11]=e[14];
  2410. e[14]=t;
  2411. return this;
  2412. }
  2413. /**
  2414. *计算一个矩阵的逆矩阵
  2415. *@param out 输出矩阵
  2416. */
  2417. __proto.invert=function(out){
  2418. var ae=this.elements;
  2419. var oe=out.elements;
  2420. 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],
  2421. 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,
  2422. det=b00 *b11-b01 *b10+b02 *b09+b03 *b08-b04 *b07+b05 *b06;
  2423. if (Math.abs(det)===0.0){
  2424. return;
  2425. }
  2426. det=1.0 / det;
  2427. oe[0]=(a11 *b11-a12 *b10+a13 *b09)*det;
  2428. oe[1]=(a02 *b10-a01 *b11-a03 *b09)*det;
  2429. oe[2]=(a31 *b05-a32 *b04+a33 *b03)*det;
  2430. oe[3]=(a22 *b04-a21 *b05-a23 *b03)*det;
  2431. oe[4]=(a12 *b08-a10 *b11-a13 *b07)*det;
  2432. oe[5]=(a00 *b11-a02 *b08+a03 *b07)*det;
  2433. oe[6]=(a32 *b02-a30 *b05-a33 *b01)*det;
  2434. oe[7]=(a20 *b05-a22 *b02+a23 *b01)*det;
  2435. oe[8]=(a10 *b10-a11 *b08+a13 *b06)*det;
  2436. oe[9]=(a01 *b08-a00 *b10-a03 *b06)*det;
  2437. oe[10]=(a30 *b04-a31 *b02+a33 *b00)*det;
  2438. oe[11]=(a21 *b02-a20 *b04-a23 *b00)*det;
  2439. oe[12]=(a11 *b07-a10 *b09-a12 *b06)*det;
  2440. oe[13]=(a00 *b09-a01 *b07+a02 *b06)*det;
  2441. oe[14]=(a31 *b01-a30 *b03-a32 *b00)*det;
  2442. oe[15]=(a20 *b03-a21 *b01+a22 *b00)*det;
  2443. }
  2444. /**设置矩阵为单位矩阵*/
  2445. __proto.identity=function(){
  2446. var e=this.elements;
  2447. 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;
  2448. e[0]=e[5]=e[10]=e[15]=1;
  2449. }
  2450. /**
  2451. *克隆。
  2452. *@param destObject 克隆源。
  2453. */
  2454. __proto.cloneTo=function(destObject){
  2455. var i,s,d;
  2456. s=this.elements;
  2457. d=destObject.elements;
  2458. if (s===d){
  2459. return;
  2460. }
  2461. for (i=0;i < 16;++i){
  2462. d[i]=s[i];
  2463. }
  2464. }
  2465. /**
  2466. *克隆。
  2467. *@return 克隆副本。
  2468. */
  2469. __proto.clone=function(){
  2470. var dest=/*__JS__ */new this.constructor();
  2471. this.cloneTo(dest);
  2472. return dest;
  2473. }
  2474. /**
  2475. *获取平移向量。
  2476. *@param out 平移向量。
  2477. */
  2478. __proto.getTranslationVector=function(out){
  2479. var me=this.elements;
  2480. out.x=me[12];
  2481. out.y=me[13];
  2482. out.z=me[14];
  2483. }
  2484. /**
  2485. *设置平移向量。
  2486. *@param translate 平移向量。
  2487. */
  2488. __proto.setTranslationVector=function(translate){
  2489. var me=this.elements;
  2490. var ve=translate;
  2491. me[12]=ve.x;
  2492. me[13]=ve.y;
  2493. me[14]=ve.z;
  2494. }
  2495. /**
  2496. *获取前向量。
  2497. *@param out 前向量。
  2498. */
  2499. __proto.getForward=function(out){
  2500. var me=this.elements;
  2501. out.x=-me[8];
  2502. out.y=-me[9];
  2503. out.z=-me[10];
  2504. }
  2505. /**
  2506. *设置前向量。
  2507. *@param forward 前向量。
  2508. */
  2509. __proto.setForward=function(forward){
  2510. var me=this.elements;
  2511. me[8]=-forward.x;
  2512. me[9]=-forward.y;
  2513. me[10]=-forward.z;
  2514. }
  2515. Matrix4x4.createRotationX=function(rad,out){
  2516. var oe=out.elements;
  2517. var s=Math.sin(rad),c=Math.cos(rad);
  2518. oe[1]=oe[2]=oe[3]=oe[4]=oe[7]=oe[8]=oe[11]=oe[12]=oe[13]=oe[14]=0;
  2519. oe[0]=oe[15]=1;
  2520. oe[5]=oe[10]=c;
  2521. oe[6]=s;
  2522. oe[9]=-s;
  2523. }
  2524. Matrix4x4.createRotationY=function(rad,out){
  2525. var oe=out.elements;
  2526. var s=Math.sin(rad),c=Math.cos(rad);
  2527. oe[1]=oe[3]=oe[4]=oe[6]=oe[7]=oe[9]=oe[11]=oe[12]=oe[13]=oe[14]=0;
  2528. oe[5]=oe[15]=1;
  2529. oe[0]=oe[10]=c;
  2530. oe[2]=-s;
  2531. oe[8]=s;
  2532. }
  2533. Matrix4x4.createRotationZ=function(rad,out){
  2534. var oe=out.elements;
  2535. var s=Math.sin(rad),c=Math.cos(rad);
  2536. oe[2]=oe[3]=oe[6]=oe[7]=oe[8]=oe[9]=oe[11]=oe[12]=oe[13]=oe[14]=0;
  2537. oe[10]=oe[15]=1;
  2538. oe[0]=oe[5]=c;
  2539. oe[1]=s;
  2540. oe[4]=-s;
  2541. }
  2542. Matrix4x4.createRotationYawPitchRoll=function(yaw,pitch,roll,result){
  2543. Quaternion.createFromYawPitchRoll(yaw,pitch,roll,Matrix4x4._tempQuaternion);
  2544. Matrix4x4.createRotationQuaternion(Matrix4x4._tempQuaternion,result);
  2545. }
  2546. Matrix4x4.createRotationAxis=function(axis,angle,result){
  2547. var x=axis.x;
  2548. var y=axis.y;
  2549. var z=axis.z;
  2550. var cos=Math.cos(angle);
  2551. var sin=Math.sin(angle);
  2552. var xx=x *x;
  2553. var yy=y *y;
  2554. var zz=z *z;
  2555. var xy=x *y;
  2556. var xz=x *z;
  2557. var yz=y *z;
  2558. var resultE=result.elements;
  2559. resultE[3]=resultE[7]=resultE[11]=resultE[12]=resultE[13]=resultE[14]=0;
  2560. resultE[15]=1.0;
  2561. resultE[0]=xx+(cos *(1.0-xx));
  2562. resultE[1]=(xy-(cos *xy))+(sin *z);
  2563. resultE[2]=(xz-(cos *xz))-(sin *y);
  2564. resultE[4]=(xy-(cos *xy))-(sin *z);
  2565. resultE[5]=yy+(cos *(1.0-yy));
  2566. resultE[6]=(yz-(cos *yz))+(sin *x);
  2567. resultE[8]=(xz-(cos *xz))+(sin *y);
  2568. resultE[9]=(yz-(cos *yz))-(sin *x);
  2569. resultE[10]=zz+(cos *(1.0-zz));
  2570. }
  2571. Matrix4x4.createRotationQuaternion=function(rotation,result){
  2572. var resultE=result.elements;
  2573. var rotationX=rotation.x;
  2574. var rotationY=rotation.y;
  2575. var rotationZ=rotation.z;
  2576. var rotationW=rotation.w;
  2577. var xx=rotationX *rotationX;
  2578. var yy=rotationY *rotationY;
  2579. var zz=rotationZ *rotationZ;
  2580. var xy=rotationX *rotationY;
  2581. var zw=rotationZ *rotationW;
  2582. var zx=rotationZ *rotationX;
  2583. var yw=rotationY *rotationW;
  2584. var yz=rotationY *rotationZ;
  2585. var xw=rotationX *rotationW;
  2586. resultE[3]=resultE[7]=resultE[11]=resultE[12]=resultE[13]=resultE[14]=0;
  2587. resultE[15]=1.0;
  2588. resultE[0]=1.0-(2.0 *(yy+zz));
  2589. resultE[1]=2.0 *(xy+zw);
  2590. resultE[2]=2.0 *(zx-yw);
  2591. resultE[4]=2.0 *(xy-zw);
  2592. resultE[5]=1.0-(2.0 *(zz+xx));
  2593. resultE[6]=2.0 *(yz+xw);
  2594. resultE[8]=2.0 *(zx+yw);
  2595. resultE[9]=2.0 *(yz-xw);
  2596. resultE[10]=1.0-(2.0 *(yy+xx));
  2597. }
  2598. Matrix4x4.createTranslate=function(trans,out){
  2599. var oe=out.elements;
  2600. oe[4]=oe[8]=oe[1]=oe[9]=oe[2]=oe[6]=oe[3]=oe[7]=oe[11]=0;
  2601. oe[0]=oe[5]=oe[10]=oe[15]=1;
  2602. oe[12]=trans.x;
  2603. oe[13]=trans.y;
  2604. oe[14]=trans.z;
  2605. }
  2606. Matrix4x4.createScaling=function(scale,out){
  2607. var oe=out.elements;
  2608. oe[0]=scale.x;
  2609. oe[5]=scale.y;
  2610. oe[10]=scale.z;
  2611. 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;
  2612. oe[15]=1;
  2613. }
  2614. Matrix4x4.multiply=function(left,right,out){
  2615. var i,e,a,b,ai0,ai1,ai2,ai3;
  2616. e=out.elements;
  2617. a=left.elements;
  2618. b=right.elements;
  2619. if (e===b){
  2620. b=new Float32Array(16);
  2621. for (i=0;i < 16;++i){
  2622. b[i]=e[i];
  2623. }
  2624. };
  2625. var b0=b[0],b1=b[1],b2=b[2],b3=b[3];
  2626. var b4=b[4],b5=b[5],b6=b[6],b7=b[7];
  2627. var b8=b[8],b9=b[9],b10=b[10],b11=b[11];
  2628. var b12=b[12],b13=b[13],b14=b[14],b15=b[15];
  2629. for (i=0;i < 4;i++){
  2630. ai0=a[i];
  2631. ai1=a[i+4];
  2632. ai2=a[i+8];
  2633. ai3=a[i+12];
  2634. e[i]=ai0 *b0+ai1 *b1+ai2 *b2+ai3 *b3;
  2635. e[i+4]=ai0 *b4+ai1 *b5+ai2 *b6+ai3 *b7;
  2636. e[i+8]=ai0 *b8+ai1 *b9+ai2 *b10+ai3 *b11;
  2637. e[i+12]=ai0 *b12+ai1 *b13+ai2 *b14+ai3 *b15;
  2638. }
  2639. }
  2640. Matrix4x4.multiplyForNative=function(left,right,out){
  2641. LayaGL.instance.matrix4x4Multiply(left.elements,right.elements,out.elements);
  2642. }
  2643. Matrix4x4.createFromQuaternion=function(rotation,out){
  2644. var e=out.elements;
  2645. var x=rotation.x,y=rotation.y,z=rotation.z,w=rotation.w;
  2646. var x2=x+x;
  2647. var y2=y+y;
  2648. var z2=z+z;
  2649. var xx=x *x2;
  2650. var yx=y *x2;
  2651. var yy=y *y2;
  2652. var zx=z *x2;
  2653. var zy=z *y2;
  2654. var zz=z *z2;
  2655. var wx=w *x2;
  2656. var wy=w *y2;
  2657. var wz=w *z2;
  2658. e[0]=1-yy-zz;
  2659. e[1]=yx+wz;
  2660. e[2]=zx-wy;
  2661. e[3]=0;
  2662. e[4]=yx-wz;
  2663. e[5]=1-xx-zz;
  2664. e[6]=zy+wx;
  2665. e[7]=0;
  2666. e[8]=zx+wy;
  2667. e[9]=zy-wx;
  2668. e[10]=1-xx-yy;
  2669. e[11]=0;
  2670. e[12]=0;
  2671. e[13]=0;
  2672. e[14]=0;
  2673. e[15]=1;
  2674. }
  2675. Matrix4x4.createAffineTransformation=function(trans,rot,scale,out){
  2676. var oe=out.elements;
  2677. var x=rot.x,y=rot.y,z=rot.z,w=rot.w,x2=x+x,y2=y+y,z2=z+z;
  2678. var xx=x *x2,xy=x *y2,xz=x *z2,yy=y *y2,yz=y *z2,zz=z *z2;
  2679. var wx=w *x2,wy=w *y2,wz=w *z2,sx=scale.x,sy=scale.y,sz=scale.z;
  2680. oe[0]=(1-(yy+zz))*sx;
  2681. oe[1]=(xy+wz)*sx;
  2682. oe[2]=(xz-wy)*sx;
  2683. oe[3]=0;
  2684. oe[4]=(xy-wz)*sy;
  2685. oe[5]=(1-(xx+zz))*sy;
  2686. oe[6]=(yz+wx)*sy;
  2687. oe[7]=0;
  2688. oe[8]=(xz+wy)*sz;
  2689. oe[9]=(yz-wx)*sz;
  2690. oe[10]=(1-(xx+yy))*sz;
  2691. oe[11]=0;
  2692. oe[12]=trans.x;
  2693. oe[13]=trans.y;
  2694. oe[14]=trans.z;
  2695. oe[15]=1;
  2696. }
  2697. Matrix4x4.createLookAt=function(eye,target,up,out){
  2698. var oE=out.elements;
  2699. var xaxis=Matrix4x4._tempVector0;
  2700. var yaxis=Matrix4x4._tempVector1;
  2701. var zaxis=Matrix4x4._tempVector2;
  2702. Vector3.subtract(eye,target,zaxis);
  2703. Vector3.normalize(zaxis,zaxis);
  2704. Vector3.cross(up,zaxis,xaxis);
  2705. Vector3.normalize(xaxis,xaxis);
  2706. Vector3.cross(zaxis,xaxis,yaxis);
  2707. out.identity();
  2708. oE[0]=xaxis.x;
  2709. oE[4]=xaxis.y;
  2710. oE[8]=xaxis.z;
  2711. oE[1]=yaxis.x;
  2712. oE[5]=yaxis.y;
  2713. oE[9]=yaxis.z;
  2714. oE[2]=zaxis.x;
  2715. oE[6]=zaxis.y;
  2716. oE[10]=zaxis.z;
  2717. oE[12]=-Vector3.dot(xaxis,eye);
  2718. oE[13]=-Vector3.dot(yaxis,eye);
  2719. oE[14]=-Vector3.dot(zaxis,eye);
  2720. }
  2721. Matrix4x4.createPerspective=function(fov,aspect,znear,zfar,out){
  2722. var yScale=1.0 / Math.tan(fov *0.5);
  2723. var xScale=yScale / aspect;
  2724. var halfWidth=znear / xScale;
  2725. var halfHeight=znear / yScale;
  2726. Matrix4x4.createPerspectiveOffCenter(-halfWidth,halfWidth,-halfHeight,halfHeight,znear,zfar,out);
  2727. }
  2728. Matrix4x4.createPerspectiveOffCenter=function(left,right,bottom,top,znear,zfar,out){
  2729. var oe=out.elements;
  2730. var zRange=zfar / (zfar-znear);
  2731. oe[1]=oe[2]=oe[3]=oe[4]=oe[6]=oe[7]=oe[12]=oe[13]=oe[15]=0;
  2732. oe[0]=2.0 *znear / (right-left);
  2733. oe[5]=2.0 *znear / (top-bottom);
  2734. oe[8]=(left+right)/ (right-left);
  2735. oe[9]=(top+bottom)/ (top-bottom);
  2736. oe[10]=-zRange;
  2737. oe[11]=-1.0;
  2738. oe[14]=-znear *zRange;
  2739. }
  2740. Matrix4x4.createOrthoOffCenter=function(left,right,bottom,top,znear,zfar,out){
  2741. var oe=out.elements;
  2742. var zRange=1.0 / (zfar-znear);
  2743. oe[1]=oe[2]=oe[3]=oe[4]=oe[6]=oe[8]=oe[7]=oe[9]=oe[11]=0;
  2744. oe[15]=1;
  2745. oe[0]=2.0 / (right-left);
  2746. oe[5]=2.0 / (top-bottom);
  2747. oe[10]=-zRange;
  2748. oe[12]=(left+right)/ (left-right);
  2749. oe[13]=(top+bottom)/ (bottom-top);
  2750. oe[14]=-znear *zRange;
  2751. }
  2752. Matrix4x4.billboard=function(objectPosition,cameraPosition,cameraRight,cameraUp,cameraForward,mat){
  2753. Vector3.subtract(objectPosition,cameraPosition,Matrix4x4._tempVector0);
  2754. var lengthSq=Vector3.scalarLengthSquared(Matrix4x4._tempVector0);
  2755. if (MathUtils3D.isZero(lengthSq)){
  2756. Vector3.scale(cameraForward,-1,Matrix4x4._tempVector1);
  2757. Matrix4x4._tempVector1.cloneTo(Matrix4x4._tempVector0);
  2758. }else {
  2759. Vector3.scale(Matrix4x4._tempVector0,1 / Math.sqrt(lengthSq),Matrix4x4._tempVector0);
  2760. }
  2761. Vector3.cross(cameraUp,Matrix4x4._tempVector0,Matrix4x4._tempVector2);
  2762. Vector3.normalize(Matrix4x4._tempVector2,Matrix4x4._tempVector2);
  2763. Vector3.cross(Matrix4x4._tempVector0,Matrix4x4._tempVector2,Matrix4x4._tempVector3);
  2764. var crosse=Matrix4x4._tempVector2;
  2765. var finale=Matrix4x4._tempVector3;
  2766. var diffee=Matrix4x4._tempVector0;
  2767. var obpose=objectPosition;
  2768. var mate=mat.elements;
  2769. mate[0]=crosse.x;
  2770. mate[1]=crosse.y;
  2771. mate[2]=crosse.z;
  2772. mate[3]=0.0;
  2773. mate[4]=finale.x;
  2774. mate[5]=finale.y;
  2775. mate[6]=finale.z;
  2776. mate[7]=0.0;
  2777. mate[8]=diffee.x;
  2778. mate[9]=diffee.y;
  2779. mate[10]=diffee.z;
  2780. mate[11]=0.0;
  2781. mate[12]=obpose.x;
  2782. mate[13]=obpose.y;
  2783. mate[14]=obpose.z;
  2784. mate[15]=1.0;
  2785. }
  2786. Matrix4x4.translation=function(v3,out){
  2787. var oe=out.elements;
  2788. oe[0]=oe[5]=oe[10]=oe[15]=1;
  2789. oe[12]=v3.x;
  2790. oe[13]=v3.y;
  2791. oe[14]=v3.z;
  2792. }
  2793. __static(Matrix4x4,
  2794. ['_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);}
  2795. ]);
  2796. return Matrix4x4;
  2797. })()
  2798. /**
  2799. *@private
  2800. *<code>DynamicBatchManager</code> 类用于管理动态批处理。
  2801. */
  2802. //class laya.d3.graphics.DynamicBatchManager
  2803. var DynamicBatchManager=(function(){
  2804. function DynamicBatchManager(){
  2805. /**@private */
  2806. //this._batchRenderElementPool=null;
  2807. /**@private */
  2808. //this._batchRenderElementPoolIndex=0;
  2809. this._batchRenderElementPool=[];
  2810. }
  2811. __class(DynamicBatchManager,'laya.d3.graphics.DynamicBatchManager');
  2812. var __proto=DynamicBatchManager.prototype;
  2813. /**
  2814. *@private
  2815. */
  2816. __proto._clear=function(){
  2817. this._batchRenderElementPoolIndex=0;
  2818. }
  2819. /**
  2820. *@private
  2821. */
  2822. __proto._getBatchRenderElementFromPool=function(){
  2823. throw "StaticBatch:must override this function.";
  2824. }
  2825. /**
  2826. *@private
  2827. */
  2828. __proto.dispose=function(){}
  2829. DynamicBatchManager._registerManager=function(manager){
  2830. DynamicBatchManager._managers.push(manager);
  2831. }
  2832. DynamicBatchManager._managers=[];
  2833. return DynamicBatchManager;
  2834. })()
  2835. /**
  2836. *<code>Collision</code> 类用于创建物理碰撞信息。
  2837. */
  2838. //class laya.d3.physics.Collision
  2839. var Collision=(function(){
  2840. function Collision(){
  2841. /**@private */
  2842. this._lastUpdateFrame=-2147483648;
  2843. /**@private */
  2844. this._updateFrame=-2147483648;
  2845. /**@private */
  2846. this._isTrigger=false;
  2847. /**@private */
  2848. //this._colliderA=null;
  2849. /**@private */
  2850. //this._colliderB=null;
  2851. /**@private [只读]*/
  2852. //this.other=null;
  2853. this.contacts=[];
  2854. }
  2855. __class(Collision,'laya.d3.physics.Collision');
  2856. var __proto=Collision.prototype;
  2857. /**
  2858. *@private
  2859. */
  2860. __proto._setUpdateFrame=function(farme){
  2861. this._lastUpdateFrame=this._updateFrame;
  2862. this._updateFrame=farme;
  2863. }
  2864. return Collision;
  2865. })()
  2866. /**
  2867. *<code>ColliderShape</code> 类用于创建形状碰撞器的父类,该类为抽象类。
  2868. */
  2869. //class laya.d3.physics.shape.ColliderShape
  2870. var ColliderShape=(function(){
  2871. function ColliderShape(){
  2872. /**@private */
  2873. //this._nativeShape=null;
  2874. /**@private */
  2875. //this._type=0;
  2876. /**@private */
  2877. this._attatched=false;
  2878. /**@private */
  2879. this._indexInCompound=-1;
  2880. /**@private */
  2881. this._compoundParent=null;
  2882. /**@private */
  2883. this._attatchedCollisionObject=null;
  2884. /**@private */
  2885. this._referenceCount=0;
  2886. this.needsCustomCollisionCallback=false;
  2887. this._scale=new Vector3(1,1,1);
  2888. this._centerMatrix=new Matrix4x4();
  2889. this._localOffset=new Vector3(0,0,0);
  2890. this._localRotation=new Quaternion(0,0,0,1);
  2891. }
  2892. __class(ColliderShape,'laya.d3.physics.shape.ColliderShape');
  2893. var __proto=ColliderShape.prototype;
  2894. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  2895. /**
  2896. *@private
  2897. */
  2898. __proto._setScale=function(value){
  2899. if (this._compoundParent){
  2900. this.updateLocalTransformations();
  2901. }else {
  2902. ColliderShape._nativeScale.setValue(value.x,value.y,value.z);
  2903. this._nativeShape.setLocalScaling(ColliderShape._nativeScale);
  2904. }
  2905. }
  2906. /**
  2907. *@private
  2908. */
  2909. __proto._addReference=function(){
  2910. this._referenceCount++;
  2911. }
  2912. /**
  2913. *@private
  2914. */
  2915. __proto._removeReference=function(){
  2916. this._referenceCount--;
  2917. }
  2918. /**
  2919. *更新本地偏移,如果修改LocalOffset或LocalRotation需要调用。
  2920. */
  2921. __proto.updateLocalTransformations=function(){
  2922. if (this._compoundParent){
  2923. var offset=ColliderShape._tempVector30;
  2924. Vector3.multiply(this.localOffset,this._scale,offset);
  2925. ColliderShape._createAffineTransformation(offset,this.localRotation,this._centerMatrix.elements);
  2926. }else {
  2927. ColliderShape._createAffineTransformation(this.localOffset,this.localRotation,this._centerMatrix.elements);
  2928. }
  2929. }
  2930. /**
  2931. *克隆。
  2932. *@param destObject 克隆源。
  2933. */
  2934. __proto.cloneTo=function(destObject){
  2935. var destColliderShape=destObject;
  2936. this._localOffset.cloneTo(destColliderShape.localOffset);
  2937. this._localRotation.cloneTo(destColliderShape.localRotation);
  2938. destColliderShape.localOffset=destColliderShape.localOffset;
  2939. destColliderShape.localRotation=destColliderShape.localRotation;
  2940. }
  2941. /**
  2942. *克隆。
  2943. *@return 克隆副本。
  2944. */
  2945. __proto.clone=function(){
  2946. return null;
  2947. }
  2948. /**
  2949. *@private
  2950. */
  2951. __proto.destroy=function(){
  2952. if (this._nativeShape){
  2953. Laya3D._physics3D.destroy(this._nativeShape);
  2954. this._nativeShape=null;
  2955. }
  2956. }
  2957. /**
  2958. *获取碰撞类型。
  2959. *@return 碰撞类型。
  2960. */
  2961. __getset(0,__proto,'type',function(){
  2962. return this._type;
  2963. });
  2964. /**
  2965. *设置Shape的本地偏移。
  2966. *@param Shape的本地偏移。
  2967. */
  2968. /**
  2969. *获取Shape的本地偏移。
  2970. *@return Shape的本地偏移。
  2971. */
  2972. __getset(0,__proto,'localOffset',function(){
  2973. return this._localOffset;
  2974. },function(value){
  2975. this._localOffset=value;
  2976. if (this._compoundParent)
  2977. this._compoundParent._updateChildTransform(this);
  2978. });
  2979. /**
  2980. *设置Shape的本地旋转。
  2981. *@param Shape的本地旋转。
  2982. */
  2983. /**
  2984. *获取Shape的本地旋转。
  2985. *@return Shape的本地旋转。
  2986. */
  2987. __getset(0,__proto,'localRotation',function(){
  2988. return this._localRotation;
  2989. },function(value){
  2990. this._localRotation=value;
  2991. if (this._compoundParent)
  2992. this._compoundParent._updateChildTransform(this);
  2993. });
  2994. ColliderShape._creatShape=function(shapeData){
  2995. var colliderShape;
  2996. switch (shapeData.type){
  2997. case "BoxColliderShape":;
  2998. var sizeData=shapeData.size;
  2999. colliderShape=sizeData ? new BoxColliderShape(sizeData[0],sizeData[1],sizeData[2]):new BoxColliderShape();
  3000. break ;
  3001. case "SphereColliderShape":
  3002. colliderShape=new SphereColliderShape(shapeData.radius);
  3003. break ;
  3004. case "CapsuleColliderShape":
  3005. colliderShape=new CapsuleColliderShape(shapeData.radius,shapeData.height,shapeData.orientation);
  3006. break ;
  3007. case "MeshColliderShape":;
  3008. var meshCollider=new MeshColliderShape();
  3009. shapeData.mesh && (meshCollider.mesh=Loader.getRes(shapeData.mesh));
  3010. colliderShape=meshCollider;
  3011. break ;
  3012. case "ConeColliderShape":
  3013. colliderShape=new ConeColliderShape(shapeData.radius,shapeData.height,shapeData.orientation);
  3014. break ;
  3015. case "CylinderColliderShape":
  3016. colliderShape=new CylinderColliderShape(shapeData.radius,shapeData.height,shapeData.orientation);
  3017. break ;
  3018. default :
  3019. throw "unknown shape type.";
  3020. }
  3021. if (shapeData.center){
  3022. var localOffset=colliderShape.localOffset;
  3023. localOffset.fromArray(shapeData.center);
  3024. colliderShape.localOffset=localOffset;
  3025. }
  3026. return colliderShape;
  3027. }
  3028. ColliderShape._createAffineTransformation=function(trans,rot,outE){
  3029. var x=rot.x,y=rot.y,z=rot.z,w=rot.w,x2=x+x,y2=y+y,z2=z+z;
  3030. var xx=x *x2,xy=x *y2,xz=x *z2,yy=y *y2,yz=y *z2,zz=z *z2;
  3031. var wx=w *x2,wy=w *y2,wz=w *z2;
  3032. outE[0]=(1-(yy+zz));
  3033. outE[1]=(xy+wz);
  3034. outE[2]=(xz-wy);
  3035. outE[3]=0;
  3036. outE[4]=(xy-wz);
  3037. outE[5]=(1-(xx+zz));
  3038. outE[6]=(yz+wx);
  3039. outE[7]=0;
  3040. outE[8]=(xz+wy);
  3041. outE[9]=(yz-wx);
  3042. outE[10]=(1-(xx+yy));
  3043. outE[11]=0;
  3044. outE[12]=trans.x;
  3045. outE[13]=trans.y;
  3046. outE[14]=trans.z;
  3047. outE[15]=1;
  3048. }
  3049. ColliderShape.SHAPEORIENTATION_UPX=0;
  3050. ColliderShape.SHAPEORIENTATION_UPY=1;
  3051. ColliderShape.SHAPEORIENTATION_UPZ=2;
  3052. ColliderShape.SHAPETYPES_BOX=0;
  3053. ColliderShape.SHAPETYPES_SPHERE=1;
  3054. ColliderShape.SHAPETYPES_CYLINDER=2;
  3055. ColliderShape.SHAPETYPES_CAPSULE=3;
  3056. ColliderShape.SHAPETYPES_CONVEXHULL=4;
  3057. ColliderShape.SHAPETYPES_COMPOUND=5;
  3058. ColliderShape.SHAPETYPES_STATICPLANE=6;
  3059. ColliderShape.SHAPETYPES_CONE=7;
  3060. __static(ColliderShape,
  3061. ['_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();}
  3062. ]);
  3063. return ColliderShape;
  3064. })()
  3065. /**
  3066. *<code>GradientDataInt</code> 类用于创建整形渐变。
  3067. */
  3068. //class laya.d3.core.particleShuriKen.module.GradientDataInt
  3069. var GradientDataInt=(function(){
  3070. function GradientDataInt(){
  3071. /**@private */
  3072. this._currentLength=0;
  3073. /**@private 开发者禁止修改。*/
  3074. this._elements=null;
  3075. this._elements=new Float32Array(8);
  3076. }
  3077. __class(GradientDataInt,'laya.d3.core.particleShuriKen.module.GradientDataInt');
  3078. var __proto=GradientDataInt.prototype;
  3079. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  3080. /**
  3081. *增加整形渐变。
  3082. *@param key 生命周期,范围为0到1。
  3083. *@param value 整形值。
  3084. */
  3085. __proto.add=function(key,value){
  3086. if (this._currentLength < 8){
  3087. if ((this._currentLength===6)&& ((key!==1))){
  3088. key=1;
  3089. console.log("Warning:the forth key is be force set to 1.");
  3090. }
  3091. this._elements[this._currentLength++]=key;
  3092. this._elements[this._currentLength++]=value;
  3093. }else {
  3094. console.log("Warning:data count must lessEqual than 4");
  3095. }
  3096. }
  3097. /**
  3098. *克隆。
  3099. *@param destObject 克隆源。
  3100. */
  3101. __proto.cloneTo=function(destObject){
  3102. var destGradientDataInt=destObject;
  3103. destGradientDataInt._currentLength=this._currentLength;
  3104. var destElements=destGradientDataInt._elements;
  3105. destElements.length=this._elements.length;
  3106. for (var i=0,n=this._elements.length;i < n;i++){
  3107. destElements[i]=this._elements[i];
  3108. }
  3109. }
  3110. /**
  3111. *克隆。
  3112. *@return 克隆副本。
  3113. */
  3114. __proto.clone=function(){
  3115. var destGradientDataInt=/*__JS__ */new this.constructor();
  3116. this.cloneTo(destGradientDataInt);
  3117. return destGradientDataInt;
  3118. }
  3119. /**整形渐变数量。*/
  3120. __getset(0,__proto,'gradientCount',function(){
  3121. return this._currentLength / 2;
  3122. });
  3123. return GradientDataInt;
  3124. })()
  3125. /**
  3126. *<code>DetailTextureInfo</code> 类用于描述地形细节纹理。
  3127. */
  3128. //class laya.d3.terrain.unit.DetailTextureInfo
  3129. var DetailTextureInfo=(function(){
  3130. function DetailTextureInfo(){
  3131. this.diffuseTexture=null;
  3132. this.normalTexture=null;
  3133. this.scale=null;
  3134. this.offset=null;
  3135. }
  3136. __class(DetailTextureInfo,'laya.d3.terrain.unit.DetailTextureInfo');
  3137. return DetailTextureInfo;
  3138. })()
  3139. /**
  3140. *<code>HitResult</code> 类用于实现射线检测或形状扫描的结果。
  3141. */
  3142. //class laya.d3.physics.HitResult
  3143. var HitResult=(function(){
  3144. function HitResult(){
  3145. /**是否成功。 */
  3146. this.succeeded=false;
  3147. /**发生碰撞的碰撞组件。*/
  3148. this.collider=null;
  3149. /**碰撞分数。 */
  3150. this.hitFraction=0;
  3151. this.point=new Vector3();
  3152. this.normal=new Vector3();
  3153. }
  3154. __class(HitResult,'laya.d3.physics.HitResult');
  3155. return HitResult;
  3156. })()
  3157. /**
  3158. *<code>ContactPoint</code> 类用于创建物理碰撞信息。
  3159. */
  3160. //class laya.d3.physics.ContactPoint
  3161. var ContactPoint=(function(){
  3162. function ContactPoint(){
  3163. /**@private */
  3164. this._idCounter=0;
  3165. /**@private */
  3166. //this._id=0;
  3167. /**碰撞器A。*/
  3168. this.colliderA=null;
  3169. /**碰撞器B。*/
  3170. this.colliderB=null;
  3171. /**距离。*/
  3172. this.distance=0;
  3173. this.normal=new Vector3();
  3174. this.positionOnA=new Vector3();
  3175. this.positionOnB=new Vector3();
  3176. this._id=++this._idCounter;
  3177. }
  3178. __class(ContactPoint,'laya.d3.physics.ContactPoint');
  3179. return ContactPoint;
  3180. })()
  3181. /**
  3182. *<code>GradientVelocity</code> 类用于创建渐变速度。
  3183. */
  3184. //class laya.d3.core.particleShuriKen.module.GradientVelocity
  3185. var GradientVelocity=(function(){
  3186. function GradientVelocity(){
  3187. /**@private */
  3188. this._type=0;
  3189. /**@private */
  3190. this._constant=null;
  3191. /**@private */
  3192. this._gradientX=null;
  3193. /**@private */
  3194. this._gradientY=null;
  3195. /**@private */
  3196. this._gradientZ=null;
  3197. /**@private */
  3198. this._constantMin=null;
  3199. /**@private */
  3200. this._constantMax=null;
  3201. /**@private */
  3202. this._gradientXMin=null;
  3203. /**@private */
  3204. this._gradientXMax=null;
  3205. /**@private */
  3206. this._gradientYMin=null;
  3207. /**@private */
  3208. this._gradientYMax=null;
  3209. /**@private */
  3210. this._gradientZMin=null;
  3211. /**@private */
  3212. this._gradientZMax=null;
  3213. }
  3214. __class(GradientVelocity,'laya.d3.core.particleShuriKen.module.GradientVelocity');
  3215. var __proto=GradientVelocity.prototype;
  3216. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  3217. /**
  3218. *克隆。
  3219. *@param destObject 克隆源。
  3220. */
  3221. __proto.cloneTo=function(destObject){
  3222. var destGradientVelocity=destObject;
  3223. destGradientVelocity._type=this._type;
  3224. this._constant.cloneTo(destGradientVelocity._constant);
  3225. this._gradientX.cloneTo(destGradientVelocity._gradientX);
  3226. this._gradientY.cloneTo(destGradientVelocity._gradientY);
  3227. this._gradientZ.cloneTo(destGradientVelocity._gradientZ);
  3228. this._constantMin.cloneTo(destGradientVelocity._constantMin);
  3229. this._constantMax.cloneTo(destGradientVelocity._constantMax);
  3230. this._gradientXMin.cloneTo(destGradientVelocity._gradientXMin);
  3231. this._gradientXMax.cloneTo(destGradientVelocity._gradientXMax);
  3232. this._gradientYMin.cloneTo(destGradientVelocity._gradientYMin);
  3233. this._gradientYMax.cloneTo(destGradientVelocity._gradientYMax);
  3234. this._gradientZMin.cloneTo(destGradientVelocity._gradientZMin);
  3235. this._gradientZMax.cloneTo(destGradientVelocity._gradientZMax);
  3236. }
  3237. /**
  3238. *克隆。
  3239. *@return 克隆副本。
  3240. */
  3241. __proto.clone=function(){
  3242. var destGradientVelocity=/*__JS__ */new this.constructor();
  3243. this.cloneTo(destGradientVelocity);
  3244. return destGradientVelocity;
  3245. }
  3246. /**
  3247. *渐变速度Z。
  3248. */
  3249. __getset(0,__proto,'gradientZ',function(){
  3250. return this._gradientZ;
  3251. });
  3252. /**固定速度。*/
  3253. __getset(0,__proto,'constant',function(){
  3254. return this._constant;
  3255. });
  3256. /**
  3257. *生命周期速度类型,0常量模式,1曲线模式,2随机双常量模式,3随机双曲线模式。
  3258. */
  3259. __getset(0,__proto,'type',function(){
  3260. return this._type;
  3261. });
  3262. /**
  3263. *渐变最大速度X。
  3264. */
  3265. __getset(0,__proto,'gradientXMax',function(){
  3266. return this._gradientXMax;
  3267. });
  3268. /**最小固定速度。*/
  3269. __getset(0,__proto,'constantMin',function(){
  3270. return this._constantMin;
  3271. });
  3272. /**
  3273. *渐变速度X。
  3274. */
  3275. __getset(0,__proto,'gradientX',function(){
  3276. return this._gradientX;
  3277. });
  3278. /**
  3279. *渐变速度Y。
  3280. */
  3281. __getset(0,__proto,'gradientY',function(){
  3282. return this._gradientY;
  3283. });
  3284. /**
  3285. *渐变最小速度X。
  3286. */
  3287. __getset(0,__proto,'gradientXMin',function(){
  3288. return this._gradientXMin;
  3289. });
  3290. /**最大固定速度。*/
  3291. __getset(0,__proto,'constantMax',function(){
  3292. return this._constantMax;
  3293. });
  3294. /**
  3295. *渐变最小速度Y。
  3296. */
  3297. __getset(0,__proto,'gradientYMin',function(){
  3298. return this._gradientYMin;
  3299. });
  3300. /**
  3301. *渐变最大速度Y。
  3302. */
  3303. __getset(0,__proto,'gradientYMax',function(){
  3304. return this._gradientYMax;
  3305. });
  3306. /**
  3307. *渐变最小速度Z。
  3308. */
  3309. __getset(0,__proto,'gradientZMin',function(){
  3310. return this._gradientZMin;
  3311. });
  3312. /**
  3313. *渐变最大速度Z。
  3314. */
  3315. __getset(0,__proto,'gradientZMax',function(){
  3316. return this._gradientZMax;
  3317. });
  3318. GradientVelocity.createByConstant=function(constant){
  3319. var gradientVelocity=new GradientVelocity();
  3320. gradientVelocity._type=0;
  3321. gradientVelocity._constant=constant;
  3322. return gradientVelocity;
  3323. }
  3324. GradientVelocity.createByGradient=function(gradientX,gradientY,gradientZ){
  3325. var gradientVelocity=new GradientVelocity();
  3326. gradientVelocity._type=1;
  3327. gradientVelocity._gradientX=gradientX;
  3328. gradientVelocity._gradientY=gradientY;
  3329. gradientVelocity._gradientZ=gradientZ;
  3330. return gradientVelocity;
  3331. }
  3332. GradientVelocity.createByRandomTwoConstant=function(constantMin,constantMax){
  3333. var gradientVelocity=new GradientVelocity();
  3334. gradientVelocity._type=2;
  3335. gradientVelocity._constantMin=constantMin;
  3336. gradientVelocity._constantMax=constantMax;
  3337. return gradientVelocity;
  3338. }
  3339. GradientVelocity.createByRandomTwoGradient=function(gradientXMin,gradientXMax,gradientYMin,gradientYMax,gradientZMin,gradientZMax){
  3340. var gradientVelocity=new GradientVelocity();
  3341. gradientVelocity._type=3;
  3342. gradientVelocity._gradientXMin=gradientXMin;
  3343. gradientVelocity._gradientXMax=gradientXMax;
  3344. gradientVelocity._gradientYMin=gradientYMin;
  3345. gradientVelocity._gradientYMax=gradientYMax;
  3346. gradientVelocity._gradientZMin=gradientZMin;
  3347. gradientVelocity._gradientZMax=gradientZMax;
  3348. return gradientVelocity;
  3349. }
  3350. return GradientVelocity;
  3351. })()
  3352. /**
  3353. *@private
  3354. *<code>GeometryElement</code> 类用于实现几何体元素,该类为抽象类。
  3355. */
  3356. //class laya.d3.core.GeometryElement
  3357. var GeometryElement=(function(){
  3358. function GeometryElement(){
  3359. /**@private */
  3360. //this._destroyed=false;
  3361. this._destroyed=false;
  3362. }
  3363. __class(GeometryElement,'laya.d3.core.GeometryElement');
  3364. var __proto=GeometryElement.prototype;
  3365. Laya.imps(__proto,{"laya.resource.IDestroy":true})
  3366. /**
  3367. *获取几何体类型。
  3368. */
  3369. __proto._getType=function(){
  3370. throw "GeometryElement:must override it.";
  3371. }
  3372. /**
  3373. *@private
  3374. *@return 是否需要渲染。
  3375. */
  3376. __proto._prepareRender=function(state){
  3377. return true;
  3378. }
  3379. /**
  3380. *@private
  3381. */
  3382. __proto._render=function(state){
  3383. throw "GeometryElement:must override it.";
  3384. }
  3385. /**
  3386. *销毁。
  3387. */
  3388. __proto.destroy=function(){
  3389. if (this._destroyed)
  3390. return;
  3391. this._destroyed=true;
  3392. }
  3393. /**
  3394. *获取是否销毁。
  3395. *@return 是否销毁。
  3396. */
  3397. __getset(0,__proto,'destroyed',function(){
  3398. return this._destroyed;
  3399. });
  3400. GeometryElement._typeCounter=0;
  3401. return GeometryElement;
  3402. })()
  3403. /**
  3404. *<code>StaticBatchManager</code> 类用于静态批处理管理的父类。
  3405. */
  3406. //class laya.d3.graphics.StaticBatchManager
  3407. var StaticBatchManager=(function(){
  3408. function StaticBatchManager(){
  3409. /**@private */
  3410. //this._batchRenderElementPool=null;
  3411. /**@private */
  3412. //this._batchRenderElementPoolIndex=0;
  3413. /**@private */
  3414. //this._initBatchSprites=null;
  3415. /**@private */
  3416. //this._staticBatches=null;
  3417. this._initBatchSprites=[];
  3418. this._staticBatches={};
  3419. this._batchRenderElementPoolIndex=0;
  3420. this._batchRenderElementPool=[];
  3421. }
  3422. __class(StaticBatchManager,'laya.d3.graphics.StaticBatchManager');
  3423. var __proto=StaticBatchManager.prototype;
  3424. /**
  3425. *@private
  3426. */
  3427. __proto._partition=function(items,left,right){
  3428. var pivot=items[Math.floor((right+left)/ 2)];
  3429. while (left <=right){
  3430. while (this._compare(items[left],pivot)< 0)
  3431. left++;
  3432. while (this._compare(items[right],pivot)> 0)
  3433. right--;
  3434. if (left < right){
  3435. var temp=items[left];
  3436. items[left]=items[right];
  3437. items[right]=temp;
  3438. left++;
  3439. right--;
  3440. }else if (left===right){
  3441. left++;
  3442. break ;
  3443. }
  3444. }
  3445. return left;
  3446. }
  3447. /**
  3448. *@private
  3449. */
  3450. __proto._quickSort=function(items,left,right){
  3451. if (items.length > 1){
  3452. var index=this._partition(items,left,right);
  3453. var leftIndex=index-1;
  3454. if (left < leftIndex)
  3455. this._quickSort(items,left,leftIndex);
  3456. if (index < right)
  3457. this._quickSort(items,index,right);
  3458. }
  3459. }
  3460. /**
  3461. *@private
  3462. */
  3463. __proto._compare=function(left,right){
  3464. throw "StaticBatch:must override this function.";
  3465. }
  3466. /**
  3467. *@private
  3468. */
  3469. __proto._initStaticBatchs=function(rootSprite){
  3470. throw "StaticBatch:must override this function.";
  3471. }
  3472. /**
  3473. *@private
  3474. */
  3475. __proto._getBatchRenderElementFromPool=function(){
  3476. throw "StaticBatch:must override this function.";
  3477. }
  3478. /**
  3479. *@private
  3480. */
  3481. __proto._addBatchSprite=function(renderableSprite3D){
  3482. this._initBatchSprites.push(renderableSprite3D);
  3483. }
  3484. /**
  3485. *@private
  3486. */
  3487. __proto._clear=function(){
  3488. this._batchRenderElementPoolIndex=0;
  3489. }
  3490. /**
  3491. *@private
  3492. */
  3493. __proto._garbageCollection=function(){
  3494. throw "StaticBatchManager: must override it.";
  3495. }
  3496. /**
  3497. *@private
  3498. */
  3499. __proto.dispose=function(){
  3500. this._staticBatches=null;
  3501. }
  3502. StaticBatchManager._registerManager=function(manager){
  3503. StaticBatchManager._managers.push(manager);
  3504. }
  3505. StaticBatchManager._addToStaticBatchQueue=function(sprite3D,renderableSprite3D){
  3506. if ((sprite3D instanceof laya.d3.core.RenderableSprite3D )&& sprite3D.isStatic)
  3507. renderableSprite3D.push(sprite3D);
  3508. for (var i=0,n=sprite3D.numChildren;i < n;i++)
  3509. StaticBatchManager._addToStaticBatchQueue(sprite3D._children [i],renderableSprite3D);
  3510. }
  3511. StaticBatchManager.combine=function(staticBatchRoot,renderableSprite3Ds){
  3512. if (!renderableSprite3Ds){
  3513. renderableSprite3Ds=[];
  3514. if (staticBatchRoot)
  3515. StaticBatchManager._addToStaticBatchQueue(staticBatchRoot,renderableSprite3Ds);
  3516. };
  3517. var batchSpritesCount=renderableSprite3Ds.length;
  3518. if (batchSpritesCount > 0){
  3519. for (var i=0;i < batchSpritesCount;i++){
  3520. var renderableSprite3D=renderableSprite3Ds[i];
  3521. (renderableSprite3D.isStatic)&& (renderableSprite3D._addToInitStaticBatchManager());
  3522. }
  3523. for (var k=0,m=StaticBatchManager._managers.length;k < m;k++){
  3524. var manager=StaticBatchManager._managers[k];
  3525. manager._initStaticBatchs(staticBatchRoot);
  3526. }
  3527. }
  3528. }
  3529. StaticBatchManager._managers=[];
  3530. return StaticBatchManager;
  3531. })()
  3532. /**
  3533. *@private
  3534. */
  3535. //class laya.d3.animation.AnimationClipParser04
  3536. var AnimationClipParser04=(function(){
  3537. function AnimationClipParser04(){}
  3538. __class(AnimationClipParser04,'laya.d3.animation.AnimationClipParser04');
  3539. AnimationClipParser04.READ_DATA=function(){
  3540. AnimationClipParser04._DATA.offset=AnimationClipParser04._reader.getUint32();
  3541. AnimationClipParser04._DATA.size=AnimationClipParser04._reader.getUint32();
  3542. }
  3543. AnimationClipParser04.READ_BLOCK=function(){
  3544. var count=AnimationClipParser04._BLOCK.count=AnimationClipParser04._reader.getUint16();
  3545. var blockStarts=AnimationClipParser04._BLOCK.blockStarts=[];
  3546. var blockLengths=AnimationClipParser04._BLOCK.blockLengths=[];
  3547. for (var i=0;i < count;i++){
  3548. blockStarts.push(AnimationClipParser04._reader.getUint32());
  3549. blockLengths.push(AnimationClipParser04._reader.getUint32());
  3550. }
  3551. }
  3552. AnimationClipParser04.READ_STRINGS=function(){
  3553. var offset=AnimationClipParser04._reader.getUint32();
  3554. var count=AnimationClipParser04._reader.getUint16();
  3555. var prePos=AnimationClipParser04._reader.pos;
  3556. AnimationClipParser04._reader.pos=offset+AnimationClipParser04._DATA.offset;
  3557. for (var i=0;i < count;i++)
  3558. AnimationClipParser04._strings[i]=AnimationClipParser04._reader.readUTFString();
  3559. AnimationClipParser04._reader.pos=prePos;
  3560. }
  3561. AnimationClipParser04.parse=function(clip,reader,version){
  3562. AnimationClipParser04._animationClip=clip;
  3563. AnimationClipParser04._reader=reader;
  3564. AnimationClipParser04._version=version;
  3565. AnimationClipParser04.READ_DATA();
  3566. AnimationClipParser04.READ_BLOCK();
  3567. AnimationClipParser04.READ_STRINGS();
  3568. for (var i=0,n=AnimationClipParser04._BLOCK.count;i < n;i++){
  3569. var index=reader.getUint16();
  3570. var blockName=AnimationClipParser04._strings[index];
  3571. var fn=AnimationClipParser04["READ_"+blockName];
  3572. if (fn==null)
  3573. throw new Error("model file err,no this function:"+index+" "+blockName);
  3574. else
  3575. fn.call(null);
  3576. }
  3577. AnimationClipParser04._version=null;
  3578. AnimationClipParser04._reader=null;
  3579. AnimationClipParser04._animationClip=null;
  3580. }
  3581. AnimationClipParser04.READ_ANIMATIONS=function(){
  3582. var i=0,j=0;
  3583. var node;
  3584. var reader=AnimationClipParser04._reader;
  3585. var buffer=reader.__getBuffer();
  3586. var startTimeTypes=[];
  3587. var startTimeTypeCount=reader.getUint16();
  3588. startTimeTypes.length=startTimeTypeCount;
  3589. for (i=0;i < startTimeTypeCount;i++)
  3590. startTimeTypes[i]=reader.getFloat32();
  3591. var clip=AnimationClipParser04._animationClip;
  3592. clip.name=AnimationClipParser04._strings[reader.getUint16()];
  3593. var clipDur=clip._duration=reader.getFloat32();
  3594. clip.islooping=!!reader.getByte();
  3595. clip._frameRate=reader.getInt16();
  3596. var nodeCount=reader.getInt16();
  3597. var nodes=clip._nodes;
  3598. nodes.count=nodeCount;
  3599. var nodesMap=clip._nodesMap={};
  3600. var nodesDic=clip._nodesDic={};
  3601. for (i=0;i < nodeCount;i++){
  3602. node=new KeyframeNode();
  3603. nodes.setNodeByIndex(i,node);
  3604. node._indexInList=i;
  3605. var type=node.type=reader.getUint8();
  3606. var pathLength=reader.getUint16();
  3607. node._setOwnerPathCount(pathLength);
  3608. for (j=0;j < pathLength;j++)
  3609. node._setOwnerPathByIndex(j,AnimationClipParser04._strings[reader.getUint16()]);
  3610. var nodePath=node._joinOwnerPath("/");
  3611. var mapArray=nodesMap[nodePath];
  3612. (mapArray)|| (nodesMap[nodePath]=mapArray=[]);
  3613. mapArray.push(node);
  3614. node.propertyOwner=AnimationClipParser04._strings[reader.getUint16()];
  3615. var propertyLength=reader.getUint16();
  3616. node._setPropertyCount(propertyLength);
  3617. for (j=0;j < propertyLength;j++)
  3618. node._setPropertyByIndex(j,AnimationClipParser04._strings[reader.getUint16()]);
  3619. var fullPath=nodePath+"."+node.propertyOwner+"."+node._joinProperty(".");
  3620. nodesDic[fullPath]=node;
  3621. node.fullPath=fullPath;
  3622. var keyframeCount=reader.getUint16();
  3623. node._setKeyframeCount(keyframeCount);
  3624. var startTime=NaN;
  3625. switch (type){
  3626. case 0:
  3627. break ;
  3628. case 1:
  3629. case 3:
  3630. case 4:
  3631. node.data=Render.supportWebGLPlusAnimation ? new ConchVector3 :new Vector3();
  3632. break ;
  3633. case 2:
  3634. node.data=Render.supportWebGLPlusAnimation ? new ConchQuaternion :new Quaternion();
  3635. break ;
  3636. default :
  3637. throw "AnimationClipParser04:unknown type.";
  3638. }
  3639. switch (AnimationClipParser04._version){
  3640. case "LAYAANIMATION:04":
  3641. for (j=0;j < keyframeCount;j++){
  3642. switch (type){
  3643. case 0:;
  3644. var floatKeyframe=new FloatKeyframe();
  3645. node._setKeyframeByIndex(j,floatKeyframe);
  3646. startTime=floatKeyframe.time=startTimeTypes[reader.getUint16()];
  3647. floatKeyframe.inTangent=reader.getFloat32();
  3648. floatKeyframe.outTangent=reader.getFloat32();
  3649. floatKeyframe.value=reader.getFloat32();
  3650. break ;
  3651. case 1:
  3652. case 3:
  3653. case 4:;
  3654. var floatArrayKeyframe=new Vector3Keyframe();
  3655. node._setKeyframeByIndex(j,floatArrayKeyframe);
  3656. startTime=floatArrayKeyframe.time=startTimeTypes[reader.getUint16()];
  3657. if (Render.supportWebGLPlusAnimation){
  3658. var data=(floatArrayKeyframe).data=new Float32Array(3 *3);
  3659. for (var k=0;k < 3;k++)
  3660. data[k]=reader.getFloat32();
  3661. for (k=0;k < 3;k++)
  3662. data[3+k]=reader.getFloat32();
  3663. for (k=0;k < 3;k++)
  3664. data[6+k]=reader.getFloat32();
  3665. }
  3666. else {
  3667. var inTangent=floatArrayKeyframe.inTangent;
  3668. var outTangent=floatArrayKeyframe.outTangent;
  3669. var value=floatArrayKeyframe.value;
  3670. inTangent.x=reader.getFloat32();
  3671. inTangent.y=reader.getFloat32();
  3672. inTangent.z=reader.getFloat32();
  3673. outTangent.x=reader.getFloat32();
  3674. outTangent.y=reader.getFloat32();
  3675. outTangent.z=reader.getFloat32();
  3676. value.x=reader.getFloat32();
  3677. value.y=reader.getFloat32();
  3678. value.z=reader.getFloat32();
  3679. }
  3680. break ;
  3681. case 2:;
  3682. var quaternionKeyframe=new QuaternionKeyframe();
  3683. node._setKeyframeByIndex(j,quaternionKeyframe);
  3684. startTime=quaternionKeyframe.time=startTimeTypes[reader.getUint16()];
  3685. if (Render.supportWebGLPlusAnimation){
  3686. data=(quaternionKeyframe).data=new Float32Array(3 *4);
  3687. for (k=0;k < 4;k++)
  3688. data[k]=reader.getFloat32();
  3689. for (k=0;k < 4;k++)
  3690. data[4+k]=reader.getFloat32();
  3691. for (k=0;k < 4;k++)
  3692. data[8+k]=reader.getFloat32();
  3693. }
  3694. else {
  3695. var inTangentQua=quaternionKeyframe.inTangent;
  3696. var outTangentQua=quaternionKeyframe.outTangent;
  3697. var valueQua=quaternionKeyframe.value;
  3698. inTangentQua.x=reader.getFloat32();
  3699. inTangentQua.y=reader.getFloat32();
  3700. inTangentQua.z=reader.getFloat32();
  3701. inTangentQua.w=reader.getFloat32();
  3702. outTangentQua.x=reader.getFloat32();
  3703. outTangentQua.y=reader.getFloat32();
  3704. outTangentQua.z=reader.getFloat32();
  3705. outTangentQua.w=reader.getFloat32();
  3706. valueQua.x=reader.getFloat32();
  3707. valueQua.y=reader.getFloat32();
  3708. valueQua.z=reader.getFloat32();
  3709. valueQua.w=reader.getFloat32();
  3710. }
  3711. break ;
  3712. default :
  3713. throw "AnimationClipParser04:unknown type.";
  3714. }
  3715. }
  3716. break ;
  3717. case "LAYAANIMATION:COMPRESSION_04":
  3718. for (j=0;j < keyframeCount;j++){
  3719. switch (type){
  3720. case 0:
  3721. floatKeyframe=new FloatKeyframe();
  3722. node._setKeyframeByIndex(j,floatKeyframe);
  3723. startTime=floatKeyframe.time=startTimeTypes[reader.getUint16()];
  3724. floatKeyframe.inTangent=HalfFloatUtils.convertToNumber(reader.getUint16());
  3725. floatKeyframe.outTangent=HalfFloatUtils.convertToNumber(reader.getUint16());
  3726. floatKeyframe.value=HalfFloatUtils.convertToNumber(reader.getUint16());
  3727. break ;
  3728. case 1:
  3729. case 3:
  3730. case 4:
  3731. floatArrayKeyframe=new Vector3Keyframe();
  3732. node._setKeyframeByIndex(j,floatArrayKeyframe);
  3733. startTime=floatArrayKeyframe.time=startTimeTypes[reader.getUint16()];
  3734. if (Render.supportWebGLPlusAnimation){
  3735. data=(floatArrayKeyframe).data=new Float32Array(3 *3);
  3736. for (k=0;k < 3;k++)
  3737. data[k]=HalfFloatUtils.convertToNumber(reader.getUint16());
  3738. for (k=0;k < 3;k++)
  3739. data[3+k]=HalfFloatUtils.convertToNumber(reader.getUint16());
  3740. for (k=0;k < 3;k++)
  3741. data[6+k]=HalfFloatUtils.convertToNumber(reader.getUint16());
  3742. }
  3743. else {
  3744. inTangent=floatArrayKeyframe.inTangent;
  3745. outTangent=floatArrayKeyframe.outTangent;
  3746. value=floatArrayKeyframe.value;
  3747. inTangent.x=HalfFloatUtils.convertToNumber(reader.getUint16());
  3748. inTangent.y=HalfFloatUtils.convertToNumber(reader.getUint16());
  3749. inTangent.z=HalfFloatUtils.convertToNumber(reader.getUint16());
  3750. outTangent.x=HalfFloatUtils.convertToNumber(reader.getUint16());
  3751. outTangent.y=HalfFloatUtils.convertToNumber(reader.getUint16());
  3752. outTangent.z=HalfFloatUtils.convertToNumber(reader.getUint16());
  3753. value.x=HalfFloatUtils.convertToNumber(reader.getUint16());
  3754. value.y=HalfFloatUtils.convertToNumber(reader.getUint16());
  3755. value.z=HalfFloatUtils.convertToNumber(reader.getUint16());
  3756. }
  3757. break ;
  3758. case 2:
  3759. quaternionKeyframe=new QuaternionKeyframe();
  3760. node._setKeyframeByIndex(j,quaternionKeyframe);
  3761. startTime=quaternionKeyframe.time=startTimeTypes[reader.getUint16()];
  3762. if (Render.supportWebGLPlusAnimation){
  3763. data=(quaternionKeyframe).data=new Float32Array(3 *4);
  3764. for (k=0;k < 4;k++)
  3765. data[k]=HalfFloatUtils.convertToNumber(reader.getUint16());
  3766. for (k=0;k < 4;k++)
  3767. data[4+k]=HalfFloatUtils.convertToNumber(reader.getUint16());
  3768. for (k=0;k < 4;k++)
  3769. data[8+k]=HalfFloatUtils.convertToNumber(reader.getUint16());
  3770. }
  3771. else {
  3772. inTangentQua=quaternionKeyframe.inTangent;
  3773. outTangentQua=quaternionKeyframe.outTangent;
  3774. valueQua=quaternionKeyframe.value;
  3775. inTangentQua.x=HalfFloatUtils.convertToNumber(reader.getUint16());
  3776. inTangentQua.y=HalfFloatUtils.convertToNumber(reader.getUint16());
  3777. inTangentQua.z=HalfFloatUtils.convertToNumber(reader.getUint16());
  3778. inTangentQua.w=HalfFloatUtils.convertToNumber(reader.getUint16());
  3779. outTangentQua.x=HalfFloatUtils.convertToNumber(reader.getUint16());
  3780. outTangentQua.y=HalfFloatUtils.convertToNumber(reader.getUint16());
  3781. outTangentQua.z=HalfFloatUtils.convertToNumber(reader.getUint16());
  3782. outTangentQua.w=HalfFloatUtils.convertToNumber(reader.getUint16());
  3783. valueQua.x=HalfFloatUtils.convertToNumber(reader.getUint16());
  3784. valueQua.y=HalfFloatUtils.convertToNumber(reader.getUint16());
  3785. valueQua.z=HalfFloatUtils.convertToNumber(reader.getUint16());
  3786. valueQua.w=HalfFloatUtils.convertToNumber(reader.getUint16());
  3787. }
  3788. break ;
  3789. default :
  3790. throw "AnimationClipParser04:unknown type.";
  3791. }
  3792. }
  3793. break ;
  3794. }
  3795. };
  3796. var eventCount=reader.getUint16();
  3797. for (i=0;i < eventCount;i++){
  3798. var event=new AnimationEvent();
  3799. event.time=Math.min(clipDur,reader.getFloat32());
  3800. event.eventName=AnimationClipParser04._strings[reader.getUint16()];
  3801. var params;
  3802. var paramCount=reader.getUint16();
  3803. (paramCount > 0)&& (event.params=params=[]);
  3804. for (j=0;j < paramCount;j++){
  3805. var eventType=reader.getByte();
  3806. switch (eventType){
  3807. case 0:
  3808. params.push(!!reader.getByte());
  3809. break ;
  3810. case 1:
  3811. params.push(reader.getInt32());
  3812. break ;
  3813. case 2:
  3814. params.push(reader.getFloat32());
  3815. break ;
  3816. case 3:
  3817. params.push(AnimationClipParser04._strings[reader.getUint16()]);
  3818. break ;
  3819. default :
  3820. throw new Error("unknown type.");
  3821. }
  3822. }
  3823. clip.addEvent(event);
  3824. }
  3825. }
  3826. AnimationClipParser04._animationClip=null;
  3827. AnimationClipParser04._reader=null;
  3828. AnimationClipParser04._strings=[];
  3829. AnimationClipParser04._version=null;
  3830. __static(AnimationClipParser04,
  3831. ['_BLOCK',function(){return this._BLOCK={count:0};},'_DATA',function(){return this._DATA={offset:0,size:0};}
  3832. ]);
  3833. return AnimationClipParser04;
  3834. })()
  3835. /**
  3836. *@private
  3837. */
  3838. //class laya.d3.animation.AnimationClipParser03
  3839. var AnimationClipParser03=(function(){
  3840. function AnimationClipParser03(){}
  3841. __class(AnimationClipParser03,'laya.d3.animation.AnimationClipParser03');
  3842. AnimationClipParser03.READ_DATA=function(){
  3843. AnimationClipParser03._DATA.offset=AnimationClipParser03._reader.getUint32();
  3844. AnimationClipParser03._DATA.size=AnimationClipParser03._reader.getUint32();
  3845. }
  3846. AnimationClipParser03.READ_BLOCK=function(){
  3847. var count=AnimationClipParser03._BLOCK.count=AnimationClipParser03._reader.getUint16();
  3848. var blockStarts=AnimationClipParser03._BLOCK.blockStarts=[];
  3849. var blockLengths=AnimationClipParser03._BLOCK.blockLengths=[];
  3850. for (var i=0;i < count;i++){
  3851. blockStarts.push(AnimationClipParser03._reader.getUint32());
  3852. blockLengths.push(AnimationClipParser03._reader.getUint32());
  3853. }
  3854. }
  3855. AnimationClipParser03.READ_STRINGS=function(){
  3856. var offset=AnimationClipParser03._reader.getUint32();
  3857. var count=AnimationClipParser03._reader.getUint16();
  3858. var prePos=AnimationClipParser03._reader.pos;
  3859. AnimationClipParser03._reader.pos=offset+AnimationClipParser03._DATA.offset;
  3860. for (var i=0;i < count;i++)
  3861. AnimationClipParser03._strings[i]=AnimationClipParser03._reader.readUTFString();
  3862. AnimationClipParser03._reader.pos=prePos;
  3863. }
  3864. AnimationClipParser03.parse=function(clip,reader){
  3865. AnimationClipParser03._animationClip=clip;
  3866. AnimationClipParser03._reader=reader;
  3867. var arrayBuffer=reader.__getBuffer();
  3868. AnimationClipParser03.READ_DATA();
  3869. AnimationClipParser03.READ_BLOCK();
  3870. AnimationClipParser03.READ_STRINGS();
  3871. for (var i=0,n=AnimationClipParser03._BLOCK.count;i < n;i++){
  3872. var index=reader.getUint16();
  3873. var blockName=AnimationClipParser03._strings[index];
  3874. var fn=AnimationClipParser03["READ_"+blockName];
  3875. if (fn==null)
  3876. throw new Error("model file err,no this function:"+index+" "+blockName);
  3877. else
  3878. fn.call(null);
  3879. }
  3880. }
  3881. AnimationClipParser03.READ_ANIMATIONS=function(){
  3882. var i=0,j=0;
  3883. var node;
  3884. var reader=AnimationClipParser03._reader;
  3885. var buffer=reader.__getBuffer();
  3886. var startTimeTypes=[];
  3887. var startTimeTypeCount=reader.getUint16();
  3888. startTimeTypes.length=startTimeTypeCount;
  3889. for (i=0;i < startTimeTypeCount;i++)
  3890. startTimeTypes[i]=reader.getFloat32();
  3891. var clip=AnimationClipParser03._animationClip;
  3892. clip.name=AnimationClipParser03._strings[reader.getUint16()];
  3893. var clipDur=clip._duration=reader.getFloat32();
  3894. clip.islooping=!!reader.getByte();
  3895. clip._frameRate=reader.getInt16();
  3896. var nodeCount=reader.getInt16();
  3897. var nodes=clip._nodes;
  3898. nodes.count=nodeCount;
  3899. var nodesMap=clip._nodesMap={};
  3900. var nodesDic=clip._nodesDic={};
  3901. for (i=0;i < nodeCount;i++){
  3902. node=new KeyframeNode();
  3903. nodes.setNodeByIndex(i,node);
  3904. node._indexInList=i;
  3905. var type=node.type=reader.getUint8();
  3906. var pathLength=reader.getUint16();
  3907. node._setOwnerPathCount(pathLength);
  3908. for (j=0;j < pathLength;j++)
  3909. node._setOwnerPathByIndex(j,AnimationClipParser03._strings[reader.getUint16()]);
  3910. var nodePath=node._joinOwnerPath("/");
  3911. var mapArray=nodesMap[nodePath];
  3912. (mapArray)|| (nodesMap[nodePath]=mapArray=[]);
  3913. mapArray.push(node);
  3914. node.propertyOwner=AnimationClipParser03._strings[reader.getUint16()];
  3915. var propertyLength=reader.getUint16();
  3916. node._setPropertyCount(propertyLength);
  3917. for (j=0;j < propertyLength;j++)
  3918. node._setPropertyByIndex(j,AnimationClipParser03._strings[reader.getUint16()]);
  3919. var fullPath=nodePath+"."+node.propertyOwner+"."+node._joinProperty(".");
  3920. nodesDic[fullPath]=node;
  3921. node.fullPath=fullPath;
  3922. var keyframeCount=reader.getUint16();
  3923. node._setKeyframeCount(keyframeCount);
  3924. var startTime=NaN;
  3925. switch (type){
  3926. case 0:
  3927. break ;
  3928. case 1:
  3929. case 3:
  3930. case 4:
  3931. node.data=Render.supportWebGLPlusAnimation ? new ConchVector3 :new Vector3();
  3932. break ;
  3933. case 2:
  3934. node.data=Render.supportWebGLPlusAnimation ? new ConchQuaternion :new Quaternion();
  3935. break ;
  3936. default :
  3937. throw "AnimationClipParser03:unknown type.";
  3938. }
  3939. for (j=0;j < keyframeCount;j++){
  3940. switch (type){
  3941. case 0:;
  3942. var floatKeyframe=new FloatKeyframe();
  3943. node._setKeyframeByIndex(j,floatKeyframe);
  3944. startTime=floatKeyframe.time=startTimeTypes[reader.getUint16()];
  3945. floatKeyframe.inTangent=reader.getFloat32();
  3946. floatKeyframe.outTangent=reader.getFloat32();
  3947. floatKeyframe.value=reader.getFloat32();
  3948. break ;
  3949. case 1:
  3950. case 3:
  3951. case 4:;
  3952. var floatArrayKeyframe=new Vector3Keyframe();
  3953. node._setKeyframeByIndex(j,floatArrayKeyframe);
  3954. startTime=floatArrayKeyframe.time=startTimeTypes[reader.getUint16()];
  3955. if (Render.supportWebGLPlusAnimation){
  3956. var data=(floatArrayKeyframe).data=new Float32Array(3 *3);
  3957. for (var k=0;k < 3;k++)
  3958. data[k]=reader.getFloat32();
  3959. for (k=0;k < 3;k++)
  3960. data[3+k]=reader.getFloat32();
  3961. for (k=0;k < 3;k++)
  3962. data[6+k]=reader.getFloat32();
  3963. }
  3964. else {
  3965. var inTangent=floatArrayKeyframe.inTangent;
  3966. var outTangent=floatArrayKeyframe.outTangent;
  3967. var value=floatArrayKeyframe.value;
  3968. inTangent.x=reader.getFloat32();
  3969. inTangent.y=reader.getFloat32();
  3970. inTangent.z=reader.getFloat32();
  3971. outTangent.x=reader.getFloat32();
  3972. outTangent.y=reader.getFloat32();
  3973. outTangent.z=reader.getFloat32();
  3974. value.x=reader.getFloat32();
  3975. value.y=reader.getFloat32();
  3976. value.z=reader.getFloat32();
  3977. }
  3978. break ;
  3979. case 2:;
  3980. var quaArrayKeyframe=new QuaternionKeyframe();
  3981. node._setKeyframeByIndex(j,quaArrayKeyframe);
  3982. startTime=quaArrayKeyframe.time=startTimeTypes[reader.getUint16()];
  3983. if (Render.supportWebGLPlusAnimation){
  3984. data=(quaArrayKeyframe).data=new Float32Array(3 *4);
  3985. for (k=0;k < 4;k++)
  3986. data[k]=reader.getFloat32();
  3987. for (k=0;k < 4;k++)
  3988. data[4+k]=reader.getFloat32();
  3989. for (k=0;k < 4;k++)
  3990. data[8+k]=reader.getFloat32();
  3991. }
  3992. else {
  3993. var inTangentQua=quaArrayKeyframe.inTangent;
  3994. var outTangentQua=quaArrayKeyframe.outTangent;
  3995. var valueQua=quaArrayKeyframe.value;
  3996. inTangentQua.x=reader.getFloat32();
  3997. inTangentQua.y=reader.getFloat32();
  3998. inTangentQua.z=reader.getFloat32();
  3999. inTangentQua.w=reader.getFloat32();
  4000. outTangentQua.x=reader.getFloat32();
  4001. outTangentQua.y=reader.getFloat32();
  4002. outTangentQua.z=reader.getFloat32();
  4003. outTangentQua.w=reader.getFloat32();
  4004. valueQua.x=reader.getFloat32();
  4005. valueQua.y=reader.getFloat32();
  4006. valueQua.z=reader.getFloat32();
  4007. valueQua.w=reader.getFloat32();
  4008. }
  4009. break ;
  4010. default :
  4011. throw "AnimationClipParser03:unknown type.";
  4012. }
  4013. }
  4014. };
  4015. var eventCount=reader.getUint16();
  4016. for (i=0;i < eventCount;i++){
  4017. var event=new AnimationEvent();
  4018. event.time=Math.min(clipDur,reader.getFloat32());
  4019. event.eventName=AnimationClipParser03._strings[reader.getUint16()];
  4020. var params;
  4021. var paramCount=reader.getUint16();
  4022. (paramCount > 0)&& (event.params=params=[]);
  4023. for (j=0;j < paramCount;j++){
  4024. var eventType=reader.getByte();
  4025. switch (eventType){
  4026. case 0:
  4027. params.push(!!reader.getByte());
  4028. break ;
  4029. case 1:
  4030. params.push(reader.getInt32());
  4031. break ;
  4032. case 2:
  4033. params.push(reader.getFloat32());
  4034. break ;
  4035. case 3:
  4036. params.push(AnimationClipParser03._strings[reader.getUint16()]);
  4037. break ;
  4038. default :
  4039. throw new Error("unknown type.");
  4040. }
  4041. }
  4042. clip.addEvent(event);
  4043. }
  4044. }
  4045. AnimationClipParser03._animationClip=null;
  4046. AnimationClipParser03._reader=null;
  4047. AnimationClipParser03._strings=[];
  4048. __static(AnimationClipParser03,
  4049. ['_BLOCK',function(){return this._BLOCK={count:0};},'_DATA',function(){return this._DATA={offset:0,size:0};}
  4050. ]);
  4051. return AnimationClipParser03;
  4052. })()
  4053. /**
  4054. *<code>PhysicsSettings</code> 类用于创建物理配置信息。
  4055. */
  4056. //class laya.d3.physics.PhysicsSettings
  4057. var PhysicsSettings=(function(){
  4058. function PhysicsSettings(){
  4059. /**标志集合。*/
  4060. this.flags=0;
  4061. /**物理引擎在一帧中用于补偿减速的最大次数。*/
  4062. this.maxSubSteps=1;
  4063. /**物理模拟器帧的间隔时间。*/
  4064. this.fixedTimeStep=1.0 / 60.0;
  4065. }
  4066. __class(PhysicsSettings,'laya.d3.physics.PhysicsSettings');
  4067. return PhysicsSettings;
  4068. })()
  4069. /**
  4070. *<code>Burst</code> 类用于粒子的爆裂描述。
  4071. */
  4072. //class laya.d3.core.particleShuriKen.module.Burst
  4073. var Burst=(function(){
  4074. function Burst(time,minCount,maxCount){
  4075. /**@private 爆裂时间,单位为秒。*/
  4076. this._time=NaN;
  4077. /**@private 爆裂的最小数量。*/
  4078. this._minCount=0;
  4079. /**@private 爆裂的最大数量。*/
  4080. this._maxCount=0;
  4081. this._time=time;
  4082. this._minCount=minCount;
  4083. this._maxCount=maxCount;
  4084. }
  4085. __class(Burst,'laya.d3.core.particleShuriKen.module.Burst');
  4086. var __proto=Burst.prototype;
  4087. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  4088. /**
  4089. *克隆。
  4090. *@param destObject 克隆源。
  4091. */
  4092. __proto.cloneTo=function(destObject){
  4093. var destBurst=destObject;
  4094. destBurst._time=this._time
  4095. destBurst._minCount=this._minCount;
  4096. destBurst._maxCount=this._maxCount;
  4097. }
  4098. /**
  4099. *克隆。
  4100. *@return 克隆副本。
  4101. */
  4102. __proto.clone=function(){
  4103. var destBurst=/*__JS__ */new this.constructor();
  4104. this.cloneTo(destBurst);
  4105. return destBurst;
  4106. }
  4107. /**
  4108. *获取爆裂时间,单位为秒。
  4109. *@return 爆裂时间,单位为秒。
  4110. */
  4111. __getset(0,__proto,'time',function(){
  4112. return this._time;
  4113. });
  4114. /**
  4115. *获取爆裂的最小数量。
  4116. *@return 爆裂的最小数量。
  4117. */
  4118. __getset(0,__proto,'minCount',function(){
  4119. return this._minCount;
  4120. });
  4121. /**
  4122. *获取爆裂的最大数量。
  4123. *@return 爆裂的最大数量。
  4124. */
  4125. __getset(0,__proto,'maxCount',function(){
  4126. return this._maxCount;
  4127. });
  4128. return Burst;
  4129. })()
  4130. /**
  4131. *<code>VertexPositionTerrain</code> 类用于创建位置、法线、纹理1、纹理2顶点结构。
  4132. */
  4133. //class laya.d3.graphics.Vertex.VertexPositionTerrain
  4134. var VertexPositionTerrain=(function(){
  4135. function VertexPositionTerrain(position,normal,textureCoord0,textureCoord1){
  4136. this._position=null;
  4137. this._normal=null;
  4138. this._textureCoord0=null;
  4139. this._textureCoord1=null;
  4140. this._position=position;
  4141. this._normal=normal;
  4142. this._textureCoord0=textureCoord0;
  4143. this._textureCoord1=textureCoord1;
  4144. }
  4145. __class(VertexPositionTerrain,'laya.d3.graphics.Vertex.VertexPositionTerrain');
  4146. var __proto=VertexPositionTerrain.prototype;
  4147. Laya.imps(__proto,{"laya.d3.graphics.IVertex":true})
  4148. __getset(0,__proto,'normal',function(){
  4149. return this._normal;
  4150. });
  4151. __getset(0,__proto,'position',function(){
  4152. return this._position;
  4153. });
  4154. __getset(0,__proto,'textureCoord0',function(){
  4155. return this._textureCoord0;
  4156. });
  4157. __getset(0,__proto,'textureCoord1',function(){
  4158. return this._textureCoord1;
  4159. });
  4160. __getset(0,__proto,'vertexDeclaration',function(){
  4161. return VertexPositionTerrain._vertexDeclaration;
  4162. });
  4163. __getset(1,VertexPositionTerrain,'vertexDeclaration',function(){
  4164. return VertexPositionTerrain._vertexDeclaration;
  4165. });
  4166. VertexPositionTerrain.TERRAIN_POSITION0=0;
  4167. VertexPositionTerrain.TERRAIN_NORMAL0=1;
  4168. VertexPositionTerrain.TERRAIN_TEXTURECOORDINATE0=2;
  4169. VertexPositionTerrain.TERRAIN_TEXTURECOORDINATE1=3;
  4170. __static(VertexPositionTerrain,
  4171. ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(40,[
  4172. new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*CLASS CONST:laya.d3.graphics.Vertex.VertexPositionTerrain.TERRAIN_POSITION0*/0),
  4173. new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*CLASS CONST:laya.d3.graphics.Vertex.VertexPositionTerrain.TERRAIN_NORMAL0*/1),
  4174. new VertexElement(24,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*CLASS CONST:laya.d3.graphics.Vertex.VertexPositionTerrain.TERRAIN_TEXTURECOORDINATE0*/2),
  4175. new VertexElement(32,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*CLASS CONST:laya.d3.graphics.Vertex.VertexPositionTerrain.TERRAIN_TEXTURECOORDINATE1*/3)]);}
  4176. ]);
  4177. return VertexPositionTerrain;
  4178. })()
  4179. /**
  4180. *<code>BaseShape</code> 类用于粒子形状。
  4181. */
  4182. //class laya.d3.core.particleShuriKen.module.shape.BaseShape
  4183. var BaseShape=(function(){
  4184. function BaseShape(){
  4185. /**是否启用。*/
  4186. this.enable=false;
  4187. /**随机方向。*/
  4188. this.randomDirection=false;
  4189. }
  4190. __class(BaseShape,'laya.d3.core.particleShuriKen.module.shape.BaseShape');
  4191. var __proto=BaseShape.prototype;
  4192. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  4193. /**@private */
  4194. __proto._getShapeBoundBox=function(boundBox){
  4195. throw new Error("BaseShape: must override it.");
  4196. }
  4197. /**@private */
  4198. __proto._getSpeedBoundBox=function(boundBox){
  4199. throw new Error("BaseShape: must override it.");
  4200. }
  4201. /**
  4202. *用于生成粒子初始位置和方向。
  4203. *@param position 粒子位置。
  4204. *@param direction 粒子方向。
  4205. */
  4206. __proto.generatePositionAndDirection=function(position,direction,rand,randomSeeds){
  4207. throw new Error("BaseShape: must override it.");
  4208. }
  4209. /**
  4210. *@private
  4211. */
  4212. __proto._calculateProceduralBounds=function(boundBox,emitterPosScale,minMaxBounds){
  4213. this._getShapeBoundBox(boundBox);
  4214. var min=boundBox.min;
  4215. var max=boundBox.max;
  4216. Vector3.multiply(min,emitterPosScale,min);
  4217. Vector3.multiply(max,emitterPosScale,max);
  4218. var speedBounds=new BoundBox(new Vector3(),new Vector3());
  4219. if (this.randomDirection){
  4220. speedBounds.min=new Vector3(-1,-1,-1);
  4221. speedBounds.max=new Vector3(1,1,1);
  4222. }
  4223. else{
  4224. this._getSpeedBoundBox(speedBounds);
  4225. };
  4226. var maxSpeedBound=new BoundBox(new Vector3(),new Vector3());
  4227. var maxSpeedMin=maxSpeedBound.min;
  4228. var maxSpeedMax=maxSpeedBound.max;
  4229. Vector3.scale(speedBounds.min,minMaxBounds.y,maxSpeedMin);
  4230. Vector3.scale(speedBounds.max,minMaxBounds.y,maxSpeedMax);
  4231. Vector3.add(boundBox.min,maxSpeedMin,maxSpeedMin);
  4232. Vector3.add(boundBox.max,maxSpeedMax,maxSpeedMax);
  4233. Vector3.min(boundBox.min,maxSpeedMin,boundBox.min);
  4234. Vector3.max(boundBox.max,maxSpeedMin,boundBox.max);
  4235. var minSpeedBound=new BoundBox(new Vector3(),new Vector3());
  4236. var minSpeedMin=minSpeedBound.min;
  4237. var minSpeedMax=minSpeedBound.max;
  4238. Vector3.scale(speedBounds.min,minMaxBounds.x,minSpeedMin);
  4239. Vector3.scale(speedBounds.max,minMaxBounds.x,minSpeedMax);
  4240. Vector3.min(minSpeedBound.min,minSpeedMax,maxSpeedMin);
  4241. Vector3.max(minSpeedBound.min,minSpeedMax,maxSpeedMax);
  4242. Vector3.min(boundBox.min,maxSpeedMin,boundBox.min);
  4243. Vector3.max(boundBox.max,maxSpeedMin,boundBox.max);
  4244. }
  4245. /**
  4246. *克隆。
  4247. *@param destObject 克隆源。
  4248. */
  4249. __proto.cloneTo=function(destObject){
  4250. var destShape=destObject;
  4251. destShape.enable=this.enable;
  4252. }
  4253. /**
  4254. *克隆。
  4255. *@return 克隆副本。
  4256. */
  4257. __proto.clone=function(){
  4258. var destShape=/*__JS__ */new this.constructor();
  4259. this.cloneTo(destShape);
  4260. return destShape;
  4261. }
  4262. return BaseShape;
  4263. })()
  4264. /**
  4265. *<code>SubShader</code> 类用于创建SubShader。
  4266. */
  4267. //class laya.d3.shader.SubShader
  4268. var SubShader=(function(){
  4269. function SubShader(attributeMap,uniformMap,spriteDefines,materialDefines){
  4270. /**@private */
  4271. this._attributeMap=null;
  4272. /**@private */
  4273. this._uniformMap=null;
  4274. /**@private */
  4275. this._publicDefines=null;
  4276. /**@private */
  4277. this._publicDefinesMap=null;
  4278. /**@private */
  4279. this._spriteDefines=null;
  4280. /**@private */
  4281. this._spriteDefinesMap=null;
  4282. /**@private */
  4283. this._materialDefines=null;
  4284. /**@private */
  4285. this._materialDefinesMap=null;
  4286. /**@private */
  4287. this._owner=null;
  4288. /**@private */
  4289. this._flags={};
  4290. this._passes=[];
  4291. this._publicDefines=[];
  4292. this._publicDefinesMap={};
  4293. this._spriteDefines=[];
  4294. this._spriteDefinesMap={};
  4295. this._materialDefines=[];
  4296. this._materialDefinesMap={};
  4297. this._addDefines(this._publicDefines,this._publicDefinesMap,Shader3D._globleDefines);
  4298. (spriteDefines)&& (this._addDefines(this._spriteDefines,this._spriteDefinesMap,spriteDefines.defines));
  4299. (materialDefines)&& (this._addDefines(this._materialDefines,this._materialDefinesMap,materialDefines.defines));
  4300. this._attributeMap=attributeMap;
  4301. this._uniformMap=uniformMap;
  4302. }
  4303. __class(SubShader,'laya.d3.shader.SubShader');
  4304. var __proto=SubShader.prototype;
  4305. /**
  4306. *@private
  4307. */
  4308. __proto._addDefines=function(defines,definesMap,supportDefines){
  4309. for (var k in supportDefines){
  4310. var name=supportDefines[k];
  4311. var i=parseInt(k);
  4312. defines[i]=name;
  4313. definesMap[name]=i;
  4314. }
  4315. }
  4316. /**
  4317. *通过名称获取宏定义值。
  4318. *@param name 名称。
  4319. *@return 宏定义值。
  4320. */
  4321. __proto.getMaterialDefineByName=function(name){
  4322. return this._materialDefinesMap[name];
  4323. }
  4324. /**
  4325. *添加标记。
  4326. *@param key 标记键。
  4327. *@param value 标记值。
  4328. */
  4329. __proto.setFlag=function(key,value){
  4330. if (value)
  4331. this._flags[key]=value;
  4332. else
  4333. delete this._flags[key];
  4334. }
  4335. /**
  4336. *获取标记值。
  4337. *@return key 标记键。
  4338. */
  4339. __proto.getFlag=function(key){
  4340. return this._flags[key];
  4341. }
  4342. /**
  4343. *@private
  4344. */
  4345. __proto.addShaderPass=function(vs,ps,stateMap){
  4346. var shaderPass=new ShaderPass(this,vs,ps,stateMap);
  4347. this._passes.push(shaderPass);
  4348. return shaderPass;
  4349. }
  4350. return SubShader;
  4351. })()
  4352. /**
  4353. *<code>SingletonList</code> 类用于实现单例队列。
  4354. */
  4355. //class laya.d3.component.SingletonList
  4356. var SingletonList=(function(){
  4357. function SingletonList(){
  4358. /**@private [只读]*/
  4359. this.length=0;
  4360. this.elements=[];
  4361. }
  4362. __class(SingletonList,'laya.d3.component.SingletonList');
  4363. var __proto=SingletonList.prototype;
  4364. /**
  4365. *@private
  4366. */
  4367. __proto._add=function(element){
  4368. if (this.length===this.elements.length)
  4369. this.elements.push(element);
  4370. else
  4371. this.elements[this.length]=element;
  4372. }
  4373. return SingletonList;
  4374. })()
  4375. /**
  4376. *<code>Utils3D</code> 类用于创建3D工具。
  4377. */
  4378. //class laya.d3.utils.Utils3D
  4379. var Utils3D=(function(){
  4380. function Utils3D(){}
  4381. __class(Utils3D,'laya.d3.utils.Utils3D');
  4382. Utils3D._convertToLayaVec3=function(bVector,out,inverseX){
  4383. out.x=inverseX ?-bVector.x():bVector.x();
  4384. out.y=bVector.y();
  4385. out.z=bVector.z();
  4386. }
  4387. Utils3D._convertToBulletVec3=function(lVector,out,inverseX){
  4388. out.setValue(inverseX ?-lVector.x :lVector.x,lVector.y,lVector.z);
  4389. }
  4390. Utils3D._rotationTransformScaleSkinAnimation=function(tx,ty,tz,qx,qy,qz,qw,sx,sy,sz,outArray,outOffset){
  4391. var re=Utils3D._tempArray16_0;
  4392. var se=Utils3D._tempArray16_1;
  4393. var tse=Utils3D._tempArray16_2;
  4394. var x2=qx+qx;
  4395. var y2=qy+qy;
  4396. var z2=qz+qz;
  4397. var xx=qx *x2;
  4398. var yx=qy *x2;
  4399. var yy=qy *y2;
  4400. var zx=qz *x2;
  4401. var zy=qz *y2;
  4402. var zz=qz *z2;
  4403. var wx=qw *x2;
  4404. var wy=qw *y2;
  4405. var wz=qw *z2;
  4406. re[15]=1;
  4407. re[0]=1-yy-zz;
  4408. re[1]=yx+wz;
  4409. re[2]=zx-wy;
  4410. re[4]=yx-wz;
  4411. re[5]=1-xx-zz;
  4412. re[6]=zy+wx;
  4413. re[8]=zx+wy;
  4414. re[9]=zy-wx;
  4415. re[10]=1-xx-yy;
  4416. se[15]=1;
  4417. se[0]=sx;
  4418. se[5]=sy;
  4419. se[10]=sz;
  4420. var i,a,b,e,ai0,ai1,ai2,ai3;
  4421. for (i=0;i < 4;i++){
  4422. ai0=re[i];
  4423. ai1=re[i+4];
  4424. ai2=re[i+8];
  4425. ai3=re[i+12];
  4426. tse[i]=ai0;
  4427. tse[i+4]=ai1;
  4428. tse[i+8]=ai2;
  4429. tse[i+12]=ai0 *tx+ai1 *ty+ai2 *tz+ai3;
  4430. }
  4431. for (i=0;i < 4;i++){
  4432. ai0=tse[i];
  4433. ai1=tse[i+4];
  4434. ai2=tse[i+8];
  4435. ai3=tse[i+12];
  4436. outArray[i+outOffset]=ai0 *se[0]+ai1 *se[1]+ai2 *se[2]+ai3 *se[3];
  4437. outArray[i+outOffset+4]=ai0 *se[4]+ai1 *se[5]+ai2 *se[6]+ai3 *se[7];
  4438. outArray[i+outOffset+8]=ai0 *se[8]+ai1 *se[9]+ai2 *se[10]+ai3 *se[11];
  4439. outArray[i+outOffset+12]=ai0 *se[12]+ai1 *se[13]+ai2 *se[14]+ai3 *se[15];
  4440. }
  4441. }
  4442. Utils3D._createSceneByJsonForMaker=function(nodeData,outBatchSprites,initTool){
  4443. var scene3d=Utils3D._createNodeByJsonForMaker(nodeData,outBatchSprites,initTool);
  4444. Utils3D._addComponentByJsonForMaker(nodeData,outBatchSprites,initTool);
  4445. return scene3d;
  4446. }
  4447. Utils3D._createNodeByJsonForMaker=function(nodeData,outBatchSprites,initTool){
  4448. var node;
  4449. switch (nodeData.type){
  4450. case "Scene3D":
  4451. node=new Scene3D();
  4452. break ;
  4453. case "Sprite3D":
  4454. node=new Sprite3D();
  4455. break ;
  4456. case "MeshSprite3D":
  4457. node=new MeshSprite3D();
  4458. (outBatchSprites)&& (outBatchSprites.push(node));
  4459. break ;
  4460. case "SkinnedMeshSprite3D":
  4461. node=new SkinnedMeshSprite3D();
  4462. break ;
  4463. case "ShuriKenParticle3D":
  4464. node=new ShuriKenParticle3D();
  4465. break ;
  4466. case "Terrain":
  4467. node=new Terrain();
  4468. break ;
  4469. case "Camera":
  4470. node=new Camera();
  4471. break ;
  4472. case "DirectionLight":
  4473. node=new DirectionLight();
  4474. break ;
  4475. case "PointLight":
  4476. node=new PointLight();
  4477. break ;
  4478. case "SpotLight":
  4479. node=new SpotLight();
  4480. break ;
  4481. case "TrailSprite3D":
  4482. node=new TrailSprite3D();
  4483. break ;
  4484. default :;
  4485. var clas=ClassUtils.getClass(nodeData.props.runtime);
  4486. node=new clas();
  4487. break ;
  4488. };
  4489. var childData=nodeData.child;
  4490. if (childData){
  4491. for (var i=0,n=childData.length;i < n;i++){
  4492. var child=Utils3D._createNodeByJsonForMaker(childData[i],outBatchSprites,initTool);
  4493. node.addChild(child);
  4494. }
  4495. };
  4496. var compId=nodeData.compId;
  4497. (node).compId=compId;
  4498. node._parse(nodeData.props,null);
  4499. if (initTool){
  4500. initTool._idMap[compId]=node;
  4501. }
  4502. Utils3D._compIdToNode[compId]=node;
  4503. var componentsData=nodeData.components;
  4504. if (componentsData){
  4505. for (var j=0,m=componentsData.length;j < m;j++){
  4506. var data=componentsData[j];
  4507. clas=Browser.window.Laya[data.type];
  4508. if (!clas){
  4509. clas=Browser.window;
  4510. var clasPaths=data.type.split('.');
  4511. clasPaths.forEach(function(cls){
  4512. clas=clas[cls];
  4513. });
  4514. }
  4515. if (typeof(clas)=='function'){
  4516. var comp=new clas();
  4517. if (initTool){
  4518. initTool._idMap[data.compId]=comp;
  4519. console.log(data.compId);
  4520. }
  4521. }else {
  4522. console.warn("Utils3D:Unkown component type.");
  4523. }
  4524. }
  4525. }
  4526. return node;
  4527. }
  4528. Utils3D._addComponentByJsonForMaker=function(nodeData,outBatchSprites,initTool){
  4529. var compId=nodeData.compId;
  4530. var node=Utils3D._compIdToNode[compId];
  4531. var childData=nodeData.child;
  4532. if (childData){
  4533. for (var i=0,n=childData.length;i < n;i++){
  4534. var child=Utils3D._addComponentByJsonForMaker(childData[i],outBatchSprites,initTool);
  4535. }
  4536. };
  4537. var componentsData=nodeData.components;
  4538. if (componentsData){
  4539. for (var j=0,m=componentsData.length;j < m;j++){
  4540. var data=componentsData[j];
  4541. clas=Browser.window.Laya[data.type];
  4542. if (!clas){
  4543. var clasPaths=data.type.split('.');
  4544. var clas=Browser.window;
  4545. clasPaths.forEach(function(cls){
  4546. clas=clas[cls];
  4547. });
  4548. }
  4549. if (typeof(clas)=='function'){
  4550. var component=initTool._idMap[data.compId];
  4551. node.addComponentIntance(component);
  4552. component._parse(data);
  4553. }else {
  4554. console.warn("Utils3D:Unkown component type.");
  4555. }
  4556. }
  4557. }
  4558. }
  4559. Utils3D._createSprite3DInstance=function(nodeData,spriteMap,outBatchSprites){
  4560. var node;
  4561. switch (nodeData.type){
  4562. case "Scene3D":
  4563. node=new Scene3D();
  4564. break ;
  4565. case "Sprite3D":
  4566. node=new Sprite3D();
  4567. break ;
  4568. case "MeshSprite3D":
  4569. node=new MeshSprite3D();
  4570. (outBatchSprites)&& (outBatchSprites.push(node));
  4571. break ;
  4572. case "SkinnedMeshSprite3D":
  4573. node=new SkinnedMeshSprite3D();
  4574. break ;
  4575. case "ShuriKenParticle3D":
  4576. node=new ShuriKenParticle3D();
  4577. break ;
  4578. case "Terrain":
  4579. node=new Terrain();
  4580. break ;
  4581. case "Camera":
  4582. node=new Camera();
  4583. break ;
  4584. case "DirectionLight":
  4585. node=new DirectionLight();
  4586. break ;
  4587. case "PointLight":
  4588. node=new PointLight();
  4589. break ;
  4590. case "SpotLight":
  4591. node=new SpotLight();
  4592. break ;
  4593. case "TrailSprite3D":
  4594. node=new TrailSprite3D();
  4595. break ;
  4596. default :
  4597. throw new Error("Utils3D:unidentified class type in (.lh) file.");
  4598. };
  4599. var childData=nodeData.child;
  4600. if (childData){
  4601. for (var i=0,n=childData.length;i < n;i++){
  4602. var child=Utils3D._createSprite3DInstance(childData[i],spriteMap,outBatchSprites)
  4603. node.addChild(child);
  4604. }
  4605. }
  4606. spriteMap[nodeData.instanceID]=node;
  4607. return node;
  4608. }
  4609. Utils3D._createComponentInstance=function(nodeData,spriteMap){
  4610. var node=spriteMap[nodeData.instanceID];
  4611. node._parse(nodeData.props,spriteMap);
  4612. var childData=nodeData.child;
  4613. if (childData){
  4614. for (var i=0,n=childData.length;i < n;i++)
  4615. Utils3D._createComponentInstance(childData[i],spriteMap)
  4616. };
  4617. var componentsData=nodeData.components;
  4618. if (componentsData){
  4619. for (var j=0,m=componentsData.length;j < m;j++){
  4620. var data=componentsData[j];
  4621. var clas=Browser.window.Laya[data.type];
  4622. if (!clas){
  4623. var clasPaths=data.type.split('.');
  4624. clas=Browser.window;
  4625. clasPaths.forEach(function(cls){
  4626. clas=clas[cls];
  4627. });
  4628. }
  4629. if (typeof(clas)=='function'){
  4630. var component=node.addComponent(clas);
  4631. component._parse(data);
  4632. }else {
  4633. console.warn("Unkown component type.");
  4634. }
  4635. }
  4636. }
  4637. }
  4638. Utils3D._createNodeByJson02=function(nodeData,outBatchSprites){
  4639. var spriteMap={};
  4640. var node=Utils3D._createSprite3DInstance(nodeData,spriteMap,outBatchSprites);
  4641. Utils3D._createComponentInstance(nodeData,spriteMap);
  4642. return node;
  4643. }
  4644. Utils3D._computeBoneAndAnimationDatasByBindPoseMatrxix=function(bones,curData,inverGlobalBindPose,outBonesDatas,outAnimationDatas,boneIndexToMesh){
  4645. var offset=0;
  4646. var matOffset=0;
  4647. var i;
  4648. var parentOffset;
  4649. var boneLength=bones.length;
  4650. for (i=0;i < boneLength;offset+=bones[i].keyframeWidth,matOffset+=16,i++){
  4651. 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);
  4652. if (i !=0){
  4653. parentOffset=bones[i].parentIndex *16;
  4654. laya.d3.utils.Utils3D.mulMatrixByArray(outBonesDatas,parentOffset,outBonesDatas,matOffset,outBonesDatas,matOffset);
  4655. }
  4656. };
  4657. var n=inverGlobalBindPose.length;
  4658. for (i=0;i < n;i++){
  4659. laya.d3.utils.Utils3D.mulMatrixByArrayAndMatrixFast(outBonesDatas,boneIndexToMesh[i] *16,inverGlobalBindPose[i],outAnimationDatas,i *16);
  4660. }
  4661. }
  4662. Utils3D._computeAnimationDatasByArrayAndMatrixFast=function(inverGlobalBindPose,bonesDatas,outAnimationDatas,boneIndexToMesh){
  4663. for (var i=0,n=inverGlobalBindPose.length;i < n;i++)
  4664. laya.d3.utils.Utils3D.mulMatrixByArrayAndMatrixFast(bonesDatas,boneIndexToMesh[i] *16,inverGlobalBindPose[i],outAnimationDatas,i *16);
  4665. }
  4666. Utils3D._computeBoneAndAnimationDatasByBindPoseMatrxixOld=function(bones,curData,inverGlobalBindPose,outBonesDatas,outAnimationDatas){
  4667. var offset=0;
  4668. var matOffset=0;
  4669. var i;
  4670. var parentOffset;
  4671. var boneLength=bones.length;
  4672. for (i=0;i < boneLength;offset+=bones[i].keyframeWidth,matOffset+=16,i++){
  4673. 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);
  4674. if (i !=0){
  4675. parentOffset=bones[i].parentIndex *16;
  4676. laya.d3.utils.Utils3D.mulMatrixByArray(outBonesDatas,parentOffset,outBonesDatas,matOffset,outBonesDatas,matOffset);
  4677. }
  4678. };
  4679. var n=inverGlobalBindPose.length;
  4680. for (i=0;i < n;i++){
  4681. var arrayOffset=i *16;
  4682. laya.d3.utils.Utils3D.mulMatrixByArrayAndMatrixFast(outBonesDatas,arrayOffset,inverGlobalBindPose[i],outAnimationDatas,arrayOffset);
  4683. }
  4684. }
  4685. Utils3D._computeAnimationDatasByArrayAndMatrixFastOld=function(inverGlobalBindPose,bonesDatas,outAnimationDatas){
  4686. var n=inverGlobalBindPose.length;
  4687. for (var i=0;i < n;i++){
  4688. var arrayOffset=i *16;
  4689. laya.d3.utils.Utils3D.mulMatrixByArrayAndMatrixFast(bonesDatas,arrayOffset,inverGlobalBindPose[i],outAnimationDatas,arrayOffset);
  4690. }
  4691. }
  4692. Utils3D._computeRootAnimationData=function(bones,curData,animationDatas){
  4693. for (var i=0,offset=0,matOffset=0,boneLength=bones.length;i < boneLength;offset+=bones[i].keyframeWidth,matOffset+=16,i++)
  4694. 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);
  4695. }
  4696. Utils3D.transformVector3ArrayByQuat=function(sourceArray,sourceOffset,rotation,outArray,outOffset){
  4697. 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;
  4698. outArray[outOffset]=ix *qw+iw *-qx+iy *-qz-iz *-qy;
  4699. outArray[outOffset+1]=iy *qw+iw *-qy+iz *-qx-ix *-qz;
  4700. outArray[outOffset+2]=iz *qw+iw *-qz+ix *-qy-iy *-qx;
  4701. }
  4702. Utils3D.mulMatrixByArray=function(leftArray,leftOffset,rightArray,rightOffset,outArray,outOffset){
  4703. var i,ai0,ai1,ai2,ai3;
  4704. if (outArray===rightArray){
  4705. rightArray=Utils3D._tempArray16_3;
  4706. for (i=0;i < 16;++i){
  4707. rightArray[i]=outArray[outOffset+i];
  4708. }
  4709. rightOffset=0;
  4710. }
  4711. for (i=0;i < 4;i++){
  4712. ai0=leftArray[leftOffset+i];
  4713. ai1=leftArray[leftOffset+i+4];
  4714. ai2=leftArray[leftOffset+i+8];
  4715. ai3=leftArray[leftOffset+i+12];
  4716. outArray[outOffset+i]=ai0 *rightArray[rightOffset+0]+ai1 *rightArray[rightOffset+1]+ai2 *rightArray[rightOffset+2]+ai3 *rightArray[rightOffset+3];
  4717. outArray[outOffset+i+4]=ai0 *rightArray[rightOffset+4]+ai1 *rightArray[rightOffset+5]+ai2 *rightArray[rightOffset+6]+ai3 *rightArray[rightOffset+7];
  4718. outArray[outOffset+i+8]=ai0 *rightArray[rightOffset+8]+ai1 *rightArray[rightOffset+9]+ai2 *rightArray[rightOffset+10]+ai3 *rightArray[rightOffset+11];
  4719. outArray[outOffset+i+12]=ai0 *rightArray[rightOffset+12]+ai1 *rightArray[rightOffset+13]+ai2 *rightArray[rightOffset+14]+ai3 *rightArray[rightOffset+15];
  4720. }
  4721. }
  4722. Utils3D.mulMatrixByArrayFast=function(leftArray,leftOffset,rightArray,rightOffset,outArray,outOffset){
  4723. var i,ai0,ai1,ai2,ai3;
  4724. for (i=0;i < 4;i++){
  4725. ai0=leftArray[leftOffset+i];
  4726. ai1=leftArray[leftOffset+i+4];
  4727. ai2=leftArray[leftOffset+i+8];
  4728. ai3=leftArray[leftOffset+i+12];
  4729. outArray[outOffset+i]=ai0 *rightArray[rightOffset+0]+ai1 *rightArray[rightOffset+1]+ai2 *rightArray[rightOffset+2]+ai3 *rightArray[rightOffset+3];
  4730. outArray[outOffset+i+4]=ai0 *rightArray[rightOffset+4]+ai1 *rightArray[rightOffset+5]+ai2 *rightArray[rightOffset+6]+ai3 *rightArray[rightOffset+7];
  4731. outArray[outOffset+i+8]=ai0 *rightArray[rightOffset+8]+ai1 *rightArray[rightOffset+9]+ai2 *rightArray[rightOffset+10]+ai3 *rightArray[rightOffset+11];
  4732. outArray[outOffset+i+12]=ai0 *rightArray[rightOffset+12]+ai1 *rightArray[rightOffset+13]+ai2 *rightArray[rightOffset+14]+ai3 *rightArray[rightOffset+15];
  4733. }
  4734. }
  4735. Utils3D.mulMatrixByArrayAndMatrixFast=function(leftArray,leftOffset,rightMatrix,outArray,outOffset){
  4736. var i,ai0,ai1,ai2,ai3;
  4737. var rightMatrixE=rightMatrix.elements;
  4738. var m11=rightMatrixE[0],m12=rightMatrixE[1],m13=rightMatrixE[2],m14=rightMatrixE[3];
  4739. var m21=rightMatrixE[4],m22=rightMatrixE[5],m23=rightMatrixE[6],m24=rightMatrixE[7];
  4740. var m31=rightMatrixE[8],m32=rightMatrixE[9],m33=rightMatrixE[10],m34=rightMatrixE[11];
  4741. var m41=rightMatrixE[12],m42=rightMatrixE[13],m43=rightMatrixE[14],m44=rightMatrixE[15];
  4742. var ai0LeftOffset=leftOffset;
  4743. var ai1LeftOffset=leftOffset+4;
  4744. var ai2LeftOffset=leftOffset+8;
  4745. var ai3LeftOffset=leftOffset+12;
  4746. var ai0OutOffset=outOffset;
  4747. var ai1OutOffset=outOffset+4;
  4748. var ai2OutOffset=outOffset+8;
  4749. var ai3OutOffset=outOffset+12;
  4750. for (i=0;i < 4;i++){
  4751. ai0=leftArray[ai0LeftOffset+i];
  4752. ai1=leftArray[ai1LeftOffset+i];
  4753. ai2=leftArray[ai2LeftOffset+i];
  4754. ai3=leftArray[ai3LeftOffset+i];
  4755. outArray[ai0OutOffset+i]=ai0 *m11+ai1 *m12+ai2 *m13+ai3 *m14;
  4756. outArray[ai1OutOffset+i]=ai0 *m21+ai1 *m22+ai2 *m23+ai3 *m24;
  4757. outArray[ai2OutOffset+i]=ai0 *m31+ai1 *m32+ai2 *m33+ai3 *m34;
  4758. outArray[ai3OutOffset+i]=ai0 *m41+ai1 *m42+ai2 *m43+ai3 *m44;
  4759. }
  4760. }
  4761. Utils3D.createAffineTransformationArray=function(tX,tY,tZ,rX,rY,rZ,rW,sX,sY,sZ,outArray,outOffset){
  4762. var x2=rX+rX,y2=rY+rY,z2=rZ+rZ;
  4763. var xx=rX *x2,xy=rX *y2,xz=rX *z2,yy=rY *y2,yz=rY *z2,zz=rZ *z2;
  4764. var wx=rW *x2,wy=rW *y2,wz=rW *z2;
  4765. outArray[outOffset+0]=(1-(yy+zz))*sX;
  4766. outArray[outOffset+1]=(xy+wz)*sX;
  4767. outArray[outOffset+2]=(xz-wy)*sX;
  4768. outArray[outOffset+3]=0;
  4769. outArray[outOffset+4]=(xy-wz)*sY;
  4770. outArray[outOffset+5]=(1-(xx+zz))*sY;
  4771. outArray[outOffset+6]=(yz+wx)*sY;
  4772. outArray[outOffset+7]=0;
  4773. outArray[outOffset+8]=(xz+wy)*sZ;
  4774. outArray[outOffset+9]=(yz-wx)*sZ;
  4775. outArray[outOffset+10]=(1-(xx+yy))*sZ;
  4776. outArray[outOffset+11]=0;
  4777. outArray[outOffset+12]=tX;
  4778. outArray[outOffset+13]=tY;
  4779. outArray[outOffset+14]=tZ;
  4780. outArray[outOffset+15]=1;
  4781. }
  4782. Utils3D.transformVector3ArrayToVector3ArrayCoordinate=function(source,sourceOffset,transform,result,resultOffset){
  4783. var coordinateX=source[sourceOffset+0];
  4784. var coordinateY=source[sourceOffset+1];
  4785. var coordinateZ=source[sourceOffset+2];
  4786. var transformElem=transform.elements;
  4787. var w=((coordinateX *transformElem[3])+(coordinateY *transformElem[7])+(coordinateZ *transformElem[11])+transformElem[15]);
  4788. result[resultOffset]=(coordinateX *transformElem[0])+(coordinateY *transformElem[4])+(coordinateZ *transformElem[8])+transformElem[12] / w;
  4789. result[resultOffset+1]=(coordinateX *transformElem[1])+(coordinateY *transformElem[5])+(coordinateZ *transformElem[9])+transformElem[13] / w;
  4790. result[resultOffset+2]=(coordinateX *transformElem[2])+(coordinateY *transformElem[6])+(coordinateZ *transformElem[10])+transformElem[14] / w;
  4791. }
  4792. Utils3D.transformLightingMapTexcoordArray=function(source,sourceOffset,lightingMapScaleOffset,result,resultOffset){
  4793. result[resultOffset+0]=source[sourceOffset+0] *lightingMapScaleOffset.x+lightingMapScaleOffset.z;
  4794. result[resultOffset+1]=1.0-((1.0-source[sourceOffset+1])*lightingMapScaleOffset.y+lightingMapScaleOffset.w);
  4795. }
  4796. Utils3D.getURLVerion=function(url){
  4797. var index=url.indexOf("?");
  4798. return index >=0 ? url.substr(index):null;
  4799. }
  4800. Utils3D._createAffineTransformationArray=function(trans,rot,scale,outE){
  4801. var x=rot.x,y=rot.y,z=rot.z,w=rot.w,x2=x+x,y2=y+y,z2=z+z;
  4802. var xx=x *x2,xy=x *y2,xz=x *z2,yy=y *y2,yz=y *z2,zz=z *z2;
  4803. var wx=w *x2,wy=w *y2,wz=w *z2,sx=scale.x,sy=scale.y,sz=scale.z;
  4804. outE[0]=(1-(yy+zz))*sx;
  4805. outE[1]=(xy+wz)*sx;
  4806. outE[2]=(xz-wy)*sx;
  4807. outE[3]=0;
  4808. outE[4]=(xy-wz)*sy;
  4809. outE[5]=(1-(xx+zz))*sy;
  4810. outE[6]=(yz+wx)*sy;
  4811. outE[7]=0;
  4812. outE[8]=(xz+wy)*sz;
  4813. outE[9]=(yz-wx)*sz;
  4814. outE[10]=(1-(xx+yy))*sz;
  4815. outE[11]=0;
  4816. outE[12]=trans.x;
  4817. outE[13]=trans.y;
  4818. outE[14]=trans.z;
  4819. outE[15]=1;
  4820. }
  4821. Utils3D._mulMatrixArray=function(leftMatrixE,rightMatrix,outArray,outOffset){
  4822. var i,ai0,ai1,ai2,ai3;
  4823. var rightMatrixE=rightMatrix.elements;
  4824. var m11=rightMatrixE[0],m12=rightMatrixE[1],m13=rightMatrixE[2],m14=rightMatrixE[3];
  4825. var m21=rightMatrixE[4],m22=rightMatrixE[5],m23=rightMatrixE[6],m24=rightMatrixE[7];
  4826. var m31=rightMatrixE[8],m32=rightMatrixE[9],m33=rightMatrixE[10],m34=rightMatrixE[11];
  4827. var m41=rightMatrixE[12],m42=rightMatrixE[13],m43=rightMatrixE[14],m44=rightMatrixE[15];
  4828. var ai0OutOffset=outOffset;
  4829. var ai1OutOffset=outOffset+4;
  4830. var ai2OutOffset=outOffset+8;
  4831. var ai3OutOffset=outOffset+12;
  4832. for (i=0;i < 4;i++){
  4833. ai0=leftMatrixE[i];
  4834. ai1=leftMatrixE[i+4];
  4835. ai2=leftMatrixE[i+8];
  4836. ai3=leftMatrixE[i+12];
  4837. outArray[ai0OutOffset+i]=ai0 *m11+ai1 *m12+ai2 *m13+ai3 *m14;
  4838. outArray[ai1OutOffset+i]=ai0 *m21+ai1 *m22+ai2 *m23+ai3 *m24;
  4839. outArray[ai2OutOffset+i]=ai0 *m31+ai1 *m32+ai2 *m33+ai3 *m34;
  4840. outArray[ai3OutOffset+i]=ai0 *m41+ai1 *m42+ai2 *m43+ai3 *m44;
  4841. }
  4842. }
  4843. Utils3D.arcTanAngle=function(x,y){
  4844. if (x==0){
  4845. if (y==1)
  4846. return Math.PI / 2;
  4847. return-Math.PI / 2;
  4848. }
  4849. if (x > 0)
  4850. return Math.atan(y / x);
  4851. if (x < 0){
  4852. if (y > 0)
  4853. return Math.atan(y / x)+Math.PI;
  4854. return Math.atan(y / x)-Math.PI;
  4855. }
  4856. return 0;
  4857. }
  4858. Utils3D.angleTo=function(from,location,angle){
  4859. Vector3.subtract(location,from,Quaternion.TEMPVector30);
  4860. Vector3.normalize(Quaternion.TEMPVector30,Quaternion.TEMPVector30);
  4861. angle.x=Math.asin(Quaternion.TEMPVector30.y);
  4862. angle.y=Utils3D.arcTanAngle(-Quaternion.TEMPVector30.z,-Quaternion.TEMPVector30.x);
  4863. }
  4864. Utils3D.transformQuat=function(source,rotation,out){
  4865. var re=rotation;
  4866. var x=source.x,y=source.y,z=source.z,qx=re[0],qy=re[1],qz=re[2],qw=re[3],
  4867. 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;
  4868. out.x=ix *qw+iw *-qx+iy *-qz-iz *-qy;
  4869. out.y=iy *qw+iw *-qy+iz *-qx-ix *-qz;
  4870. out.z=iz *qw+iw *-qz+ix *-qy-iy *-qx;
  4871. }
  4872. Utils3D.quaternionWeight=function(f,weight,e){
  4873. e.x=f.x *weight;
  4874. e.y=f.y *weight;
  4875. e.z=f.z *weight;
  4876. e.w=f.w;
  4877. }
  4878. Utils3D.quaternionConjugate=function(value,result){
  4879. result.x=-value.x;
  4880. result.y=-value.y;
  4881. result.z=-value.z;
  4882. result.w=value.w;
  4883. }
  4884. Utils3D.scaleWeight=function(s,w,out){
  4885. var sX=s.x,sY=s.y,sZ=s.z;
  4886. out.x=sX > 0 ? Math.pow(Math.abs(sX),w):-Math.pow(Math.abs(sX),w);
  4887. out.y=sY > 0 ? Math.pow(Math.abs(sY),w):-Math.pow(Math.abs(sY),w);
  4888. out.z=sZ > 0 ? Math.pow(Math.abs(sZ),w):-Math.pow(Math.abs(sZ),w);
  4889. }
  4890. Utils3D.scaleBlend=function(sa,sb,w,out){
  4891. var saw=Utils3D._tempVector3_0;
  4892. var sbw=Utils3D._tempVector3_1;
  4893. Utils3D.scaleWeight(sa,1.0-w,saw);
  4894. Utils3D.scaleWeight(sb,w,sbw);
  4895. var sng=w > 0.5 ? sb :sa;
  4896. out.x=sng.x > 0 ? Math.abs(saw.x *sbw.x):-Math.abs(saw.x *sbw.x);
  4897. out.y=sng.y > 0 ? Math.abs(saw.y *sbw.y):-Math.abs(saw.y *sbw.y);
  4898. out.z=sng.z > 0 ? Math.abs(saw.z *sbw.z):-Math.abs(saw.z *sbw.z);
  4899. }
  4900. Utils3D.gammaToLinearSpace=function(value){
  4901. if (value <=0.04045)
  4902. return value / 12.92;
  4903. else if (value < 1.0)
  4904. return Math.pow((value+0.055)/ 1.055,2.4);
  4905. else
  4906. return Math.pow(value,2.4);
  4907. }
  4908. Utils3D.linearToGammaSpace=function(value){
  4909. if (value <=0.0)
  4910. return 0.0;
  4911. else if (value <=0.0031308)
  4912. return 12.92 *value;
  4913. else if (value <=1.0)
  4914. return 1.055 *Math.pow(value,0.41666)-0.055;
  4915. else
  4916. return Math.pow(value,0.41666);
  4917. }
  4918. Utils3D.matrix4x4MultiplyFFF=function(a,b,e){
  4919. var i,ai0,ai1,ai2,ai3;
  4920. if (e===b){
  4921. b=new Float32Array(16);
  4922. for (i=0;i < 16;++i){
  4923. b[i]=e[i];
  4924. }
  4925. };
  4926. var b0=b[0],b1=b[1],b2=b[2],b3=b[3];
  4927. var b4=b[4],b5=b[5],b6=b[6],b7=b[7];
  4928. var b8=b[8],b9=b[9],b10=b[10],b11=b[11];
  4929. var b12=b[12],b13=b[13],b14=b[14],b15=b[15];
  4930. for (i=0;i < 4;i++){
  4931. ai0=a[i];
  4932. ai1=a[i+4];
  4933. ai2=a[i+8];
  4934. ai3=a[i+12];
  4935. e[i]=ai0 *b0+ai1 *b1+ai2 *b2+ai3 *b3;
  4936. e[i+4]=ai0 *b4+ai1 *b5+ai2 *b6+ai3 *b7;
  4937. e[i+8]=ai0 *b8+ai1 *b9+ai2 *b10+ai3 *b11;
  4938. e[i+12]=ai0 *b12+ai1 *b13+ai2 *b14+ai3 *b15;
  4939. }
  4940. }
  4941. Utils3D.matrix4x4MultiplyFFFForNative=function(a,b,e){
  4942. LayaGL.instance.matrix4x4Multiply(a,b,e);
  4943. }
  4944. Utils3D.matrix4x4MultiplyMFM=function(left,right,out){
  4945. Utils3D.matrix4x4MultiplyFFF(left.elements,right,out.elements);
  4946. }
  4947. Utils3D._buildTexture2D=function(width,height,format,colorFunc,mipmaps){
  4948. (mipmaps===void 0)&& (mipmaps=false);
  4949. var texture=new Texture2D(width,height,format,mipmaps,true);
  4950. texture.anisoLevel=1;
  4951. texture.filterMode=/*laya.resource.BaseTexture.FILTERMODE_POINT*/0;
  4952. TextureGenerator._generateTexture2D(texture,width,height,colorFunc);
  4953. return texture;
  4954. }
  4955. Utils3D._drawBound=function(debugLine,boundBox,color){
  4956. if (debugLine.lineCount+12 > debugLine.maxLineCount)
  4957. debugLine.maxLineCount+=12;
  4958. var start=Utils3D._tempVector3_0;
  4959. var end=Utils3D._tempVector3_1;
  4960. var min=boundBox.min;
  4961. var max=boundBox.max;
  4962. start.setValue(min.x,min.y,min.z);
  4963. end.setValue(max.x,min.y,min.z);
  4964. debugLine.addLine(start,end,color,color);
  4965. start.setValue(min.x,min.y,min.z);
  4966. end.setValue(min.x,min.y,max.z);
  4967. debugLine.addLine(start,end,color,color);
  4968. start.setValue(max.x,min.y,min.z);
  4969. end.setValue(max.x,min.y,max.z);
  4970. debugLine.addLine(start,end,color,color);
  4971. start.setValue(min.x,min.y,max.z);
  4972. end.setValue(max.x,min.y,max.z);
  4973. debugLine.addLine(start,end,color,color);
  4974. start.setValue(min.x,min.y,min.z);
  4975. end.setValue(min.x,max.y,min.z);
  4976. debugLine.addLine(start,end,color,color);
  4977. start.setValue(min.x,min.y,max.z);
  4978. end.setValue(min.x,max.y,max.z);
  4979. debugLine.addLine(start,end,color,color);
  4980. start.setValue(max.x,min.y,min.z);
  4981. end.setValue(max.x,max.y,min.z);
  4982. debugLine.addLine(start,end,color,color);
  4983. start.setValue(max.x,min.y,max.z);
  4984. end.setValue(max.x,max.y,max.z);
  4985. debugLine.addLine(start,end,color,color);
  4986. start.setValue(min.x,max.y,min.z);
  4987. end.setValue(max.x,max.y,min.z);
  4988. debugLine.addLine(start,end,color,color);
  4989. start.setValue(min.x,max.y,min.z);
  4990. end.setValue(min.x,max.y,max.z);
  4991. debugLine.addLine(start,end,color,color);
  4992. start.setValue(max.x,max.y,min.z);
  4993. end.setValue(max.x,max.y,max.z);
  4994. debugLine.addLine(start,end,color,color);
  4995. start.setValue(min.x,max.y,max.z);
  4996. end.setValue(max.x,max.y,max.z);
  4997. debugLine.addLine(start,end,color,color);
  4998. }
  4999. Utils3D._getHierarchyPath=function(rootSprite,checkSprite,path){
  5000. path.length=0;
  5001. var sprite=checkSprite;
  5002. while (sprite!==rootSprite){
  5003. var parent=sprite._parent;
  5004. if (parent)
  5005. path.push(parent.getChildIndex(sprite));
  5006. else
  5007. return null;
  5008. sprite=parent;
  5009. }
  5010. return path;
  5011. }
  5012. Utils3D._getNodeByHierarchyPath=function(rootSprite,invPath){
  5013. var sprite=rootSprite;
  5014. for (var i=invPath.length-1;i >=0;i--){
  5015. sprite=sprite.getChildAt(invPath[i]);
  5016. }
  5017. return sprite;
  5018. }
  5019. Utils3D._createNodeByJson=function(nodeData,outBatchSprites){
  5020. var node;
  5021. switch (nodeData.type){
  5022. case "Scene3D":
  5023. node=new Scene3D();
  5024. break ;
  5025. case "Sprite3D":
  5026. node=new Sprite3D();
  5027. break ;
  5028. case "MeshSprite3D":
  5029. node=new MeshSprite3D();
  5030. (outBatchSprites)&& (outBatchSprites.push(node));
  5031. break ;
  5032. case "SkinnedMeshSprite3D":
  5033. node=new SkinnedMeshSprite3D();
  5034. break ;
  5035. case "ShuriKenParticle3D":
  5036. node=new ShuriKenParticle3D();
  5037. break ;
  5038. case "Terrain":
  5039. node=new Terrain();
  5040. break ;
  5041. case "Camera":
  5042. node=new Camera();
  5043. break ;
  5044. case "DirectionLight":
  5045. node=new DirectionLight();
  5046. break ;
  5047. case "PointLight":
  5048. node=new PointLight();
  5049. break ;
  5050. case "SpotLight":
  5051. node=new SpotLight();
  5052. break ;
  5053. case "TrailSprite3D":
  5054. node=new TrailSprite3D();
  5055. break ;
  5056. default :
  5057. throw new Error("Utils3D:unidentified class type in (.lh) file.");
  5058. };
  5059. var childData=nodeData.child;
  5060. if (childData){
  5061. for (var i=0,n=childData.length;i < n;i++){
  5062. var child=Utils3D._createNodeByJson(childData[i],outBatchSprites)
  5063. node.addChild(child);
  5064. }
  5065. };
  5066. var componentsData=nodeData.components;
  5067. if (componentsData){
  5068. for (var j=0,m=componentsData.length;j < m;j++){
  5069. var data=componentsData[j];
  5070. clas=Browser.window.Laya[data.type];
  5071. if (!clas){
  5072. var clasPaths=data.type.split('.');
  5073. var clas=Browser.window;
  5074. clasPaths.forEach(function(cls){
  5075. clas=clas[cls];
  5076. });
  5077. }
  5078. if (typeof(clas)=='function'){
  5079. var component=node.addComponent(clas);
  5080. component._parse(data);
  5081. }else {
  5082. console.warn("Unkown component type.");
  5083. }
  5084. }
  5085. }
  5086. node._parse(nodeData.props,null);
  5087. return node;
  5088. }
  5089. Utils3D._tempArray16_0=new Float32Array(16);
  5090. Utils3D._tempArray16_1=new Float32Array(16);
  5091. Utils3D._tempArray16_2=new Float32Array(16);
  5092. Utils3D._tempArray16_3=new Float32Array(16);
  5093. __static(Utils3D,
  5094. ['_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();}
  5095. ]);
  5096. return Utils3D;
  5097. })()
  5098. /**
  5099. *<code>VelocityOverLifetime</code> 类用于粒子的生命周期速度。
  5100. */
  5101. //class laya.d3.core.particleShuriKen.module.VelocityOverLifetime
  5102. var VelocityOverLifetime=(function(){
  5103. function VelocityOverLifetime(velocity){
  5104. /**@private */
  5105. this._velocity=null;
  5106. /**是否启用*/
  5107. this.enbale=false;
  5108. /**速度空间,0为local,1为world。*/
  5109. this.space=0;
  5110. this._velocity=velocity;
  5111. }
  5112. __class(VelocityOverLifetime,'laya.d3.core.particleShuriKen.module.VelocityOverLifetime');
  5113. var __proto=VelocityOverLifetime.prototype;
  5114. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  5115. /**
  5116. *克隆。
  5117. *@param destObject 克隆源。
  5118. */
  5119. __proto.cloneTo=function(destObject){
  5120. var destVelocityOverLifetime=destObject;
  5121. this._velocity.cloneTo(destVelocityOverLifetime._velocity);
  5122. destVelocityOverLifetime.enbale=this.enbale;
  5123. destVelocityOverLifetime.space=this.space;
  5124. }
  5125. /**
  5126. *克隆。
  5127. *@return 克隆副本。
  5128. */
  5129. __proto.clone=function(){
  5130. var destVelocity;
  5131. switch(this._velocity.type){
  5132. case 0:
  5133. destVelocity=GradientVelocity.createByConstant(this._velocity.constant.clone());
  5134. break ;
  5135. case 1:
  5136. destVelocity=GradientVelocity.createByGradient(this._velocity.gradientX.clone(),this._velocity.gradientY.clone(),this._velocity.gradientZ.clone());
  5137. break ;
  5138. case 2:
  5139. destVelocity=GradientVelocity.createByRandomTwoConstant(this._velocity.constantMin.clone(),this._velocity.constantMax.clone());
  5140. break ;
  5141. case 3:
  5142. 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());
  5143. break ;
  5144. };
  5145. var destVelocityOverLifetime=/*__JS__ */new this.constructor(destVelocity);
  5146. destVelocityOverLifetime.enbale=this.enbale;
  5147. destVelocityOverLifetime.space=this.space;
  5148. return destVelocityOverLifetime;
  5149. }
  5150. /**
  5151. *获取尺寸。
  5152. */
  5153. __getset(0,__proto,'velocity',function(){
  5154. return this._velocity;
  5155. });
  5156. return VelocityOverLifetime;
  5157. })()
  5158. /**
  5159. *<code>TrailFilter</code> 类用于创建拖尾过滤器。
  5160. */
  5161. //class laya.d3.core.trail.TrailFilter
  5162. var TrailFilter=(function(){
  5163. function TrailFilter(owner){
  5164. /**@private */
  5165. this._minVertexDistance=NaN;
  5166. /**@private */
  5167. this._widthMultiplier=NaN;
  5168. /**@private */
  5169. this._time=NaN;
  5170. /**@private */
  5171. this._widthCurve=null;
  5172. /**@private */
  5173. this._colorGradient=null;
  5174. /**@private */
  5175. this._textureMode=0;
  5176. /**@private */
  5177. this._trialGeometry=null;
  5178. /**@private 拖尾总长度*/
  5179. this._totalLength=0;
  5180. this._owner=null;
  5181. this._curtime=0;
  5182. this._trailRenderElementIndex=0;
  5183. this._lastPosition=new Vector3();
  5184. this.alignment=0;
  5185. this._owner=owner;
  5186. this._initDefaultData();
  5187. this.addRenderElement();
  5188. }
  5189. __class(TrailFilter,'laya.d3.core.trail.TrailFilter');
  5190. var __proto=TrailFilter.prototype;
  5191. /**
  5192. *@private
  5193. */
  5194. __proto.addRenderElement=function(){
  5195. var render=this._owner._render;
  5196. var elements=render._renderElements;
  5197. var material=render.sharedMaterials [0];
  5198. (material)|| (material=TrailMaterial.defaultMaterial);
  5199. var element=new RenderElement();
  5200. element.setTransform(this._owner._transform);
  5201. element.render=render;
  5202. element.material=material;
  5203. this._trialGeometry=new TrailGeometry(this);
  5204. element.setGeometry(this._trialGeometry);
  5205. elements.push(element);
  5206. }
  5207. /**
  5208. *@private
  5209. */
  5210. __proto._update=function(state){
  5211. var render=this._owner._render;
  5212. this._curtime+=(state.scene).timer._delta / 1000;
  5213. render._shaderValues.setNumber(TrailSprite3D.CURTIME,this._curtime);
  5214. var curPos=this._owner.transform.position;
  5215. var element=render._renderElements[0] ._geometry;
  5216. element._updateDisappear();
  5217. element._updateTrail(state.camera,this._lastPosition,curPos);
  5218. element._updateVertexBufferUV();
  5219. curPos.cloneTo(this._lastPosition);
  5220. }
  5221. /**
  5222. *@private
  5223. */
  5224. __proto._initDefaultData=function(){
  5225. this.time=5.0;
  5226. this.minVertexDistance=0.1;
  5227. this.widthMultiplier=1;
  5228. this.textureMode=/*laya.d3.core.TextureMode.Stretch*/0;
  5229. var widthKeyFrames=[];
  5230. var widthKeyFrame1=new FloatKeyframe();
  5231. widthKeyFrame1.time=0;
  5232. widthKeyFrame1.inTangent=0;
  5233. widthKeyFrame1.outTangent=0;
  5234. widthKeyFrame1.value=1;
  5235. widthKeyFrames.push(widthKeyFrame1);
  5236. var widthKeyFrame2=new FloatKeyframe();
  5237. widthKeyFrame2.time=1;
  5238. widthKeyFrame2.inTangent=0;
  5239. widthKeyFrame2.outTangent=0;
  5240. widthKeyFrame2.value=1;
  5241. widthKeyFrames.push(widthKeyFrame2);
  5242. this.widthCurve=widthKeyFrames;
  5243. var gradient=new Gradient(2,2);
  5244. gradient.mode=/*laya.d3.core.GradientMode.Blend*/0;
  5245. gradient.addColorRGB(0,Color.WHITE);
  5246. gradient.addColorRGB(1,Color.WHITE);
  5247. gradient.addColorAlpha(0,1);
  5248. gradient.addColorAlpha(1,1);
  5249. this.colorGradient=gradient;
  5250. }
  5251. /**
  5252. *@private
  5253. */
  5254. __proto.destroy=function(){
  5255. this._trialGeometry.destroy();
  5256. this._trialGeometry=null;
  5257. this._widthCurve=null;
  5258. this._colorGradient=null;
  5259. }
  5260. /**
  5261. *设置宽度倍数。
  5262. *@param value 宽度倍数。
  5263. */
  5264. /**
  5265. *获取宽度倍数。
  5266. *@return 宽度倍数。
  5267. */
  5268. __getset(0,__proto,'widthMultiplier',function(){
  5269. return this._widthMultiplier;
  5270. },function(value){
  5271. this._widthMultiplier=value;
  5272. });
  5273. /**
  5274. *设置淡出时间。
  5275. *@param value 淡出时间。
  5276. */
  5277. /**
  5278. *获取淡出时间。
  5279. *@return 淡出时间。
  5280. */
  5281. __getset(0,__proto,'time',function(){
  5282. return this._time;
  5283. },function(value){
  5284. this._time=value;
  5285. this._owner._render._shaderValues.setNumber(TrailSprite3D.LIFETIME,value);
  5286. });
  5287. /**
  5288. *设置宽度曲线。
  5289. *@param value 宽度曲线。
  5290. */
  5291. /**
  5292. *获取宽度曲线。
  5293. *@return 宽度曲线。
  5294. */
  5295. __getset(0,__proto,'widthCurve',function(){
  5296. return this._widthCurve;
  5297. },function(value){
  5298. this._widthCurve=value;
  5299. var widthCurveFloatArray=new Float32Array(value.length *4);
  5300. var i=0,j=0,index=0;
  5301. for (i=0,j=value.length;i < j;i++){
  5302. widthCurveFloatArray[index++]=value[i].time;
  5303. widthCurveFloatArray[index++]=value[i].inTangent;
  5304. widthCurveFloatArray[index++]=value[i].outTangent;
  5305. widthCurveFloatArray[index++]=value[i].value;
  5306. }
  5307. this._owner._render._shaderValues.setBuffer(TrailSprite3D.WIDTHCURVE,widthCurveFloatArray);
  5308. this._owner._render._shaderValues.setInt(TrailSprite3D.WIDTHCURVEKEYLENGTH,value.length);
  5309. });
  5310. /**
  5311. *设置新旧顶点之间最小距离。
  5312. *@param value 新旧顶点之间最小距离。
  5313. */
  5314. /**
  5315. *获取新旧顶点之间最小距离。
  5316. *@return 新旧顶点之间最小距离。
  5317. */
  5318. __getset(0,__proto,'minVertexDistance',function(){
  5319. return this._minVertexDistance;
  5320. },function(value){
  5321. this._minVertexDistance=value;
  5322. });
  5323. /**
  5324. *设置颜色梯度。
  5325. *@param value 颜色梯度。
  5326. */
  5327. /**
  5328. *获取颜色梯度。
  5329. *@return 颜色梯度。
  5330. */
  5331. __getset(0,__proto,'colorGradient',function(){
  5332. return this._colorGradient;
  5333. },function(value){
  5334. this._colorGradient=value;
  5335. this._owner._render._shaderValues.setBuffer(TrailSprite3D.GRADIENTCOLORKEY,value._rgbElements);
  5336. this._owner._render._shaderValues.setBuffer(TrailSprite3D.GRADIENTALPHAKEY,value._alphaElements);
  5337. if (value.mode==/*laya.d3.core.GradientMode.Blend*/0){
  5338. this._owner._render._defineDatas.add(TrailSprite3D.SHADERDEFINE_GRADIENTMODE_BLEND);
  5339. }else {
  5340. this._owner._render._defineDatas.remove(TrailSprite3D.SHADERDEFINE_GRADIENTMODE_BLEND);
  5341. }
  5342. });
  5343. /**
  5344. *设置纹理模式。
  5345. *@param value 纹理模式。
  5346. */
  5347. /**
  5348. *获取纹理模式。
  5349. *@return 纹理模式。
  5350. */
  5351. __getset(0,__proto,'textureMode',function(){
  5352. return this._textureMode;
  5353. },function(value){
  5354. this._textureMode=value;
  5355. });
  5356. TrailFilter.ALIGNMENT_VIEW=0;
  5357. TrailFilter.ALIGNMENT_TRANSFORM_Z=1;
  5358. return TrailFilter;
  5359. })()
  5360. /**
  5361. *<code>CollisionMap</code> 类用于实现碰撞组合实例图。
  5362. */
  5363. //class laya.d3.physics.CollisionTool
  5364. var CollisionTool=(function(){
  5365. function CollisionTool(){
  5366. /**@private */
  5367. this._hitResultsPoolIndex=0;
  5368. /**@private */
  5369. this._contactPonintsPoolIndex=0;
  5370. /**@private */
  5371. this._collisions={};
  5372. this._hitResultsPool=[];
  5373. this._contactPointsPool=[];
  5374. this._collisionsPool=[];
  5375. }
  5376. __class(CollisionTool,'laya.d3.physics.CollisionTool');
  5377. var __proto=CollisionTool.prototype;
  5378. /**
  5379. *@private
  5380. */
  5381. __proto.getHitResult=function(){
  5382. var hitResult=this._hitResultsPool[this._hitResultsPoolIndex++];
  5383. if (!hitResult){
  5384. hitResult=new HitResult();
  5385. this._hitResultsPool.push(hitResult);
  5386. }
  5387. return hitResult;
  5388. }
  5389. /**
  5390. *@private
  5391. */
  5392. __proto.recoverAllHitResultsPool=function(){
  5393. this._hitResultsPoolIndex=0;
  5394. }
  5395. /**
  5396. *@private
  5397. */
  5398. __proto.getContactPoints=function(){
  5399. var contactPoint=this._contactPointsPool[this._contactPonintsPoolIndex++];
  5400. if (!contactPoint){
  5401. contactPoint=new ContactPoint();
  5402. this._contactPointsPool.push(contactPoint);
  5403. }
  5404. return contactPoint;
  5405. }
  5406. /**
  5407. *@private
  5408. */
  5409. __proto.recoverAllContactPointsPool=function(){
  5410. this._contactPonintsPoolIndex=0;
  5411. }
  5412. /**
  5413. *@private
  5414. */
  5415. __proto.getCollision=function(physicComponentA,physicComponentB){
  5416. var collision;
  5417. var idA=physicComponentA.id;
  5418. var idB=physicComponentB.id;
  5419. var subCollisionFirst=this._collisions[idA];
  5420. if (subCollisionFirst)
  5421. collision=subCollisionFirst[idB];
  5422. if (!collision){
  5423. if (!subCollisionFirst){
  5424. subCollisionFirst={};
  5425. this._collisions[idA]=subCollisionFirst;
  5426. }
  5427. collision=this._collisionsPool.length===0 ? new Collision():this._collisionsPool.pop();
  5428. collision._colliderA=physicComponentA;
  5429. collision._colliderB=physicComponentB;
  5430. subCollisionFirst[idB]=collision;
  5431. }
  5432. return collision;
  5433. }
  5434. /**
  5435. *@private
  5436. */
  5437. __proto.recoverCollision=function(collision){
  5438. var idA=collision._colliderA.id;
  5439. var idB=collision._colliderB.id;
  5440. this._collisions[idA][idB]=null;
  5441. this._collisionsPool.push(collision);
  5442. }
  5443. /**
  5444. *@private
  5445. */
  5446. __proto.garbageCollection=function(){
  5447. this._hitResultsPoolIndex=0;
  5448. this._hitResultsPool.length=0;
  5449. this._contactPonintsPoolIndex=0;
  5450. this._contactPointsPool.length=0;
  5451. this._collisionsPool.length=0;
  5452. for (var subCollisionsKey in this._collisionsPool){
  5453. var subCollisions=this._collisionsPool[subCollisionsKey];
  5454. var wholeDelete=true;
  5455. for (var collisionKey in subCollisions){
  5456. if (subCollisions[collisionKey])
  5457. wholeDelete=false;
  5458. else
  5459. delete subCollisions[collisionKey];
  5460. }
  5461. if (wholeDelete)
  5462. delete this._collisionsPool[subCollisionsKey];
  5463. }
  5464. }
  5465. return CollisionTool;
  5466. })()
  5467. /**
  5468. *<code>VertexTrail</code> 类用于创建拖尾顶点结构。
  5469. */
  5470. //class laya.d3.core.trail.VertexTrail
  5471. var VertexTrail=(function(){
  5472. function VertexTrail(){}
  5473. __class(VertexTrail,'laya.d3.core.trail.VertexTrail');
  5474. var __proto=VertexTrail.prototype;
  5475. Laya.imps(__proto,{"laya.d3.graphics.IVertex":true})
  5476. __getset(0,__proto,'vertexDeclaration',function(){
  5477. return VertexTrail._vertexDeclaration1;
  5478. });
  5479. __getset(1,VertexTrail,'vertexDeclaration1',function(){
  5480. return VertexTrail._vertexDeclaration1;
  5481. });
  5482. __getset(1,VertexTrail,'vertexDeclaration2',function(){
  5483. return VertexTrail._vertexDeclaration2;
  5484. });
  5485. VertexTrail.TRAIL_POSITION0=0;
  5486. VertexTrail.TRAIL_OFFSETVECTOR=1;
  5487. VertexTrail.TRAIL_TIME0=2;
  5488. VertexTrail.TRAIL_TEXTURECOORDINATE0Y=3;
  5489. VertexTrail.TRAIL_TEXTURECOORDINATE0X=4;
  5490. __static(VertexTrail,
  5491. ['_vertexDeclaration1',function(){return this._vertexDeclaration1=new VertexDeclaration(32,
  5492. [new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*CLASS CONST:laya.d3.core.trail.VertexTrail.TRAIL_POSITION0*/0),
  5493. new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*CLASS CONST:laya.d3.core.trail.VertexTrail.TRAIL_OFFSETVECTOR*/1),
  5494. new VertexElement(24,/*laya.d3.graphics.VertexElementFormat.Single*/"single",/*CLASS CONST:laya.d3.core.trail.VertexTrail.TRAIL_TIME0*/2),
  5495. 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,
  5496. [new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Single*/"single",/*CLASS CONST:laya.d3.core.trail.VertexTrail.TRAIL_TEXTURECOORDINATE0X*/4)]);}
  5497. ]);
  5498. return VertexTrail;
  5499. })()
  5500. /**
  5501. *...
  5502. *@author ...
  5503. */
  5504. //class laya.d3.graphics.VertexElementFormat
  5505. var VertexElementFormat=(function(){
  5506. function VertexElementFormat(){}
  5507. __class(VertexElementFormat,'laya.d3.graphics.VertexElementFormat');
  5508. VertexElementFormat.getElementInfos=function(element){
  5509. var info=VertexElementFormat._elementInfos[element];
  5510. if (info)
  5511. return info;
  5512. else
  5513. throw "VertexElementFormat: this vertexElementFormat is not implement.";
  5514. }
  5515. VertexElementFormat.Single="single";
  5516. VertexElementFormat.Vector2="vector2";
  5517. VertexElementFormat.Vector3="vector3";
  5518. VertexElementFormat.Vector4="vector4";
  5519. VertexElementFormat.Color="color";
  5520. VertexElementFormat.Byte4="byte4";
  5521. VertexElementFormat.Short2="short2";
  5522. VertexElementFormat.Short4="short4";
  5523. VertexElementFormat.NormalizedShort2="normalizedshort2";
  5524. VertexElementFormat.NormalizedShort4="normalizedshort4";
  5525. VertexElementFormat.HalfVector2="halfvector2";
  5526. VertexElementFormat.HalfVector4="halfvector4";
  5527. __static(VertexElementFormat,
  5528. ['_elementInfos',function(){return this._elementInfos={
  5529. "single":[1,/*laya.webgl.WebGLContext.FLOAT*/0x1406,0],
  5530. "vector2":[2,/*laya.webgl.WebGLContext.FLOAT*/0x1406,0],
  5531. "vector3":[3,/*laya.webgl.WebGLContext.FLOAT*/0x1406,0],
  5532. "vector4":[4,/*laya.webgl.WebGLContext.FLOAT*/0x1406,0],
  5533. "color":[4,/*laya.webgl.WebGLContext.FLOAT*/0x1406,0],
  5534. "byte4":[4,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,0],
  5535. "short2":[2,/*laya.webgl.WebGLContext.FLOAT*/0x1406,0],
  5536. "short4":[4,/*laya.webgl.WebGLContext.FLOAT*/0x1406,0],
  5537. "normalizedshort2":[2,/*laya.webgl.WebGLContext.FLOAT*/0x1406,0],
  5538. "normalizedshort4":[4,/*laya.webgl.WebGLContext.FLOAT*/0x1406,0],
  5539. "halfvector2":[2,/*laya.webgl.WebGLContext.FLOAT*/0x1406,0],
  5540. "halfvector4":[4,/*laya.webgl.WebGLContext.FLOAT*/0x1406,0]
  5541. };}
  5542. ]);
  5543. return VertexElementFormat;
  5544. })()
  5545. /**
  5546. *<code>HalfFloatUtils</code> 类用于创建HalfFloat工具。
  5547. */
  5548. //class laya.d3.math.HalfFloatUtils
  5549. var HalfFloatUtils=(function(){
  5550. function HalfFloatUtils(){}
  5551. __class(HalfFloatUtils,'laya.d3.math.HalfFloatUtils');
  5552. HalfFloatUtils.__init__=function(){
  5553. for (var i=0;i < 256;++i){
  5554. var e=i-127;
  5555. if (e <-27){
  5556. HalfFloatUtils._baseTable[i | 0x000]=0x0000;
  5557. HalfFloatUtils._baseTable[i | 0x100]=0x8000;
  5558. HalfFloatUtils._shiftTable[i | 0x000]=24;
  5559. HalfFloatUtils._shiftTable[i | 0x100]=24;
  5560. }else if (e <-14){
  5561. HalfFloatUtils._baseTable[i | 0x000]=0x0400 >> (-e-14);
  5562. HalfFloatUtils._baseTable[i | 0x100]=(0x0400 >> (-e-14))| 0x8000;
  5563. HalfFloatUtils._shiftTable[i | 0x000]=-e-1;
  5564. HalfFloatUtils._shiftTable[i | 0x100]=-e-1;
  5565. }else if (e <=15){
  5566. HalfFloatUtils._baseTable[i | 0x000]=(e+15)<< 10;
  5567. HalfFloatUtils._baseTable[i | 0x100]=((e+15)<< 10)| 0x8000;
  5568. HalfFloatUtils._shiftTable[i | 0x000]=13;
  5569. HalfFloatUtils._shiftTable[i | 0x100]=13;
  5570. }else if (e < 128){
  5571. HalfFloatUtils._baseTable[i | 0x000]=0x7c00;
  5572. HalfFloatUtils._baseTable[i | 0x100]=0xfc00;
  5573. HalfFloatUtils._shiftTable[i | 0x000]=24;
  5574. HalfFloatUtils._shiftTable[i | 0x100]=24;
  5575. }else {
  5576. HalfFloatUtils._baseTable[i | 0x000]=0x7c00;
  5577. HalfFloatUtils._baseTable[i | 0x100]=0xfc00;
  5578. HalfFloatUtils._shiftTable[i | 0x000]=13;
  5579. HalfFloatUtils._shiftTable[i | 0x100]=13;
  5580. }
  5581. }
  5582. HalfFloatUtils._mantissaTable[0]=0;
  5583. for (i=1;i < 1024;++i){
  5584. var m=i << 13;
  5585. e=0;
  5586. while ((m & 0x00800000)===0){
  5587. e-=0x00800000;
  5588. m <<=1;
  5589. }
  5590. m &=~0x00800000;
  5591. e+=0x38800000;
  5592. HalfFloatUtils._mantissaTable[i]=m | e;
  5593. }
  5594. for (i=1024;i < 2048;++i){
  5595. HalfFloatUtils._mantissaTable[i]=0x38000000+((i-1024)<< 13);
  5596. }
  5597. HalfFloatUtils._exponentTable[0]=0;
  5598. for (i=1;i < 31;++i){
  5599. HalfFloatUtils._exponentTable[i]=i << 23;
  5600. }
  5601. HalfFloatUtils._exponentTable[31]=0x47800000;
  5602. HalfFloatUtils._exponentTable[32]=0x80000000;
  5603. for (i=33;i < 63;++i){
  5604. HalfFloatUtils._exponentTable[i]=0x80000000+((i-32)<< 23);
  5605. }
  5606. HalfFloatUtils._exponentTable[63]=0xc7800000;
  5607. HalfFloatUtils._offsetTable[0]=0;
  5608. for (i=1;i < 64;++i){
  5609. if (i===32){
  5610. HalfFloatUtils._offsetTable[i]=0;
  5611. }else {
  5612. HalfFloatUtils._offsetTable[i]=1024;
  5613. }
  5614. }
  5615. }
  5616. HalfFloatUtils.roundToFloat16Bits=function(num){
  5617. HalfFloatUtils._floatView[0]=num;
  5618. var f=HalfFloatUtils._uint32View[0];
  5619. var e=(f >> 23)& 0x1ff;
  5620. return HalfFloatUtils._baseTable[e]+((f & 0x007fffff)>> HalfFloatUtils._shiftTable[e]);
  5621. }
  5622. HalfFloatUtils.convertToNumber=function(float16bits){
  5623. var m=float16bits >> 10;
  5624. HalfFloatUtils._uint32View[0]=HalfFloatUtils._mantissaTable[HalfFloatUtils._offsetTable[m]+(float16bits & 0x3ff)]+HalfFloatUtils._exponentTable[m];
  5625. return HalfFloatUtils._floatView[0];
  5626. }
  5627. __static(HalfFloatUtils,
  5628. ['_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);}
  5629. ]);
  5630. return HalfFloatUtils;
  5631. })()
  5632. /**
  5633. *...
  5634. *@author ...
  5635. */
  5636. //class laya.d3.core.scene.SceneManager
  5637. var SceneManager=(function(){
  5638. function SceneManager(){}
  5639. __class(SceneManager,'laya.d3.core.scene.SceneManager');
  5640. return SceneManager;
  5641. })()
  5642. /**
  5643. *@private
  5644. */
  5645. //class laya.d3.shader.ShaderDefines
  5646. var ShaderDefines=(function(){
  5647. function ShaderDefines(superDefines){
  5648. /**@private */
  5649. this._counter=0;
  5650. /**@private [只读]*/
  5651. this.defines={};
  5652. if (superDefines){
  5653. this._counter=superDefines._counter;
  5654. for (var k in superDefines.defines)
  5655. this.defines[k]=superDefines.defines[k];
  5656. }
  5657. }
  5658. __class(ShaderDefines,'laya.d3.shader.ShaderDefines');
  5659. var __proto=ShaderDefines.prototype;
  5660. /**
  5661. *@private
  5662. */
  5663. __proto.registerDefine=function(name){
  5664. var value=Math.pow(2,this._counter++);
  5665. this.defines[value]=name;
  5666. return value;
  5667. }
  5668. return ShaderDefines;
  5669. })()
  5670. /**
  5671. *<code>Simulation</code> 类用于创建物理模拟器。
  5672. */
  5673. //class laya.d3.physics.PhysicsSimulation
  5674. var PhysicsSimulation=(function(){
  5675. function PhysicsSimulation(configuration,flags){
  5676. /**@private */
  5677. this._nativeDiscreteDynamicsWorld=null;
  5678. /**@private */
  5679. this._nativeCollisionWorld=null;
  5680. /**@private */
  5681. this._nativeDispatcher=null;
  5682. /**@private */
  5683. this._nativeCollisionConfiguration=null;
  5684. /**@private */
  5685. this._nativeBroadphase=null;
  5686. /**@private */
  5687. this._nativeSolverInfo=null;
  5688. /**@private */
  5689. this._nativeDispatchInfo=null;
  5690. /**@private */
  5691. this._nativeClosestRayResultCallback=null;
  5692. /**@private */
  5693. this._nativeAllHitsRayResultCallback=null;
  5694. /**@private */
  5695. this._nativeClosestConvexResultCallback=null;
  5696. /**@private */
  5697. this._nativeAllConvexResultCallback=null;
  5698. /**@private */
  5699. this._updatedRigidbodies=0;
  5700. /**物理引擎在一帧中用于补偿减速的最大次数:模拟器每帧允许的最大模拟次数,如果引擎运行缓慢,可能需要增加该次数,否则模拟器会丢失“时间",引擎间隔时间小于maxSubSteps*fixedTimeStep非常重要。*/
  5701. this.maxSubSteps=1;
  5702. /**物理模拟器帧的间隔时间:通过减少fixedTimeStep可增加模拟精度,默认是1.0 / 60.0。*/
  5703. this.fixedTimeStep=1.0 / 60.0;
  5704. this._gravity=new Vector3(0,-10,0);
  5705. this._nativeVector3Zero=new Laya3D._physics3D.btVector3(0,0,0);
  5706. this._nativeDefaultQuaternion=new Laya3D._physics3D.btQuaternion(0,0,0,-1);
  5707. this._collisionsUtils=new CollisionTool();
  5708. this._previousFrameCollisions=[];
  5709. this._currentFrameCollisions=[];
  5710. this._physicsUpdateList=new PhysicsUpdateList();
  5711. this._characters=[];
  5712. (flags===void 0)&& (flags=0);
  5713. this.maxSubSteps=configuration.maxSubSteps;
  5714. this.fixedTimeStep=configuration.fixedTimeStep;
  5715. var physics3D=Laya3D._physics3D;
  5716. this._nativeCollisionConfiguration=new physics3D.btDefaultCollisionConfiguration();
  5717. this._nativeDispatcher=new physics3D.btCollisionDispatcher(this._nativeCollisionConfiguration);
  5718. this._nativeBroadphase=new physics3D.btDbvtBroadphase();
  5719. this._nativeBroadphase.getOverlappingPairCache().setInternalGhostPairCallback(new physics3D.btGhostPairCallback());
  5720. var conFlags=configuration.flags;
  5721. if (conFlags & 0x1){
  5722. this._nativeCollisionWorld=new physics3D.btCollisionWorld(this._nativeDispatcher,this._nativeBroadphase,this._nativeCollisionConfiguration);
  5723. }else if (conFlags & 0x2){
  5724. throw "PhysicsSimulation:SoftBody processing is not yet available";
  5725. }else {
  5726. var solver=new physics3D.btSequentialImpulseConstraintSolver();
  5727. this._nativeDiscreteDynamicsWorld=new physics3D.btDiscreteDynamicsWorld(this._nativeDispatcher,this._nativeBroadphase,solver,this._nativeCollisionConfiguration);
  5728. this._nativeCollisionWorld=this._nativeDiscreteDynamicsWorld;
  5729. }
  5730. if (this._nativeDiscreteDynamicsWorld){
  5731. this._nativeSolverInfo=this._nativeDiscreteDynamicsWorld.getSolverInfo();
  5732. this._nativeDispatchInfo=this._nativeDiscreteDynamicsWorld.getDispatchInfo();
  5733. }
  5734. this._nativeClosestRayResultCallback=new physics3D.ClosestRayResultCallback(this._nativeVector3Zero,this._nativeVector3Zero);
  5735. this._nativeAllHitsRayResultCallback=new physics3D.AllHitsRayResultCallback(this._nativeVector3Zero,this._nativeVector3Zero);
  5736. this._nativeClosestConvexResultCallback=new physics3D.ClosestConvexResultCallback(this._nativeVector3Zero,this._nativeVector3Zero);
  5737. this._nativeAllConvexResultCallback=new physics3D.AllConvexResultCallback(this._nativeVector3Zero,this._nativeVector3Zero);
  5738. physics3D._btGImpactCollisionAlgorithm_RegisterAlgorithm(this._nativeDispatcher.a);
  5739. }
  5740. __class(PhysicsSimulation,'laya.d3.physics.PhysicsSimulation');
  5741. var __proto=PhysicsSimulation.prototype;
  5742. /**
  5743. *@private
  5744. */
  5745. __proto._simulate=function(deltaTime){
  5746. this._updatedRigidbodies=0;
  5747. if (this._nativeDiscreteDynamicsWorld)
  5748. this._nativeDiscreteDynamicsWorld.stepSimulation(deltaTime,this.maxSubSteps,this.fixedTimeStep);
  5749. else
  5750. this._nativeCollisionWorld.PerformDiscreteCollisionDetection();
  5751. }
  5752. /**
  5753. *@private
  5754. */
  5755. __proto._destroy=function(){
  5756. var physics3D=Laya3D._physics3D;
  5757. if (this._nativeDiscreteDynamicsWorld){
  5758. physics3D.destroy(this._nativeDiscreteDynamicsWorld);
  5759. this._nativeDiscreteDynamicsWorld=null;
  5760. }else {
  5761. physics3D.destroy(this._nativeCollisionWorld);
  5762. this._nativeCollisionWorld=null;
  5763. }
  5764. physics3D.destroy(this._nativeBroadphase);
  5765. this._nativeBroadphase=null;
  5766. physics3D.destroy(this._nativeDispatcher);
  5767. this._nativeDispatcher=null;
  5768. physics3D.destroy(this._nativeCollisionConfiguration);
  5769. this._nativeCollisionConfiguration=null;
  5770. }
  5771. /**
  5772. *@private
  5773. */
  5774. __proto._addPhysicsCollider=function(component,group,mask){
  5775. this._nativeCollisionWorld.addCollisionObject(component._nativeColliderObject,group,mask);
  5776. }
  5777. /**
  5778. *@private
  5779. */
  5780. __proto._removePhysicsCollider=function(component){
  5781. this._nativeCollisionWorld.removeCollisionObject(component._nativeColliderObject);
  5782. }
  5783. /**
  5784. *@private
  5785. */
  5786. __proto._addRigidBody=function(rigidBody,group,mask){
  5787. if (!this._nativeDiscreteDynamicsWorld)
  5788. throw "Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";
  5789. this._nativeCollisionWorld.addRigidBody(rigidBody._nativeColliderObject,group,mask);
  5790. }
  5791. /**
  5792. *@private
  5793. */
  5794. __proto._removeRigidBody=function(rigidBody){
  5795. if (!this._nativeDiscreteDynamicsWorld)
  5796. throw "Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";
  5797. this._nativeCollisionWorld.removeRigidBody(rigidBody._nativeColliderObject);
  5798. }
  5799. /**
  5800. *@private
  5801. */
  5802. __proto._addCharacter=function(character,group,mask){
  5803. if (!this._nativeDiscreteDynamicsWorld)
  5804. throw "Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";
  5805. this._nativeCollisionWorld.addCollisionObject(character._nativeColliderObject,group,mask);
  5806. this._nativeCollisionWorld.addAction(character._nativeKinematicCharacter);
  5807. }
  5808. /**
  5809. *@private
  5810. */
  5811. __proto._removeCharacter=function(character){
  5812. if (!this._nativeDiscreteDynamicsWorld)
  5813. throw "Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";
  5814. this._nativeCollisionWorld.removeCollisionObject(character._nativeColliderObject);
  5815. this._nativeCollisionWorld.removeAction(character._nativeKinematicCharacter);
  5816. }
  5817. /**
  5818. *射线检测第一个碰撞物体。
  5819. *@param from 起始位置。
  5820. *@param to 结束位置。
  5821. *@param out 碰撞结果。
  5822. *@param collisonGroup 射线所属碰撞组。
  5823. *@param collisionMask 与射线可产生碰撞的组。
  5824. *@return 是否成功。
  5825. */
  5826. __proto.raycastFromTo=function(from,to,out,collisonGroup,collisionMask){
  5827. (collisonGroup===void 0)&& (collisonGroup=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  5828. (collisionMask===void 0)&& (collisionMask=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  5829. var rayResultCall=this._nativeClosestRayResultCallback;
  5830. var rayFrom=PhysicsSimulation._nativeTempVector30;
  5831. var rayTo=PhysicsSimulation._nativeTempVector31;
  5832. rayFrom.setValue(-from.x,from.y,from.z);
  5833. rayTo.setValue(-to.x,to.y,to.z);
  5834. rayResultCall.set_m_rayFromWorld(rayFrom);
  5835. rayResultCall.set_m_rayToWorld(rayTo);
  5836. rayResultCall.set_m_collisionFilterGroup(collisonGroup);
  5837. rayResultCall.set_m_collisionFilterMask(collisionMask);
  5838. rayResultCall.set_m_collisionObject(null);
  5839. rayResultCall.set_m_closestHitFraction(1);
  5840. this._nativeCollisionWorld.rayTest(rayFrom,rayTo,rayResultCall);
  5841. if (rayResultCall.hasHit()){
  5842. if (out){
  5843. out.succeeded=true;
  5844. out.collider=PhysicsComponent._physicObjectsMap[rayResultCall.get_m_collisionObject().getUserIndex()];
  5845. out.hitFraction=rayResultCall.get_m_closestHitFraction();
  5846. var nativePoint=rayResultCall.get_m_hitPointWorld();
  5847. var point=out.point;
  5848. point.x=-nativePoint.x();
  5849. point.y=nativePoint.y();
  5850. point.z=nativePoint.z();
  5851. var nativeNormal=rayResultCall.get_m_hitNormalWorld();
  5852. var normal=out.normal;
  5853. normal.x=-nativeNormal.x();
  5854. normal.y=nativeNormal.y();
  5855. normal.z=nativeNormal.z();
  5856. }
  5857. return true;
  5858. }else {
  5859. if (out)
  5860. out.succeeded=false;
  5861. return false;
  5862. }
  5863. }
  5864. /**
  5865. *射线检测所有碰撞的物体。
  5866. *@param from 起始位置。
  5867. *@param to 结束位置。
  5868. *@param out 碰撞结果[数组元素会被回收]。
  5869. *@param collisonGroup 射线所属碰撞组。
  5870. *@param collisionMask 与射线可产生碰撞的组。
  5871. *@return 是否成功。
  5872. */
  5873. __proto.raycastAllFromTo=function(from,to,out,collisonGroup,collisionMask){
  5874. (collisonGroup===void 0)&& (collisonGroup=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  5875. (collisionMask===void 0)&& (collisionMask=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  5876. var rayResultCall=this._nativeAllHitsRayResultCallback;
  5877. var rayFrom=PhysicsSimulation._nativeTempVector30;
  5878. var rayTo=PhysicsSimulation._nativeTempVector31;
  5879. out.length=0;
  5880. rayFrom.setValue(-from.x,from.y,from.z);
  5881. rayTo.setValue(-to.x,to.y,to.z);
  5882. rayResultCall.set_m_rayFromWorld(rayFrom);
  5883. rayResultCall.set_m_rayToWorld(rayTo);
  5884. rayResultCall.set_m_collisionFilterGroup(collisonGroup);
  5885. rayResultCall.set_m_collisionFilterMask(collisionMask);
  5886. var collisionObjects=rayResultCall.get_m_collisionObjects();
  5887. var nativePoints=rayResultCall.get_m_hitPointWorld();
  5888. var nativeNormals=rayResultCall.get_m_hitNormalWorld();
  5889. var nativeFractions=rayResultCall.get_m_hitFractions();
  5890. collisionObjects.clear();
  5891. nativePoints.clear();
  5892. nativeNormals.clear();
  5893. nativeFractions.clear();
  5894. this._nativeCollisionWorld.rayTest(rayFrom,rayTo,rayResultCall);
  5895. var count=collisionObjects.size();
  5896. if (count > 0){
  5897. this._collisionsUtils.recoverAllHitResultsPool();
  5898. for (var i=0;i < count;i++){
  5899. var hitResult=this._collisionsUtils.getHitResult();
  5900. out.push(hitResult);
  5901. hitResult.succeeded=true;
  5902. hitResult.collider=PhysicsComponent._physicObjectsMap[collisionObjects.at(i).getUserIndex()];
  5903. hitResult.hitFraction=nativeFractions.at(i);
  5904. var nativePoint=nativePoints.at(i);
  5905. var pointE=hitResult.point;
  5906. pointE.x=-nativePoint.x();
  5907. pointE.y=nativePoint.y();
  5908. pointE.z=nativePoint.z();
  5909. var nativeNormal=nativeNormals.at(i);
  5910. var normalE=hitResult.normal;
  5911. normalE.x=-nativeNormal.x();
  5912. normalE.y=nativeNormal.y();
  5913. normalE.z=nativeNormal.z();
  5914. }
  5915. return true;
  5916. }else {
  5917. return false;
  5918. }
  5919. }
  5920. /**
  5921. *射线检测第一个碰撞物体。
  5922. *@param ray 射线
  5923. *@param outHitInfo 与该射线发生碰撞的第一个碰撞器的碰撞信息
  5924. *@param distance 射线长度,默认为最大值
  5925. *@param collisonGroup 射线所属碰撞组。
  5926. *@param collisionMask 与射线可产生碰撞的组。
  5927. *@return 是否检测成功。
  5928. */
  5929. __proto.rayCast=function(ray,outHitResult,distance,collisonGroup,collisionMask){
  5930. (distance===void 0)&& (distance=2147483647);
  5931. (collisonGroup===void 0)&& (collisonGroup=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  5932. (collisionMask===void 0)&& (collisionMask=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  5933. var from=ray.origin;
  5934. var to=PhysicsSimulation._tempVector30;
  5935. Vector3.normalize(ray.direction,to);
  5936. Vector3.scale(to,distance,to);
  5937. Vector3.add(from,to,to);
  5938. return this.raycastFromTo(from,to,outHitResult,collisonGroup,collisionMask);
  5939. }
  5940. /**
  5941. *射线检测所有碰撞的物体。
  5942. *@param ray 射线
  5943. *@param out 碰撞结果[数组元素会被回收]。
  5944. *@param distance 射线长度,默认为最大值
  5945. *@param collisonGroup 射线所属碰撞组。
  5946. *@param collisionMask 与射线可产生碰撞的组。
  5947. *@return 是否检测成功。
  5948. */
  5949. __proto.rayCastAll=function(ray,out,distance,collisonGroup,collisionMask){
  5950. (distance===void 0)&& (distance=2147483647);
  5951. (collisonGroup===void 0)&& (collisonGroup=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  5952. (collisionMask===void 0)&& (collisionMask=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  5953. var from=ray.origin;
  5954. var to=PhysicsSimulation._tempVector30;
  5955. Vector3.normalize(ray.direction,to);
  5956. Vector3.scale(to,distance,to);
  5957. Vector3.add(from,to,to);
  5958. return this.raycastAllFromTo(from,to,out,collisonGroup,collisionMask);
  5959. }
  5960. /**
  5961. *形状检测第一个碰撞的物体。
  5962. *@param shape 形状。
  5963. *@param fromPosition 世界空间起始位置。
  5964. *@param toPosition 世界空间结束位置。
  5965. *@param out 碰撞结果。
  5966. *@param fromRotation 起始旋转。
  5967. *@param toRotation 结束旋转。
  5968. *@param collisonGroup 射线所属碰撞组。
  5969. *@param collisionMask 与射线可产生碰撞的组。
  5970. *@return 是否成功。
  5971. */
  5972. __proto.shapeCast=function(shape,fromPosition,toPosition,out,fromRotation,toRotation,collisonGroup,collisionMask,allowedCcdPenetration){
  5973. (collisonGroup===void 0)&& (collisonGroup=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  5974. (collisionMask===void 0)&& (collisionMask=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  5975. (allowedCcdPenetration===void 0)&& (allowedCcdPenetration=0.0);
  5976. var convexResultCall=this._nativeClosestConvexResultCallback;
  5977. var convexPosFrom=PhysicsSimulation._nativeTempVector30;
  5978. var convexPosTo=PhysicsSimulation._nativeTempVector31;
  5979. var convexRotFrom=PhysicsSimulation._nativeTempQuaternion0;
  5980. var convexRotTo=PhysicsSimulation._nativeTempQuaternion1;
  5981. var convexTransform=PhysicsSimulation._nativeTempTransform0;
  5982. var convexTransTo=PhysicsSimulation._nativeTempTransform1;
  5983. var sweepShape=shape._nativeShape;
  5984. convexPosFrom.setValue(-fromPosition.x,fromPosition.y,fromPosition.z);
  5985. convexPosTo.setValue(-toPosition.x,toPosition.y,toPosition.z);
  5986. convexResultCall.set_m_collisionFilterGroup(collisonGroup);
  5987. convexResultCall.set_m_collisionFilterMask(collisionMask);
  5988. convexTransform.setOrigin(convexPosFrom);
  5989. convexTransTo.setOrigin(convexPosTo);
  5990. if (fromRotation){
  5991. convexRotFrom.setValue(-fromRotation.x,fromRotation.y,fromRotation.z,-fromRotation.w);
  5992. convexTransform.setRotation(convexRotFrom);
  5993. }else {
  5994. convexTransform.setRotation(this._nativeDefaultQuaternion);
  5995. }
  5996. if (toRotation){
  5997. convexRotTo.setValue(-toRotation.x,toRotation.y,toRotation.z,-toRotation.w);
  5998. convexTransTo.setRotation(convexRotTo);
  5999. }else {
  6000. convexTransTo.setRotation(this._nativeDefaultQuaternion);
  6001. }
  6002. convexResultCall.set_m_hitCollisionObject(null);
  6003. convexResultCall.set_m_closestHitFraction(1);
  6004. this._nativeCollisionWorld.convexSweepTest(sweepShape,convexTransform,convexTransTo,convexResultCall,allowedCcdPenetration);
  6005. if (convexResultCall.hasHit()){
  6006. if (out){
  6007. out.succeeded=true;
  6008. out.collider=PhysicsComponent._physicObjectsMap[convexResultCall.get_m_hitCollisionObject().getUserIndex()];
  6009. out.hitFraction=convexResultCall.get_m_closestHitFraction();
  6010. var nativePoint=convexResultCall.get_m_hitPointWorld();
  6011. var nativeNormal=convexResultCall.get_m_hitNormalWorld();
  6012. var point=out.point;
  6013. var normal=out.normal;
  6014. point.x=-nativePoint.x();
  6015. point.y=nativePoint.y();
  6016. point.z=nativePoint.z();
  6017. normal.x=-nativeNormal.x();
  6018. normal.y=nativeNormal.y();
  6019. normal.z=nativeNormal.z();
  6020. }
  6021. return true;
  6022. }else {
  6023. if (out)
  6024. out.succeeded=false;
  6025. return false;
  6026. }
  6027. }
  6028. /**
  6029. *形状检测所有碰撞的物体。
  6030. *@param shape 形状。
  6031. *@param fromPosition 世界空间起始位置。
  6032. *@param toPosition 世界空间结束位置。
  6033. *@param out 碰撞结果[数组元素会被回收]。
  6034. *@param fromRotation 起始旋转。
  6035. *@param toRotation 结束旋转。
  6036. *@param collisonGroup 射线所属碰撞组。
  6037. *@param collisionMask 与射线可产生碰撞的组。
  6038. *@return 是否成功。
  6039. */
  6040. __proto.shapeCastAll=function(shape,fromPosition,toPosition,out,fromRotation,toRotation,collisonGroup,collisionMask,allowedCcdPenetration){
  6041. (collisonGroup===void 0)&& (collisonGroup=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  6042. (collisionMask===void 0)&& (collisionMask=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  6043. (allowedCcdPenetration===void 0)&& (allowedCcdPenetration=0.0);
  6044. var convexResultCall=this._nativeAllConvexResultCallback;
  6045. var convexPosFrom=PhysicsSimulation._nativeTempVector30;
  6046. var convexPosTo=PhysicsSimulation._nativeTempVector31;
  6047. var convexRotFrom=PhysicsSimulation._nativeTempQuaternion0;
  6048. var convexRotTo=PhysicsSimulation._nativeTempQuaternion1;
  6049. var convexTransform=PhysicsSimulation._nativeTempTransform0;
  6050. var convexTransTo=PhysicsSimulation._nativeTempTransform1;
  6051. var sweepShape=shape._nativeShape;
  6052. out.length=0;
  6053. convexPosFrom.setValue(-fromPosition.x,fromPosition.y,fromPosition.z);
  6054. convexPosTo.setValue(-toPosition.x,toPosition.y,toPosition.z);
  6055. convexResultCall.set_m_collisionFilterGroup(collisonGroup);
  6056. convexResultCall.set_m_collisionFilterMask(collisionMask);
  6057. convexTransform.setOrigin(convexPosFrom);
  6058. convexTransTo.setOrigin(convexPosTo);
  6059. if (fromRotation){
  6060. convexRotFrom.setValue(-fromRotation.x,fromRotation.y,fromRotation.z,-fromRotation.w);
  6061. convexTransform.setRotation(convexRotFrom);
  6062. }else {
  6063. convexTransform.setRotation(this._nativeDefaultQuaternion);
  6064. }
  6065. if (toRotation){
  6066. convexRotTo.setValue(-toRotation.x,toRotation.y,toRotation.z,-toRotation.w);
  6067. convexTransTo.setRotation(convexRotTo);
  6068. }else {
  6069. convexTransTo.setRotation(this._nativeDefaultQuaternion);
  6070. };
  6071. var collisionObjects=convexResultCall.get_m_collisionObjects();
  6072. collisionObjects.clear();
  6073. this._nativeCollisionWorld.convexSweepTest(sweepShape,convexTransform,convexTransTo,convexResultCall,allowedCcdPenetration);
  6074. var count=collisionObjects.size();
  6075. if (count > 0){
  6076. var nativePoints=convexResultCall.get_m_hitPointWorld();
  6077. var nativeNormals=convexResultCall.get_m_hitNormalWorld();
  6078. var nativeFractions=convexResultCall.get_m_hitFractions();
  6079. for (var i=0;i < count;i++){
  6080. var hitResult=this._collisionsUtils.getHitResult();
  6081. out.push(hitResult);
  6082. hitResult.succeeded=true;
  6083. hitResult.collider=PhysicsComponent._physicObjectsMap[collisionObjects.at(i).getUserIndex()];
  6084. hitResult.hitFraction=nativeFractions.at(i);
  6085. var nativePoint=nativePoints.at(i);
  6086. var point=hitResult.point;
  6087. point.x=-nativePoint.x();
  6088. point.y=nativePoint.y();
  6089. point.z=nativePoint.z();
  6090. var nativeNormal=nativeNormals.at(i);
  6091. var normal=hitResult.normal;
  6092. normal.x=-nativeNormal.x();
  6093. normal.y=nativeNormal.y();
  6094. normal.z=nativeNormal.z();
  6095. }
  6096. return true;
  6097. }else {
  6098. return false;
  6099. }
  6100. }
  6101. /**
  6102. *添加刚体运动的约束条件。
  6103. *@param constraint 约束。
  6104. *@param disableCollisionsBetweenLinkedBodies 是否禁用
  6105. */
  6106. __proto.addConstraint=function(constraint,disableCollisionsBetweenLinkedBodies){
  6107. (disableCollisionsBetweenLinkedBodies===void 0)&& (disableCollisionsBetweenLinkedBodies=false);
  6108. if (!this._nativeDiscreteDynamicsWorld)
  6109. throw "Cannot perform this action when the physics engine is set to CollisionsOnly";
  6110. this._nativeDiscreteDynamicsWorld.addConstraint(constraint._nativeConstraint,disableCollisionsBetweenLinkedBodies);
  6111. constraint._simulation=this;
  6112. }
  6113. /**
  6114. *移除刚体运动的约束条件。
  6115. */
  6116. __proto.removeConstraint=function(constraint){
  6117. if (!this._nativeDiscreteDynamicsWorld)
  6118. throw "Cannot perform this action when the physics engine is set to CollisionsOnly";
  6119. this._nativeDiscreteDynamicsWorld.removeConstraint(constraint._nativeConstraint);
  6120. }
  6121. /**
  6122. *@private
  6123. */
  6124. __proto._updatePhysicsTransformFromRender=function(){
  6125. var elements=this._physicsUpdateList.elements;
  6126. for (var i=0,n=this._physicsUpdateList.length;i < n;i++){
  6127. var physicCollider=elements[i];
  6128. physicCollider._derivePhysicsTransformation(false);
  6129. physicCollider._inPhysicUpdateListIndex=-1;
  6130. }
  6131. this._physicsUpdateList.length=0;
  6132. }
  6133. /**
  6134. *@private
  6135. */
  6136. __proto._updateCharacters=function(){
  6137. for (var i=0,n=this._characters.length;i < n;i++){
  6138. var character=this._characters[i];
  6139. character._updateTransformComponent(character._nativeColliderObject.getWorldTransform());
  6140. }
  6141. }
  6142. /**
  6143. *@private
  6144. */
  6145. __proto._updateCollisions=function(){
  6146. this._collisionsUtils.recoverAllContactPointsPool();
  6147. var previous=this._currentFrameCollisions;
  6148. this._currentFrameCollisions=this._previousFrameCollisions;
  6149. this._currentFrameCollisions.length=0;
  6150. this._previousFrameCollisions=previous;
  6151. var loopCount=Stat.loopCount;
  6152. var numManifolds=this._nativeDispatcher.getNumManifolds();
  6153. for (var i=0;i < numManifolds;i++){
  6154. var contactManifold=this._nativeDispatcher.getManifoldByIndexInternal(i);
  6155. var componentA=PhysicsComponent._physicObjectsMap[contactManifold.getBody0().getUserIndex()];
  6156. var componentB=PhysicsComponent._physicObjectsMap[contactManifold.getBody1().getUserIndex()];
  6157. var collision=null;
  6158. var isFirstCollision=false;
  6159. var contacts=null;
  6160. var isTrigger=componentA.isTrigger || componentB.isTrigger;
  6161. if (isTrigger && ((componentA.owner)._needProcessTriggers || (componentB.owner)._needProcessTriggers)){
  6162. var numContacts=contactManifold.getNumContacts();
  6163. for (var j=0;j < numContacts;j++){
  6164. var pt=contactManifold.getContactPoint(j);
  6165. var distance=pt.getDistance();
  6166. if (distance <=0){
  6167. collision=this._collisionsUtils.getCollision(componentA,componentB);
  6168. contacts=collision.contacts;
  6169. isFirstCollision=collision._updateFrame!==loopCount;
  6170. if (isFirstCollision){
  6171. collision._isTrigger=true;
  6172. contacts.length=0;
  6173. }
  6174. break ;
  6175. }
  6176. }
  6177. }else if ((componentA.owner)._needProcessCollisions || (componentB.owner)._needProcessCollisions){
  6178. if (componentA._enableProcessCollisions || componentB._enableProcessCollisions){
  6179. numContacts=contactManifold.getNumContacts();
  6180. for (j=0;j < numContacts;j++){
  6181. pt=contactManifold.getContactPoint(j);
  6182. distance=pt.getDistance();
  6183. if (distance <=0){
  6184. var contactPoint=this._collisionsUtils.getContactPoints();
  6185. contactPoint.colliderA=componentA;
  6186. contactPoint.colliderB=componentB;
  6187. contactPoint.distance=distance;
  6188. var nativeNormal=pt.get_m_normalWorldOnB();
  6189. var normal=contactPoint.normal;
  6190. normal.x=-nativeNormal.x();
  6191. normal.y=nativeNormal.y();
  6192. normal.z=nativeNormal.z();
  6193. var nativePostionA=pt.get_m_positionWorldOnA();
  6194. var positionOnA=contactPoint.positionOnA;
  6195. positionOnA.x=-nativePostionA.x();
  6196. positionOnA.y=nativePostionA.y();
  6197. positionOnA.z=nativePostionA.z();
  6198. var nativePostionB=pt.get_m_positionWorldOnB();
  6199. var positionOnB=contactPoint.positionOnB;
  6200. positionOnB.x=-nativePostionB.x();
  6201. positionOnB.y=nativePostionB.y();
  6202. positionOnB.z=nativePostionB.z();
  6203. if (!collision){
  6204. collision=this._collisionsUtils.getCollision(componentA,componentB);
  6205. contacts=collision.contacts;
  6206. isFirstCollision=collision._updateFrame!==loopCount;
  6207. if (isFirstCollision){
  6208. collision._isTrigger=false;
  6209. contacts.length=0;
  6210. }
  6211. }
  6212. contacts.push(contactPoint);
  6213. }
  6214. }
  6215. }
  6216. }
  6217. if (collision && isFirstCollision){
  6218. this._currentFrameCollisions.push(collision);
  6219. collision._setUpdateFrame(loopCount);
  6220. }
  6221. }
  6222. }
  6223. /**
  6224. *@private
  6225. */
  6226. __proto._eventScripts=function(){
  6227. var loopCount=Stat.loopCount;
  6228. for (var i=0,n=this._currentFrameCollisions.length;i < n;i++){
  6229. var curFrameCol=this._currentFrameCollisions[i];
  6230. var colliderA=curFrameCol._colliderA;
  6231. var colliderB=curFrameCol._colliderB;
  6232. if (colliderA.destroyed || colliderB.destroyed)
  6233. continue ;
  6234. if (loopCount-curFrameCol._lastUpdateFrame===1){
  6235. var ownerA=colliderA.owner;
  6236. var scriptsA=ownerA._scripts;
  6237. if (scriptsA){
  6238. if (curFrameCol._isTrigger){
  6239. if (ownerA._needProcessTriggers){
  6240. for (var j=0,m=scriptsA.length;j < m;j++)
  6241. scriptsA[j].onTriggerStay(colliderB);
  6242. }
  6243. }else {
  6244. if (ownerA._needProcessCollisions){
  6245. for (j=0,m=scriptsA.length;j < m;j++){
  6246. curFrameCol.other=colliderB;
  6247. scriptsA[j].onCollisionStay(curFrameCol);
  6248. }
  6249. }
  6250. }
  6251. };
  6252. var ownerB=colliderB.owner;
  6253. var scriptsB=ownerB._scripts;
  6254. if (scriptsB){
  6255. if (curFrameCol._isTrigger){
  6256. if (ownerB._needProcessTriggers){
  6257. for (j=0,m=scriptsB.length;j < m;j++)
  6258. scriptsB[j].onTriggerStay(colliderA);
  6259. }
  6260. }else {
  6261. if (ownerB._needProcessCollisions){
  6262. for (j=0,m=scriptsB.length;j < m;j++){
  6263. curFrameCol.other=colliderA;
  6264. scriptsB[j].onCollisionStay(curFrameCol);
  6265. }
  6266. }
  6267. }
  6268. }
  6269. }else {
  6270. ownerA=colliderA.owner;
  6271. scriptsA=ownerA._scripts;
  6272. if (scriptsA){
  6273. if (curFrameCol._isTrigger){
  6274. if (ownerA._needProcessTriggers){
  6275. for (j=0,m=scriptsA.length;j < m;j++)
  6276. scriptsA[j].onTriggerEnter(colliderB);
  6277. }
  6278. }else {
  6279. if (ownerA._needProcessCollisions){
  6280. for (j=0,m=scriptsA.length;j < m;j++){
  6281. curFrameCol.other=colliderB;
  6282. scriptsA[j].onCollisionEnter(curFrameCol);
  6283. }
  6284. }
  6285. }
  6286. }
  6287. ownerB=colliderB.owner;
  6288. scriptsB=ownerB._scripts;
  6289. if (scriptsB){
  6290. if (curFrameCol._isTrigger){
  6291. if (ownerB._needProcessTriggers){
  6292. for (j=0,m=scriptsB.length;j < m;j++)
  6293. scriptsB[j].onTriggerEnter(colliderA);
  6294. }
  6295. }else {
  6296. if (ownerB._needProcessCollisions){
  6297. for (j=0,m=scriptsB.length;j < m;j++){
  6298. curFrameCol.other=colliderA;
  6299. scriptsB[j].onCollisionEnter(curFrameCol);
  6300. }
  6301. }
  6302. }
  6303. }
  6304. }
  6305. }
  6306. for (i=0,n=this._previousFrameCollisions.length;i < n;i++){
  6307. var preFrameCol=this._previousFrameCollisions[i];
  6308. var preColliderA=preFrameCol._colliderA;
  6309. var preColliderB=preFrameCol._colliderB;
  6310. if (preColliderA.destroyed || preColliderB.destroyed)
  6311. continue ;
  6312. if (loopCount-preFrameCol._updateFrame===1){
  6313. this._collisionsUtils.recoverCollision(preFrameCol);
  6314. ownerA=preColliderA.owner;
  6315. scriptsA=ownerA._scripts;
  6316. if (scriptsA){
  6317. if (preFrameCol._isTrigger){
  6318. if (ownerA._needProcessTriggers){
  6319. for (j=0,m=scriptsA.length;j < m;j++)
  6320. scriptsA[j].onTriggerExit(preColliderB);
  6321. }
  6322. }else {
  6323. if (ownerA._needProcessCollisions){
  6324. for (j=0,m=scriptsA.length;j < m;j++){
  6325. preFrameCol.other=preColliderB;
  6326. scriptsA[j].onCollisionExit(preFrameCol);
  6327. }
  6328. }
  6329. }
  6330. }
  6331. ownerB=preColliderB.owner;
  6332. scriptsB=ownerB._scripts;
  6333. if (scriptsB){
  6334. if (preFrameCol._isTrigger){
  6335. if (ownerB._needProcessTriggers){
  6336. for (j=0,m=scriptsB.length;j < m;j++)
  6337. scriptsB[j].onTriggerExit(preColliderA);
  6338. }
  6339. }else {
  6340. if (ownerB._needProcessCollisions){
  6341. for (j=0,m=scriptsB.length;j < m;j++){
  6342. preFrameCol.other=preColliderA;
  6343. scriptsB[j].onCollisionExit(preFrameCol);
  6344. }
  6345. }
  6346. }
  6347. }
  6348. }
  6349. }
  6350. }
  6351. /**
  6352. *清除力。
  6353. */
  6354. __proto.clearForces=function(){
  6355. if (!this._nativeDiscreteDynamicsWorld)
  6356. throw "Cannot perform this action when the physics engine is set to CollisionsOnly";
  6357. this._nativeDiscreteDynamicsWorld.clearForces();
  6358. }
  6359. /**
  6360. *设置重力。
  6361. */
  6362. /**
  6363. *获取重力。
  6364. */
  6365. __getset(0,__proto,'gravity',function(){
  6366. if (!this._nativeDiscreteDynamicsWorld)
  6367. throw "Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";
  6368. return this._gravity;
  6369. },function(value){
  6370. if (!this._nativeDiscreteDynamicsWorld)
  6371. throw "Simulation:Cannot perform this action when the physics engine is set to CollisionsOnly";
  6372. this._gravity=value;
  6373. var nativeGravity=PhysicsSimulation._nativeTempVector30;
  6374. nativeGravity.setValue(-value.x,value.y,value.z);
  6375. this._nativeDiscreteDynamicsWorld.setGravity(nativeGravity);
  6376. });
  6377. /**
  6378. *设置是否进行连续碰撞检测。
  6379. *@param value 是否进行连续碰撞检测。
  6380. */
  6381. /**
  6382. *获取是否进行连续碰撞检测。
  6383. *@return 是否进行连续碰撞检测。
  6384. */
  6385. __getset(0,__proto,'continuousCollisionDetection',function(){
  6386. return this._nativeDispatchInfo.get_m_useContinuous();
  6387. },function(value){
  6388. this._nativeDispatchInfo.set_m_useContinuous(value);
  6389. });
  6390. /**
  6391. *@private
  6392. */
  6393. /**
  6394. *@private
  6395. */
  6396. __getset(0,__proto,'speculativeContactRestitution',function(){
  6397. if (!this._nativeDiscreteDynamicsWorld)
  6398. throw "Simulation:Cannot Cannot perform this action when the physics engine is set to CollisionsOnly";
  6399. return this._nativeDiscreteDynamicsWorld.getApplySpeculativeContactRestitution();
  6400. },function(value){
  6401. if (!this._nativeDiscreteDynamicsWorld)
  6402. throw "Simulation:Cannot Cannot perform this action when the physics engine is set to CollisionsOnly";
  6403. this._nativeDiscreteDynamicsWorld.setApplySpeculativeContactRestitution(value);
  6404. });
  6405. PhysicsSimulation.createConstraint=function(){}
  6406. PhysicsSimulation.PHYSICSENGINEFLAGS_NONE=0x0;
  6407. PhysicsSimulation.PHYSICSENGINEFLAGS_COLLISIONSONLY=0x1;
  6408. PhysicsSimulation.PHYSICSENGINEFLAGS_SOFTBODYSUPPORT=0x2;
  6409. PhysicsSimulation.PHYSICSENGINEFLAGS_MULTITHREADED=0x4;
  6410. PhysicsSimulation.PHYSICSENGINEFLAGS_USEHARDWAREWHENPOSSIBLE=0x8;
  6411. PhysicsSimulation.SOLVERMODE_RANDMIZE_ORDER=1;
  6412. PhysicsSimulation.SOLVERMODE_FRICTION_SEPARATE=2;
  6413. PhysicsSimulation.SOLVERMODE_USE_WARMSTARTING=4;
  6414. PhysicsSimulation.SOLVERMODE_USE_2_FRICTION_DIRECTIONS=16;
  6415. PhysicsSimulation.SOLVERMODE_ENABLE_FRICTION_DIRECTION_CACHING=32;
  6416. PhysicsSimulation.SOLVERMODE_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION=64;
  6417. PhysicsSimulation.SOLVERMODE_CACHE_FRIENDLY=128;
  6418. PhysicsSimulation.SOLVERMODE_SIMD=256;
  6419. PhysicsSimulation.SOLVERMODE_INTERLEAVE_CONTACT_AND_FRICTION_CONSTRAINTS=512;
  6420. PhysicsSimulation.SOLVERMODE_ALLOW_ZERO_LENGTH_FRICTION_DIRECTIONS=1024;
  6421. PhysicsSimulation.disableSimulation=false;
  6422. __static(PhysicsSimulation,
  6423. ['_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();}
  6424. ]);
  6425. return PhysicsSimulation;
  6426. })()
  6427. /**
  6428. *...
  6429. *@author ...
  6430. */
  6431. //class laya.d3.core.particleShuriKen.module.shape.ShapeUtils
  6432. var ShapeUtils=(function(){
  6433. function ShapeUtils(){}
  6434. __class(ShapeUtils,'laya.d3.core.particleShuriKen.module.shape.ShapeUtils');
  6435. ShapeUtils._randomPointUnitArcCircle=function(arc,out,rand){
  6436. var angle=NaN;
  6437. if (rand)
  6438. angle=rand.getFloat()*arc;
  6439. else
  6440. angle=Math.random()*arc;
  6441. out.x=Math.cos(angle);
  6442. out.y=Math.sin(angle);
  6443. }
  6444. ShapeUtils._randomPointInsideUnitArcCircle=function(arc,out,rand){
  6445. ShapeUtils._randomPointUnitArcCircle(arc,out,rand);
  6446. var range=NaN;
  6447. if (rand)
  6448. range=Math.pow(rand.getFloat(),1.0 / 2.0);
  6449. else
  6450. range=Math.pow(Math.random(),1.0 / 2.0);
  6451. out.x=out.x *range;
  6452. out.y=out.y *range;
  6453. }
  6454. ShapeUtils._randomPointUnitCircle=function(out,rand){
  6455. var angle=NaN;
  6456. if (rand)
  6457. angle=rand.getFloat()*Math.PI *2;
  6458. else
  6459. angle=Math.random()*Math.PI *2;
  6460. out.x=Math.cos(angle);
  6461. out.y=Math.sin(angle);
  6462. }
  6463. ShapeUtils._randomPointInsideUnitCircle=function(out,rand){
  6464. ShapeUtils._randomPointUnitCircle(out);
  6465. var range=NaN;
  6466. if (rand)
  6467. range=Math.pow(rand.getFloat(),1.0 / 2.0);
  6468. else
  6469. range=Math.pow(Math.random(),1.0 / 2.0);
  6470. out.x=out.x *range;
  6471. out.y=out.y *range;
  6472. }
  6473. ShapeUtils._randomPointUnitSphere=function(out,rand){
  6474. var z=NaN;
  6475. var a=NaN;
  6476. if (rand){
  6477. z=out.z=rand.getFloat()*2-1.0;
  6478. a=rand.getFloat()*Math.PI *2;
  6479. }else {
  6480. z=out.z=Math.random()*2-1.0;
  6481. a=Math.random()*Math.PI *2;
  6482. };
  6483. var r=Math.sqrt(1.0-z *z);
  6484. out.x=r *Math.cos(a);
  6485. out.y=r *Math.sin(a);
  6486. }
  6487. ShapeUtils._randomPointInsideUnitSphere=function(out,rand){;
  6488. ShapeUtils._randomPointUnitSphere(out);
  6489. var range=NaN;
  6490. if (rand)
  6491. range=Math.pow(rand.getFloat(),1.0 / 3.0);
  6492. else
  6493. range=Math.pow(Math.random(),1.0 / 3.0);
  6494. out.x=out.x *range;
  6495. out.y=out.y *range;
  6496. out.z=out.z *range;
  6497. }
  6498. ShapeUtils._randomPointInsideHalfUnitBox=function(out,rand){
  6499. if (rand){
  6500. out.x=(rand.getFloat()-0.5);
  6501. out.y=(rand.getFloat()-0.5);
  6502. out.z=(rand.getFloat()-0.5);
  6503. }else {
  6504. out.x=(Math.random()-0.5);
  6505. out.y=(Math.random()-0.5);
  6506. out.z=(Math.random()-0.5);
  6507. }
  6508. }
  6509. return ShapeUtils;
  6510. })()
  6511. /**
  6512. *@private
  6513. *<code>KeyframeNodeOwner</code> 类用于保存帧节点的拥有者信息。
  6514. */
  6515. //class laya.d3.component.KeyframeNodeOwner
  6516. var KeyframeNodeOwner=(function(){
  6517. function KeyframeNodeOwner(){
  6518. /**@private */
  6519. this.indexInList=-1;
  6520. /**@private */
  6521. this.referenceCount=0;
  6522. /**@private */
  6523. this.updateMark=-1;
  6524. /**@private */
  6525. this.type=-1;
  6526. /**@private */
  6527. this.fullPath=null;
  6528. /**@private */
  6529. this.propertyOwner=null;
  6530. /**@private */
  6531. this.property=null;
  6532. /**@private */
  6533. this.defaultValue=null;
  6534. /**@private */
  6535. this.crossFixedValue=null;
  6536. }
  6537. __class(KeyframeNodeOwner,'laya.d3.component.KeyframeNodeOwner');
  6538. var __proto=KeyframeNodeOwner.prototype;
  6539. /**
  6540. *@private
  6541. */
  6542. __proto.saveCrossFixedValue=function(){
  6543. var pro=this.propertyOwner;
  6544. if (pro){
  6545. switch (this.type){
  6546. case 0:;
  6547. var proPat=this.property;
  6548. var m=proPat.length-1;
  6549. for (var j=0;j < m;j++){
  6550. pro=pro[proPat[j]];
  6551. if (!pro)
  6552. break ;
  6553. }
  6554. this.crossFixedValue=pro[proPat[m]];
  6555. break ;
  6556. case 1:;
  6557. var locPos=pro.localPosition;
  6558. this.crossFixedValue || (this.crossFixedValue=new Vector3());
  6559. this.crossFixedValue.x=locPos.x;
  6560. this.crossFixedValue.y=locPos.y;
  6561. this.crossFixedValue.z=locPos.z;
  6562. break ;
  6563. case 2:;
  6564. var locRot=pro.localRotation;
  6565. this.crossFixedValue || (this.crossFixedValue=new Quaternion());
  6566. this.crossFixedValue.x=locRot.x;
  6567. this.crossFixedValue.y=locRot.y;
  6568. this.crossFixedValue.z=locRot.z;
  6569. this.crossFixedValue.w=locRot.w;
  6570. break ;
  6571. case 3:;
  6572. var locSca=pro.localScale;
  6573. this.crossFixedValue || (this.crossFixedValue=new Vector3());
  6574. this.crossFixedValue.x=locSca.x;
  6575. this.crossFixedValue.y=locSca.y;
  6576. this.crossFixedValue.z=locSca.z;
  6577. break ;
  6578. case 4:;
  6579. var locEul=pro.localRotationEuler;
  6580. this.crossFixedValue || (this.crossFixedValue=new Vector3());
  6581. this.crossFixedValue.x=locEul.x;
  6582. this.crossFixedValue.y=locEul.y;
  6583. this.crossFixedValue.z=locEul.z;
  6584. break ;
  6585. default :
  6586. throw "Animator:unknown type.";
  6587. }
  6588. }
  6589. }
  6590. return KeyframeNodeOwner;
  6591. })()
  6592. /**
  6593. **<code>PostProcessRenderContext</code> 类用于创建后期处理渲染上下文。
  6594. */
  6595. //class laya.d3.core.render.PostProcessRenderContext
  6596. var PostProcessRenderContext=(function(){
  6597. function PostProcessRenderContext(){
  6598. /**源纹理。*/
  6599. this.source=null;
  6600. /**输出纹理。*/
  6601. this.destination=null;
  6602. /**渲染相机。*/
  6603. this.camera=null;
  6604. /**合成着色器数据。*/
  6605. this.compositeShaderData=null;
  6606. /**合成着色器宏定义。*/
  6607. this.compositeDefineData=null;
  6608. /**后期处理指令流。*/
  6609. this.command=null;
  6610. this.tempRenderTextures=[];
  6611. }
  6612. __class(PostProcessRenderContext,'laya.d3.core.render.PostProcessRenderContext');
  6613. return PostProcessRenderContext;
  6614. })()
  6615. /**
  6616. *...
  6617. *@author ...
  6618. */
  6619. //class laya.d3.graphics.Vertex.VertexMesh
  6620. var VertexMesh=(function(){
  6621. function VertexMesh(){}
  6622. __class(VertexMesh,'laya.d3.graphics.Vertex.VertexMesh');
  6623. VertexMesh.getVertexDeclaration=function(vertexFlag,compatible){
  6624. (compatible===void 0)&& (compatible=true);
  6625. var verDec=VertexMesh._vertexDeclarationMap[vertexFlag+(compatible?"_0":"_1")];
  6626. if (!verDec){
  6627. var subFlags=vertexFlag.split(",");
  6628. var offset=0;
  6629. var elements=[];
  6630. for (var i=0,n=subFlags.length;i < n;i++){
  6631. var element;
  6632. switch (subFlags[i]){
  6633. case "POSITION":
  6634. element=new VertexElement(offset,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0);
  6635. offset+=12;
  6636. break ;
  6637. case "NORMAL":
  6638. element=new VertexElement(offset,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_NORMAL0*/3);
  6639. offset+=12;
  6640. break ;
  6641. case "COLOR":
  6642. element=new VertexElement(offset,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_COLOR0*/1);
  6643. offset+=16;
  6644. break ;
  6645. case "UV":
  6646. element=new VertexElement(offset,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE0*/2);
  6647. offset+=8;
  6648. break ;
  6649. case "UV1":
  6650. element=new VertexElement(offset,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE1*/7);
  6651. offset+=8;
  6652. break ;
  6653. case "BLENDWEIGHT":
  6654. element=new VertexElement(offset,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_BLENDWEIGHT0*/6);
  6655. offset+=16;
  6656. break ;
  6657. case "BLENDINDICES":
  6658. if (compatible){
  6659. element=new VertexElement(offset,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_BLENDINDICES0*/5);
  6660. offset+=16;
  6661. }else {
  6662. element=new VertexElement(offset,/*laya.d3.graphics.VertexElementFormat.Byte4*/"byte4",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_BLENDINDICES0*/5);
  6663. offset+=4;
  6664. }
  6665. break ;
  6666. case "TANGENT":
  6667. element=new VertexElement(offset,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_TANGENT0*/4);
  6668. offset+=16;
  6669. break ;
  6670. default :
  6671. throw "VertexMesh: unknown vertex flag.";
  6672. }
  6673. elements.push(element);
  6674. }
  6675. verDec=new VertexDeclaration(offset,elements);
  6676. VertexMesh._vertexDeclarationMap[vertexFlag+(compatible?"_0":"_1")]=verDec;
  6677. }
  6678. return verDec;
  6679. }
  6680. VertexMesh.MESH_POSITION0=0;
  6681. VertexMesh.MESH_COLOR0=1;
  6682. VertexMesh.MESH_TEXTURECOORDINATE0=2;
  6683. VertexMesh.MESH_NORMAL0=3;
  6684. VertexMesh.MESH_TANGENT0=4;
  6685. VertexMesh.MESH_BLENDINDICES0=5;
  6686. VertexMesh.MESH_BLENDWEIGHT0=6;
  6687. VertexMesh.MESH_TEXTURECOORDINATE1=7;
  6688. VertexMesh.MESH_WORLDMATRIX_ROW0=8;
  6689. VertexMesh.MESH_WORLDMATRIX_ROW1=9;
  6690. VertexMesh.MESH_WORLDMATRIX_ROW2=10;
  6691. VertexMesh.MESH_WORLDMATRIX_ROW3=11;
  6692. VertexMesh.MESH_MVPMATRIX_ROW0=12;
  6693. VertexMesh.MESH_MVPMATRIX_ROW1=13;
  6694. VertexMesh.MESH_MVPMATRIX_ROW2=14;
  6695. VertexMesh.MESH_MVPMATRIX_ROW3=15;
  6696. VertexMesh._vertexDeclarationMap={};
  6697. __static(VertexMesh,
  6698. ['instanceWorldMatrixDeclaration',function(){return this.instanceWorldMatrixDeclaration=new VertexDeclaration(64,
  6699. [new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_WORLDMATRIX_ROW0*/8),
  6700. new VertexElement(16,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_WORLDMATRIX_ROW1*/9),
  6701. new VertexElement(32,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_WORLDMATRIX_ROW2*/10),
  6702. 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,
  6703. [new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_MVPMATRIX_ROW0*/12),
  6704. new VertexElement(16,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_MVPMATRIX_ROW1*/13),
  6705. new VertexElement(32,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_MVPMATRIX_ROW2*/14),
  6706. new VertexElement(48,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*CLASS CONST:laya.d3.graphics.Vertex.VertexMesh.MESH_MVPMATRIX_ROW3*/15)]);}
  6707. ]);
  6708. return VertexMesh;
  6709. })()
  6710. /**
  6711. *<code>ContainmentType</code> 类用于定义空间物体位置关系。
  6712. */
  6713. //class laya.d3.math.ContainmentType
  6714. var ContainmentType=(function(){
  6715. function ContainmentType(){}
  6716. __class(ContainmentType,'laya.d3.math.ContainmentType');
  6717. ContainmentType.Disjoint=0;
  6718. ContainmentType.Contains=1;
  6719. ContainmentType.Intersects=2;
  6720. return ContainmentType;
  6721. })()
  6722. /**
  6723. *@private
  6724. *<code>ShaderInit</code> 类用于初始化内置Shader。
  6725. */
  6726. //class laya.d3.shader.ShaderInit3D
  6727. var ShaderInit3D=(function(){
  6728. /**
  6729. *创建一个 <code>ShaderInit</code> 实例。
  6730. */
  6731. function ShaderInit3D(){}
  6732. __class(ShaderInit3D,'laya.d3.shader.ShaderInit3D');
  6733. ShaderInit3D.__init__=function(){
  6734. ShaderInit3D._rangeAttenTex=Utils3D._buildTexture2D(1024,1,/*laya.resource.BaseTexture.FORMAT_ALPHA8*/2,TextureGenerator.lightAttenTexture);
  6735. ShaderInit3D._rangeAttenTex.wrapModeU=/*laya.resource.BaseTexture.WARPMODE_CLAMP*/1;
  6736. ShaderInit3D._rangeAttenTex.wrapModeV=/*laya.resource.BaseTexture.WARPMODE_CLAMP*/1;
  6737. ShaderInit3D._rangeAttenTex.lock=true;
  6738. Shader3D.SHADERDEFINE_HIGHPRECISION=Shader3D.registerPublicDefine("HIGHPRECISION");
  6739. Scene3D.SHADERDEFINE_FOG=Shader3D.registerPublicDefine("FOG");
  6740. Scene3D.SHADERDEFINE_DIRECTIONLIGHT=Shader3D.registerPublicDefine("DIRECTIONLIGHT");
  6741. Scene3D.SHADERDEFINE_POINTLIGHT=Shader3D.registerPublicDefine("POINTLIGHT");
  6742. Scene3D.SHADERDEFINE_SPOTLIGHT=Shader3D.registerPublicDefine("SPOTLIGHT");
  6743. Scene3D.SHADERDEFINE_CAST_SHADOW=Shader3D.registerPublicDefine("CASTSHADOW");
  6744. Scene3D.SHADERDEFINE_SHADOW_PSSM1=Shader3D.registerPublicDefine("SHADOWMAP_PSSM1");
  6745. Scene3D.SHADERDEFINE_SHADOW_PSSM2=Shader3D.registerPublicDefine("SHADOWMAP_PSSM2");
  6746. Scene3D.SHADERDEFINE_SHADOW_PSSM3=Shader3D.registerPublicDefine("SHADOWMAP_PSSM3");
  6747. Scene3D.SHADERDEFINE_SHADOW_PCF_NO=Shader3D.registerPublicDefine("SHADOWMAP_PCF_NO");
  6748. Scene3D.SHADERDEFINE_SHADOW_PCF1=Shader3D.registerPublicDefine("SHADOWMAP_PCF1");
  6749. Scene3D.SHADERDEFINE_SHADOW_PCF2=Shader3D.registerPublicDefine("SHADOWMAP_PCF2");
  6750. Scene3D.SHADERDEFINE_SHADOW_PCF3=Shader3D.registerPublicDefine("SHADOWMAP_PCF3");
  6751. Scene3D.SHADERDEFINE_REFLECTMAP=Shader3D.registerPublicDefine("REFLECTMAP");
  6752. 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");
  6753. 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}");
  6754. 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}");
  6755. 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");
  6756. 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");
  6757. 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");
  6758. 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}");
  6759. 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}");
  6760. 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}");
  6761. var vs,ps;
  6762. var attributeMap={
  6763. 'a_Position':/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0,
  6764. 'a_Color':/*laya.d3.graphics.Vertex.VertexMesh.MESH_COLOR0*/1,
  6765. 'a_Normal':/*laya.d3.graphics.Vertex.VertexMesh.MESH_NORMAL0*/3,
  6766. 'a_Texcoord0':/*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE0*/2,
  6767. 'a_Texcoord1':/*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE1*/7,
  6768. 'a_BoneWeights':/*laya.d3.graphics.Vertex.VertexMesh.MESH_BLENDWEIGHT0*/6,
  6769. 'a_BoneIndices':/*laya.d3.graphics.Vertex.VertexMesh.MESH_BLENDINDICES0*/5,
  6770. 'a_Tangent0':/*laya.d3.graphics.Vertex.VertexMesh.MESH_TANGENT0*/4,
  6771. 'a_MvpMatrix':/*laya.d3.graphics.Vertex.VertexMesh.MESH_MVPMATRIX_ROW0*/12,
  6772. 'a_WorldMat':/*laya.d3.graphics.Vertex.VertexMesh.MESH_WORLDMATRIX_ROW0*/8
  6773. };
  6774. var uniformMap={
  6775. 'u_Bones':/*laya.d3.shader.Shader3D.PERIOD_CUSTOM*/0,
  6776. 'u_DiffuseTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6777. 'u_SpecularTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6778. 'u_NormalTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6779. 'u_AlphaTestValue':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6780. 'u_DiffuseColor':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6781. 'u_MaterialSpecular':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6782. 'u_Shininess':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6783. 'u_TilingOffset':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6784. 'u_WorldMat':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  6785. 'u_MvpMatrix':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  6786. 'u_LightmapScaleOffset':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  6787. 'u_LightMap':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  6788. 'u_CameraPos':/*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3,
  6789. 'u_ReflectTexture':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6790. 'u_ReflectIntensity':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6791. 'u_FogStart':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6792. 'u_FogRange':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6793. 'u_FogColor':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6794. 'u_DirectionLight.Color':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6795. 'u_DirectionLight.Direction':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6796. 'u_PointLight.Position':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6797. 'u_PointLight.Range':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6798. 'u_PointLight.Color':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6799. 'u_SpotLight.Position':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6800. 'u_SpotLight.Direction':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6801. 'u_SpotLight.Range':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6802. 'u_SpotLight.Spot':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6803. 'u_SpotLight.Color':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6804. 'u_AmbientColor':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6805. 'u_shadowMap1':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6806. 'u_shadowMap2':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6807. 'u_shadowMap3':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6808. 'u_shadowPSSMDistance':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6809. 'u_lightShadowVP':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6810. 'u_shadowPCFoffset':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4
  6811. };
  6812. var stateMap={
  6813. 's_Cull':/*laya.d3.shader.Shader3D.RENDER_STATE_CULL*/0,
  6814. 's_Blend':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND*/1,
  6815. 's_BlendSrc':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_SRC*/2,
  6816. 's_BlendDst':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_DST*/3,
  6817. 's_DepthTest':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_TEST*/12,
  6818. 's_DepthWrite':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_WRITE*/13
  6819. }
  6820. 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}";
  6821. 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";
  6822. var shader=Shader3D.add("BLINNPHONG",true);
  6823. var subShader=new SubShader(attributeMap,uniformMap,SkinnedMeshSprite3D.shaderDefines,BlinnPhongMaterial.shaderDefines);
  6824. shader.addSubShader(subShader);
  6825. subShader.addShaderPass(vs,ps,stateMap);
  6826. attributeMap={
  6827. 'a_Position':/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0,
  6828. 'a_Color':/*laya.d3.graphics.Vertex.VertexMesh.MESH_COLOR0*/1};
  6829. uniformMap={
  6830. 'u_MvpMatrix':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  6831. 'u_Color':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1
  6832. };
  6833. stateMap={
  6834. 's_Cull':/*laya.d3.shader.Shader3D.RENDER_STATE_CULL*/0,
  6835. 's_Blend':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND*/1,
  6836. 's_BlendSrc':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_SRC*/2,
  6837. 's_BlendDst':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_DST*/3,
  6838. 's_DepthTest':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_TEST*/12,
  6839. 's_DepthWrite':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_WRITE*/13
  6840. }
  6841. 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}";
  6842. 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";
  6843. shader=Shader3D.add("LineShader");
  6844. subShader=new SubShader(attributeMap,uniformMap);
  6845. shader.addSubShader(subShader);
  6846. subShader.addShaderPass(vs,ps,stateMap);
  6847. attributeMap={
  6848. 'a_Position':/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0,
  6849. 'a_Normal':/*laya.d3.graphics.Vertex.VertexMesh.MESH_NORMAL0*/3,
  6850. 'a_Tangent0':/*laya.d3.graphics.Vertex.VertexMesh.MESH_TANGENT0*/4,
  6851. 'a_Texcoord0':/*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE0*/2,
  6852. 'a_BoneWeights':/*laya.d3.graphics.Vertex.VertexMesh.MESH_BLENDWEIGHT0*/6,
  6853. 'a_BoneIndices':/*laya.d3.graphics.Vertex.VertexMesh.MESH_BLENDINDICES0*/5,
  6854. 'a_MvpMatrix':/*laya.d3.graphics.Vertex.VertexMesh.MESH_MVPMATRIX_ROW0*/12,
  6855. 'a_WorldMat':/*laya.d3.graphics.Vertex.VertexMesh.MESH_WORLDMATRIX_ROW0*/8
  6856. };
  6857. uniformMap={
  6858. 'u_Bones':/*laya.d3.shader.Shader3D.PERIOD_CUSTOM*/0,
  6859. 'u_MvpMatrix':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  6860. 'u_WorldMat':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  6861. 'u_CameraPos':/*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3,
  6862. 'u_AlphaTestValue':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6863. 'u_AlbedoColor':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6864. 'u_EmissionColor':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6865. 'u_AlbedoTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6866. 'u_NormalTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6867. 'u_ParallaxTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6868. 'u_MetallicGlossTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6869. 'u_OcclusionTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6870. 'u_EmissionTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6871. 'u_metallic':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6872. 'u_smoothness':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6873. 'u_smoothnessScale':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6874. 'u_occlusionStrength':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6875. 'u_normalScale':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6876. 'u_parallaxScale':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6877. 'u_TilingOffset':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6878. 'u_DirectionLight.Direction':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6879. 'u_DirectionLight.Color':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6880. 'u_PointLightMatrix':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6881. 'u_PointLight.Position':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6882. 'u_PointLight.Range':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6883. 'u_PointLight.Color':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6884. 'u_SpotLight.Position':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6885. 'u_SpotLight.Direction':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6886. 'u_SpotLight.Range':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6887. 'u_SpotLight.SpotAngle':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6888. 'u_SpotLight.Color':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6889. 'u_RangeTexture':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6890. 'u_ReflectTexture':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6891. 'u_ReflectIntensity':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6892. 'u_AmbientColor':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6893. 'u_shadowMap1':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6894. 'u_shadowMap2':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6895. 'u_shadowMap3':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6896. 'u_shadowPSSMDistance':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6897. 'u_lightShadowVP':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6898. 'u_shadowPCFoffset':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6899. 'u_FogStart':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6900. 'u_FogRange':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6901. 'u_FogColor':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4
  6902. };
  6903. stateMap={
  6904. 's_Cull':/*laya.d3.shader.Shader3D.RENDER_STATE_CULL*/0,
  6905. 's_Blend':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND*/1,
  6906. 's_BlendSrc':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_SRC*/2,
  6907. 's_BlendDst':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_DST*/3,
  6908. 's_DepthTest':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_TEST*/12,
  6909. 's_DepthWrite':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_WRITE*/13
  6910. }
  6911. 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}";
  6912. 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}";
  6913. shader=Shader3D.add("PBRStandard",true);
  6914. subShader=new SubShader(attributeMap,uniformMap,SkinnedMeshSprite3D.shaderDefines,PBRStandardMaterial.shaderDefines);
  6915. shader.addSubShader(subShader);
  6916. subShader.addShaderPass(vs,ps,stateMap);
  6917. attributeMap={
  6918. 'a_Position':/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0,
  6919. 'a_Normal':/*laya.d3.graphics.Vertex.VertexMesh.MESH_NORMAL0*/3,
  6920. 'a_Tangent0':/*laya.d3.graphics.Vertex.VertexMesh.MESH_TANGENT0*/4,
  6921. 'a_Texcoord0':/*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE0*/2,
  6922. 'a_BoneWeights':/*laya.d3.graphics.Vertex.VertexMesh.MESH_BLENDWEIGHT0*/6,
  6923. 'a_BoneIndices':/*laya.d3.graphics.Vertex.VertexMesh.MESH_BLENDINDICES0*/5,
  6924. 'a_MvpMatrix':/*laya.d3.graphics.Vertex.VertexMesh.MESH_MVPMATRIX_ROW0*/12,
  6925. 'a_WorldMat':/*laya.d3.graphics.Vertex.VertexMesh.MESH_WORLDMATRIX_ROW0*/8
  6926. };
  6927. uniformMap={
  6928. 'u_Bones':/*laya.d3.shader.Shader3D.PERIOD_CUSTOM*/0,
  6929. 'u_MvpMatrix':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  6930. 'u_WorldMat':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  6931. 'u_CameraPos':/*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3,
  6932. 'u_AlphaTestValue':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6933. 'u_AlbedoColor':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6934. 'u_SpecularColor':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6935. 'u_EmissionColor':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6936. 'u_AlbedoTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6937. 'u_NormalTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6938. 'u_ParallaxTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6939. 'u_SpecularTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6940. 'u_OcclusionTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6941. 'u_EmissionTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6942. 'u_smoothness':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6943. 'u_smoothnessScale':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6944. 'u_occlusionStrength':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6945. 'u_normalScale':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6946. 'u_parallaxScale':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6947. 'u_TilingOffset':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6948. 'u_DirectionLight.Direction':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6949. 'u_DirectionLight.Color':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6950. 'u_PointLightMatrix':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6951. 'u_PointLight.Position':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6952. 'u_PointLight.Range':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6953. 'u_PointLight.Color':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6954. 'u_SpotLight.Position':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6955. 'u_SpotLight.Direction':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6956. 'u_SpotLight.Range':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6957. 'u_SpotLight.SpotAngle':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6958. 'u_SpotLight.Color':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6959. 'u_RangeTexture':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6960. 'u_ReflectTexture':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6961. 'u_ReflectIntensity':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6962. 'u_AmbientColor':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6963. 'u_shadowMap1':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6964. 'u_shadowMap2':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6965. 'u_shadowMap3':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6966. 'u_shadowPSSMDistance':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6967. 'u_lightShadowVP':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6968. 'u_shadowPCFoffset':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6969. 'u_FogStart':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6970. 'u_FogRange':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  6971. 'u_FogColor':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4
  6972. };
  6973. stateMap={
  6974. 's_Cull':/*laya.d3.shader.Shader3D.RENDER_STATE_CULL*/0,
  6975. 's_Blend':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND*/1,
  6976. 's_BlendSrc':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_SRC*/2,
  6977. 's_BlendDst':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_DST*/3,
  6978. 's_DepthTest':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_TEST*/12,
  6979. 's_DepthWrite':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_WRITE*/13
  6980. }
  6981. 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}";
  6982. 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";
  6983. shader=Shader3D.add("PBRSpecular",true);
  6984. subShader=new SubShader(attributeMap,uniformMap,SkinnedMeshSprite3D.shaderDefines,PBRSpecularMaterial.shaderDefines);
  6985. shader.addSubShader(subShader);
  6986. subShader.addShaderPass(vs,ps,stateMap);
  6987. attributeMap={
  6988. 'a_Position':/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0,
  6989. 'a_Color':/*laya.d3.graphics.Vertex.VertexMesh.MESH_COLOR0*/1,
  6990. 'a_Texcoord0':/*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE0*/2,
  6991. 'a_BoneWeights':/*laya.d3.graphics.Vertex.VertexMesh.MESH_BLENDWEIGHT0*/6,
  6992. 'a_BoneIndices':/*laya.d3.graphics.Vertex.VertexMesh.MESH_BLENDINDICES0*/5,
  6993. 'a_MvpMatrix':/*laya.d3.graphics.Vertex.VertexMesh.MESH_MVPMATRIX_ROW0*/12
  6994. };
  6995. uniformMap={
  6996. 'u_Bones':/*laya.d3.shader.Shader3D.PERIOD_CUSTOM*/0,
  6997. 'u_AlbedoTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6998. 'u_AlbedoColor':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  6999. 'u_TilingOffset':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7000. 'u_AlphaTestValue':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7001. 'u_MvpMatrix':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7002. 'u_FogStart':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  7003. 'u_FogRange':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  7004. 'u_FogColor':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4
  7005. };
  7006. stateMap={
  7007. 's_Cull':/*laya.d3.shader.Shader3D.RENDER_STATE_CULL*/0,
  7008. 's_Blend':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND*/1,
  7009. 's_BlendSrc':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_SRC*/2,
  7010. 's_BlendDst':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_DST*/3,
  7011. 's_DepthTest':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_TEST*/12,
  7012. 's_DepthWrite':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_WRITE*/13
  7013. }
  7014. 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}";
  7015. 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";
  7016. shader=Shader3D.add("Unlit",true);
  7017. subShader=new SubShader(attributeMap,uniformMap,SkinnedMeshSprite3D.shaderDefines,UnlitMaterial.shaderDefines);
  7018. shader.addSubShader(subShader);
  7019. subShader.addShaderPass(vs,ps,stateMap);
  7020. attributeMap={
  7021. 'a_Position':/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0,
  7022. 'a_Texcoord0':/*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE0*/2,
  7023. 'a_BoneWeights':/*laya.d3.graphics.Vertex.VertexMesh.MESH_BLENDWEIGHT0*/6,
  7024. 'a_BoneIndices':/*laya.d3.graphics.Vertex.VertexMesh.MESH_BLENDINDICES0*/5,
  7025. 'a_MvpMatrix':/*laya.d3.graphics.Vertex.VertexMesh.MESH_MVPMATRIX_ROW0*/12
  7026. };
  7027. uniformMap={
  7028. 'u_Bones':/*laya.d3.shader.Shader3D.PERIOD_CUSTOM*/0,
  7029. 'u_AlbedoTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7030. 'u_AlbedoColor':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7031. 'u_TilingOffset':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7032. 'u_AlphaTestValue':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7033. 'u_MvpMatrix':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7034. 'u_FogStart':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  7035. 'u_FogRange':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  7036. 'u_FogColor':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4
  7037. };
  7038. stateMap={
  7039. 's_Cull':/*laya.d3.shader.Shader3D.RENDER_STATE_CULL*/0,
  7040. 's_Blend':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND*/1,
  7041. 's_BlendSrc':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_SRC*/2,
  7042. 's_BlendDst':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_DST*/3,
  7043. 's_DepthTest':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_TEST*/12,
  7044. 's_DepthWrite':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_WRITE*/13
  7045. }
  7046. 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}";
  7047. 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";
  7048. shader=Shader3D.add("Effect",true);
  7049. subShader=new SubShader(attributeMap,uniformMap,SkinnedMeshSprite3D.shaderDefines,EffectMaterial.shaderDefines);
  7050. shader.addSubShader(subShader);
  7051. subShader.addShaderPass(vs,ps,stateMap);
  7052. attributeMap={
  7053. 'a_CornerTextureCoordinate':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_CORNERTEXTURECOORDINATE0*/0,
  7054. 'a_MeshPosition':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_POSITION0*/1,
  7055. 'a_MeshColor':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_COLOR0*/2,
  7056. 'a_MeshTextureCoordinate':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_TEXTURECOORDINATE0*/3,
  7057. 'a_ShapePositionStartLifeTime':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_SHAPEPOSITIONSTARTLIFETIME*/4,
  7058. 'a_DirectionTime':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_DIRECTIONTIME*/5,
  7059. 'a_StartColor':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_STARTCOLOR0*/6,
  7060. 'a_EndColor':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_ENDCOLOR0*/7,
  7061. 'a_StartSize':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_STARTSIZE*/8,
  7062. 'a_StartRotation0':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_STARTROTATION*/9,
  7063. 'a_StartSpeed':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_STARTSPEED*/10,
  7064. 'a_Random0':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_RANDOM0*/11,
  7065. 'a_Random1':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_RANDOM1*/12,
  7066. 'a_SimulationWorldPostion':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_SIMULATIONWORLDPOSTION*/13,
  7067. 'a_SimulationWorldRotation':/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_SIMULATIONWORLDROTATION*/14};
  7068. uniformMap={
  7069. 'u_Tintcolor':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7070. 'u_TilingOffset':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7071. 'u_texture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7072. 'u_WorldPosition':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7073. 'u_WorldRotation':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7074. 'u_PositionScale':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7075. 'u_SizeScale':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7076. 'u_ScalingMode':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7077. 'u_Gravity':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7078. 'u_ThreeDStartRotation':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7079. 'u_StretchedBillboardLengthScale':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7080. 'u_StretchedBillboardSpeedScale':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7081. 'u_SimulationSpace':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7082. 'u_CurrentTime':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7083. 'u_ColorOverLifeGradientAlphas':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7084. 'u_ColorOverLifeGradientColors':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7085. 'u_MaxColorOverLifeGradientAlphas':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7086. 'u_MaxColorOverLifeGradientColors':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7087. 'u_VOLVelocityConst':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7088. 'u_VOLVelocityGradientX':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7089. 'u_VOLVelocityGradientY':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7090. 'u_VOLVelocityGradientZ':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7091. 'u_VOLVelocityConstMax':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7092. 'u_VOLVelocityGradientMaxX':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7093. 'u_VOLVelocityGradientMaxY':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7094. 'u_VOLVelocityGradientMaxZ':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7095. 'u_VOLSpaceType':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7096. 'u_SOLSizeGradient':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7097. 'u_SOLSizeGradientX':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7098. 'u_SOLSizeGradientY':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7099. 'u_SOLSizeGradientZ':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7100. 'u_SOLSizeGradientMax':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7101. 'u_SOLSizeGradientMaxX':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7102. 'u_SOLSizeGradientMaxY':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7103. 'u_SOLSizeGradientMaxZ':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7104. 'u_ROLAngularVelocityConst':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7105. 'u_ROLAngularVelocityConstSeprarate':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7106. 'u_ROLAngularVelocityGradient':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7107. 'u_ROLAngularVelocityGradientX':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7108. 'u_ROLAngularVelocityGradientY':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7109. 'u_ROLAngularVelocityGradientZ':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7110. 'u_ROLAngularVelocityConstMax':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7111. 'u_ROLAngularVelocityConstMaxSeprarate':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7112. 'u_ROLAngularVelocityGradientMax':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7113. 'u_ROLAngularVelocityGradientMaxX':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7114. 'u_ROLAngularVelocityGradientMaxY':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7115. 'u_ROLAngularVelocityGradientMaxZ':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7116. 'u_ROLAngularVelocityGradientMaxW':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7117. 'u_TSACycles':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7118. 'u_TSASubUVLength':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7119. 'u_TSAGradientUVs':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7120. 'u_TSAMaxGradientUVs':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7121. 'u_CameraPos':/*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3,
  7122. 'u_CameraDirection':/*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3,
  7123. 'u_CameraUp':/*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3,
  7124. 'u_View':/*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3,
  7125. 'u_Projection':/*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3,
  7126. 'u_FogStart':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  7127. 'u_FogRange':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  7128. 'u_FogColor':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4
  7129. };
  7130. stateMap={
  7131. 's_Cull':/*laya.d3.shader.Shader3D.RENDER_STATE_CULL*/0,
  7132. 's_Blend':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND*/1,
  7133. 's_BlendSrc':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_SRC*/2,
  7134. 's_BlendDst':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_DST*/3,
  7135. 's_DepthTest':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_TEST*/12,
  7136. 's_DepthWrite':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_WRITE*/13
  7137. };
  7138. 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";
  7139. //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}";
  7140. 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 #else\n \n #endif\n #endif\n}";
  7141. shader=Shader3D.add("PARTICLESHURIKEN");
  7142. subShader=new SubShader(attributeMap,uniformMap,ShuriKenParticle3D.shaderDefines,ShurikenParticleMaterial.shaderDefines);
  7143. shader.addSubShader(subShader);
  7144. subShader.addShaderPass(vs,ps,stateMap);
  7145. attributeMap={
  7146. 'a_Position':/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0};
  7147. uniformMap={
  7148. 'u_TintColor':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7149. 'u_Exposure':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7150. 'u_Rotation':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7151. 'u_CubeTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7152. 'u_MvpMatrix':/*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3};
  7153. 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";
  7154. 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";
  7155. shader=Shader3D.add("SkyBox");
  7156. subShader=new SubShader(attributeMap,uniformMap);
  7157. shader.addSubShader(subShader);
  7158. subShader.addShaderPass(vs,ps);
  7159. attributeMap={
  7160. 'a_Position':/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0};
  7161. uniformMap={
  7162. 'u_SunSize':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7163. 'u_SunSizeConvergence':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7164. 'u_AtmosphereThickness':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7165. 'u_SkyTint':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7166. 'u_GroundTint':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7167. 'u_Exposure':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7168. 'u_MvpMatrix':/*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3,
  7169. 'u_DirectionLight.Direction':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  7170. 'u_DirectionLight.Color':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4
  7171. };
  7172. 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";
  7173. 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";
  7174. shader=Shader3D.add("SkyBoxProcedural");
  7175. subShader=new SubShader(attributeMap,uniformMap,null,SkyProceduralMaterial.shaderDefines);
  7176. shader.addSubShader(subShader);
  7177. subShader.addShaderPass(vs,ps);
  7178. attributeMap={
  7179. 'a_Position':/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0,
  7180. 'a_Normal':/*laya.d3.graphics.Vertex.VertexMesh.MESH_NORMAL0*/3,
  7181. 'a_Texcoord0':/*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE0*/2
  7182. };
  7183. uniformMap={
  7184. 'u_MvpMatrix':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7185. 'u_WorldMat':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7186. 'u_CameraPos':/*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3,
  7187. 'u_LightmapScaleOffset':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7188. 'u_LightMap':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7189. 'u_SplatAlphaTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7190. 'u_DiffuseTexture1':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7191. 'u_DiffuseTexture2':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7192. 'u_DiffuseTexture3':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7193. 'u_DiffuseTexture4':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7194. 'u_DiffuseTexture5':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7195. 'u_DiffuseScaleOffset1':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7196. 'u_DiffuseScaleOffset2':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7197. 'u_DiffuseScaleOffset3':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7198. 'u_DiffuseScaleOffset4':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7199. 'u_DiffuseScaleOffset5':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7200. 'u_FogStart':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  7201. 'u_FogRange':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  7202. 'u_FogColor':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  7203. 'u_DirectionLight.Direction':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  7204. 'u_DirectionLight.Color':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  7205. 'u_PointLight.Position':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  7206. 'u_PointLight.Range':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  7207. 'u_PointLight.Attenuation':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  7208. 'u_PointLight.Color':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  7209. 'u_SpotLight.Position':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  7210. 'u_SpotLight.Direction':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  7211. 'u_SpotLight.Range':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  7212. 'u_SpotLight.Spot':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  7213. 'u_SpotLight.Color':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  7214. 'u_AmbientColor':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  7215. 'u_shadowMap1':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  7216. 'u_shadowMap2':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  7217. 'u_shadowMap3':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  7218. 'u_shadowPSSMDistance':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  7219. 'u_lightShadowVP':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  7220. 'u_shadowPCFoffset':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4
  7221. };
  7222. stateMap={
  7223. 's_Cull':/*laya.d3.shader.Shader3D.RENDER_STATE_CULL*/0,
  7224. 's_Blend':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND*/1,
  7225. 's_BlendSrc':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_SRC*/2,
  7226. 's_BlendDst':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_DST*/3,
  7227. 's_DepthTest':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_TEST*/12,
  7228. 's_DepthWrite':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_WRITE*/13
  7229. };
  7230. 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}";
  7231. 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";
  7232. shader=Shader3D.add("ExtendTerrain");
  7233. subShader=new SubShader(attributeMap,uniformMap,RenderableSprite3D.shaderDefines,ExtendTerrainMaterial.shaderDefines);
  7234. shader.addSubShader(subShader);
  7235. subShader.addShaderPass(vs,ps,stateMap);
  7236. attributeMap={
  7237. 'a_Position' :/*laya.d3.core.trail.VertexTrail.TRAIL_POSITION0*/0,
  7238. 'a_OffsetVector':/*laya.d3.core.trail.VertexTrail.TRAIL_OFFSETVECTOR*/1,
  7239. 'a_Texcoord0X' :/*laya.d3.core.trail.VertexTrail.TRAIL_TEXTURECOORDINATE0X*/4,
  7240. 'a_Texcoord0Y' :/*laya.d3.core.trail.VertexTrail.TRAIL_TEXTURECOORDINATE0Y*/3,
  7241. 'a_BirthTime' :/*laya.d3.core.trail.VertexTrail.TRAIL_TIME0*/2
  7242. };
  7243. uniformMap={
  7244. 'u_MvpMatrix':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7245. 'u_View':/*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3,
  7246. 'u_Projection':/*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3,
  7247. 'u_TilingOffset':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7248. 'u_MainTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7249. 'u_MainColor':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7250. 'u_CurTime' :/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7251. 'u_LifeTime' :/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7252. 'u_WidthCurve' :/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7253. 'u_WidthCurveKeyLength' :/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7254. 'u_GradientColorkey' :/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7255. 'u_GradientAlphakey' :/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2
  7256. };
  7257. stateMap={
  7258. 's_Cull':/*laya.d3.shader.Shader3D.RENDER_STATE_CULL*/0,
  7259. 's_Blend':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND*/1,
  7260. 's_BlendSrc':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_SRC*/2,
  7261. 's_BlendDst':/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_DST*/3,
  7262. 's_DepthTest':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_TEST*/12,
  7263. 's_DepthWrite':/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_WRITE*/13
  7264. };
  7265. 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";
  7266. 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";
  7267. shader=Shader3D.add("Trail");
  7268. subShader=new SubShader(attributeMap,uniformMap,TrailSprite3D.shaderDefines,TrailMaterial.shaderDefines);
  7269. shader.addSubShader(subShader);
  7270. subShader.addShaderPass(vs,ps,stateMap);
  7271. attributeMap={
  7272. 'a_Position':/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0,
  7273. 'a_Normal':/*laya.d3.graphics.Vertex.VertexMesh.MESH_NORMAL0*/3,
  7274. 'a_Tangent0':/*laya.d3.graphics.Vertex.VertexMesh.MESH_TANGENT0*/4
  7275. };
  7276. uniformMap={
  7277. 'u_MvpMatrix':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7278. 'u_WorldMat':/*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2,
  7279. 'u_CameraPos':/*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3,
  7280. 'u_Time':/*laya.d3.shader.Shader3D.PERIOD_SCENE*/4,
  7281. 'u_MainTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7282. 'u_NormalTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7283. 'u_HorizonColor':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7284. 'u_WaveScale' :/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7285. 'u_WaveSpeed' :/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1
  7286. };
  7287. 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}";
  7288. 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";
  7289. shader=Shader3D.add("WaterPrimary");
  7290. subShader=new SubShader(attributeMap,uniformMap,null,WaterPrimaryMaterial.shaderDefines);
  7291. shader.addSubShader(subShader);
  7292. subShader.addShaderPass(vs,ps);
  7293. attributeMap={
  7294. 'a_PositionTexcoord':/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0
  7295. };
  7296. uniformMap={
  7297. 'u_ScreenTexture':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1
  7298. };
  7299. 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}";
  7300. 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";
  7301. shader=Shader3D.add("ScreenQuad");
  7302. subShader=new SubShader(attributeMap,uniformMap,null,null);
  7303. shader.addSubShader(subShader);
  7304. var shaderPass=subShader.addShaderPass(vs,ps);
  7305. var renderState=shaderPass.renderState;
  7306. renderState.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_ALWAYS*/0x0207;
  7307. renderState.depthWrite=false;
  7308. renderState.cull=/*laya.d3.core.material.RenderState.CULL_NONE*/0;
  7309. renderState.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  7310. attributeMap={
  7311. 'a_PositionTexcoord':/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0
  7312. };
  7313. uniformMap={
  7314. 'u_MainTex':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7315. 'u_BloomTex':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7316. 'u_AutoExposureTex':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7317. 'u_MainTex_TexelSize':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7318. 'u_SampleScale':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7319. 'u_Threshold':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7320. 'u_Params' :/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1
  7321. };
  7322. shader=Shader3D.add("PostProcessBloom",attributeMap,uniformMap);
  7323. subShader=new SubShader(null,null,null,null);
  7324. shader.addSubShader(subShader);
  7325. 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}");
  7326. renderState=shaderPass.renderState;
  7327. renderState.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_ALWAYS*/0x0207;
  7328. renderState.depthWrite=false;
  7329. renderState.cull=/*laya.d3.core.material.RenderState.CULL_NONE*/0;
  7330. renderState.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  7331. subShader=new SubShader(null,null,null,null);
  7332. shader.addSubShader(subShader);
  7333. 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}");
  7334. renderState=shaderPass.renderState;
  7335. renderState.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_ALWAYS*/0x0207;
  7336. renderState.depthWrite=false;
  7337. renderState.cull=/*laya.d3.core.material.RenderState.CULL_NONE*/0;
  7338. renderState.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  7339. subShader=new SubShader(null,null,null,null);
  7340. shader.addSubShader(subShader);
  7341. 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}");
  7342. renderState=shaderPass.renderState;
  7343. renderState.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_ALWAYS*/0x0207;
  7344. renderState.depthWrite=false;
  7345. renderState.cull=/*laya.d3.core.material.RenderState.CULL_NONE*/0;
  7346. renderState.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  7347. subShader=new SubShader(null,null,null,null);
  7348. shader.addSubShader(subShader);
  7349. 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}");
  7350. renderState=shaderPass.renderState;
  7351. renderState.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_ALWAYS*/0x0207;
  7352. renderState.depthWrite=false;
  7353. renderState.cull=/*laya.d3.core.material.RenderState.CULL_NONE*/0;
  7354. renderState.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  7355. subShader=new SubShader(null,null,null,null);
  7356. shader.addSubShader(subShader);
  7357. 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}");
  7358. renderState=shaderPass.renderState;
  7359. renderState.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_ALWAYS*/0x0207;
  7360. renderState.depthWrite=false;
  7361. renderState.cull=/*laya.d3.core.material.RenderState.CULL_NONE*/0;
  7362. renderState.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  7363. subShader=new SubShader(null,null,null,null);
  7364. shader.addSubShader(subShader);
  7365. 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}");
  7366. renderState=shaderPass.renderState;
  7367. renderState.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_ALWAYS*/0x0207;
  7368. renderState.depthWrite=false;
  7369. renderState.cull=/*laya.d3.core.material.RenderState.CULL_NONE*/0;
  7370. renderState.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  7371. attributeMap={
  7372. 'a_PositionTexcoord':/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0
  7373. };
  7374. uniformMap={
  7375. 'u_MainTex':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7376. 'u_BloomTex':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7377. 'u_AutoExposureTex':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7378. 'u_Bloom_DirtTex':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7379. 'u_BloomTex_TexelSize':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7380. 'u_Bloom_Settings':/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1,
  7381. 'u_Bloom_Color' :/*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1
  7382. };
  7383. shader=Shader3D.add("PostProcessComposite",attributeMap,uniformMap);
  7384. subShader=new SubShader(null,null,null,PostProcess.shaderDefines);
  7385. shader.addSubShader(subShader);
  7386. 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}");
  7387. renderState=shaderPass.renderState;
  7388. renderState.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_ALWAYS*/0x0207;
  7389. renderState.depthWrite=false;
  7390. renderState.cull=/*laya.d3.core.material.RenderState.CULL_NONE*/0;
  7391. renderState.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  7392. }
  7393. ShaderInit3D._rangeAttenTex=null;
  7394. return ShaderInit3D;
  7395. })()
  7396. /**
  7397. *@private
  7398. *<code>LoadModelV05</code> 类用于模型加载。
  7399. */
  7400. //class laya.d3.loaders.LoadModelV05
  7401. var LoadModelV05=(function(){
  7402. function LoadModelV05(){}
  7403. __class(LoadModelV05,'laya.d3.loaders.LoadModelV05');
  7404. LoadModelV05.parse=function(readData,version,mesh,subMeshes){
  7405. LoadModelV05._mesh=mesh;
  7406. LoadModelV05._subMeshes=subMeshes;
  7407. LoadModelV05._version=version;
  7408. LoadModelV05._readData=readData;
  7409. LoadModelV05.READ_DATA();
  7410. LoadModelV05.READ_BLOCK();
  7411. LoadModelV05.READ_STRINGS();
  7412. for (var i=0,n=LoadModelV05._BLOCK.count;i < n;i++){
  7413. LoadModelV05._readData.pos=LoadModelV05._BLOCK.blockStarts[i];
  7414. var index=LoadModelV05._readData.getUint16();
  7415. var blockName=LoadModelV05._strings[index];
  7416. var fn=LoadModelV05["READ_"+blockName];
  7417. if (fn==null)
  7418. throw new Error("model file err,no this function:"+index+" "+blockName);
  7419. else
  7420. fn.call(null);
  7421. }
  7422. LoadModelV05._mesh._bindPoseIndices=new Uint16Array(LoadModelV05._bindPoseIndices);
  7423. LoadModelV05._bindPoseIndices.length=0;
  7424. LoadModelV05._strings.length=0;
  7425. LoadModelV05._readData=null;
  7426. LoadModelV05._version=null;
  7427. LoadModelV05._mesh=null;
  7428. LoadModelV05._subMeshes=null;
  7429. }
  7430. LoadModelV05._readString=function(){
  7431. return LoadModelV05._strings[LoadModelV05._readData.getUint16()];
  7432. }
  7433. LoadModelV05.READ_DATA=function(){
  7434. LoadModelV05._DATA.offset=LoadModelV05._readData.getUint32();
  7435. LoadModelV05._DATA.size=LoadModelV05._readData.getUint32();
  7436. }
  7437. LoadModelV05.READ_BLOCK=function(){
  7438. var count=LoadModelV05._BLOCK.count=LoadModelV05._readData.getUint16();
  7439. var blockStarts=LoadModelV05._BLOCK.blockStarts=[];
  7440. var blockLengths=LoadModelV05._BLOCK.blockLengths=[];
  7441. for (var i=0;i < count;i++){
  7442. blockStarts.push(LoadModelV05._readData.getUint32());
  7443. blockLengths.push(LoadModelV05._readData.getUint32());
  7444. }
  7445. }
  7446. LoadModelV05.READ_STRINGS=function(){
  7447. var offset=LoadModelV05._readData.getUint32();
  7448. var count=LoadModelV05._readData.getUint16();
  7449. var prePos=LoadModelV05._readData.pos;
  7450. LoadModelV05._readData.pos=offset+LoadModelV05._DATA.offset;
  7451. for (var i=0;i < count;i++)
  7452. LoadModelV05._strings[i]=LoadModelV05._readData.readUTFString();
  7453. LoadModelV05._readData.pos=prePos;
  7454. }
  7455. LoadModelV05.READ_MESH=function(){
  7456. var i=0,n=0;
  7457. var memorySize=0;
  7458. var name=LoadModelV05._readString();
  7459. var arrayBuffer=LoadModelV05._readData.__getBuffer();
  7460. var vertexBufferCount=LoadModelV05._readData.getInt16();
  7461. var offset=LoadModelV05._DATA.offset;
  7462. for (i=0;i < vertexBufferCount;i++){
  7463. var vbStart=offset+LoadModelV05._readData.getUint32();
  7464. var vertexCount=LoadModelV05._readData.getUint32();
  7465. var vertexFlag=LoadModelV05._readString();
  7466. var vertexDeclaration=VertexMesh.getVertexDeclaration(vertexFlag,false);
  7467. var vertexStride=vertexDeclaration.vertexStride;
  7468. var vertexData=new ArrayBuffer(vertexStride *vertexCount);
  7469. var floatData=new Float32Array(vertexData);
  7470. var subVertexFlags=vertexFlag.split(",");
  7471. var subVertexCount=subVertexFlags.length;
  7472. switch (LoadModelV05._version){
  7473. case "LAYAMODEL:05":
  7474. floatData=new Float32Array(arrayBuffer.slice(vbStart,vbStart+vertexCount *vertexStride));
  7475. break ;
  7476. case "LAYAMODEL:COMPRESSION_05":;
  7477. var lastPosition=LoadModelV05._readData.pos;
  7478. floatData=new Float32Array(vertexData);
  7479. var uint8Data=new Uint8Array(vertexData);
  7480. LoadModelV05._readData.pos=vbStart;
  7481. for (var j=0;j < vertexCount;j++){
  7482. var subOffset=0;
  7483. var verOffset=j *vertexStride;
  7484. for (var k=0;k < subVertexCount;k++){
  7485. switch (subVertexFlags[k]){
  7486. case "POSITION":
  7487. subOffset=verOffset / 4;
  7488. floatData[subOffset]=HalfFloatUtils.convertToNumber(LoadModelV05._readData.getUint16());
  7489. floatData[subOffset+1]=HalfFloatUtils.convertToNumber(LoadModelV05._readData.getUint16());
  7490. floatData[subOffset+2]=HalfFloatUtils.convertToNumber(LoadModelV05._readData.getUint16());
  7491. verOffset+=12;
  7492. break ;
  7493. case "NORMAL":
  7494. subOffset=verOffset / 4;
  7495. floatData[subOffset]=LoadModelV05._readData.getUint8()/ 127.5-1;
  7496. floatData[subOffset+1]=LoadModelV05._readData.getUint8()/ 127.5-1;
  7497. floatData[subOffset+2]=LoadModelV05._readData.getUint8()/ 127.5-1;
  7498. verOffset+=12;
  7499. break ;
  7500. case "COLOR":
  7501. subOffset=verOffset / 4;
  7502. floatData[subOffset]=LoadModelV05._readData.getUint8()/ 255;
  7503. floatData[subOffset+1]=LoadModelV05._readData.getUint8()/ 255;
  7504. floatData[subOffset+2]=LoadModelV05._readData.getUint8()/ 255;
  7505. floatData[subOffset+3]=LoadModelV05._readData.getUint8()/ 255;
  7506. verOffset+=16;
  7507. break ;
  7508. case "UV":
  7509. subOffset=verOffset / 4;
  7510. floatData[subOffset]=HalfFloatUtils.convertToNumber(LoadModelV05._readData.getUint16());
  7511. floatData[subOffset+1]=HalfFloatUtils.convertToNumber(LoadModelV05._readData.getUint16());
  7512. verOffset+=8;
  7513. break ;
  7514. case "UV1":
  7515. subOffset=verOffset / 4;
  7516. floatData[subOffset]=HalfFloatUtils.convertToNumber(LoadModelV05._readData.getUint16());
  7517. floatData[subOffset+1]=HalfFloatUtils.convertToNumber(LoadModelV05._readData.getUint16());
  7518. verOffset+=8;
  7519. break ;
  7520. case "BLENDWEIGHT":
  7521. subOffset=verOffset / 4;
  7522. floatData[subOffset]=LoadModelV05._readData.getUint8()/ 255;
  7523. floatData[subOffset+1]=LoadModelV05._readData.getUint8()/ 255;
  7524. floatData[subOffset+2]=LoadModelV05._readData.getUint8()/ 255;
  7525. floatData[subOffset+3]=LoadModelV05._readData.getUint8()/ 255;
  7526. verOffset+=16;
  7527. break ;
  7528. case "BLENDINDICES":
  7529. uint8Data[verOffset]=LoadModelV05._readData.getUint8();
  7530. uint8Data[verOffset+1]=LoadModelV05._readData.getUint8();
  7531. uint8Data[verOffset+2]=LoadModelV05._readData.getUint8();
  7532. uint8Data[verOffset+3]=LoadModelV05._readData.getUint8();
  7533. verOffset+=4;
  7534. break ;
  7535. case "TANGENT":
  7536. subOffset=verOffset / 4;
  7537. floatData[subOffset]=LoadModelV05._readData.getUint8()/ 127.5-1;
  7538. floatData[subOffset+1]=LoadModelV05._readData.getUint8()/ 127.5-1;
  7539. floatData[subOffset+2]=LoadModelV05._readData.getUint8()/ 127.5-1;
  7540. floatData[subOffset+3]=LoadModelV05._readData.getUint8()/ 127.5-1;
  7541. verOffset+=16;
  7542. break ;
  7543. }
  7544. }
  7545. }
  7546. LoadModelV05._readData.pos=lastPosition;
  7547. break ;
  7548. };
  7549. var vertexBuffer=new VertexBuffer3D(vertexData.byteLength,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,true);
  7550. vertexBuffer.vertexDeclaration=vertexDeclaration;
  7551. vertexBuffer.setData(floatData);
  7552. LoadModelV05._mesh._vertexBuffers.push(vertexBuffer);
  7553. LoadModelV05._mesh._vertexCount+=vertexBuffer.vertexCount;
  7554. memorySize+=floatData.length *4;
  7555. };
  7556. var ibStart=offset+LoadModelV05._readData.getUint32();
  7557. var ibLength=LoadModelV05._readData.getUint32();
  7558. var ibDatas=new Uint16Array(arrayBuffer.slice(ibStart,ibStart+ibLength));
  7559. var indexBuffer=new IndexBuffer3D(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",ibLength / 2,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,true);
  7560. indexBuffer.setData(ibDatas);
  7561. LoadModelV05._mesh._indexBuffer=indexBuffer;
  7562. LoadModelV05._mesh._setBuffer(LoadModelV05._mesh._vertexBuffers,indexBuffer);
  7563. memorySize+=indexBuffer.indexCount *2;
  7564. LoadModelV05._mesh._setCPUMemory(memorySize);
  7565. LoadModelV05._mesh._setGPUMemory(memorySize);
  7566. var boneNames=LoadModelV05._mesh._boneNames=[];
  7567. var boneCount=LoadModelV05._readData.getUint16();
  7568. boneNames.length=boneCount;
  7569. for (i=0;i < boneCount;i++)
  7570. boneNames[i]=LoadModelV05._strings[LoadModelV05._readData.getUint16()];
  7571. var bindPoseDataStart=LoadModelV05._readData.getUint32();
  7572. var bindPoseDataLength=LoadModelV05._readData.getUint32();
  7573. var bindPoseDatas=new Float32Array(arrayBuffer.slice(offset+bindPoseDataStart,offset+bindPoseDataStart+bindPoseDataLength));
  7574. var bindPoseFloatCount=bindPoseDatas.length;
  7575. var bindPoseCount=bindPoseFloatCount / 16;
  7576. var bindPoseBuffer=LoadModelV05._mesh._inverseBindPosesBuffer=new ArrayBuffer(bindPoseFloatCount *4);
  7577. LoadModelV05._mesh._inverseBindPoses=__newvec(bindPoseCount);
  7578. for (i=0;i < bindPoseFloatCount;i+=16){
  7579. 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));
  7580. LoadModelV05._mesh._inverseBindPoses[i / 16]=inverseGlobalBindPose;
  7581. }
  7582. return true;
  7583. }
  7584. LoadModelV05.READ_SUBMESH=function(){
  7585. var arrayBuffer=LoadModelV05._readData.__getBuffer();
  7586. var submesh=new SubMesh(LoadModelV05._mesh);
  7587. var vbIndex=LoadModelV05._readData.getInt16();
  7588. var ibStart=LoadModelV05._readData.getUint32();
  7589. var ibCount=LoadModelV05._readData.getUint32();
  7590. var indexBuffer=LoadModelV05._mesh._indexBuffer;
  7591. submesh._indexBuffer=indexBuffer;
  7592. submesh._indexStart=ibStart;
  7593. submesh._indexCount=ibCount;
  7594. submesh._indices=new Uint16Array(indexBuffer.getData().buffer,ibStart *2,ibCount);
  7595. var vertexBuffer=LoadModelV05._mesh._vertexBuffers[vbIndex];
  7596. submesh._vertexBuffer=vertexBuffer;
  7597. var offset=LoadModelV05._DATA.offset;
  7598. var subIndexBufferStart=submesh._subIndexBufferStart;
  7599. var subIndexBufferCount=submesh._subIndexBufferCount;
  7600. var boneIndicesList=submesh._boneIndicesList;
  7601. var drawCount=LoadModelV05._readData.getUint16();
  7602. subIndexBufferStart.length=drawCount;
  7603. subIndexBufferCount.length=drawCount;
  7604. boneIndicesList.length=drawCount;
  7605. var pathMarks=LoadModelV05._mesh._skinDataPathMarks;
  7606. var bindPoseIndices=LoadModelV05._bindPoseIndices;
  7607. var subMeshIndex=LoadModelV05._subMeshes.length;
  7608. for (var i=0;i < drawCount;i++){
  7609. subIndexBufferStart[i]=LoadModelV05._readData.getUint32();
  7610. subIndexBufferCount[i]=LoadModelV05._readData.getUint32();
  7611. var boneDicofs=LoadModelV05._readData.getUint32();
  7612. var boneDicCount=LoadModelV05._readData.getUint32();
  7613. var boneIndices=boneIndicesList[i]=new Uint16Array(arrayBuffer.slice(offset+boneDicofs,offset+boneDicofs+boneDicCount));
  7614. for (var j=0,m=boneIndices.length;j < m;j++){
  7615. var index=boneIndices[j];
  7616. var combineIndex=bindPoseIndices.indexOf(index);
  7617. if (combineIndex===-1){
  7618. boneIndices[j]=bindPoseIndices.length;
  7619. bindPoseIndices.push(index);
  7620. pathMarks.push([subMeshIndex,i,j]);
  7621. }else {
  7622. boneIndices[j]=combineIndex;
  7623. }
  7624. }
  7625. }
  7626. LoadModelV05._subMeshes.push(submesh);
  7627. return true;
  7628. }
  7629. LoadModelV05._strings=[];
  7630. LoadModelV05._readData=null;
  7631. LoadModelV05._version=null;
  7632. LoadModelV05._mesh=null;
  7633. LoadModelV05._subMeshes=null;
  7634. LoadModelV05._bindPoseIndices=[];
  7635. __static(LoadModelV05,
  7636. ['_BLOCK',function(){return this._BLOCK={count:0};},'_DATA',function(){return this._DATA={offset:0,size:0};}
  7637. ]);
  7638. return LoadModelV05;
  7639. })()
  7640. /**
  7641. *<code>PrimitiveMesh</code> 类用于创建简单网格。
  7642. */
  7643. //class laya.d3.resource.models.PrimitiveMesh
  7644. var PrimitiveMesh=(function(){
  7645. function PrimitiveMesh(){}
  7646. __class(PrimitiveMesh,'laya.d3.resource.models.PrimitiveMesh');
  7647. PrimitiveMesh._createMesh=function(vertexDeclaration,vertices,indices){
  7648. var mesh=new Mesh();
  7649. var subMesh=new SubMesh(mesh);
  7650. var vertexBuffer=new VertexBuffer3D(vertices.length *4,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,true);
  7651. vertexBuffer.vertexDeclaration=vertexDeclaration;
  7652. vertexBuffer.setData(vertices);
  7653. mesh._vertexBuffers.push(vertexBuffer);
  7654. mesh._vertexCount+=vertexBuffer.vertexCount;
  7655. var indexBuffer=new IndexBuffer3D(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",indices.length,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,true);
  7656. indexBuffer.setData(indices);
  7657. mesh._indexBuffer=indexBuffer;
  7658. var vertexBuffers=__newvec(1,null);
  7659. vertexBuffers[0]=vertexBuffer;
  7660. mesh._setBuffer(vertexBuffers,indexBuffer);
  7661. subMesh._vertexBuffer=vertexBuffer;
  7662. subMesh._indexBuffer=indexBuffer;
  7663. subMesh._indexStart=0;
  7664. subMesh._indexCount=indexBuffer.indexCount;
  7665. var subIndexBufferStart=subMesh._subIndexBufferStart;
  7666. var subIndexBufferCount=subMesh._subIndexBufferCount;
  7667. var boneIndicesList=subMesh._boneIndicesList;
  7668. subIndexBufferStart.length=1;
  7669. subIndexBufferCount.length=1;
  7670. boneIndicesList.length=1;
  7671. subIndexBufferStart[0]=0;
  7672. subIndexBufferCount[0]=indexBuffer.indexCount;
  7673. var subMeshes=[];
  7674. subMeshes.push(subMesh);
  7675. mesh._setSubMeshes(subMeshes);
  7676. var memorySize=vertexBuffer._byteLength+indexBuffer._byteLength;
  7677. mesh._setCPUMemory(memorySize);
  7678. mesh._setGPUMemory(memorySize);
  7679. return mesh;
  7680. }
  7681. PrimitiveMesh.createBox=function(long,height,width){
  7682. (long===void 0)&& (long=1);
  7683. (height===void 0)&& (height=1);
  7684. (width===void 0)&& (width=1);
  7685. var vertexCount=24;
  7686. var indexCount=36;
  7687. var vertexDeclaration=VertexMesh.getVertexDeclaration("POSITION,NORMAL,UV");
  7688. var halfLong=long / 2;
  7689. var halfHeight=height / 2;
  7690. var halfWidth=width / 2;
  7691. var vertices=new Float32Array([
  7692. -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,
  7693. -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,
  7694. -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,
  7695. 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,
  7696. -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,
  7697. -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]);
  7698. var indices=new Uint16Array([
  7699. 0,1,2,2,3,0,
  7700. 4,7,6,6,5,4,
  7701. 8,9,10,10,11,8,
  7702. 12,15,14,14,13,12,
  7703. 16,17,18,18,19,16,
  7704. 20,23,22,22,21,20]);
  7705. return PrimitiveMesh._createMesh(vertexDeclaration,vertices,indices);
  7706. }
  7707. PrimitiveMesh.createCapsule=function(radius,height,stacks,slices){
  7708. (radius===void 0)&& (radius=0.5);
  7709. (height===void 0)&& (height=2);
  7710. (stacks===void 0)&& (stacks=16);
  7711. (slices===void 0)&& (slices=32);
  7712. var vertexCount=(stacks+1)*(slices+1)*2+(slices+1)*2;
  7713. var indexCount=(3 *stacks *(slices+1))*2 *2+2 *slices *3;
  7714. var vertexDeclaration=VertexMesh.getVertexDeclaration("POSITION,NORMAL,UV");
  7715. var vertexFloatStride=vertexDeclaration.vertexStride / 4;
  7716. var vertices=new Float32Array(vertexCount *vertexFloatStride);
  7717. var indices=new Uint16Array(indexCount);
  7718. var stackAngle=(Math.PI / 2.0)/ stacks;
  7719. var sliceAngle=(Math.PI *2.0)/ slices;
  7720. var hcHeight=height / 2-radius;
  7721. var posX=0;
  7722. var posY=0;
  7723. var posZ=0;
  7724. var vc=0;
  7725. var ic=0;
  7726. var verticeCount=0;
  7727. var stack=0,slice=0;
  7728. for (stack=0;stack <=stacks;stack++){
  7729. for (slice=0;slice <=slices;slice++){
  7730. posX=radius *Math.cos(stack *stackAngle)*Math.cos(slice *sliceAngle+Math.PI);
  7731. posY=radius *Math.sin(stack *stackAngle);
  7732. posZ=radius *Math.cos(stack *stackAngle)*Math.sin(slice *sliceAngle+Math.PI);
  7733. vertices[vc++]=posX;
  7734. vertices[vc++]=posY+hcHeight;
  7735. vertices[vc++]=posZ;
  7736. vertices[vc++]=posX;
  7737. vertices[vc++]=posY;
  7738. vertices[vc++]=posZ;
  7739. vertices[vc++]=1-slice / slices;
  7740. vertices[vc++]=(1-stack / stacks)*((Math.PI *radius / 2)/ (height+Math.PI *radius));
  7741. if (stack < stacks){
  7742. indices[ic++]=(stack *(slices+1))+slice+(slices+1);
  7743. indices[ic++]=(stack *(slices+1))+slice;
  7744. indices[ic++]=(stack *(slices+1))+slice+1;
  7745. indices[ic++]=(stack *(slices+1))+slice+(slices);
  7746. indices[ic++]=(stack *(slices+1))+slice;
  7747. indices[ic++]=(stack *(slices+1))+slice+(slices+1);
  7748. }
  7749. }
  7750. }
  7751. verticeCount+=(stacks+1)*(slices+1);
  7752. for (stack=0;stack <=stacks;stack++){
  7753. for (slice=0;slice <=slices;slice++){
  7754. posX=radius *Math.cos(stack *stackAngle)*Math.cos(slice *sliceAngle+Math.PI);
  7755. posY=radius *Math.sin(-stack *stackAngle);
  7756. posZ=radius *Math.cos(stack *stackAngle)*Math.sin(slice *sliceAngle+Math.PI);
  7757. vertices[vc++]=posX;
  7758. vertices[vc++]=posY-hcHeight;
  7759. vertices[vc++]=posZ;
  7760. vertices[vc++]=posX;
  7761. vertices[vc++]=posY;
  7762. vertices[vc++]=posZ;
  7763. vertices[vc++]=1-slice / slices;
  7764. vertices[vc++]=((stack / stacks)*(Math.PI *radius / 2)+(height+Math.PI *radius / 2))/ (height+Math.PI *radius);
  7765. if (stack < stacks){
  7766. indices[ic++]=verticeCount+(stack *(slices+1))+slice;
  7767. indices[ic++]=verticeCount+(stack *(slices+1))+slice+(slices+1);
  7768. indices[ic++]=verticeCount+(stack *(slices+1))+slice+1;
  7769. indices[ic++]=verticeCount+(stack *(slices+1))+slice;
  7770. indices[ic++]=verticeCount+(stack *(slices+1))+slice+(slices);
  7771. indices[ic++]=verticeCount+(stack *(slices+1))+slice+(slices+1);
  7772. }
  7773. }
  7774. }
  7775. verticeCount+=(stacks+1)*(slices+1);
  7776. for (slice=0;slice <=slices;slice++){
  7777. posX=radius *Math.cos(slice *sliceAngle+Math.PI);
  7778. posY=hcHeight;
  7779. posZ=radius *Math.sin(slice *sliceAngle+Math.PI);
  7780. vertices[vc++]=posX;
  7781. vertices[vc+(slices+1)*8-1]=posX;
  7782. vertices[vc++]=posY;
  7783. vertices[vc+(slices+1)*8-1]=-posY;
  7784. vertices[vc++]=posZ;
  7785. vertices[vc+(slices+1)*8-1]=posZ;
  7786. vertices[vc++]=posX;
  7787. vertices[vc+(slices+1)*8-1]=posX;
  7788. vertices[vc++]=0;
  7789. vertices[vc+(slices+1)*8-1]=0;
  7790. vertices[vc++]=posZ;
  7791. vertices[vc+(slices+1)*8-1]=posZ;
  7792. vertices[vc++]=1-slice *1 / slices;
  7793. vertices[vc+(slices+1)*8-1]=1-slice *1 / slices;
  7794. vertices[vc++]=(Math.PI *radius / 2)/ (height+Math.PI *radius);
  7795. vertices[vc+(slices+1)*8-1]=(Math.PI *radius / 2+height)/ (height+Math.PI *radius);
  7796. }
  7797. for (slice=0;slice < slices;slice++){
  7798. indices[ic++]=slice+verticeCount+(slices+1);
  7799. indices[ic++]=slice+verticeCount+1;
  7800. indices[ic++]=slice+verticeCount;
  7801. indices[ic++]=slice+verticeCount+(slices+1);
  7802. indices[ic++]=slice+verticeCount+(slices+1)+1;
  7803. indices[ic++]=slice+verticeCount+1;
  7804. }
  7805. verticeCount+=2 *(slices+1);
  7806. return PrimitiveMesh._createMesh(vertexDeclaration,vertices,indices);
  7807. }
  7808. PrimitiveMesh.createCone=function(radius,height,slices){
  7809. (radius===void 0)&& (radius=0.5);
  7810. (height===void 0)&& (height=1);
  7811. (slices===void 0)&& (slices=32);
  7812. var vertexCount=(slices+1+1)+(slices+1)*2;
  7813. var indexCount=6 *slices+3 *slices;
  7814. var vertexDeclaration=VertexMesh.getVertexDeclaration("POSITION,NORMAL,UV");
  7815. var vertexFloatStride=vertexDeclaration.vertexStride / 4;
  7816. var vertices=new Float32Array(vertexCount *vertexFloatStride);
  7817. var indices=new Uint16Array(indexCount);
  7818. var sliceAngle=(Math.PI *2.0)/ slices;
  7819. var halfHeight=height / 2;
  7820. var curAngle=0;
  7821. var verticeCount=0;
  7822. var posX=0;
  7823. var posY=0;
  7824. var posZ=0;
  7825. var normal=new Vector3();
  7826. var downV3=new Vector3(0,-1,0);
  7827. var upPoint=new Vector3(0,halfHeight,0);
  7828. var downPoint=new Vector3();
  7829. var v3=new Vector3();
  7830. var q4=new Quaternion();
  7831. var rotateAxis=new Vector3();
  7832. var rotateRadius=NaN;
  7833. var vc=0;
  7834. var ic=0;
  7835. for (var rv=0;rv <=slices;rv++){
  7836. curAngle=rv *sliceAngle;
  7837. posX=Math.cos(curAngle+Math.PI)*radius;
  7838. posY=halfHeight;
  7839. posZ=Math.sin(curAngle+Math.PI)*radius;
  7840. vertices[vc++]=0;
  7841. vertices[vc+(slices+1)*8-1]=posX;
  7842. vertices[vc++]=posY;
  7843. vertices[vc+(slices+1)*8-1]=-posY;
  7844. vertices[vc++]=0;
  7845. vertices[vc+(slices+1)*8-1]=posZ;
  7846. normal.x=posX;
  7847. normal.y=0;
  7848. normal.z=posZ;
  7849. downPoint.x=posX;
  7850. downPoint.y=-posY;
  7851. downPoint.z=posZ;
  7852. Vector3.subtract(downPoint,upPoint,v3);
  7853. Vector3.normalize(v3,v3);
  7854. rotateRadius=Math.acos(Vector3.dot(downV3,v3));
  7855. Vector3.cross(downV3,v3,rotateAxis);
  7856. Vector3.normalize(rotateAxis,rotateAxis);
  7857. Quaternion.createFromAxisAngle(rotateAxis,rotateRadius,q4);
  7858. Vector3.normalize(normal,normal);
  7859. Vector3.transformQuat(normal,q4,normal);
  7860. Vector3.normalize(normal,normal);
  7861. vertices[vc++]=normal.x;
  7862. vertices[vc+(slices+1)*8-1]=normal.x;
  7863. vertices[vc++]=normal.y;
  7864. vertices[vc+(slices+1)*8-1]=normal.y;
  7865. vertices[vc++]=normal.z;
  7866. vertices[vc+(slices+1)*8-1]=normal.z;
  7867. vertices[vc++]=1-rv *1 / slices;
  7868. vertices[vc+(slices+1)*8-1]=1-rv *1 / slices;
  7869. vertices[vc++]=0;
  7870. vertices[vc+(slices+1)*8-1]=1;
  7871. }
  7872. vc+=(slices+1)*8;
  7873. for (var ri=0;ri < slices;ri++){
  7874. indices[ic++]=ri+verticeCount+(slices+1);
  7875. indices[ic++]=ri+verticeCount+1;
  7876. indices[ic++]=ri+verticeCount;
  7877. indices[ic++]=ri+verticeCount+(slices+1);
  7878. indices[ic++]=ri+verticeCount+(slices+1)+1;
  7879. indices[ic++]=ri+verticeCount+1;
  7880. }
  7881. verticeCount+=2 *(slices+1);
  7882. for (var bv=0;bv <=slices;bv++){
  7883. if (bv===0){
  7884. vertices[vc++]=0;
  7885. vertices[vc++]=-halfHeight;
  7886. vertices[vc++]=0;
  7887. vertices[vc++]=0;
  7888. vertices[vc++]=-1;
  7889. vertices[vc++]=0;
  7890. vertices[vc++]=0.5;
  7891. vertices[vc++]=0.5;
  7892. }
  7893. curAngle=bv *sliceAngle;
  7894. posX=Math.cos(curAngle+Math.PI)*radius;
  7895. posY=-halfHeight;
  7896. posZ=Math.sin(curAngle+Math.PI)*radius;
  7897. vertices[vc++]=posX;
  7898. vertices[vc++]=posY;
  7899. vertices[vc++]=posZ;
  7900. vertices[vc++]=0;
  7901. vertices[vc++]=-1;
  7902. vertices[vc++]=0;
  7903. vertices[vc++]=0.5+Math.cos(curAngle)*0.5;
  7904. vertices[vc++]=0.5+Math.sin(curAngle)*0.5;
  7905. }
  7906. for (var bi=0;bi < slices;bi++){
  7907. indices[ic++]=0+verticeCount;
  7908. indices[ic++]=bi+2+verticeCount;
  7909. indices[ic++]=bi+1+verticeCount;
  7910. }
  7911. verticeCount+=slices+1+1;
  7912. return PrimitiveMesh._createMesh(vertexDeclaration,vertices,indices);
  7913. }
  7914. PrimitiveMesh.createCylinder=function(radius,height,slices){
  7915. (radius===void 0)&& (radius=0.5);
  7916. (height===void 0)&& (height=2);
  7917. (slices===void 0)&& (slices=32);
  7918. var vertexCount=(slices+1+1)+(slices+1)*2+(slices+1+1);
  7919. var indexCount=3 *slices+6 *slices+3 *slices;
  7920. var vertexDeclaration=VertexMesh.getVertexDeclaration("POSITION,NORMAL,UV");
  7921. var vertexFloatStride=vertexDeclaration.vertexStride / 4;
  7922. var vertices=new Float32Array(vertexCount *vertexFloatStride);
  7923. var indices=new Uint16Array(indexCount);
  7924. var sliceAngle=(Math.PI *2.0)/ slices;
  7925. var halfHeight=height / 2;
  7926. var curAngle=0;
  7927. var verticeCount=0;
  7928. var posX=0;
  7929. var posY=0;
  7930. var posZ=0;
  7931. var vc=0;
  7932. var ic=0;
  7933. for (var tv=0;tv <=slices;tv++){
  7934. if (tv===0){
  7935. vertices[vc++]=0;
  7936. vertices[vc++]=halfHeight;
  7937. vertices[vc++]=0;
  7938. vertices[vc++]=0;
  7939. vertices[vc++]=1;
  7940. vertices[vc++]=0;
  7941. vertices[vc++]=0.5;
  7942. vertices[vc++]=0.5;
  7943. }
  7944. curAngle=tv *sliceAngle;
  7945. posX=Math.cos(curAngle)*radius;
  7946. posY=halfHeight;
  7947. posZ=Math.sin(curAngle)*radius;
  7948. vertices[vc++]=posX;
  7949. vertices[vc++]=posY;
  7950. vertices[vc++]=posZ;
  7951. vertices[vc++]=0;
  7952. vertices[vc++]=1;
  7953. vertices[vc++]=0;
  7954. vertices[vc++]=0.5+Math.cos(curAngle)*0.5;
  7955. vertices[vc++]=0.5+Math.sin(curAngle)*0.5;
  7956. }
  7957. for (var ti=0;ti < slices;ti++){
  7958. indices[ic++]=0;
  7959. indices[ic++]=ti+1;
  7960. indices[ic++]=ti+2;
  7961. }
  7962. verticeCount+=slices+1+1;
  7963. for (var rv=0;rv <=slices;rv++){
  7964. curAngle=rv *sliceAngle;
  7965. posX=Math.cos(curAngle+Math.PI)*radius;
  7966. posY=halfHeight;
  7967. posZ=Math.sin(curAngle+Math.PI)*radius;
  7968. vertices[vc++]=posX;
  7969. vertices[vc+(slices+1)*8-1]=posX;
  7970. vertices[vc++]=posY;
  7971. vertices[vc+(slices+1)*8-1]=-posY;
  7972. vertices[vc++]=posZ;
  7973. vertices[vc+(slices+1)*8-1]=posZ;
  7974. vertices[vc++]=posX;
  7975. vertices[vc+(slices+1)*8-1]=posX;
  7976. vertices[vc++]=0;
  7977. vertices[vc+(slices+1)*8-1]=0;
  7978. vertices[vc++]=posZ;
  7979. vertices[vc+(slices+1)*8-1]=posZ;
  7980. vertices[vc++]=1-rv *1 / slices;
  7981. vertices[vc+(slices+1)*8-1]=1-rv *1 / slices;
  7982. vertices[vc++]=0;
  7983. vertices[vc+(slices+1)*8-1]=1;
  7984. }
  7985. vc+=(slices+1)*8;
  7986. for (var ri=0;ri < slices;ri++){
  7987. indices[ic++]=ri+verticeCount+(slices+1);
  7988. indices[ic++]=ri+verticeCount+1;
  7989. indices[ic++]=ri+verticeCount;
  7990. indices[ic++]=ri+verticeCount+(slices+1);
  7991. indices[ic++]=ri+verticeCount+(slices+1)+1;
  7992. indices[ic++]=ri+verticeCount+1;
  7993. }
  7994. verticeCount+=2 *(slices+1);
  7995. for (var bv=0;bv <=slices;bv++){
  7996. if (bv===0){
  7997. vertices[vc++]=0;
  7998. vertices[vc++]=-halfHeight;
  7999. vertices[vc++]=0;
  8000. vertices[vc++]=0;
  8001. vertices[vc++]=-1;
  8002. vertices[vc++]=0;
  8003. vertices[vc++]=0.5;
  8004. vertices[vc++]=0.5;
  8005. }
  8006. curAngle=bv *sliceAngle;
  8007. posX=Math.cos(curAngle+Math.PI)*radius;
  8008. posY=-halfHeight;
  8009. posZ=Math.sin(curAngle+Math.PI)*radius;
  8010. vertices[vc++]=posX;
  8011. vertices[vc++]=posY;
  8012. vertices[vc++]=posZ;
  8013. vertices[vc++]=0;
  8014. vertices[vc++]=-1;
  8015. vertices[vc++]=0;
  8016. vertices[vc++]=0.5+Math.cos(curAngle)*0.5;
  8017. vertices[vc++]=0.5+Math.sin(curAngle)*0.5;
  8018. }
  8019. for (var bi=0;bi < slices;bi++){
  8020. indices[ic++]=0+verticeCount;
  8021. indices[ic++]=bi+2+verticeCount;
  8022. indices[ic++]=bi+1+verticeCount;
  8023. }
  8024. verticeCount+=slices+1+1;
  8025. return PrimitiveMesh._createMesh(vertexDeclaration,vertices,indices);
  8026. }
  8027. PrimitiveMesh.createPlane=function(long,width,stacks,slices){
  8028. (long===void 0)&& (long=10);
  8029. (width===void 0)&& (width=10);
  8030. (stacks===void 0)&& (stacks=10);
  8031. (slices===void 0)&& (slices=10);
  8032. var vertexCount=(stacks+1)*(slices+1);
  8033. var indexCount=stacks *slices *2 *3;
  8034. var indices=new Uint16Array(indexCount);
  8035. var vertexDeclaration=VertexMesh.getVertexDeclaration("POSITION,NORMAL,UV");
  8036. var vertexFloatStride=vertexDeclaration.vertexStride / 4;
  8037. var vertices=new Float32Array(vertexCount *vertexFloatStride);
  8038. var halfLong=long / 2;
  8039. var halfWidth=width / 2;
  8040. var stacksLong=long / stacks;
  8041. var slicesWidth=width / slices;
  8042. var verticeCount=0;
  8043. for (var i=0;i <=slices;i++){
  8044. for (var j=0;j <=stacks;j++){
  8045. vertices[verticeCount++]=j *stacksLong-halfLong;
  8046. vertices[verticeCount++]=0;
  8047. vertices[verticeCount++]=i *slicesWidth-halfWidth;
  8048. vertices[verticeCount++]=0;
  8049. vertices[verticeCount++]=1;
  8050. vertices[verticeCount++]=0;
  8051. vertices[verticeCount++]=j *1 / stacks;
  8052. vertices[verticeCount++]=i *1 / slices;
  8053. }
  8054. };
  8055. var indiceIndex=0;
  8056. for (i=0;i < slices;i++){
  8057. for (j=0;j < stacks;j++){
  8058. indices[indiceIndex++]=(i+1)*(stacks+1)+j;
  8059. indices[indiceIndex++]=i *(stacks+1)+j;
  8060. indices[indiceIndex++]=(i+1)*(stacks+1)+j+1;
  8061. indices[indiceIndex++]=i *(stacks+1)+j;
  8062. indices[indiceIndex++]=i *(stacks+1)+j+1;
  8063. indices[indiceIndex++]=(i+1)*(stacks+1)+j+1;
  8064. }
  8065. }
  8066. return PrimitiveMesh._createMesh(vertexDeclaration,vertices,indices);
  8067. }
  8068. PrimitiveMesh.createQuad=function(long,width){
  8069. (long===void 0)&& (long=1);
  8070. (width===void 0)&& (width=1);
  8071. var vertexCount=4;
  8072. var indexCount=6;
  8073. var vertexDeclaration=VertexMesh.getVertexDeclaration("POSITION,NORMAL,UV");
  8074. var vertexFloatStride=vertexDeclaration.vertexStride / 4;
  8075. var halfLong=long / 2;
  8076. var halfWidth=width / 2;
  8077. var vertices=new Float32Array([
  8078. -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,]);
  8079. var indices=new Uint16Array([
  8080. 0,1,2,3,2,1,]);
  8081. return PrimitiveMesh._createMesh(vertexDeclaration,vertices,indices);
  8082. }
  8083. PrimitiveMesh.createSphere=function(radius,stacks,slices){
  8084. (radius===void 0)&& (radius=0.5);
  8085. (stacks===void 0)&& (stacks=32);
  8086. (slices===void 0)&& (slices=32);
  8087. var vertexCount=(stacks+1)*(slices+1);
  8088. var indexCount=(3 *stacks *(slices+1))*2;
  8089. var indices=new Uint16Array(indexCount);
  8090. var vertexDeclaration=VertexMesh.getVertexDeclaration("POSITION,NORMAL,UV");
  8091. var vertexFloatStride=vertexDeclaration.vertexStride / 4;
  8092. var vertices=new Float32Array(vertexCount *vertexFloatStride);
  8093. var stackAngle=Math.PI / stacks;
  8094. var sliceAngle=(Math.PI *2.0)/ slices;
  8095. var vertexIndex=0;
  8096. vertexCount=0;
  8097. indexCount=0;
  8098. for (var stack=0;stack < (stacks+1);stack++){
  8099. var r=Math.sin(stack *stackAngle);
  8100. var y=Math.cos(stack *stackAngle);
  8101. for (var slice=0;slice < (slices+1);slice++){
  8102. var x=r *Math.sin(slice *sliceAngle+Math.PI *1 / 2);
  8103. var z=r *Math.cos(slice *sliceAngle+Math.PI *1 / 2);
  8104. vertices[vertexCount+0]=x *radius;
  8105. vertices[vertexCount+1]=y *radius;
  8106. vertices[vertexCount+2]=z *radius;
  8107. vertices[vertexCount+3]=x;
  8108. vertices[vertexCount+4]=y;
  8109. vertices[vertexCount+5]=z;
  8110. vertices[vertexCount+6]=slice / slices;
  8111. vertices[vertexCount+7]=stack / stacks;
  8112. vertexCount+=vertexFloatStride;
  8113. if (stack !=(stacks-1)){
  8114. indices[indexCount++]=vertexIndex+(slices+1);
  8115. indices[indexCount++]=vertexIndex;
  8116. indices[indexCount++]=vertexIndex+1;
  8117. indices[indexCount++]=vertexIndex+(slices);
  8118. indices[indexCount++]=vertexIndex;
  8119. indices[indexCount++]=vertexIndex+(slices+1);
  8120. vertexIndex++;
  8121. }
  8122. }
  8123. }
  8124. return PrimitiveMesh._createMesh(vertexDeclaration,vertices,indices);
  8125. }
  8126. return PrimitiveMesh;
  8127. })()
  8128. /**
  8129. *@private
  8130. *<code>LoadModel</code> 类用于模型加载。
  8131. */
  8132. //class laya.d3.loaders.LoadModelV04
  8133. var LoadModelV04=(function(){
  8134. function LoadModelV04(){}
  8135. __class(LoadModelV04,'laya.d3.loaders.LoadModelV04');
  8136. LoadModelV04.parse=function(readData,version,mesh,subMeshes){
  8137. LoadModelV04._mesh=mesh;
  8138. LoadModelV04._subMeshes=subMeshes;
  8139. LoadModelV04._version=version;
  8140. LoadModelV04._readData=readData;
  8141. LoadModelV04.READ_DATA();
  8142. LoadModelV04.READ_BLOCK();
  8143. LoadModelV04.READ_STRINGS();
  8144. for (var i=0,n=LoadModelV04._BLOCK.count;i < n;i++){
  8145. LoadModelV04._readData.pos=LoadModelV04._BLOCK.blockStarts[i];
  8146. var index=LoadModelV04._readData.getUint16();
  8147. var blockName=LoadModelV04._strings[index];
  8148. var fn=LoadModelV04["READ_"+blockName];
  8149. if (fn==null)
  8150. throw new Error("model file err,no this function:"+index+" "+blockName);
  8151. else
  8152. fn.call(null);
  8153. }
  8154. LoadModelV04._mesh._bindPoseIndices=new Uint16Array(LoadModelV04._bindPoseIndices);
  8155. LoadModelV04._bindPoseIndices.length=0;
  8156. LoadModelV04._strings.length=0;
  8157. LoadModelV04._readData=null;
  8158. LoadModelV04._version=null;
  8159. LoadModelV04._mesh=null;
  8160. LoadModelV04._subMeshes=null;
  8161. }
  8162. LoadModelV04._readString=function(){
  8163. return LoadModelV04._strings[LoadModelV04._readData.getUint16()];
  8164. }
  8165. LoadModelV04.READ_DATA=function(){
  8166. LoadModelV04._DATA.offset=LoadModelV04._readData.getUint32();
  8167. LoadModelV04._DATA.size=LoadModelV04._readData.getUint32();
  8168. }
  8169. LoadModelV04.READ_BLOCK=function(){
  8170. var count=LoadModelV04._BLOCK.count=LoadModelV04._readData.getUint16();
  8171. var blockStarts=LoadModelV04._BLOCK.blockStarts=[];
  8172. var blockLengths=LoadModelV04._BLOCK.blockLengths=[];
  8173. for (var i=0;i < count;i++){
  8174. blockStarts.push(LoadModelV04._readData.getUint32());
  8175. blockLengths.push(LoadModelV04._readData.getUint32());
  8176. }
  8177. }
  8178. LoadModelV04.READ_STRINGS=function(){
  8179. var offset=LoadModelV04._readData.getUint32();
  8180. var count=LoadModelV04._readData.getUint16();
  8181. var prePos=LoadModelV04._readData.pos;
  8182. LoadModelV04._readData.pos=offset+LoadModelV04._DATA.offset;
  8183. for (var i=0;i < count;i++)
  8184. LoadModelV04._strings[i]=LoadModelV04._readData.readUTFString();
  8185. LoadModelV04._readData.pos=prePos;
  8186. }
  8187. LoadModelV04.READ_MESH=function(){
  8188. var name=LoadModelV04._readString();
  8189. var arrayBuffer=LoadModelV04._readData.__getBuffer();
  8190. var i=0,n=0;
  8191. var memorySize=0;
  8192. var vertexBufferCount=LoadModelV04._readData.getInt16();
  8193. var offset=LoadModelV04._DATA.offset;
  8194. for (i=0;i < vertexBufferCount;i++){
  8195. var vbStart=offset+LoadModelV04._readData.getUint32();
  8196. var vbLength=LoadModelV04._readData.getUint32();
  8197. var vbDatas=new Float32Array(arrayBuffer.slice(vbStart,vbStart+vbLength));
  8198. var bufferAttribute=LoadModelV04._readString();
  8199. var vertexDeclaration;
  8200. switch (LoadModelV04._version){
  8201. case "LAYAMODEL:0301":
  8202. case "LAYAMODEL:0400":
  8203. vertexDeclaration=VertexMesh.getVertexDeclaration(bufferAttribute);
  8204. break ;
  8205. case "LAYAMODEL:0401":
  8206. vertexDeclaration=VertexMesh.getVertexDeclaration(bufferAttribute,false);
  8207. break ;
  8208. default :
  8209. throw new Error("LoadModelV03: unknown version.");
  8210. }
  8211. if (!vertexDeclaration)
  8212. throw new Error("LoadModelV03: unknown vertexDeclaration.");
  8213. var vertexBuffer=new VertexBuffer3D(vbDatas.length *4,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,true);
  8214. vertexBuffer.vertexDeclaration=vertexDeclaration;
  8215. vertexBuffer.setData(vbDatas);
  8216. LoadModelV04._mesh._vertexBuffers.push(vertexBuffer);
  8217. LoadModelV04._mesh._vertexCount+=vertexBuffer.vertexCount;
  8218. memorySize+=vbDatas.length *4;
  8219. };
  8220. var ibStart=offset+LoadModelV04._readData.getUint32();
  8221. var ibLength=LoadModelV04._readData.getUint32();
  8222. var ibDatas=new Uint16Array(arrayBuffer.slice(ibStart,ibStart+ibLength));
  8223. var indexBuffer=new IndexBuffer3D(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",ibLength / 2,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,true);
  8224. indexBuffer.setData(ibDatas);
  8225. LoadModelV04._mesh._indexBuffer=indexBuffer;
  8226. memorySize+=indexBuffer.indexCount *2;
  8227. LoadModelV04._mesh._setBuffer(LoadModelV04._mesh._vertexBuffers,indexBuffer);
  8228. LoadModelV04._mesh._setCPUMemory(memorySize);
  8229. LoadModelV04._mesh._setGPUMemory(memorySize);
  8230. var boneNames=LoadModelV04._mesh._boneNames=[];
  8231. var boneCount=LoadModelV04._readData.getUint16();
  8232. boneNames.length=boneCount;
  8233. for (i=0;i < boneCount;i++)
  8234. boneNames[i]=LoadModelV04._strings[LoadModelV04._readData.getUint16()];
  8235. LoadModelV04._readData.pos+=8;
  8236. var bindPoseDataStart=LoadModelV04._readData.getUint32();
  8237. var bindPoseDataLength=LoadModelV04._readData.getUint32();
  8238. var bindPoseDatas=new Float32Array(arrayBuffer.slice(offset+bindPoseDataStart,offset+bindPoseDataStart+bindPoseDataLength));
  8239. var bindPoseFloatCount=bindPoseDatas.length;
  8240. var bindPoseCount=bindPoseFloatCount / 16;
  8241. var bindPoseBuffer=LoadModelV04._mesh._inverseBindPosesBuffer=new ArrayBuffer(bindPoseFloatCount *4);
  8242. LoadModelV04._mesh._inverseBindPoses=__newvec(bindPoseCount);
  8243. for (i=0;i < bindPoseFloatCount;i+=16){
  8244. 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));
  8245. LoadModelV04._mesh._inverseBindPoses[i / 16]=inverseGlobalBindPose;
  8246. }
  8247. return true;
  8248. }
  8249. LoadModelV04.READ_SUBMESH=function(){
  8250. var arrayBuffer=LoadModelV04._readData.__getBuffer();
  8251. var submesh=new SubMesh(LoadModelV04._mesh);
  8252. var vbIndex=LoadModelV04._readData.getInt16();
  8253. LoadModelV04._readData.getUint32();
  8254. LoadModelV04._readData.getUint32();
  8255. var ibStart=LoadModelV04._readData.getUint32();
  8256. var ibCount=LoadModelV04._readData.getUint32();
  8257. var indexBuffer=LoadModelV04._mesh._indexBuffer;
  8258. submesh._indexBuffer=indexBuffer;
  8259. submesh._indexStart=ibStart;
  8260. submesh._indexCount=ibCount;
  8261. submesh._indices=new Uint16Array(indexBuffer.getData().buffer,ibStart *2,ibCount);
  8262. var vertexBuffer=LoadModelV04._mesh._vertexBuffers[vbIndex];
  8263. submesh._vertexBuffer=vertexBuffer;
  8264. var offset=LoadModelV04._DATA.offset;
  8265. var subIndexBufferStart=submesh._subIndexBufferStart;
  8266. var subIndexBufferCount=submesh._subIndexBufferCount;
  8267. var boneIndicesList=submesh._boneIndicesList;
  8268. var drawCount=LoadModelV04._readData.getUint16();
  8269. subIndexBufferStart.length=drawCount;
  8270. subIndexBufferCount.length=drawCount;
  8271. boneIndicesList.length=drawCount;
  8272. var pathMarks=LoadModelV04._mesh._skinDataPathMarks;
  8273. var bindPoseIndices=LoadModelV04._bindPoseIndices;
  8274. var subMeshIndex=LoadModelV04._subMeshes.length;
  8275. for (var i=0;i < drawCount;i++){
  8276. subIndexBufferStart[i]=LoadModelV04._readData.getUint32();
  8277. subIndexBufferCount[i]=LoadModelV04._readData.getUint32();
  8278. var boneDicofs=LoadModelV04._readData.getUint32();
  8279. var boneDicCount=LoadModelV04._readData.getUint32();
  8280. var boneIndices=boneIndicesList[i]=new Uint16Array(arrayBuffer.slice(offset+boneDicofs,offset+boneDicofs+boneDicCount));
  8281. for (var j=0,m=boneIndices.length;j < m;j++){
  8282. var index=boneIndices[j];
  8283. var combineIndex=bindPoseIndices.indexOf(index);
  8284. if (combineIndex===-1){
  8285. boneIndices[j]=bindPoseIndices.length;
  8286. bindPoseIndices.push(index);
  8287. pathMarks.push([subMeshIndex,i,j]);
  8288. }else {
  8289. boneIndices[j]=combineIndex;
  8290. }
  8291. }
  8292. }
  8293. LoadModelV04._subMeshes.push(submesh);
  8294. return true;
  8295. }
  8296. LoadModelV04._strings=[];
  8297. LoadModelV04._readData=null;
  8298. LoadModelV04._version=null;
  8299. LoadModelV04._mesh=null;
  8300. LoadModelV04._subMeshes=null;
  8301. LoadModelV04._bindPoseIndices=[];
  8302. __static(LoadModelV04,
  8303. ['_BLOCK',function(){return this._BLOCK={count:0};},'_DATA',function(){return this._DATA={offset:0,size:0};}
  8304. ]);
  8305. return LoadModelV04;
  8306. })()
  8307. /**
  8308. *<code>Picker</code> 类用于创建拾取。
  8309. */
  8310. //class laya.d3.utils.Picker
  8311. var Picker=(function(){
  8312. /**
  8313. *创建一个 <code>Picker</code> 实例。
  8314. */
  8315. function Picker(){}
  8316. __class(Picker,'laya.d3.utils.Picker');
  8317. Picker.calculateCursorRay=function(point,viewPort,projectionMatrix,viewMatrix,world,out){
  8318. var x=point.x;
  8319. var y=point.y;
  8320. var nearSource=Picker._tempVector30;
  8321. var nerSourceE=nearSource;
  8322. nerSourceE.x=x;
  8323. nerSourceE.y=y;
  8324. nerSourceE.z=viewPort.minDepth;
  8325. var farSource=Picker._tempVector31;
  8326. var farSourceE=farSource;
  8327. farSourceE.x=x;
  8328. farSourceE.y=y;
  8329. farSourceE.z=viewPort.maxDepth;
  8330. var nearPoint=out.origin;
  8331. var farPoint=Picker._tempVector32;
  8332. viewPort.unprojectFromWVP(nearSource,projectionMatrix,viewMatrix,world,nearPoint);
  8333. viewPort.unprojectFromWVP(farSource,projectionMatrix,viewMatrix,world,farPoint);
  8334. var outDire=out.direction;
  8335. outDire.x=farPoint.x-nearPoint.x;
  8336. outDire.y=farPoint.y-nearPoint.y;
  8337. outDire.z=farPoint.z-nearPoint.z;
  8338. Vector3.normalize(out.direction,out.direction);
  8339. }
  8340. Picker.rayIntersectsTriangle=function(ray,vertex1,vertex2,vertex3){
  8341. var result;
  8342. var edge1=Picker._tempVector30,edge2=Picker._tempVector31;
  8343. Vector3.subtract(vertex2,vertex1,edge1);
  8344. Vector3.subtract(vertex3,vertex1,edge2);
  8345. var directionCrossEdge2=Picker._tempVector32;
  8346. Vector3.cross(ray.direction,edge2,directionCrossEdge2);
  8347. var determinant;
  8348. determinant=Vector3.dot(edge1,directionCrossEdge2);
  8349. if (determinant >-Number.MIN_VALUE && determinant < Number.MIN_VALUE){
  8350. result=Number.NaN;
  8351. return result;
  8352. };
  8353. var inverseDeterminant=1.0 / determinant;
  8354. var distanceVector=Picker._tempVector33;
  8355. Vector3.subtract(ray.origin,vertex1,distanceVector);
  8356. var triangleU;
  8357. triangleU=Vector3.dot(distanceVector,directionCrossEdge2);
  8358. triangleU *=inverseDeterminant;
  8359. if (triangleU < 0 || triangleU > 1){
  8360. result=Number.NaN;
  8361. return result;
  8362. };
  8363. var distanceCrossEdge1=Picker._tempVector34;
  8364. Vector3.cross(distanceVector,edge1,distanceCrossEdge1);
  8365. var triangleV;
  8366. triangleV=Vector3.dot(ray.direction,distanceCrossEdge1);
  8367. triangleV *=inverseDeterminant;
  8368. if (triangleV < 0 || triangleU+triangleV > 1){
  8369. result=Number.NaN;
  8370. return result;
  8371. };
  8372. var rayDistance;
  8373. rayDistance=Vector3.dot(edge2,distanceCrossEdge1);
  8374. rayDistance *=inverseDeterminant;
  8375. if (rayDistance < 0){
  8376. result=Number.NaN;
  8377. return result;
  8378. }
  8379. result=rayDistance;
  8380. return result;
  8381. }
  8382. __static(Picker,
  8383. ['_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();}
  8384. ]);
  8385. return Picker;
  8386. })()
  8387. /**
  8388. *<code>GradientDataNumber</code> 类用于创建浮点渐变。
  8389. */
  8390. //class laya.d3.core.particleShuriKen.module.GradientDataNumber
  8391. var GradientDataNumber=(function(){
  8392. function GradientDataNumber(){
  8393. /**@private */
  8394. this._currentLength=0;
  8395. /**@private 开发者禁止修改。*/
  8396. this._elements=null;
  8397. this._elements=new Float32Array(8);
  8398. }
  8399. __class(GradientDataNumber,'laya.d3.core.particleShuriKen.module.GradientDataNumber');
  8400. var __proto=GradientDataNumber.prototype;
  8401. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  8402. /**
  8403. *增加浮点渐变。
  8404. *@param key 生命周期,范围为0到1。
  8405. *@param value 浮点值。
  8406. */
  8407. __proto.add=function(key,value){
  8408. if (this._currentLength < 8){
  8409. if ((this._currentLength===6)&& ((key!==1))){
  8410. key=1;
  8411. console.log("GradientDataNumber warning:the forth key is be force set to 1.");
  8412. }
  8413. this._elements[this._currentLength++]=key;
  8414. this._elements[this._currentLength++]=value;
  8415. }else {
  8416. console.log("GradientDataNumber warning:data count must lessEqual than 4");
  8417. }
  8418. }
  8419. /**
  8420. *通过索引获取键。
  8421. *@param index 索引。
  8422. *@return value 键。
  8423. */
  8424. __proto.getKeyByIndex=function(index){
  8425. return this._elements[index *2];
  8426. }
  8427. /**
  8428. *通过索引获取值。
  8429. *@param index 索引。
  8430. *@return value 值。
  8431. */
  8432. __proto.getValueByIndex=function(index){
  8433. return this._elements[index *2+1];
  8434. }
  8435. /**
  8436. *获取平均值。
  8437. */
  8438. __proto.getAverageValue=function(){
  8439. var total=0;
  8440. for (var i=0,n=this._currentLength-2;i < n;i+=2){
  8441. var subValue=this._elements[i+1];
  8442. subValue+=this._elements[i+3];
  8443. subValue=subValue *(this._elements[i+2]-this._elements[i]);
  8444. }
  8445. return total / 2;
  8446. }
  8447. /**
  8448. *克隆。
  8449. *@param destObject 克隆源。
  8450. */
  8451. __proto.cloneTo=function(destObject){
  8452. var destGradientDataNumber=destObject;
  8453. destGradientDataNumber._currentLength=this._currentLength;
  8454. var destElements=destGradientDataNumber._elements;
  8455. destElements.length=this._elements.length;
  8456. for (var i=0,n=this._elements.length;i < n;i++)
  8457. destElements[i]=this._elements[i];
  8458. }
  8459. /**
  8460. *克隆。
  8461. *@return 克隆副本。
  8462. */
  8463. __proto.clone=function(){
  8464. var destGradientDataNumber=/*__JS__ */new this.constructor();
  8465. this.cloneTo(destGradientDataNumber);
  8466. return destGradientDataNumber;
  8467. }
  8468. /**渐变浮点数量。*/
  8469. __getset(0,__proto,'gradientCount',function(){
  8470. return this._currentLength / 2;
  8471. });
  8472. return GradientDataNumber;
  8473. })()
  8474. /**
  8475. *<code>ColorOverLifetime</code> 类用于粒子的生命周期颜色。
  8476. */
  8477. //class laya.d3.core.particleShuriKen.module.ColorOverLifetime
  8478. var ColorOverLifetime=(function(){
  8479. function ColorOverLifetime(color){
  8480. /**@private */
  8481. this._color=null;
  8482. /**是否启用。*/
  8483. this.enbale=false;
  8484. this._color=color;
  8485. }
  8486. __class(ColorOverLifetime,'laya.d3.core.particleShuriKen.module.ColorOverLifetime');
  8487. var __proto=ColorOverLifetime.prototype;
  8488. /**
  8489. *克隆。
  8490. *@param destObject 克隆源。
  8491. */
  8492. __proto.cloneTo=function(destObject){
  8493. var destColorOverLifetime=destObject;
  8494. this._color.cloneTo(destColorOverLifetime._color);
  8495. destColorOverLifetime.enbale=this.enbale;
  8496. }
  8497. /**
  8498. *克隆。
  8499. *@return 克隆副本。
  8500. */
  8501. __proto.clone=function(){
  8502. var destColor;
  8503. switch (this._color.type){
  8504. case 0:
  8505. destColor=GradientColor.createByConstant(this._color.constant.clone());
  8506. break ;
  8507. case 1:
  8508. destColor=GradientColor.createByGradient(this._color.gradient.clone());
  8509. break ;
  8510. case 2:
  8511. destColor=GradientColor.createByRandomTwoConstant(this._color.constantMin.clone(),this._color.constantMax.clone());
  8512. break ;
  8513. case 3:
  8514. destColor=GradientColor.createByRandomTwoGradient(this._color.gradientMin.clone(),this._color.gradientMax.clone());
  8515. break ;
  8516. };
  8517. var destColorOverLifetime=/*__JS__ */new this.constructor(destColor);
  8518. destColorOverLifetime.enbale=this.enbale;
  8519. return destColorOverLifetime;
  8520. }
  8521. /**
  8522. *获取颜色。
  8523. */
  8524. __getset(0,__proto,'color',function(){
  8525. return this._color;
  8526. });
  8527. return ColorOverLifetime;
  8528. })()
  8529. /**
  8530. *<code>BoundFrustum</code> 类用于创建锥截体。
  8531. */
  8532. //class laya.d3.math.BoundFrustum
  8533. var BoundFrustum=(function(){
  8534. function BoundFrustum(matrix){
  8535. /**4x4矩阵*/
  8536. this._matrix=null;
  8537. /**近平面*/
  8538. this._near=null;
  8539. /**远平面*/
  8540. this._far=null;
  8541. /**左平面*/
  8542. this._left=null;
  8543. /**右平面*/
  8544. this._right=null;
  8545. /**顶平面*/
  8546. this._top=null;
  8547. /**底平面*/
  8548. this._bottom=null;
  8549. this._matrix=matrix;
  8550. this._near=new Plane(new Vector3());
  8551. this._far=new Plane(new Vector3());
  8552. this._left=new Plane(new Vector3());
  8553. this._right=new Plane(new Vector3());
  8554. this._top=new Plane(new Vector3());
  8555. this._bottom=new Plane(new Vector3());
  8556. BoundFrustum._getPlanesFromMatrix(this._matrix,this._near,this._far,this._left,this._right,this._top,this._bottom);
  8557. }
  8558. __class(BoundFrustum,'laya.d3.math.BoundFrustum');
  8559. var __proto=BoundFrustum.prototype;
  8560. /**
  8561. *判断是否与其他锥截体相等。
  8562. *@param other 锥截体。
  8563. */
  8564. __proto.equalsBoundFrustum=function(other){
  8565. return this._matrix.equalsOtherMatrix(other.matrix)
  8566. }
  8567. /**
  8568. *判断是否与其他对象相等。
  8569. *@param obj 对象。
  8570. */
  8571. __proto.equalsObj=function(obj){
  8572. if ((obj instanceof laya.d3.math.BoundFrustum )){
  8573. var bf=obj;
  8574. return this.equalsBoundFrustum(bf);
  8575. }
  8576. return false;
  8577. }
  8578. /**
  8579. *获取锥截体的任意一平面。
  8580. *0:近平面
  8581. *1:远平面
  8582. *2:左平面
  8583. *3:右平面
  8584. *4:顶平面
  8585. *5:底平面
  8586. *@param index 索引。
  8587. */
  8588. __proto.getPlane=function(index){
  8589. switch (index){
  8590. case 0:
  8591. return this._near;
  8592. case 1:
  8593. return this._far;
  8594. case 2:
  8595. return this._left;
  8596. case 3:
  8597. return this._right;
  8598. case 4:
  8599. return this._top;
  8600. case 5:
  8601. return this._bottom;
  8602. default :
  8603. return null;
  8604. }
  8605. }
  8606. /**
  8607. *锥截体的8个顶点。
  8608. *@param corners 返回顶点的输出队列。
  8609. */
  8610. __proto.getCorners=function(corners){
  8611. BoundFrustum._get3PlaneInterPoint(this._near,this._bottom,this._right).cloneTo(corners[0]);
  8612. BoundFrustum._get3PlaneInterPoint(this._near,this._top,this._right).cloneTo(corners[1]);
  8613. BoundFrustum._get3PlaneInterPoint(this._near,this._top,this._left).cloneTo(corners[2]);
  8614. BoundFrustum._get3PlaneInterPoint(this._near,this._bottom,this._left).cloneTo(corners[3]);
  8615. BoundFrustum._get3PlaneInterPoint(this._far,this._bottom,this._right).cloneTo(corners[4]);
  8616. BoundFrustum._get3PlaneInterPoint(this._far,this._top,this._right).cloneTo(corners[5]);
  8617. BoundFrustum._get3PlaneInterPoint(this._far,this._top,this._left).cloneTo(corners[6]);
  8618. BoundFrustum._get3PlaneInterPoint(this._far,this._bottom,this._left).cloneTo(corners[7]);
  8619. }
  8620. /**
  8621. *与点的位置关系。返回-1,包涵;0,相交;1,不相交
  8622. *@param point 点。
  8623. */
  8624. __proto.containsPoint=function(point){
  8625. var result=Plane.PlaneIntersectionType_Front;
  8626. var planeResult=Plane.PlaneIntersectionType_Front;
  8627. for (var i=0;i < 6;i++){
  8628. switch (i){
  8629. case 0:
  8630. planeResult=CollisionUtils.intersectsPlaneAndPoint(this._near,point);
  8631. break ;
  8632. case 1:
  8633. planeResult=CollisionUtils.intersectsPlaneAndPoint(this._far,point);
  8634. break ;
  8635. case 2:
  8636. planeResult=CollisionUtils.intersectsPlaneAndPoint(this._left,point);
  8637. break ;
  8638. case 3:
  8639. planeResult=CollisionUtils.intersectsPlaneAndPoint(this._right,point);
  8640. break ;
  8641. case 4:
  8642. planeResult=CollisionUtils.intersectsPlaneAndPoint(this._top,point);
  8643. break ;
  8644. case 5:
  8645. planeResult=CollisionUtils.intersectsPlaneAndPoint(this._bottom,point);
  8646. break ;
  8647. }
  8648. switch (planeResult){
  8649. case Plane.PlaneIntersectionType_Back:
  8650. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  8651. case Plane.PlaneIntersectionType_Intersecting:
  8652. result=Plane.PlaneIntersectionType_Intersecting;
  8653. break ;
  8654. }
  8655. }
  8656. switch (result){
  8657. case Plane.PlaneIntersectionType_Intersecting:
  8658. return /*laya.d3.math.ContainmentType.Intersects*/2;
  8659. default :
  8660. return /*laya.d3.math.ContainmentType.Contains*/1;
  8661. }
  8662. }
  8663. /**
  8664. *与包围盒的位置关系。返回-1,包涵;0,相交;1,不相交
  8665. *@param box 包围盒。
  8666. */
  8667. __proto.containsBoundBox=function(box){
  8668. var p=BoundFrustum._tempV30,n=BoundFrustum._tempV31;
  8669. var boxMin=box.min;
  8670. var boxMax=box.max;
  8671. var result=/*laya.d3.math.ContainmentType.Contains*/1;
  8672. for (var i=0;i < 6;i++){
  8673. var plane=this.getPlane(i);
  8674. var planeNor=plane.normal;
  8675. if (planeNor.x >=0){
  8676. p.x=boxMax.x;
  8677. n.x=boxMin.x;
  8678. }else {
  8679. p.x=boxMin.x;
  8680. n.x=boxMax.x;
  8681. }
  8682. if (planeNor.y >=0){
  8683. p.y=boxMax.y;
  8684. n.y=boxMin.y;
  8685. }else {
  8686. p.y=boxMin.y;
  8687. n.y=boxMax.y;
  8688. }
  8689. if (planeNor.z >=0){
  8690. p.z=boxMax.z;
  8691. n.z=boxMin.z;
  8692. }else {
  8693. p.z=boxMin.z;
  8694. n.z=boxMax.z;
  8695. }
  8696. if (CollisionUtils.intersectsPlaneAndPoint(plane,p)===Plane.PlaneIntersectionType_Back)
  8697. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  8698. if (CollisionUtils.intersectsPlaneAndPoint(plane,n)===Plane.PlaneIntersectionType_Back)
  8699. result=/*laya.d3.math.ContainmentType.Intersects*/2;
  8700. }
  8701. return result;
  8702. }
  8703. /**
  8704. *与包围球的位置关系。返回-1,包涵;0,相交;1,不相交
  8705. *@param sphere 包围球。
  8706. */
  8707. __proto.containsBoundSphere=function(sphere){
  8708. var result=Plane.PlaneIntersectionType_Front;
  8709. var planeResult=Plane.PlaneIntersectionType_Front;
  8710. for (var i=0;i < 6;i++){
  8711. switch (i){
  8712. case 0:
  8713. planeResult=CollisionUtils.intersectsPlaneAndSphere(this._near,sphere);
  8714. break ;
  8715. case 1:
  8716. planeResult=CollisionUtils.intersectsPlaneAndSphere(this._far,sphere);
  8717. break ;
  8718. case 2:
  8719. planeResult=CollisionUtils.intersectsPlaneAndSphere(this._left,sphere);
  8720. break ;
  8721. case 3:
  8722. planeResult=CollisionUtils.intersectsPlaneAndSphere(this._right,sphere);
  8723. break ;
  8724. case 4:
  8725. planeResult=CollisionUtils.intersectsPlaneAndSphere(this._top,sphere);
  8726. break ;
  8727. case 5:
  8728. planeResult=CollisionUtils.intersectsPlaneAndSphere(this._bottom,sphere);
  8729. break ;
  8730. }
  8731. switch (planeResult){
  8732. case Plane.PlaneIntersectionType_Back:
  8733. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  8734. case Plane.PlaneIntersectionType_Intersecting:
  8735. result=Plane.PlaneIntersectionType_Intersecting;
  8736. break ;
  8737. }
  8738. }
  8739. switch (result){
  8740. case Plane.PlaneIntersectionType_Intersecting:
  8741. return /*laya.d3.math.ContainmentType.Intersects*/2;
  8742. default :
  8743. return /*laya.d3.math.ContainmentType.Contains*/1;
  8744. }
  8745. }
  8746. /**
  8747. *获取顶平面。
  8748. *@return 顶平面。
  8749. */
  8750. __getset(0,__proto,'top',function(){
  8751. return this._top;
  8752. });
  8753. /**
  8754. *设置描述矩阵。
  8755. *@param matrix 描述矩阵。
  8756. */
  8757. /**
  8758. *获取描述矩阵。
  8759. *@return 描述矩阵。
  8760. */
  8761. __getset(0,__proto,'matrix',function(){
  8762. return this._matrix;
  8763. },function(matrix){
  8764. this._matrix=matrix;
  8765. BoundFrustum._getPlanesFromMatrix(this._matrix,this._near,this._far,this._left,this._right,this._top,this._bottom);
  8766. });
  8767. /**
  8768. *获取近平面。
  8769. *@return 近平面。
  8770. */
  8771. __getset(0,__proto,'near',function(){
  8772. return this._near;
  8773. });
  8774. /**
  8775. *获取远平面。
  8776. *@return 远平面。
  8777. */
  8778. __getset(0,__proto,'far',function(){
  8779. return this._far;
  8780. });
  8781. /**
  8782. *获取左平面。
  8783. *@return 左平面。
  8784. */
  8785. __getset(0,__proto,'left',function(){
  8786. return this._left;
  8787. });
  8788. /**
  8789. *获取右平面。
  8790. *@return 右平面。
  8791. */
  8792. __getset(0,__proto,'right',function(){
  8793. return this._right;
  8794. });
  8795. /**
  8796. *获取底平面。
  8797. *@return 底平面。
  8798. */
  8799. __getset(0,__proto,'bottom',function(){
  8800. return this._bottom;
  8801. });
  8802. BoundFrustum._getPlanesFromMatrix=function(m,np,fp,lp,rp,tp,bp){
  8803. var matrixE=m.elements;
  8804. var m11=matrixE[0];
  8805. var m12=matrixE[1];
  8806. var m13=matrixE[2];
  8807. var m14=matrixE[3];
  8808. var m21=matrixE[4];
  8809. var m22=matrixE[5];
  8810. var m23=matrixE[6];
  8811. var m24=matrixE[7];
  8812. var m31=matrixE[8];
  8813. var m32=matrixE[9];
  8814. var m33=matrixE[10];
  8815. var m34=matrixE[11];
  8816. var m41=matrixE[12];
  8817. var m42=matrixE[13];
  8818. var m43=matrixE[14];
  8819. var m44=matrixE[15];
  8820. var nearNorE=np.normal;
  8821. nearNorE.x=m14+m13;
  8822. nearNorE.y=m24+m23;
  8823. nearNorE.z=m34+m33;
  8824. np.distance=m44+m43;
  8825. np.normalize();
  8826. var farNorE=fp.normal;
  8827. farNorE.x=m14-m13;
  8828. farNorE.y=m24-m23;
  8829. farNorE.z=m34-m33;
  8830. fp.distance=m44-m43;
  8831. fp.normalize();
  8832. var leftNorE=lp.normal;
  8833. leftNorE.x=m14+m11;
  8834. leftNorE.y=m24+m21;
  8835. leftNorE.z=m34+m31;
  8836. lp.distance=m44+m41;
  8837. lp.normalize();
  8838. var rightNorE=rp.normal;
  8839. rightNorE.x=m14-m11;
  8840. rightNorE.y=m24-m21;
  8841. rightNorE.z=m34-m31;
  8842. rp.distance=m44-m41;
  8843. rp.normalize();
  8844. var topNorE=tp.normal;
  8845. topNorE.x=m14-m12;
  8846. topNorE.y=m24-m22;
  8847. topNorE.z=m34-m32;
  8848. tp.distance=m44-m42;
  8849. tp.normalize();
  8850. var bottomNorE=bp.normal;
  8851. bottomNorE.x=m14+m12;
  8852. bottomNorE.y=m24+m22;
  8853. bottomNorE.z=m34+m32;
  8854. bp.distance=m44+m42;
  8855. bp.normalize();
  8856. }
  8857. BoundFrustum._get3PlaneInterPoint=function(p1,p2,p3){
  8858. var p1Nor=p1.normal;
  8859. var p2Nor=p2.normal;
  8860. var p3Nor=p3.normal;
  8861. Vector3.cross(p2Nor,p3Nor,BoundFrustum._tempV30);
  8862. Vector3.cross(p3Nor,p1Nor,BoundFrustum._tempV31);
  8863. Vector3.cross(p1Nor,p2Nor,BoundFrustum._tempV32);
  8864. var a=Vector3.dot(p1Nor,BoundFrustum._tempV30);
  8865. var b=Vector3.dot(p2Nor,BoundFrustum._tempV31);
  8866. var c=Vector3.dot(p3Nor,BoundFrustum._tempV32);
  8867. Vector3.scale(BoundFrustum._tempV30,-p1.distance / a,BoundFrustum._tempV33);
  8868. Vector3.scale(BoundFrustum._tempV31,-p2.distance / b,BoundFrustum._tempV34);
  8869. Vector3.scale(BoundFrustum._tempV32,-p3.distance / c,BoundFrustum._tempV35);
  8870. Vector3.add(BoundFrustum._tempV33,BoundFrustum._tempV34,BoundFrustum._tempV36);
  8871. Vector3.add(BoundFrustum._tempV35,BoundFrustum._tempV36,BoundFrustum._tempV37);
  8872. var v=BoundFrustum._tempV37;
  8873. return v;
  8874. }
  8875. __static(BoundFrustum,
  8876. ['_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();}
  8877. ]);
  8878. return BoundFrustum;
  8879. })()
  8880. /**
  8881. *<code>RenderState</code> 类用于控制渲染状态。
  8882. */
  8883. //class laya.d3.core.material.RenderState
  8884. var RenderState=(function(){
  8885. function RenderState(){
  8886. /**渲染剔除状态。*/
  8887. this.cull=0;
  8888. /**透明混合。*/
  8889. this.blend=0;
  8890. /**源混合参数,在blend为BLEND_ENABLE_ALL时生效。*/
  8891. this.srcBlend=0;
  8892. /**目标混合参数,在blend为BLEND_ENABLE_ALL时生效。*/
  8893. this.dstBlend=0;
  8894. /**RGB源混合参数,在blend为BLEND_ENABLE_SEPERATE时生效。*/
  8895. this.srcBlendRGB=0;
  8896. /**RGB目标混合参数,在blend为BLEND_ENABLE_SEPERATE时生效。*/
  8897. this.dstBlendRGB=0;
  8898. /**Alpha源混合参数,在blend为BLEND_ENABLE_SEPERATE时生效。*/
  8899. this.srcBlendAlpha=0;
  8900. /**Alpha目标混合参数,在blend为BLEND_ENABLE_SEPERATE时生效。*/
  8901. this.dstBlendAlpha=0;
  8902. /**混合常量颜色。*/
  8903. this.blendConstColor=null;
  8904. /**混合方程。*/
  8905. this.blendEquation=0;
  8906. /**RGB混合方程。*/
  8907. this.blendEquationRGB=0;
  8908. /**Alpha混合方程。*/
  8909. this.blendEquationAlpha=0;
  8910. /**深度测试函数。*/
  8911. this.depthTest=0;
  8912. /**是否深度写入。*/
  8913. this.depthWrite=false;
  8914. this.cull=2;
  8915. this.blend=0;
  8916. this.srcBlend=1;
  8917. this.dstBlend=0;
  8918. this.srcBlendRGB=1;
  8919. this.dstBlendRGB=0;
  8920. this.srcBlendAlpha=1;
  8921. this.dstBlendAlpha=0;
  8922. this.blendConstColor=new Vector4(1,1,1,1);
  8923. this.blendEquation=0;
  8924. this.blendEquationRGB=0;
  8925. this.blendEquationAlpha=0;
  8926. this.depthTest=0x0203;
  8927. this.depthWrite=true;
  8928. }
  8929. __class(RenderState,'laya.d3.core.material.RenderState');
  8930. var __proto=RenderState.prototype;
  8931. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  8932. /**
  8933. *克隆。
  8934. *@param destObject 克隆源。
  8935. */
  8936. __proto.cloneTo=function(dest){
  8937. var destState=dest;
  8938. destState.cull=this.cull;
  8939. destState.blend=this.blend;
  8940. destState.srcBlend=this.srcBlend;
  8941. destState.dstBlend=this.dstBlend;
  8942. destState.srcBlendRGB=this.srcBlendRGB;
  8943. destState.dstBlendRGB=this.dstBlendRGB;
  8944. destState.srcBlendAlpha=this.srcBlendAlpha;
  8945. destState.dstBlendAlpha=this.dstBlendAlpha;
  8946. this.blendConstColor.cloneTo(destState.blendConstColor);
  8947. destState.blendEquation=this.blendEquation;
  8948. destState.blendEquationRGB=this.blendEquationRGB;
  8949. destState.blendEquationAlpha=this.blendEquationAlpha;
  8950. destState.depthTest=this.depthTest;
  8951. destState.depthWrite=this.depthWrite;
  8952. }
  8953. /**
  8954. *克隆。
  8955. *@return 克隆副本。
  8956. */
  8957. __proto.clone=function(){
  8958. var dest=/*__JS__ */new this.constructor();
  8959. this.cloneTo(dest);
  8960. return dest;
  8961. }
  8962. RenderState.CULL_NONE=0;
  8963. RenderState.CULL_FRONT=1;
  8964. RenderState.CULL_BACK=2;
  8965. RenderState.BLEND_DISABLE=0;
  8966. RenderState.BLEND_ENABLE_ALL=1;
  8967. RenderState.BLEND_ENABLE_SEPERATE=2;
  8968. RenderState.BLENDPARAM_ZERO=0;
  8969. RenderState.BLENDPARAM_ONE=1;
  8970. RenderState.BLENDPARAM_SRC_COLOR=0x0300;
  8971. RenderState.BLENDPARAM_ONE_MINUS_SRC_COLOR=0x0301;
  8972. RenderState.BLENDPARAM_DST_COLOR=0x0306;
  8973. RenderState.BLENDPARAM_ONE_MINUS_DST_COLOR=0x0307;
  8974. RenderState.BLENDPARAM_SRC_ALPHA=0x0302;
  8975. RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA=0x0303;
  8976. RenderState.BLENDPARAM_DST_ALPHA=0x0304;
  8977. RenderState.BLENDPARAM_ONE_MINUS_DST_ALPHA=0x0305;
  8978. RenderState.BLENDPARAM_SRC_ALPHA_SATURATE=0x0308;
  8979. RenderState.BLENDEQUATION_ADD=0;
  8980. RenderState.BLENDEQUATION_SUBTRACT=1;
  8981. RenderState.BLENDEQUATION_REVERSE_SUBTRACT=2;
  8982. RenderState.DEPTHTEST_OFF=0;
  8983. RenderState.DEPTHTEST_NEVER=0x0200;
  8984. RenderState.DEPTHTEST_LESS=0x0201;
  8985. RenderState.DEPTHTEST_EQUAL=0x0202;
  8986. RenderState.DEPTHTEST_LEQUAL=0x0203;
  8987. RenderState.DEPTHTEST_GREATER=0x0204;
  8988. RenderState.DEPTHTEST_NOTEQUAL=0x0205;
  8989. RenderState.DEPTHTEST_GEQUAL=0x0206;
  8990. RenderState.DEPTHTEST_ALWAYS=0x0207;
  8991. return RenderState;
  8992. })()
  8993. /**
  8994. *<code>StartFrame</code> 类用于创建开始帧。
  8995. */
  8996. //class laya.d3.core.particleShuriKen.module.StartFrame
  8997. var StartFrame=(function(){
  8998. function StartFrame(){
  8999. /**@private */
  9000. this._type=0;
  9001. /**@private */
  9002. this._constant=NaN;
  9003. /**@private */
  9004. this._constantMin=NaN;
  9005. /**@private */
  9006. this._constantMax=NaN;
  9007. }
  9008. __class(StartFrame,'laya.d3.core.particleShuriKen.module.StartFrame');
  9009. var __proto=StartFrame.prototype;
  9010. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  9011. /**
  9012. *克隆。
  9013. *@param destObject 克隆源。
  9014. */
  9015. __proto.cloneTo=function(destObject){
  9016. var destStartFrame=destObject;
  9017. destStartFrame._type=this._type;
  9018. destStartFrame._constant=this._constant;
  9019. destStartFrame._constantMin=this._constantMin;
  9020. destStartFrame._constantMax=this._constantMax;
  9021. }
  9022. /**
  9023. *克隆。
  9024. *@return 克隆副本。
  9025. */
  9026. __proto.clone=function(){
  9027. var destStartFrame=/*__JS__ */new this.constructor();
  9028. this.cloneTo(destStartFrame);
  9029. return destStartFrame;
  9030. }
  9031. /**
  9032. *固定帧。
  9033. */
  9034. __getset(0,__proto,'constant',function(){
  9035. return this._constant;
  9036. });
  9037. /**
  9038. *开始帧类型,0常量模式,1随机双常量模式。
  9039. */
  9040. __getset(0,__proto,'type',function(){
  9041. return this._type;
  9042. });
  9043. /**
  9044. *最小固定帧。
  9045. */
  9046. __getset(0,__proto,'constantMin',function(){
  9047. return this._constantMin;
  9048. });
  9049. /**
  9050. *最大固定帧。
  9051. */
  9052. __getset(0,__proto,'constantMax',function(){
  9053. return this._constantMax;
  9054. });
  9055. StartFrame.createByConstant=function(constant){
  9056. var rotationOverLifetime=new StartFrame();
  9057. rotationOverLifetime._type=0;
  9058. rotationOverLifetime._constant=constant;
  9059. return rotationOverLifetime;
  9060. }
  9061. StartFrame.createByRandomTwoConstant=function(constantMin,constantMax){
  9062. var rotationOverLifetime=new StartFrame();
  9063. rotationOverLifetime._type=1;
  9064. rotationOverLifetime._constantMin=constantMin;
  9065. rotationOverLifetime._constantMax=constantMax;
  9066. return rotationOverLifetime;
  9067. }
  9068. return StartFrame;
  9069. })()
  9070. /**
  9071. *@private
  9072. *<code>Command</code> 类用于创建指令。
  9073. */
  9074. //class laya.d3.core.render.command.Command
  9075. var Command=(function(){
  9076. /**
  9077. *创建一个 <code>Command</code> 实例。
  9078. */
  9079. function Command(){}
  9080. __class(Command,'laya.d3.core.render.command.Command');
  9081. var __proto=Command.prototype;
  9082. /**
  9083. *@private
  9084. */
  9085. __proto.run=function(){}
  9086. /**
  9087. *@private
  9088. */
  9089. __proto.recover=function(){}
  9090. return Command;
  9091. })()
  9092. /**
  9093. *<code>DetailTextureInfo</code> 类用于描述地形细节纹理。
  9094. */
  9095. //class laya.d3.terrain.unit.ChunkInfo
  9096. var ChunkInfo=(function(){
  9097. function ChunkInfo(){
  9098. this.alphaMap=null;
  9099. this.detailID=null;
  9100. this.normalMap=null;
  9101. }
  9102. __class(ChunkInfo,'laya.d3.terrain.unit.ChunkInfo');
  9103. return ChunkInfo;
  9104. })()
  9105. /**
  9106. *...
  9107. *@author ...
  9108. */
  9109. //class laya.d3.shadowMap.ParallelSplitShadowMap
  9110. var ParallelSplitShadowMap=(function(){
  9111. function ParallelSplitShadowMap(){
  9112. /**@private */
  9113. //this.lastNearPlane=NaN;
  9114. /**@private */
  9115. //this.lastFieldOfView=NaN;
  9116. /**@private */
  9117. //this.lastAspectRatio=NaN;
  9118. /**@private */
  9119. this._currentPSSM=-1;
  9120. /**@private */
  9121. this._shadowMapCount=3;
  9122. /**@private */
  9123. this._maxDistance=200.0;
  9124. /**@private */
  9125. this._ratioOfDistance=1.0 / this._shadowMapCount;
  9126. /**@private */
  9127. this._statesDirty=true;
  9128. /**@private */
  9129. //this.cameras=null;
  9130. /**@private */
  9131. this._shadowMapTextureSize=1024;
  9132. /**@private */
  9133. this._scene=null;
  9134. /**@private */
  9135. this._PCFType=0;
  9136. /**@private */
  9137. this._shaderValueLightVP=null;
  9138. /**@private */
  9139. //this._shaderValueVPs=null;
  9140. this._spiltDistance=new Array(/*CLASS CONST:laya.d3.shadowMap.ParallelSplitShadowMap.MAX_PSSM_COUNT*/3+1);
  9141. this._globalParallelLightDir=new Vector3(0,-1,0);
  9142. this._boundingSphere=new Array(/*CLASS CONST:laya.d3.shadowMap.ParallelSplitShadowMap.MAX_PSSM_COUNT*/3+1);
  9143. this._boundingBox=new Array(/*CLASS CONST:laya.d3.shadowMap.ParallelSplitShadowMap.MAX_PSSM_COUNT*/3+1);
  9144. this._frustumPos=new Array((/*CLASS CONST:laya.d3.shadowMap.ParallelSplitShadowMap.MAX_PSSM_COUNT*/3+1)*4);
  9145. this._uniformDistance=new Array(/*CLASS CONST:laya.d3.shadowMap.ParallelSplitShadowMap.MAX_PSSM_COUNT*/3+1);
  9146. this._logDistance=new Array(/*CLASS CONST:laya.d3.shadowMap.ParallelSplitShadowMap.MAX_PSSM_COUNT*/3+1);
  9147. this._dimension=new Array(/*CLASS CONST:laya.d3.shadowMap.ParallelSplitShadowMap.MAX_PSSM_COUNT*/3+1);
  9148. this._tempLookAt3=new Vector3();
  9149. this._tempLookAt4=new Vector4();
  9150. this._tempValue=new Vector4();
  9151. this._tempPos=new Vector3();
  9152. this._tempLightUp=new Vector3();
  9153. this._tempMin=new Vector4();
  9154. this._tempMax=new Vector4();
  9155. this._tempMatrix44=new Matrix4x4;
  9156. this._splitFrustumCulling=new BoundFrustum(Matrix4x4.DEFAULT);
  9157. this._tempScaleMatrix44=new Matrix4x4();
  9158. this._shadowPCFOffset=new Vector2(1.0 / 1024.0,1.0 / 1024.0);
  9159. this._shaderValueDistance=new Vector4();
  9160. this.cameras=[];
  9161. this._shaderValueVPs=[];
  9162. var i=0;
  9163. for (i=0;i < this._spiltDistance.length;i++){
  9164. this._spiltDistance[i]=0.0;
  9165. }
  9166. for (i=0;i < this._dimension.length;i++){
  9167. this._dimension[i]=new Vector2();
  9168. }
  9169. for (i=0;i < this._frustumPos.length;i++){
  9170. this._frustumPos[i]=new Vector3();
  9171. }
  9172. for (i=0;i < this._boundingBox.length;i++){
  9173. this._boundingBox[i]=new BoundBox(new Vector3(),new Vector3());
  9174. }
  9175. for (i=0;i < this._boundingSphere.length;i++){
  9176. this._boundingSphere[i]=new BoundSphere(new Vector3(),0.0);
  9177. }
  9178. Matrix4x4.createScaling(new Vector3(0.5,0.5,1.0),this._tempScaleMatrix44);
  9179. this._tempScaleMatrix44.elements[12]=0.5;
  9180. this._tempScaleMatrix44.elements[13]=0.5;
  9181. }
  9182. __class(ParallelSplitShadowMap,'laya.d3.shadowMap.ParallelSplitShadowMap');
  9183. var __proto=ParallelSplitShadowMap.prototype;
  9184. __proto.setInfo=function(scene,maxDistance,globalParallelDir,shadowMapTextureSize,numberOfPSSM,PCFType){
  9185. if (numberOfPSSM > /*CLASS CONST:laya.d3.shadowMap.ParallelSplitShadowMap.MAX_PSSM_COUNT*/3){
  9186. this._shadowMapCount=/*CLASS CONST:laya.d3.shadowMap.ParallelSplitShadowMap.MAX_PSSM_COUNT*/3;
  9187. }
  9188. this._scene=scene;
  9189. this._maxDistance=maxDistance;
  9190. this.shadowMapCount=numberOfPSSM;
  9191. this._globalParallelLightDir=globalParallelDir;
  9192. this._ratioOfDistance=1.0 / this._shadowMapCount;
  9193. for (var i=0;i < this._spiltDistance.length;i++){
  9194. this._spiltDistance[i]=0.0;
  9195. }
  9196. this._shadowMapTextureSize=shadowMapTextureSize;
  9197. this._shadowPCFOffset.x=1.0 / this._shadowMapTextureSize;
  9198. this._shadowPCFOffset.y=1.0 / this._shadowMapTextureSize;
  9199. this.setPCFType(PCFType);
  9200. this._statesDirty=true;
  9201. }
  9202. __proto.setPCFType=function(PCFtype){
  9203. this._PCFType=PCFtype;
  9204. var defineData=this._scene._defineDatas;
  9205. switch (this._PCFType){
  9206. case 0:
  9207. defineData.add(Scene3D.SHADERDEFINE_SHADOW_PCF_NO);
  9208. defineData.remove(Scene3D.SHADERDEFINE_SHADOW_PCF1);
  9209. defineData.remove(Scene3D.SHADERDEFINE_SHADOW_PCF2);
  9210. defineData.remove(Scene3D.SHADERDEFINE_SHADOW_PCF3);
  9211. break ;
  9212. case 1:
  9213. defineData.add(Scene3D.SHADERDEFINE_SHADOW_PCF1);
  9214. defineData.remove(Scene3D.SHADERDEFINE_SHADOW_PCF_NO);
  9215. defineData.remove(Scene3D.SHADERDEFINE_SHADOW_PCF2);
  9216. defineData.remove(Scene3D.SHADERDEFINE_SHADOW_PCF3);
  9217. break ;
  9218. case 2:
  9219. defineData.add(Scene3D.SHADERDEFINE_SHADOW_PCF2);
  9220. defineData.remove(Scene3D.SHADERDEFINE_SHADOW_PCF_NO);
  9221. defineData.remove(Scene3D.SHADERDEFINE_SHADOW_PCF1);
  9222. defineData.remove(Scene3D.SHADERDEFINE_SHADOW_PCF3);
  9223. break ;
  9224. case 3:
  9225. defineData.add(Scene3D.SHADERDEFINE_SHADOW_PCF3);
  9226. defineData.remove(Scene3D.SHADERDEFINE_SHADOW_PCF_NO);
  9227. defineData.remove(Scene3D.SHADERDEFINE_SHADOW_PCF1);
  9228. defineData.remove(Scene3D.SHADERDEFINE_SHADOW_PCF2);
  9229. break ;
  9230. }
  9231. }
  9232. __proto.getPCFType=function(){
  9233. return this._PCFType;
  9234. }
  9235. __proto.setFarDistance=function(value){
  9236. if (this._maxDistance !=value){
  9237. this._maxDistance=value;
  9238. this._statesDirty=true;
  9239. }
  9240. }
  9241. __proto.getFarDistance=function(){
  9242. return this._maxDistance;
  9243. }
  9244. /**
  9245. *@private
  9246. */
  9247. __proto._beginSampler=function(index,sceneCamera){
  9248. if (index < 0 || index > this._shadowMapCount)
  9249. throw new Error("ParallelSplitShadowMap: beginSample invalid index");
  9250. this._currentPSSM=index;
  9251. this._update(sceneCamera);
  9252. }
  9253. /**
  9254. *@private
  9255. */
  9256. __proto.endSampler=function(sceneCamera){
  9257. this._currentPSSM=-1;
  9258. }
  9259. /**
  9260. *@private
  9261. */
  9262. __proto._calcAllLightCameraInfo=function(sceneCamera){
  9263. if (this._shadowMapCount===1){
  9264. this._beginSampler(0,sceneCamera);
  9265. this.endSampler(sceneCamera);
  9266. }else {
  9267. for (var i=0,n=this._shadowMapCount+1;i < n;i++){
  9268. this._beginSampler(i,sceneCamera);
  9269. this.endSampler(sceneCamera);
  9270. }
  9271. }
  9272. }
  9273. /**
  9274. *@private
  9275. */
  9276. __proto._recalculate=function(nearPlane,fieldOfView,aspectRatio){
  9277. this._calcSplitDistance(nearPlane);
  9278. this._calcBoundingBox(fieldOfView,aspectRatio);
  9279. this._rebuildRenderInfo();
  9280. }
  9281. /**
  9282. *@private
  9283. */
  9284. __proto._update=function(sceneCamera){
  9285. var nearPlane=sceneCamera.nearPlane;
  9286. var fieldOfView=sceneCamera.fieldOfView;
  9287. var aspectRatio=(sceneCamera).aspectRatio;
  9288. if (this._statesDirty || this.lastNearPlane!==nearPlane || this.lastFieldOfView!==fieldOfView || this.lastAspectRatio!==aspectRatio){
  9289. this._recalculate(nearPlane,fieldOfView,aspectRatio);
  9290. this._uploadShaderValue();
  9291. this._statesDirty=false;
  9292. this.lastNearPlane=nearPlane;
  9293. this.lastFieldOfView=fieldOfView;
  9294. this.lastAspectRatio=aspectRatio;
  9295. }
  9296. this._calcLightViewProject(sceneCamera);
  9297. }
  9298. /**
  9299. *@private
  9300. */
  9301. __proto._uploadShaderValue=function(){
  9302. var defDatas=this._scene._defineDatas;
  9303. switch (this._shadowMapCount){
  9304. case 1:
  9305. defDatas.add(Scene3D.SHADERDEFINE_SHADOW_PSSM1);
  9306. defDatas.remove(Scene3D.SHADERDEFINE_SHADOW_PSSM2);
  9307. defDatas.remove(Scene3D.SHADERDEFINE_SHADOW_PSSM3);
  9308. break ;
  9309. case 2:
  9310. defDatas.add(Scene3D.SHADERDEFINE_SHADOW_PSSM2);
  9311. defDatas.remove(Scene3D.SHADERDEFINE_SHADOW_PSSM1);
  9312. defDatas.remove(Scene3D.SHADERDEFINE_SHADOW_PSSM3);
  9313. break ;
  9314. case 3:
  9315. defDatas.add(Scene3D.SHADERDEFINE_SHADOW_PSSM3);
  9316. defDatas.remove(Scene3D.SHADERDEFINE_SHADOW_PSSM1);
  9317. defDatas.remove(Scene3D.SHADERDEFINE_SHADOW_PSSM2);
  9318. break ;
  9319. };
  9320. var sceneSV=this._scene._shaderValues;
  9321. sceneSV.setVector(Scene3D.SHADOWDISTANCE,this._shaderValueDistance);
  9322. sceneSV.setBuffer(Scene3D.SHADOWLIGHTVIEWPROJECT,this._shaderValueLightVP);
  9323. sceneSV.setVector2(Scene3D.SHADOWMAPPCFOFFSET,this._shadowPCFOffset);
  9324. switch (this._shadowMapCount){
  9325. case 3:
  9326. sceneSV.setTexture(Scene3D.SHADOWMAPTEXTURE1,this.cameras[1].renderTarget);
  9327. sceneSV.setTexture(Scene3D.SHADOWMAPTEXTURE2,this.cameras[2].renderTarget)
  9328. sceneSV.setTexture(Scene3D.SHADOWMAPTEXTURE3,this.cameras[3].renderTarget);
  9329. break ;
  9330. case 2:
  9331. sceneSV.setTexture(Scene3D.SHADOWMAPTEXTURE1,this.cameras[1].renderTarget);
  9332. sceneSV.setTexture(Scene3D.SHADOWMAPTEXTURE2,this.cameras[2].renderTarget);
  9333. break ;
  9334. case 1:
  9335. sceneSV.setTexture(Scene3D.SHADOWMAPTEXTURE1,this.cameras[1].renderTarget);
  9336. break ;
  9337. }
  9338. }
  9339. /**
  9340. *@private
  9341. */
  9342. __proto._calcSplitDistance=function(nearPlane){
  9343. var far=this._maxDistance;
  9344. var invNumberOfPSSM=1.0 / this._shadowMapCount;
  9345. var i=0;
  9346. for (i=0;i <=this._shadowMapCount;i++){
  9347. this._uniformDistance[i]=nearPlane+(far-nearPlane)*i *invNumberOfPSSM;
  9348. };
  9349. var farDivNear=far / nearPlane;
  9350. for (i=0;i <=this._shadowMapCount;i++){
  9351. var n=Math.pow(farDivNear,i *invNumberOfPSSM);
  9352. this._logDistance[i]=nearPlane *n;
  9353. }
  9354. for (i=0;i <=this._shadowMapCount;i++){
  9355. this._spiltDistance[i]=this._uniformDistance[i] *this._ratioOfDistance+this._logDistance[i] *(1.0-this._ratioOfDistance);
  9356. }
  9357. this._shaderValueDistance.x=this._spiltDistance[1];
  9358. this._shaderValueDistance.y=this._spiltDistance[2];
  9359. this._shaderValueDistance.z=this._spiltDistance[3];
  9360. this._shaderValueDistance.w=0.0;
  9361. }
  9362. /**
  9363. *@private
  9364. */
  9365. __proto._calcBoundingBox=function(fieldOfView,aspectRatio){
  9366. var fov=3.1415926 *fieldOfView / 180.0;
  9367. var halfTanValue=Math.tan(fov / 2.0);
  9368. var height=NaN;
  9369. var width=NaN;
  9370. var distance=NaN;
  9371. var i=0;
  9372. for (i=0;i <=this._shadowMapCount;i++){
  9373. distance=this._spiltDistance[i];
  9374. height=distance *halfTanValue;
  9375. width=height *aspectRatio;
  9376. var temp=this._frustumPos[i *4+0];
  9377. temp.x=-width;
  9378. temp.y=-height;
  9379. temp.z=-distance;
  9380. temp=this._frustumPos[i *4+1];
  9381. temp.x=width;
  9382. temp.y=-height;
  9383. temp.z=-distance;
  9384. temp=this._frustumPos[i *4+2];
  9385. temp.x=-width;
  9386. temp.y=height;
  9387. temp.z=-distance;
  9388. temp=this._frustumPos[i *4+3];
  9389. temp.x=width;
  9390. temp.y=height;
  9391. temp.z=-distance;
  9392. temp=this._dimension[i];
  9393. temp.x=width;
  9394. temp.y=height;
  9395. };
  9396. var d;
  9397. var min;
  9398. var max;
  9399. var center;
  9400. for (i=1;i <=this._shadowMapCount;i++){
  9401. d=this._dimension[i];
  9402. min=this._boundingBox[i].min;
  9403. min.x=-d.x;
  9404. min.y=-d.y;
  9405. min.z=-this._spiltDistance[i];
  9406. max=this._boundingBox[i].max;
  9407. max.x=d.x;
  9408. max.y=d.y;
  9409. max.z=-this._spiltDistance[i-1];
  9410. center=this._boundingSphere[i].center;
  9411. center.x=(min.x+max.x)*0.5;
  9412. center.y=(min.y+max.y)*0.5;
  9413. center.z=(min.z+max.z)*0.5;
  9414. 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;
  9415. }
  9416. min=this._boundingBox[0].min;
  9417. d=this._dimension[this._shadowMapCount];
  9418. min.x=-d.x;
  9419. min.y=-d.y;
  9420. min.z=-this._spiltDistance[this._shadowMapCount];
  9421. max=this._boundingBox[0].max;
  9422. max.x=d.x;
  9423. max.y=d.y;
  9424. max.z=-this._spiltDistance[0];
  9425. center=this._boundingSphere[0].center;
  9426. center.x=(min.x+max.x)*0.5;
  9427. center.y=(min.y+max.y)*0.5;
  9428. center.z=(min.z+max.z)*0.5;
  9429. 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;
  9430. }
  9431. __proto.calcSplitFrustum=function(sceneCamera){
  9432. if (this._currentPSSM > 0){
  9433. Matrix4x4.createPerspective(3.1416 *sceneCamera.fieldOfView / 180.0,(sceneCamera).aspectRatio,this._spiltDistance[this._currentPSSM-1],this._spiltDistance[this._currentPSSM],this._tempMatrix44);
  9434. }else {
  9435. Matrix4x4.createPerspective(3.1416 *sceneCamera.fieldOfView / 180.0,(sceneCamera).aspectRatio,this._spiltDistance[0],this._spiltDistance[this._shadowMapCount],this._tempMatrix44);
  9436. }
  9437. Matrix4x4.multiply(this._tempMatrix44,(sceneCamera).viewMatrix,this._tempMatrix44);
  9438. this._splitFrustumCulling.matrix=this._tempMatrix44;
  9439. }
  9440. /**
  9441. *@private
  9442. */
  9443. __proto._rebuildRenderInfo=function(){
  9444. var nNum=this._shadowMapCount+1;
  9445. var i=0;
  9446. this.cameras.length=nNum;
  9447. for (i=0;i < nNum;i++){
  9448. if (!this.cameras[i]){
  9449. var camera=new Camera();
  9450. camera.name="lightCamera"+i;
  9451. camera.clearColor=new Vector4(1.0,1.0,1.0,1.0);
  9452. this.cameras[i]=camera;
  9453. };
  9454. var shadowMap=this.cameras[i].renderTarget;
  9455. if (shadowMap==null || shadowMap.width !=this._shadowMapTextureSize || shadowMap.height !=this._shadowMapTextureSize){
  9456. (shadowMap)&& (shadowMap.destroy());
  9457. shadowMap=new RenderTexture(this._shadowMapTextureSize,this._shadowMapTextureSize,/*laya.resource.BaseTexture.FORMAT_R8G8B8A8*/1,/*laya.resource.BaseTexture.FORMAT_DEPTH_16*/0);
  9458. shadowMap.filterMode=/*laya.resource.BaseTexture.FILTERMODE_POINT*/0;
  9459. this.cameras[i].renderTarget=shadowMap;
  9460. }
  9461. }
  9462. }
  9463. /**
  9464. *@private
  9465. */
  9466. __proto._calcLightViewProject=function(sceneCamera){
  9467. var boundSphere=this._boundingSphere[this._currentPSSM];
  9468. var cameraMatViewInv=sceneCamera.transform.worldMatrix;
  9469. var radius=boundSphere.radius;
  9470. boundSphere.center.cloneTo(this._tempLookAt3);
  9471. Vector3.transformV3ToV4(this._tempLookAt3,cameraMatViewInv,this._tempLookAt4);
  9472. var lookAt3Element=this._tempLookAt3;
  9473. var lookAt4Element=this._tempLookAt4;
  9474. lookAt3Element.x=lookAt4Element.x;
  9475. lookAt3Element.y=lookAt4Element.y;
  9476. lookAt3Element.z=lookAt4Element.z;
  9477. var lightUpElement=this._tempLightUp;
  9478. sceneCamera.transform.worldMatrix.getForward(ParallelSplitShadowMap._tempVector30);
  9479. var sceneCameraDir=ParallelSplitShadowMap._tempVector30;
  9480. lightUpElement.x=sceneCameraDir.x;
  9481. lightUpElement.y=1.0;
  9482. lightUpElement.z=sceneCameraDir.z;
  9483. Vector3.normalize(this._tempLightUp,this._tempLightUp);
  9484. Vector3.scale(this._globalParallelLightDir,boundSphere.radius *4,this._tempPos);
  9485. Vector3.subtract(this._tempLookAt3,this._tempPos,this._tempPos);
  9486. var curLightCamera=this.cameras[this._currentPSSM];
  9487. curLightCamera.transform.position=this._tempPos;
  9488. curLightCamera.transform.lookAt(this._tempLookAt3,this._tempLightUp,false);
  9489. var tempMax=this._tempMax;
  9490. var tempMin=this._tempMin;
  9491. tempMax.x=tempMax.y=tempMax.z=-100000.0;
  9492. tempMax.w=1.0;
  9493. tempMin.x=tempMin.y=tempMin.z=100000.0;
  9494. tempMin.w=1.0;
  9495. Matrix4x4.multiply(curLightCamera.viewMatrix,cameraMatViewInv,this._tempMatrix44);
  9496. var tempValueElement=this._tempValue;
  9497. var corners=[];
  9498. corners.length=8;
  9499. this._boundingBox[this._currentPSSM].getCorners(corners);
  9500. for (var i=0;i < 8;i++){
  9501. var frustumPosElements=corners[i];
  9502. tempValueElement.x=frustumPosElements.x;
  9503. tempValueElement.y=frustumPosElements.y;
  9504. tempValueElement.z=frustumPosElements.z;
  9505. tempValueElement.w=1.0;
  9506. Vector4.transformByM4x4(this._tempValue,this._tempMatrix44,this._tempValue);
  9507. tempMin.x=(tempValueElement.x < tempMin.x)? tempValueElement.x :tempMin.x;
  9508. tempMin.y=(tempValueElement.y < tempMin.y)? tempValueElement.y :tempMin.y;
  9509. tempMin.z=(tempValueElement.z < tempMin.z)? tempValueElement.z :tempMin.z;
  9510. tempMax.x=(tempValueElement.x > tempMax.x)? tempValueElement.x :tempMax.x;
  9511. tempMax.y=(tempValueElement.y > tempMax.y)? tempValueElement.y :tempMax.y;
  9512. tempMax.z=(tempValueElement.z > tempMax.z)? tempValueElement.z :tempMax.z;
  9513. }
  9514. Vector4.add(this._tempMax,this._tempMin,this._tempValue);
  9515. tempValueElement.x *=0.5;
  9516. tempValueElement.y *=0.5;
  9517. tempValueElement.z *=0.5;
  9518. tempValueElement.w=1;
  9519. Vector4.transformByM4x4(this._tempValue,curLightCamera.transform.worldMatrix,this._tempValue);
  9520. var distance=Math.abs(-this._tempMax.z);
  9521. var farPlane=distance > this._maxDistance ? distance :this._maxDistance;
  9522. Vector3.scale(this._globalParallelLightDir,farPlane,this._tempPos);
  9523. var tempPosElement=this._tempPos;
  9524. tempPosElement.x=tempValueElement.x-tempPosElement.x;
  9525. tempPosElement.y=tempValueElement.y-tempPosElement.y;
  9526. tempPosElement.z=tempValueElement.z-tempPosElement.z;
  9527. curLightCamera.transform.position=this._tempPos;
  9528. curLightCamera.transform.lookAt(this._tempLookAt3,this._tempLightUp,false);
  9529. Matrix4x4.createOrthoOffCenter(tempMin.x,tempMax.x,tempMin.y,tempMax.y,1.0,farPlane+0.5 *(tempMax.z-tempMin.z),curLightCamera.projectionMatrix);
  9530. var projectView=curLightCamera.projectionViewMatrix;
  9531. ParallelSplitShadowMap.multiplyMatrixOutFloat32Array(this._tempScaleMatrix44,projectView,this._shaderValueVPs[this._currentPSSM]);
  9532. this._scene._shaderValues.setBuffer(Scene3D.SHADOWLIGHTVIEWPROJECT,this._shaderValueLightVP);
  9533. }
  9534. __proto.setShadowMapTextureSize=function(size){
  9535. if (size!==this._shadowMapTextureSize){
  9536. this._shadowMapTextureSize=size;
  9537. this._shadowPCFOffset.x=1 / this._shadowMapTextureSize;
  9538. this._shadowPCFOffset.y=1 / this._shadowMapTextureSize;
  9539. this._statesDirty=true;
  9540. }
  9541. }
  9542. __proto.disposeAllRenderTarget=function(){
  9543. for (var i=0,n=this._shadowMapCount+1;i < n;i++){
  9544. if (this.cameras[i].renderTarget){
  9545. this.cameras[i].renderTarget.destroy();
  9546. this.cameras[i].renderTarget=null;
  9547. }
  9548. }
  9549. }
  9550. __getset(0,__proto,'shadowMapCount',function(){
  9551. return this._shadowMapCount;
  9552. },function(value){
  9553. value=value > 0 ? value :1;
  9554. value=value <=3 ? value :3;
  9555. if (this._shadowMapCount !=value){
  9556. this._shadowMapCount=value;
  9557. this._ratioOfDistance=1.0 / this._shadowMapCount;
  9558. this._statesDirty=true;
  9559. this._shaderValueLightVP=new Float32Array(value *16);
  9560. this._shaderValueVPs.length=value;
  9561. for (var i=0;i < value;i++)
  9562. this._shaderValueVPs[i]=new Float32Array(this._shaderValueLightVP.buffer,i *64);
  9563. }
  9564. });
  9565. ParallelSplitShadowMap.multiplyMatrixOutFloat32Array=function(left,right,out){
  9566. var i,a,b,ai0,ai1,ai2,ai3;
  9567. a=left.elements;
  9568. b=right.elements;
  9569. for (i=0;i < 4;i++){
  9570. ai0=a[i];
  9571. ai1=a[i+4];
  9572. ai2=a[i+8];
  9573. ai3=a[i+12];
  9574. out[i]=ai0 *b[0]+ai1 *b[1]+ai2 *b[2]+ai3 *b[3];
  9575. out[i+4]=ai0 *b[4]+ai1 *b[5]+ai2 *b[6]+ai3 *b[7];
  9576. out[i+8]=ai0 *b[8]+ai1 *b[9]+ai2 *b[10]+ai3 *b[11];
  9577. out[i+12]=ai0 *b[12]+ai1 *b[13]+ai2 *b[14]+ai3 *b[15];
  9578. }
  9579. }
  9580. ParallelSplitShadowMap.MAX_PSSM_COUNT=3;
  9581. __static(ParallelSplitShadowMap,
  9582. ['_tempVector30',function(){return this._tempVector30=new Vector3();}
  9583. ]);
  9584. return ParallelSplitShadowMap;
  9585. })()
  9586. /**
  9587. *@private
  9588. */
  9589. //class laya.d3.animation.KeyframeNode
  9590. var KeyframeNode=(function(){
  9591. function KeyframeNode(){
  9592. /**@private */
  9593. this._indexInList=0;
  9594. /**@private */
  9595. this.type=0;
  9596. /**@private */
  9597. this.fullPath=null;
  9598. /**@private */
  9599. this.propertyOwner=null;
  9600. /**@private */
  9601. this.data=null;
  9602. this._ownerPath=[];
  9603. this._propertys=[];
  9604. this._keyFrames=[];
  9605. }
  9606. __class(KeyframeNode,'laya.d3.animation.KeyframeNode');
  9607. var __proto=KeyframeNode.prototype;
  9608. /**
  9609. *@private
  9610. */
  9611. __proto._setOwnerPathCount=function(value){
  9612. this._ownerPath.length=value;
  9613. }
  9614. /**
  9615. *@private
  9616. */
  9617. __proto._setOwnerPathByIndex=function(index,value){
  9618. this._ownerPath[index]=value;
  9619. }
  9620. /**
  9621. *@private
  9622. */
  9623. __proto._joinOwnerPath=function(sep){
  9624. return this._ownerPath.join(sep);
  9625. }
  9626. /**
  9627. *@private
  9628. */
  9629. __proto._setPropertyCount=function(value){
  9630. this._propertys.length=value;
  9631. }
  9632. /**
  9633. *@private
  9634. */
  9635. __proto._setPropertyByIndex=function(index,value){
  9636. this._propertys[index]=value;
  9637. }
  9638. /**
  9639. *@private
  9640. */
  9641. __proto._joinProperty=function(sep){
  9642. return this._propertys.join(sep);
  9643. }
  9644. /**
  9645. *@private
  9646. */
  9647. __proto._setKeyframeCount=function(value){
  9648. this._keyFrames.length=value;
  9649. }
  9650. /**
  9651. *@private
  9652. */
  9653. __proto._setKeyframeByIndex=function(index,value){
  9654. this._keyFrames[index]=value;
  9655. }
  9656. /**
  9657. *通过索引获取精灵路径。
  9658. *@param index 索引。
  9659. */
  9660. __proto.getOwnerPathByIndex=function(index){
  9661. return this._ownerPath[index];
  9662. }
  9663. /**
  9664. *通过索引获取属性路径。
  9665. *@param index 索引。
  9666. */
  9667. __proto.getPropertyByIndex=function(index){
  9668. return this._propertys[index];
  9669. }
  9670. /**
  9671. *通过索引获取帧。
  9672. *@param index 索引。
  9673. */
  9674. __proto.getKeyframeByIndex=function(index){
  9675. return this._keyFrames[index];
  9676. }
  9677. /**
  9678. *获取精灵路径个数。
  9679. *@return 精灵路径个数。
  9680. */
  9681. __getset(0,__proto,'ownerPathCount',function(){
  9682. return this._ownerPath.length;
  9683. });
  9684. /**
  9685. *获取属性路径个数。
  9686. *@return 数量路径个数。
  9687. */
  9688. __getset(0,__proto,'propertyCount',function(){
  9689. return this._propertys.length;
  9690. });
  9691. /**
  9692. *获取帧个数。
  9693. *帧个数。
  9694. */
  9695. __getset(0,__proto,'keyFramesCount',function(){
  9696. return this._keyFrames.length;
  9697. });
  9698. return KeyframeNode;
  9699. })()
  9700. /**
  9701. *@private
  9702. */
  9703. //class laya.d3.MouseTouch
  9704. var MouseTouch=(function(){
  9705. function MouseTouch(){
  9706. /**@private */
  9707. this._pressedSprite=null;
  9708. /**@private */
  9709. this._pressedLoopCount=-1;
  9710. /**@private */
  9711. this.sprite=null;
  9712. /**@private */
  9713. this.mousePositionX=0;
  9714. /**@private */
  9715. this.mousePositionY=0;
  9716. }
  9717. __class(MouseTouch,'laya.d3.MouseTouch');
  9718. return MouseTouch;
  9719. })()
  9720. /**
  9721. *@private
  9722. */
  9723. //class laya.d3.core.render.BatchMark
  9724. var BatchMark=(function(){
  9725. function BatchMark(){
  9726. /**@private */
  9727. this.updateMark=-1;
  9728. /**@private */
  9729. this.indexInList=-1;
  9730. /**@private */
  9731. this.batched=false;
  9732. }
  9733. __class(BatchMark,'laya.d3.core.render.BatchMark');
  9734. return BatchMark;
  9735. })()
  9736. /**
  9737. *<code>Point2PointConstraint</code> 类用于创建物理组件的父类。
  9738. */
  9739. //class laya.d3.physics.constraints.Point2PointConstraint
  9740. var Point2PointConstraint=(function(){
  9741. function Point2PointConstraint(){
  9742. /**@private */
  9743. this._damping=NaN;
  9744. /**@private */
  9745. this._impulseClamp=NaN;
  9746. /**@private */
  9747. this._tau=NaN;
  9748. this._pivotInA=new Vector3();
  9749. this._pivotInB=new Vector3();
  9750. }
  9751. __class(Point2PointConstraint,'laya.d3.physics.constraints.Point2PointConstraint');
  9752. var __proto=Point2PointConstraint.prototype;
  9753. __getset(0,__proto,'pivotInA',function(){
  9754. return this._pivotInA;
  9755. },function(value){
  9756. this._pivotInA=value;
  9757. });
  9758. __getset(0,__proto,'pivotInB',function(){
  9759. return this._pivotInB;
  9760. },function(value){
  9761. this._pivotInB=value;
  9762. });
  9763. __getset(0,__proto,'damping',function(){
  9764. return this._damping;
  9765. },function(value){
  9766. this._damping=value;
  9767. });
  9768. __getset(0,__proto,'impulseClamp',function(){
  9769. return this._impulseClamp;
  9770. },function(value){
  9771. this._impulseClamp=value;
  9772. });
  9773. __getset(0,__proto,'tau',function(){
  9774. return this._tau;
  9775. },function(value){
  9776. this._tau=value;
  9777. });
  9778. return Point2PointConstraint;
  9779. })()
  9780. /**
  9781. *<code>PostProcessEffect</code> 类用于创建后期处理渲染效果。
  9782. */
  9783. //class laya.d3.core.render.PostProcessEffect
  9784. var PostProcessEffect=(function(){
  9785. /**
  9786. *创建一个 <code>PostProcessEffect</code> 实例。
  9787. */
  9788. function PostProcessEffect(){}
  9789. __class(PostProcessEffect,'laya.d3.core.render.PostProcessEffect');
  9790. var __proto=PostProcessEffect.prototype;
  9791. /**
  9792. *@private
  9793. */
  9794. __proto.render=function(context){}
  9795. return PostProcessEffect;
  9796. })()
  9797. /**
  9798. *@private
  9799. *<code>shaderVariable</code> 类用于保存shader变量上传相关信息。
  9800. */
  9801. //class laya.d3.shader.ShaderVariable
  9802. var ShaderVariable=(function(){
  9803. function ShaderVariable(){
  9804. /**@private */
  9805. //this.name=null;
  9806. /**@private */
  9807. //this.type=0;
  9808. /**@private */
  9809. //this.location=0;
  9810. /**@private */
  9811. //this.isArray=false;
  9812. /**@private */
  9813. //this.textureID=0;
  9814. /**@private */
  9815. //this.dataOffset=0;
  9816. /**@private */
  9817. //this.caller=null;
  9818. /**@private */
  9819. //this.fun=null;
  9820. /**@private */
  9821. //this.uploadedValue=null;
  9822. this.textureID=-1;
  9823. }
  9824. __class(ShaderVariable,'laya.d3.shader.ShaderVariable');
  9825. return ShaderVariable;
  9826. })()
  9827. /**
  9828. *<code>MaterialInfo</code> 类用于描述地形材质信息。
  9829. */
  9830. //class laya.d3.terrain.unit.MaterialInfo
  9831. var MaterialInfo=(function(){
  9832. function MaterialInfo(){
  9833. this.ambientColor=null;
  9834. this.diffuseColor=null;
  9835. this.specularColor=null;
  9836. }
  9837. __class(MaterialInfo,'laya.d3.terrain.unit.MaterialInfo');
  9838. return MaterialInfo;
  9839. })()
  9840. /**
  9841. *<code>FrameOverTime</code> 类用于创建时间帧。
  9842. */
  9843. //class laya.d3.core.particleShuriKen.module.FrameOverTime
  9844. var FrameOverTime=(function(){
  9845. function FrameOverTime(){
  9846. /**@private */
  9847. this._type=0;
  9848. /**@private */
  9849. this._constant=0;
  9850. /**@private */
  9851. this._overTime=null;
  9852. /**@private */
  9853. this._constantMin=0;
  9854. /**@private */
  9855. this._constantMax=0;
  9856. /**@private */
  9857. this._overTimeMin=null;
  9858. /**@private */
  9859. this._overTimeMax=null;
  9860. }
  9861. __class(FrameOverTime,'laya.d3.core.particleShuriKen.module.FrameOverTime');
  9862. var __proto=FrameOverTime.prototype;
  9863. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  9864. /**
  9865. *克隆。
  9866. *@param destObject 克隆源。
  9867. */
  9868. __proto.cloneTo=function(destObject){
  9869. var destFrameOverTime=destObject;
  9870. destFrameOverTime._type=this._type;
  9871. destFrameOverTime._constant=this._constant;
  9872. this._overTime.cloneTo(destFrameOverTime._overTime);
  9873. destFrameOverTime._constantMin=this._constantMin;
  9874. destFrameOverTime._constantMax=this._constantMax;
  9875. this._overTimeMin.cloneTo(destFrameOverTime._overTimeMin);
  9876. this._overTimeMax.cloneTo(destFrameOverTime._overTimeMax);
  9877. }
  9878. /**
  9879. *克隆。
  9880. *@return 克隆副本。
  9881. */
  9882. __proto.clone=function(){
  9883. var destFrameOverTime=/*__JS__ */new this.constructor();
  9884. this.cloneTo(destFrameOverTime);
  9885. return destFrameOverTime;
  9886. }
  9887. /**
  9888. *时间帧。
  9889. */
  9890. __getset(0,__proto,'frameOverTimeData',function(){
  9891. return this._overTime;
  9892. });
  9893. /**
  9894. *固定帧。
  9895. */
  9896. __getset(0,__proto,'constant',function(){
  9897. return this._constant;
  9898. });
  9899. /**
  9900. *生命周期旋转类型,0常量模式,1曲线模式,2随机双常量模式,3随机双曲线模式。
  9901. */
  9902. __getset(0,__proto,'type',function(){
  9903. return this._type;
  9904. });
  9905. /**
  9906. *最小时间帧。
  9907. */
  9908. __getset(0,__proto,'frameOverTimeDataMin',function(){
  9909. return this._overTimeMin;
  9910. });
  9911. /**
  9912. *最小固定帧。
  9913. */
  9914. __getset(0,__proto,'constantMin',function(){
  9915. return this._constantMin;
  9916. });
  9917. /**
  9918. *最大时间帧。
  9919. */
  9920. __getset(0,__proto,'frameOverTimeDataMax',function(){
  9921. return this._overTimeMax;
  9922. });
  9923. /**
  9924. *最大固定帧。
  9925. */
  9926. __getset(0,__proto,'constantMax',function(){
  9927. return this._constantMax;
  9928. });
  9929. FrameOverTime.createByConstant=function(constant){
  9930. var rotationOverLifetime=new FrameOverTime();
  9931. rotationOverLifetime._type=0;
  9932. rotationOverLifetime._constant=constant;
  9933. return rotationOverLifetime;
  9934. }
  9935. FrameOverTime.createByOverTime=function(overTime){
  9936. var rotationOverLifetime=new FrameOverTime();
  9937. rotationOverLifetime._type=1;
  9938. rotationOverLifetime._overTime=overTime;
  9939. return rotationOverLifetime;
  9940. }
  9941. FrameOverTime.createByRandomTwoConstant=function(constantMin,constantMax){
  9942. var rotationOverLifetime=new FrameOverTime();
  9943. rotationOverLifetime._type=2;
  9944. rotationOverLifetime._constantMin=constantMin;
  9945. rotationOverLifetime._constantMax=constantMax;
  9946. return rotationOverLifetime;
  9947. }
  9948. FrameOverTime.createByRandomTwoOverTime=function(gradientFrameMin,gradientFrameMax){
  9949. var rotationOverLifetime=new FrameOverTime();
  9950. rotationOverLifetime._type=3;
  9951. rotationOverLifetime._overTimeMin=gradientFrameMin;
  9952. rotationOverLifetime._overTimeMax=gradientFrameMax;
  9953. return rotationOverLifetime;
  9954. }
  9955. return FrameOverTime;
  9956. })()
  9957. /**
  9958. *...
  9959. *@author ...
  9960. */
  9961. //class laya.d3.core.TextureMode
  9962. var TextureMode=(function(){
  9963. function TextureMode(){}
  9964. __class(TextureMode,'laya.d3.core.TextureMode');
  9965. TextureMode.Stretch=0;
  9966. TextureMode.Tile=1;
  9967. return TextureMode;
  9968. })()
  9969. /**
  9970. *<code>Rand</code> 类用于通过128位整型种子创建随机数,算法来自:https://github.com/AndreasMadsen/xorshift。
  9971. */
  9972. //class laya.d3.math.RandX
  9973. var RandX=(function(){
  9974. function RandX(seed){
  9975. /**@private */
  9976. this._state0U=NaN;
  9977. /**@private */
  9978. this._state0L=NaN;
  9979. /**@private */
  9980. this._state1U=NaN;
  9981. /**@private */
  9982. this._state1L=NaN;
  9983. if (!((seed instanceof Array))|| seed.length!==4)
  9984. throw new Error('Rand:Seed must be an array with 4 numbers');
  9985. this._state0U=seed[0] | 0;
  9986. this._state0L=seed[1] | 0;
  9987. this._state1U=seed[2] | 0;
  9988. this._state1L=seed[3] | 0;
  9989. }
  9990. __class(RandX,'laya.d3.math.RandX');
  9991. var __proto=RandX.prototype;
  9992. /**
  9993. *通过2x32位的数组,返回64位的随机数。
  9994. *@return 64位的随机数。
  9995. */
  9996. __proto.randomint=function(){
  9997. var s1U=this._state0U,s1L=this._state0L;
  9998. var s0U=this._state1U,s0L=this._state1L;
  9999. var sumL=(s0L >>> 0)+(s1L >>> 0);
  10000. var resU=(s0U+s1U+(sumL / 2 >>> 31))>>> 0;
  10001. var resL=sumL >>> 0;
  10002. this._state0U=s0U;
  10003. this._state0L=s0L;
  10004. var t1U=0,t1L=0;
  10005. var t2U=0,t2L=0;
  10006. var a1=23;
  10007. var m1=0xFFFFFFFF << (32-a1);
  10008. t1U=(s1U << a1)| ((s1L & m1)>>> (32-a1));
  10009. t1L=s1L << a1;
  10010. s1U=s1U ^ t1U;
  10011. s1L=s1L ^ t1L;
  10012. t1U=s1U ^ s0U;
  10013. t1L=s1L ^ s0L;
  10014. var a2=18;
  10015. var m2=0xFFFFFFFF >>> (32-a2);
  10016. t2U=s1U >>> a2;
  10017. t2L=(s1L >>> a2)| ((s1U & m2)<< (32-a2));
  10018. t1U=t1U ^ t2U;
  10019. t1L=t1L ^ t2L;
  10020. var a3=5;
  10021. var m3=0xFFFFFFFF >>> (32-a3);
  10022. t2U=s0U >>> a3;
  10023. t2L=(s0L >>> a3)| ((s0U & m3)<< (32-a3));
  10024. t1U=t1U ^ t2U;
  10025. t1L=t1L ^ t2L;
  10026. this._state1U=t1U;
  10027. this._state1L=t1L;
  10028. return [resU,resL];
  10029. }
  10030. /**
  10031. *返回[0,1)之间的随机数。
  10032. *@return
  10033. */
  10034. __proto.random=function(){
  10035. var t2=this.randomint();
  10036. var t2U=t2[0];
  10037. var t2L=t2[1];
  10038. var eU=0x3FF << (52-32);
  10039. var eL=0;
  10040. var a1=12;
  10041. var m1=0xFFFFFFFF >>> (32-a1);
  10042. var sU=t2U >>> a1;
  10043. var sL=(t2L >>> a1)| ((t2U & m1)<< (32-a1));
  10044. var xU=eU | sU;
  10045. var xL=eL | sL;
  10046. RandX._CONVERTION_BUFFER.setUint32(0,xU,false);
  10047. RandX._CONVERTION_BUFFER.setUint32(4,xL,false);
  10048. var d=/*__JS__ */Rand._CONVERTION_BUFFER.getFloat64(0,false);
  10049. return d-1;
  10050. }
  10051. __static(RandX,
  10052. ['_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]);}
  10053. ]);
  10054. return RandX;
  10055. })()
  10056. /**
  10057. *<code>Config3D</code> 类用于创建3D初始化配置。
  10058. */
  10059. //class Config3D
  10060. var Config3D=(function(){
  10061. function Config3D(){
  10062. /**@private */
  10063. this._defaultPhysicsMemory=128;
  10064. /**@private */
  10065. this._editerEnvironment=false;
  10066. /**是否开启抗锯齿。*/
  10067. this.isAntialias=true;
  10068. /**设置画布是否透明。*/
  10069. this.isAlpha=false;
  10070. /**设置画布是否预乘。*/
  10071. this.premultipliedAlpha=true;
  10072. /**设置画布的是否开启模板缓冲。*/
  10073. this.isStencil=true;
  10074. /**是否开启八叉树裁剪。*/
  10075. this.octreeCulling=false;
  10076. /**八叉树初始化尺寸。*/
  10077. this.octreeInitialSize=64.0;
  10078. /**八叉树最小尺寸。*/
  10079. this.octreeMinNodeSize=2.0;
  10080. /**八叉树松散值。*/
  10081. this.octreeLooseness=1.25;
  10082. /**
  10083. *是否开启视锥裁剪调试。
  10084. *如果开启八叉树裁剪,使用红色绘制高层次八叉树节点包围盒,使用蓝色绘制低层次八叉节点包围盒,精灵包围盒和八叉树节点包围盒颜色一致,但Alpha为半透明。如果视锥完全包含八叉树节点,八叉树节点包围盒和精灵包围盒变为蓝色,同样精灵包围盒的Alpha为半透明。
  10085. *如果不开启八叉树裁剪,使用绿色像素线绘制精灵包围盒。
  10086. */
  10087. this.debugFrustumCulling=false;
  10088. this.octreeInitialCenter=new Vector3(0,0,0);
  10089. }
  10090. __class(Config3D,'Config3D');
  10091. var __proto=Config3D.prototype;
  10092. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  10093. /**
  10094. *克隆。
  10095. *@param destObject 克隆源。
  10096. */
  10097. __proto.cloneTo=function(dest){
  10098. var destConfig3D=dest;
  10099. destConfig3D._defaultPhysicsMemory=this._defaultPhysicsMemory;
  10100. destConfig3D._editerEnvironment=this._editerEnvironment;
  10101. destConfig3D.isAntialias=this.isAntialias;
  10102. destConfig3D.isAlpha=this.isAlpha;
  10103. destConfig3D.premultipliedAlpha=this.premultipliedAlpha;
  10104. destConfig3D.isStencil=this.isStencil;
  10105. destConfig3D.octreeCulling=this.octreeCulling;
  10106. this.octreeInitialCenter.cloneTo(destConfig3D.octreeInitialCenter);
  10107. destConfig3D.octreeMinNodeSize=this.octreeMinNodeSize;
  10108. destConfig3D.octreeLooseness=this.octreeLooseness;
  10109. destConfig3D.debugFrustumCulling=this.debugFrustumCulling;
  10110. }
  10111. /**
  10112. *克隆。
  10113. *@return 克隆副本。
  10114. */
  10115. __proto.clone=function(){
  10116. var dest=new Config3D();
  10117. this.cloneTo(dest);
  10118. return dest;
  10119. }
  10120. /**
  10121. *设置默认物理功能初始化内存,单位为M。
  10122. *@param value 默认物理功能初始化内存。
  10123. */
  10124. /**
  10125. *获取默认物理功能初始化内存,单位为M。
  10126. *@return 默认物理功能初始化内存。
  10127. */
  10128. __getset(0,__proto,'defaultPhysicsMemory',function(){
  10129. return this._defaultPhysicsMemory;
  10130. },function(value){
  10131. if (value < 16)
  10132. throw "defaultPhysicsMemory must large than 16M";
  10133. this._defaultPhysicsMemory=value;
  10134. });
  10135. __static(Config3D,
  10136. ['_default',function(){return this._default=new Config3D();}
  10137. ]);
  10138. return Config3D;
  10139. })()
  10140. /**
  10141. *<code>RenderContext3D</code> 类用于实现渲染状态。
  10142. */
  10143. //class laya.d3.core.render.RenderContext3D
  10144. var RenderContext3D=(function(){
  10145. function RenderContext3D(){
  10146. /**@private */
  10147. //this._batchIndexStart=0;
  10148. /**@private */
  10149. //this._batchIndexEnd=0;
  10150. /**@private */
  10151. //this.viewMatrix=null;
  10152. /**@private */
  10153. //this.projectionMatrix=null;
  10154. /**@private */
  10155. //this.projectionViewMatrix=null;
  10156. /**@private */
  10157. //this.viewport=null;
  10158. /**@private */
  10159. //this.scene=null;
  10160. /**@private */
  10161. //this.camera=null;
  10162. /**@private */
  10163. //this.renderElement=null;
  10164. /**@private */
  10165. //this.shader=null;
  10166. }
  10167. __class(RenderContext3D,'laya.d3.core.render.RenderContext3D');
  10168. RenderContext3D.clientWidth=0;
  10169. RenderContext3D.clientHeight=0;
  10170. __static(RenderContext3D,
  10171. ['_instance',function(){return this._instance=new RenderContext3D();}
  10172. ]);
  10173. return RenderContext3D;
  10174. })()
  10175. /**
  10176. *<code>Ray</code> 类用于创建射线。
  10177. */
  10178. //class laya.d3.math.Ray
  10179. var Ray=(function(){
  10180. function Ray(origin,direction){
  10181. /**原点*/
  10182. this.origin=null;
  10183. /**方向*/
  10184. this.direction=null;
  10185. this.origin=origin;
  10186. this.direction=direction;
  10187. }
  10188. __class(Ray,'laya.d3.math.Ray');
  10189. return Ray;
  10190. })()
  10191. /**
  10192. *<code>AnimationEvent</code> 类用于实现动画事件。
  10193. */
  10194. //class laya.d3.animation.AnimationEvent
  10195. var AnimationEvent=(function(){
  10196. function AnimationEvent(){
  10197. /**事件触发时间。*/
  10198. this.time=NaN;
  10199. /**事件触发名称。*/
  10200. this.eventName=null;
  10201. /**事件触发参数。*/
  10202. this.params=null;
  10203. }
  10204. __class(AnimationEvent,'laya.d3.animation.AnimationEvent');
  10205. return AnimationEvent;
  10206. })()
  10207. /**
  10208. *<code>PostProcess</code> 类用于创建后期处理组件。
  10209. */
  10210. //class laya.d3.component.PostProcess
  10211. var PostProcess=(function(){
  10212. function PostProcess(){
  10213. /**@private */
  10214. this._context=null;
  10215. this._compositeShader=Shader3D.find("PostProcessComposite");
  10216. this._compositeShaderData=new ShaderData();
  10217. this._compositeDefineData=new DefineDatas();
  10218. this._effects=[];
  10219. this._context=new PostProcessRenderContext();
  10220. this._context.compositeShaderData=this._compositeShaderData;
  10221. this._context.compositeDefineData=this._compositeDefineData;
  10222. }
  10223. __class(PostProcess,'laya.d3.component.PostProcess');
  10224. var __proto=PostProcess.prototype;
  10225. /**
  10226. *@private
  10227. */
  10228. __proto._init=function(camera,command){
  10229. this._context.camera=camera;
  10230. this._context.command=command;
  10231. }
  10232. /**
  10233. *@private
  10234. */
  10235. __proto._render=function(){
  10236. var screenTexture=RenderTexture.getTemporary(RenderContext3D.clientWidth,RenderContext3D.clientHeight,/*laya.resource.BaseTexture.FORMAT_R8G8B8*/0,/*laya.resource.BaseTexture.FORMAT_DEPTHSTENCIL_NONE*/3);
  10237. var cameraTarget=this._context.camera.getRenderTexture();
  10238. this._context.command.clear();
  10239. this._context.source=screenTexture;
  10240. this._context.destination=cameraTarget;
  10241. for (var i=0,n=this._effects.length;i < n;i++)
  10242. this._effects[i].render(this._context);
  10243. RenderTexture.setReleaseTemporary(screenTexture);
  10244. var tempRenderTextures=this._context.tempRenderTextures;
  10245. for (i=0,n=tempRenderTextures.length;i < n;i++)
  10246. RenderTexture.setReleaseTemporary(tempRenderTextures[i]);
  10247. }
  10248. /**
  10249. *添加后期处理效果。
  10250. */
  10251. __proto.addEffect=function(effect){
  10252. this._effects.push(effect);
  10253. }
  10254. /**
  10255. *移除后期处理效果。
  10256. */
  10257. __proto.removeEffect=function(effect){
  10258. var index=this._effects.indexOf(effect);
  10259. if (index!==-1)
  10260. this._effects.splice(index,1);
  10261. }
  10262. PostProcess.__init__=function(){
  10263. PostProcess.SHADERDEFINE_BLOOM_LOW=PostProcess.shaderDefines.registerDefine("BLOOM_LOW");
  10264. PostProcess.SHADERDEFINE_BLOOM=PostProcess.shaderDefines.registerDefine("BLOOM");
  10265. }
  10266. PostProcess.SHADERDEFINE_BLOOM_LOW=0;
  10267. PostProcess.SHADERDEFINE_BLOOM=0;
  10268. __static(PostProcess,
  10269. ['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();}
  10270. ]);
  10271. return PostProcess;
  10272. })()
  10273. /**
  10274. *<code>GradientColor</code> 类用于创建渐变颜色。
  10275. */
  10276. //class laya.d3.core.particleShuriKen.module.GradientColor
  10277. var GradientColor=(function(){
  10278. function GradientColor(){
  10279. /**@private */
  10280. this._type=0;
  10281. /**@private */
  10282. this._constant=null;
  10283. /**@private */
  10284. this._constantMin=null;
  10285. /**@private */
  10286. this._constantMax=null;
  10287. /**@private */
  10288. this._gradient=null;
  10289. /**@private */
  10290. this._gradientMin=null;
  10291. /**@private */
  10292. this._gradientMax=null;
  10293. }
  10294. __class(GradientColor,'laya.d3.core.particleShuriKen.module.GradientColor');
  10295. var __proto=GradientColor.prototype;
  10296. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  10297. /**
  10298. *克隆。
  10299. *@param destObject 克隆源。
  10300. */
  10301. __proto.cloneTo=function(destObject){
  10302. var destGradientColor=destObject;
  10303. destGradientColor._type=this._type;
  10304. this._constant.cloneTo(destGradientColor._constant);
  10305. this._constantMin.cloneTo(destGradientColor._constantMin);
  10306. this._constantMax.cloneTo(destGradientColor._constantMax);
  10307. this._gradient.cloneTo(destGradientColor._gradient);
  10308. this._gradientMin.cloneTo(destGradientColor._gradientMin);
  10309. this._gradientMax.cloneTo(destGradientColor._gradientMax);
  10310. }
  10311. /**
  10312. *克隆。
  10313. *@return 克隆副本。
  10314. */
  10315. __proto.clone=function(){
  10316. var destGradientColor=/*__JS__ */new this.constructor();
  10317. this.cloneTo(destGradientColor);
  10318. return destGradientColor;
  10319. }
  10320. /**
  10321. *渐变颜色。
  10322. */
  10323. __getset(0,__proto,'gradient',function(){
  10324. return this._gradient;
  10325. });
  10326. /**
  10327. *固定颜色。
  10328. */
  10329. __getset(0,__proto,'constant',function(){
  10330. return this._constant;
  10331. });
  10332. /**
  10333. *生命周期颜色类型,0为固定颜色模式,1渐变模式,2为随机双固定颜色模式,3随机双渐变模式。
  10334. */
  10335. __getset(0,__proto,'type',function(){
  10336. return this._type;
  10337. });
  10338. /**
  10339. *最小渐变颜色。
  10340. */
  10341. __getset(0,__proto,'gradientMin',function(){
  10342. return this._gradientMin;
  10343. });
  10344. /**
  10345. *最小固定颜色。
  10346. */
  10347. __getset(0,__proto,'constantMin',function(){
  10348. return this._constantMin;
  10349. });
  10350. /**
  10351. *最大渐变颜色。
  10352. */
  10353. __getset(0,__proto,'gradientMax',function(){
  10354. return this._gradientMax;
  10355. });
  10356. /**
  10357. *最大固定颜色。
  10358. */
  10359. __getset(0,__proto,'constantMax',function(){
  10360. return this._constantMax;
  10361. });
  10362. GradientColor.createByConstant=function(constant){
  10363. var gradientColor=new GradientColor();
  10364. gradientColor._type=0;
  10365. gradientColor._constant=constant;
  10366. return gradientColor;
  10367. }
  10368. GradientColor.createByGradient=function(gradient){
  10369. var gradientColor=new GradientColor();
  10370. gradientColor._type=1;
  10371. gradientColor._gradient=gradient;
  10372. return gradientColor;
  10373. }
  10374. GradientColor.createByRandomTwoConstant=function(minConstant,maxConstant){
  10375. var gradientColor=new GradientColor();
  10376. gradientColor._type=2;
  10377. gradientColor._constantMin=minConstant;
  10378. gradientColor._constantMax=maxConstant;
  10379. return gradientColor;
  10380. }
  10381. GradientColor.createByRandomTwoGradient=function(minGradient,maxGradient){
  10382. var gradientColor=new GradientColor();
  10383. gradientColor._type=3;
  10384. gradientColor._gradientMin=minGradient;
  10385. gradientColor._gradientMax=maxGradient;
  10386. return gradientColor;
  10387. }
  10388. return GradientColor;
  10389. })()
  10390. /**
  10391. *...
  10392. *@author ...
  10393. */
  10394. //class laya.d3.core.GradientMode
  10395. var GradientMode=(function(){
  10396. function GradientMode(){}
  10397. __class(GradientMode,'laya.d3.core.GradientMode');
  10398. GradientMode.Blend=0;
  10399. GradientMode.Fixed=1;
  10400. return GradientMode;
  10401. })()
  10402. /**
  10403. *<code>HeightMap</code> 类用于实现高度图数据。
  10404. */
  10405. //class laya.d3.core.HeightMap
  10406. var HeightMap=(function(){
  10407. function HeightMap(width,height,minHeight,maxHeight){
  10408. /**@private */
  10409. this._datas=null;
  10410. /**@private */
  10411. this._w=0;
  10412. /**@private */
  10413. this._h=0;
  10414. /**@private */
  10415. this._minHeight=NaN;
  10416. /**@private */
  10417. this._maxHeight=NaN;
  10418. this._datas=[];
  10419. this._w=width;
  10420. this._h=height;
  10421. this._minHeight=minHeight;
  10422. this._maxHeight=maxHeight;
  10423. }
  10424. __class(HeightMap,'laya.d3.core.HeightMap');
  10425. var __proto=HeightMap.prototype;
  10426. /**@private */
  10427. __proto._inBounds=function(row,col){
  10428. return row >=0 && row < this._h && col >=0 && col < this._w;
  10429. }
  10430. /**
  10431. *获取高度。
  10432. *@param row 列数。
  10433. *@param col 行数。
  10434. *@return 高度。
  10435. */
  10436. __proto.getHeight=function(row,col){
  10437. if (this._inBounds(row,col))
  10438. return this._datas[row][col];
  10439. else
  10440. return NaN;
  10441. }
  10442. /**
  10443. *获取宽度。
  10444. *@return value 宽度。
  10445. */
  10446. __getset(0,__proto,'width',function(){
  10447. return this._w;
  10448. });
  10449. /**
  10450. *获取高度。
  10451. *@return value 高度。
  10452. */
  10453. __getset(0,__proto,'height',function(){
  10454. return this._h;
  10455. });
  10456. /**
  10457. *最大高度。
  10458. *@return value 最大高度。
  10459. */
  10460. __getset(0,__proto,'maxHeight',function(){
  10461. return this._maxHeight;
  10462. });
  10463. /**
  10464. *最大高度。
  10465. *@return value 最大高度。
  10466. */
  10467. __getset(0,__proto,'minHeight',function(){
  10468. return this._minHeight;
  10469. });
  10470. HeightMap.creatFromMesh=function(mesh,width,height,outCellSize){
  10471. var vertices=[];
  10472. var indexs=[];
  10473. var submesheCount=mesh.subMeshCount;
  10474. for (var i=0;i < submesheCount;i++){
  10475. var subMesh=mesh._getSubMesh(i);
  10476. var vertexBuffer=subMesh._vertexBuffer;
  10477. var verts=vertexBuffer.getData();
  10478. var subMeshVertices=[];
  10479. for (var j=0;j < verts.length;j+=vertexBuffer.vertexDeclaration.vertexStride / 4){
  10480. var position=new Vector3(verts[j+0],verts[j+1],verts[j+2]);
  10481. subMeshVertices.push(position);
  10482. }
  10483. vertices.push(subMeshVertices);
  10484. var ib=subMesh._indexBuffer;
  10485. indexs.push(ib.getData());
  10486. };
  10487. var bounds=mesh.bounds;
  10488. var minX=bounds.getMin().x;
  10489. var minZ=bounds.getMin().z;
  10490. var maxX=bounds.getMax().x;
  10491. var maxZ=bounds.getMax().z;
  10492. var minY=bounds.getMin().y;
  10493. var maxY=bounds.getMax().y;
  10494. var widthSize=maxX-minX;
  10495. var heightSize=maxZ-minZ;
  10496. var cellWidth=outCellSize.x=widthSize / (width-1);
  10497. var cellHeight=outCellSize.y=heightSize / (height-1);
  10498. var heightMap=new HeightMap(width,height,minY,maxY);
  10499. var ray=HeightMap._tempRay;
  10500. var rayDir=ray.direction;
  10501. rayDir.x=0;
  10502. rayDir.y=-1;
  10503. rayDir.z=0;
  10504. var heightOffset=0.1;
  10505. var rayY=maxY+heightOffset;
  10506. ray.origin.y=rayY;
  10507. for (var h=0;h < height;h++){
  10508. var posZ=minZ+h *cellHeight;
  10509. heightMap._datas[h]=[];
  10510. for (var w=0;w < width;w++){
  10511. var posX=minX+w *cellWidth;
  10512. var rayOri=ray.origin;
  10513. rayOri.x=posX;
  10514. rayOri.z=posZ;
  10515. var closestIntersection=HeightMap._getPosition(ray,vertices,indexs);
  10516. heightMap._datas[h][w]=(closestIntersection===Number.MAX_VALUE)? NaN :rayY-closestIntersection;
  10517. }
  10518. }
  10519. return heightMap;
  10520. }
  10521. HeightMap.createFromImage=function(texture,minHeight,maxHeight){
  10522. var textureWidth=texture.width;
  10523. var textureHeight=texture.height;
  10524. var heightMap=new HeightMap(textureWidth,textureHeight,minHeight,maxHeight);
  10525. var compressionRatio=(maxHeight-minHeight)/ 254;
  10526. var pixelsInfo=texture.getPixels();
  10527. var index=0;
  10528. for (var h=0;h <textureHeight;h++){
  10529. var colDatas=heightMap._datas[h]=[];
  10530. for (var w=0;w < textureWidth;w++){
  10531. var r=pixelsInfo[index++];
  10532. var g=pixelsInfo[index++];
  10533. var b=pixelsInfo[index++];
  10534. var a=pixelsInfo[index++];
  10535. if (r==255 && g==255 && b==255 && a==255)
  10536. colDatas[w]=NaN;
  10537. else {
  10538. colDatas[w]=(r+g+b)/ 3 *compressionRatio+minHeight;
  10539. }
  10540. }
  10541. }
  10542. return heightMap;
  10543. }
  10544. HeightMap._getPosition=function(ray,vertices,indexs){
  10545. var closestIntersection=Number.MAX_VALUE;
  10546. for (var i=0;i < vertices.length;i++){
  10547. var subMeshVertices=vertices[i];
  10548. var subMeshIndexes=indexs[i];
  10549. for (var j=0;j < subMeshIndexes.length;j+=3){
  10550. var vertex1=subMeshVertices[subMeshIndexes[j+0]];
  10551. var vertex2=subMeshVertices[subMeshIndexes[j+1]];
  10552. var vertex3=subMeshVertices[subMeshIndexes[j+2]];
  10553. var intersection=Picker.rayIntersectsTriangle(ray,vertex1,vertex2,vertex3);
  10554. if (!isNaN(intersection)&& intersection < closestIntersection){
  10555. closestIntersection=intersection;
  10556. }
  10557. }
  10558. }
  10559. return closestIntersection;
  10560. }
  10561. __static(HeightMap,
  10562. ['_tempRay',function(){return this._tempRay=new Ray(new Vector3(),new Vector3());}
  10563. ]);
  10564. return HeightMap;
  10565. })()
  10566. /**
  10567. *<code>SkyMesh</code> 类用于实现天空网格。
  10568. */
  10569. //class laya.d3.resource.models.SkyMesh
  10570. var SkyMesh=(function(){
  10571. function SkyMesh(){
  10572. /**@private */
  10573. this._vertexBuffer=null;
  10574. /**@private */
  10575. this._indexBuffer=null;
  10576. /**@private */
  10577. this._bufferState=null;
  10578. }
  10579. __class(SkyMesh,'laya.d3.resource.models.SkyMesh');
  10580. var __proto=SkyMesh.prototype;
  10581. /**
  10582. *@private
  10583. */
  10584. __proto._render=function(state){}
  10585. return SkyMesh;
  10586. })()
  10587. /**
  10588. *<code>Input3D</code> 类用于实现3D输入。
  10589. */
  10590. //class laya.d3.Input3D
  10591. var Input3D=(function(){
  10592. function Input3D(){
  10593. /**@private */
  10594. this._scene=null;
  10595. /**@private */
  10596. this._eventList=[];
  10597. /**@private */
  10598. this._multiTouchEnabled=true;
  10599. this._mouseTouch=new MouseTouch();
  10600. this._touchPool=[];
  10601. this._touches=new SimpleSingletonList();
  10602. }
  10603. __class(Input3D,'laya.d3.Input3D');
  10604. var __proto=Input3D.prototype;
  10605. /**
  10606. *@private
  10607. */
  10608. __proto.__init__=function(canvas,scene){
  10609. this._scene=scene;
  10610. var list=this._eventList;
  10611. canvas.oncontextmenu=function (e){
  10612. return false;
  10613. }
  10614. canvas.addEventListener('mousedown',function(e){
  10615. e.preventDefault();
  10616. list.push(e);
  10617. });
  10618. canvas.addEventListener('mouseup',function(e){
  10619. e.preventDefault();
  10620. list.push(e);
  10621. },true);
  10622. canvas.addEventListener('mousemove',function(e){
  10623. e.preventDefault();
  10624. list.push(e);
  10625. },true);
  10626. canvas.addEventListener("touchstart",function(e){
  10627. e.preventDefault();
  10628. list.push(e);
  10629. });
  10630. canvas.addEventListener("touchend",function(e){
  10631. e.preventDefault();
  10632. list.push(e);
  10633. },true);
  10634. canvas.addEventListener("touchmove",function(e){
  10635. e.preventDefault();
  10636. list.push(e);
  10637. },true);
  10638. canvas.addEventListener("touchcancel",function(e){
  10639. list.push(e);
  10640. },true);
  10641. }
  10642. /**
  10643. *获取触摸点个数。
  10644. *@return 触摸点个数。
  10645. */
  10646. __proto.touchCount=function(){
  10647. return this._touches.length;
  10648. }
  10649. /**
  10650. *@private
  10651. */
  10652. __proto._getTouch=function(touchID){
  10653. var touch=this._touchPool[touchID];
  10654. if (!touch){
  10655. touch=new Touch();
  10656. this._touchPool[touchID]=touch;
  10657. touch._identifier=touchID;
  10658. }
  10659. return touch;
  10660. }
  10661. /**
  10662. *@private
  10663. */
  10664. __proto._mouseTouchDown=function(){
  10665. var touch=this._mouseTouch;
  10666. var sprite=touch.sprite;
  10667. touch._pressedSprite=sprite;
  10668. touch._pressedLoopCount=Stat.loopCount;
  10669. if (sprite){
  10670. var scripts=sprite._scripts;
  10671. if (scripts){
  10672. for (var i=0,n=scripts.length;i < n;i++)
  10673. scripts[i].onMouseDown();
  10674. }
  10675. }
  10676. }
  10677. /**
  10678. *@private
  10679. */
  10680. __proto._mouseTouchUp=function(){
  10681. var i=0,n=0;
  10682. var touch=this._mouseTouch;
  10683. var lastPressedSprite=touch._pressedSprite;
  10684. touch._pressedSprite=null;
  10685. touch._pressedLoopCount=-1;
  10686. var sprite=touch.sprite;
  10687. if (sprite){
  10688. if (sprite===lastPressedSprite){
  10689. var scripts=sprite._scripts;
  10690. if (scripts){
  10691. for (i=0,n=scripts.length;i < n;i++)
  10692. scripts[i].onMouseClick();
  10693. }
  10694. }
  10695. }
  10696. if (lastPressedSprite){
  10697. var lastScripts=lastPressedSprite._scripts;
  10698. if (lastScripts){
  10699. for (i=0,n=lastScripts.length;i < n;i++)
  10700. lastScripts[i].onMouseUp();
  10701. }
  10702. }
  10703. }
  10704. /**
  10705. *@private
  10706. */
  10707. __proto._mouseTouchRayCast=function(cameras){
  10708. var touchHitResult=Input3D._tempHitResult0;
  10709. var touchPos=Input3D._tempVector20;
  10710. var touchRay=Input3D._tempRay0;
  10711. touchHitResult.succeeded=false;
  10712. var x=this._mouseTouch.mousePositionX;
  10713. var y=this._mouseTouch.mousePositionY;
  10714. touchPos.x=x;
  10715. touchPos.y=y;
  10716. for (var i=cameras.length-1;i >=0;i--){
  10717. var camera=cameras [i];
  10718. var viewport=camera.viewport;
  10719. if (touchPos.x >=viewport.x && touchPos.y >=viewport.y && touchPos.x <=viewport.width && touchPos.y <=viewport.height){
  10720. camera.viewportPointToRay(touchPos,touchRay);
  10721. var sucess=this._scene._physicsSimulation.rayCast(touchRay,touchHitResult);
  10722. if (sucess || (camera.clearFlag===/*laya.d3.core.BaseCamera.CLEARFLAG_SOLIDCOLOR*/0 || camera.clearFlag===/*laya.d3.core.BaseCamera.CLEARFLAG_SKY*/1))
  10723. break ;
  10724. }
  10725. };
  10726. var touch=this._mouseTouch;
  10727. var lastSprite=touch.sprite;
  10728. if (touchHitResult.succeeded){
  10729. var touchSprite=touchHitResult.collider.owner;
  10730. touch.sprite=touchSprite;
  10731. var scripts=touchSprite._scripts;
  10732. if (lastSprite!==touchSprite){
  10733. if (scripts){
  10734. for (var j=0,m=scripts.length;j < m;j++)
  10735. scripts[j].onMouseEnter();
  10736. }
  10737. }
  10738. }else {
  10739. touch.sprite=null;
  10740. }
  10741. if (lastSprite && (lastSprite!==touchSprite)){
  10742. var outScripts=lastSprite._scripts;
  10743. if (outScripts){
  10744. for (j=0,m=outScripts.length;j < m;j++)
  10745. outScripts[j].onMouseOut();
  10746. }
  10747. }
  10748. }
  10749. /**
  10750. *@private
  10751. *@param flag 0:add、1:remove、2:change
  10752. */
  10753. __proto._changeTouches=function(changedTouches,flag){
  10754. var offsetX=0,offsetY=0;
  10755. var lastCount=this._touches.length;
  10756. for (var j=0,m=changedTouches.length;j < m;j++){
  10757. var nativeTouch=changedTouches[j];
  10758. var identifier=nativeTouch.identifier;
  10759. if (!this._multiTouchEnabled && identifier!==0)
  10760. continue ;
  10761. var touch=this._getTouch(identifier);
  10762. var pos=touch._position;
  10763. var mousePoint=Input3D._tempPoint;
  10764. mousePoint.setTo(nativeTouch.pageX,nativeTouch.pageY);
  10765. Laya.stage._canvasTransform.invertTransformPoint(mousePoint);
  10766. var posX=mousePoint.x;
  10767. var posY=mousePoint.y;
  10768. switch (flag){
  10769. case 0:
  10770. this._touches.add(touch);
  10771. offsetX+=posX;
  10772. offsetY+=posY;
  10773. break ;
  10774. case 1:
  10775. this._touches.remove(touch);
  10776. offsetX-=posX;
  10777. offsetY-=posY;
  10778. break ;
  10779. case 2:
  10780. offsetX=posX-pos.x;
  10781. offsetY=posY-pos.y;
  10782. break ;
  10783. }
  10784. pos.x=posX;
  10785. pos.y=posY;
  10786. };
  10787. var touchCount=this._touches.length;
  10788. if (touchCount===0){
  10789. this._mouseTouch.mousePositionX=0;
  10790. this._mouseTouch.mousePositionY=0;
  10791. }else {
  10792. this._mouseTouch.mousePositionX=(this._mouseTouch.mousePositionX *lastCount+offsetX)/ touchCount;
  10793. this._mouseTouch.mousePositionY=(this._mouseTouch.mousePositionY *lastCount+offsetY)/ touchCount;
  10794. }
  10795. }
  10796. /**
  10797. *@private
  10798. */
  10799. __proto._update=function(){
  10800. var i=0,n=0,j=0,m=0;
  10801. n=this._eventList.length;
  10802. var cameras=this._scene._cameraPool;
  10803. if (n > 0){
  10804. for (i=0;i < n;i++){
  10805. var e=this._eventList[i];
  10806. switch (e.type){
  10807. case "mousedown":
  10808. this._mouseTouchDown();
  10809. break ;
  10810. case "mouseup":
  10811. this._mouseTouchUp();
  10812. break ;
  10813. case "mousemove":;
  10814. var mousePoint=Input3D._tempPoint;
  10815. mousePoint.setTo(e.pageX,e.pageY);
  10816. Laya.stage._canvasTransform.invertTransformPoint(mousePoint);
  10817. this._mouseTouch.mousePositionX=mousePoint.x;
  10818. this._mouseTouch.mousePositionY=mousePoint.y;
  10819. this._mouseTouchRayCast(cameras);
  10820. break ;
  10821. case "touchstart":;
  10822. var lastLength=this._touches.length;
  10823. this._changeTouches(e.changedTouches,0);
  10824. this._mouseTouchRayCast(cameras);
  10825. (lastLength===0)&& (this._mouseTouchDown());
  10826. break ;
  10827. case "touchend":
  10828. case "touchcancel":
  10829. this._changeTouches(e.changedTouches,1);
  10830. (this._touches.length===0)&& (this._mouseTouchUp());
  10831. break ;
  10832. case "touchmove":
  10833. this._changeTouches(e.changedTouches,2);
  10834. this._mouseTouchRayCast(cameras);
  10835. break ;
  10836. default :
  10837. throw "Input3D:unkonwn event type.";
  10838. }
  10839. }
  10840. this._eventList.length=0;
  10841. };
  10842. var mouseTouch=this._mouseTouch;
  10843. var pressedSprite=mouseTouch._pressedSprite;
  10844. if (pressedSprite && (Stat.loopCount > mouseTouch._pressedLoopCount)){
  10845. var pressedScripts=pressedSprite._scripts;
  10846. if (pressedScripts){
  10847. for (j=0,m=pressedScripts.length;j < m;j++)
  10848. pressedScripts[j].onMouseDrag();
  10849. }
  10850. };
  10851. var touchSprite=mouseTouch.sprite;
  10852. if (touchSprite){
  10853. var scripts=touchSprite._scripts;
  10854. if (scripts){
  10855. for (j=0,m=scripts.length;j < m;j++)
  10856. scripts[j].onMouseOver();
  10857. }
  10858. }
  10859. }
  10860. /**
  10861. *获取触摸点。
  10862. *@param index 索引。
  10863. *@return 触摸点。
  10864. */
  10865. __proto.getTouch=function(index){
  10866. if (index < this._touches.length){
  10867. return this._touches.elements [index];
  10868. }else {
  10869. return null;
  10870. }
  10871. }
  10872. /**
  10873. *设置是否可以使用多点触摸。
  10874. *@param 是否可以使用多点触摸。
  10875. */
  10876. /**
  10877. *获取是否可以使用多点触摸。
  10878. *@return 是否可以使用多点触摸。
  10879. */
  10880. __getset(0,__proto,'multiTouchEnabled',function(){
  10881. return this._multiTouchEnabled;
  10882. },function(value){
  10883. this._multiTouchEnabled=value;
  10884. });
  10885. __static(Input3D,
  10886. ['_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();}
  10887. ]);
  10888. return Input3D;
  10889. })()
  10890. /**
  10891. *<code>Viewport</code> 类用于创建视口。
  10892. */
  10893. //class laya.d3.math.Viewport
  10894. var Viewport=(function(){
  10895. function Viewport(x,y,width,height){
  10896. /**X轴坐标*/
  10897. //this.x=NaN;
  10898. /**Y轴坐标*/
  10899. //this.y=NaN;
  10900. /**宽度*/
  10901. //this.width=NaN;
  10902. /**高度*/
  10903. //this.height=NaN;
  10904. /**最小深度*/
  10905. //this.minDepth=NaN;
  10906. /**最大深度*/
  10907. //this.maxDepth=NaN;
  10908. this.minDepth=0.0;
  10909. this.maxDepth=1.0;
  10910. this.x=x;
  10911. this.y=y;
  10912. this.width=width;
  10913. this.height=height;
  10914. }
  10915. __class(Viewport,'laya.d3.math.Viewport');
  10916. var __proto=Viewport.prototype;
  10917. /**
  10918. *变换一个三维向量。
  10919. *@param source 源三维向量。
  10920. *@param matrix 变换矩阵。
  10921. *@param vector 输出三维向量。
  10922. */
  10923. __proto.project=function(source,matrix,out){
  10924. Vector3.transformV3ToV3(source,matrix,out);
  10925. var matrixEleme=matrix.elements;
  10926. var a=(((source.x *matrixEleme[3])+(source.y *matrixEleme[7]))+(source.z *matrixEleme[11]))+matrixEleme[15];
  10927. if (a!==1.0){
  10928. out.x=out.x / a;
  10929. out.y=out.y / a;
  10930. out.z=out.z / a;
  10931. }
  10932. out.x=(((out.x+1.0)*0.5)*this.width)+this.x;
  10933. out.y=(((-out.y+1.0)*0.5)*this.height)+this.y;
  10934. out.z=(out.z *(this.maxDepth-this.minDepth))+this.minDepth;
  10935. }
  10936. __proto.project1=function(source,matrix,out){
  10937. var v4=Vector3._tempVector4;
  10938. Vector3.transformV3ToV4(source,matrix,v4);
  10939. var dist=v4.w;
  10940. if (dist < 1e-1 && dist >-1e-6)dist=1e-6;
  10941. v4.x /=dist;
  10942. v4.y /=dist;
  10943. v4.z /=dist;
  10944. out.x=(v4.x+1)*this.width / 2+this.x;
  10945. out.y=(-v4.y+1)*this.height / 2+this.y;
  10946. out.z=v4.w;
  10947. return;
  10948. }
  10949. /**
  10950. *反变换一个三维向量。
  10951. *@param source 源三维向量。
  10952. *@param matrix 变换矩阵。
  10953. *@param vector 输出三维向量。
  10954. */
  10955. __proto.unprojectFromMat=function(source,matrix,out){
  10956. var matrixEleme=matrix.elements;
  10957. out.x=(((source.x-this.x)/ (this.width))*2.0)-1.0;
  10958. out.y=-((((source.y-this.y)/ (this.height))*2.0)-1.0);
  10959. var halfDepth=(this.maxDepth-this.minDepth)/ 2;
  10960. out.z=(source.z-this.minDepth-halfDepth)/ halfDepth;
  10961. var a=(((out.x *matrixEleme[3])+(out.y *matrixEleme[7]))+(out.z *matrixEleme[11]))+matrixEleme[15];
  10962. Vector3.transformV3ToV3(out,matrix,out);
  10963. if (a!==1.0){
  10964. out.x=out.x / a;
  10965. out.y=out.y / a;
  10966. out.z=out.z / a;
  10967. }
  10968. }
  10969. /**
  10970. *反变换一个三维向量。
  10971. *@param source 源三维向量。
  10972. *@param projection 透视投影矩阵。
  10973. *@param view 视图矩阵。
  10974. *@param world 世界矩阵,可设置为null。
  10975. *@param out 输出向量。
  10976. */
  10977. __proto.unprojectFromWVP=function(source,projection,view,world,out){
  10978. Matrix4x4.multiply(projection,view,Viewport._tempMatrix4x4);
  10979. (world)&& (Matrix4x4.multiply(Viewport._tempMatrix4x4,world,Viewport._tempMatrix4x4));
  10980. Viewport._tempMatrix4x4.invert(Viewport._tempMatrix4x4);
  10981. this.unprojectFromMat(source,Viewport._tempMatrix4x4,out);
  10982. }
  10983. /**
  10984. *克隆
  10985. *@param out
  10986. */
  10987. __proto.cloneTo=function(out){
  10988. out.x=this.x;
  10989. out.y=this.y;
  10990. out.width=this.width;
  10991. out.height=this.height;
  10992. out.minDepth=this.minDepth;
  10993. out.maxDepth=this.maxDepth;
  10994. }
  10995. __static(Viewport,
  10996. ['_tempMatrix4x4',function(){return this._tempMatrix4x4=new Matrix4x4();}
  10997. ]);
  10998. return Viewport;
  10999. })()
  11000. /**
  11001. *<code>BoundsOctree</code> 类用于创建八叉树。
  11002. */
  11003. //class laya.d3.core.scene.BoundsOctree
  11004. var BoundsOctree=(function(){
  11005. function BoundsOctree(initialWorldSize,initialWorldPos,minNodeSize,looseness){
  11006. /**@private */
  11007. this._initialSize=NaN;
  11008. /**@private */
  11009. this._rootNode=null;
  11010. /**@private */
  11011. this._looseness=NaN;
  11012. /**@private */
  11013. this._minSize=NaN;
  11014. /**@private [只读]*/
  11015. this.count=0;
  11016. this._motionObjects=new OctreeMotionList();
  11017. if (minNodeSize > initialWorldSize){
  11018. console.warn("Minimum node size must be at least as big as the initial world size. Was: "+minNodeSize+" Adjusted to: "+initialWorldSize);
  11019. minNodeSize=initialWorldSize;
  11020. }
  11021. this._initialSize=initialWorldSize;
  11022. this._minSize=minNodeSize;
  11023. this._looseness=Math.min(Math.max(looseness,1.0),2.0);
  11024. this._rootNode=new BoundsOctreeNode(this,null,initialWorldSize,initialWorldPos);
  11025. }
  11026. __class(BoundsOctree,'laya.d3.core.scene.BoundsOctree');
  11027. var __proto=BoundsOctree.prototype;
  11028. /**
  11029. *@private
  11030. */
  11031. __proto._getMaxDepth=function(node,depth){
  11032. depth++;
  11033. var children=node._children;
  11034. if (children !=null){
  11035. var curDepth=depth;
  11036. for (var i=0,n=children.length;i < n;i++){
  11037. var child=children[i];
  11038. child && (depth=Math.max(this._getMaxDepth(child,curDepth),depth));
  11039. }
  11040. }
  11041. return depth;
  11042. }
  11043. /**
  11044. *@private
  11045. */
  11046. __proto._grow=function(growObjectCenter){
  11047. var xDirection=growObjectCenter.x >=0 ? 1 :-1;
  11048. var yDirection=growObjectCenter.y >=0 ? 1 :-1;
  11049. var zDirection=growObjectCenter.z >=0 ? 1 :-1;
  11050. var oldRoot=this._rootNode;
  11051. var half=this._rootNode.baseLength / 2;
  11052. var newLength=this._rootNode.baseLength *2;
  11053. var rootCenter=this._rootNode.center;
  11054. var newCenter=new Vector3(rootCenter.x+xDirection *half,rootCenter.y+yDirection *half,rootCenter.z+zDirection *half);
  11055. this._rootNode=new BoundsOctreeNode(this,null,newLength,newCenter);
  11056. if (oldRoot.hasAnyObjects()){
  11057. var rootPos=this._rootNode._bestFitChild(oldRoot.center);
  11058. var children=__newvec(8,null);
  11059. for (var i=0;i < 8;i++){
  11060. if (i==rootPos){
  11061. oldRoot._parent=this._rootNode;
  11062. children[i]=oldRoot;
  11063. }
  11064. }
  11065. this._rootNode._children=children;
  11066. }
  11067. }
  11068. /**
  11069. *添加物体
  11070. *@param object
  11071. */
  11072. __proto.add=function(object){
  11073. var count=0;
  11074. while (!this._rootNode.add(object)){
  11075. var growCenter=BoundsOctree._tempVector30;
  11076. Vector3.subtract(object.bounds.getCenter(),this._rootNode.center,growCenter);
  11077. this._grow(growCenter);
  11078. if (++count > 20){
  11079. throw "Aborted Add operation as it seemed to be going on forever ("+(count-1)+") attempts at growing the octree.";
  11080. }
  11081. }
  11082. this.count++;
  11083. }
  11084. /**
  11085. *移除物体
  11086. *@return 是否成功
  11087. */
  11088. __proto.remove=function(object){
  11089. var removed=object._getOctreeNode().remove(object);
  11090. if (removed){
  11091. this.count--;
  11092. }
  11093. return removed;
  11094. }
  11095. /**
  11096. *更新物体
  11097. */
  11098. __proto.update=function(object){
  11099. var count=0;
  11100. var octreeNode=object._getOctreeNode();
  11101. if (octreeNode){
  11102. while (!octreeNode._update(object)){
  11103. this._grow(object.bounds.getCenter());
  11104. if (++count > 20){
  11105. throw "Aborted Add operation as it seemed to be going on forever ("+(count-1)+") attempts at growing the octree.";
  11106. }
  11107. }
  11108. return true;
  11109. }else {
  11110. return false;
  11111. }
  11112. }
  11113. /**
  11114. *如果可能则收缩根节点。
  11115. */
  11116. __proto.shrinkRootIfPossible=function(){
  11117. this._rootNode=this._rootNode.shrinkIfPossible(this._initialSize);
  11118. }
  11119. /**
  11120. *添加运动物体。
  11121. *@param 运动物体。
  11122. */
  11123. __proto.addMotionObject=function(object){
  11124. this._motionObjects.add(object);
  11125. }
  11126. /**
  11127. *移除运动物体。
  11128. *@param 运动物体。
  11129. */
  11130. __proto.removeMotionObject=function(object){
  11131. this._motionObjects.remove(object);
  11132. }
  11133. /**
  11134. *更新所有运动物体。
  11135. */
  11136. __proto.updateMotionObjects=function(){
  11137. var elements=this._motionObjects.elements;
  11138. for (var i=0,n=this._motionObjects.length;i < n;i++){
  11139. var object=elements [i];
  11140. this.update(object);
  11141. object._setIndexInMotionList(-1);
  11142. }
  11143. this._motionObjects.length=0;
  11144. }
  11145. /**
  11146. *获取是否与指定包围盒相交。
  11147. *@param checkBound AABB包围盒。
  11148. *@return 是否相交。
  11149. */
  11150. __proto.isCollidingWithBoundBox=function(checkBounds){
  11151. return this._rootNode.isCollidingWithBoundBox(checkBounds);
  11152. }
  11153. /**
  11154. *获取是否与指定射线相交。
  11155. *@param ray 射线。
  11156. *@param maxDistance 射线的最大距离。
  11157. *@return 是否相交。
  11158. */
  11159. __proto.isCollidingWithRay=function(ray,maxDistance){
  11160. (maxDistance===void 0)&& (maxDistance=Number.MAX_VALUE);
  11161. return this._rootNode.isCollidingWithRay(ray,maxDistance);
  11162. }
  11163. /**
  11164. *获取与指定包围盒相交的物体列表。
  11165. *@param checkBound AABB包围盒。
  11166. *@param result 相交物体列表
  11167. */
  11168. __proto.getCollidingWithBoundBox=function(checkBound,result){
  11169. this._rootNode.getCollidingWithBoundBox(checkBound,result);
  11170. }
  11171. /**
  11172. *获取与指定射线相交的的物理列表。
  11173. *@param ray 射线。
  11174. *@param result 相交物体列表。
  11175. *@param maxDistance 射线的最大距离。
  11176. */
  11177. __proto.getCollidingWithRay=function(ray,result,maxDistance){
  11178. (maxDistance===void 0)&& (maxDistance=Number.MAX_VALUE);
  11179. this._rootNode.getCollidingWithRay(ray,result,maxDistance);
  11180. }
  11181. /**
  11182. *获取与指定视锥相交的的物理列表。
  11183. *@param 渲染上下文。
  11184. */
  11185. __proto.getCollidingWithFrustum=function(context){
  11186. this._rootNode.getCollidingWithFrustum(context);
  11187. }
  11188. /**
  11189. *获取最大包围盒
  11190. *@return 最大包围盒
  11191. */
  11192. __proto.getMaxBounds=function(){
  11193. return this._rootNode.getBound();
  11194. }
  11195. /**
  11196. *@private
  11197. *[Debug]
  11198. */
  11199. __proto.drawAllBounds=function(pixelLine){
  11200. var maxDepth=this._getMaxDepth(this._rootNode,-1);
  11201. this._rootNode.drawAllBounds(pixelLine,-1,maxDepth);
  11202. }
  11203. /**
  11204. *@private
  11205. *[Debug]
  11206. */
  11207. __proto.drawAllObjects=function(pixelLine){
  11208. var maxDepth=this._getMaxDepth(this._rootNode,-1);
  11209. this._rootNode.drawAllObjects(pixelLine,-1,maxDepth);
  11210. }
  11211. __static(BoundsOctree,
  11212. ['_tempVector30',function(){return this._tempVector30=new Vector3();}
  11213. ]);
  11214. return BoundsOctree;
  11215. })()
  11216. /**
  11217. *<code>KeyframeNodeList</code> 类用于创建KeyframeNode节点队列。
  11218. */
  11219. //class laya.d3.animation.KeyframeNodeList
  11220. var KeyframeNodeList=(function(){
  11221. function KeyframeNodeList(){
  11222. this._nodes=[];
  11223. }
  11224. __class(KeyframeNodeList,'laya.d3.animation.KeyframeNodeList');
  11225. var __proto=KeyframeNodeList.prototype;
  11226. /**
  11227. *通过索引获取节点。
  11228. *@param index 索引。
  11229. *@return 节点。
  11230. */
  11231. __proto.getNodeByIndex=function(index){
  11232. return this._nodes[index];
  11233. }
  11234. /**
  11235. *通过索引设置节点。
  11236. *@param index 索引。
  11237. *@param 节点。
  11238. */
  11239. __proto.setNodeByIndex=function(index,node){
  11240. this._nodes[index]=node;
  11241. }
  11242. /**
  11243. *设置节点个数。
  11244. *@param value 节点个数。
  11245. */
  11246. /**
  11247. *获取节点个数。
  11248. *@return 节点个数。
  11249. */
  11250. __getset(0,__proto,'count',function(){
  11251. return this._nodes.length;
  11252. },function(value){
  11253. this._nodes.length=value;
  11254. });
  11255. return KeyframeNodeList;
  11256. })()
  11257. /**
  11258. *<code>OrientedBoundBox</code> 类用于创建OBB包围盒。
  11259. */
  11260. //class laya.d3.math.OrientedBoundBox
  11261. var OrientedBoundBox=(function(){
  11262. function OrientedBoundBox(extents,transformation){
  11263. /**每个轴长度的一半*/
  11264. this.extents=null;
  11265. /**这个矩阵表示包围盒的位置和缩放,它的平移向量表示该包围盒的中心*/
  11266. this.transformation=null;
  11267. this.extents=extents;
  11268. this.transformation=transformation;
  11269. }
  11270. __class(OrientedBoundBox,'laya.d3.math.OrientedBoundBox');
  11271. var __proto=OrientedBoundBox.prototype;
  11272. /**
  11273. *获取OBB包围盒的8个顶点。
  11274. *@param corners 返回顶点的输出队列。
  11275. */
  11276. __proto.getCorners=function(corners){
  11277. OrientedBoundBox._tempV30.x=this.extents.x;
  11278. OrientedBoundBox._tempV30.y=OrientedBoundBox._tempV30.z=0;
  11279. OrientedBoundBox._tempV31.y=this.extents.y;
  11280. OrientedBoundBox._tempV31.x=OrientedBoundBox._tempV31.z=0;
  11281. OrientedBoundBox._tempV32.z=this.extents.z;
  11282. OrientedBoundBox._tempV32.x=OrientedBoundBox._tempV32.y=0;
  11283. Vector3.TransformNormal(OrientedBoundBox._tempV30,this.transformation,OrientedBoundBox._tempV30);
  11284. Vector3.TransformNormal(OrientedBoundBox._tempV31,this.transformation,OrientedBoundBox._tempV31);
  11285. Vector3.TransformNormal(OrientedBoundBox._tempV32,this.transformation,OrientedBoundBox._tempV32);
  11286. var center=OrientedBoundBox._tempV33;
  11287. this.transformation.getTranslationVector(center);
  11288. corners.length=8;
  11289. Vector3.add(center,OrientedBoundBox._tempV30,OrientedBoundBox._tempV34);
  11290. Vector3.add(OrientedBoundBox._tempV34,OrientedBoundBox._tempV31,OrientedBoundBox._tempV34);
  11291. Vector3.add(OrientedBoundBox._tempV34,OrientedBoundBox._tempV32,corners[0]);
  11292. Vector3.add(center,OrientedBoundBox._tempV30,OrientedBoundBox._tempV34);
  11293. Vector3.add(OrientedBoundBox._tempV34,OrientedBoundBox._tempV31,OrientedBoundBox._tempV34);
  11294. Vector3.subtract(OrientedBoundBox._tempV34,OrientedBoundBox._tempV32,corners[1]);
  11295. Vector3.subtract(center,OrientedBoundBox._tempV30,OrientedBoundBox._tempV34);
  11296. Vector3.add(OrientedBoundBox._tempV34,OrientedBoundBox._tempV31,OrientedBoundBox._tempV34);
  11297. Vector3.subtract(OrientedBoundBox._tempV34,OrientedBoundBox._tempV32,corners[2]);
  11298. Vector3.subtract(center,OrientedBoundBox._tempV30,OrientedBoundBox._tempV34);
  11299. Vector3.add(OrientedBoundBox._tempV34,OrientedBoundBox._tempV31,OrientedBoundBox._tempV34);
  11300. Vector3.add(OrientedBoundBox._tempV34,OrientedBoundBox._tempV32,corners[3]);
  11301. Vector3.add(center,OrientedBoundBox._tempV30,OrientedBoundBox._tempV34);
  11302. Vector3.subtract(OrientedBoundBox._tempV34,OrientedBoundBox._tempV31,OrientedBoundBox._tempV34);
  11303. Vector3.add(OrientedBoundBox._tempV34,OrientedBoundBox._tempV32,corners[4]);
  11304. Vector3.add(center,OrientedBoundBox._tempV30,OrientedBoundBox._tempV34);
  11305. Vector3.subtract(OrientedBoundBox._tempV34,OrientedBoundBox._tempV31,OrientedBoundBox._tempV34);
  11306. Vector3.subtract(OrientedBoundBox._tempV34,OrientedBoundBox._tempV32,corners[5]);
  11307. Vector3.subtract(center,OrientedBoundBox._tempV30,OrientedBoundBox._tempV34);
  11308. Vector3.subtract(OrientedBoundBox._tempV34,OrientedBoundBox._tempV31,OrientedBoundBox._tempV34);
  11309. Vector3.subtract(OrientedBoundBox._tempV34,OrientedBoundBox._tempV32,corners[6]);
  11310. Vector3.subtract(center,OrientedBoundBox._tempV30,OrientedBoundBox._tempV34);
  11311. Vector3.subtract(OrientedBoundBox._tempV34,OrientedBoundBox._tempV31,OrientedBoundBox._tempV34);
  11312. Vector3.add(OrientedBoundBox._tempV34,OrientedBoundBox._tempV32,corners[7]);
  11313. }
  11314. /**
  11315. *变换该包围盒的矩阵信息。
  11316. *@param mat 矩阵
  11317. */
  11318. __proto.transform=function(mat){
  11319. Matrix4x4.multiply(this.transformation,mat,this.transformation);
  11320. }
  11321. /**
  11322. *缩放该包围盒
  11323. *@param scaling 各轴的缩放比。
  11324. */
  11325. __proto.scale=function(scaling){
  11326. Vector3.multiply(this.extents,scaling,this.extents);
  11327. }
  11328. /**
  11329. *平移该包围盒。
  11330. *@param translation 平移参数
  11331. */
  11332. __proto.translate=function(translation){
  11333. this.transformation.getTranslationVector(OrientedBoundBox._tempV30);
  11334. Vector3.add(OrientedBoundBox._tempV30,translation,OrientedBoundBox._tempV31);
  11335. this.transformation.setTranslationVector(OrientedBoundBox._tempV31);
  11336. }
  11337. /**
  11338. *该包围盒的尺寸。
  11339. *@param out 输出
  11340. */
  11341. __proto.Size=function(out){
  11342. Vector3.scale(this.extents,2,out);
  11343. }
  11344. /**
  11345. *该包围盒需要考虑的尺寸
  11346. *@param out 输出
  11347. */
  11348. __proto.getSize=function(out){
  11349. OrientedBoundBox._tempV30.x=this.extents.x;
  11350. OrientedBoundBox._tempV31.y=this.extents.y;
  11351. OrientedBoundBox._tempV32.z=this.extents.z;
  11352. Vector3.TransformNormal(OrientedBoundBox._tempV30,this.transformation,OrientedBoundBox._tempV30);
  11353. Vector3.TransformNormal(OrientedBoundBox._tempV31,this.transformation,OrientedBoundBox._tempV31);
  11354. Vector3.TransformNormal(OrientedBoundBox._tempV31,this.transformation,OrientedBoundBox._tempV32);
  11355. out.x=Vector3.scalarLength(OrientedBoundBox._tempV30);
  11356. out.y=Vector3.scalarLength(OrientedBoundBox._tempV31);
  11357. out.z=Vector3.scalarLength(OrientedBoundBox._tempV32);
  11358. }
  11359. /**
  11360. *该包围盒需要考虑尺寸的平方
  11361. *@param out 输出
  11362. */
  11363. __proto.getSizeSquared=function(out){
  11364. OrientedBoundBox._tempV30.x=this.extents.x;
  11365. OrientedBoundBox._tempV31.y=this.extents.y;
  11366. OrientedBoundBox._tempV32.z=this.extents.z;
  11367. Vector3.TransformNormal(OrientedBoundBox._tempV30,this.transformation,OrientedBoundBox._tempV30);
  11368. Vector3.TransformNormal(OrientedBoundBox._tempV31,this.transformation,OrientedBoundBox._tempV31);
  11369. Vector3.TransformNormal(OrientedBoundBox._tempV31,this.transformation,OrientedBoundBox._tempV32);
  11370. out.x=Vector3.scalarLengthSquared(OrientedBoundBox._tempV30);
  11371. out.y=Vector3.scalarLengthSquared(OrientedBoundBox._tempV31);
  11372. out.z=Vector3.scalarLengthSquared(OrientedBoundBox._tempV32);
  11373. }
  11374. /**
  11375. *该包围盒的几何中心
  11376. */
  11377. __proto.getCenter=function(center){
  11378. this.transformation.getTranslationVector(center);
  11379. }
  11380. /**
  11381. *该包围盒是否包含空间中一点
  11382. *@param point 点
  11383. *@return 返回位置关系
  11384. */
  11385. __proto.containsPoint=function(point){
  11386. var extentsEX=this.extents.x;
  11387. var extentsEY=this.extents.y;
  11388. var extentsEZ=this.extents.z;
  11389. this.transformation.invert(OrientedBoundBox._tempM0);
  11390. Vector3.transformCoordinate(point,OrientedBoundBox._tempM0,OrientedBoundBox._tempV30);
  11391. var _tempV30ex=Math.abs(OrientedBoundBox._tempV30.x);
  11392. var _tempV30ey=Math.abs(OrientedBoundBox._tempV30.y);
  11393. var _tempV30ez=Math.abs(OrientedBoundBox._tempV30.z);
  11394. if (MathUtils3D.nearEqual(_tempV30ex,extentsEX)&& MathUtils3D.nearEqual(_tempV30ey,extentsEY)&& MathUtils3D.nearEqual(_tempV30ez,extentsEZ))
  11395. return /*laya.d3.math.ContainmentType.Intersects*/2;
  11396. if (_tempV30ex < extentsEX && _tempV30ey < extentsEY && _tempV30ez < extentsEZ)
  11397. return /*laya.d3.math.ContainmentType.Contains*/1;
  11398. else
  11399. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  11400. }
  11401. /**
  11402. *该包围盒是否包含空间中多点
  11403. *@param point 点
  11404. *@return 返回位置关系
  11405. */
  11406. __proto.containsPoints=function(points){
  11407. var extentsex=this.extents.x;
  11408. var extentsey=this.extents.y;
  11409. var extentsez=this.extents.z;
  11410. this.transformation.invert(OrientedBoundBox._tempM0);
  11411. var containsAll=true;
  11412. var containsAny=false;
  11413. for (var i=0;i < points.length;i++){
  11414. Vector3.transformCoordinate(points[i],OrientedBoundBox._tempM0,OrientedBoundBox._tempV30);
  11415. var _tempV30ex=Math.abs(OrientedBoundBox._tempV30.x);
  11416. var _tempV30ey=Math.abs(OrientedBoundBox._tempV30.y);
  11417. var _tempV30ez=Math.abs(OrientedBoundBox._tempV30.z);
  11418. if (MathUtils3D.nearEqual(_tempV30ex,extentsex)&& MathUtils3D.nearEqual(_tempV30ey,extentsey)&& MathUtils3D.nearEqual(_tempV30ez,extentsez))
  11419. containsAny=true;
  11420. if (_tempV30ex < extentsex && _tempV30ey < extentsey && _tempV30ez < extentsez)
  11421. containsAny=true;
  11422. else
  11423. containsAll=false;
  11424. }
  11425. if (containsAll)
  11426. return /*laya.d3.math.ContainmentType.Contains*/1;
  11427. else if (containsAny)
  11428. return /*laya.d3.math.ContainmentType.Intersects*/2;
  11429. else
  11430. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  11431. }
  11432. /**
  11433. *该包围盒是否包含空间中一包围球
  11434. *@param sphere 包围球
  11435. *@param ignoreScale 是否考虑该包围盒的缩放
  11436. *@return 返回位置关系
  11437. */
  11438. __proto.containsSphere=function(sphere,ignoreScale){
  11439. (ignoreScale===void 0)&& (ignoreScale=false);
  11440. var extentsEX=this.extents.x;
  11441. var extentsEY=this.extents.y;
  11442. var extentsEZ=this.extents.z;
  11443. var sphereR=sphere.radius;
  11444. this.transformation.invert(OrientedBoundBox._tempM0);
  11445. Vector3.transformCoordinate(sphere.center,OrientedBoundBox._tempM0,OrientedBoundBox._tempV30);
  11446. var locRadius=NaN;
  11447. if (ignoreScale){
  11448. locRadius=sphereR;
  11449. }else {
  11450. Vector3.scale(Vector3._UnitX,sphereR,OrientedBoundBox._tempV31);
  11451. Vector3.TransformNormal(OrientedBoundBox._tempV31,OrientedBoundBox._tempM0,OrientedBoundBox._tempV31);
  11452. locRadius=Vector3.scalarLength(OrientedBoundBox._tempV31);
  11453. }
  11454. Vector3.scale(this.extents,-1,OrientedBoundBox._tempV32);
  11455. Vector3.Clamp(OrientedBoundBox._tempV30,OrientedBoundBox._tempV32,this.extents,OrientedBoundBox._tempV33);
  11456. var distance=Vector3.distanceSquared(OrientedBoundBox._tempV30,OrientedBoundBox._tempV33);
  11457. if (distance > locRadius *locRadius)
  11458. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  11459. var tempV30ex=OrientedBoundBox._tempV30.x;
  11460. var tempV30ey=OrientedBoundBox._tempV30.y;
  11461. var tempV30ez=OrientedBoundBox._tempV30.z;
  11462. var tempV32ex=OrientedBoundBox._tempV32.x;
  11463. var tempV32ey=OrientedBoundBox._tempV32.y;
  11464. var tempV32ez=OrientedBoundBox._tempV32.z;
  11465. 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)))){
  11466. return /*laya.d3.math.ContainmentType.Contains*/1;
  11467. }
  11468. return /*laya.d3.math.ContainmentType.Intersects*/2;
  11469. }
  11470. /**
  11471. *For accuracy,The transformation matrix for both <see cref="OrientedBoundingBox"/> must not have any scaling applied to it.
  11472. *Anyway,scaling using Scale method will keep this method accurate.
  11473. *该包围盒是否包含空间中另一OBB包围盒
  11474. *@param obb OBB包围盒
  11475. *@return 返回位置关系
  11476. */
  11477. __proto.containsOrientedBoundBox=function(obb){
  11478. var i=0,k=0;
  11479. obb.getCorners(OrientedBoundBox._corners);
  11480. var cornersCheck=this.containsPoints(OrientedBoundBox._corners);
  11481. if (cornersCheck !=/*laya.d3.math.ContainmentType.Disjoint*/0)
  11482. return cornersCheck;
  11483. OrientedBoundBox._sizeAe[0]=this.extents.x;
  11484. OrientedBoundBox._sizeAe[1]=this.extents.y;
  11485. OrientedBoundBox._sizeAe[2]=this.extents.z;
  11486. obb.extents.cloneTo(OrientedBoundBox._tempV35);
  11487. OrientedBoundBox._sizeBe[0]=OrientedBoundBox._tempV35.x;
  11488. OrientedBoundBox._sizeBe[1]=OrientedBoundBox._tempV35.y;
  11489. OrientedBoundBox._sizeBe[2]=OrientedBoundBox._tempV35.z;
  11490. OrientedBoundBox._getRows(this.transformation,OrientedBoundBox._rows1);
  11491. OrientedBoundBox._getRows(obb.transformation,OrientedBoundBox._rows2);
  11492. var extentA=NaN,extentB=NaN,separation=NaN,dotNumber=NaN;
  11493. for (i=0;i < 4;i++){
  11494. for (k=0;k < 4;k++){
  11495. if (i==3 || k==3){
  11496. OrientedBoundBox._tempM0.setElementByRowColumn(i,k,0);
  11497. OrientedBoundBox._tempM1.setElementByRowColumn(i,k,0);
  11498. }else {
  11499. dotNumber=Vector3.dot(OrientedBoundBox._rows1[i],OrientedBoundBox._rows2[k]);
  11500. OrientedBoundBox._tempM0.setElementByRowColumn(i,k,dotNumber);
  11501. OrientedBoundBox._tempM1.setElementByRowColumn(i,k,Math.abs(dotNumber));
  11502. }
  11503. }
  11504. }
  11505. obb.getCenter(OrientedBoundBox._tempV34);
  11506. this.getCenter(OrientedBoundBox._tempV36);
  11507. Vector3.subtract(OrientedBoundBox._tempV34,OrientedBoundBox._tempV36,OrientedBoundBox._tempV30);
  11508. OrientedBoundBox._tempV31.x=Vector3.dot(OrientedBoundBox._tempV30,OrientedBoundBox._rows1[0]);
  11509. OrientedBoundBox._tempV31.y=Vector3.dot(OrientedBoundBox._tempV30,OrientedBoundBox._rows1[1]);
  11510. OrientedBoundBox._tempV31.z=Vector3.dot(OrientedBoundBox._tempV30,OrientedBoundBox._rows1[2]);
  11511. OrientedBoundBox._vsepAe[0]=OrientedBoundBox._tempV31.x;
  11512. OrientedBoundBox._vsepAe[1]=OrientedBoundBox._tempV31.y;
  11513. OrientedBoundBox._vsepAe[2]=OrientedBoundBox._tempV31.z;
  11514. for (i=0;i < 3;i++){
  11515. OrientedBoundBox._tempV32.x=OrientedBoundBox._tempM1.getElementByRowColumn(i,0);
  11516. OrientedBoundBox._tempV32.y=OrientedBoundBox._tempM1.getElementByRowColumn(i,1);
  11517. OrientedBoundBox._tempV32.z=OrientedBoundBox._tempM1.getElementByRowColumn(i,2);
  11518. extentA=OrientedBoundBox._sizeAe[i];
  11519. extentB=Vector3.dot(OrientedBoundBox._tempV35,OrientedBoundBox._tempV32);
  11520. separation=Math.abs(OrientedBoundBox._vsepAe[i]);
  11521. if (separation > extentA+extentB)
  11522. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  11523. }
  11524. for (k=0;k < 3;k++){
  11525. OrientedBoundBox._tempV32.x=OrientedBoundBox._tempM1.getElementByRowColumn(0,k);
  11526. OrientedBoundBox._tempV32.y=OrientedBoundBox._tempM1.getElementByRowColumn(1,k);
  11527. OrientedBoundBox._tempV32.z=OrientedBoundBox._tempM1.getElementByRowColumn(2,k);
  11528. OrientedBoundBox._tempV33.x=OrientedBoundBox._tempM0.getElementByRowColumn(0,k);
  11529. OrientedBoundBox._tempV33.y=OrientedBoundBox._tempM0.getElementByRowColumn(1,k);
  11530. OrientedBoundBox._tempV33.z=OrientedBoundBox._tempM0.getElementByRowColumn(2,k);
  11531. extentA=Vector3.dot(this.extents,OrientedBoundBox._tempV32);
  11532. extentB=OrientedBoundBox._sizeBe[k];
  11533. separation=Math.abs(Vector3.dot(OrientedBoundBox._tempV31,OrientedBoundBox._tempV33));
  11534. if (separation > extentA+extentB)
  11535. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  11536. }
  11537. for (i=0;i < 3;i++){
  11538. for (k=0;k < 3;k++){
  11539. var i1=(i+1)% 3,i2=(i+2)% 3;
  11540. var k1=(k+1)% 3,k2=(k+2)% 3;
  11541. extentA=OrientedBoundBox._sizeAe[i1] *OrientedBoundBox._tempM1.getElementByRowColumn(i2,k)+OrientedBoundBox._sizeAe[i2] *OrientedBoundBox._tempM1.getElementByRowColumn(i1,k);
  11542. extentB=OrientedBoundBox._sizeBe[k1] *OrientedBoundBox._tempM1.getElementByRowColumn(i,k2)+OrientedBoundBox._sizeBe[k2] *OrientedBoundBox._tempM1.getElementByRowColumn(i,k1);
  11543. separation=Math.abs(OrientedBoundBox._vsepAe[i2] *OrientedBoundBox._tempM0.getElementByRowColumn(i1,k)-OrientedBoundBox._vsepAe[i1] *OrientedBoundBox._tempM0.getElementByRowColumn(i2,k));
  11544. if (separation > extentA+extentB)
  11545. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  11546. }
  11547. }
  11548. return /*laya.d3.math.ContainmentType.Intersects*/2;
  11549. }
  11550. /**
  11551. *该包围盒是否包含空间中一条线
  11552. *@param point1 点1
  11553. *@param point2 点2
  11554. *@return 返回位置关系
  11555. */
  11556. __proto.containsLine=function(point1,point2){
  11557. OrientedBoundBox._corners[0]=point1;
  11558. OrientedBoundBox._corners[1]=point2;
  11559. var cornersCheck=this.containsPoints(OrientedBoundBox._corners);
  11560. if (cornersCheck !=/*laya.d3.math.ContainmentType.Disjoint*/0)
  11561. return cornersCheck;
  11562. var extentsX=this.extents.x;
  11563. var extentsY=this.extents.y;
  11564. var extentsZ=this.extents.z;
  11565. this.transformation.invert(OrientedBoundBox._tempM0);
  11566. Vector3.transformCoordinate(point1,OrientedBoundBox._tempM0,OrientedBoundBox._tempV30);
  11567. Vector3.transformCoordinate(point2,OrientedBoundBox._tempM0,OrientedBoundBox._tempV31);
  11568. Vector3.add(OrientedBoundBox._tempV30,OrientedBoundBox._tempV31,OrientedBoundBox._tempV32);
  11569. Vector3.scale(OrientedBoundBox._tempV32,0.5,OrientedBoundBox._tempV32);
  11570. Vector3.subtract(OrientedBoundBox._tempV30,OrientedBoundBox._tempV32,OrientedBoundBox._tempV33);
  11571. var _tempV33X=OrientedBoundBox._tempV33.x;
  11572. var _tempV33Y=OrientedBoundBox._tempV33.y;
  11573. var _tempV33Z=OrientedBoundBox._tempV33.z;
  11574. var _tempV34X=OrientedBoundBox._tempV34.x=Math.abs(OrientedBoundBox._tempV33.x);
  11575. var _tempV34Y=OrientedBoundBox._tempV34.y=Math.abs(OrientedBoundBox._tempV33.y);
  11576. var _tempV34Z=OrientedBoundBox._tempV34.z=Math.abs(OrientedBoundBox._tempV33.z);
  11577. var _tempV32X=OrientedBoundBox._tempV32.x;
  11578. var _tempV32Y=OrientedBoundBox._tempV32.y;
  11579. var _tempV32Z=OrientedBoundBox._tempV32.z;
  11580. if (Math.abs(_tempV32X)> extentsX+_tempV34X)
  11581. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  11582. if (Math.abs(_tempV32Y)> extentsY+_tempV34Y)
  11583. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  11584. if (Math.abs(_tempV32Z)> extentsZ+_tempV34Z)
  11585. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  11586. if (Math.abs(_tempV32Y *_tempV33Z-_tempV32Z *_tempV33Y)> (extentsY *_tempV34Z+extentsZ *_tempV34Y))
  11587. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  11588. if (Math.abs(_tempV32X *_tempV33Z-_tempV32Z *_tempV33X)> (extentsX *_tempV34Z+extentsZ *_tempV34X))
  11589. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  11590. if (Math.abs(_tempV32X *_tempV33Y-_tempV32Y *_tempV33X)> (extentsX *_tempV34Y+extentsY *_tempV34X))
  11591. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  11592. return /*laya.d3.math.ContainmentType.Intersects*/2;
  11593. }
  11594. /**
  11595. *该包围盒是否包含空间中另一OBB包围盒
  11596. *@param box 包围盒
  11597. *@return 返回位置关系
  11598. */
  11599. __proto.containsBoundBox=function(box){
  11600. var i=0,k=0;
  11601. var min=box.min;
  11602. var max=box.max;
  11603. box.getCorners(OrientedBoundBox._corners);
  11604. var cornersCheck=this.containsPoints(OrientedBoundBox._corners);
  11605. if (cornersCheck !=/*laya.d3.math.ContainmentType.Disjoint*/0)
  11606. return cornersCheck;
  11607. Vector3.subtract(max,min,OrientedBoundBox._tempV30);
  11608. Vector3.scale(OrientedBoundBox._tempV30,0.5,OrientedBoundBox._tempV30);
  11609. Vector3.add(min,OrientedBoundBox._tempV30,OrientedBoundBox._tempV30);
  11610. Vector3.subtract(max,OrientedBoundBox._tempV30,OrientedBoundBox._tempV31);
  11611. OrientedBoundBox._sizeAe[0]=this.extents.x;
  11612. OrientedBoundBox._sizeAe[1]=this.extents.y;
  11613. OrientedBoundBox._sizeAe[2]=this.extents.z;
  11614. OrientedBoundBox._sizeBe[0]=OrientedBoundBox._tempV31.x;
  11615. OrientedBoundBox._sizeBe[1]=OrientedBoundBox._tempV31.y;
  11616. OrientedBoundBox._sizeBe[2]=OrientedBoundBox._tempV31.z;
  11617. OrientedBoundBox._getRows(this.transformation,OrientedBoundBox._rows1);
  11618. this.transformation.invert(OrientedBoundBox._tempM0);
  11619. var extentA=NaN,extentB=NaN,separation=NaN,dotNumber=NaN;
  11620. for (i=0;i < 3;i++){
  11621. for (k=0;k < 3;k++){
  11622. OrientedBoundBox._tempM1.setElementByRowColumn(i,k,Math.abs(OrientedBoundBox._tempM0.getElementByRowColumn(i,k)));
  11623. }
  11624. }
  11625. this.getCenter(OrientedBoundBox._tempV35);
  11626. Vector3.subtract(OrientedBoundBox._tempV30,OrientedBoundBox._tempV35,OrientedBoundBox._tempV32);
  11627. OrientedBoundBox._tempV31.x=Vector3.dot(OrientedBoundBox._tempV32,OrientedBoundBox._rows1[0]);
  11628. OrientedBoundBox._tempV31.y=Vector3.dot(OrientedBoundBox._tempV32,OrientedBoundBox._rows1[1]);
  11629. OrientedBoundBox._tempV31.z=Vector3.dot(OrientedBoundBox._tempV32,OrientedBoundBox._rows1[2]);
  11630. OrientedBoundBox._vsepAe[0]=OrientedBoundBox._tempV31.x;
  11631. OrientedBoundBox._vsepAe[1]=OrientedBoundBox._tempV31.y;
  11632. OrientedBoundBox._vsepAe[2]=OrientedBoundBox._tempV31.z;
  11633. for (i=0;i < 3;i++){
  11634. OrientedBoundBox._tempV33.x=OrientedBoundBox._tempM1.getElementByRowColumn(i,0);
  11635. OrientedBoundBox._tempV33.y=OrientedBoundBox._tempM1.getElementByRowColumn(i,1);
  11636. OrientedBoundBox._tempV33.z=OrientedBoundBox._tempM1.getElementByRowColumn(i,2);
  11637. extentA=OrientedBoundBox._sizeAe[i];
  11638. extentB=Vector3.dot(OrientedBoundBox._tempV31,OrientedBoundBox._tempV33);
  11639. separation=Math.abs(OrientedBoundBox._vsepAe[i]);
  11640. if (separation > extentA+extentB)
  11641. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  11642. }
  11643. for (k=0;k < 3;k++){
  11644. OrientedBoundBox._tempV33.x=OrientedBoundBox._tempM1.getElementByRowColumn(0,k);
  11645. OrientedBoundBox._tempV33.y=OrientedBoundBox._tempM1.getElementByRowColumn(1,k);
  11646. OrientedBoundBox._tempV33.z=OrientedBoundBox._tempM1.getElementByRowColumn(2,k);
  11647. OrientedBoundBox._tempV34.x=OrientedBoundBox._tempM0.getElementByRowColumn(0,k);
  11648. OrientedBoundBox._tempV34.y=OrientedBoundBox._tempM0.getElementByRowColumn(1,k);
  11649. OrientedBoundBox._tempV34.z=OrientedBoundBox._tempM0.getElementByRowColumn(2,k);
  11650. extentA=Vector3.dot(this.extents,OrientedBoundBox._tempV33);
  11651. extentB=OrientedBoundBox._sizeBe[k];
  11652. separation=Math.abs(Vector3.dot(OrientedBoundBox._tempV31,OrientedBoundBox._tempV34));
  11653. if (separation > extentA+extentB)
  11654. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  11655. }
  11656. for (i=0;i < 3;i++){
  11657. for (k=0;k < 3;k++){
  11658. var i1=(i+1)% 3,i2=(i+2)% 3;
  11659. var k1=(k+1)% 3,k2=(k+2)% 3;
  11660. extentA=OrientedBoundBox._sizeAe[i1] *OrientedBoundBox._tempM1.getElementByRowColumn(i2,k)+OrientedBoundBox._sizeAe[i2] *OrientedBoundBox._tempM1.getElementByRowColumn(i1,k);
  11661. extentB=OrientedBoundBox._sizeBe[k1] *OrientedBoundBox._tempM1.getElementByRowColumn(i,k2)+OrientedBoundBox._sizeBe[k2] *OrientedBoundBox._tempM1.getElementByRowColumn(i,k1);
  11662. separation=Math.abs(OrientedBoundBox._vsepAe[i2] *OrientedBoundBox._tempM0.getElementByRowColumn(i1,k)-OrientedBoundBox._vsepAe[i1] *OrientedBoundBox._tempM0.getElementByRowColumn(i2,k));
  11663. if (separation > extentA+extentB)
  11664. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  11665. }
  11666. }
  11667. return /*laya.d3.math.ContainmentType.Intersects*/2;
  11668. }
  11669. /**
  11670. *该包围盒是否与空间中另一射线相交
  11671. *@param ray
  11672. *@param out
  11673. *@return
  11674. */
  11675. __proto.intersectsRay=function(ray,out){
  11676. Vector3.scale(this.extents,-1,OrientedBoundBox._tempV30);
  11677. this.transformation.invert(OrientedBoundBox._tempM0);
  11678. Vector3.TransformNormal(ray.direction,OrientedBoundBox._tempM0,OrientedBoundBox._ray.direction);
  11679. Vector3.transformCoordinate(ray.origin,OrientedBoundBox._tempM0,OrientedBoundBox._ray.origin);
  11680. OrientedBoundBox._boxBound1.min=OrientedBoundBox._tempV30;
  11681. OrientedBoundBox._boxBound1.max=this.extents;
  11682. var intersects=CollisionUtils.intersectsRayAndBoxRP(OrientedBoundBox._ray,OrientedBoundBox._boxBound1,out);
  11683. if (intersects!==-1)
  11684. Vector3.transformCoordinate(out,this.transformation,out);
  11685. return intersects;
  11686. }
  11687. __proto._getLocalCorners=function(corners){
  11688. corners.length=8;
  11689. OrientedBoundBox._tempV30.x=this.extents.x;
  11690. OrientedBoundBox._tempV31.y=this.extents.y;
  11691. OrientedBoundBox._tempV32.z=this.extents.z;
  11692. Vector3.add(OrientedBoundBox._tempV30,OrientedBoundBox._tempV31,OrientedBoundBox._tempV33);
  11693. Vector3.add(OrientedBoundBox._tempV33,OrientedBoundBox._tempV32,corners[0]);
  11694. Vector3.add(OrientedBoundBox._tempV30,OrientedBoundBox._tempV31,OrientedBoundBox._tempV33);
  11695. Vector3.subtract(OrientedBoundBox._tempV33,OrientedBoundBox._tempV32,corners[1]);
  11696. Vector3.subtract(OrientedBoundBox._tempV31,OrientedBoundBox._tempV30,OrientedBoundBox._tempV33);
  11697. Vector3.subtract(OrientedBoundBox._tempV33,OrientedBoundBox._tempV30,corners[2]);
  11698. Vector3.subtract(OrientedBoundBox._tempV31,OrientedBoundBox._tempV30,OrientedBoundBox._tempV33);
  11699. Vector3.add(OrientedBoundBox._tempV33,OrientedBoundBox._tempV32,corners[3]);
  11700. Vector3.subtract(OrientedBoundBox._tempV30,OrientedBoundBox._tempV31,OrientedBoundBox._tempV33);
  11701. Vector3.add(OrientedBoundBox._tempV33,OrientedBoundBox._tempV32,corners[4]);
  11702. Vector3.subtract(OrientedBoundBox._tempV30,OrientedBoundBox._tempV31,OrientedBoundBox._tempV33);
  11703. Vector3.subtract(OrientedBoundBox._tempV33,OrientedBoundBox._tempV32,corners[5]);
  11704. Vector3.scale(corners[0],-1,corners[6]);
  11705. Vector3.subtract(OrientedBoundBox._tempV32,OrientedBoundBox._tempV30,OrientedBoundBox._tempV33);
  11706. Vector3.subtract(OrientedBoundBox._tempV33,OrientedBoundBox._tempV31,corners[7]);
  11707. }
  11708. /**
  11709. *判断两个包围盒是否相等
  11710. *@param obb obb包围盒
  11711. *@return Boolean
  11712. */
  11713. __proto.equals=function(obb){
  11714. return this.extents==obb.extents && this.transformation==obb.transformation;
  11715. }
  11716. /**
  11717. *克隆。
  11718. *@param destObject 克隆源。
  11719. */
  11720. __proto.cloneTo=function(destObject){
  11721. var dest=destObject;
  11722. this.extents.cloneTo(dest.extents);
  11723. this.transformation.cloneTo(dest.transformation);
  11724. }
  11725. OrientedBoundBox.createByBoundBox=function(box,out){
  11726. var min=box.min;
  11727. var max=box.max;
  11728. Vector3.subtract(max,min,OrientedBoundBox._tempV30);
  11729. Vector3.scale(OrientedBoundBox._tempV30,0.5,OrientedBoundBox._tempV30);
  11730. Vector3.add(min,OrientedBoundBox._tempV30,OrientedBoundBox._tempV31);
  11731. Vector3.subtract(max,OrientedBoundBox._tempV31,OrientedBoundBox._tempV32);
  11732. Matrix4x4.translation(OrientedBoundBox._tempV31,OrientedBoundBox._tempM0);
  11733. var extents=OrientedBoundBox._tempV32.clone();
  11734. var transformation=OrientedBoundBox._tempM0.clone();
  11735. out.extents=extents;
  11736. out.transformation=transformation;
  11737. }
  11738. OrientedBoundBox.createByMinAndMaxVertex=function(min,max){
  11739. Vector3.subtract(max,min,OrientedBoundBox._tempV30);
  11740. Vector3.scale(OrientedBoundBox._tempV30,0.5,OrientedBoundBox._tempV30);
  11741. Vector3.add(min,OrientedBoundBox._tempV30,OrientedBoundBox._tempV31);
  11742. Vector3.subtract(max,OrientedBoundBox._tempV31,OrientedBoundBox._tempV32);
  11743. Matrix4x4.translation(OrientedBoundBox._tempV31,OrientedBoundBox._tempM0);
  11744. var obb=new OrientedBoundBox(OrientedBoundBox._tempV32,OrientedBoundBox._tempM0);
  11745. return obb;
  11746. }
  11747. OrientedBoundBox._getRows=function(mat,out){
  11748. out.length=3;
  11749. var mate=mat.elements;
  11750. out[0].x=mate[0];
  11751. out[0].y=mate[1];
  11752. out[0].z=mate[2];
  11753. out[1].x=mate[4];
  11754. out[1].y=mate[5];
  11755. out[1].z=mate[6];
  11756. out[2].x=mate[8];
  11757. out[2].y=mate[9];
  11758. out[2].z=mate[10];
  11759. }
  11760. OrientedBoundBox.getObbtoObbMatrix4x4=function(a,b,noMatrixScaleApplied,out){
  11761. var at=a.transformation;
  11762. var bt=b.transformation;
  11763. if (noMatrixScaleApplied){
  11764. OrientedBoundBox._getRows(at,OrientedBoundBox._rows1);
  11765. OrientedBoundBox._getRows(bt,OrientedBoundBox._rows2);
  11766. for (var i=0;i < 3;i++){
  11767. for (var k=0;k < 3;k++){
  11768. out.setElementByRowColumn(i,k,Vector3.dot(OrientedBoundBox._rows2[i],OrientedBoundBox._rows1[k]));
  11769. }
  11770. }
  11771. b.getCenter(OrientedBoundBox._tempV30);
  11772. a.getCenter(OrientedBoundBox._tempV31);
  11773. Vector3.subtract(OrientedBoundBox._tempV30,OrientedBoundBox._tempV31,OrientedBoundBox._tempV32);
  11774. var AtoBMe=out.elements;
  11775. AtoBMe[12]=Vector3.dot(OrientedBoundBox._tempV32,OrientedBoundBox._rows1[0]);
  11776. AtoBMe[13]=Vector3.dot(OrientedBoundBox._tempV32,OrientedBoundBox._rows1[1]);
  11777. AtoBMe[14]=Vector3.dot(OrientedBoundBox._tempV32,OrientedBoundBox._rows1[2]);
  11778. AtoBMe[15]=1;
  11779. }else {
  11780. at.invert(OrientedBoundBox._tempM0);
  11781. Matrix4x4.multiply(bt,OrientedBoundBox._tempM0,out);
  11782. }
  11783. }
  11784. OrientedBoundBox.merge=function(a,b,noMatrixScaleApplied){
  11785. var ae=a.extents;
  11786. var at=a.transformation;
  11787. OrientedBoundBox.getObbtoObbMatrix4x4(a,b,noMatrixScaleApplied,OrientedBoundBox._tempM0);
  11788. b._getLocalCorners(OrientedBoundBox._corners);
  11789. Vector3.transformCoordinate(OrientedBoundBox._corners[0],OrientedBoundBox._tempM0,OrientedBoundBox._corners[0]);
  11790. Vector3.transformCoordinate(OrientedBoundBox._corners[1],OrientedBoundBox._tempM0,OrientedBoundBox._corners[1]);
  11791. Vector3.transformCoordinate(OrientedBoundBox._corners[2],OrientedBoundBox._tempM0,OrientedBoundBox._corners[2]);
  11792. Vector3.transformCoordinate(OrientedBoundBox._corners[3],OrientedBoundBox._tempM0,OrientedBoundBox._corners[3]);
  11793. Vector3.transformCoordinate(OrientedBoundBox._corners[4],OrientedBoundBox._tempM0,OrientedBoundBox._corners[4]);
  11794. Vector3.transformCoordinate(OrientedBoundBox._corners[5],OrientedBoundBox._tempM0,OrientedBoundBox._corners[5]);
  11795. Vector3.transformCoordinate(OrientedBoundBox._corners[6],OrientedBoundBox._tempM0,OrientedBoundBox._corners[6]);
  11796. Vector3.transformCoordinate(OrientedBoundBox._corners[7],OrientedBoundBox._tempM0,OrientedBoundBox._corners[7]);
  11797. Vector3.scale(ae,-1,OrientedBoundBox._boxBound1.min);
  11798. ae.cloneTo(OrientedBoundBox._boxBound1.max);
  11799. BoundBox.createfromPoints(OrientedBoundBox._corners,OrientedBoundBox._boxBound2);
  11800. BoundBox.merge(OrientedBoundBox._boxBound2,OrientedBoundBox._boxBound1,OrientedBoundBox._boxBound3);
  11801. var box3Min=OrientedBoundBox._boxBound3.min;
  11802. var box3Max=OrientedBoundBox._boxBound3.max;
  11803. Vector3.subtract(box3Max,box3Min,OrientedBoundBox._tempV30);
  11804. Vector3.scale(OrientedBoundBox._tempV30,0.5,OrientedBoundBox._tempV30);
  11805. Vector3.add(box3Min,OrientedBoundBox._tempV30,OrientedBoundBox._tempV32);
  11806. Vector3.subtract(box3Max,OrientedBoundBox._tempV32,ae);
  11807. Vector3.transformCoordinate(OrientedBoundBox._tempV32,at,OrientedBoundBox._tempV33);
  11808. }
  11809. __static(OrientedBoundBox,
  11810. ['_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();}
  11811. ]);
  11812. return OrientedBoundBox;
  11813. })()
  11814. /**
  11815. *<code>AnimatorPlayState</code> 类用于创建动画播放状态信息。
  11816. */
  11817. //class laya.d3.component.AnimatorPlayState
  11818. var AnimatorPlayState=(function(){
  11819. function AnimatorPlayState(){
  11820. /**@private */
  11821. //this._finish=false;
  11822. /**@private */
  11823. //this._startPlayTime=NaN;
  11824. /**@private */
  11825. //this._lastElapsedTime=NaN;
  11826. /**@private */
  11827. //this._elapsedTime=NaN;
  11828. /**@private */
  11829. //this._normalizedTime=NaN;
  11830. /**@private */
  11831. //this._normalizedPlayTime=NaN;
  11832. /**@private */
  11833. //this._duration=NaN;
  11834. /**@private */
  11835. //this._playEventIndex=0;
  11836. /**@private */
  11837. //this._lastIsFront=false;
  11838. }
  11839. __class(AnimatorPlayState,'laya.d3.component.AnimatorPlayState');
  11840. var __proto=AnimatorPlayState.prototype;
  11841. /**
  11842. *@private
  11843. */
  11844. __proto._resetPlayState=function(startTime){
  11845. this._finish=false;
  11846. this._startPlayTime=startTime;
  11847. this._elapsedTime=startTime;
  11848. this._playEventIndex=0;
  11849. this._lastIsFront=true;
  11850. }
  11851. /**
  11852. *@private
  11853. */
  11854. __proto._cloneTo=function(dest){
  11855. dest._finish=this._finish;
  11856. dest._startPlayTime=this._startPlayTime;
  11857. dest._elapsedTime=this._elapsedTime;
  11858. dest._playEventIndex=this._playEventIndex;
  11859. dest._lastIsFront=this._lastIsFront;
  11860. }
  11861. /**
  11862. *获取播放状态的归一化时间,整数为循环次数,小数为单次播放时间。
  11863. */
  11864. __getset(0,__proto,'normalizedTime',function(){
  11865. return this._normalizedTime;
  11866. });
  11867. /**
  11868. *获取当前动画的持续时间,以秒为单位。
  11869. */
  11870. __getset(0,__proto,'duration',function(){
  11871. return this._duration;
  11872. });
  11873. return AnimatorPlayState;
  11874. })()
  11875. /**
  11876. *<code>SizeOverLifetime</code> 类用于粒子的生命周期尺寸。
  11877. */
  11878. //class laya.d3.core.particleShuriKen.module.SizeOverLifetime
  11879. var SizeOverLifetime=(function(){
  11880. function SizeOverLifetime(size){
  11881. /**@private */
  11882. this._size=null;
  11883. /**是否启用*/
  11884. this.enbale=false;
  11885. this._size=size;
  11886. }
  11887. __class(SizeOverLifetime,'laya.d3.core.particleShuriKen.module.SizeOverLifetime');
  11888. var __proto=SizeOverLifetime.prototype;
  11889. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  11890. /**
  11891. *克隆。
  11892. *@param destObject 克隆源。
  11893. */
  11894. __proto.cloneTo=function(destObject){
  11895. var destSizeOverLifetime=destObject;
  11896. this._size.cloneTo(destSizeOverLifetime._size);
  11897. destSizeOverLifetime.enbale=this.enbale;
  11898. }
  11899. /**
  11900. *克隆。
  11901. *@return 克隆副本。
  11902. */
  11903. __proto.clone=function(){
  11904. var destSize;
  11905. switch (this._size.type){
  11906. case 0:
  11907. if (this._size.separateAxes)
  11908. destSize=GradientSize.createByGradientSeparate(this._size.gradientX.clone(),this._size.gradientY.clone(),this._size.gradientZ.clone());
  11909. else
  11910. destSize=GradientSize.createByGradient(this._size.gradient.clone());
  11911. break ;
  11912. case 1:
  11913. if (this._size.separateAxes)
  11914. destSize=GradientSize.createByRandomTwoConstantSeparate(this._size.constantMinSeparate.clone(),this._size.constantMaxSeparate.clone());
  11915. else
  11916. destSize=GradientSize.createByRandomTwoConstant(this._size.constantMin,this._size.constantMax);
  11917. break ;
  11918. case 2:
  11919. if (this._size.separateAxes)
  11920. 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());
  11921. else
  11922. destSize=GradientSize.createByRandomTwoGradient(this._size.gradientMin.clone(),this._size.gradientMax.clone());
  11923. break ;
  11924. };
  11925. var destSizeOverLifetime=/*__JS__ */new this.constructor(destSize);
  11926. destSizeOverLifetime.enbale=this.enbale;
  11927. return destSizeOverLifetime;
  11928. }
  11929. /**
  11930. *获取尺寸。
  11931. */
  11932. __getset(0,__proto,'size',function(){
  11933. return this._size;
  11934. });
  11935. return SizeOverLifetime;
  11936. })()
  11937. /**
  11938. *<code>Bounds</code> 类用于创建包围体。
  11939. */
  11940. //class laya.d3.core.Bounds
  11941. var Bounds=(function(){
  11942. function Bounds(min,max){
  11943. /**@private */
  11944. this._updateFlag=0;
  11945. this._center=new Vector3();
  11946. this._extent=new Vector3();
  11947. this._boundBox=new BoundBox(new Vector3(),new Vector3());
  11948. min.cloneTo(this._boundBox.min);
  11949. max.cloneTo(this._boundBox.max);
  11950. this._setUpdateFlag(0x04 | 0x08,true);
  11951. }
  11952. __class(Bounds,'laya.d3.core.Bounds');
  11953. var __proto=Bounds.prototype;
  11954. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  11955. /**
  11956. *设置包围盒的最小点。
  11957. *@param value 包围盒的最小点。
  11958. */
  11959. __proto.setMin=function(value){
  11960. var min=this._boundBox.min;
  11961. if (value!==min)
  11962. value.cloneTo(min);
  11963. this._setUpdateFlag(0x04 | 0x08,true);
  11964. this._setUpdateFlag(0x01,false);
  11965. }
  11966. /**
  11967. *获取包围盒的最小点。
  11968. *@return 包围盒的最小点。
  11969. */
  11970. __proto.getMin=function(){
  11971. var min=this._boundBox.min;
  11972. if (this._getUpdateFlag(0x01)){
  11973. this._getMin(this.getCenter(),this.getExtent(),min);
  11974. this._setUpdateFlag(0x01,false);
  11975. }
  11976. return min;
  11977. }
  11978. /**
  11979. *设置包围盒的最大点。
  11980. *@param value 包围盒的最大点。
  11981. */
  11982. __proto.setMax=function(value){
  11983. var max=this._boundBox.max;
  11984. if (value!==max)
  11985. value.cloneTo(max);
  11986. this._setUpdateFlag(0x04 | 0x08,true);
  11987. this._setUpdateFlag(0x02,false);
  11988. }
  11989. /**
  11990. *获取包围盒的最大点。
  11991. *@return 包围盒的最大点。
  11992. */
  11993. __proto.getMax=function(){
  11994. var max=this._boundBox.max;
  11995. if (this._getUpdateFlag(0x02)){
  11996. this._getMax(this.getCenter(),this.getExtent(),max);
  11997. this._setUpdateFlag(0x02,false);
  11998. }
  11999. return max;
  12000. }
  12001. /**
  12002. *设置包围盒的中心点。
  12003. *@param value 包围盒的中心点。
  12004. */
  12005. __proto.setCenter=function(value){
  12006. if (value!==this._center)
  12007. value.cloneTo(this._center);
  12008. this._setUpdateFlag(0x01 | 0x02,true);
  12009. this._setUpdateFlag(0x04,false);
  12010. }
  12011. /**
  12012. *获取包围盒的中心点。
  12013. *@return 包围盒的中心点。
  12014. */
  12015. __proto.getCenter=function(){
  12016. if (this._getUpdateFlag(0x04)){
  12017. this._getCenter(this.getMin(),this.getMax(),this._center);
  12018. this._setUpdateFlag(0x04,false);
  12019. }
  12020. return this._center;
  12021. }
  12022. /**
  12023. *设置包围盒的范围。
  12024. *@param value 包围盒的范围。
  12025. */
  12026. __proto.setExtent=function(value){
  12027. if (value!==this._extent)
  12028. value.cloneTo(this._extent);
  12029. this._setUpdateFlag(0x01 | 0x02,true);
  12030. this._setUpdateFlag(0x08,false);
  12031. }
  12032. /**
  12033. *获取包围盒的范围。
  12034. *@return 包围盒的范围。
  12035. */
  12036. __proto.getExtent=function(){
  12037. if (this._getUpdateFlag(0x08)){
  12038. this._getExtent(this.getMin(),this.getMax(),this._extent);
  12039. this._setUpdateFlag(0x08,false);
  12040. }
  12041. return this._extent;
  12042. }
  12043. /**
  12044. *@private
  12045. */
  12046. __proto._getUpdateFlag=function(type){
  12047. return (this._updateFlag & type)!=0;
  12048. }
  12049. /**
  12050. *@private
  12051. */
  12052. __proto._setUpdateFlag=function(type,value){
  12053. if (value)
  12054. this._updateFlag |=type;
  12055. else
  12056. this._updateFlag &=~type;
  12057. }
  12058. /**
  12059. *@private
  12060. */
  12061. __proto._getCenter=function(min,max,out){
  12062. Vector3.add(min,max,out);
  12063. Vector3.scale(out,0.5,out);
  12064. }
  12065. /**
  12066. *@private
  12067. */
  12068. __proto._getExtent=function(min,max,out){
  12069. Vector3.subtract(max,min,out);
  12070. Vector3.scale(out,0.5,out);
  12071. }
  12072. /**
  12073. *@private
  12074. */
  12075. __proto._getMin=function(center,extent,out){
  12076. Vector3.subtract(center,extent,out);
  12077. }
  12078. /**
  12079. *@private
  12080. */
  12081. __proto._getMax=function(center,extent,out){
  12082. Vector3.add(center,extent,out);
  12083. }
  12084. /**
  12085. *@private
  12086. */
  12087. __proto._rotateExtents=function(extents,rotation,out){
  12088. var extentsX=extents.x;
  12089. var extentsY=extents.y;
  12090. var extentsZ=extents.z;
  12091. var matE=rotation.elements;
  12092. out.x=Math.abs(matE[0] *extentsX)+Math.abs(matE[4] *extentsY)+Math.abs(matE[8] *extentsZ);
  12093. out.y=Math.abs(matE[1] *extentsX)+Math.abs(matE[5] *extentsY)+Math.abs(matE[9] *extentsZ);
  12094. out.z=Math.abs(matE[2] *extentsX)+Math.abs(matE[6] *extentsY)+Math.abs(matE[10] *extentsZ);
  12095. }
  12096. /**
  12097. *@private
  12098. */
  12099. __proto._tranform=function(matrix,out){
  12100. var outCen=out._center;
  12101. var outExt=out._extent;
  12102. Vector3.transformCoordinate(this.getCenter(),matrix,outCen);
  12103. this._rotateExtents(this.getExtent(),matrix,outExt);
  12104. out._boundBox.setCenterAndExtent(outCen,outExt);
  12105. out._updateFlag=0;
  12106. }
  12107. /**
  12108. *@private
  12109. */
  12110. __proto._getBoundBox=function(){
  12111. var min=this._boundBox.min;
  12112. if (this._getUpdateFlag(0x01)){
  12113. this._getMin(this.getCenter(),this.getExtent(),min);
  12114. this._setUpdateFlag(0x01,false);
  12115. };
  12116. var max=this._boundBox.max;
  12117. if (this._getUpdateFlag(0x02)){
  12118. this._getMax(this.getCenter(),this.getExtent(),max);
  12119. this._setUpdateFlag(0x02,false);
  12120. }
  12121. return this._boundBox;
  12122. }
  12123. /**
  12124. *克隆。
  12125. *@param destObject 克隆源。
  12126. */
  12127. __proto.cloneTo=function(destObject){
  12128. var destBounds=destObject;
  12129. this.getMin().cloneTo(destBounds._boundBox.min);
  12130. this.getMax().cloneTo(destBounds._boundBox.max);
  12131. this.getCenter().cloneTo(destBounds._center);
  12132. this.getExtent().cloneTo(destBounds._extent);
  12133. destBounds._updateFlag=0;
  12134. }
  12135. /**
  12136. *克隆。
  12137. *@return 克隆副本。
  12138. */
  12139. __proto.clone=function(){
  12140. var dest=/*__JS__ */new this.constructor();
  12141. this.cloneTo(dest);
  12142. return dest;
  12143. }
  12144. Bounds._UPDATE_MIN=0x01;
  12145. Bounds._UPDATE_MAX=0x02;
  12146. Bounds._UPDATE_CENTER=0x04;
  12147. Bounds._UPDATE_EXTENT=0x08;
  12148. return Bounds;
  12149. })()
  12150. /**
  12151. *@private
  12152. */
  12153. //class laya.d3.shader.ShaderData
  12154. var ShaderData=(function(){
  12155. function ShaderData(ownerResource){
  12156. /**@private */
  12157. this._ownerResource=null;
  12158. /**@private */
  12159. this._data=null;
  12160. /**@private [NATIVE]*/
  12161. this._int32Data=null;
  12162. /**@private [NATIVE]*/
  12163. this._float32Data=null;
  12164. /**@private [NATIVE]*/
  12165. this._nativeArray=null;
  12166. /**@private [NATIVE]*/
  12167. this._frameCount=0;
  12168. /**@private [NATIVE]*/
  12169. this._runtimeCopyValues=[];
  12170. this._ownerResource=ownerResource;
  12171. this._initData();
  12172. }
  12173. __class(ShaderData,'laya.d3.shader.ShaderData');
  12174. var __proto=ShaderData.prototype;
  12175. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  12176. /**
  12177. *@private
  12178. */
  12179. __proto._initData=function(){
  12180. this._data=new Object();
  12181. }
  12182. /**
  12183. *@private
  12184. */
  12185. __proto.getData=function(){
  12186. return this._data;
  12187. }
  12188. /**
  12189. *获取布尔。
  12190. *@param index shader索引。
  12191. *@return 布尔。
  12192. */
  12193. __proto.getBool=function(index){
  12194. return this._data[index];
  12195. }
  12196. /**
  12197. *设置布尔。
  12198. *@param index shader索引。
  12199. *@param value 布尔。
  12200. */
  12201. __proto.setBool=function(index,value){
  12202. this._data[index]=value;
  12203. }
  12204. /**
  12205. *获取整形。
  12206. *@param index shader索引。
  12207. *@return 整形。
  12208. */
  12209. __proto.getInt=function(index){
  12210. return this._data[index];
  12211. }
  12212. /**
  12213. *设置整型。
  12214. *@param index shader索引。
  12215. *@param value 整形。
  12216. */
  12217. __proto.setInt=function(index,value){
  12218. this._data[index]=value;
  12219. }
  12220. /**
  12221. *获取浮点。
  12222. *@param index shader索引。
  12223. *@return 浮点。
  12224. */
  12225. __proto.getNumber=function(index){
  12226. return this._data[index];
  12227. }
  12228. /**
  12229. *设置浮点。
  12230. *@param index shader索引。
  12231. *@param value 浮点。
  12232. */
  12233. __proto.setNumber=function(index,value){
  12234. this._data[index]=value;
  12235. }
  12236. /**
  12237. *获取Vector2向量。
  12238. *@param index shader索引。
  12239. *@return Vector2向量。
  12240. */
  12241. __proto.getVector2=function(index){
  12242. return this._data[index];
  12243. }
  12244. /**
  12245. *设置Vector2向量。
  12246. *@param index shader索引。
  12247. *@param value Vector2向量。
  12248. */
  12249. __proto.setVector2=function(index,value){
  12250. this._data[index]=value;
  12251. }
  12252. /**
  12253. *获取Vector3向量。
  12254. *@param index shader索引。
  12255. *@return Vector3向量。
  12256. */
  12257. __proto.getVector3=function(index){
  12258. return this._data[index];
  12259. }
  12260. /**
  12261. *设置Vector3向量。
  12262. *@param index shader索引。
  12263. *@param value Vector3向量。
  12264. */
  12265. __proto.setVector3=function(index,value){
  12266. this._data[index]=value;
  12267. }
  12268. /**
  12269. *获取颜色。
  12270. *@param index shader索引。
  12271. *@return 颜色向量。
  12272. */
  12273. __proto.getVector=function(index){
  12274. return this._data[index];
  12275. }
  12276. /**
  12277. *设置向量。
  12278. *@param index shader索引。
  12279. *@param value 向量。
  12280. */
  12281. __proto.setVector=function(index,value){
  12282. this._data[index]=value;
  12283. }
  12284. /**
  12285. *获取四元数。
  12286. *@param index shader索引。
  12287. *@return 四元。
  12288. */
  12289. __proto.getQuaternion=function(index){
  12290. return this._data[index];
  12291. }
  12292. /**
  12293. *设置四元数。
  12294. *@param index shader索引。
  12295. *@param value 四元数。
  12296. */
  12297. __proto.setQuaternion=function(index,value){
  12298. this._data[index]=value;
  12299. }
  12300. /**
  12301. *获取矩阵。
  12302. *@param index shader索引。
  12303. *@return 矩阵。
  12304. */
  12305. __proto.getMatrix4x4=function(index){
  12306. return this._data[index];
  12307. }
  12308. /**
  12309. *设置矩阵。
  12310. *@param index shader索引。
  12311. *@param value 矩阵。
  12312. */
  12313. __proto.setMatrix4x4=function(index,value){
  12314. this._data[index]=value;
  12315. }
  12316. /**
  12317. *获取Buffer。
  12318. *@param index shader索引。
  12319. *@return
  12320. */
  12321. __proto.getBuffer=function(shaderIndex){
  12322. return this._data[shaderIndex];
  12323. }
  12324. /**
  12325. *设置Buffer。
  12326. *@param index shader索引。
  12327. *@param value buffer数据。
  12328. */
  12329. __proto.setBuffer=function(index,value){
  12330. this._data[index]=value;
  12331. }
  12332. /**
  12333. *设置纹理。
  12334. *@param index shader索引。
  12335. *@param value 纹理。
  12336. */
  12337. __proto.setTexture=function(index,value){
  12338. var lastValue=this._data[index];
  12339. this._data[index]=value;
  12340. if (this._ownerResource && this._ownerResource.referenceCount > 0){
  12341. (lastValue)&& (lastValue._removeReference());
  12342. (value)&& (value._addReference());
  12343. }
  12344. }
  12345. /**
  12346. *获取纹理。
  12347. *@param index shader索引。
  12348. *@return 纹理。
  12349. */
  12350. __proto.getTexture=function(index){
  12351. return this._data[index];
  12352. }
  12353. /**
  12354. *设置Attribute。
  12355. *@param index shader索引。
  12356. *@param value 纹理。
  12357. */
  12358. __proto.setAttribute=function(index,value){
  12359. this._data[index]=value;
  12360. }
  12361. /**
  12362. *获取Attribute。
  12363. *@param index shader索引。
  12364. *@return 纹理。
  12365. */
  12366. __proto.getAttribute=function(index){
  12367. return this._data[index];
  12368. }
  12369. /**
  12370. *获取长度。
  12371. *@return 长度。
  12372. */
  12373. __proto.getLength=function(){
  12374. return this._data.length;
  12375. }
  12376. /**
  12377. *设置长度。
  12378. *@param 长度。
  12379. */
  12380. __proto.setLength=function(value){
  12381. this._data.length=value;
  12382. }
  12383. /**
  12384. *克隆。
  12385. *@param destObject 克隆源。
  12386. */
  12387. __proto.cloneTo=function(destObject){
  12388. var dest=destObject;
  12389. var destData=dest._data;
  12390. for (var k in this._data){
  12391. var value=this._data[k];
  12392. if (value !=null){
  12393. if ((typeof value=='number')){
  12394. destData[k]=value;
  12395. }else if (((typeof value=='number')&& Math.floor(value)==value)){
  12396. destData[k]=value;
  12397. }else if ((typeof value=='boolean')){
  12398. destData[k]=value;
  12399. }else if ((value instanceof laya.d3.math.Vector2 )){
  12400. var v2=(destData[k])|| (destData[k]=new Vector2());
  12401. (value).cloneTo(v2);
  12402. destData[k]=v2;
  12403. }else if ((value instanceof laya.d3.math.Vector3 )){
  12404. var v3=(destData[k])|| (destData[k]=new Vector3());
  12405. (value).cloneTo(v3);
  12406. destData[k]=v3;
  12407. }else if ((value instanceof laya.d3.math.Vector4 )){
  12408. var v4=(destData[k])|| (destData[k]=new Vector4());
  12409. (value).cloneTo(v4);
  12410. destData[k]=v4;
  12411. }else if ((value instanceof laya.d3.math.Matrix4x4 )){
  12412. var mat=(destData[k])|| (destData[k]=new Matrix4x4());
  12413. (value).cloneTo(mat);
  12414. destData[k]=mat;
  12415. }else if ((value instanceof laya.resource.BaseTexture )){
  12416. destData[k]=value;
  12417. }
  12418. }
  12419. }
  12420. }
  12421. /**
  12422. *克隆。
  12423. *@return 克隆副本。
  12424. */
  12425. __proto.clone=function(){
  12426. var dest=/*__JS__ */new this.constructor();
  12427. this.cloneTo(dest);
  12428. return dest;
  12429. }
  12430. /**
  12431. *克隆。
  12432. *@param destObject 克隆源。
  12433. */
  12434. __proto.cloneToForNative=function(destObject){
  12435. var dest=destObject;
  12436. var diffSize=this._int32Data.length-dest._int32Data.length;
  12437. if (diffSize > 0){
  12438. dest.needRenewArrayBufferForNative(this._int32Data.length);
  12439. }
  12440. dest._int32Data.set(this._int32Data,0);
  12441. var destData=dest._nativeArray;
  12442. var dataCount=this._nativeArray.length;
  12443. destData.length=dataCount;
  12444. for (var i=0;i < dataCount;i++){
  12445. var value=this._nativeArray[i];
  12446. if (value){
  12447. if ((typeof value=='number')){
  12448. destData[i]=value;
  12449. dest.setNumber(i,value);
  12450. }else if (((typeof value=='number')&& Math.floor(value)==value)){
  12451. destData[i]=value;
  12452. dest.setInt(i,value);
  12453. }else if ((typeof value=='boolean')){
  12454. destData[i]=value;
  12455. dest.setBool(i,value);
  12456. }else if ((value instanceof laya.d3.math.Vector2 )){
  12457. var v2=(destData[i])|| (destData[i]=new Vector2());
  12458. (value).cloneTo(v2);
  12459. destData[i]=v2;
  12460. dest.setVector2(i,v2);
  12461. }else if ((value instanceof laya.d3.math.Vector3 )){
  12462. var v3=(destData[i])|| (destData[i]=new Vector3());
  12463. (value).cloneTo(v3);
  12464. destData[i]=v3;
  12465. dest.setVector3(i,v3);
  12466. }else if ((value instanceof laya.d3.math.Vector4 )){
  12467. var v4=(destData[i])|| (destData[i]=new Vector4());
  12468. (value).cloneTo(v4);
  12469. destData[i]=v4;
  12470. dest.setVector(i,v4);
  12471. }else if ((value instanceof laya.d3.math.Matrix4x4 )){
  12472. var mat=(destData[i])|| (destData[i]=new Matrix4x4());
  12473. (value).cloneTo(mat);
  12474. destData[i]=mat;
  12475. dest.setMatrix4x4(i,mat);
  12476. }else if ((value instanceof laya.resource.BaseTexture )){
  12477. destData[i]=value;
  12478. dest.setTexture(i,value);
  12479. }
  12480. }
  12481. }
  12482. }
  12483. /**
  12484. *@private [NATIVE]
  12485. */
  12486. __proto._initDataForNative=function(){
  12487. var length=8;
  12488. if (!length){
  12489. alert("ShaderData _initDataForNative error length=0");
  12490. }
  12491. this._frameCount=-1;
  12492. this._runtimeCopyValues.length=0;
  12493. this._nativeArray=[];
  12494. this._data=new ArrayBuffer(length *4);
  12495. this._int32Data=new Int32Array(this._data);
  12496. this._float32Data=new Float32Array(this._data);
  12497. LayaGL.createArrayBufferRef(this._data,/*laya.layagl.LayaGL.ARRAY_BUFFER_TYPE_DATA*/0,true);
  12498. }
  12499. __proto.needRenewArrayBufferForNative=function(index){
  12500. if (index >=this._int32Data.length){
  12501. var nByteLen=(index+1)*4;
  12502. var pre=this._int32Data;
  12503. var preConchRef=this._data["conchRef"];
  12504. var prePtrID=this._data["_ptrID"];
  12505. this._data=new ArrayBuffer(nByteLen);
  12506. this._int32Data=new Int32Array(this._data);
  12507. this._float32Data=new Float32Array(this._data);
  12508. this._data["conchRef"]=preConchRef;
  12509. this._data["_ptrID"]=prePtrID;
  12510. pre && this._int32Data.set(pre,0);
  12511. /*__JS__ */conch.updateArrayBufferRef(this._data['_ptrID'],preConchRef.isSyncToRender(),this._data);
  12512. }
  12513. }
  12514. __proto.getDataForNative=function(){
  12515. return this._nativeArray;
  12516. }
  12517. /**
  12518. *@private [NATIVE]
  12519. */
  12520. __proto.getIntForNative=function(index){
  12521. return this._int32Data[index];
  12522. }
  12523. /**
  12524. *@private [NATIVE]
  12525. */
  12526. __proto.setIntForNative=function(index,value){
  12527. this.needRenewArrayBufferForNative(index);
  12528. this._int32Data[index]=value;
  12529. this._nativeArray[index]=value;
  12530. }
  12531. /**
  12532. *@private [NATIVE]
  12533. */
  12534. __proto.getBoolForNative=function(index){
  12535. return this._int32Data[index]==1;
  12536. }
  12537. /**
  12538. *@private [NATIVE]
  12539. */
  12540. __proto.setBoolForNative=function(index,value){
  12541. this.needRenewArrayBufferForNative(index);
  12542. this._int32Data[index]=value;
  12543. this._nativeArray[index]=value;
  12544. }
  12545. /**
  12546. *@private [NATIVE]
  12547. */
  12548. __proto.getNumberForNative=function(index){
  12549. return this._float32Data[index];
  12550. }
  12551. /**
  12552. *@private [NATIVE]
  12553. */
  12554. __proto.setNumberForNative=function(index,value){
  12555. this.needRenewArrayBufferForNative(index);
  12556. this._float32Data[index]=value;
  12557. this._nativeArray[index]=value;
  12558. }
  12559. /**
  12560. *@private [NATIVE]
  12561. */
  12562. __proto.getMatrix4x4ForNative=function(index){
  12563. return this._nativeArray[index];
  12564. }
  12565. /**
  12566. *@private [NATIVE]
  12567. */
  12568. __proto.setMatrix4x4ForNative=function(index,value){
  12569. this.needRenewArrayBufferForNative(index);
  12570. this._nativeArray[index]=value;
  12571. var nPtrID=this.setReferenceForNative(value.elements);
  12572. this._int32Data[index]=nPtrID;
  12573. }
  12574. /**
  12575. *@private [NATIVE]
  12576. */
  12577. __proto.getVectorForNative=function(index){
  12578. return this._nativeArray[index];
  12579. }
  12580. /**
  12581. *@private [NATIVE]
  12582. */
  12583. __proto.setVectorForNative=function(index,value){
  12584. this.needRenewArrayBufferForNative(index);
  12585. this._nativeArray[index]=value;
  12586. if (!value.elements){
  12587. value.forNativeElement();
  12588. };
  12589. var nPtrID=this.setReferenceForNative(value.elements);
  12590. this._int32Data[index]=nPtrID;
  12591. }
  12592. /**
  12593. *@private [NATIVE]
  12594. */
  12595. __proto.getVector2ForNative=function(index){
  12596. return this._nativeArray[index];
  12597. }
  12598. /**
  12599. *@private [NATIVE]
  12600. */
  12601. __proto.setVector2ForNative=function(index,value){
  12602. this.needRenewArrayBufferForNative(index);
  12603. this._nativeArray[index]=value;
  12604. if (!value.elements){
  12605. value.forNativeElement();
  12606. };
  12607. var nPtrID=this.setReferenceForNative(value.elements);
  12608. this._int32Data[index]=nPtrID;
  12609. }
  12610. /**
  12611. *@private [NATIVE]
  12612. */
  12613. __proto.getVector3ForNative=function(index){
  12614. return this._nativeArray[index];
  12615. }
  12616. /**
  12617. *@private [NATIVE]
  12618. */
  12619. __proto.setVector3ForNative=function(index,value){
  12620. this.needRenewArrayBufferForNative(index);
  12621. this._nativeArray[index]=value;
  12622. if (!value.elements){
  12623. value.forNativeElement();
  12624. };
  12625. var nPtrID=this.setReferenceForNative(value.elements);
  12626. this._int32Data[index]=nPtrID;
  12627. }
  12628. /**
  12629. *@private [NATIVE]
  12630. */
  12631. __proto.getQuaternionForNative=function(index){
  12632. return this._nativeArray[index];
  12633. }
  12634. /**
  12635. *@private [NATIVE]
  12636. */
  12637. __proto.setQuaternionForNative=function(index,value){
  12638. this.needRenewArrayBufferForNative(index);
  12639. this._nativeArray[index]=value;
  12640. if (!value.elements){
  12641. value.forNativeElement();
  12642. };
  12643. var nPtrID=this.setReferenceForNative(value.elements);
  12644. this._int32Data[index]=nPtrID;
  12645. }
  12646. /**
  12647. *@private [NATIVE]
  12648. */
  12649. __proto.getBufferForNative=function(shaderIndex){
  12650. return this._nativeArray[shaderIndex];
  12651. }
  12652. /**
  12653. *@private [NATIVE]
  12654. */
  12655. __proto.setBufferForNative=function(index,value){
  12656. this.needRenewArrayBufferForNative(index);
  12657. this._nativeArray[index]=value;
  12658. var nPtrID=this.setReferenceForNative(value);
  12659. this._int32Data[index]=nPtrID;
  12660. }
  12661. /**
  12662. *@private [NATIVE]
  12663. */
  12664. __proto.getAttributeForNative=function(index){
  12665. return this._nativeArray[index];
  12666. }
  12667. /**
  12668. *@private [NATIVE]
  12669. */
  12670. __proto.setAttributeForNative=function(index,value){
  12671. this._nativeArray[index]=value;
  12672. if (!value["_ptrID"]){
  12673. LayaGL.createArrayBufferRef(value,/*laya.layagl.LayaGL.ARRAY_BUFFER_TYPE_DATA*/0,true);
  12674. }
  12675. LayaGL.syncBufferToRenderThread(value);
  12676. this._int32Data[index]=value["_ptrID"];
  12677. }
  12678. /**
  12679. *@private [NATIVE]
  12680. */
  12681. __proto.getTextureForNative=function(index){
  12682. return this._nativeArray[index];
  12683. }
  12684. /**
  12685. *@private [NATIVE]
  12686. */
  12687. __proto.setTextureForNative=function(index,value){
  12688. if (!value)return;
  12689. this.needRenewArrayBufferForNative(index);
  12690. var lastValue=this._nativeArray[index];
  12691. this._nativeArray[index]=value;
  12692. this._int32Data[index]=(value)._glTexture.id;
  12693. if (this._ownerResource && this._ownerResource.referenceCount > 0){
  12694. (lastValue)&& (lastValue._removeReference());
  12695. (value)&& (value._addReference());
  12696. }
  12697. }
  12698. __proto.setReferenceForNative=function(value){
  12699. this.clearRuntimeCopyArray();
  12700. var nRefID=0;
  12701. var nPtrID=0;
  12702. if (ShaderData._SET_RUNTIME_VALUE_MODE_REFERENCE_){
  12703. LayaGL.createArrayBufferRefs(value,/*laya.layagl.LayaGL.ARRAY_BUFFER_TYPE_DATA*/0,true,/*laya.layagl.LayaGL.ARRAY_BUFFER_REF_REFERENCE*/0);
  12704. nRefID=0;
  12705. nPtrID=value.getPtrID(nRefID);
  12706. }else {
  12707. LayaGL.createArrayBufferRefs(value,/*laya.layagl.LayaGL.ARRAY_BUFFER_TYPE_DATA*/0,true,/*laya.layagl.LayaGL.ARRAY_BUFFER_REF_COPY*/1);
  12708. nRefID=value.getRefNum()-1;
  12709. nPtrID=value.getPtrID(nRefID);
  12710. this._runtimeCopyValues.push({"obj":value,"refID":nRefID,"ptrID":nPtrID});
  12711. }
  12712. LayaGL.syncBufferToRenderThread(value,nRefID);
  12713. return nPtrID;
  12714. }
  12715. __proto.clearRuntimeCopyArray=function(){
  12716. var currentFrame=LayaGL.getFrameCount();
  12717. if (this._frameCount !=currentFrame){
  12718. this._frameCount=currentFrame;
  12719. for (var i=0,n=this._runtimeCopyValues.length;i < n;i++){
  12720. var obj=this._runtimeCopyValues[i];
  12721. obj.obj.clearRefNum();
  12722. }
  12723. this._runtimeCopyValues.length=0;
  12724. }
  12725. }
  12726. ShaderData.setRuntimeValueMode=function(bReference){
  12727. ShaderData._SET_RUNTIME_VALUE_MODE_REFERENCE_=bReference;
  12728. }
  12729. ShaderData._SET_RUNTIME_VALUE_MODE_REFERENCE_=true;
  12730. return ShaderData;
  12731. })()
  12732. /**
  12733. *@private
  12734. *<code>RenderElement</code> 类用于实现渲染元素。
  12735. */
  12736. //class laya.d3.core.render.RenderElement
  12737. var RenderElement=(function(){
  12738. function RenderElement(){
  12739. /**@private */
  12740. //this._transform=null;
  12741. /**@private */
  12742. //this._geometry=null;
  12743. /**@private */
  12744. //this.material=null;
  12745. /**@private */
  12746. //this.render=null;
  12747. /**@private */
  12748. //this.staticBatch=null;
  12749. this.renderType=/*CLASS CONST:laya.d3.core.render.RenderElement.RENDERTYPE_NORMAL*/0;
  12750. }
  12751. __class(RenderElement,'laya.d3.core.render.RenderElement');
  12752. var __proto=RenderElement.prototype;
  12753. /**
  12754. *@private
  12755. */
  12756. __proto.setTransform=function(transform){
  12757. this._transform=transform;
  12758. }
  12759. /**
  12760. *@private
  12761. */
  12762. __proto.setGeometry=function(geometry){
  12763. this._geometry=geometry;
  12764. }
  12765. /**
  12766. *@private
  12767. */
  12768. __proto.addToOpaqueRenderQueue=function(context,queue){
  12769. queue.elements.push(this);
  12770. }
  12771. /**
  12772. *@private
  12773. */
  12774. __proto.addToTransparentRenderQueue=function(context,queue){
  12775. queue.elements.push(this);
  12776. queue.lastTransparentBatched=false;
  12777. queue.lastTransparentRenderElement=this;
  12778. }
  12779. /**
  12780. *@private
  12781. */
  12782. __proto._render=function(context,isTarget,customShader,replacementTag){
  12783. var lastStateMaterial,lastStateShaderInstance,lastStateRender;
  12784. var updateMark=Camera._updateMark;
  12785. var scene=context.scene;
  12786. var camera=context.camera;
  12787. var transform=this._transform;
  12788. var geometry=this._geometry;
  12789. context.renderElement=this;
  12790. var updateRender=updateMark!==this.render._updateMark || this.renderType!==this.render._updateRenderType;
  12791. if (updateRender){
  12792. this.render._renderUpdate(context,transform);
  12793. this.render._renderUpdateWithCamera(context,transform);
  12794. this.render._updateMark=updateMark;
  12795. this.render._updateRenderType=this.renderType;
  12796. }
  12797. if (geometry._prepareRender(context)){
  12798. var subShader=this.material._shader.getSubShaderAt(0);
  12799. var passes;
  12800. if (customShader){
  12801. if (replacementTag){
  12802. var oriTag=subShader.getFlag(replacementTag);
  12803. if (oriTag){
  12804. var customSubShaders=customShader._subShaders;
  12805. for (var k=0,p=customSubShaders.length;k < p;k++){
  12806. var customSubShader=customSubShaders[k];
  12807. if (oriTag===customSubShader.getFlag(replacementTag)){
  12808. passes=customSubShader._passes;
  12809. break ;
  12810. }
  12811. }
  12812. if (!passes)
  12813. return;
  12814. }else {
  12815. return;
  12816. }
  12817. }else {
  12818. passes=customShader.getSubShaderAt(0)._passes;
  12819. }
  12820. }else {
  12821. passes=subShader._passes;
  12822. }
  12823. for (var j=0,m=passes.length;j < m;j++){
  12824. var shaderPass=context.shader=passes[j].withCompile((scene._defineDatas.value)& (~this.material._disablePublicDefineDatas.value),this.render._defineDatas.value,this.material._defineDatas.value);
  12825. var switchShader=shaderPass.bind();
  12826. var switchUpdateMark=(updateMark!==shaderPass._uploadMark);
  12827. var uploadScene=(shaderPass._uploadScene!==scene)|| switchUpdateMark;
  12828. if (uploadScene || switchShader){
  12829. shaderPass.uploadUniforms(shaderPass._sceneUniformParamsMap,scene._shaderValues,uploadScene);
  12830. shaderPass._uploadScene=scene;
  12831. };
  12832. var uploadSprite3D=(shaderPass._uploadRender!==this.render || shaderPass._uploadRenderType!==this.renderType)|| switchUpdateMark;
  12833. if (uploadSprite3D || switchShader){
  12834. shaderPass.uploadUniforms(shaderPass._spriteUniformParamsMap,this.render._shaderValues,uploadSprite3D);
  12835. shaderPass._uploadRender=this.render;
  12836. shaderPass._uploadRenderType=this.renderType;
  12837. };
  12838. var uploadCamera=shaderPass._uploadCamera!==camera || switchUpdateMark;
  12839. if (uploadCamera || switchShader){
  12840. shaderPass.uploadUniforms(shaderPass._cameraUniformParamsMap,camera._shaderValues,uploadCamera);
  12841. shaderPass._uploadCamera=camera;
  12842. };
  12843. var uploadMaterial=(shaderPass._uploadMaterial!==this.material)|| switchUpdateMark;
  12844. if (uploadMaterial || switchShader){
  12845. shaderPass.uploadUniforms(shaderPass._materialUniformParamsMap,this.material._shaderValues,uploadMaterial);
  12846. shaderPass._uploadMaterial=this.material;
  12847. };
  12848. var matValues=this.material._shaderValues;
  12849. if (lastStateMaterial!==this.material||lastStateShaderInstance!==shaderPass){
  12850. shaderPass.uploadRenderStateBlendDepth(matValues);
  12851. shaderPass.uploadRenderStateFrontFace(matValues,isTarget,transform);
  12852. lastStateMaterial=this.material;
  12853. lastStateShaderInstance=shaderPass;
  12854. lastStateRender=this.render;
  12855. }else {
  12856. if (lastStateRender!==this.render){
  12857. shaderPass.uploadRenderStateFrontFace(matValues,isTarget,transform);
  12858. lastStateRender=this.render;
  12859. }
  12860. }
  12861. geometry._render(context);
  12862. shaderPass._uploadMark=updateMark;
  12863. }
  12864. }
  12865. if (updateRender && this.renderType!==/*CLASS CONST:laya.d3.core.render.RenderElement.RENDERTYPE_NORMAL*/0)
  12866. this.render._revertBatchRenderUpdate(context);
  12867. Camera._updateMark++;
  12868. }
  12869. /**
  12870. *@private
  12871. */
  12872. __proto.destroy=function(){
  12873. this._transform=null;
  12874. this._geometry=null;
  12875. this.material=null;
  12876. this.render=null;
  12877. }
  12878. RenderElement.RENDERTYPE_NORMAL=0;
  12879. RenderElement.RENDERTYPE_STATICBATCH=1;
  12880. RenderElement.RENDERTYPE_INSTANCEBATCH=2;
  12881. RenderElement.RENDERTYPE_VERTEXBATCH=3;
  12882. return RenderElement;
  12883. })()
  12884. /**
  12885. *...
  12886. *@author ...
  12887. */
  12888. //class laya.d3.physics.Constraint3D
  12889. var Constraint3D=(function(){
  12890. function Constraint3D(){
  12891. /**@private */
  12892. this._nativeConstraint=null;
  12893. /**@private */
  12894. this._simulation=null;
  12895. /**获取刚体A。[只读]*/
  12896. this.rigidbodyA=null;
  12897. /**获取刚体A。[只读]*/
  12898. this.rigidbodyB=null;
  12899. }
  12900. __class(Constraint3D,'laya.d3.physics.Constraint3D');
  12901. return Constraint3D;
  12902. })()
  12903. /**
  12904. *<code>AnimatorStateScript</code> 类用于动画状态脚本的父类,该类为抽象类,不允许实例。
  12905. */
  12906. //class laya.d3.animation.AnimatorStateScript
  12907. var AnimatorStateScript=(function(){
  12908. /**
  12909. *创建一个新的 <code>AnimatorStateScript</code> 实例。
  12910. */
  12911. function AnimatorStateScript(){}
  12912. __class(AnimatorStateScript,'laya.d3.animation.AnimatorStateScript');
  12913. var __proto=AnimatorStateScript.prototype;
  12914. /**
  12915. *动画状态开始时执行。
  12916. */
  12917. __proto.onStateEnter=function(){}
  12918. /**
  12919. *动画状态更新时执行。
  12920. */
  12921. __proto.onStateUpdate=function(){}
  12922. /**
  12923. *动画状态退出时执行。
  12924. */
  12925. __proto.onStateExit=function(){}
  12926. return AnimatorStateScript;
  12927. })()
  12928. /**
  12929. *...
  12930. *@author
  12931. */
  12932. //class laya.d3.resource.TextureGenerator
  12933. var TextureGenerator=(function(){
  12934. function TextureGenerator(){}
  12935. __class(TextureGenerator,'laya.d3.resource.TextureGenerator');
  12936. TextureGenerator.lightAttenTexture=function(x,y,maxX,maxY,index,data){
  12937. var sqrRange=x / maxX;
  12938. var atten=1.0 / (1.0+25.0 *sqrRange);
  12939. if (sqrRange >=0.64){
  12940. if (sqrRange > 1.0){
  12941. atten=0;
  12942. }else {
  12943. atten *=1-(sqrRange-0.64)/ (1-0.64);
  12944. }
  12945. }
  12946. data[index]=Math.floor(atten *255.0+0.5);
  12947. }
  12948. TextureGenerator.haloTexture=function(x,y,maxX,maxY,index,data){
  12949. maxX >>=1;
  12950. maxY >>=1;
  12951. var xFac=(x-maxX)/ maxX;
  12952. var yFac=(y-maxY)/ maxY;
  12953. var sqrRange=xFac *xFac+yFac *yFac;
  12954. if (sqrRange > 1.0){
  12955. sqrRange=1.0;
  12956. }
  12957. data[index]=Math.floor((1.0-sqrRange)*255.0+0.5);
  12958. }
  12959. TextureGenerator._generateTexture2D=function(texture,textureWidth,textureHeight,func){
  12960. var index=0;
  12961. var size=0;
  12962. switch (texture.format){
  12963. case /*laya.resource.BaseTexture.FORMAT_R8G8B8*/0:
  12964. size=3;
  12965. break ;
  12966. case /*laya.resource.BaseTexture.FORMAT_R8G8B8A8*/1:
  12967. size=4;
  12968. break ;
  12969. case /*laya.resource.BaseTexture.FORMAT_ALPHA8*/2:
  12970. size=1;
  12971. break ;
  12972. default :
  12973. throw "GeneratedTexture._generateTexture: unkonw texture format.";
  12974. };
  12975. var data=new Uint8Array(textureWidth *textureHeight *size);
  12976. for (var y=0;y < textureHeight;y++){
  12977. for (var x=0;x < textureWidth;x++){
  12978. func(x,y,textureWidth,textureHeight,index,data);
  12979. index+=size;
  12980. }
  12981. }
  12982. texture.setPixels(data);
  12983. }
  12984. return TextureGenerator;
  12985. })()
  12986. /**
  12987. *<code>CommandBuffer</code> 类用于创建命令流。
  12988. */
  12989. //class laya.d3.core.render.command.CommandBuffer
  12990. var CommandBuffer=(function(){
  12991. function CommandBuffer(){
  12992. this._commands=[];
  12993. }
  12994. __class(CommandBuffer,'laya.d3.core.render.command.CommandBuffer');
  12995. var __proto=CommandBuffer.prototype;
  12996. /**
  12997. *@private
  12998. */
  12999. __proto._apply=function(){
  13000. for (var i=0,n=this._commands.length;i < n;i++)
  13001. this._commands[i].run();
  13002. }
  13003. /**
  13004. *@private
  13005. */
  13006. __proto.setShaderDataTexture=function(shaderData,nameID,source){
  13007. this._commands.push(SetShaderDataTextureCMD.create(shaderData,nameID,source));
  13008. }
  13009. /**
  13010. *@private
  13011. */
  13012. __proto.blit=function(source,dest,shader,shaderData,subShader){
  13013. (subShader===void 0)&& (subShader=0);
  13014. this._commands.push(BlitCMD.create(source,dest,shader,shaderData,subShader));
  13015. }
  13016. /**
  13017. *@private
  13018. */
  13019. __proto.setRenderTarget=function(renderTexture){
  13020. this._commands.push(SetRenderTargetCMD.create(renderTexture));
  13021. }
  13022. /**
  13023. *@private
  13024. */
  13025. __proto.clear=function(){
  13026. for (var i=0,n=this._commands.length;i < n;i++)
  13027. this._commands[i].recover();
  13028. this._commands.length=0;
  13029. }
  13030. CommandBuffer.SCREENTEXTURE_NAME="u_ScreenTexture";
  13031. __static(CommandBuffer,
  13032. ['screenShader',function(){return this.screenShader=Shader3D.find("ScreenQuad");},'SCREENTEXTURE_ID',function(){return this.SCREENTEXTURE_ID=Shader3D.propertyNameToID("u_ScreenTexture");}
  13033. ]);
  13034. return CommandBuffer;
  13035. })()
  13036. /**
  13037. *<code>KeyFrame</code> 类用于创建关键帧实例。
  13038. */
  13039. //class laya.d3.core.Keyframe
  13040. var Keyframe=(function(){
  13041. function Keyframe(){
  13042. /**时间。*/
  13043. this.time=NaN;
  13044. }
  13045. __class(Keyframe,'laya.d3.core.Keyframe');
  13046. var __proto=Keyframe.prototype;
  13047. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  13048. /**
  13049. *克隆。
  13050. *@param destObject 克隆源。
  13051. */
  13052. __proto.cloneTo=function(destObject){
  13053. var destKeyFrame=destObject;
  13054. destKeyFrame.time=this.time;
  13055. }
  13056. /**
  13057. *克隆。
  13058. *@return 克隆副本。
  13059. */
  13060. __proto.clone=function(){
  13061. var dest=/*__JS__ */new this.constructor();
  13062. this.cloneTo(dest);
  13063. return dest;
  13064. }
  13065. return Keyframe;
  13066. })()
  13067. /**
  13068. *<code>Quaternion</code> 类用于创建四元数。
  13069. */
  13070. //class laya.d3.math.Quaternion
  13071. var Quaternion=(function(){
  13072. function Quaternion(x,y,z,w,nativeElements){
  13073. /**X轴坐标*/
  13074. //this.x=NaN;
  13075. /**Y轴坐标*/
  13076. //this.y=NaN;
  13077. /**Z轴坐标*/
  13078. //this.z=NaN;
  13079. /**W轴坐标*/
  13080. //this.w=NaN;
  13081. (x===void 0)&& (x=0);
  13082. (y===void 0)&& (y=0);
  13083. (z===void 0)&& (z=0);
  13084. (w===void 0)&& (w=1);
  13085. this.x=x;
  13086. this.y=y;
  13087. this.z=z;
  13088. this.w=w;
  13089. }
  13090. __class(Quaternion,'laya.d3.math.Quaternion');
  13091. var __proto=Quaternion.prototype;
  13092. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  13093. /**
  13094. *根据缩放值缩放四元数
  13095. *@param scale 缩放值
  13096. *@param out 输出四元数
  13097. */
  13098. __proto.scaling=function(scaling,out){
  13099. out.x=this.x *scaling;
  13100. out.y=this.y *scaling;
  13101. out.z=this.z *scaling;
  13102. out.w=this.w *scaling;
  13103. }
  13104. /**
  13105. *归一化四元数
  13106. *@param out 输出四元数
  13107. */
  13108. __proto.normalize=function(out){
  13109. var len=this.x *this.x+this.y *this.y+this.z *this.z+this.w *this.w;
  13110. if (len > 0){
  13111. len=1 / Math.sqrt(len);
  13112. out.x=this.x *len;
  13113. out.y=this.y *len;
  13114. out.z=this.z *len;
  13115. out.w=this.w *len;
  13116. }
  13117. }
  13118. /**
  13119. *计算四元数的长度
  13120. *@return 长度
  13121. */
  13122. __proto.length=function(){
  13123. return Math.sqrt(this.x *this.x+this.y *this.y+this.z *this.z+this.w *this.w);
  13124. }
  13125. /**
  13126. *根据绕X轴的角度旋转四元数
  13127. *@param rad 角度
  13128. *@param out 输出四元数
  13129. */
  13130. __proto.rotateX=function(rad,out){
  13131. rad *=0.5;
  13132. var bx=Math.sin(rad),bw=Math.cos(rad);
  13133. out.x=this.x *bw+this.w *bx;
  13134. out.y=this.y *bw+this.z *bx;
  13135. out.z=this.z *bw-this.y *bx;
  13136. out.w=this.w *bw-this.x *bx;
  13137. }
  13138. /**
  13139. *根据绕Y轴的制定角度旋转四元数
  13140. *@param rad 角度
  13141. *@param out 输出四元数
  13142. */
  13143. __proto.rotateY=function(rad,out){
  13144. rad *=0.5;
  13145. var by=Math.sin(rad),bw=Math.cos(rad);
  13146. out.x=this.x *bw-this.z *by;
  13147. out.y=this.y *bw+this.w *by;
  13148. out.z=this.z *bw+this.x *by;
  13149. out.w=this.w *bw-this.y *by;
  13150. }
  13151. /**
  13152. *根据绕Z轴的制定角度旋转四元数
  13153. *@param rad 角度
  13154. *@param out 输出四元数
  13155. */
  13156. __proto.rotateZ=function(rad,out){
  13157. rad *=0.5;
  13158. var bz=Math.sin(rad),bw=Math.cos(rad);
  13159. out.x=this.x *bw+this.y *bz;
  13160. out.y=this.y *bw-this.x *bz;
  13161. out.z=this.z *bw+this.w *bz;
  13162. out.w=this.w *bw-this.z *bz;
  13163. }
  13164. /**
  13165. *分解四元数到欧拉角(顺序为Yaw、Pitch、Roll),参考自http://xboxforums.create.msdn.com/forums/p/4574/23988.aspx#23988,问题绕X轴翻转超过±90度时有,会产生瞬间反转
  13166. *@param quaternion 源四元数
  13167. *@param out 欧拉角值
  13168. */
  13169. __proto.getYawPitchRoll=function(out){
  13170. Vector3.transformQuat(Vector3._ForwardRH,this,Quaternion.TEMPVector31);
  13171. Vector3.transformQuat(Vector3._Up,this,Quaternion.TEMPVector32);
  13172. var upe=Quaternion.TEMPVector32;
  13173. Quaternion.angleTo(Vector3._ZERO,Quaternion.TEMPVector31,Quaternion.TEMPVector33);
  13174. var angle=Quaternion.TEMPVector33;
  13175. if (angle.x==Math.PI / 2){
  13176. angle.y=Quaternion.arcTanAngle(upe.z,upe.x);
  13177. angle.z=0;
  13178. }else if (angle.x==-Math.PI / 2){
  13179. angle.y=Quaternion.arcTanAngle(-upe.z,-upe.x);
  13180. angle.z=0;
  13181. }else {
  13182. Matrix4x4.createRotationY(-angle.y,Quaternion.TEMPMatrix0);
  13183. Matrix4x4.createRotationX(-angle.x,Quaternion.TEMPMatrix1);
  13184. Vector3.transformCoordinate(Quaternion.TEMPVector32,Quaternion.TEMPMatrix0,Quaternion.TEMPVector32);
  13185. Vector3.transformCoordinate(Quaternion.TEMPVector32,Quaternion.TEMPMatrix1,Quaternion.TEMPVector32);
  13186. angle.z=Quaternion.arcTanAngle(upe.y,-upe.x);
  13187. }
  13188. if (angle.y <=-Math.PI)
  13189. angle.y=Math.PI;
  13190. if (angle.z <=-Math.PI)
  13191. angle.z=Math.PI;
  13192. if (angle.y >=Math.PI && angle.z >=Math.PI){
  13193. angle.y=0;
  13194. angle.z=0;
  13195. angle.x=Math.PI-angle.x;
  13196. };
  13197. var oe=out;
  13198. oe.x=angle.y;
  13199. oe.y=angle.x;
  13200. oe.z=angle.z;
  13201. }
  13202. /**
  13203. *求四元数的逆
  13204. *@param out 输出四元数
  13205. */
  13206. __proto.invert=function(out){
  13207. var a0=this.x,a1=this.y,a2=this.z,a3=this.w;
  13208. var dot=a0 *a0+a1 *a1+a2 *a2+a3 *a3;
  13209. var invDot=dot ? 1.0 / dot :0;
  13210. out.x=-a0 *invDot;
  13211. out.y=-a1 *invDot;
  13212. out.z=-a2 *invDot;
  13213. out.w=a3 *invDot;
  13214. }
  13215. /**
  13216. *设置四元数为单位算数
  13217. *@param out 输出四元数
  13218. */
  13219. __proto.identity=function(){
  13220. this.x=0;
  13221. this.y=0;
  13222. this.z=0;
  13223. this.w=1;
  13224. }
  13225. /**
  13226. *从Array数组拷贝值。
  13227. *@param array 数组。
  13228. *@param offset 数组偏移。
  13229. */
  13230. __proto.fromArray=function(array,offset){
  13231. (offset===void 0)&& (offset=0);
  13232. this.x=array[offset+0];
  13233. this.y=array[offset+1];
  13234. this.z=array[offset+2];
  13235. this.w=array[offset+3];
  13236. }
  13237. /**
  13238. *克隆。
  13239. *@param destObject 克隆源。
  13240. */
  13241. __proto.cloneTo=function(destObject){
  13242. if (this===destObject){
  13243. return;
  13244. }
  13245. destObject.x=this.x;
  13246. destObject.y=this.y;
  13247. destObject.z=this.z;
  13248. destObject.w=this.w;
  13249. }
  13250. /**
  13251. *克隆。
  13252. *@return 克隆副本。
  13253. */
  13254. __proto.clone=function(){
  13255. var dest=/*__JS__ */new this.constructor();
  13256. this.cloneTo(dest);
  13257. return dest;
  13258. }
  13259. __proto.equals=function(b){
  13260. 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);
  13261. }
  13262. /**
  13263. *计算长度的平方。
  13264. *@return 长度的平方。
  13265. */
  13266. __proto.lengthSquared=function(){
  13267. return (this.x *this.x)+(this.y *this.y)+(this.z *this.z)+(this.w *this.w);
  13268. }
  13269. __proto.forNativeElement=function(nativeElements){
  13270. if (nativeElements){
  13271. /*__JS__ */this.elements=nativeElements;
  13272. /*__JS__ */this.elements[0]=this.x;
  13273. /*__JS__ */this.elements[1]=this.y;
  13274. /*__JS__ */this.elements[2]=this.z;
  13275. /*__JS__ */this.elements[3]=this.w;
  13276. }
  13277. else{
  13278. /*__JS__ */this.elements=new Float32Array([this.x,this.y,this.z,this.w]);
  13279. }
  13280. Vector2.rewriteNumProperty(this,"x",0);
  13281. Vector2.rewriteNumProperty(this,"y",1);
  13282. Vector2.rewriteNumProperty(this,"z",2);
  13283. Vector2.rewriteNumProperty(this,"w",3);
  13284. }
  13285. Quaternion.createFromYawPitchRoll=function(yaw,pitch,roll,out){
  13286. var halfRoll=roll *0.5;
  13287. var halfPitch=pitch *0.5;
  13288. var halfYaw=yaw *0.5;
  13289. var sinRoll=Math.sin(halfRoll);
  13290. var cosRoll=Math.cos(halfRoll);
  13291. var sinPitch=Math.sin(halfPitch);
  13292. var cosPitch=Math.cos(halfPitch);
  13293. var sinYaw=Math.sin(halfYaw);
  13294. var cosYaw=Math.cos(halfYaw);
  13295. out.x=(cosYaw *sinPitch *cosRoll)+(sinYaw *cosPitch *sinRoll);
  13296. out.y=(sinYaw *cosPitch *cosRoll)-(cosYaw *sinPitch *sinRoll);
  13297. out.z=(cosYaw *cosPitch *sinRoll)-(sinYaw *sinPitch *cosRoll);
  13298. out.w=(cosYaw *cosPitch *cosRoll)+(sinYaw *sinPitch *sinRoll);
  13299. }
  13300. Quaternion.multiply=function(left,right,out){
  13301. var lx=left.x;
  13302. var ly=left.y;
  13303. var lz=left.z;
  13304. var lw=left.w;
  13305. var rx=right.x;
  13306. var ry=right.y;
  13307. var rz=right.z;
  13308. var rw=right.w;
  13309. var a=(ly *rz-lz *ry);
  13310. var b=(lz *rx-lx *rz);
  13311. var c=(lx *ry-ly *rx);
  13312. var d=(lx *rx+ly *ry+lz *rz);
  13313. out.x=(lx *rw+rx *lw)+a;
  13314. out.y=(ly *rw+ry *lw)+b;
  13315. out.z=(lz *rw+rz *lw)+c;
  13316. out.w=lw *rw-d;
  13317. }
  13318. Quaternion.arcTanAngle=function(x,y){
  13319. if (x==0){
  13320. if (y==1)
  13321. return Math.PI / 2;
  13322. return-Math.PI / 2;
  13323. }
  13324. if (x > 0)
  13325. return Math.atan(y / x);
  13326. if (x < 0){
  13327. if (y > 0)
  13328. return Math.atan(y / x)+Math.PI;
  13329. return Math.atan(y / x)-Math.PI;
  13330. }
  13331. return 0;
  13332. }
  13333. Quaternion.angleTo=function(from,location,angle){
  13334. Vector3.subtract(location,from,Quaternion.TEMPVector30);
  13335. Vector3.normalize(Quaternion.TEMPVector30,Quaternion.TEMPVector30);
  13336. angle.x=Math.asin(Quaternion.TEMPVector30.y);
  13337. angle.y=Quaternion.arcTanAngle(-Quaternion.TEMPVector30.z,-Quaternion.TEMPVector30.x);
  13338. }
  13339. Quaternion.createFromAxisAngle=function(axis,rad,out){
  13340. rad=rad *0.5;
  13341. var s=Math.sin(rad);
  13342. out.x=s *axis.x;
  13343. out.y=s *axis.y;
  13344. out.z=s *axis.z;
  13345. out.w=Math.cos(rad);
  13346. }
  13347. Quaternion.createFromMatrix4x4=function(mat,out){
  13348. var me=mat.elements;
  13349. var sqrt;
  13350. var half;
  13351. var scale=me[0]+me[5]+me[10];
  13352. if (scale > 0.0){
  13353. sqrt=Math.sqrt(scale+1.0);
  13354. out.w=sqrt *0.5;
  13355. sqrt=0.5 / sqrt;
  13356. out.x=(me[6]-me[9])*sqrt;
  13357. out.y=(me[8]-me[2])*sqrt;
  13358. out.z=(me[1]-me[4])*sqrt;
  13359. }else if ((me[0] >=me[5])&& (me[0] >=me[10])){
  13360. sqrt=Math.sqrt(1.0+me[0]-me[5]-me[10]);
  13361. half=0.5 / sqrt;
  13362. out.x=0.5 *sqrt;
  13363. out.y=(me[1]+me[4])*half;
  13364. out.z=(me[2]+me[8])*half;
  13365. out.w=(me[6]-me[9])*half;
  13366. }else if (me[5] > me[10]){
  13367. sqrt=Math.sqrt(1.0+me[5]-me[0]-me[10]);
  13368. half=0.5 / sqrt;
  13369. out.x=(me[4]+me[1])*half;
  13370. out.y=0.5 *sqrt;
  13371. out.z=(me[9]+me[6])*half;
  13372. out.w=(me[8]-me[2])*half;
  13373. }else {
  13374. sqrt=Math.sqrt(1.0+me[10]-me[0]-me[5]);
  13375. half=0.5 / sqrt;
  13376. out.x=(me[8]+me[2])*half;
  13377. out.y=(me[9]+me[6])*half;
  13378. out.z=0.5 *sqrt;
  13379. out.w=(me[1]-me[4])*half;
  13380. }
  13381. }
  13382. Quaternion.slerp=function(left,right,t,out){
  13383. 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;
  13384. var omega,cosom,sinom,scale0,scale1;
  13385. cosom=ax *bx+ay *by+az *bz+aw *bw;
  13386. if (cosom < 0.0){
  13387. cosom=-cosom;
  13388. bx=-bx;
  13389. by=-by;
  13390. bz=-bz;
  13391. bw=-bw;
  13392. }
  13393. if ((1.0-cosom)> 0.000001){
  13394. omega=Math.acos(cosom);
  13395. sinom=Math.sin(omega);
  13396. scale0=Math.sin((1.0-t)*omega)/ sinom;
  13397. scale1=Math.sin(t *omega)/ sinom;
  13398. }else {
  13399. scale0=1.0-t;
  13400. scale1=t;
  13401. }
  13402. out.x=scale0 *ax+scale1 *bx;
  13403. out.y=scale0 *ay+scale1 *by;
  13404. out.z=scale0 *az+scale1 *bz;
  13405. out.w=scale0 *aw+scale1 *bw;
  13406. return out;
  13407. }
  13408. Quaternion.lerp=function(left,right,amount,out){
  13409. var inverse=1.0-amount;
  13410. if (Quaternion.dot(left,right)>=0){
  13411. out.x=(inverse *left.x)+(amount *right.x);
  13412. out.y=(inverse *left.y)+(amount *right.y);
  13413. out.z=(inverse *left.z)+(amount *right.z);
  13414. out.w=(inverse *left.w)+(amount *right.w);
  13415. }else {
  13416. out.x=(inverse *left.x)-(amount *right.x);
  13417. out.y=(inverse *left.y)-(amount *right.y);
  13418. out.z=(inverse *left.z)-(amount *right.z);
  13419. out.w=(inverse *left.w)-(amount *right.w);
  13420. }
  13421. out.normalize(out);
  13422. }
  13423. Quaternion.add=function(left,right,out){
  13424. out.x=left.x+right.x;
  13425. out.y=left.y+right.y;
  13426. out.z=left.z+right.z;
  13427. out.w=left.w+right.w;
  13428. }
  13429. Quaternion.dot=function(left,right){
  13430. return left.x *right.x+left.y *right.y+left.z *right.z+left.w *right.w;
  13431. }
  13432. Quaternion.rotationLookAt=function(forward,up,out){
  13433. Quaternion.lookAt(Vector3._ZERO,forward,up,out);
  13434. }
  13435. Quaternion.lookAt=function(eye,target,up,out){
  13436. Matrix3x3.lookAt(eye,target,up,Quaternion._tempMatrix3x3);
  13437. Quaternion.rotationMatrix(Quaternion._tempMatrix3x3,out);
  13438. }
  13439. Quaternion.invert=function(value,out){
  13440. var lengthSq=value.lengthSquared();
  13441. if (!MathUtils3D.isZero(lengthSq)){
  13442. lengthSq=1.0 / lengthSq;
  13443. out.x=-value.x *lengthSq;
  13444. out.y=-value.y *lengthSq;
  13445. out.z=-value.z *lengthSq;
  13446. out.w=value.w *lengthSq;
  13447. }
  13448. }
  13449. Quaternion.rotationMatrix=function(matrix3x3,out){
  13450. var me=matrix3x3.elements;
  13451. var m11=me[0];
  13452. var m12=me[1];
  13453. var m13=me[2];
  13454. var m21=me[3];
  13455. var m22=me[4];
  13456. var m23=me[5];
  13457. var m31=me[6];
  13458. var m32=me[7];
  13459. var m33=me[8];
  13460. var sqrt=NaN,half=NaN;
  13461. var scale=m11+m22+m33;
  13462. if (scale > 0){
  13463. sqrt=Math.sqrt(scale+1);
  13464. out.w=sqrt *0.5;
  13465. sqrt=0.5 / sqrt;
  13466. out.x=(m23-m32)*sqrt;
  13467. out.y=(m31-m13)*sqrt;
  13468. out.z=(m12-m21)*sqrt;
  13469. }else if ((m11 >=m22)&& (m11 >=m33)){
  13470. sqrt=Math.sqrt(1+m11-m22-m33);
  13471. half=0.5 / sqrt;
  13472. out.x=0.5 *sqrt;
  13473. out.y=(m12+m21)*half;
  13474. out.z=(m13+m31)*half;
  13475. out.w=(m23-m32)*half;
  13476. }else if (m22 > m33){
  13477. sqrt=Math.sqrt(1+m22-m11-m33);
  13478. half=0.5 / sqrt;
  13479. out.x=(m21+m12)*half;
  13480. out.y=0.5 *sqrt;
  13481. out.z=(m32+m23)*half;
  13482. out.w=(m31-m13)*half;
  13483. }else {
  13484. sqrt=Math.sqrt(1+m33-m11-m22);
  13485. half=0.5 / sqrt;
  13486. out.x=(m31+m13)*half;
  13487. out.y=(m32+m23)*half;
  13488. out.z=0.5 *sqrt;
  13489. out.w=(m12-m21)*half;
  13490. }
  13491. }
  13492. Quaternion.DEFAULT=new Quaternion();
  13493. __static(Quaternion,
  13494. ['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);}
  13495. ]);
  13496. return Quaternion;
  13497. })()
  13498. /**
  13499. *@private
  13500. *<code>VertexDeclaration</code> 类用于生成顶点声明。
  13501. */
  13502. //class laya.d3.graphics.VertexDeclaration
  13503. var VertexDeclaration=(function(){
  13504. function VertexDeclaration(vertexStride,vertexElements){
  13505. /**@private */
  13506. this._id=0;
  13507. /**@private */
  13508. this._vertexStride=0;
  13509. /**@private */
  13510. this._vertexElementsDic=null;
  13511. /**@private */
  13512. this._shaderValues=null;
  13513. /**@private */
  13514. this._defineDatas=null;
  13515. /**@private [只读]*/
  13516. this.vertexElements=null;
  13517. this._id=++VertexDeclaration._uniqueIDCounter;
  13518. this._defineDatas=new DefineDatas();
  13519. this._vertexElementsDic={};
  13520. this._vertexStride=vertexStride;
  13521. this.vertexElements=vertexElements;
  13522. var count=vertexElements.length;
  13523. this._shaderValues=new ShaderData(null);
  13524. for (var j=0;j < count;j++){
  13525. var vertexElement=vertexElements[j];
  13526. var name=vertexElement.elementUsage;
  13527. this._vertexElementsDic[name]=vertexElement;
  13528. var value=new Int32Array(5);
  13529. var elmentInfo=VertexElementFormat.getElementInfos(vertexElement.elementFormat);
  13530. value[0]=elmentInfo[0];
  13531. value[1]=elmentInfo[1];
  13532. value[2]=elmentInfo[2];
  13533. value[3]=this._vertexStride;
  13534. value[4]=vertexElement.offset;
  13535. this._shaderValues.setAttribute(name,value);
  13536. }
  13537. }
  13538. __class(VertexDeclaration,'laya.d3.graphics.VertexDeclaration');
  13539. var __proto=VertexDeclaration.prototype;
  13540. /**
  13541. *@private
  13542. */
  13543. __proto.getVertexElementByUsage=function(usage){
  13544. return this._vertexElementsDic[usage];
  13545. }
  13546. /**
  13547. *@private
  13548. */
  13549. __proto.unBinding=function(){}
  13550. /**
  13551. *获取唯一标识ID(通常用于优化或识别)。
  13552. *@return 唯一标识ID
  13553. */
  13554. __getset(0,__proto,'id',function(){
  13555. return this._id;
  13556. });
  13557. /**
  13558. *@private
  13559. */
  13560. __getset(0,__proto,'vertexStride',function(){
  13561. return this._vertexStride;
  13562. });
  13563. VertexDeclaration._uniqueIDCounter=1;
  13564. return VertexDeclaration;
  13565. })()
  13566. /**
  13567. *<code>MathUtils</code> 类用于创建数学工具。
  13568. */
  13569. //class laya.d3.math.MathUtils3D
  13570. var MathUtils3D=(function(){
  13571. /**
  13572. *创建一个 <code>MathUtils</code> 实例。
  13573. */
  13574. function MathUtils3D(){}
  13575. __class(MathUtils3D,'laya.d3.math.MathUtils3D');
  13576. MathUtils3D.isZero=function(v){
  13577. return Math.abs(v)< MathUtils3D.zeroTolerance;
  13578. }
  13579. MathUtils3D.nearEqual=function(n1,n2){
  13580. if (MathUtils3D.isZero(n1-n2))
  13581. return true;
  13582. return false;
  13583. }
  13584. MathUtils3D.fastInvSqrt=function(value){
  13585. if (MathUtils3D.isZero(value))
  13586. return value;
  13587. return 1.0 / Math.sqrt(value);
  13588. }
  13589. __static(MathUtils3D,
  13590. ['zeroTolerance',function(){return this.zeroTolerance=1e-6;},'MaxValue',function(){return this.MaxValue=3.40282347e+38;},'MinValue',function(){return this.MinValue=-3.40282347e+38;}
  13591. ]);
  13592. return MathUtils3D;
  13593. })()
  13594. /**
  13595. *<code>BoundBox</code> 类用于创建包围盒。
  13596. */
  13597. //class laya.d3.math.BoundBox
  13598. var BoundBox=(function(){
  13599. function BoundBox(min,max){
  13600. /**最小顶点。*/
  13601. this.min=null;
  13602. /**最大顶点。*/
  13603. this.max=null;
  13604. this.min=min;
  13605. this.max=max;
  13606. }
  13607. __class(BoundBox,'laya.d3.math.BoundBox');
  13608. var __proto=BoundBox.prototype;
  13609. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  13610. /**
  13611. *@private
  13612. */
  13613. __proto._rotateExtents=function(extents,rotation,out){
  13614. var extentsX=extents.x;
  13615. var extentsY=extents.y;
  13616. var extentsZ=extents.z;
  13617. var matElements=rotation.elements;
  13618. out.x=Math.abs(matElements[0] *extentsX)+Math.abs(matElements[4] *extentsY)+Math.abs(matElements[8] *extentsZ);
  13619. out.y=Math.abs(matElements[1] *extentsX)+Math.abs(matElements[5] *extentsY)+Math.abs(matElements[9] *extentsZ);
  13620. out.z=Math.abs(matElements[2] *extentsX)+Math.abs(matElements[6] *extentsY)+Math.abs(matElements[10] *extentsZ);
  13621. }
  13622. /**
  13623. *获取包围盒的8个角顶点。
  13624. *@param corners 返回顶点的输出队列。
  13625. */
  13626. __proto.getCorners=function(corners){
  13627. corners.length=8;
  13628. var minX=this.min.x;
  13629. var minY=this.min.y;
  13630. var minZ=this.min.z;
  13631. var maxX=this.max.x;
  13632. var maxY=this.max.y;
  13633. var maxZ=this.max.z;
  13634. corners[0]=new Vector3(minX,maxY,maxZ);
  13635. corners[1]=new Vector3(maxX,maxY,maxZ);
  13636. corners[2]=new Vector3(maxX,minY,maxZ);
  13637. corners[3]=new Vector3(minX,minY,maxZ);
  13638. corners[4]=new Vector3(minX,maxY,minZ);
  13639. corners[5]=new Vector3(maxX,maxY,minZ);
  13640. corners[6]=new Vector3(maxX,minY,minZ);
  13641. corners[7]=new Vector3(minX,minY,minZ);
  13642. }
  13643. /**
  13644. *获取中心点。
  13645. *@param out
  13646. */
  13647. __proto.getCenter=function(out){
  13648. Vector3.add(this.min,this.max,out);
  13649. Vector3.scale(out,0.5,out);
  13650. }
  13651. /**
  13652. *获取范围。
  13653. *@param out
  13654. */
  13655. __proto.getExtent=function(out){
  13656. Vector3.subtract(this.max,this.min,out);
  13657. Vector3.scale(out,0.5,out);
  13658. }
  13659. /**
  13660. *设置中心点和范围。
  13661. *@param center
  13662. */
  13663. __proto.setCenterAndExtent=function(center,extent){
  13664. Vector3.subtract(center,extent,this.min);
  13665. Vector3.add(center,extent,this.max);
  13666. }
  13667. /**
  13668. *@private
  13669. */
  13670. __proto.tranform=function(matrix,out){
  13671. var center=BoundBox._tempVector30;
  13672. var extent=BoundBox._tempVector31;
  13673. this.getCenter(center);
  13674. this.getExtent(extent);
  13675. Vector3.transformCoordinate(center,matrix,center);
  13676. this._rotateExtents(extent,matrix,extent);
  13677. out.setCenterAndExtent(center,extent);
  13678. }
  13679. __proto.toDefault=function(){
  13680. this.min.toDefault();
  13681. this.max.toDefault();
  13682. }
  13683. /**
  13684. *克隆。
  13685. *@param destObject 克隆源。
  13686. */
  13687. __proto.cloneTo=function(destObject){
  13688. var dest=destObject;
  13689. this.min.cloneTo(dest.min);
  13690. this.max.cloneTo(dest.max);
  13691. }
  13692. /**
  13693. *克隆。
  13694. *@return 克隆副本。
  13695. */
  13696. __proto.clone=function(){
  13697. var dest=/*__JS__ */new this.constructor(new Vector3(),new Vector3());
  13698. this.cloneTo(dest);
  13699. return dest;
  13700. }
  13701. BoundBox.createfromPoints=function(points,out){
  13702. if (points==null)
  13703. throw new Error("points");
  13704. var min=out.min;
  13705. var max=out.max;
  13706. min.x=Number.MAX_VALUE;
  13707. min.y=Number.MAX_VALUE;
  13708. min.z=Number.MAX_VALUE;
  13709. max.x=-Number.MAX_VALUE;
  13710. max.y=-Number.MAX_VALUE;
  13711. max.z=-Number.MAX_VALUE;
  13712. for (var i=0,n=points.length;i < n;++i){
  13713. Vector3.min(min,points[i],min);
  13714. Vector3.max(max,points[i],max);
  13715. }
  13716. }
  13717. BoundBox.merge=function(box1,box2,out){
  13718. Vector3.min(box1.min,box2.min,out.min);
  13719. Vector3.max(box1.max,box2.max,out.max);
  13720. }
  13721. __static(BoundBox,
  13722. ['_tempVector30',function(){return this._tempVector30=new Vector3();},'_tempVector31',function(){return this._tempVector31=new Vector3();}
  13723. ]);
  13724. return BoundBox;
  13725. })()
  13726. /**
  13727. *<code>TextMesh</code> 类用于创建文本网格。
  13728. */
  13729. //class laya.d3.text.TextMesh
  13730. var TextMesh=(function(){
  13731. function TextMesh(){
  13732. /**@private */
  13733. this._vertices=null;
  13734. /**@private */
  13735. this._vertexBuffer=null;
  13736. /**@private */
  13737. this._text=null;
  13738. /**@private */
  13739. this._fontSize=0;
  13740. /**@private */
  13741. this._color=null;
  13742. }
  13743. __class(TextMesh,'laya.d3.text.TextMesh');
  13744. var __proto=TextMesh.prototype;
  13745. /**
  13746. *@private
  13747. */
  13748. __proto._createVertexBuffer=function(charCount){}
  13749. /**
  13750. *@private
  13751. */
  13752. __proto._resizeVertexBuffer=function(charCount){}
  13753. /**
  13754. *@private
  13755. */
  13756. __proto._addChar=function(){}
  13757. /**
  13758. *设置文本。
  13759. *@param value 文本。
  13760. */
  13761. /**
  13762. *获取文本。
  13763. *@return 文本。
  13764. */
  13765. __getset(0,__proto,'text',function(){
  13766. return this._text;
  13767. },function(value){
  13768. this._text=value;
  13769. });
  13770. /**
  13771. *设置字体储存。
  13772. *@return 字体尺寸。
  13773. */
  13774. /**
  13775. *获取字体尺寸。
  13776. *@param value 字体尺寸。
  13777. */
  13778. __getset(0,__proto,'fontSize',function(){
  13779. return this._fontSize;
  13780. },function(value){
  13781. this._fontSize=value;
  13782. });
  13783. /**
  13784. *设置颜色。
  13785. *@param 颜色。
  13786. */
  13787. /**
  13788. *获取颜色。
  13789. *@return 颜色。
  13790. */
  13791. __getset(0,__proto,'color',function(){
  13792. return this._color;
  13793. },function(value){
  13794. this._color=value;
  13795. });
  13796. TextMesh._indexBuffer=null;
  13797. return TextMesh;
  13798. })()
  13799. /**
  13800. *...
  13801. *@author
  13802. */
  13803. //class laya.d3.core.pixelLine.PixelLineVertex
  13804. var PixelLineVertex=(function(){
  13805. function PixelLineVertex(){}
  13806. __class(PixelLineVertex,'laya.d3.core.pixelLine.PixelLineVertex');
  13807. var __proto=PixelLineVertex.prototype;
  13808. __getset(0,__proto,'vertexDeclaration',function(){
  13809. return PixelLineVertex._vertexDeclaration;
  13810. });
  13811. __getset(1,PixelLineVertex,'vertexDeclaration',function(){
  13812. return PixelLineVertex._vertexDeclaration;
  13813. });
  13814. __static(PixelLineVertex,
  13815. ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(28,
  13816. [new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0),
  13817. new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexMesh.MESH_COLOR0*/1)]);}
  13818. ]);
  13819. return PixelLineVertex;
  13820. })()
  13821. /**
  13822. *...
  13823. *@author ...
  13824. */
  13825. //class laya.d3.physics.shape.HeightfieldColliderShape
  13826. var HeightfieldColliderShape=(function(){
  13827. function HeightfieldColliderShape(){}
  13828. __class(HeightfieldColliderShape,'laya.d3.physics.shape.HeightfieldColliderShape');
  13829. return HeightfieldColliderShape;
  13830. })()
  13831. /**
  13832. *...
  13833. *@author ...
  13834. */
  13835. //class laya.d3.loaders.MeshReader
  13836. var MeshReader=(function(){
  13837. function MeshReader(){}
  13838. __class(MeshReader,'laya.d3.loaders.MeshReader');
  13839. MeshReader.read=function(data,mesh,subMeshes){
  13840. var readData=new Byte(data);
  13841. readData.pos=0;
  13842. var version=readData.readUTFString();
  13843. switch (version){
  13844. case "LAYAMODEL:0301":
  13845. case "LAYAMODEL:0400":
  13846. case "LAYAMODEL:0401":
  13847. LoadModelV04.parse(readData,version,mesh,subMeshes);
  13848. break ;
  13849. case "LAYAMODEL:05":
  13850. case "LAYAMODEL:COMPRESSION_05":
  13851. LoadModelV05.parse(readData,version,mesh,subMeshes);
  13852. break ;
  13853. default :
  13854. throw new Error("MeshReader: unknown mesh version.");
  13855. }
  13856. mesh._setSubMeshes(subMeshes);
  13857. }
  13858. return MeshReader;
  13859. })()
  13860. /**
  13861. *<code>TextureSheetAnimation</code> 类用于创建粒子帧动画。
  13862. */
  13863. //class laya.d3.core.particleShuriKen.module.TextureSheetAnimation
  13864. var TextureSheetAnimation=(function(){
  13865. function TextureSheetAnimation(frame,startFrame){
  13866. /**@private */
  13867. this._frame=null;
  13868. /**@private */
  13869. this._startFrame=null;
  13870. /**纹理平铺。*/
  13871. this.tiles=null;
  13872. /**类型,0为whole sheet、1为singal row。*/
  13873. this.type=0;
  13874. /**是否随机行,type为1时有效。*/
  13875. this.randomRow=false;
  13876. /**行索引,type为1时有效。*/
  13877. this.rowIndex=0;
  13878. /**循环次数。*/
  13879. this.cycles=0;
  13880. /**UV通道类型,0为Noting,1为Everything,待补充,暂不支持。*/
  13881. this.enableUVChannels=0;
  13882. /**是否启用*/
  13883. this.enable=false;
  13884. this.tiles=new Vector2(1,1);
  13885. this.type=0;
  13886. this.randomRow=true;
  13887. this.rowIndex=0;
  13888. this.cycles=1;
  13889. this.enableUVChannels=1;
  13890. this._frame=frame;
  13891. this._startFrame=startFrame;
  13892. }
  13893. __class(TextureSheetAnimation,'laya.d3.core.particleShuriKen.module.TextureSheetAnimation');
  13894. var __proto=TextureSheetAnimation.prototype;
  13895. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  13896. /**
  13897. *克隆。
  13898. *@param destObject 克隆源。
  13899. */
  13900. __proto.cloneTo=function(destObject){
  13901. var destTextureSheetAnimation=destObject;
  13902. this.tiles.cloneTo(destTextureSheetAnimation.tiles);
  13903. destTextureSheetAnimation.type=this.type;
  13904. destTextureSheetAnimation.randomRow=this.randomRow;
  13905. this._frame.cloneTo(destTextureSheetAnimation._frame);
  13906. this._startFrame.cloneTo(destTextureSheetAnimation._startFrame);
  13907. destTextureSheetAnimation.cycles=this.cycles;
  13908. destTextureSheetAnimation.enableUVChannels=this.enableUVChannels;
  13909. destTextureSheetAnimation.enable=this.enable;
  13910. }
  13911. /**
  13912. *克隆。
  13913. *@return 克隆副本。
  13914. */
  13915. __proto.clone=function(){
  13916. var destFrame;
  13917. switch (this._frame.type){
  13918. case 0:
  13919. destFrame=FrameOverTime.createByConstant(this._frame.constant);
  13920. break ;
  13921. case 1:
  13922. destFrame=FrameOverTime.createByOverTime(this._frame.frameOverTimeData.clone());
  13923. break ;
  13924. case 2:
  13925. destFrame=FrameOverTime.createByRandomTwoConstant(this._frame.constantMin,this._frame.constantMax);
  13926. break ;
  13927. case 3:
  13928. destFrame=FrameOverTime.createByRandomTwoOverTime(this._frame.frameOverTimeDataMin.clone(),this._frame.frameOverTimeDataMax.clone());
  13929. break ;
  13930. };
  13931. var destStartFrame;
  13932. switch (this._startFrame.type){
  13933. case 0:
  13934. destStartFrame=StartFrame.createByConstant(this._startFrame.constant);
  13935. break ;
  13936. case 1:
  13937. destStartFrame=StartFrame.createByRandomTwoConstant(this._startFrame.constantMin,this._startFrame.constantMax);
  13938. break ;
  13939. };
  13940. var destTextureSheetAnimation=/*__JS__ */new this.constructor(destFrame,destStartFrame);
  13941. this.tiles.cloneTo(destTextureSheetAnimation.tiles);
  13942. destTextureSheetAnimation.type=this.type;
  13943. destTextureSheetAnimation.randomRow=this.randomRow;
  13944. destTextureSheetAnimation.cycles=this.cycles;
  13945. destTextureSheetAnimation.enableUVChannels=this.enableUVChannels;
  13946. destTextureSheetAnimation.enable=this.enable;
  13947. return destTextureSheetAnimation;
  13948. }
  13949. /**获取时间帧率。*/
  13950. __getset(0,__proto,'frame',function(){
  13951. return this._frame;
  13952. });
  13953. /**获取开始帧率。*/
  13954. __getset(0,__proto,'startFrame',function(){
  13955. return this._startFrame;
  13956. });
  13957. return TextureSheetAnimation;
  13958. })()
  13959. /**
  13960. *<code>BoneNode</code> 类用于实现骨骼节点。
  13961. */
  13962. //class laya.d3.animation.AnimationNode
  13963. var AnimationNode=(function(){
  13964. function AnimationNode(localPosition,localRotation,localScale,worldMatrix){
  13965. /**@private */
  13966. //this._children=null;
  13967. /**@private */
  13968. //this._parent=null;
  13969. /**@private [只读]*/
  13970. //this.transform=null;
  13971. /**节点名称。 */
  13972. //this.name=null;
  13973. /**@private [NATIVE]*/
  13974. //this._worldMatrixIndex=0;
  13975. this._children=[];
  13976. this.transform=new AnimationTransform3D(this,localPosition,localRotation,localScale,worldMatrix);
  13977. }
  13978. __class(AnimationNode,'laya.d3.animation.AnimationNode');
  13979. var __proto=AnimationNode.prototype;
  13980. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  13981. /**
  13982. *添加子节点。
  13983. *@param child 子节点。
  13984. */
  13985. __proto.addChild=function(child){
  13986. child._parent=this;
  13987. child.transform.setParent(this.transform);
  13988. this._children.push(child);
  13989. }
  13990. /**
  13991. *移除子节点。
  13992. *@param child 子节点。
  13993. */
  13994. __proto.removeChild=function(child){
  13995. var index=this._children.indexOf(child);
  13996. (index!==-1)&& (this._children.splice(index,1));
  13997. }
  13998. /**
  13999. *根据名字获取子节点。
  14000. *@param name 名字。
  14001. */
  14002. __proto.getChildByName=function(name){
  14003. for (var i=0,n=this._children.length;i < n;i++){
  14004. var child=this._children[i];
  14005. if (child.name===name)
  14006. return child;
  14007. }
  14008. return null;
  14009. }
  14010. /**
  14011. *根据索引获取子节点。
  14012. *@param index 索引。
  14013. */
  14014. __proto.getChildByIndex=function(index){
  14015. return this._children[index];
  14016. }
  14017. /**
  14018. *获取子节点的个数。
  14019. */
  14020. __proto.getChildCount=function(){
  14021. return this._children.length;
  14022. }
  14023. /**
  14024. *克隆。
  14025. *@param destObject 克隆源。
  14026. */
  14027. __proto.cloneTo=function(destObject){
  14028. var destNode=destObject;
  14029. destNode.name=this.name;
  14030. for (var i=0,n=this._children.length;i < n;i++){
  14031. var child=this._children[i];
  14032. var destChild=child.clone();
  14033. destNode.addChild(destChild);
  14034. var transform=child.transform;
  14035. var destTransform=destChild.transform;
  14036. var destLocalPosition=destTransform.localPosition;
  14037. var destLocalRotation=destTransform.localRotation;
  14038. var destLocalScale=destTransform.localScale;
  14039. transform.localPosition.cloneTo(destLocalPosition);
  14040. transform.localRotation.cloneTo(destLocalRotation);
  14041. transform.localScale.cloneTo(destLocalScale);
  14042. destTransform.localPosition=destLocalPosition;
  14043. destTransform.localRotation=destLocalRotation;
  14044. destTransform.localScale=destLocalScale;
  14045. }
  14046. }
  14047. /**
  14048. *克隆。
  14049. *@return 克隆副本。
  14050. */
  14051. __proto.clone=function(){
  14052. var dest=new AnimationNode();
  14053. this.cloneTo(dest);
  14054. return dest;
  14055. }
  14056. /**
  14057. *@private [NATIVE]
  14058. */
  14059. __proto._cloneNative=function(localPositions,localRotations,localScales,animationNodeWorldMatrixs,animationNodeParentIndices,parentIndex,avatar){
  14060. var curID=avatar._nativeCurCloneCount;
  14061. animationNodeParentIndices[curID]=parentIndex;
  14062. var localPosition=new Float32Array(localPositions.buffer,curID *3 *4,3);
  14063. var localRotation=new Float32Array(localRotations.buffer,curID *4 *4,4);
  14064. var localScale=new Float32Array(localScales.buffer,curID *3 *4,3);
  14065. var worldMatrix=new Float32Array(animationNodeWorldMatrixs.buffer,curID *16 *4,16);
  14066. var dest=new AnimationNode(localPosition,localRotation,localScale,worldMatrix);
  14067. dest._worldMatrixIndex=curID;
  14068. this._cloneToNative(dest,localPositions,localRotations,localScales,animationNodeWorldMatrixs,animationNodeParentIndices,curID,avatar);
  14069. return dest;
  14070. }
  14071. /**
  14072. *@private [NATIVE]
  14073. */
  14074. __proto._cloneToNative=function(destObject,localPositions,localRotations,localScales,animationNodeWorldMatrixs,animationNodeParentIndices,parentIndex,avatar){
  14075. var destNode=destObject;
  14076. destNode.name=this.name;
  14077. for (var i=0,n=this._children.length;i < n;i++){
  14078. var child=this._children[i];
  14079. avatar._nativeCurCloneCount++;
  14080. var destChild=child._cloneNative(localPositions,localRotations,localScales,animationNodeWorldMatrixs,animationNodeParentIndices,parentIndex,avatar);
  14081. destNode.addChild(destChild);
  14082. var transform=child.transform;
  14083. var destTransform=destChild.transform;
  14084. var destLocalPosition=destTransform.localPosition;
  14085. var destLocalRotation=destTransform.localRotation;
  14086. var destLocalScale=destTransform.localScale;
  14087. transform.localPosition.cloneTo(destLocalPosition);
  14088. transform.localRotation.cloneTo(destLocalRotation);
  14089. transform.localScale.cloneTo(destLocalScale);
  14090. destTransform.localPosition=destLocalPosition;
  14091. destTransform.localRotation=destLocalRotation;
  14092. destTransform.localScale=destLocalScale;
  14093. }
  14094. }
  14095. return AnimationNode;
  14096. })()
  14097. /**
  14098. *<code>Collision</code> 类用于检测碰撞。
  14099. */
  14100. //class laya.d3.math.CollisionUtils
  14101. var CollisionUtils=(function(){
  14102. /**
  14103. *创建一个 <code>Collision</code> 实例。
  14104. */
  14105. function CollisionUtils(){}
  14106. __class(CollisionUtils,'laya.d3.math.CollisionUtils');
  14107. CollisionUtils.distancePlaneToPoint=function(plane,point){
  14108. var dot=Vector3.dot(plane.normal,point);
  14109. return dot-plane.distance;
  14110. }
  14111. CollisionUtils.distanceBoxToPoint=function(box,point){
  14112. var boxMin=box.min;
  14113. var boxMineX=boxMin.x;
  14114. var boxMineY=boxMin.y;
  14115. var boxMineZ=boxMin.z;
  14116. var boxMax=box.max;
  14117. var boxMaxeX=boxMax.x;
  14118. var boxMaxeY=boxMax.y;
  14119. var boxMaxeZ=boxMax.z;
  14120. var pointeX=point.x;
  14121. var pointeY=point.y;
  14122. var pointeZ=point.z;
  14123. var distance=0;
  14124. if (pointeX < boxMineX)
  14125. distance+=(boxMineX-pointeX)*(boxMineX-pointeX);
  14126. if (pointeX > boxMaxeX)
  14127. distance+=(boxMaxeX-pointeX)*(boxMaxeX-pointeX);
  14128. if (pointeY < boxMineY)
  14129. distance+=(boxMineY-pointeY)*(boxMineY-pointeY);
  14130. if (pointeY > boxMaxeY)
  14131. distance+=(boxMaxeY-pointeY)*(boxMaxeY-pointeY);
  14132. if (pointeZ < boxMineZ)
  14133. distance+=(boxMineZ-pointeZ)*(boxMineZ-pointeZ);
  14134. if (pointeZ > boxMaxeZ)
  14135. distance+=(boxMaxeZ-pointeZ)*(boxMaxeZ-pointeZ);
  14136. return Math.sqrt(distance);
  14137. }
  14138. CollisionUtils.distanceBoxToBox=function(box1,box2){
  14139. var box1Mine=box1.min;
  14140. var box1MineX=box1Mine.x;
  14141. var box1MineY=box1Mine.y;
  14142. var box1MineZ=box1Mine.z;
  14143. var box1Maxe=box1.max;
  14144. var box1MaxeX=box1Maxe.x;
  14145. var box1MaxeY=box1Maxe.y;
  14146. var box1MaxeZ=box1Maxe.z;
  14147. var box2Mine=box2.min;
  14148. var box2MineX=box2Mine.x;
  14149. var box2MineY=box2Mine.y;
  14150. var box2MineZ=box2Mine.z;
  14151. var box2Maxe=box2.max;
  14152. var box2MaxeX=box2Maxe.x;
  14153. var box2MaxeY=box2Maxe.y;
  14154. var box2MaxeZ=box2Maxe.z;
  14155. var distance=0;
  14156. var delta=NaN;
  14157. if (box1MineX > box2MaxeX){
  14158. delta=box1MineX-box2MaxeX;
  14159. distance+=delta *delta;
  14160. }else if (box2MineX > box1MaxeX){
  14161. delta=box2MineX-box1MaxeX;
  14162. distance+=delta *delta;
  14163. }
  14164. if (box1MineY > box2MaxeY){
  14165. delta=box1MineY-box2MaxeY;
  14166. distance+=delta *delta;
  14167. }else if (box2MineY > box1MaxeY){
  14168. delta=box2MineY-box1MaxeY;
  14169. distance+=delta *delta;
  14170. }
  14171. if (box1MineZ > box2MaxeZ){
  14172. delta=box1MineZ-box2MaxeZ;
  14173. distance+=delta *delta;
  14174. }else if (box2MineZ > box1MaxeZ){
  14175. delta=box2MineZ-box1MaxeZ;
  14176. distance+=delta *delta;
  14177. }
  14178. return Math.sqrt(distance);
  14179. }
  14180. CollisionUtils.distanceSphereToPoint=function(sphere,point){
  14181. var distance=Math.sqrt(Vector3.distanceSquared(sphere.center,point));
  14182. distance-=sphere.radius;
  14183. return Math.max(distance,0);
  14184. }
  14185. CollisionUtils.distanceSphereToSphere=function(sphere1,sphere2){
  14186. var distance=Math.sqrt(Vector3.distanceSquared(sphere1.center,sphere2.center));
  14187. distance-=sphere1.radius+sphere2.radius;
  14188. return Math.max(distance,0);
  14189. }
  14190. CollisionUtils.intersectsRayAndTriangleRD=function(ray,vertex1,vertex2,vertex3,out){
  14191. var rayO=ray.origin;
  14192. var rayOeX=rayO.x;
  14193. var rayOeY=rayO.y;
  14194. var rayOeZ=rayO.z;
  14195. var rayD=ray.direction;
  14196. var rayDeX=rayD.x;
  14197. var rayDeY=rayD.y;
  14198. var rayDeZ=rayD.z;
  14199. var v1eX=vertex1.x;
  14200. var v1eY=vertex1.y;
  14201. var v1eZ=vertex1.z;
  14202. var v2eX=vertex2.x;
  14203. var v2eY=vertex2.y;
  14204. var v2eZ=vertex2.z;
  14205. var v3eX=vertex3.x;
  14206. var v3eY=vertex3.y;
  14207. var v3eZ=vertex3.z;
  14208. var _tempV30eX=CollisionUtils._tempV30.x;
  14209. var _tempV30eY=CollisionUtils._tempV30.y;
  14210. var _tempV30eZ=CollisionUtils._tempV30.z;
  14211. _tempV30eX=v2eX-v1eX;
  14212. _tempV30eY=v2eY-v1eY;
  14213. _tempV30eZ=v2eZ-v1eZ;
  14214. var _tempV31eX=CollisionUtils._tempV31.x;
  14215. var _tempV31eY=CollisionUtils._tempV31.y;
  14216. var _tempV31eZ=CollisionUtils._tempV31.z;
  14217. _tempV31eX=v3eX-v1eX;
  14218. _tempV31eY=v3eY-v1eY;
  14219. _tempV31eZ=v3eZ-v1eZ;
  14220. var _tempV32eX=CollisionUtils._tempV32.x;
  14221. var _tempV32eY=CollisionUtils._tempV32.y;
  14222. var _tempV32eZ=CollisionUtils._tempV32.z;
  14223. _tempV32eX=(rayDeY *_tempV31eZ)-(rayDeZ *_tempV31eY);
  14224. _tempV32eY=(rayDeZ *_tempV31eX)-(rayDeX *_tempV31eZ);
  14225. _tempV32eZ=(rayDeX *_tempV31eY)-(rayDeY *_tempV31eX);
  14226. var determinant=(_tempV30eX *_tempV32eX)+(_tempV30eY *_tempV32eY)+(_tempV30eZ *_tempV32eZ);
  14227. if (MathUtils3D.isZero(determinant)){
  14228. out=0;
  14229. return false;
  14230. };
  14231. var inversedeterminant=1 / determinant;
  14232. var _tempV33eX=CollisionUtils._tempV33.x;
  14233. var _tempV33eY=CollisionUtils._tempV33.y;
  14234. var _tempV33eZ=CollisionUtils._tempV33.z;
  14235. _tempV33eX=rayOeX-v1eX;
  14236. _tempV33eY=rayOeY-v1eY;
  14237. _tempV33eZ=rayOeZ-v1eZ;
  14238. var triangleU=(_tempV33eX *_tempV32eX)+(_tempV33eY *_tempV32eY)+(_tempV33eZ *_tempV32eZ);
  14239. triangleU *=inversedeterminant;
  14240. if (triangleU < 0 || triangleU > 1){
  14241. out=0;
  14242. return false;
  14243. };
  14244. var _tempV34eX=CollisionUtils._tempV34.x;
  14245. var _tempV34eY=CollisionUtils._tempV34.y;
  14246. var _tempV34eZ=CollisionUtils._tempV34.z;
  14247. _tempV34eX=(_tempV33eY *_tempV30eZ)-(_tempV33eZ *_tempV30eY);
  14248. _tempV34eY=(_tempV33eZ *_tempV30eX)-(_tempV33eX *_tempV30eZ);
  14249. _tempV34eZ=(_tempV33eX *_tempV30eY)-(_tempV33eY *_tempV30eX);
  14250. var triangleV=((rayDeX *_tempV34eX)+(rayDeY *_tempV34eY))+(rayDeZ *_tempV34eZ);
  14251. triangleV *=inversedeterminant;
  14252. if (triangleV < 0 || triangleU+triangleV > 1){
  14253. out=0;
  14254. return false;
  14255. };
  14256. var raydistance=(_tempV31eX *_tempV34eX)+(_tempV31eY *_tempV34eY)+(_tempV31eZ *_tempV34eZ);
  14257. raydistance *=inversedeterminant;
  14258. if (raydistance < 0){
  14259. out=0;
  14260. return false;
  14261. }
  14262. out=raydistance;
  14263. return true;
  14264. }
  14265. CollisionUtils.intersectsRayAndTriangleRP=function(ray,vertex1,vertex2,vertex3,out){
  14266. var distance=NaN;
  14267. if (!CollisionUtils.intersectsRayAndTriangleRD(ray,vertex1,vertex2,vertex3,distance)){
  14268. out=Vector3._ZERO;
  14269. return false;
  14270. }
  14271. Vector3.scale(ray.direction,distance,CollisionUtils._tempV30);
  14272. Vector3.add(ray.origin,CollisionUtils._tempV30,out);
  14273. return true;
  14274. }
  14275. CollisionUtils.intersectsRayAndPoint=function(ray,point){
  14276. Vector3.subtract(ray.origin,point,CollisionUtils._tempV30);
  14277. var b=Vector3.dot(CollisionUtils._tempV30,ray.direction);
  14278. var c=Vector3.dot(CollisionUtils._tempV30,CollisionUtils._tempV30)-MathUtils3D.zeroTolerance;
  14279. if (c > 0 && b > 0)
  14280. return false;
  14281. var discriminant=b *b-c;
  14282. if (discriminant < 0)
  14283. return false;
  14284. return true;
  14285. }
  14286. CollisionUtils.intersectsRayAndRay=function(ray1,ray2,out){
  14287. var ray1o=ray1.origin;
  14288. var ray1oeX=ray1o.x;
  14289. var ray1oeY=ray1o.y;
  14290. var ray1oeZ=ray1o.z;
  14291. var ray1d=ray1.direction;
  14292. var ray1deX=ray1d.x;
  14293. var ray1deY=ray1d.y;
  14294. var ray1deZ=ray1d.z;
  14295. var ray2o=ray2.origin;
  14296. var ray2oeX=ray2o.x;
  14297. var ray2oeY=ray2o.y;
  14298. var ray2oeZ=ray2o.z;
  14299. var ray2d=ray2.direction;
  14300. var ray2deX=ray2d.x;
  14301. var ray2deY=ray2d.y;
  14302. var ray2deZ=ray2d.z;
  14303. Vector3.cross(ray1d,ray2d,CollisionUtils._tempV30);
  14304. var tempV3=CollisionUtils._tempV30;
  14305. var denominator=Vector3.scalarLength(CollisionUtils._tempV30);
  14306. if (MathUtils3D.isZero(denominator)){
  14307. if (MathUtils3D.nearEqual(ray2oeX,ray1oeX)&& MathUtils3D.nearEqual(ray2oeY,ray1oeY)&& MathUtils3D.nearEqual(ray2oeZ,ray1oeZ)){
  14308. out=Vector3._ZERO;
  14309. return true;
  14310. }
  14311. }
  14312. denominator=denominator *denominator;
  14313. var m11=ray2oeX-ray1oeX;
  14314. var m12=ray2oeY-ray1oeY;
  14315. var m13=ray2oeZ-ray1oeZ;
  14316. var m21=ray2deX;
  14317. var m22=ray2deY;
  14318. var m23=ray2deZ;
  14319. var m31=tempV3.x;
  14320. var m32=tempV3.y;
  14321. var m33=tempV3.z;
  14322. var dets=m11 *m22 *m33+m12 *m23 *m31+m13 *m21 *m32-m11 *m23 *m32-m12 *m21 *m33-m13 *m22 *m31;
  14323. m21=ray1deX;
  14324. m22=ray1deY;
  14325. m23=ray1deZ;
  14326. var dett=m11 *m22 *m33+m12 *m23 *m31+m13 *m21 *m32-m11 *m23 *m32-m12 *m21 *m33-m13 *m22 *m31;
  14327. var s=dets / denominator;
  14328. var t=dett / denominator;
  14329. Vector3.scale(ray1d,s,CollisionUtils._tempV30);
  14330. Vector3.scale(ray2d,s,CollisionUtils._tempV31);
  14331. Vector3.add(ray1o,CollisionUtils._tempV30,CollisionUtils._tempV32);
  14332. Vector3.add(ray2o,CollisionUtils._tempV31,CollisionUtils._tempV33);
  14333. var point1e=CollisionUtils._tempV32;
  14334. var point2e=CollisionUtils._tempV33;
  14335. if (!MathUtils3D.nearEqual(point2e.x,point1e.x)|| !MathUtils3D.nearEqual(point2e.y,point1e.y)|| !MathUtils3D.nearEqual(point2e.z,point1e.z)){
  14336. out=Vector3._ZERO;
  14337. return false;
  14338. }
  14339. out=CollisionUtils._tempV32;
  14340. return true;
  14341. }
  14342. CollisionUtils.intersectsPlaneAndTriangle=function(plane,vertex1,vertex2,vertex3){
  14343. var test1=CollisionUtils.intersectsPlaneAndPoint(plane,vertex1);
  14344. var test2=CollisionUtils.intersectsPlaneAndPoint(plane,vertex2);
  14345. var test3=CollisionUtils.intersectsPlaneAndPoint(plane,vertex3);
  14346. if (test1==Plane.PlaneIntersectionType_Front && test2==Plane.PlaneIntersectionType_Front && test3==Plane.PlaneIntersectionType_Front)
  14347. return Plane.PlaneIntersectionType_Front;
  14348. if (test1==Plane.PlaneIntersectionType_Back && test2==Plane.PlaneIntersectionType_Back && test3==Plane.PlaneIntersectionType_Back)
  14349. return Plane.PlaneIntersectionType_Back;
  14350. return Plane.PlaneIntersectionType_Intersecting;
  14351. }
  14352. CollisionUtils.intersectsRayAndPlaneRD=function(ray,plane,out){
  14353. var planeNor=plane.normal;
  14354. var direction=Vector3.dot(planeNor,ray.direction);
  14355. if (MathUtils3D.isZero(direction)){
  14356. out=0;
  14357. return false;
  14358. };
  14359. var position=Vector3.dot(planeNor,ray.origin);
  14360. out=(-plane.distance-position)/ direction;
  14361. if (out < 0){
  14362. out=0;
  14363. return false;
  14364. }
  14365. return true;
  14366. }
  14367. CollisionUtils.intersectsRayAndPlaneRP=function(ray,plane,out){
  14368. var distance=NaN;
  14369. if (!CollisionUtils.intersectsRayAndPlaneRD(ray,plane,distance)){
  14370. out=Vector3._ZERO;
  14371. return false;
  14372. }
  14373. Vector3.scale(ray.direction,distance,CollisionUtils._tempV30);
  14374. Vector3.add(ray.origin,CollisionUtils._tempV30,CollisionUtils._tempV31);
  14375. out=CollisionUtils._tempV31;
  14376. return true;
  14377. }
  14378. CollisionUtils.intersectsRayAndBoxRD=function(ray,box){
  14379. var rayoe=ray.origin;
  14380. var rayoeX=rayoe.x;
  14381. var rayoeY=rayoe.y;
  14382. var rayoeZ=rayoe.z;
  14383. var rayde=ray.direction;
  14384. var raydeX=rayde.x;
  14385. var raydeY=rayde.y;
  14386. var raydeZ=rayde.z;
  14387. var boxMine=box.min;
  14388. var boxMineX=boxMine.x;
  14389. var boxMineY=boxMine.y;
  14390. var boxMineZ=boxMine.z;
  14391. var boxMaxe=box.max;
  14392. var boxMaxeX=boxMaxe.x;
  14393. var boxMaxeY=boxMaxe.y;
  14394. var boxMaxeZ=boxMaxe.z;
  14395. var out=0;
  14396. var tmax=MathUtils3D.MaxValue;
  14397. if (MathUtils3D.isZero(raydeX)){
  14398. if (rayoeX < boxMineX || rayoeX > boxMaxeX){
  14399. return-1;
  14400. }
  14401. }else {
  14402. var inverse=1 / raydeX;
  14403. var t1=(boxMineX-rayoeX)*inverse;
  14404. var t2=(boxMaxeX-rayoeX)*inverse;
  14405. if (t1 > t2){
  14406. var temp=t1;
  14407. t1=t2;
  14408. t2=temp;
  14409. }
  14410. out=Math.max(t1,out);
  14411. tmax=Math.min(t2,tmax);
  14412. if (out > tmax){
  14413. return-1;
  14414. }
  14415. }
  14416. if (MathUtils3D.isZero(raydeY)){
  14417. if (rayoeY < boxMineY || rayoeY > boxMaxeY){
  14418. return-1;
  14419. }
  14420. }else {
  14421. var inverse1=1 / raydeY;
  14422. var t3=(boxMineY-rayoeY)*inverse1;
  14423. var t4=(boxMaxeY-rayoeY)*inverse1;
  14424. if (t3 > t4){
  14425. var temp1=t3;
  14426. t3=t4;
  14427. t4=temp1;
  14428. }
  14429. out=Math.max(t3,out);
  14430. tmax=Math.min(t4,tmax);
  14431. if (out > tmax){
  14432. return-1;
  14433. }
  14434. }
  14435. if (MathUtils3D.isZero(raydeZ)){
  14436. if (rayoeZ < boxMineZ || rayoeZ > boxMaxeZ){
  14437. return-1;
  14438. }
  14439. }else {
  14440. var inverse2=1 / raydeZ;
  14441. var t5=(boxMineZ-rayoeZ)*inverse2;
  14442. var t6=(boxMaxeZ-rayoeZ)*inverse2;
  14443. if (t5 > t6){
  14444. var temp2=t5;
  14445. t5=t6;
  14446. t6=temp2;
  14447. }
  14448. out=Math.max(t5,out);
  14449. tmax=Math.min(t6,tmax);
  14450. if (out > tmax){
  14451. return-1;
  14452. }
  14453. }
  14454. return out;
  14455. }
  14456. CollisionUtils.intersectsRayAndBoxRP=function(ray,box,out){
  14457. var distance=CollisionUtils.intersectsRayAndBoxRD(ray,box);
  14458. if (distance===-1){
  14459. Vector3._ZERO.cloneTo(out);
  14460. return distance;
  14461. }
  14462. Vector3.scale(ray.direction,distance,CollisionUtils._tempV30);
  14463. Vector3.add(ray.origin,CollisionUtils._tempV30,CollisionUtils._tempV31);
  14464. CollisionUtils._tempV31.cloneTo(out);
  14465. return distance;
  14466. }
  14467. CollisionUtils.intersectsRayAndSphereRD=function(ray,sphere){
  14468. var sphereR=sphere.radius;
  14469. Vector3.subtract(ray.origin,sphere.center,CollisionUtils._tempV30);
  14470. var b=Vector3.dot(CollisionUtils._tempV30,ray.direction);
  14471. var c=Vector3.dot(CollisionUtils._tempV30,CollisionUtils._tempV30)-(sphereR *sphereR);
  14472. if (c > 0 && b > 0){
  14473. return-1;
  14474. };
  14475. var discriminant=b *b-c;
  14476. if (discriminant < 0){
  14477. return-1;
  14478. };
  14479. var distance=-b-Math.sqrt(discriminant);
  14480. if (distance < 0)
  14481. distance=0;
  14482. return distance;
  14483. }
  14484. CollisionUtils.intersectsRayAndSphereRP=function(ray,sphere,out){
  14485. var distance=CollisionUtils.intersectsRayAndSphereRD(ray,sphere);
  14486. if (distance===-1){
  14487. Vector3._ZERO.cloneTo(out);
  14488. return distance;
  14489. }
  14490. Vector3.scale(ray.direction,distance,CollisionUtils._tempV30);
  14491. Vector3.add(ray.origin,CollisionUtils._tempV30,CollisionUtils._tempV31);
  14492. CollisionUtils._tempV31.cloneTo(out);
  14493. return distance;
  14494. }
  14495. CollisionUtils.intersectsSphereAndTriangle=function(sphere,vertex1,vertex2,vertex3){
  14496. var sphereC=sphere.center;
  14497. var sphereR=sphere.radius;
  14498. CollisionUtils.closestPointPointTriangle(sphereC,vertex1,vertex2,vertex3,CollisionUtils._tempV30);
  14499. Vector3.subtract(CollisionUtils._tempV30,sphereC,CollisionUtils._tempV31);
  14500. var dot=Vector3.dot(CollisionUtils._tempV31,CollisionUtils._tempV31);
  14501. return dot <=sphereR *sphereR;
  14502. }
  14503. CollisionUtils.intersectsPlaneAndPoint=function(plane,point){
  14504. var distance=Vector3.dot(plane.normal,point)+plane.distance;
  14505. if (distance > 0)
  14506. return Plane.PlaneIntersectionType_Front;
  14507. if (distance < 0)
  14508. return Plane.PlaneIntersectionType_Back;
  14509. return Plane.PlaneIntersectionType_Intersecting;
  14510. }
  14511. CollisionUtils.intersectsPlaneAndPlane=function(plane1,plane2){
  14512. Vector3.cross(plane1.normal,plane2.normal,CollisionUtils._tempV30);
  14513. var denominator=Vector3.dot(CollisionUtils._tempV30,CollisionUtils._tempV30);
  14514. if (MathUtils3D.isZero(denominator))
  14515. return false;
  14516. return true;
  14517. }
  14518. CollisionUtils.intersectsPlaneAndPlaneRL=function(plane1,plane2,line){
  14519. var plane1nor=plane1.normal;
  14520. var plane2nor=plane2.normal;
  14521. Vector3.cross(plane1nor,plane2nor,CollisionUtils._tempV34);
  14522. var denominator=Vector3.dot(CollisionUtils._tempV34,CollisionUtils._tempV34);
  14523. if (MathUtils3D.isZero(denominator))
  14524. return false;
  14525. Vector3.scale(plane2nor,plane1.distance,CollisionUtils._tempV30);
  14526. Vector3.scale(plane1nor,plane2.distance,CollisionUtils._tempV31);
  14527. Vector3.subtract(CollisionUtils._tempV30,CollisionUtils._tempV31,CollisionUtils._tempV32);
  14528. Vector3.cross(CollisionUtils._tempV32,CollisionUtils._tempV34,CollisionUtils._tempV33);
  14529. Vector3.normalize(CollisionUtils._tempV34,CollisionUtils._tempV34);
  14530. line=new Ray(CollisionUtils._tempV33,CollisionUtils._tempV34);
  14531. return true;
  14532. }
  14533. CollisionUtils.intersectsPlaneAndBox=function(plane,box){
  14534. var planeD=plane.distance;
  14535. var planeNor=plane.normal;
  14536. var planeNoreX=planeNor.x;
  14537. var planeNoreY=planeNor.y;
  14538. var planeNoreZ=planeNor.z;
  14539. var boxMine=box.min;
  14540. var boxMineX=boxMine.x;
  14541. var boxMineY=boxMine.y;
  14542. var boxMineZ=boxMine.z;
  14543. var boxMaxe=box.max;
  14544. var boxMaxeX=boxMaxe.x;
  14545. var boxMaxeY=boxMaxe.y;
  14546. var boxMaxeZ=boxMaxe.z;
  14547. CollisionUtils._tempV30.x=(planeNoreX > 0)? boxMineX :boxMaxeX;
  14548. CollisionUtils._tempV30.y=(planeNoreY > 0)? boxMineY :boxMaxeY;
  14549. CollisionUtils._tempV30.z=(planeNoreZ > 0)? boxMineZ :boxMaxeZ;
  14550. CollisionUtils._tempV31.x=(planeNoreX > 0)? boxMaxeX :boxMineX;
  14551. CollisionUtils._tempV31.y=(planeNoreY > 0)? boxMaxeY :boxMineY;
  14552. CollisionUtils._tempV31.z=(planeNoreZ > 0)? boxMaxeZ :boxMineZ;
  14553. var distance=Vector3.dot(planeNor,CollisionUtils._tempV30);
  14554. if (distance+planeD > 0)
  14555. return Plane.PlaneIntersectionType_Front;
  14556. distance=Vector3.dot(planeNor,CollisionUtils._tempV31);
  14557. if (distance+planeD < 0)
  14558. return Plane.PlaneIntersectionType_Back;
  14559. return Plane.PlaneIntersectionType_Intersecting;
  14560. }
  14561. CollisionUtils.intersectsPlaneAndSphere=function(plane,sphere){
  14562. var sphereR=sphere.radius;
  14563. var distance=Vector3.dot(plane.normal,sphere.center)+plane.distance;
  14564. if (distance > sphereR)
  14565. return Plane.PlaneIntersectionType_Front;
  14566. if (distance <-sphereR)
  14567. return Plane.PlaneIntersectionType_Back;
  14568. return Plane.PlaneIntersectionType_Intersecting;
  14569. }
  14570. CollisionUtils.intersectsBoxAndBox=function(box1,box2){
  14571. var box1Mine=box1.min;
  14572. var box1Maxe=box1.max;
  14573. var box2Mine=box2.min;
  14574. var box2Maxe=box2.max;
  14575. if (box1Mine.x > box2Maxe.x || box2Mine.x > box1Maxe.x)
  14576. return false;
  14577. if (box1Mine.y > box2Maxe.y || box2Mine.y > box1Maxe.y)
  14578. return false;
  14579. if (box1Mine.z > box2Maxe.z || box2Mine.z > box1Maxe.z)
  14580. return false;
  14581. return true;
  14582. }
  14583. CollisionUtils.intersectsBoxAndSphere=function(box,sphere){
  14584. var sphereC=sphere.center;
  14585. var sphereR=sphere.radius;
  14586. Vector3.Clamp(sphereC,box.min,box.max,CollisionUtils._tempV30);
  14587. var distance=Vector3.distanceSquared(sphereC,CollisionUtils._tempV30);
  14588. return distance <=sphereR *sphereR;
  14589. }
  14590. CollisionUtils.intersectsSphereAndSphere=function(sphere1,sphere2){
  14591. var radiisum=sphere1.radius+sphere2.radius;
  14592. return Vector3.distanceSquared(sphere1.center,sphere2.center)<=radiisum *radiisum;
  14593. }
  14594. CollisionUtils.boxContainsPoint=function(box,point){
  14595. var boxMine=box.min;
  14596. var boxMaxe=box.max;
  14597. 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)
  14598. return /*laya.d3.math.ContainmentType.Contains*/1;
  14599. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  14600. }
  14601. CollisionUtils.boxContainsBox=function(box1,box2){
  14602. var box1Mine=box1.min;
  14603. var box1MineX=box1Mine.x;
  14604. var box1MineY=box1Mine.y;
  14605. var box1MineZ=box1Mine.z;
  14606. var box1Maxe=box1.max;
  14607. var box1MaxeX=box1Maxe.x;
  14608. var box1MaxeY=box1Maxe.y;
  14609. var box1MaxeZ=box1Maxe.z;
  14610. var box2Mine=box2.min;
  14611. var box2MineX=box2Mine.x;
  14612. var box2MineY=box2Mine.y;
  14613. var box2MineZ=box2Mine.z;
  14614. var box2Maxe=box2.max;
  14615. var box2MaxeX=box2Maxe.x;
  14616. var box2MaxeY=box2Maxe.y;
  14617. var box2MaxeZ=box2Maxe.z;
  14618. if (box1MaxeX < box2MineX || box1MineX > box2MaxeX)
  14619. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  14620. if (box1MaxeY < box2MineY || box1MineY > box2MaxeY)
  14621. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  14622. if (box1MaxeZ < box2MineZ || box1MineZ > box2MaxeZ)
  14623. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  14624. if (box1MineX <=box2MineX && box2MaxeX <=box1MaxeX && box1MineY <=box2MineY && box2MaxeY <=box1MaxeY && box1MineZ <=box2MineZ && box2MaxeZ <=box1MaxeZ){
  14625. return /*laya.d3.math.ContainmentType.Contains*/1;
  14626. }
  14627. return /*laya.d3.math.ContainmentType.Intersects*/2;
  14628. }
  14629. CollisionUtils.boxContainsSphere=function(box,sphere){
  14630. var boxMin=box.min;
  14631. var boxMineX=boxMin.x;
  14632. var boxMineY=boxMin.y;
  14633. var boxMineZ=boxMin.z;
  14634. var boxMax=box.max;
  14635. var boxMaxeX=boxMax.x;
  14636. var boxMaxeY=boxMax.y;
  14637. var boxMaxeZ=boxMax.z;
  14638. var sphereC=sphere.center;
  14639. var sphereCeX=sphereC.x;
  14640. var sphereCeY=sphereC.y;
  14641. var sphereCeZ=sphereC.z;
  14642. var sphereR=sphere.radius;
  14643. Vector3.Clamp(sphereC,boxMin,boxMax,CollisionUtils._tempV30);
  14644. var distance=Vector3.distanceSquared(sphereC,CollisionUtils._tempV30);
  14645. if (distance > sphereR *sphereR)
  14646. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  14647. if ((((boxMineX+sphereR <=sphereCeX)&& (sphereCeX <=boxMaxeX-sphereR))&& ((boxMaxeX-boxMineX > sphereR)&&
  14648. (boxMineY+sphereR <=sphereCeY)))&& (((sphereCeY <=boxMaxeY-sphereR)&& (boxMaxeY-boxMineY > sphereR))&&
  14649. (((boxMineZ+sphereR <=sphereCeZ)&& (sphereCeZ <=boxMaxeZ-sphereR))&& (boxMaxeZ-boxMineZ > sphereR))))
  14650. return /*laya.d3.math.ContainmentType.Contains*/1;
  14651. return /*laya.d3.math.ContainmentType.Intersects*/2;
  14652. }
  14653. CollisionUtils.sphereContainsPoint=function(sphere,point){
  14654. if (Vector3.distanceSquared(point,sphere.center)<=sphere.radius *sphere.radius)
  14655. return /*laya.d3.math.ContainmentType.Contains*/1;
  14656. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  14657. }
  14658. CollisionUtils.sphereContainsTriangle=function(sphere,vertex1,vertex2,vertex3){
  14659. var test1=CollisionUtils.sphereContainsPoint(sphere,vertex1);
  14660. var test2=CollisionUtils.sphereContainsPoint(sphere,vertex2);
  14661. var test3=CollisionUtils.sphereContainsPoint(sphere,vertex3);
  14662. if (test1==/*laya.d3.math.ContainmentType.Contains*/1 && test2==/*laya.d3.math.ContainmentType.Contains*/1 && test3==/*laya.d3.math.ContainmentType.Contains*/1)
  14663. return /*laya.d3.math.ContainmentType.Contains*/1;
  14664. if (CollisionUtils.intersectsSphereAndTriangle(sphere,vertex1,vertex2,vertex3))
  14665. return /*laya.d3.math.ContainmentType.Intersects*/2;
  14666. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  14667. }
  14668. CollisionUtils.sphereContainsBox=function(sphere,box){
  14669. var sphereC=sphere.center;
  14670. var sphereCeX=sphereC.x;
  14671. var sphereCeY=sphereC.y;
  14672. var sphereCeZ=sphereC.z;
  14673. var sphereR=sphere.radius;
  14674. var boxMin=box.min;
  14675. var boxMineX=boxMin.x;
  14676. var boxMineY=boxMin.y;
  14677. var boxMineZ=boxMin.z;
  14678. var boxMax=box.max;
  14679. var boxMaxeX=boxMax.x;
  14680. var boxMaxeY=boxMax.y;
  14681. var boxMaxeZ=boxMax.z;
  14682. var _tempV30e=CollisionUtils._tempV30;
  14683. var _tempV30eX=_tempV30e.x;
  14684. var _tempV30eY=_tempV30e.y;
  14685. var _tempV30eZ=_tempV30e.z;
  14686. if (!CollisionUtils.intersectsBoxAndSphere(box,sphere))
  14687. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  14688. var radiusSquared=sphereR *sphereR;
  14689. _tempV30eX=sphereCeX-boxMineX;
  14690. _tempV30eY=sphereCeY-boxMaxeY;
  14691. _tempV30eZ=sphereCeZ-boxMaxeZ;
  14692. if (Vector3.scalarLengthSquared(CollisionUtils._tempV30)> radiusSquared)
  14693. return /*laya.d3.math.ContainmentType.Intersects*/2;
  14694. _tempV30eX=sphereCeX-boxMaxeX;
  14695. _tempV30eY=sphereCeY-boxMaxeY;
  14696. _tempV30eZ=sphereCeZ-boxMaxeZ;
  14697. if (Vector3.scalarLengthSquared(CollisionUtils._tempV30)> radiusSquared)
  14698. return /*laya.d3.math.ContainmentType.Intersects*/2;
  14699. _tempV30eX=sphereCeX-boxMaxeX;
  14700. _tempV30eY=sphereCeY-boxMineY;
  14701. _tempV30eZ=sphereCeZ-boxMaxeZ;
  14702. if (Vector3.scalarLengthSquared(CollisionUtils._tempV30)> radiusSquared)
  14703. return /*laya.d3.math.ContainmentType.Intersects*/2;
  14704. _tempV30eX=sphereCeX-boxMineX;
  14705. _tempV30eY=sphereCeY-boxMineY;
  14706. _tempV30eZ=sphereCeZ-boxMaxeZ;
  14707. if (Vector3.scalarLengthSquared(CollisionUtils._tempV30)> radiusSquared)
  14708. return /*laya.d3.math.ContainmentType.Intersects*/2;
  14709. _tempV30eX=sphereCeX-boxMineX;
  14710. _tempV30eY=sphereCeY-boxMaxeY;
  14711. _tempV30eZ=sphereCeZ-boxMineZ;
  14712. if (Vector3.scalarLengthSquared(CollisionUtils._tempV30)> radiusSquared)
  14713. return /*laya.d3.math.ContainmentType.Intersects*/2;
  14714. _tempV30eX=sphereCeX-boxMaxeX;
  14715. _tempV30eY=sphereCeY-boxMaxeY;
  14716. _tempV30eZ=sphereCeZ-boxMineZ;
  14717. if (Vector3.scalarLengthSquared(CollisionUtils._tempV30)> radiusSquared)
  14718. return /*laya.d3.math.ContainmentType.Intersects*/2;
  14719. _tempV30eX=sphereCeX-boxMaxeX;
  14720. _tempV30eY=sphereCeY-boxMineY;
  14721. _tempV30eZ=sphereCeZ-boxMineZ;
  14722. if (Vector3.scalarLengthSquared(CollisionUtils._tempV30)> radiusSquared)
  14723. return /*laya.d3.math.ContainmentType.Intersects*/2;
  14724. _tempV30eX=sphereCeX-boxMineX;
  14725. _tempV30eY=sphereCeY-boxMineY;
  14726. _tempV30eZ=sphereCeZ-boxMineZ;
  14727. if (Vector3.scalarLengthSquared(CollisionUtils._tempV30)> radiusSquared)
  14728. return /*laya.d3.math.ContainmentType.Intersects*/2;
  14729. return /*laya.d3.math.ContainmentType.Contains*/1;
  14730. }
  14731. CollisionUtils.sphereContainsSphere=function(sphere1,sphere2){
  14732. var sphere1R=sphere1.radius;
  14733. var sphere2R=sphere2.radius;
  14734. var distance=Vector3.distance(sphere1.center,sphere2.center);
  14735. if (sphere1R+sphere2R < distance)
  14736. return /*laya.d3.math.ContainmentType.Disjoint*/0;
  14737. if (sphere1R-sphere2R < distance)
  14738. return /*laya.d3.math.ContainmentType.Intersects*/2;
  14739. return /*laya.d3.math.ContainmentType.Contains*/1;
  14740. }
  14741. CollisionUtils.closestPointPointTriangle=function(point,vertex1,vertex2,vertex3,out){
  14742. Vector3.subtract(vertex2,vertex1,CollisionUtils._tempV30);
  14743. Vector3.subtract(vertex3,vertex1,CollisionUtils._tempV31);
  14744. Vector3.subtract(point,vertex1,CollisionUtils._tempV32);
  14745. Vector3.subtract(point,vertex2,CollisionUtils._tempV33);
  14746. Vector3.subtract(point,vertex3,CollisionUtils._tempV34);
  14747. var d1=Vector3.dot(CollisionUtils._tempV30,CollisionUtils._tempV32);
  14748. var d2=Vector3.dot(CollisionUtils._tempV31,CollisionUtils._tempV32);
  14749. var d3=Vector3.dot(CollisionUtils._tempV30,CollisionUtils._tempV33);
  14750. var d4=Vector3.dot(CollisionUtils._tempV31,CollisionUtils._tempV33);
  14751. var d5=Vector3.dot(CollisionUtils._tempV30,CollisionUtils._tempV34);
  14752. var d6=Vector3.dot(CollisionUtils._tempV31,CollisionUtils._tempV34);
  14753. if (d1 <=0 && d2 <=0){
  14754. vertex1.cloneTo(out);
  14755. return;
  14756. }
  14757. if (d3 >=0 && d4 <=d3){
  14758. vertex2.cloneTo(out);
  14759. return;
  14760. };
  14761. var vc=d1 *d4-d3 *d2;
  14762. if (vc <=0 && d1 >=0 && d3 <=0){
  14763. var v=d1 / (d1-d3);
  14764. Vector3.scale(CollisionUtils._tempV30,v,out);
  14765. Vector3.add(vertex1,out,out);
  14766. return;
  14767. }
  14768. if (d6 >=0 && d5 <=d6){
  14769. vertex3.cloneTo(out);
  14770. return;
  14771. };
  14772. var vb=d5 *d2-d1 *d6;
  14773. if (vb <=0 && d2 >=0 && d6 <=0){
  14774. var w=d2 / (d2-d6);
  14775. Vector3.scale(CollisionUtils._tempV31,w,out);
  14776. Vector3.add(vertex1,out,out);
  14777. return;
  14778. };
  14779. var va=d3 *d6-d5 *d4;
  14780. if (va <=0 && (d4-d3)>=0 && (d5-d6)>=0){
  14781. var w3=(d4-d3)/ ((d4-d3)+(d5-d6));
  14782. Vector3.subtract(vertex3,vertex2,out);
  14783. Vector3.scale(out,w3,out);
  14784. Vector3.add(vertex2,out,out);
  14785. return;
  14786. };
  14787. var denom=1 / (va+vb+vc);
  14788. var v2=vb *denom;
  14789. var w2=vc *denom;
  14790. Vector3.scale(CollisionUtils._tempV30,v2,CollisionUtils._tempV35);
  14791. Vector3.scale(CollisionUtils._tempV31,w2,CollisionUtils._tempV36);
  14792. Vector3.add(CollisionUtils._tempV35,CollisionUtils._tempV36,out);
  14793. Vector3.add(vertex1,out,out);
  14794. }
  14795. CollisionUtils.closestPointPlanePoint=function(plane,point,out){
  14796. var planeN=plane.normal;
  14797. var t=Vector3.dot(planeN,point)-plane.distance;
  14798. Vector3.scale(planeN,t,CollisionUtils._tempV30);
  14799. Vector3.subtract(point,CollisionUtils._tempV30,out);
  14800. }
  14801. CollisionUtils.closestPointBoxPoint=function(box,point,out){
  14802. Vector3.max(point,box.min,CollisionUtils._tempV30);
  14803. Vector3.min(CollisionUtils._tempV30,box.max,out);
  14804. }
  14805. CollisionUtils.closestPointSpherePoint=function(sphere,point,out){
  14806. var sphereC=sphere.center;
  14807. Vector3.subtract(point,sphereC,out);
  14808. Vector3.normalize(out,out);
  14809. Vector3.scale(out,sphere.radius,out);
  14810. Vector3.add(out,sphereC,out);
  14811. }
  14812. CollisionUtils.closestPointSphereSphere=function(sphere1,sphere2,out){
  14813. var sphere1C=sphere1.center;
  14814. Vector3.subtract(sphere2.center,sphere1C,out);
  14815. Vector3.normalize(out,out);
  14816. Vector3.scale(out,sphere1.radius,out);
  14817. Vector3.add(out,sphere1C,out);
  14818. }
  14819. __static(CollisionUtils,
  14820. ['_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();}
  14821. ]);
  14822. return CollisionUtils;
  14823. })()
  14824. /**
  14825. *@private
  14826. */
  14827. //class laya.d3.core.particleShuriKen.ShurikenParticleData
  14828. var ShurikenParticleData=(function(){
  14829. function ShurikenParticleData(){}
  14830. __class(ShurikenParticleData,'laya.d3.core.particleShuriKen.ShurikenParticleData');
  14831. ShurikenParticleData._getStartLifetimeFromGradient=function(startLifeTimeGradient,emissionTime){
  14832. for (var i=1,n=startLifeTimeGradient.gradientCount;i < n;i++){
  14833. var key=startLifeTimeGradient.getKeyByIndex(i);
  14834. if (key >=emissionTime){
  14835. var lastKey=startLifeTimeGradient.getKeyByIndex(i-1);
  14836. var age=(emissionTime-lastKey)/ (key-lastKey);
  14837. return MathUtil.lerp(startLifeTimeGradient.getValueByIndex(i-1),startLifeTimeGradient.getValueByIndex(i),age)
  14838. }
  14839. }
  14840. throw new Error("ShurikenParticleData: can't get value foam startLifeTimeGradient.");
  14841. }
  14842. ShurikenParticleData._randomInvertRoationArray=function(rotatonE,outE,randomizeRotationDirection,rand,randomSeeds){
  14843. var randDic=NaN;
  14844. if (rand){
  14845. rand.seed=randomSeeds[6];
  14846. randDic=rand.getFloat();
  14847. randomSeeds[6]=rand.seed;
  14848. }else {
  14849. randDic=Math.random();
  14850. }
  14851. if (randDic < randomizeRotationDirection){
  14852. outE.x=-rotatonE.x;
  14853. outE.y=-rotatonE.y;
  14854. outE.z=-rotatonE.z;
  14855. }else {
  14856. outE.x=rotatonE.x;
  14857. outE.y=rotatonE.y;
  14858. outE.z=rotatonE.z;
  14859. }
  14860. }
  14861. ShurikenParticleData._randomInvertRoation=function(rotaton,randomizeRotationDirection,rand,randomSeeds){
  14862. var randDic=NaN;
  14863. if (rand){
  14864. rand.seed=randomSeeds[6];
  14865. randDic=rand.getFloat();
  14866. randomSeeds[6]=rand.seed;
  14867. }else {
  14868. randDic=Math.random();
  14869. }
  14870. if (randDic < randomizeRotationDirection)
  14871. rotaton=-rotaton;
  14872. return rotaton;
  14873. }
  14874. ShurikenParticleData.create=function(particleSystem,particleRender,transform){
  14875. var autoRandomSeed=particleSystem.autoRandomSeed;
  14876. var rand=particleSystem._rand;
  14877. var randomSeeds=particleSystem._randomSeeds;
  14878. switch (particleSystem.startColorType){
  14879. case 0:;
  14880. var constantStartColor=particleSystem.startColorConstant;
  14881. ShurikenParticleData.startColor.x=constantStartColor.x;
  14882. ShurikenParticleData.startColor.y=constantStartColor.y;
  14883. ShurikenParticleData.startColor.z=constantStartColor.z;
  14884. ShurikenParticleData.startColor.w=constantStartColor.w;
  14885. break ;
  14886. case 2:
  14887. if (autoRandomSeed){
  14888. Vector4.lerp(particleSystem.startColorConstantMin,particleSystem.startColorConstantMax,Math.random(),ShurikenParticleData.startColor);
  14889. }else {
  14890. rand.seed=randomSeeds[3];
  14891. Vector4.lerp(particleSystem.startColorConstantMin,particleSystem.startColorConstantMax,rand.getFloat(),ShurikenParticleData.startColor);
  14892. randomSeeds[3]=rand.seed;
  14893. }
  14894. break ;
  14895. };
  14896. var colorOverLifetime=particleSystem.colorOverLifetime;
  14897. if (colorOverLifetime && colorOverLifetime.enbale){
  14898. var color=colorOverLifetime.color;
  14899. switch (color.type){
  14900. case 0:
  14901. ShurikenParticleData.startColor.x=ShurikenParticleData.startColor.x *color.constant.x;
  14902. ShurikenParticleData.startColor.y=ShurikenParticleData.startColor.y *color.constant.y;
  14903. ShurikenParticleData.startColor.z=ShurikenParticleData.startColor.z *color.constant.z;
  14904. ShurikenParticleData.startColor.w=ShurikenParticleData.startColor.w *color.constant.w;
  14905. break ;
  14906. case 2:;
  14907. var colorRandom=NaN;
  14908. if (autoRandomSeed){
  14909. colorRandom=Math.random();
  14910. }else {
  14911. rand.seed=randomSeeds[10];
  14912. colorRandom=rand.getFloat();
  14913. randomSeeds[10]=rand.seed;
  14914. };
  14915. var minConstantColor=color.constantMin;
  14916. var maxConstantColor=color.constantMax;
  14917. ShurikenParticleData.startColor.x=ShurikenParticleData.startColor.x *MathUtil.lerp(minConstantColor.x,maxConstantColor.x,colorRandom);
  14918. ShurikenParticleData.startColor.y=ShurikenParticleData.startColor.y *MathUtil.lerp(minConstantColor.y,maxConstantColor.y,colorRandom);
  14919. ShurikenParticleData.startColor.z=ShurikenParticleData.startColor.z *MathUtil.lerp(minConstantColor.z,maxConstantColor.z,colorRandom);
  14920. ShurikenParticleData.startColor.w=ShurikenParticleData.startColor.w *MathUtil.lerp(minConstantColor.w,maxConstantColor.w,colorRandom);
  14921. break ;
  14922. }
  14923. };
  14924. var particleSize=ShurikenParticleData.startSize;
  14925. switch (particleSystem.startSizeType){
  14926. case 0:
  14927. if (particleSystem.threeDStartSize){
  14928. var startSizeConstantSeparate=particleSystem.startSizeConstantSeparate;
  14929. particleSize[0]=startSizeConstantSeparate.x;
  14930. particleSize[1]=startSizeConstantSeparate.y;
  14931. particleSize[2]=startSizeConstantSeparate.z;
  14932. }else {
  14933. particleSize[0]=particleSize[1]=particleSize[2]=particleSystem.startSizeConstant;
  14934. }
  14935. break ;
  14936. case 2:
  14937. if (particleSystem.threeDStartSize){
  14938. var startSizeConstantMinSeparate=particleSystem.startSizeConstantMinSeparate;
  14939. var startSizeConstantMaxSeparate=particleSystem.startSizeConstantMaxSeparate;
  14940. if (autoRandomSeed){
  14941. particleSize[0]=MathUtil.lerp(startSizeConstantMinSeparate.x,startSizeConstantMaxSeparate.x,Math.random());
  14942. particleSize[1]=MathUtil.lerp(startSizeConstantMinSeparate.y,startSizeConstantMaxSeparate.y,Math.random());
  14943. particleSize[2]=MathUtil.lerp(startSizeConstantMinSeparate.z,startSizeConstantMaxSeparate.z,Math.random());
  14944. }else {
  14945. rand.seed=randomSeeds[4];
  14946. particleSize[0]=MathUtil.lerp(startSizeConstantMinSeparate.x,startSizeConstantMaxSeparate.x,rand.getFloat());
  14947. particleSize[1]=MathUtil.lerp(startSizeConstantMinSeparate.y,startSizeConstantMaxSeparate.y,rand.getFloat());
  14948. particleSize[2]=MathUtil.lerp(startSizeConstantMinSeparate.z,startSizeConstantMaxSeparate.z,rand.getFloat());
  14949. randomSeeds[4]=rand.seed;
  14950. }
  14951. }else {
  14952. if (autoRandomSeed){
  14953. particleSize[0]=particleSize[1]=particleSize[2]=MathUtil.lerp(particleSystem.startSizeConstantMin,particleSystem.startSizeConstantMax,Math.random());
  14954. }else {
  14955. rand.seed=randomSeeds[4];
  14956. particleSize[0]=particleSize[1]=particleSize[2]=MathUtil.lerp(particleSystem.startSizeConstantMin,particleSystem.startSizeConstantMax,rand.getFloat());
  14957. randomSeeds[4]=rand.seed;
  14958. }
  14959. }
  14960. break ;
  14961. };
  14962. var sizeOverLifetime=particleSystem.sizeOverLifetime;
  14963. if (sizeOverLifetime && sizeOverLifetime.enbale && sizeOverLifetime.size.type===1){
  14964. var size=sizeOverLifetime.size;
  14965. if (size.separateAxes){
  14966. if (autoRandomSeed){
  14967. particleSize[0]=particleSize[0] *MathUtil.lerp(size.constantMinSeparate.x,size.constantMaxSeparate.x,Math.random());
  14968. particleSize[1]=particleSize[1] *MathUtil.lerp(size.constantMinSeparate.y,size.constantMaxSeparate.y,Math.random());
  14969. particleSize[2]=particleSize[2] *MathUtil.lerp(size.constantMinSeparate.z,size.constantMaxSeparate.z,Math.random());
  14970. }else {
  14971. rand.seed=randomSeeds[11];
  14972. particleSize[0]=particleSize[0] *MathUtil.lerp(size.constantMinSeparate.x,size.constantMaxSeparate.x,rand.getFloat());
  14973. particleSize[1]=particleSize[1] *MathUtil.lerp(size.constantMinSeparate.y,size.constantMaxSeparate.y,rand.getFloat());
  14974. particleSize[2]=particleSize[2] *MathUtil.lerp(size.constantMinSeparate.z,size.constantMaxSeparate.z,rand.getFloat());
  14975. randomSeeds[11]=rand.seed;
  14976. }
  14977. }else {
  14978. var randomSize=NaN;
  14979. if (autoRandomSeed){
  14980. randomSize=MathUtil.lerp(size.constantMin,size.constantMax,Math.random());
  14981. }else {
  14982. rand.seed=randomSeeds[11];
  14983. randomSize=MathUtil.lerp(size.constantMin,size.constantMax,rand.getFloat());
  14984. randomSeeds[11]=rand.seed;
  14985. }
  14986. particleSize[0]=particleSize[0] *randomSize;
  14987. particleSize[1]=particleSize[1] *randomSize;
  14988. particleSize[2]=particleSize[2] *randomSize;
  14989. }
  14990. };
  14991. var renderMode=particleRender.renderMode;
  14992. if (renderMode!==1){
  14993. switch (particleSystem.startRotationType){
  14994. case 0:
  14995. if (particleSystem.threeDStartRotation){
  14996. var startRotationConstantSeparate=particleSystem.startRotationConstantSeparate;
  14997. var randomRotationE=ShurikenParticleData._tempVector30;
  14998. ShurikenParticleData._randomInvertRoationArray(startRotationConstantSeparate,randomRotationE,particleSystem.randomizeRotationDirection,autoRandomSeed ? null :rand,randomSeeds);
  14999. ShurikenParticleData.startRotation[0]=randomRotationE.x;
  15000. ShurikenParticleData.startRotation[1]=randomRotationE.y;
  15001. if (renderMode!==4)
  15002. ShurikenParticleData.startRotation[2]=-randomRotationE.z;
  15003. else
  15004. ShurikenParticleData.startRotation[2]=randomRotationE.z;
  15005. }else {
  15006. ShurikenParticleData.startRotation[0]=ShurikenParticleData._randomInvertRoation(particleSystem.startRotationConstant,particleSystem.randomizeRotationDirection,autoRandomSeed ? null :rand,randomSeeds);
  15007. ShurikenParticleData.startRotation[1]=0;
  15008. ShurikenParticleData.startRotation[2]=0;
  15009. }
  15010. break ;
  15011. case 2:
  15012. if (particleSystem.threeDStartRotation){
  15013. var startRotationConstantMinSeparate=particleSystem.startRotationConstantMinSeparate;
  15014. var startRotationConstantMaxSeparate=particleSystem.startRotationConstantMaxSeparate;
  15015. var lerpRoationE=ShurikenParticleData._tempVector30;
  15016. if (autoRandomSeed){
  15017. lerpRoationE.x=MathUtil.lerp(startRotationConstantMinSeparate.x,startRotationConstantMaxSeparate.x,Math.random());
  15018. lerpRoationE.y=MathUtil.lerp(startRotationConstantMinSeparate.y,startRotationConstantMaxSeparate.y,Math.random());
  15019. lerpRoationE.z=MathUtil.lerp(startRotationConstantMinSeparate.z,startRotationConstantMaxSeparate.z,Math.random());
  15020. }else {
  15021. rand.seed=randomSeeds[5];
  15022. lerpRoationE.x=MathUtil.lerp(startRotationConstantMinSeparate.x,startRotationConstantMaxSeparate.x,rand.getFloat());
  15023. lerpRoationE.y=MathUtil.lerp(startRotationConstantMinSeparate.y,startRotationConstantMaxSeparate.y,rand.getFloat());
  15024. lerpRoationE.z=MathUtil.lerp(startRotationConstantMinSeparate.z,startRotationConstantMaxSeparate.z,rand.getFloat());
  15025. randomSeeds[5]=rand.seed;
  15026. }
  15027. ShurikenParticleData._randomInvertRoationArray(lerpRoationE,lerpRoationE,particleSystem.randomizeRotationDirection,autoRandomSeed ? null :rand,randomSeeds);
  15028. ShurikenParticleData.startRotation[0]=lerpRoationE.x;
  15029. ShurikenParticleData.startRotation[1]=lerpRoationE.y;
  15030. if (renderMode!==4)
  15031. ShurikenParticleData.startRotation[2]=-lerpRoationE.z;
  15032. else
  15033. ShurikenParticleData.startRotation[2]=lerpRoationE.z;
  15034. }else {
  15035. if (autoRandomSeed){
  15036. ShurikenParticleData.startRotation[0]=ShurikenParticleData._randomInvertRoation(MathUtil.lerp(particleSystem.startRotationConstantMin,particleSystem.startRotationConstantMax,Math.random()),particleSystem.randomizeRotationDirection,autoRandomSeed ? null :rand,randomSeeds);
  15037. }else {
  15038. rand.seed=randomSeeds[5];
  15039. ShurikenParticleData.startRotation[0]=ShurikenParticleData._randomInvertRoation(MathUtil.lerp(particleSystem.startRotationConstantMin,particleSystem.startRotationConstantMax,rand.getFloat()),particleSystem.randomizeRotationDirection,autoRandomSeed ? null :rand,randomSeeds);
  15040. randomSeeds[5]=rand.seed;
  15041. }
  15042. }
  15043. break ;
  15044. }
  15045. }
  15046. switch (particleSystem.startLifetimeType){
  15047. case 0:
  15048. ShurikenParticleData.startLifeTime=particleSystem.startLifetimeConstant;
  15049. break ;
  15050. case 1:
  15051. ShurikenParticleData.startLifeTime=ShurikenParticleData._getStartLifetimeFromGradient(particleSystem.startLifeTimeGradient,particleSystem.emissionTime);
  15052. break ;
  15053. case 2:
  15054. if (autoRandomSeed){
  15055. ShurikenParticleData.startLifeTime=MathUtil.lerp(particleSystem.startLifetimeConstantMin,particleSystem.startLifetimeConstantMax,Math.random());
  15056. }else {
  15057. rand.seed=randomSeeds[7];
  15058. ShurikenParticleData.startLifeTime=MathUtil.lerp(particleSystem.startLifetimeConstantMin,particleSystem.startLifetimeConstantMax,rand.getFloat());
  15059. randomSeeds[7]=rand.seed;
  15060. }
  15061. break ;
  15062. case 3:;
  15063. var emissionTime=particleSystem.emissionTime;
  15064. if (autoRandomSeed){
  15065. ShurikenParticleData.startLifeTime=MathUtil.lerp(ShurikenParticleData._getStartLifetimeFromGradient(particleSystem.startLifeTimeGradientMin,emissionTime),ShurikenParticleData._getStartLifetimeFromGradient(particleSystem.startLifeTimeGradientMax,emissionTime),Math.random());
  15066. }else {
  15067. rand.seed=randomSeeds[7];
  15068. ShurikenParticleData.startLifeTime=MathUtil.lerp(ShurikenParticleData._getStartLifetimeFromGradient(particleSystem.startLifeTimeGradientMin,emissionTime),ShurikenParticleData._getStartLifetimeFromGradient(particleSystem.startLifeTimeGradientMax,emissionTime),rand.getFloat());
  15069. randomSeeds[7]=rand.seed;
  15070. }
  15071. break ;
  15072. }
  15073. switch (particleSystem.startSpeedType){
  15074. case 0:
  15075. ShurikenParticleData.startSpeed=particleSystem.startSpeedConstant;
  15076. break ;
  15077. case 2:
  15078. if (autoRandomSeed){
  15079. ShurikenParticleData.startSpeed=MathUtil.lerp(particleSystem.startSpeedConstantMin,particleSystem.startSpeedConstantMax,Math.random());
  15080. }else {
  15081. rand.seed=randomSeeds[8];
  15082. ShurikenParticleData.startSpeed=MathUtil.lerp(particleSystem.startSpeedConstantMin,particleSystem.startSpeedConstantMax,rand.getFloat());
  15083. randomSeeds[8]=rand.seed;
  15084. }
  15085. break ;
  15086. };
  15087. var textureSheetAnimation=particleSystem.textureSheetAnimation;
  15088. var enableSheetAnimation=textureSheetAnimation && textureSheetAnimation.enable;
  15089. if (enableSheetAnimation){
  15090. var title=textureSheetAnimation.tiles;
  15091. var titleX=title.x,titleY=title.y;
  15092. var subU=1.0 / titleX,subV=1.0 / titleY;
  15093. var startFrameCount=0;
  15094. var startFrame=textureSheetAnimation.startFrame;
  15095. switch (startFrame.type){
  15096. case 0:
  15097. startFrameCount=startFrame.constant;
  15098. break ;
  15099. case 1:
  15100. if (autoRandomSeed){
  15101. startFrameCount=MathUtil.lerp(startFrame.constantMin,startFrame.constantMax,Math.random());
  15102. }else {
  15103. rand.seed=randomSeeds[14];
  15104. startFrameCount=MathUtil.lerp(startFrame.constantMin,startFrame.constantMax,rand.getFloat());
  15105. randomSeeds[14]=rand.seed;
  15106. }
  15107. break ;
  15108. };
  15109. var frame=textureSheetAnimation.frame;
  15110. switch (frame.type){
  15111. case 0:
  15112. startFrameCount+=frame.constant;
  15113. break ;
  15114. case 2:
  15115. if (autoRandomSeed){
  15116. startFrameCount+=MathUtil.lerp(frame.constantMin,frame.constantMax,Math.random());
  15117. }else {
  15118. rand.seed=randomSeeds[15];
  15119. startFrameCount+=MathUtil.lerp(frame.constantMin,frame.constantMax,rand.getFloat());
  15120. randomSeeds[15]=rand.seed;
  15121. }
  15122. break ;
  15123. };
  15124. var startRow=0;
  15125. switch (textureSheetAnimation.type){
  15126. case 0:
  15127. startRow=Math.floor(startFrameCount / titleX);
  15128. break ;
  15129. case 1:
  15130. if (textureSheetAnimation.randomRow){
  15131. if (autoRandomSeed){
  15132. startRow=Math.floor(Math.random()*titleY);
  15133. }else {
  15134. rand.seed=randomSeeds[13];
  15135. startRow=Math.floor(rand.getFloat()*titleY);
  15136. randomSeeds[13]=rand.seed;
  15137. }
  15138. }else {
  15139. startRow=textureSheetAnimation.rowIndex;
  15140. }
  15141. break ;
  15142. };
  15143. var startCol=Math.floor(startFrameCount % titleX);
  15144. ShurikenParticleData.startUVInfo=ShurikenParticleData.startUVInfo;
  15145. ShurikenParticleData.startUVInfo[0]=subU;
  15146. ShurikenParticleData.startUVInfo[1]=subV;
  15147. ShurikenParticleData.startUVInfo[2]=startCol *subU;
  15148. ShurikenParticleData.startUVInfo[3]=startRow *subV;
  15149. }else {
  15150. ShurikenParticleData.startUVInfo=ShurikenParticleData.startUVInfo;
  15151. ShurikenParticleData.startUVInfo[0]=1.0;
  15152. ShurikenParticleData.startUVInfo[1]=1.0;
  15153. ShurikenParticleData.startUVInfo[2]=0.0;
  15154. ShurikenParticleData.startUVInfo[3]=0.0;
  15155. }
  15156. switch (particleSystem.simulationSpace){
  15157. case 0:;
  15158. var position=transform.position;
  15159. ShurikenParticleData.simulationWorldPostion[0]=position.x;
  15160. ShurikenParticleData.simulationWorldPostion[1]=position.y;
  15161. ShurikenParticleData.simulationWorldPostion[2]=position.z;
  15162. var rotation=transform.rotation;
  15163. ShurikenParticleData.simulationWorldRotation[0]=rotation.x;
  15164. ShurikenParticleData.simulationWorldRotation[1]=rotation.y;
  15165. ShurikenParticleData.simulationWorldRotation[2]=rotation.z;
  15166. ShurikenParticleData.simulationWorldRotation[3]=rotation.w;
  15167. break ;
  15168. case 1:
  15169. break ;
  15170. default :
  15171. throw new Error("ShurikenParticleMaterial: SimulationSpace value is invalid.");
  15172. break ;
  15173. }
  15174. }
  15175. ShurikenParticleData.startLifeTime=NaN;
  15176. ShurikenParticleData.startSpeed=NaN;
  15177. __static(ShurikenParticleData,
  15178. ['_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);}
  15179. ]);
  15180. return ShurikenParticleData;
  15181. })()
  15182. /**
  15183. *<code>BoundsOctreeNode</code> 类用于创建八叉树节点。
  15184. */
  15185. //class laya.d3.core.scene.BoundsOctreeNode
  15186. var BoundsOctreeNode=(function(){
  15187. function BoundsOctreeNode(octree,parent,baseLength,center){
  15188. /**@private */
  15189. this._octree=null;
  15190. /**@private */
  15191. this._parent=null;
  15192. /**@private */
  15193. this._children=null;
  15194. /**@private [Debug]*/
  15195. this._isContaion=false;
  15196. /**@private [只读]*/
  15197. this.baseLength=0.0;
  15198. this._bounds=new BoundBox(new Vector3(),new Vector3());
  15199. this._objects=[];
  15200. this.center=new Vector3();
  15201. this._setValues(octree,parent,baseLength,center);
  15202. }
  15203. __class(BoundsOctreeNode,'laya.d3.core.scene.BoundsOctreeNode');
  15204. var __proto=BoundsOctreeNode.prototype;
  15205. /**
  15206. *@private
  15207. */
  15208. __proto._setValues=function(octree,parent,baseLength,center){
  15209. this._octree=octree;
  15210. this._parent=parent;
  15211. this.baseLength=baseLength;
  15212. center.cloneTo(this.center);
  15213. var min=this._bounds.min;
  15214. var max=this._bounds.max;
  15215. var halfSize=(octree._looseness *baseLength)/ 2;
  15216. min.setValue(center.x-halfSize,center.y-halfSize,center.z-halfSize);
  15217. max.setValue(center.x+halfSize,center.y+halfSize,center.z+halfSize);
  15218. }
  15219. /**
  15220. *@private
  15221. */
  15222. __proto._getChildBound=function(index){
  15223. if (this._children !=null && this._children[index]){
  15224. return this._children[index]._bounds;
  15225. }else {
  15226. var quarter=this.baseLength / 4;
  15227. var halfChildSize=((this.baseLength / 2)*this._octree._looseness)/ 2;
  15228. var bounds=BoundsOctreeNode._tempBoundBox;
  15229. var min=bounds.min;
  15230. var max=bounds.max;
  15231. switch (index){
  15232. case 0:
  15233. min.x=this.center.x-quarter-halfChildSize;
  15234. min.y=this.center.y+quarter-halfChildSize;
  15235. min.z=this.center.z-quarter-halfChildSize;
  15236. max.x=this.center.x-quarter+halfChildSize;
  15237. max.y=this.center.y+quarter+halfChildSize;
  15238. max.z=this.center.z-quarter+halfChildSize;
  15239. break ;
  15240. case 1:
  15241. min.x=this.center.x+quarter-halfChildSize;
  15242. min.y=this.center.y+quarter-halfChildSize;
  15243. min.z=this.center.z-quarter-halfChildSize;
  15244. max.x=this.center.x+quarter+halfChildSize;
  15245. max.y=this.center.y+quarter+halfChildSize;
  15246. max.z=this.center.z-quarter+halfChildSize;
  15247. break ;
  15248. case 2:
  15249. min.x=this.center.x-quarter-halfChildSize;
  15250. min.y=this.center.y+quarter-halfChildSize;
  15251. min.z=this.center.z+quarter-halfChildSize;
  15252. max.x=this.center.x-quarter+halfChildSize;
  15253. max.y=this.center.y+quarter+halfChildSize;
  15254. max.z=this.center.z+quarter+halfChildSize;
  15255. break ;
  15256. case 3:
  15257. min.x=this.center.x+quarter-halfChildSize;
  15258. min.y=this.center.y+quarter-halfChildSize;
  15259. min.z=this.center.z+quarter-halfChildSize;
  15260. max.x=this.center.x+quarter+halfChildSize;
  15261. max.y=this.center.y+quarter+halfChildSize;
  15262. max.z=this.center.z+quarter+halfChildSize;
  15263. break ;
  15264. case 4:
  15265. min.x=this.center.x-quarter-halfChildSize;
  15266. min.y=this.center.y-quarter-halfChildSize;
  15267. min.z=this.center.z-quarter-halfChildSize;
  15268. max.x=this.center.x-quarter+halfChildSize;
  15269. max.y=this.center.y-quarter+halfChildSize;
  15270. max.z=this.center.z-quarter+halfChildSize;
  15271. break ;
  15272. case 5:
  15273. min.x=this.center.x+quarter-halfChildSize;
  15274. min.y=this.center.y-quarter-halfChildSize;
  15275. min.z=this.center.z-quarter-halfChildSize;
  15276. max.x=this.center.x+quarter+halfChildSize;
  15277. max.y=this.center.y-quarter+halfChildSize;
  15278. max.z=this.center.z-quarter+halfChildSize;
  15279. break ;
  15280. case 6:
  15281. min.x=this.center.x-quarter-halfChildSize;
  15282. min.y=this.center.y-quarter-halfChildSize;
  15283. min.z=this.center.z+quarter-halfChildSize;
  15284. max.x=this.center.x-quarter+halfChildSize;
  15285. max.y=this.center.y-quarter+halfChildSize;
  15286. max.z=this.center.z+quarter+halfChildSize;
  15287. break ;
  15288. case 7:
  15289. min.x=this.center.x+quarter-halfChildSize;
  15290. min.y=this.center.y-quarter-halfChildSize;
  15291. min.z=this.center.z+quarter-halfChildSize;
  15292. max.x=this.center.x+quarter+halfChildSize;
  15293. max.y=this.center.y-quarter+halfChildSize;
  15294. max.z=this.center.z+quarter+halfChildSize;
  15295. break ;
  15296. default :
  15297. }
  15298. return bounds;
  15299. }
  15300. }
  15301. /**
  15302. *@private
  15303. */
  15304. __proto._getChildCenter=function(index){
  15305. if (this._children !=null){
  15306. return this._children[index].center;
  15307. }else {
  15308. var quarter=this.baseLength / 4;
  15309. var childCenter=BoundsOctreeNode._tempVector30;
  15310. switch (index){
  15311. case 0:
  15312. childCenter.x=this.center.x-quarter;
  15313. childCenter.y=this.center.y+quarter;
  15314. childCenter.z=this.center.z-quarter;
  15315. break ;
  15316. case 1:
  15317. childCenter.x=this.center.x+quarter;
  15318. childCenter.y=this.center.y+quarter;
  15319. childCenter.z=this.center.z-quarter;
  15320. break ;
  15321. case 2:
  15322. childCenter.x=this.center.x-quarter;
  15323. childCenter.y=this.center.y+quarter;
  15324. childCenter.z=this.center.z+quarter;
  15325. break ;
  15326. case 3:
  15327. childCenter.x=this.center.x+quarter;
  15328. childCenter.y=this.center.y+quarter;
  15329. childCenter.z=this.center.z+quarter;
  15330. break ;
  15331. case 4:
  15332. childCenter.x=this.center.x-quarter;
  15333. childCenter.y=this.center.y-quarter;
  15334. childCenter.z=this.center.z-quarter;
  15335. break ;
  15336. case 5:
  15337. childCenter.x=this.center.x+quarter;
  15338. childCenter.y=this.center.y-quarter;
  15339. childCenter.z=this.center.z-quarter;
  15340. break ;
  15341. case 6:
  15342. childCenter.x=this.center.x-quarter;
  15343. childCenter.y=this.center.y-quarter;
  15344. childCenter.z=this.center.z+quarter;
  15345. break ;
  15346. case 7:
  15347. childCenter.x=this.center.x+quarter;
  15348. childCenter.y=this.center.y-quarter;
  15349. childCenter.z=this.center.z+quarter;
  15350. break ;
  15351. default :
  15352. }
  15353. return childCenter;
  15354. }
  15355. }
  15356. /**
  15357. *@private
  15358. */
  15359. __proto._getChild=function(index){
  15360. var quarter=this.baseLength / 4;
  15361. this._children || (this._children=__newvec(8,null));
  15362. switch (index){
  15363. case 0:
  15364. 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)));
  15365. case 1:
  15366. 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)));
  15367. case 2:
  15368. 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)));
  15369. case 3:
  15370. 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)));
  15371. case 4:
  15372. 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)));
  15373. case 5:
  15374. 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)));
  15375. case 6:
  15376. 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)));
  15377. case 7:
  15378. 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)));
  15379. default :
  15380. throw "BoundsOctreeNode: unknown index.";
  15381. }
  15382. }
  15383. /**
  15384. *@private
  15385. *是否合并判断(如果该节点和子节点包含的物体小于_NUM_OBJECTS_ALLOWED则应将子节点合并到该节点)
  15386. */
  15387. __proto._shouldMerge=function(){
  15388. var objectCount=this._objects.length;
  15389. for (var i=0;i < 8;i++){
  15390. var child=this._children[i];
  15391. if (child){
  15392. if (child._children !=null)
  15393. return false;
  15394. objectCount+=child._objects.length;
  15395. }
  15396. }
  15397. return objectCount <=8;
  15398. }
  15399. /**
  15400. *@private
  15401. */
  15402. __proto._mergeChildren=function(){
  15403. for (var i=0;i < 8;i++){
  15404. var child=this._children[i];
  15405. if (child){
  15406. child._parent=null;
  15407. var childObjects=child._objects;
  15408. for (var j=childObjects.length-1;j >=0;j--){
  15409. var childObject=childObjects[j];
  15410. this._objects.push(childObject);
  15411. childObject._setOctreeNode(this);
  15412. }
  15413. }
  15414. }
  15415. this._children=null;
  15416. }
  15417. /**
  15418. *@private
  15419. */
  15420. __proto._merge=function(){
  15421. if (this._children===null){
  15422. var parent=this._parent;
  15423. if (parent && parent._shouldMerge()){
  15424. parent._mergeChildren();
  15425. parent._merge();
  15426. }
  15427. }
  15428. }
  15429. /**
  15430. *@private
  15431. */
  15432. __proto._checkAddNode=function(object){
  15433. if (this._children==null){
  15434. if (this._objects.length < 8 || (this.baseLength / 2)< this._octree._minSize){
  15435. return this;
  15436. }
  15437. for (var i=this._objects.length-1;i >=0;i--){
  15438. var existObject=this._objects[i];
  15439. var fitChildIndex=this._bestFitChild(existObject.bounds.getCenter());
  15440. if (BoundsOctreeNode._encapsulates(this._getChildBound(fitChildIndex),existObject.bounds._getBoundBox())){
  15441. this._objects.splice(this._objects.indexOf(existObject),1);
  15442. this._getChild(fitChildIndex)._add(existObject);
  15443. }
  15444. }
  15445. };
  15446. var newFitChildIndex=this._bestFitChild(object.bounds.getCenter());
  15447. if (BoundsOctreeNode._encapsulates(this._getChildBound(newFitChildIndex),object.bounds._getBoundBox()))
  15448. return this._getChild(newFitChildIndex)._checkAddNode(object);
  15449. else
  15450. return this;
  15451. }
  15452. /**
  15453. *@private
  15454. */
  15455. __proto._add=function(object){
  15456. var addNode=this._checkAddNode(object);
  15457. addNode._objects.push(object);
  15458. object._setOctreeNode(addNode);
  15459. }
  15460. /**
  15461. *@private
  15462. */
  15463. __proto._remove=function(object){
  15464. var index=this._objects.indexOf(object);
  15465. this._objects.splice(index,1);
  15466. object._setOctreeNode(null);
  15467. this._merge();
  15468. }
  15469. /**
  15470. *@private
  15471. */
  15472. __proto._addUp=function(object){
  15473. if ((CollisionUtils.boxContainsBox(this._bounds,object.bounds._getBoundBox())===/*laya.d3.math.ContainmentType.Contains*/1)){
  15474. this._add(object);
  15475. return true;
  15476. }else {
  15477. if (this._parent)
  15478. return this._parent._addUp(object);
  15479. else
  15480. return false;
  15481. }
  15482. }
  15483. /**
  15484. *@private
  15485. */
  15486. __proto._getCollidingWithFrustum=function(context,frustum,testVisible,camPos){
  15487. if (testVisible){
  15488. var type=frustum.containsBoundBox(this._bounds);
  15489. Stat.octreeNodeCulling++;
  15490. if (type===/*laya.d3.math.ContainmentType.Disjoint*/0)
  15491. return;
  15492. testVisible=(type===/*laya.d3.math.ContainmentType.Intersects*/2);
  15493. }
  15494. this._isContaion=!testVisible;
  15495. var camera=context.camera;
  15496. var scene=context.scene;
  15497. for (var i=0,n=this._objects.length;i < n;i++){
  15498. var render=this._objects [i];
  15499. if (camera._isLayerVisible(render._owner.layer)&& render._enable){
  15500. if (testVisible){
  15501. Stat.frustumCulling++;
  15502. if (!render._needRender(frustum))
  15503. continue ;
  15504. }
  15505. render._distanceForSort=Vector3.distance(render.bounds.getCenter(),camPos);
  15506. var elements=render._renderElements;
  15507. for (var j=0,m=elements.length;j < m;j++){
  15508. var element=elements[j];
  15509. var renderQueue=scene._getRenderQueue(element.material.renderQueue);
  15510. if (renderQueue.isTransparent)
  15511. element.addToTransparentRenderQueue(context,renderQueue);
  15512. else
  15513. element.addToOpaqueRenderQueue(context,renderQueue);
  15514. }
  15515. }
  15516. }
  15517. if (this._children !=null){
  15518. for (i=0;i < 8;i++){
  15519. var child=this._children[i];
  15520. child && child._getCollidingWithFrustum(context,frustum,testVisible,camPos);
  15521. }
  15522. }
  15523. }
  15524. /**
  15525. *@private
  15526. */
  15527. __proto._getCollidingWithBoundBox=function(checkBound,testVisible,result){
  15528. if (testVisible){
  15529. var type=CollisionUtils.boxContainsBox(this._bounds,checkBound);
  15530. if (type===/*laya.d3.math.ContainmentType.Disjoint*/0)
  15531. return;
  15532. testVisible=(type===/*laya.d3.math.ContainmentType.Intersects*/2);
  15533. }
  15534. if (testVisible){
  15535. for (var i=0,n=this._objects.length;i < n;i++){
  15536. var object=this._objects[i];
  15537. if (CollisionUtils.intersectsBoxAndBox(object.bounds._getBoundBox(),checkBound)){
  15538. result.push(object);
  15539. }
  15540. }
  15541. }
  15542. if (this._children !=null){
  15543. for (i=0;i < 8;i++){
  15544. var child=this._children[i];
  15545. child._getCollidingWithBoundBox(checkBound,testVisible,result);
  15546. }
  15547. }
  15548. }
  15549. /**
  15550. *@private
  15551. */
  15552. __proto._bestFitChild=function(boundCenter){
  15553. return (boundCenter.x <=this.center.x ? 0 :1)+(boundCenter.y >=this.center.y ? 0 :4)+(boundCenter.z <=this.center.z ? 0 :2);
  15554. }
  15555. /**
  15556. *@private
  15557. *@return 是否需要扩充根节点
  15558. */
  15559. __proto._update=function(object){
  15560. if (CollisionUtils.boxContainsBox(this._bounds,object.bounds._getBoundBox())===/*laya.d3.math.ContainmentType.Contains*/1){
  15561. var addNode=this._checkAddNode(object);
  15562. if (addNode!==object._getOctreeNode()){
  15563. addNode._objects.push(object);
  15564. object._setOctreeNode(addNode);
  15565. var index=this._objects.indexOf(object);
  15566. this._objects.splice(index,1);
  15567. this._merge();
  15568. }
  15569. return true;
  15570. }else {
  15571. if (this._parent){
  15572. var sucess=this._parent._addUp(object);
  15573. if (sucess){
  15574. index=this._objects.indexOf(object);
  15575. this._objects.splice(index,1);
  15576. this._merge();
  15577. }
  15578. return sucess;
  15579. }else {
  15580. return false;
  15581. }
  15582. }
  15583. }
  15584. /**
  15585. *添加指定物体。
  15586. *@param object 指定物体。
  15587. */
  15588. __proto.add=function(object){
  15589. if (!BoundsOctreeNode._encapsulates(this._bounds,object.bounds._getBoundBox()))
  15590. return false;
  15591. this._add(object);
  15592. return true;
  15593. }
  15594. /**
  15595. *移除指定物体。
  15596. *@param obejct 指定物体。
  15597. *@return 是否成功。
  15598. */
  15599. __proto.remove=function(object){
  15600. if (object._getOctreeNode()!==this)
  15601. return false;
  15602. this._remove(object);
  15603. return true;
  15604. }
  15605. /**
  15606. *更新制定物体,
  15607. *@param obejct 指定物体。
  15608. *@return 是否成功。
  15609. */
  15610. __proto.update=function(object){
  15611. if (object._getOctreeNode()!==this)
  15612. return false;
  15613. return this._update(object);
  15614. }
  15615. /**
  15616. *收缩八叉树节点。
  15617. *-所有物体都在根节点的八分之一区域
  15618. *-该节点无子节点或有子节点但1/8的子节点不包含物体
  15619. *@param minLength 最小尺寸。
  15620. *@return 新的根节点。
  15621. */
  15622. __proto.shrinkIfPossible=function(minLength){
  15623. if (this.baseLength < minLength *2)
  15624. return this;
  15625. var bestFit=-1;
  15626. for (var i=0,n=this._objects.length;i < n;i++){
  15627. var object=this._objects[i];
  15628. var newBestFit=this._bestFitChild(object.bounds.getCenter());
  15629. if (i==0 || newBestFit==bestFit){
  15630. var childBounds=this._getChildBound(newBestFit);
  15631. if (BoundsOctreeNode._encapsulates(childBounds,object.bounds._getBoundBox()))
  15632. (i==0)&& (bestFit=newBestFit);
  15633. else
  15634. return this;
  15635. }else {
  15636. return this;
  15637. }
  15638. }
  15639. if (this._children !=null){
  15640. var childHadContent=false;
  15641. for (i=0,n=this._children.length;i < n;i++){
  15642. var child=this._children[i];
  15643. if (child && child.hasAnyObjects()){
  15644. if (childHadContent)
  15645. return this;
  15646. if (bestFit >=0 && bestFit !=i)
  15647. return this;
  15648. childHadContent=true;
  15649. bestFit=i;
  15650. }
  15651. }
  15652. }else {
  15653. if (bestFit !=-1){
  15654. var childCenter=this._getChildCenter(bestFit);
  15655. this._setValues(this._octree,null,this.baseLength / 2,childCenter);
  15656. }
  15657. return this;
  15658. }
  15659. if (bestFit !=-1){
  15660. var newRoot=this._children[bestFit];
  15661. newRoot._parent=null;
  15662. return newRoot;
  15663. }else {
  15664. return this;
  15665. }
  15666. }
  15667. /**
  15668. *检查该节点和其子节点是否包含任意物体。
  15669. *@return 是否包含任意物体。
  15670. */
  15671. __proto.hasAnyObjects=function(){
  15672. if (this._objects.length > 0)
  15673. return true;
  15674. if (this._children !=null){
  15675. for (var i=0;i < 8;i++){
  15676. var child=this._children[i];
  15677. if (child && child.hasAnyObjects())
  15678. return true;
  15679. }
  15680. }
  15681. return false;
  15682. }
  15683. /**
  15684. *获取与指定包围盒相交的物体列表。
  15685. *@param checkBound AABB包围盒。
  15686. *@param result 相交物体列表
  15687. */
  15688. __proto.getCollidingWithBoundBox=function(checkBound,result){
  15689. this._getCollidingWithBoundBox(checkBound,true,result);
  15690. }
  15691. /**
  15692. *获取与指定射线相交的的物理列表。
  15693. *@param ray 射线。
  15694. *@param result 相交物体列表。
  15695. *@param maxDistance 射线的最大距离。
  15696. */
  15697. __proto.getCollidingWithRay=function(ray,result,maxDistance){
  15698. (maxDistance===void 0)&& (maxDistance=Number.MAX_VALUE);
  15699. var distance=CollisionUtils.intersectsRayAndBoxRD(ray,this._bounds);
  15700. if (distance==-1 || distance > maxDistance)
  15701. return;
  15702. for (var i=0,n=this._objects.length;i < n;i++){
  15703. var object=this._objects[i];
  15704. distance=CollisionUtils.intersectsRayAndBoxRD(ray,object.bounds._getBoundBox());
  15705. if (distance!==-1 && distance <=maxDistance)
  15706. result.push(object);
  15707. }
  15708. if (this._children !=null){
  15709. for (i=0;i < 8;i++){
  15710. var child=this._children[i];
  15711. child.getCollidingWithRay(ray,result,maxDistance);
  15712. }
  15713. }
  15714. }
  15715. /**
  15716. *获取与指定视锥相交的的物理列表。
  15717. *@param ray 射线。.
  15718. *@param result 相交物体列表。
  15719. */
  15720. __proto.getCollidingWithFrustum=function(context){
  15721. var cameraPos=context.camera.transform.position;
  15722. var boundFrustum=(context.camera).boundFrustum;
  15723. this._getCollidingWithFrustum(context,boundFrustum,true,cameraPos);
  15724. }
  15725. /**
  15726. *获取是否与指定包围盒相交。
  15727. *@param checkBound AABB包围盒。
  15728. *@return 是否相交。
  15729. */
  15730. __proto.isCollidingWithBoundBox=function(checkBound){
  15731. if (!(CollisionUtils.intersectsBoxAndBox(this._bounds,checkBound)))
  15732. return false;
  15733. for (var i=0,n=this._objects.length;i < n;i++){
  15734. var object=this._objects[i];
  15735. if (CollisionUtils.intersectsBoxAndBox(object.bounds._getBoundBox(),checkBound))
  15736. return true;
  15737. }
  15738. if (this._children !=null){
  15739. for (i=0;i < 8;i++){
  15740. var child=this._children[i];
  15741. if (child.isCollidingWithBoundBox(checkBound))
  15742. return true;
  15743. }
  15744. }
  15745. return false;
  15746. }
  15747. /**
  15748. *获取是否与指定射线相交。
  15749. *@param ray 射线。
  15750. *@param maxDistance 射线的最大距离。
  15751. *@return 是否相交。
  15752. */
  15753. __proto.isCollidingWithRay=function(ray,maxDistance){
  15754. (maxDistance===void 0)&& (maxDistance=Number.MAX_VALUE);
  15755. var distance=CollisionUtils.intersectsRayAndBoxRD(ray,this._bounds);
  15756. if (distance==-1 || distance > maxDistance)
  15757. return false;
  15758. for (var i=0,n=this._objects.length;i < n;i++){
  15759. var object=this._objects[i];
  15760. distance=CollisionUtils.intersectsRayAndBoxRD(ray,object.bounds._getBoundBox());
  15761. if (distance!==-1 && distance <=maxDistance)
  15762. return true;
  15763. }
  15764. if (this._children !=null){
  15765. for (i=0;i < 8;i++){
  15766. var child=this._children[i];
  15767. if (child.isCollidingWithRay(ray,maxDistance))
  15768. return true;
  15769. }
  15770. }
  15771. return false;
  15772. }
  15773. /**
  15774. *获取包围盒。
  15775. */
  15776. __proto.getBound=function(){
  15777. return this._bounds;
  15778. }
  15779. /**
  15780. *@private
  15781. *[Debug]
  15782. */
  15783. __proto.drawAllBounds=function(debugLine,currentDepth,maxDepth){
  15784. if (this._children===null && this._objects.length==0)
  15785. return;
  15786. currentDepth++;
  15787. var color=BoundsOctreeNode._tempColor0;
  15788. if (this._isContaion){
  15789. color.r=0.0;
  15790. color.g=0.0;
  15791. color.b=1.0;
  15792. }else {
  15793. var tint=maxDepth ? currentDepth / maxDepth :0;
  15794. color.r=1.0-tint;
  15795. color.g=tint;
  15796. color.b=0.0;
  15797. }
  15798. color.a=0.3;
  15799. Utils3D._drawBound(debugLine,this._bounds,color);
  15800. if (this._children !=null){
  15801. for (var i=0;i < 8;i++){
  15802. var child=this._children[i];
  15803. child && child.drawAllBounds(debugLine,currentDepth,maxDepth);
  15804. }
  15805. }
  15806. }
  15807. /**
  15808. *@private
  15809. *[Debug]
  15810. */
  15811. __proto.drawAllObjects=function(debugLine,currentDepth,maxDepth){
  15812. currentDepth++;
  15813. var color=BoundsOctreeNode._tempColor0;
  15814. if (this._isContaion){
  15815. color.r=0.0;
  15816. color.g=0.0;
  15817. color.b=1.0;
  15818. }else {
  15819. var tint=maxDepth ? currentDepth / maxDepth :0;
  15820. color.r=1.0-tint;
  15821. color.g=tint;
  15822. color.b=0.0;
  15823. }
  15824. color.a=1.0;
  15825. for (var i=0,n=this._objects.length;i < n;i++)
  15826. Utils3D._drawBound(debugLine,this._objects[i].bounds._getBoundBox(),color);
  15827. if (this._children !=null){
  15828. for (i=0;i < 8;i++){
  15829. var child=this._children[i];
  15830. child && child.drawAllObjects(debugLine,currentDepth,maxDepth);
  15831. }
  15832. }
  15833. }
  15834. BoundsOctreeNode._encapsulates=function(outerBound,innerBound){
  15835. return CollisionUtils.boxContainsBox(outerBound,innerBound)==/*laya.d3.math.ContainmentType.Contains*/1;
  15836. }
  15837. BoundsOctreeNode._NUM_OBJECTS_ALLOWED=8;
  15838. __static(BoundsOctreeNode,
  15839. ['_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());}
  15840. ]);
  15841. return BoundsOctreeNode;
  15842. })()
  15843. /**
  15844. *<code>RotationOverLifetime</code> 类用于粒子的生命周期旋转。
  15845. */
  15846. //class laya.d3.core.particleShuriKen.module.RotationOverLifetime
  15847. var RotationOverLifetime=(function(){
  15848. function RotationOverLifetime(angularVelocity){
  15849. /**@private */
  15850. this._angularVelocity=null;
  15851. /**是否启用*/
  15852. this.enbale=false;
  15853. this._angularVelocity=angularVelocity;
  15854. }
  15855. __class(RotationOverLifetime,'laya.d3.core.particleShuriKen.module.RotationOverLifetime');
  15856. var __proto=RotationOverLifetime.prototype;
  15857. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  15858. /**
  15859. *克隆。
  15860. *@param destObject 克隆源。
  15861. */
  15862. __proto.cloneTo=function(destObject){
  15863. var destRotationOverLifetime=destObject;
  15864. this._angularVelocity.cloneTo(destRotationOverLifetime._angularVelocity);
  15865. destRotationOverLifetime.enbale=this.enbale;
  15866. }
  15867. /**
  15868. *克隆。
  15869. *@return 克隆副本。
  15870. */
  15871. __proto.clone=function(){
  15872. var destAngularVelocity;
  15873. switch (this._angularVelocity.type){
  15874. case 0:
  15875. if (this._angularVelocity.separateAxes)
  15876. destAngularVelocity=GradientAngularVelocity.createByConstantSeparate(this._angularVelocity.constantSeparate.clone());
  15877. else
  15878. destAngularVelocity=GradientAngularVelocity.createByConstant(this._angularVelocity.constant);
  15879. break ;
  15880. case 1:
  15881. if (this._angularVelocity.separateAxes)
  15882. destAngularVelocity=GradientAngularVelocity.createByGradientSeparate(this._angularVelocity.gradientX.clone(),this._angularVelocity.gradientY.clone(),this._angularVelocity.gradientZ.clone());
  15883. else
  15884. destAngularVelocity=GradientAngularVelocity.createByGradient(this._angularVelocity.gradient.clone());
  15885. break ;
  15886. case 2:
  15887. if (this._angularVelocity.separateAxes)
  15888. destAngularVelocity=GradientAngularVelocity.createByRandomTwoConstantSeparate(this._angularVelocity.constantMinSeparate.clone(),this._angularVelocity.constantMaxSeparate.clone());
  15889. else
  15890. destAngularVelocity=GradientAngularVelocity.createByRandomTwoConstant(this._angularVelocity.constantMin,this._angularVelocity.constantMax);
  15891. break ;
  15892. case 3:
  15893. if (this._angularVelocity.separateAxes)
  15894. 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());
  15895. else
  15896. destAngularVelocity=GradientAngularVelocity.createByRandomTwoGradient(this._angularVelocity.gradientMin.clone(),this._angularVelocity.gradientMax.clone());
  15897. break ;
  15898. };
  15899. var destRotationOverLifetime=/*__JS__ */new this.constructor(destAngularVelocity);
  15900. destRotationOverLifetime.enbale=this.enbale;
  15901. return destRotationOverLifetime;
  15902. }
  15903. /**
  15904. *获取角速度。
  15905. */
  15906. __getset(0,__proto,'angularVelocity',function(){
  15907. return this._angularVelocity;
  15908. });
  15909. return RotationOverLifetime;
  15910. })()
  15911. /**
  15912. *@private
  15913. *<code>RenderQuene</code> 类用于实现渲染队列。
  15914. */
  15915. //class laya.d3.core.render.RenderQueue
  15916. var RenderQueue=(function(){
  15917. function RenderQueue(isTransparent){
  15918. /**@private [只读]*/
  15919. //this.isTransparent=false;
  15920. /**@private */
  15921. //this.elements=null;
  15922. /**@private */
  15923. //this.lastTransparentRenderElement=null;
  15924. /**@private */
  15925. //this.lastTransparentBatched=false;
  15926. (isTransparent===void 0)&& (isTransparent=false);
  15927. this.isTransparent=isTransparent;
  15928. this.elements=[];
  15929. }
  15930. __class(RenderQueue,'laya.d3.core.render.RenderQueue');
  15931. var __proto=RenderQueue.prototype;
  15932. /**
  15933. *@private
  15934. */
  15935. __proto._compare=function(left,right){
  15936. var renderQueue=left.material.renderQueue-right.material.renderQueue;
  15937. if (renderQueue===0){
  15938. var sort=this.isTransparent ? right.render._distanceForSort-left.render._distanceForSort :left.render._distanceForSort-right.render._distanceForSort;
  15939. return sort+right.render.sortingFudge-left.render.sortingFudge;
  15940. }else {
  15941. return renderQueue;
  15942. }
  15943. }
  15944. /**
  15945. *@private
  15946. */
  15947. __proto._partitionRenderObject=function(left,right){
  15948. var pivot=this.elements[Math.floor((right+left)/ 2)];
  15949. while (left <=right){
  15950. while (this._compare(this.elements[left],pivot)< 0)
  15951. left++;
  15952. while (this._compare(this.elements[right],pivot)> 0)
  15953. right--;
  15954. if (left < right){
  15955. var temp=this.elements[left];
  15956. this.elements[left]=this.elements[right];
  15957. this.elements[right]=temp;
  15958. left++;
  15959. right--;
  15960. }else if (left===right){
  15961. left++;
  15962. break ;
  15963. }
  15964. }
  15965. return left;
  15966. }
  15967. /**
  15968. *@private
  15969. */
  15970. __proto._quickSort=function(left,right){
  15971. if (this.elements.length > 1){
  15972. var index=this._partitionRenderObject(left,right);
  15973. var leftIndex=index-1;
  15974. if (left < leftIndex)
  15975. this._quickSort(left,leftIndex);
  15976. if (index < right)
  15977. this._quickSort(index,right);
  15978. }
  15979. }
  15980. /**
  15981. *@private
  15982. */
  15983. __proto._render=function(context,isTarget,customShader,replacementTag){
  15984. for (var i=0,n=this.elements.length;i < n;i++)
  15985. this.elements[i]._render(context,isTarget,customShader,replacementTag);
  15986. }
  15987. /**
  15988. *@private
  15989. */
  15990. __proto.clear=function(){
  15991. this.elements.length=0;
  15992. this.lastTransparentRenderElement=null;
  15993. this.lastTransparentBatched=false;
  15994. }
  15995. return RenderQueue;
  15996. })()
  15997. /**
  15998. *<code>GradientDataVector2</code> 类用于创建二维向量渐变。
  15999. */
  16000. //class laya.d3.core.particleShuriKen.module.GradientDataVector2
  16001. var GradientDataVector2=(function(){
  16002. function GradientDataVector2(){
  16003. /**@private */
  16004. this._currentLength=0;
  16005. /**@private 开发者禁止修改。*/
  16006. this._elements=null;
  16007. this._elements=new Float32Array(12);
  16008. }
  16009. __class(GradientDataVector2,'laya.d3.core.particleShuriKen.module.GradientDataVector2');
  16010. var __proto=GradientDataVector2.prototype;
  16011. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  16012. /**
  16013. *增加二维向量渐变。
  16014. *@param key 生命周期,范围为0到1。
  16015. *@param value 二维向量值。
  16016. */
  16017. __proto.add=function(key,value){
  16018. if (this._currentLength < 8){
  16019. if ((this._currentLength===6)&& ((key!==1))){
  16020. key=1;
  16021. console.log("GradientDataVector2 warning:the forth key is be force set to 1.");
  16022. }
  16023. this._elements[this._currentLength++]=key;
  16024. this._elements[this._currentLength++]=value.x;
  16025. this._elements[this._currentLength++]=value.y;
  16026. }else {
  16027. console.log("GradientDataVector2 warning:data count must lessEqual than 4");
  16028. }
  16029. }
  16030. /**
  16031. *克隆。
  16032. *@param destObject 克隆源。
  16033. */
  16034. __proto.cloneTo=function(destObject){
  16035. var destGradientDataVector2=destObject;
  16036. destGradientDataVector2._currentLength=this._currentLength;
  16037. var destElements=destGradientDataVector2._elements;
  16038. destElements.length=this._elements.length;
  16039. for (var i=0,n=this._elements.length;i < n;i++){
  16040. destElements[i]=this._elements[i];
  16041. }
  16042. }
  16043. /**
  16044. *克隆。
  16045. *@return 克隆副本。
  16046. */
  16047. __proto.clone=function(){
  16048. var destGradientDataVector2=/*__JS__ */new this.constructor();
  16049. this.cloneTo(destGradientDataVector2);
  16050. return destGradientDataVector2;
  16051. }
  16052. /**二维向量渐变数量。*/
  16053. __getset(0,__proto,'gradientCount',function(){
  16054. return this._currentLength / 3;
  16055. });
  16056. return GradientDataVector2;
  16057. })()
  16058. /**
  16059. *<code>Vector4</code> 类用于创建四维向量。
  16060. */
  16061. //class laya.d3.math.Vector4
  16062. var Vector4=(function(){
  16063. function Vector4(x,y,z,w){
  16064. /**X轴坐标*/
  16065. this.x=NaN;
  16066. /**Y轴坐标*/
  16067. this.y=NaN;
  16068. /**Z轴坐标*/
  16069. this.z=NaN;
  16070. /**W轴坐标*/
  16071. this.w=NaN;
  16072. (x===void 0)&& (x=0);
  16073. (y===void 0)&& (y=0);
  16074. (z===void 0)&& (z=0);
  16075. (w===void 0)&& (w=0);
  16076. this.x=x;
  16077. this.y=y;
  16078. this.z=z;
  16079. this.w=w;
  16080. }
  16081. __class(Vector4,'laya.d3.math.Vector4');
  16082. var __proto=Vector4.prototype;
  16083. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  16084. /**
  16085. *设置xyzw值。
  16086. *@param x X值。
  16087. *@param y Y值。
  16088. *@param z Z值。
  16089. *@param w W值。
  16090. */
  16091. __proto.setValue=function(x,y,z,w){
  16092. this.x=x;
  16093. this.y=y;
  16094. this.z=z;
  16095. this.w=w;
  16096. }
  16097. /**
  16098. *从Array数组拷贝值。
  16099. *@param array 数组。
  16100. *@param offset 数组偏移。
  16101. */
  16102. __proto.fromArray=function(array,offset){
  16103. (offset===void 0)&& (offset=0);
  16104. this.x=array[offset+0];
  16105. this.y=array[offset+1];
  16106. this.z=array[offset+2];
  16107. this.w=array[offset+3];
  16108. }
  16109. /**
  16110. *克隆。
  16111. *@param destObject 克隆源。
  16112. */
  16113. __proto.cloneTo=function(destObject){
  16114. var destVector4=destObject;
  16115. destVector4.x=this.x;
  16116. destVector4.y=this.y;
  16117. destVector4.z=this.z;
  16118. destVector4.w=this.w;
  16119. }
  16120. /**
  16121. *克隆。
  16122. *@return 克隆副本。
  16123. */
  16124. __proto.clone=function(){
  16125. var destVector4=/*__JS__ */new this.constructor();
  16126. this.cloneTo(destVector4);
  16127. return destVector4;
  16128. }
  16129. /**
  16130. *求四维向量的长度。
  16131. *@return 长度。
  16132. */
  16133. __proto.length=function(){
  16134. return Math.sqrt(this.x *this.x+this.y *this.y+this.z *this.z+this.w *this.w);
  16135. }
  16136. /**
  16137. *求四维向量长度的平方。
  16138. *@return 长度的平方。
  16139. */
  16140. __proto.lengthSquared=function(){
  16141. return this.x *this.x+this.y *this.y+this.z *this.z+this.w *this.w;
  16142. }
  16143. __proto.forNativeElement=function(nativeElements){
  16144. if (nativeElements){
  16145. /*__JS__ */this.elements=nativeElements;
  16146. /*__JS__ */this.elements[0]=this.x;
  16147. /*__JS__ */this.elements[1]=this.y;
  16148. /*__JS__ */this.elements[2]=this.z;
  16149. /*__JS__ */this.elements[3]=this.w;
  16150. }
  16151. else{
  16152. /*__JS__ */this.elements=new Float32Array([this.x,this.y,this.z,this.w]);
  16153. }
  16154. Vector2.rewriteNumProperty(this,"x",0);
  16155. Vector2.rewriteNumProperty(this,"y",1);
  16156. Vector2.rewriteNumProperty(this,"z",2);
  16157. Vector2.rewriteNumProperty(this,"w",3);
  16158. }
  16159. Vector4.lerp=function(a,b,t,out){
  16160. var ax=a.x,ay=a.y,az=a.z,aw=a.w;
  16161. out.x=ax+t *(b.x-ax);
  16162. out.y=ay+t *(b.y-ay);
  16163. out.z=az+t *(b.z-az);
  16164. out.w=aw+t *(b.w-aw);
  16165. }
  16166. Vector4.transformByM4x4=function(vector4,m4x4,out){
  16167. var vx=vector4.x;
  16168. var vy=vector4.y;
  16169. var vz=vector4.z;
  16170. var vw=vector4.w;
  16171. var me=m4x4.elements;
  16172. out.x=vx *me[0]+vy *me[4]+vz *me[8]+vw *me[12];
  16173. out.y=vx *me[1]+vy *me[5]+vz *me[9]+vw *me[13];
  16174. out.z=vx *me[2]+vy *me[6]+vz *me[10]+vw *me[14];
  16175. out.w=vx *me[3]+vy *me[7]+vz *me[11]+vw *me[15];
  16176. }
  16177. Vector4.equals=function(a,b){
  16178. 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));
  16179. }
  16180. Vector4.normalize=function(s,out){
  16181. var len=/*if err,please use iflash.method.xmlLength()*/s.length();
  16182. if (len > 0){
  16183. out.x=s.x *len;
  16184. out.y=s.y *len;
  16185. out.z=s.z *len;
  16186. out.w=s.w *len;
  16187. }
  16188. }
  16189. Vector4.add=function(a,b,out){
  16190. out.x=a.x+b.x;
  16191. out.y=a.y+b.y;
  16192. out.z=a.z+b.z;
  16193. out.w=a.w+b.w;
  16194. }
  16195. Vector4.subtract=function(a,b,out){
  16196. out.x=a.x-b.x;
  16197. out.y=a.y-b.y;
  16198. out.z=a.z-b.z;
  16199. out.w=a.w-b.w;
  16200. }
  16201. Vector4.multiply=function(a,b,out){
  16202. out.x=a.x *b.x;
  16203. out.y=a.y *b.y;
  16204. out.z=a.z *b.z;
  16205. out.w=a.w *b.w;
  16206. }
  16207. Vector4.scale=function(a,b,out){
  16208. out.x=a.x *b;
  16209. out.y=a.y *b;
  16210. out.z=a.z *b;
  16211. out.w=a.w *b;
  16212. }
  16213. Vector4.Clamp=function(value,min,max,out){
  16214. var x=value.x;
  16215. var y=value.y;
  16216. var z=value.z;
  16217. var w=value.w;
  16218. var mineX=min.x;
  16219. var mineY=min.y;
  16220. var mineZ=min.z;
  16221. var mineW=min.w;
  16222. var maxeX=max.x;
  16223. var maxeY=max.y;
  16224. var maxeZ=max.z;
  16225. var maxeW=max.w;
  16226. x=(x > maxeX)? maxeX :x;
  16227. x=(x < mineX)? mineX :x;
  16228. y=(y > maxeY)? maxeY :y;
  16229. y=(y < mineY)? mineY :y;
  16230. z=(z > maxeZ)? maxeZ :z;
  16231. z=(z < mineZ)? mineZ :z;
  16232. w=(w > maxeW)? maxeW :w;
  16233. w=(w < mineW)? mineW :w;
  16234. out.x=x;
  16235. out.y=y;
  16236. out.z=z;
  16237. out.w=w;
  16238. }
  16239. Vector4.distanceSquared=function(value1,value2){
  16240. var x=value1.x-value2.x;
  16241. var y=value1.y-value2.y;
  16242. var z=value1.z-value2.z;
  16243. var w=value1.w-value2.w;
  16244. return (x *x)+(y *y)+(z *z)+(w *w);
  16245. }
  16246. Vector4.distance=function(value1,value2){
  16247. var x=value1.x-value2.x;
  16248. var y=value1.y-value2.y;
  16249. var z=value1.z-value2.z;
  16250. var w=value1.w-value2.w;
  16251. return Math.sqrt((x *x)+(y *y)+(z *z)+(w *w));
  16252. }
  16253. Vector4.dot=function(a,b){
  16254. return (a.x *b.x)+(a.y *b.y)+(a.z *b.z)+(a.w *b.w);
  16255. }
  16256. Vector4.min=function(a,b,out){
  16257. out.x=Math.min(a.x,b.x);
  16258. out.y=Math.min(a.y,b.y);
  16259. out.z=Math.min(a.z,b.z);
  16260. out.w=Math.min(a.w,b.w);
  16261. }
  16262. Vector4.max=function(a,b,out){
  16263. out.x=Math.max(a.x,b.x);
  16264. out.y=Math.max(a.y,b.y);
  16265. out.z=Math.max(a.z,b.z);
  16266. out.w=Math.max(a.w,b.w);
  16267. }
  16268. __static(Vector4,
  16269. ['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);}
  16270. ]);
  16271. return Vector4;
  16272. })()
  16273. /**
  16274. *<code>Vector3</code> 类用于创建三维向量。
  16275. */
  16276. //class laya.d3.math.Vector3
  16277. var Vector3=(function(){
  16278. function Vector3(x,y,z,nativeElements){
  16279. /**X轴坐标*/
  16280. this.x=NaN;
  16281. /**Y轴坐标*/
  16282. this.y=NaN;
  16283. /**Z轴坐标*/
  16284. this.z=NaN;
  16285. (x===void 0)&& (x=0);
  16286. (y===void 0)&& (y=0);
  16287. (z===void 0)&& (z=0);
  16288. this.x=x;
  16289. this.y=y;
  16290. this.z=z;
  16291. }
  16292. __class(Vector3,'laya.d3.math.Vector3');
  16293. var __proto=Vector3.prototype;
  16294. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  16295. /**
  16296. *设置xyz值。
  16297. *@param x X值。
  16298. *@param y Y值。
  16299. *@param z Z值。
  16300. */
  16301. __proto.setValue=function(x,y,z){
  16302. this.x=x;
  16303. this.y=y;
  16304. this.z=z;
  16305. }
  16306. /**
  16307. *从Array数组拷贝值。
  16308. *@param array 数组。
  16309. *@param offset 数组偏移。
  16310. */
  16311. __proto.fromArray=function(array,offset){
  16312. (offset===void 0)&& (offset=0);
  16313. this.x=array[offset+0];
  16314. this.y=array[offset+1];
  16315. this.z=array[offset+2];
  16316. }
  16317. /**
  16318. *克隆。
  16319. *@param destObject 克隆源。
  16320. */
  16321. __proto.cloneTo=function(destObject){
  16322. var destVector3=destObject;
  16323. destVector3.x=this.x;
  16324. destVector3.y=this.y;
  16325. destVector3.z=this.z;
  16326. }
  16327. /**
  16328. *克隆。
  16329. *@return 克隆副本。
  16330. */
  16331. __proto.clone=function(){
  16332. var destVector3=/*__JS__ */new this.constructor();
  16333. this.cloneTo(destVector3);
  16334. return destVector3;
  16335. }
  16336. __proto.toDefault=function(){
  16337. this.x=0;
  16338. this.y=0;
  16339. this.z=0;
  16340. }
  16341. __proto.forNativeElement=function(nativeElements){
  16342. if (nativeElements){
  16343. /*__JS__ */this.elements=nativeElements;
  16344. /*__JS__ */this.elements[0]=this.x;
  16345. /*__JS__ */this.elements[1]=this.y;
  16346. /*__JS__ */this.elements[2]=this.z;
  16347. }
  16348. else{
  16349. /*__JS__ */this.elements=new Float32Array([this.x,this.y,this.z]);
  16350. }
  16351. Vector2.rewriteNumProperty(this,"x",0);
  16352. Vector2.rewriteNumProperty(this,"y",1);
  16353. Vector2.rewriteNumProperty(this,"z",2);
  16354. }
  16355. Vector3.distanceSquared=function(value1,value2){
  16356. var x=value1.x-value2.x;
  16357. var y=value1.y-value2.y;
  16358. var z=value1.z-value2.z;
  16359. return (x *x)+(y *y)+(z *z);
  16360. }
  16361. Vector3.distance=function(value1,value2){
  16362. var x=value1.x-value2.x;
  16363. var y=value1.y-value2.y;
  16364. var z=value1.z-value2.z;
  16365. return Math.sqrt((x *x)+(y *y)+(z *z));
  16366. }
  16367. Vector3.min=function(a,b,out){
  16368. out.x=Math.min(a.x,b.x);
  16369. out.y=Math.min(a.y,b.y);
  16370. out.z=Math.min(a.z,b.z);
  16371. }
  16372. Vector3.max=function(a,b,out){
  16373. out.x=Math.max(a.x,b.x);
  16374. out.y=Math.max(a.y,b.y);
  16375. out.z=Math.max(a.z,b.z);
  16376. }
  16377. Vector3.transformQuat=function(source,rotation,out){
  16378. var x=source.x,y=source.y,z=source.z,qx=rotation.x,qy=rotation.y,qz=rotation.z,qw=rotation.w,
  16379. 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;
  16380. out.x=ix *qw+iw *-qx+iy *-qz-iz *-qy;
  16381. out.y=iy *qw+iw *-qy+iz *-qx-ix *-qz;
  16382. out.z=iz *qw+iw *-qz+ix *-qy-iy *-qx;
  16383. }
  16384. Vector3.scalarLength=function(a){
  16385. var x=a.x,y=a.y,z=a.z;
  16386. return Math.sqrt(x *x+y *y+z *z);
  16387. }
  16388. Vector3.scalarLengthSquared=function(a){
  16389. var x=a.x,y=a.y,z=a.z;
  16390. return x *x+y *y+z *z;
  16391. }
  16392. Vector3.normalize=function(s,out){
  16393. var x=s.x,y=s.y,z=s.z;
  16394. var len=x *x+y *y+z *z;
  16395. if (len > 0){
  16396. len=1 / Math.sqrt(len);
  16397. out.x=s.x *len;
  16398. out.y=s.y *len;
  16399. out.z=s.z *len;
  16400. }
  16401. }
  16402. Vector3.multiply=function(a,b,out){
  16403. out.x=a.x *b.x;
  16404. out.y=a.y *b.y;
  16405. out.z=a.z *b.z;
  16406. }
  16407. Vector3.scale=function(a,b,out){
  16408. out.x=a.x *b;
  16409. out.y=a.y *b;
  16410. out.z=a.z *b;
  16411. }
  16412. Vector3.lerp=function(a,b,t,out){
  16413. var ax=a.x,ay=a.y,az=a.z;
  16414. out.x=ax+t *(b.x-ax);
  16415. out.y=ay+t *(b.y-ay);
  16416. out.z=az+t *(b.z-az);
  16417. }
  16418. Vector3.transformV3ToV3=function(vector,transform,result){
  16419. var intermediate=Vector3._tempVector4;
  16420. Vector3.transformV3ToV4(vector,transform,intermediate);
  16421. result.x=intermediate.x;
  16422. result.y=intermediate.y;
  16423. result.z=intermediate.z;
  16424. }
  16425. Vector3.transformV3ToV4=function(vector,transform,result){
  16426. var vectorX=vector.x;
  16427. var vectorY=vector.y;
  16428. var vectorZ=vector.z;
  16429. var transformElem=transform.elements;
  16430. result.x=(vectorX *transformElem[0])+(vectorY *transformElem[4])+(vectorZ *transformElem[8])+transformElem[12];
  16431. result.y=(vectorX *transformElem[1])+(vectorY *transformElem[5])+(vectorZ *transformElem[9])+transformElem[13];
  16432. result.z=(vectorX *transformElem[2])+(vectorY *transformElem[6])+(vectorZ *transformElem[10])+transformElem[14];
  16433. result.w=(vectorX *transformElem[3])+(vectorY *transformElem[7])+(vectorZ *transformElem[11])+transformElem[15];
  16434. }
  16435. Vector3.TransformNormal=function(normal,transform,result){
  16436. var normalX=normal.x;
  16437. var normalY=normal.y;
  16438. var normalZ=normal.z;
  16439. var transformElem=transform.elements;
  16440. result.x=(normalX *transformElem[0])+(normalY *transformElem[4])+(normalZ *transformElem[8]);
  16441. result.y=(normalX *transformElem[1])+(normalY *transformElem[5])+(normalZ *transformElem[9]);
  16442. result.z=(normalX *transformElem[2])+(normalY *transformElem[6])+(normalZ *transformElem[10]);
  16443. }
  16444. Vector3.transformCoordinate=function(coordinate,transform,result){
  16445. var coordinateX=coordinate.x;
  16446. var coordinateY=coordinate.y;
  16447. var coordinateZ=coordinate.z;
  16448. var transformElem=transform.elements;
  16449. var w=((coordinateX *transformElem[3])+(coordinateY *transformElem[7])+(coordinateZ *transformElem[11])+transformElem[15]);
  16450. result.x=(coordinateX *transformElem[0])+(coordinateY *transformElem[4])+(coordinateZ *transformElem[8])+transformElem[12] / w;
  16451. result.y=(coordinateX *transformElem[1])+(coordinateY *transformElem[5])+(coordinateZ *transformElem[9])+transformElem[13] / w;
  16452. result.z=(coordinateX *transformElem[2])+(coordinateY *transformElem[6])+(coordinateZ *transformElem[10])+transformElem[14] / w;
  16453. }
  16454. Vector3.Clamp=function(value,min,max,out){
  16455. var x=value.x;
  16456. var y=value.y;
  16457. var z=value.z;
  16458. var mineX=min.x;
  16459. var mineY=min.y;
  16460. var mineZ=min.z;
  16461. var maxeX=max.x;
  16462. var maxeY=max.y;
  16463. var maxeZ=max.z;
  16464. x=(x > maxeX)? maxeX :x;
  16465. x=(x < mineX)? mineX :x;
  16466. y=(y > maxeY)? maxeY :y;
  16467. y=(y < mineY)? mineY :y;
  16468. z=(z > maxeZ)? maxeZ :z;
  16469. z=(z < mineZ)? mineZ :z;
  16470. out.x=x;
  16471. out.y=y;
  16472. out.z=z;
  16473. }
  16474. Vector3.add=function(a,b,out){
  16475. out.x=a.x+b.x;
  16476. out.y=a.y+b.y;
  16477. out.z=a.z+b.z;
  16478. }
  16479. Vector3.subtract=function(a,b,o){
  16480. o.x=a.x-b.x;
  16481. o.y=a.y-b.y;
  16482. o.z=a.z-b.z;
  16483. }
  16484. Vector3.cross=function(a,b,o){
  16485. var ax=a.x,ay=a.y,az=a.z,bx=b.x,by=b.y,bz=b.z;
  16486. o.x=ay *bz-az *by;
  16487. o.y=az *bx-ax *bz;
  16488. o.z=ax *by-ay *bx;
  16489. }
  16490. Vector3.dot=function(a,b){
  16491. return (a.x *b.x)+(a.y *b.y)+(a.z *b.z);
  16492. }
  16493. Vector3.equals=function(a,b){
  16494. return MathUtils3D.nearEqual(a.x,b.x)&& MathUtils3D.nearEqual(a.y,b.y)&& MathUtils3D.nearEqual(a.z,b.z);
  16495. }
  16496. Vector3._ZERO=new Vector3(0.0,0.0,0.0);
  16497. Vector3._ONE=new Vector3(1.0,1.0,1.0);
  16498. Vector3._NegativeUnitX=new Vector3(-1,0,0);
  16499. Vector3._UnitX=new Vector3(1,0,0);
  16500. Vector3._UnitY=new Vector3(0,1,0);
  16501. Vector3._UnitZ=new Vector3(0,0,1);
  16502. Vector3._ForwardRH=new Vector3(0,0,-1);
  16503. Vector3._ForwardLH=new Vector3(0,0,1);
  16504. Vector3._Up=new Vector3(0,1,0);
  16505. __static(Vector3,
  16506. ['_tempVector4',function(){return this._tempVector4=new Vector4();}
  16507. ]);
  16508. return Vector3;
  16509. })()
  16510. /**
  16511. *<code>Vector2</code> 类用于创建二维向量。
  16512. */
  16513. //class laya.d3.math.Vector2
  16514. var Vector2=(function(){
  16515. function Vector2(x,y){
  16516. /**X轴坐标*/
  16517. this.x=NaN;
  16518. /**Y轴坐标*/
  16519. this.y=NaN;
  16520. (x===void 0)&& (x=0);
  16521. (y===void 0)&& (y=0);
  16522. this.x=x;
  16523. this.y=y;
  16524. }
  16525. __class(Vector2,'laya.d3.math.Vector2');
  16526. var __proto=Vector2.prototype;
  16527. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  16528. /**
  16529. *设置xy值。
  16530. *@param x X值。
  16531. *@param y Y值。
  16532. */
  16533. __proto.setValue=function(x,y){
  16534. this.x=x;
  16535. this.y=y;
  16536. }
  16537. /**
  16538. *从Array数组拷贝值。
  16539. *@param array 数组。
  16540. *@param offset 数组偏移。
  16541. */
  16542. __proto.fromArray=function(array,offset){
  16543. (offset===void 0)&& (offset=0);
  16544. this.x=array[offset+0];
  16545. this.y=array[offset+1];
  16546. }
  16547. /**
  16548. *克隆。
  16549. *@param destObject 克隆源。
  16550. */
  16551. __proto.cloneTo=function(destObject){
  16552. var destVector2=destObject;
  16553. destVector2.x=this.x;
  16554. destVector2.y=this.y;
  16555. }
  16556. /**
  16557. *克隆。
  16558. *@return 克隆副本。
  16559. */
  16560. __proto.clone=function(){
  16561. var destVector2=/*__JS__ */new this.constructor();
  16562. this.cloneTo(destVector2);
  16563. return destVector2;
  16564. }
  16565. __proto.forNativeElement=function(nativeElements){
  16566. if (nativeElements){
  16567. /*__JS__ */this.elements=nativeElements;
  16568. /*__JS__ */this.elements[0]=this.x;
  16569. /*__JS__ */this.elements[1]=this.y;
  16570. }
  16571. else{
  16572. /*__JS__ */this.elements=new Float32Array([this.x,this.y]);
  16573. }
  16574. Vector2.rewriteNumProperty(this,"x",0);
  16575. Vector2.rewriteNumProperty(this,"y",1);
  16576. }
  16577. Vector2.scale=function(a,b,out){
  16578. out.x=a.x *b;
  16579. out.y=a.y *b;
  16580. }
  16581. Vector2.dot=function(a,b){
  16582. return (a.x *b.x)+(a.y *b.y);
  16583. }
  16584. Vector2.normalize=function(s,out){
  16585. var x=s.x,y=s.y;
  16586. var len=x *x+y *y;
  16587. if (len > 0){
  16588. len=1 / Math.sqrt(len);
  16589. out.x=x *len;
  16590. out.y=y *len;
  16591. }
  16592. }
  16593. Vector2.scalarLength=function(a){
  16594. var x=a.x,y=a.y;
  16595. return Math.sqrt(x *x+y *y);
  16596. }
  16597. Vector2.rewriteNumProperty=function(proto,name,index){
  16598. Object["defineProperty"](proto,name,{
  16599. "get":function (){
  16600. return /*__JS__ */this.elements[index];
  16601. },
  16602. "set":function (v){
  16603. /*__JS__ */this.elements[index]=v;
  16604. }
  16605. });
  16606. }
  16607. __static(Vector2,
  16608. ['ZERO',function(){return this.ZERO=new Vector2(0.0,0.0);},'ONE',function(){return this.ONE=new Vector2(1.0,1.0);}
  16609. ]);
  16610. return Vector2;
  16611. })()
  16612. /**
  16613. *<code>BoundSphere</code> 类用于创建包围球。
  16614. */
  16615. //class laya.d3.math.BoundSphere
  16616. var BoundSphere=(function(){
  16617. function BoundSphere(center,radius){
  16618. /**包围球的中心。*/
  16619. this.center=null;
  16620. /**包围球的半径。*/
  16621. this.radius=NaN;
  16622. this.center=center;
  16623. this.radius=radius;
  16624. }
  16625. __class(BoundSphere,'laya.d3.math.BoundSphere');
  16626. var __proto=BoundSphere.prototype;
  16627. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  16628. __proto.toDefault=function(){
  16629. this.center.toDefault();
  16630. this.radius=0;
  16631. }
  16632. /**
  16633. *判断射线是否与碰撞球交叉,并返回交叉距离。
  16634. *@param ray 射线。
  16635. *@return 距离交叉点的距离,-1表示不交叉。
  16636. */
  16637. __proto.intersectsRayDistance=function(ray){
  16638. return CollisionUtils.intersectsRayAndSphereRD(ray,this);
  16639. }
  16640. /**
  16641. *判断射线是否与碰撞球交叉,并返回交叉点。
  16642. *@param ray 射线。
  16643. *@param outPoint 交叉点。
  16644. *@return 距离交叉点的距离,-1表示不交叉。
  16645. */
  16646. __proto.intersectsRayPoint=function(ray,outPoint){
  16647. return CollisionUtils.intersectsRayAndSphereRP(ray,this,outPoint);
  16648. }
  16649. /**
  16650. *克隆。
  16651. *@param destObject 克隆源。
  16652. */
  16653. __proto.cloneTo=function(destObject){
  16654. var dest=destObject;
  16655. this.center.cloneTo(dest.center);
  16656. dest.radius=this.radius;
  16657. }
  16658. /**
  16659. *克隆。
  16660. *@return 克隆副本。
  16661. */
  16662. __proto.clone=function(){
  16663. var dest=/*__JS__ */new this.constructor(new Vector3(),new Vector3());
  16664. this.cloneTo(dest);
  16665. return dest;
  16666. }
  16667. BoundSphere.createFromSubPoints=function(points,start,count,out){
  16668. if (points==null){
  16669. throw new Error("points");
  16670. }
  16671. if (start < 0 || start >=points.length){
  16672. throw new Error("start"+start+"Must be in the range [0, "+(points.length-1)+"]");
  16673. }
  16674. if (count < 0 || (start+count)> points.length){
  16675. throw new Error("count"+count+"Must be in the range <= "+points.length+"}");
  16676. };
  16677. var upperEnd=start+count;
  16678. var center=BoundSphere._tempVector3;
  16679. center.x=0;
  16680. center.y=0;
  16681. center.z=0;
  16682. for (var i=start;i < upperEnd;++i){
  16683. Vector3.add(points[i],center,center);
  16684. };
  16685. var outCenter=out.center;
  16686. Vector3.scale(center,1 / count,outCenter);
  16687. var radius=0.0;
  16688. for (i=start;i < upperEnd;++i){
  16689. var distance=Vector3.distanceSquared(outCenter,points[i]);
  16690. if (distance > radius)
  16691. radius=distance;
  16692. }
  16693. out.radius=Math.sqrt(radius);
  16694. }
  16695. BoundSphere.createfromPoints=function(points,out){
  16696. if (points==null){
  16697. throw new Error("points");
  16698. }
  16699. BoundSphere.createFromSubPoints(points,0,points.length,out);
  16700. }
  16701. __static(BoundSphere,
  16702. ['_tempVector3',function(){return this._tempVector3=new Vector3();}
  16703. ]);
  16704. return BoundSphere;
  16705. })()
  16706. /**
  16707. *<code>Shader3D</code> 类用于创建Shader3D。
  16708. */
  16709. //class laya.d3.shader.Shader3D
  16710. var Shader3D=(function(){
  16711. function Shader3D(name,attributeMap,uniformMap,enableInstancing){
  16712. /**@private */
  16713. this._attributeMap=null;
  16714. /**@private */
  16715. this._uniformMap=null;
  16716. /**@private */
  16717. //this._name=null;
  16718. /**@private */
  16719. this._enableInstancing=false;
  16720. this._subShaders=[];
  16721. this._name=name;
  16722. this._attributeMap=attributeMap;
  16723. this._uniformMap=uniformMap;
  16724. this._enableInstancing=enableInstancing;
  16725. }
  16726. __class(Shader3D,'laya.d3.shader.Shader3D');
  16727. var __proto=Shader3D.prototype;
  16728. /**
  16729. *添加子着色器。
  16730. *@param 子着色器。
  16731. */
  16732. __proto.addSubShader=function(subShader){
  16733. this._subShaders.push(subShader);
  16734. subShader._owner=this;
  16735. }
  16736. /**
  16737. *在特定索引获取子着色器。
  16738. *@param index 索引。
  16739. *@return 子着色器。
  16740. */
  16741. __proto.getSubShaderAt=function(index){
  16742. return this._subShaders[index];
  16743. }
  16744. Shader3D.propertyNameToID=function(name){
  16745. if (Shader3D._propertyNameMap[name] !=null){
  16746. return Shader3D._propertyNameMap[name];
  16747. }else {
  16748. var id=Shader3D._propertyNameCounter++;
  16749. Shader3D._propertyNameMap[name]=id;
  16750. return id;
  16751. }
  16752. }
  16753. Shader3D.addInclude=function(fileName,txt){
  16754. ShaderCompile.addInclude(fileName,txt);
  16755. }
  16756. Shader3D.registerPublicDefine=function(name){
  16757. var value=Math.pow(2,Shader3D._publicCounter++);
  16758. Shader3D._globleDefines[value]=name;
  16759. return value;
  16760. }
  16761. Shader3D.compileShader=function(name,subShaderIndex,passIndex,publicDefine,spriteDefine,materialDefine){
  16762. var shader=laya.d3.shader.Shader3D.find(name);
  16763. if (shader){
  16764. var subShader=shader.getSubShaderAt(subShaderIndex);
  16765. if (subShader){
  16766. var pass=subShader._passes[passIndex];
  16767. if (pass){
  16768. if (WebGL.shaderHighPrecision)
  16769. pass.withCompile(publicDefine,spriteDefine,materialDefine);
  16770. else
  16771. pass.withCompile(publicDefine-laya.d3.shader.Shader3D.SHADERDEFINE_HIGHPRECISION,spriteDefine,materialDefine);
  16772. }else {
  16773. console.warn("Shader3D: unknown passIndex.");
  16774. }
  16775. }else {
  16776. console.warn("Shader3D: unknown subShaderIndex.");
  16777. }
  16778. }else {
  16779. console.warn("Shader3D: unknown shader name.");
  16780. }
  16781. }
  16782. Shader3D.add=function(name,attributeMap,uniformMap,enableInstancing){
  16783. (enableInstancing===void 0)&& (enableInstancing=false);
  16784. return laya.d3.shader.Shader3D._preCompileShader[name]=new Shader3D(name,attributeMap,uniformMap,enableInstancing);
  16785. }
  16786. Shader3D.find=function(name){
  16787. return laya.d3.shader.Shader3D._preCompileShader[name];
  16788. }
  16789. Shader3D.RENDER_STATE_CULL=0;
  16790. Shader3D.RENDER_STATE_BLEND=1;
  16791. Shader3D.RENDER_STATE_BLEND_SRC=2;
  16792. Shader3D.RENDER_STATE_BLEND_DST=3;
  16793. Shader3D.RENDER_STATE_BLEND_SRC_RGB=4;
  16794. Shader3D.RENDER_STATE_BLEND_DST_RGB=5;
  16795. Shader3D.RENDER_STATE_BLEND_SRC_ALPHA=6;
  16796. Shader3D.RENDER_STATE_BLEND_DST_ALPHA=7;
  16797. Shader3D.RENDER_STATE_BLEND_CONST_COLOR=8;
  16798. Shader3D.RENDER_STATE_BLEND_EQUATION=9;
  16799. Shader3D.RENDER_STATE_BLEND_EQUATION_RGB=10;
  16800. Shader3D.RENDER_STATE_BLEND_EQUATION_ALPHA=11;
  16801. Shader3D.RENDER_STATE_DEPTH_TEST=12;
  16802. Shader3D.RENDER_STATE_DEPTH_WRITE=13;
  16803. Shader3D.PERIOD_CUSTOM=0;
  16804. Shader3D.PERIOD_MATERIAL=1;
  16805. Shader3D.PERIOD_SPRITE=2;
  16806. Shader3D.PERIOD_CAMERA=3;
  16807. Shader3D.PERIOD_SCENE=4;
  16808. Shader3D.SHADERDEFINE_HIGHPRECISION=0;
  16809. Shader3D._propertyNameCounter=0;
  16810. Shader3D._propertyNameMap={};
  16811. Shader3D._publicCounter=0;
  16812. Shader3D._globleDefines=[];
  16813. Shader3D._preCompileShader={};
  16814. Shader3D.debugMode=false;
  16815. return Shader3D;
  16816. })()
  16817. /**
  16818. *<code>Gradient</code> 类用于创建颜色渐变。
  16819. */
  16820. //class laya.d3.core.Gradient
  16821. var Gradient=(function(){
  16822. function Gradient(maxColorRGBKeyCount,maxColorAlphaKeyCount){
  16823. /**@private */
  16824. this._mode=0;
  16825. /**@private */
  16826. this._maxColorRGBKeysCount=0;
  16827. /**@private */
  16828. this._maxColorAlphaKeysCount=0;
  16829. /**@private */
  16830. this._colorRGBKeysCount=0;
  16831. /**@private */
  16832. this._colorAlphaKeysCount=0;
  16833. /**@private */
  16834. this._alphaElements=null;
  16835. /**@private */
  16836. this._rgbElements=null;
  16837. this._maxColorRGBKeysCount=maxColorRGBKeyCount;
  16838. this._maxColorAlphaKeysCount=maxColorAlphaKeyCount;
  16839. this._rgbElements=new Float32Array(maxColorRGBKeyCount *4);
  16840. this._alphaElements=new Float32Array(maxColorAlphaKeyCount *2);
  16841. }
  16842. __class(Gradient,'laya.d3.core.Gradient');
  16843. var __proto=Gradient.prototype;
  16844. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  16845. /**
  16846. *增加颜色RGB帧。
  16847. *@param key 生命周期,范围为0到1。
  16848. *@param value RGB值。
  16849. */
  16850. __proto.addColorRGB=function(key,value){
  16851. if (this._colorRGBKeysCount < this._maxColorRGBKeysCount){
  16852. var offset=this._colorRGBKeysCount *4;
  16853. this._rgbElements[offset]=key;
  16854. this._rgbElements[offset+1]=value.r;
  16855. this._rgbElements[offset+2]=value.g;
  16856. this._rgbElements[offset+3]=value.b;
  16857. this._colorRGBKeysCount++;
  16858. }else {
  16859. console.warn("Gradient:warning:data count must lessEqual than "+this._maxColorRGBKeysCount);
  16860. }
  16861. }
  16862. /**
  16863. *增加颜色Alpha帧。
  16864. *@param key 生命周期,范围为0到1。
  16865. *@param value Alpha值。
  16866. */
  16867. __proto.addColorAlpha=function(key,value){
  16868. if (this._colorAlphaKeysCount < this._maxColorAlphaKeysCount){
  16869. var offset=this._colorAlphaKeysCount *2;
  16870. this._alphaElements[offset]=key;
  16871. this._alphaElements[offset+1]=value;
  16872. this._colorAlphaKeysCount++;
  16873. }else {
  16874. console.warn("Gradient:warning:data count must lessEqual than "+this._maxColorAlphaKeysCount);
  16875. }
  16876. }
  16877. /**
  16878. *更新颜色RGB帧。
  16879. *@param index 索引。
  16880. *@param key 生命周期,范围为0到1。
  16881. *@param value RGB值。
  16882. */
  16883. __proto.updateColorRGB=function(index,key,value){
  16884. if (index < this._colorRGBKeysCount){
  16885. var offset=index *4;
  16886. this._rgbElements[offset]=key;
  16887. this._rgbElements[offset+1]=value.r;
  16888. this._rgbElements[offset+2]=value.g;
  16889. this._rgbElements[offset+3]=value.b;
  16890. }else {
  16891. console.warn("Gradient:warning:index must lessEqual than colorRGBKeysCount:"+this._colorRGBKeysCount);
  16892. }
  16893. }
  16894. /**
  16895. *更新颜色Alpha帧。
  16896. *@param index 索引。
  16897. *@param key 生命周期,范围为0到1。
  16898. *@param value Alpha值。
  16899. */
  16900. __proto.updateColorAlpha=function(index,key,value){
  16901. if (index < this._colorAlphaKeysCount){
  16902. var offset=index *2;
  16903. this._alphaElements[offset]=key;
  16904. this._alphaElements[offset+1]=value;
  16905. }else {
  16906. console.warn("Gradient:warning:index must lessEqual than colorAlphaKeysCount:"+this._colorAlphaKeysCount);
  16907. }
  16908. }
  16909. /**
  16910. *克隆。
  16911. *@param destObject 克隆源。
  16912. */
  16913. __proto.cloneTo=function(destObject){
  16914. var destGradientDataColor=destObject;
  16915. var i=0,n=0;
  16916. destGradientDataColor._colorAlphaKeysCount=this._colorAlphaKeysCount;
  16917. var destAlphaElements=destGradientDataColor._alphaElements;
  16918. destAlphaElements.length=this._alphaElements.length;
  16919. for (i=0,n=this._alphaElements.length;i < n;i++)
  16920. destAlphaElements[i]=this._alphaElements[i];
  16921. destGradientDataColor._colorRGBKeysCount=this._colorRGBKeysCount;
  16922. var destRGBElements=destGradientDataColor._rgbElements;
  16923. destRGBElements.length=this._rgbElements.length;
  16924. for (i=0,n=this._rgbElements.length;i < n;i++)
  16925. destRGBElements[i]=this._rgbElements[i];
  16926. }
  16927. /**
  16928. *克隆。
  16929. *@return 克隆副本。
  16930. */
  16931. __proto.clone=function(){
  16932. var destGradientDataColor=new Gradient(this._maxColorRGBKeysCount,this._maxColorAlphaKeysCount);
  16933. this.cloneTo(destGradientDataColor);
  16934. return destGradientDataColor;
  16935. }
  16936. /**
  16937. *获取颜色RGB数量。
  16938. *@return 颜色RGB数量。
  16939. */
  16940. __getset(0,__proto,'colorRGBKeysCount',function(){
  16941. return this._colorRGBKeysCount / 4;
  16942. });
  16943. /**
  16944. *设置梯度模式。
  16945. *@param value 梯度模式。
  16946. */
  16947. /**
  16948. *获取梯度模式。
  16949. *@return 梯度模式。
  16950. */
  16951. __getset(0,__proto,'mode',function(){
  16952. return this._mode;
  16953. },function(value){
  16954. this._mode=value;
  16955. });
  16956. /**
  16957. *获取颜色Alpha数量。
  16958. *@return 颜色Alpha数量。
  16959. */
  16960. __getset(0,__proto,'colorAlphaKeysCount',function(){
  16961. return this._colorAlphaKeysCount / 2;
  16962. });
  16963. /**
  16964. *获取最大颜色RGB帧数量。
  16965. *@return 最大RGB帧数量。
  16966. */
  16967. __getset(0,__proto,'maxColorRGBKeysCount',function(){
  16968. return this._maxColorRGBKeysCount;
  16969. });
  16970. /**
  16971. *获取最大颜色Alpha帧数量。
  16972. *@return 最大Alpha帧数量。
  16973. */
  16974. __getset(0,__proto,'maxColorAlphaKeysCount',function(){
  16975. return this._maxColorAlphaKeysCount;
  16976. });
  16977. return Gradient;
  16978. })()
  16979. /**
  16980. *<code>Touch</code> 类用于实现触摸描述。
  16981. */
  16982. //class laya.d3.Touch
  16983. var Touch=(function(){
  16984. function Touch(){
  16985. /**@private [实现IListPool接口]*/
  16986. this._indexInList=-1;
  16987. /**@private */
  16988. this._identifier=-1;
  16989. this._position=new Vector2();
  16990. }
  16991. __class(Touch,'laya.d3.Touch');
  16992. var __proto=Touch.prototype;
  16993. Laya.imps(__proto,{"laya.resource.ISingletonElement":true})
  16994. /**
  16995. *@private [实现ISingletonElement接口]
  16996. */
  16997. __proto._getIndexInList=function(){
  16998. return this._indexInList;
  16999. }
  17000. /**
  17001. *@private [实现ISingletonElement接口]
  17002. */
  17003. __proto._setIndexInList=function(index){
  17004. this._indexInList=index;
  17005. }
  17006. /**
  17007. *获取唯一识别ID。
  17008. *@return 唯一识别ID。
  17009. */
  17010. __getset(0,__proto,'identifier',function(){
  17011. return this._identifier;
  17012. });
  17013. /**
  17014. *获取触摸点的像素坐标。
  17015. *@return 触摸点的像素坐标 [只读]。
  17016. */
  17017. __getset(0,__proto,'position',function(){
  17018. return this._position;
  17019. });
  17020. return Touch;
  17021. })()
  17022. //class laya.d3.utils.Size
  17023. var Size=(function(){
  17024. function Size(width,height){
  17025. this._width=0;
  17026. this._height=0;
  17027. this._width=width;
  17028. this._height=height;
  17029. }
  17030. __class(Size,'laya.d3.utils.Size');
  17031. var __proto=Size.prototype;
  17032. __getset(0,__proto,'width',function(){
  17033. if (this._width===-1)
  17034. return RenderContext3D.clientWidth;
  17035. return this._width;
  17036. });
  17037. __getset(0,__proto,'height',function(){
  17038. if (this._height===-1)
  17039. return RenderContext3D.clientHeight;
  17040. return this._height;
  17041. });
  17042. __getset(1,Size,'fullScreen',function(){
  17043. return new Size(-1,-1);
  17044. });
  17045. return Size;
  17046. })()
  17047. /**
  17048. *<code>Plane</code> 类用于创建平面。
  17049. */
  17050. //class laya.d3.math.Plane
  17051. var Plane=(function(){
  17052. function Plane(normal,d){
  17053. /**平面的向量*/
  17054. this.normal=null;
  17055. /**平面到坐标系原点的距离*/
  17056. this.distance=NaN;
  17057. (d===void 0)&& (d=0);
  17058. this.normal=normal;
  17059. this.distance=d;
  17060. }
  17061. __class(Plane,'laya.d3.math.Plane');
  17062. var __proto=Plane.prototype;
  17063. /**
  17064. *更改平面法线向量的系数,使之成单位长度。
  17065. */
  17066. __proto.normalize=function(){
  17067. var normalEX=this.normal.x;
  17068. var normalEY=this.normal.y;
  17069. var normalEZ=this.normal.z;
  17070. var magnitude=1 / Math.sqrt(normalEX *normalEX+normalEY *normalEY+normalEZ *normalEZ);
  17071. this.normal.x=normalEX *magnitude;
  17072. this.normal.y=normalEY *magnitude;
  17073. this.normal.z=normalEZ *magnitude;
  17074. this.distance *=magnitude;
  17075. }
  17076. Plane.createPlaneBy3P=function(point1,point2,point3){
  17077. var x1=point2.x-point1.x;
  17078. var y1=point2.y-point1.y;
  17079. var z1=point2.z-point1.z;
  17080. var x2=point3.x-point1.x;
  17081. var y2=point3.y-point1.y;
  17082. var z2=point3.z-point1.z;
  17083. var yz=(y1 *z2)-(z1 *y2);
  17084. var xz=(z1 *x2)-(x1 *z2);
  17085. var xy=(x1 *y2)-(y1 *x2);
  17086. var invPyth=1 / (Math.sqrt((yz *yz)+(xz *xz)+(xy *xy)));
  17087. var x=yz *invPyth;
  17088. var y=xz *invPyth;
  17089. var z=xy *invPyth;
  17090. Plane._TEMPVec3.x=x;
  17091. Plane._TEMPVec3.y=y;
  17092. Plane._TEMPVec3.z=z;
  17093. var d=-((x *point1.x)+(y *point1.y)+(z *point1.z));
  17094. var plane=new Plane(Plane._TEMPVec3,d);
  17095. return plane;
  17096. }
  17097. Plane.PlaneIntersectionType_Back=0;
  17098. Plane.PlaneIntersectionType_Front=1;
  17099. Plane.PlaneIntersectionType_Intersecting=2;
  17100. __static(Plane,
  17101. ['_TEMPVec3',function(){return this._TEMPVec3=new Vector3();}
  17102. ]);
  17103. return Plane;
  17104. })()
  17105. /**
  17106. *<code>Emission</code> 类用于粒子发射器。
  17107. */
  17108. //class laya.d3.core.particleShuriKen.module.Emission
  17109. var Emission=(function(){
  17110. function Emission(){
  17111. /**@private */
  17112. this._destroyed=false;
  17113. /**@private 粒子发射速率,每秒发射的个数。*/
  17114. this._emissionRate=0;
  17115. /**@private 粒子的爆裂,不允许修改。*/
  17116. this._bursts=null;
  17117. /**是否启用。*/
  17118. this.enbale=false;
  17119. this._destroyed=false;
  17120. this.emissionRate=10;
  17121. this._bursts=[];
  17122. }
  17123. __class(Emission,'laya.d3.core.particleShuriKen.module.Emission');
  17124. var __proto=Emission.prototype;
  17125. Laya.imps(__proto,{"laya.d3.core.IClone":true,"laya.resource.IDestroy":true})
  17126. /**
  17127. *@private
  17128. */
  17129. __proto.destroy=function(){
  17130. this._bursts=null;
  17131. this._destroyed=true;
  17132. }
  17133. /**
  17134. *获取粒子爆裂个数。
  17135. *@return 粒子爆裂个数。
  17136. */
  17137. __proto.getBurstsCount=function(){
  17138. return this._bursts.length;
  17139. }
  17140. /**
  17141. *通过索引获取粒子爆裂。
  17142. *@param index 爆裂索引。
  17143. *@return 粒子爆裂。
  17144. */
  17145. __proto.getBurstByIndex=function(index){
  17146. return this._bursts[index];
  17147. }
  17148. /**
  17149. *增加粒子爆裂。
  17150. *@param burst 爆裂。
  17151. */
  17152. __proto.addBurst=function(burst){
  17153. var burstsCount=this._bursts.length;
  17154. if (burstsCount > 0)
  17155. for (var i=0;i < burstsCount;i++){
  17156. if (this._bursts[i].time > burst.time)
  17157. this._bursts.splice(i,0,burst);
  17158. }
  17159. this._bursts.push(burst);
  17160. }
  17161. /**
  17162. *移除粒子爆裂。
  17163. *@param burst 爆裂。
  17164. */
  17165. __proto.removeBurst=function(burst){
  17166. var index=this._bursts.indexOf(burst);
  17167. if (index!==-1){
  17168. this._bursts.splice(index,1);
  17169. }
  17170. }
  17171. /**
  17172. *通过索引移除粒子爆裂。
  17173. *@param index 爆裂索引。
  17174. */
  17175. __proto.removeBurstByIndex=function(index){
  17176. this._bursts.splice(index,1);
  17177. }
  17178. /**
  17179. *清空粒子爆裂。
  17180. */
  17181. __proto.clearBurst=function(){
  17182. this._bursts.length=0;
  17183. }
  17184. /**
  17185. *克隆。
  17186. *@param destObject 克隆源。
  17187. */
  17188. __proto.cloneTo=function(destObject){
  17189. var destEmission=destObject;
  17190. var destBursts=destEmission._bursts;
  17191. destBursts.length=this._bursts.length;
  17192. for (var i=0,n=this._bursts.length;i < n;i++){
  17193. var destBurst=destBursts[i];
  17194. if (destBurst)
  17195. this._bursts[i].cloneTo(destBurst);
  17196. else
  17197. destBursts[i]=this._bursts[i].clone();
  17198. }
  17199. destEmission._emissionRate=this._emissionRate;
  17200. destEmission.enbale=this.enbale;
  17201. }
  17202. /**
  17203. *克隆。
  17204. *@return 克隆副本。
  17205. */
  17206. __proto.clone=function(){
  17207. var destEmission=/*__JS__ */new this.constructor();
  17208. this.cloneTo(destEmission);
  17209. return destEmission;
  17210. }
  17211. /**
  17212. *获取是否已销毁。
  17213. *@return 是否已销毁。
  17214. */
  17215. __getset(0,__proto,'destroyed',function(){
  17216. return this._destroyed;
  17217. });
  17218. /**
  17219. *设置粒子发射速率。
  17220. *@param emissionRate 粒子发射速率 (个/秒)。
  17221. */
  17222. /**
  17223. *获取粒子发射速率。
  17224. *@return 粒子发射速率 (个/秒)。
  17225. */
  17226. __getset(0,__proto,'emissionRate',function(){
  17227. return this._emissionRate;
  17228. },function(value){
  17229. if (value < 0)
  17230. throw new Error("ParticleBaseShape:emissionRate value must large or equal than 0.");
  17231. this._emissionRate=value;
  17232. });
  17233. return Emission;
  17234. })()
  17235. /**
  17236. *@private
  17237. *<code>FrustumCulling</code> 类用于裁剪。
  17238. */
  17239. //class laya.d3.graphics.FrustumCulling
  17240. var FrustumCulling=(function(){
  17241. /**
  17242. *创建一个 <code>FrustumCulling</code> 实例。
  17243. */
  17244. function FrustumCulling(){}
  17245. __class(FrustumCulling,'laya.d3.graphics.FrustumCulling');
  17246. FrustumCulling.__init__=function(){
  17247. if (Render.supportWebGLPlusCulling){
  17248. FrustumCulling._cullingBufferLength=0;
  17249. FrustumCulling._cullingBuffer=new Float32Array(4096);
  17250. }
  17251. }
  17252. FrustumCulling._drawTraversalCullingBound=function(renderList,debugTool){
  17253. var validCount=renderList.length;
  17254. var renders=renderList.elements;
  17255. for (var i=0,n=renderList.length;i < n;i++){
  17256. var color=FrustumCulling._tempColor0;
  17257. color.r=0;
  17258. color.g=1;
  17259. color.b=0;
  17260. color.a=1;
  17261. Utils3D._drawBound(debugTool,(renders [i]).bounds._getBoundBox(),color);
  17262. }
  17263. }
  17264. FrustumCulling._traversalCulling=function(camera,scene,context,renderList){
  17265. var validCount=renderList.length;
  17266. var renders=renderList.elements;
  17267. var boundFrustum=camera.boundFrustum;
  17268. var camPos=camera._transform.position;
  17269. for (var i=0;i < validCount;i++){
  17270. var render=renders [i];
  17271. if (camera._isLayerVisible(render._owner._layer)&& render._enable){
  17272. Stat.frustumCulling++;
  17273. if (!camera.useOcclusionCulling || render._needRender(boundFrustum)){
  17274. render._visible=true;
  17275. var bounds=render.bounds;
  17276. render._distanceForSort=Vector3.distance(bounds.getCenter(),camPos);
  17277. var elements=render._renderElements;
  17278. for (var j=0,m=elements.length;j < m;j++){
  17279. var element=elements[j];
  17280. var renderQueue=scene._getRenderQueue(element.material.renderQueue);
  17281. if (renderQueue.isTransparent)
  17282. element.addToTransparentRenderQueue(context,renderQueue);
  17283. else
  17284. element.addToOpaqueRenderQueue(context,renderQueue);
  17285. }
  17286. }else {
  17287. render._visible=false;
  17288. }
  17289. }else {
  17290. render._visible=false;
  17291. }
  17292. }
  17293. }
  17294. FrustumCulling.renderObjectCulling=function(camera,scene,context,renderList){
  17295. var i=0,n=0,j=0,m=0;
  17296. var opaqueQueue=scene._opaqueQueue;
  17297. var transparentQueue=scene._transparentQueue;
  17298. opaqueQueue.clear();
  17299. transparentQueue.clear();
  17300. var staticBatchManagers=StaticBatchManager._managers;
  17301. for (i=0,n=staticBatchManagers.length;i < n;i++)
  17302. staticBatchManagers[i]._clear();
  17303. var dynamicBatchManagers=DynamicBatchManager._managers;
  17304. for (i=0,n=dynamicBatchManagers.length;i < n;i++)
  17305. dynamicBatchManagers[i]._clear();
  17306. var octree=scene._octree;
  17307. if (octree){
  17308. octree.updateMotionObjects();
  17309. octree.shrinkRootIfPossible();
  17310. octree.getCollidingWithFrustum(context);
  17311. }else {
  17312. FrustumCulling._traversalCulling(camera,scene,context,renderList);
  17313. }
  17314. if (Laya3D._config.debugFrustumCulling){
  17315. var debugTool=scene._debugTool;
  17316. debugTool.clear();
  17317. if (octree){
  17318. octree.drawAllBounds(debugTool);
  17319. octree.drawAllObjects(debugTool);
  17320. }else {
  17321. FrustumCulling._drawTraversalCullingBound(renderList,debugTool);
  17322. }
  17323. };
  17324. var count=opaqueQueue.elements.length;
  17325. (count > 0)&& (opaqueQueue._quickSort(0,count-1));
  17326. count=transparentQueue.elements.length;
  17327. (count > 0)&& (transparentQueue._quickSort(0,count-1));
  17328. }
  17329. FrustumCulling.renderObjectCullingNative=function(camera,scene,context,renderList){
  17330. var i=0,n=0,j=0,m=0;
  17331. var opaqueQueue=scene._opaqueQueue;
  17332. var transparentQueue=scene._transparentQueue;
  17333. opaqueQueue.clear();
  17334. transparentQueue.clear();
  17335. var staticBatchManagers=StaticBatchManager._managers;
  17336. for (i=0,n=staticBatchManagers.length;i < n;i++)
  17337. staticBatchManagers[i]._clear();
  17338. var dynamicBatchManagers=DynamicBatchManager._managers;
  17339. for (i=0,n=dynamicBatchManagers.length;i < n;i++)
  17340. dynamicBatchManagers[i]._clear();
  17341. var validCount=renderList.length;
  17342. var renders=renderList.elements;
  17343. for (i=0;i < validCount;i++){
  17344. (renders [i]).bounds;
  17345. };
  17346. var boundFrustum=camera.boundFrustum;
  17347. FrustumCulling.cullingNative(camera._boundFrustumBuffer,FrustumCulling._cullingBuffer,scene._cullingBufferIndices,validCount,scene._cullingBufferResult);
  17348. var camPos=context.camera._transform.position;
  17349. for (i=0;i < validCount;i++){
  17350. var render=renders [i];
  17351. if (camera._isLayerVisible(render._owner._layer)&& render._enable && scene._cullingBufferResult[i]){
  17352. render._visible=true;
  17353. render._distanceForSort=Vector3.distance(render.bounds.getCenter(),camPos);
  17354. var elements=render._renderElements;
  17355. for (j=0,m=elements.length;j < m;j++){
  17356. var element=elements[j];
  17357. var renderQueue=scene._getRenderQueue(element.material.renderQueue);
  17358. if (renderQueue.isTransparent)
  17359. element.addToTransparentRenderQueue(context,renderQueue);
  17360. else
  17361. element.addToOpaqueRenderQueue(context,renderQueue);
  17362. }
  17363. }else {
  17364. render._visible=false;
  17365. }
  17366. };
  17367. var count=opaqueQueue.elements.length;
  17368. (count > 0)&& (opaqueQueue._quickSort(0,count-1));
  17369. count=transparentQueue.elements.length;
  17370. (count > 0)&& (transparentQueue._quickSort(0,count-1));
  17371. }
  17372. FrustumCulling.cullingNative=function(boundFrustumBuffer,cullingBuffer,cullingBufferIndices,cullingCount,cullingBufferResult){
  17373. return LayaGL.instance.culling(boundFrustumBuffer,cullingBuffer,cullingBufferIndices,cullingCount,cullingBufferResult);
  17374. }
  17375. FrustumCulling._cullingBufferLength=0;
  17376. FrustumCulling._cullingBuffer=null;
  17377. __static(FrustumCulling,
  17378. ['_tempVector3',function(){return this._tempVector3=new Vector3();},'_tempColor0',function(){return this._tempColor0=new Color();}
  17379. ]);
  17380. return FrustumCulling;
  17381. })()
  17382. /**
  17383. *<code>DefineDatas</code> 类用于创建宏定义数据。
  17384. */
  17385. //class laya.d3.shader.DefineDatas
  17386. var DefineDatas=(function(){
  17387. function DefineDatas(){
  17388. /**@private */
  17389. //this.value=0;
  17390. this.value=0;
  17391. }
  17392. __class(DefineDatas,'laya.d3.shader.DefineDatas');
  17393. var __proto=DefineDatas.prototype;
  17394. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  17395. /**
  17396. *增加Shader宏定义。
  17397. *@param value 宏定义。
  17398. */
  17399. __proto.add=function(define){
  17400. this.value |=define;
  17401. }
  17402. /**
  17403. *移除Shader宏定义。
  17404. *@param value 宏定义。
  17405. */
  17406. __proto.remove=function(define){
  17407. this.value &=~define;
  17408. }
  17409. /**
  17410. *是否包含Shader宏定义。
  17411. *@param value 宏定义。
  17412. */
  17413. __proto.has=function(define){
  17414. return (this.value & define)> 0;
  17415. }
  17416. /**
  17417. *克隆。
  17418. *@param destObject 克隆源。
  17419. */
  17420. __proto.cloneTo=function(destObject){
  17421. var destDefineData=destObject;
  17422. destDefineData.value=this.value;
  17423. }
  17424. /**
  17425. *克隆。
  17426. *@return 克隆副本。
  17427. */
  17428. __proto.clone=function(){
  17429. var dest=/*__JS__ */new this.constructor();
  17430. this.cloneTo(dest);
  17431. return dest;
  17432. }
  17433. return DefineDatas;
  17434. })()
  17435. /**
  17436. *<code>Laya3D</code> 类用于初始化3D设置。
  17437. */
  17438. //class Laya3D
  17439. var Laya3D=(function(){
  17440. /**
  17441. *创建一个 <code>Laya3D</code> 实例。
  17442. */
  17443. function Laya3D(){}
  17444. __class(Laya3D,'Laya3D');
  17445. /**
  17446. *获取是否可以启用物理。
  17447. *@param 是否启用物理。
  17448. */
  17449. __getset(1,Laya3D,'enbalePhysics',function(){
  17450. return Laya3D._enbalePhysics;
  17451. });
  17452. Laya3D._cancelLoadByUrl=function(url){
  17453. Laya.loader.cancelLoadByUrl(url);
  17454. Laya3D._innerFirstLevelLoaderManager.cancelLoadByUrl(url);
  17455. Laya3D._innerSecondLevelLoaderManager.cancelLoadByUrl(url);
  17456. Laya3D._innerThirdLevelLoaderManager.cancelLoadByUrl(url);
  17457. Laya3D._innerFourthLevelLoaderManager.cancelLoadByUrl(url);
  17458. }
  17459. Laya3D._changeWebGLSize=function(width,height){
  17460. WebGL.onStageResize(width,height);
  17461. RenderContext3D.clientWidth=width;
  17462. RenderContext3D.clientHeight=height;
  17463. }
  17464. Laya3D.__init__=function(width,height,config){
  17465. Config.isAntialias=config.isAntialias;
  17466. Config.isAlpha=config.isAlpha;
  17467. Config.premultipliedAlpha=config.premultipliedAlpha;
  17468. Config.isStencil=config.isStencil;
  17469. if (!WebGL.enable()){
  17470. alert("Laya3D init error,must support webGL!");
  17471. return;
  17472. }
  17473. RunDriver.changeWebGLSize=Laya3D._changeWebGLSize;
  17474. Render.is3DMode=true;
  17475. Laya.init(width,height);
  17476. if (!Render.supportWebGLPlusRendering){
  17477. LayaGL.instance=WebGL.mainContext;
  17478. LayaGL.instance.createCommandEncoder=function (reserveSize,adjustSize,isSyncToRenderThread){
  17479. (reserveSize===void 0)&& (reserveSize=128);
  17480. (adjustSize===void 0)&& (adjustSize=64);
  17481. (isSyncToRenderThread===void 0)&& (isSyncToRenderThread=false);
  17482. return new CommandEncoder(this,reserveSize,adjustSize,isSyncToRenderThread);
  17483. }
  17484. }
  17485. Laya3D.enableNative3D();
  17486. Sprite3D.__init__();
  17487. RenderableSprite3D.__init__();
  17488. MeshSprite3D.__init__();
  17489. SkinnedMeshSprite3D.__init__();
  17490. ShuriKenParticle3D.__init__();
  17491. BaseMaterial.__init__();
  17492. BlinnPhongMaterial.__init__();
  17493. PBRStandardMaterial.__init__();
  17494. PBRSpecularMaterial.__init__();
  17495. SkyProceduralMaterial.__init__();
  17496. UnlitMaterial.__init__();
  17497. TrailSprite3D.__init__();
  17498. TrailMaterial.__init__();
  17499. EffectMaterial.__init__();
  17500. WaterPrimaryMaterial.__init__();
  17501. ShurikenParticleMaterial.__init__();
  17502. TerrainMaterial.__init__();
  17503. ExtendTerrainMaterial.__init__();
  17504. ShaderInit3D.__init__();
  17505. PixelLineMaterial.defaultMaterial.lock=true;
  17506. BlinnPhongMaterial.defaultMaterial.lock=true;
  17507. EffectMaterial.defaultMaterial.lock=true;
  17508. PBRStandardMaterial.defaultMaterial.lock=true;
  17509. PBRSpecularMaterial.defaultMaterial.lock=true;
  17510. UnlitMaterial.defaultMaterial.lock=true;
  17511. ShurikenParticleMaterial.defaultMaterial.lock=true;
  17512. TrailMaterial.defaultMaterial.lock=true;
  17513. SkyProceduralMaterial.defaultMaterial.lock=true;
  17514. SkyBoxMaterial.defaultMaterial.lock=true;
  17515. WaterPrimaryMaterial.defaultMaterial.lock=true;
  17516. Texture2D.__init__();
  17517. TextureCube.__init__();
  17518. SkyBox.__init__();
  17519. SkyDome.__init__();
  17520. ScreenQuad.__init__();
  17521. PostProcess.__init__();
  17522. FrustumCulling.__init__();
  17523. HalfFloatUtils.__init__();
  17524. var createMap=LoaderManager.createMap;
  17525. createMap["lh"]=[ /*CLASS CONST:Laya3D.HIERARCHY*/"HIERARCHY",Sprite3D._parse];
  17526. createMap["ls"]=[ /*CLASS CONST:Laya3D.HIERARCHY*/"HIERARCHY",Scene3D._parse];
  17527. createMap["lm"]=[ /*CLASS CONST:Laya3D.MESH*/"MESH",Mesh._parse];
  17528. createMap["lmat"]=[ /*CLASS CONST:Laya3D.MATERIAL*/"MATERIAL",BaseMaterial._parse];
  17529. createMap["ltc"]=[ /*CLASS CONST:Laya3D.TEXTURECUBE*/"TEXTURECUBE",TextureCube._parse];
  17530. createMap["jpg"]=[ /*CLASS CONST:Laya3D.TEXTURE2D*/"TEXTURE2D",Texture2D._parse];
  17531. createMap["jpeg"]=[ /*CLASS CONST:Laya3D.TEXTURE2D*/"TEXTURE2D",Texture2D._parse];
  17532. createMap["bmp"]=[ /*CLASS CONST:Laya3D.TEXTURE2D*/"TEXTURE2D",Texture2D._parse];
  17533. createMap["gif"]=[ /*CLASS CONST:Laya3D.TEXTURE2D*/"TEXTURE2D",Texture2D._parse];
  17534. createMap["png"]=[ /*CLASS CONST:Laya3D.TEXTURE2D*/"TEXTURE2D",Texture2D._parse];
  17535. createMap["dds"]=[ /*CLASS CONST:Laya3D.TEXTURE2D*/"TEXTURE2D",Texture2D._parse];
  17536. createMap["ktx"]=[ /*CLASS CONST:Laya3D.TEXTURE2D*/"TEXTURE2D",Texture2D._parse];
  17537. createMap["pvr"]=[ /*CLASS CONST:Laya3D.TEXTURE2D*/"TEXTURE2D",Texture2D._parse];
  17538. createMap["lani"]=[ /*CLASS CONST:Laya3D.ANIMATIONCLIP*/"ANIMATIONCLIP",AnimationClip._parse];
  17539. createMap["lav"]=[ /*CLASS CONST:Laya3D.AVATAR*/"AVATAR",Avatar._parse];
  17540. createMap["thdata"]=[ /*CLASS CONST:Laya3D.TERRAINHEIGHTDATA*/"TERRAINHEIGHTDATA",TerrainHeightData._pharse];
  17541. var parserMap=Loader.parserMap;
  17542. parserMap[ /*CLASS CONST:Laya3D.HIERARCHY*/"HIERARCHY"]=Laya3D._loadHierarchy;
  17543. parserMap[ /*CLASS CONST:Laya3D.MESH*/"MESH"]=Laya3D._loadMesh;
  17544. parserMap[ /*CLASS CONST:Laya3D.MATERIAL*/"MATERIAL"]=Laya3D._loadMaterial;
  17545. parserMap[ /*CLASS CONST:Laya3D.TEXTURECUBE*/"TEXTURECUBE"]=Laya3D._loadTextureCube;
  17546. parserMap[ /*CLASS CONST:Laya3D.TEXTURE2D*/"TEXTURE2D"]=Laya3D._loadTexture2D;
  17547. parserMap[ /*CLASS CONST:Laya3D.ANIMATIONCLIP*/"ANIMATIONCLIP"]=Laya3D._loadAnimationClip;
  17548. parserMap[ /*CLASS CONST:Laya3D.AVATAR*/"AVATAR"]=Laya3D._loadAvatar;
  17549. Laya3D._innerFirstLevelLoaderManager.on(/*laya.events.Event.ERROR*/"error",null,Laya3D._eventLoadManagerError);
  17550. Laya3D._innerSecondLevelLoaderManager.on(/*laya.events.Event.ERROR*/"error",null,Laya3D._eventLoadManagerError);
  17551. Laya3D._innerThirdLevelLoaderManager.on(/*laya.events.Event.ERROR*/"error",null,Laya3D._eventLoadManagerError);
  17552. Laya3D._innerFourthLevelLoaderManager.on(/*laya.events.Event.ERROR*/"error",null,Laya3D._eventLoadManagerError);
  17553. }
  17554. Laya3D.enableNative3D=function(){
  17555. if (Render.isConchApp){
  17556. /*__JS__ */LayaGL=window.LayaGLContext;
  17557. var shaderData=ShaderData;
  17558. var shader3D=ShaderInstance;
  17559. var skinnedMeshRender=SkinnedMeshRenderer;
  17560. var avatar=Avatar;
  17561. var frustumCulling=FrustumCulling;
  17562. var meshRender=MeshRenderer;
  17563. if (Render.supportWebGLPlusRendering){
  17564. shaderData.prototype._initData=shaderData.prototype._initDataForNative;
  17565. shaderData.prototype.setBool=shaderData.prototype.setBoolForNative;
  17566. shaderData.prototype.getBool=shaderData.prototype.getBoolForNative;
  17567. shaderData.prototype.setInt=shaderData.prototype.setIntForNative;
  17568. shaderData.prototype.getInt=shaderData.prototype.getIntForNative;
  17569. shaderData.prototype.setNumber=shaderData.prototype.setNumberForNative;
  17570. shaderData.prototype.getNumber=shaderData.prototype.getNumberForNative;
  17571. shaderData.prototype.setVector=shaderData.prototype.setVectorForNative;
  17572. shaderData.prototype.getVector=shaderData.prototype.getVectorForNative;
  17573. shaderData.prototype.setVector2=shaderData.prototype.setVector2ForNative;
  17574. shaderData.prototype.getVector2=shaderData.prototype.getVector2ForNative;
  17575. shaderData.prototype.setVector3=shaderData.prototype.setVector3ForNative;
  17576. shaderData.prototype.getVector3=shaderData.prototype.getVector3ForNative;
  17577. shaderData.prototype.setQuaternion=shaderData.prototype.setQuaternionForNative;
  17578. shaderData.prototype.getQuaternion=shaderData.prototype.getQuaternionForNative;
  17579. shaderData.prototype.setMatrix4x4=shaderData.prototype.setMatrix4x4ForNative;
  17580. shaderData.prototype.getMatrix4x4=shaderData.prototype.getMatrix4x4ForNative;
  17581. shaderData.prototype.setBuffer=shaderData.prototype.setBufferForNative;
  17582. shaderData.prototype.getBuffer=shaderData.prototype.getBufferForNative;
  17583. shaderData.prototype.setTexture=shaderData.prototype.setTextureForNative;
  17584. shaderData.prototype.getTexture=shaderData.prototype.getTextureForNative;
  17585. shaderData.prototype.setAttribute=shaderData.prototype.setAttributeForNative;
  17586. shaderData.prototype.getAttribute=shaderData.prototype.getAttributeForNative;
  17587. shaderData.prototype.cloneTo=shaderData.prototype.cloneToForNative;
  17588. shaderData.prototype.getData=shaderData.prototype.getDataForNative;
  17589. shader3D.prototype._uniformMatrix2fv=shader3D.prototype._uniformMatrix2fvForNative;
  17590. shader3D.prototype._uniformMatrix3fv=shader3D.prototype._uniformMatrix3fvForNative;
  17591. shader3D.prototype._uniformMatrix4fv=shader3D.prototype._uniformMatrix4fvForNative;
  17592. meshRender.prototype._renderUpdateWithCamera=meshRender.prototype._renderUpdateWithCameraForNative;
  17593. }
  17594. if (Render.supportWebGLPlusCulling){
  17595. frustumCulling.renderObjectCulling=FrustumCulling.renderObjectCullingNative;
  17596. }
  17597. if (Render.supportWebGLPlusAnimation){
  17598. avatar.prototype._cloneDatasToAnimator=avatar.prototype._cloneDatasToAnimatorNative;
  17599. /*__JS__ */FloatKeyframe=window.conchFloatKeyframe;
  17600. /*__JS__ */Vector3Keyframe=window.conchFloatArrayKeyframe;
  17601. /*__JS__ */QuaternionKeyframe=window.conchFloatArrayKeyframe;
  17602. /*__JS__ */KeyframeNode=window.conchKeyframeNode;
  17603. /*__JS__ */KeyframeNodeList=window.conchKeyframeNodeList;
  17604. var animationClip=AnimationClip;
  17605. animationClip.prototype._evaluateClipDatasRealTime=animationClip.prototype._evaluateClipDatasRealTimeForNative;
  17606. }
  17607. }
  17608. WebGL.shaderHighPrecision=false;
  17609. var precisionFormat=LayaGL.instance.getShaderPrecisionFormat(/*laya.webgl.WebGLContext.FRAGMENT_SHADER*/0x8B30,/*laya.webgl.WebGLContext.HIGH_FLOAT*/0x8DF2);
  17610. precisionFormat.precision ? WebGL.shaderHighPrecision=true :WebGL.shaderHighPrecision=false;
  17611. }
  17612. Laya3D.formatRelativePath=function(base,value){
  17613. var path;
  17614. path=base+value;
  17615. var char1=value.charAt(0);
  17616. if (char1==="."){
  17617. var parts=path.split("/");
  17618. for (var i=0,len=parts.length;i < len;i++){
  17619. if (parts[i]=='..'){
  17620. var index=i-1;
  17621. if (index > 0 && parts[index]!=='..'){
  17622. parts.splice(index,2);
  17623. i-=2;
  17624. }
  17625. }
  17626. }
  17627. path=parts.join('/');
  17628. }
  17629. return path;
  17630. }
  17631. Laya3D._endLoad=function(loader,content,subResous){
  17632. if (subResous){
  17633. for (var i=0,n=subResous.length;i < n;i++){
  17634. var resou=Loader.getRes(subResous[i]);
  17635. (resou)&& (resou._removeReference());
  17636. }
  17637. }
  17638. loader.endLoad(content);
  17639. }
  17640. Laya3D._eventLoadManagerError=function(msg){
  17641. Laya.loader.event(/*laya.events.Event.ERROR*/"error",msg);
  17642. }
  17643. Laya3D._addHierarchyInnerUrls=function(urls,urlMap,urlVersion,hierarchyBasePath,path,type,constructParams,propertyParams){
  17644. var formatUrl=Laya3D.formatRelativePath(hierarchyBasePath,path);
  17645. (urlVersion)&& (formatUrl=formatUrl+urlVersion);
  17646. urls.push({url:formatUrl,type:type,constructParams:constructParams,propertyParams:propertyParams});
  17647. urlMap.push(formatUrl);
  17648. return formatUrl;
  17649. }
  17650. Laya3D._getSprite3DHierarchyInnerUrls=function(node,firstLevelUrls,secondLevelUrls,thirdLevelUrls,fourthLelUrls,subUrls,urlVersion,hierarchyBasePath){
  17651. var i=0,n=0;
  17652. var props=node.props;
  17653. switch (node.type){
  17654. case "Scene3D":;
  17655. var lightmaps=props.lightmaps;
  17656. for (i=0,n=lightmaps.length;i < n;i++){
  17657. var lightMap=lightmaps[i];
  17658. lightMap.path=Laya3D._addHierarchyInnerUrls(fourthLelUrls,subUrls,urlVersion,hierarchyBasePath,lightMap.path,/*CLASS CONST:Laya3D.TEXTURE2D*/"TEXTURE2D",lightMap.constructParams,lightMap.propertyParams);
  17659. };
  17660. var reflectionTextureData=props.reflectionTexture;
  17661. (reflectionTextureData)&& (props.reflectionTexture=Laya3D._addHierarchyInnerUrls(thirdLevelUrls,subUrls,urlVersion,hierarchyBasePath,reflectionTextureData,/*CLASS CONST:Laya3D.TEXTURECUBE*/"TEXTURECUBE"));
  17662. if (props.sky){
  17663. var skyboxMaterial=props.sky.material;
  17664. (skyboxMaterial)&& (skyboxMaterial.path=Laya3D._addHierarchyInnerUrls(secondLevelUrls,subUrls,urlVersion,hierarchyBasePath,skyboxMaterial.path,/*CLASS CONST:Laya3D.MATERIAL*/"MATERIAL"));
  17665. }
  17666. break ;
  17667. case "Camera":;
  17668. var skyboxMatData=props.skyboxMaterial;
  17669. (skyboxMatData)&& (skyboxMatData.path=Laya3D._addHierarchyInnerUrls(secondLevelUrls,subUrls,urlVersion,hierarchyBasePath,skyboxMatData.path,/*CLASS CONST:Laya3D.MATERIAL*/"MATERIAL"));
  17670. break ;
  17671. case "TrailSprite3D":
  17672. case "MeshSprite3D":
  17673. case "SkinnedMeshSprite3D":;
  17674. var meshPath=props.meshPath;
  17675. (meshPath)&& (props.meshPath=Laya3D._addHierarchyInnerUrls(firstLevelUrls,subUrls,urlVersion,hierarchyBasePath,meshPath,/*CLASS CONST:Laya3D.MESH*/"MESH"));
  17676. var materials=props.materials;
  17677. if (materials)
  17678. for (i=0,n=materials.length;i < n;i++)
  17679. materials[i].path=Laya3D._addHierarchyInnerUrls(secondLevelUrls,subUrls,urlVersion,hierarchyBasePath,materials[i].path,/*CLASS CONST:Laya3D.MATERIAL*/"MATERIAL");
  17680. break ;
  17681. case "ShuriKenParticle3D":;
  17682. var parMeshPath=props.meshPath;
  17683. (parMeshPath)&& (props.meshPath=Laya3D._addHierarchyInnerUrls(firstLevelUrls,subUrls,urlVersion,hierarchyBasePath,parMeshPath,/*CLASS CONST:Laya3D.MESH*/"MESH"));
  17684. props.material.path=Laya3D._addHierarchyInnerUrls(secondLevelUrls,subUrls,urlVersion,hierarchyBasePath,props.material.path,/*CLASS CONST:Laya3D.MATERIAL*/"MATERIAL");
  17685. break ;
  17686. case "Terrain":
  17687. Laya3D._addHierarchyInnerUrls(fourthLelUrls,subUrls,urlVersion,hierarchyBasePath,props.dataPath,"TERRAIN");
  17688. break ;
  17689. };
  17690. var components=node.components;
  17691. if (components){
  17692. for (var k=0,p=components.length;k < p;k++){
  17693. var component=components[k];
  17694. switch (component.type){
  17695. case "Animator":;
  17696. var avatarPath=component.avatarPath;
  17697. var avatarData=component.avatar;
  17698. (avatarData)&& (avatarData.path=Laya3D._addHierarchyInnerUrls(fourthLelUrls,subUrls,urlVersion,hierarchyBasePath,avatarData.path,"AVATAR"));
  17699. var clipPaths=component.clipPaths;
  17700. if (!clipPaths){
  17701. var layersData=component.layers;
  17702. for (i=0;i < layersData.length;i++){
  17703. var states=layersData[i].states;
  17704. for (var j=0,m=states.length;j < m;j++){
  17705. var clipPath=states[j].clipPath;
  17706. (clipPath)&& (states[j].clipPath=Laya3D._addHierarchyInnerUrls(fourthLelUrls,subUrls,urlVersion,hierarchyBasePath,clipPath,"ANIMATIONCLIP"));
  17707. }
  17708. }
  17709. }else {
  17710. for (i=0,n=clipPaths.length;i < n;i++)
  17711. clipPaths[i]=Laya3D._addHierarchyInnerUrls(fourthLelUrls,subUrls,urlVersion,hierarchyBasePath,clipPaths[i],"ANIMATIONCLIP");
  17712. }
  17713. break ;
  17714. case "PhysicsCollider":
  17715. case "Rigidbody3D":
  17716. case "CharacterController":;
  17717. var shapes=component.shapes;
  17718. for (i=0;i < shapes.length;i++){
  17719. var shape=shapes[i];
  17720. if (shape.type==="MeshColliderShape"){
  17721. var mesh=shape.mesh;
  17722. (mesh)&& (shape.mesh=Laya3D._addHierarchyInnerUrls(firstLevelUrls,subUrls,urlVersion,hierarchyBasePath,mesh,/*CLASS CONST:Laya3D.MESH*/"MESH"));
  17723. }
  17724. }
  17725. break ;
  17726. }
  17727. }
  17728. };
  17729. var children=node.child;
  17730. for (i=0,n=children.length;i < n;i++)
  17731. Laya3D._getSprite3DHierarchyInnerUrls(children[i],firstLevelUrls,secondLevelUrls,thirdLevelUrls,fourthLelUrls,subUrls,urlVersion,hierarchyBasePath);
  17732. }
  17733. Laya3D._loadHierarchy=function(loader){
  17734. loader.on(/*laya.events.Event.LOADED*/"loaded",null,Laya3D._onHierarchylhLoaded,[loader]);
  17735. loader.load(loader.url,/*laya.net.Loader.JSON*/"json",false,null,true);
  17736. }
  17737. Laya3D._onHierarchylhLoaded=function(loader,lhData){
  17738. var url=loader.url;
  17739. var urlVersion=Utils3D.getURLVerion(url);
  17740. var hierarchyBasePath=URL.getPath(url);
  17741. var firstLevUrls=[];
  17742. var secondLevUrls=[];
  17743. var thirdLevUrls=[];
  17744. var forthLevUrls=[];
  17745. var subUrls=[];
  17746. Laya3D._getSprite3DHierarchyInnerUrls(lhData.data,firstLevUrls,secondLevUrls,thirdLevUrls,forthLevUrls,subUrls,urlVersion,hierarchyBasePath);
  17747. var urlCount=firstLevUrls.length+secondLevUrls.length+forthLevUrls.length;
  17748. var totalProcessCount=urlCount+1;
  17749. var weight=1 / totalProcessCount;
  17750. Laya3D._onProcessChange(loader,0,weight,1.0);
  17751. if (forthLevUrls.length > 0){
  17752. var processCeil=urlCount / totalProcessCount;
  17753. var processHandler=Handler.create(null,Laya3D._onProcessChange,[loader,weight,processCeil],false);
  17754. 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);
  17755. }else {
  17756. Laya3D._onHierarchyInnerForthLevResouLoaded(loader,null,lhData,subUrls,firstLevUrls,secondLevUrls,thirdLevUrls,weight,processCeil);
  17757. }
  17758. }
  17759. Laya3D._onHierarchyInnerForthLevResouLoaded=function(loader,processHandler,lhData,subUrls,firstLevUrls,secondLevUrls,thirdLevUrls,processOffset,processCeil){
  17760. (processHandler)&& (processHandler.recover());
  17761. if (thirdLevUrls.length > 0){
  17762. var process=Handler.create(null,Laya3D._onProcessChange,[loader,processOffset,processCeil],false);
  17763. 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);
  17764. }else {
  17765. Laya3D._onHierarchyInnerThirdLevResouLoaded(loader,null,lhData,subUrls,firstLevUrls,secondLevUrls,processOffset,processCeil);
  17766. }
  17767. }
  17768. Laya3D._onHierarchyInnerThirdLevResouLoaded=function(loader,processHandler,lhData,subUrls,firstLevUrls,secondLevUrls,processOffset,processCeil){
  17769. (processHandler)&& (processHandler.recover());
  17770. if (secondLevUrls.length > 0){
  17771. var process=Handler.create(null,Laya3D._onProcessChange,[loader,processOffset,processCeil],false);
  17772. 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);
  17773. }else {
  17774. Laya3D._onHierarchyInnerSecondLevResouLoaded(loader,null,lhData,subUrls,firstLevUrls,processOffset,processCeil);
  17775. }
  17776. }
  17777. Laya3D._onHierarchyInnerSecondLevResouLoaded=function(loader,processHandler,lhData,subUrls,firstLevUrls,processOffset,processCeil){
  17778. (processHandler)&& (processHandler.recover());
  17779. if (firstLevUrls.length > 0){
  17780. var process=Handler.create(null,Laya3D._onProcessChange,[loader,processOffset,processCeil],false);
  17781. Laya3D._innerFirstLevelLoaderManager._create(firstLevUrls,false,Handler.create(null,Laya3D._onHierarchyInnerFirstLevResouLoaded,[loader,process,lhData,subUrls]),processHandler,null,null,null,1,true);
  17782. }else {
  17783. Laya3D._onHierarchyInnerFirstLevResouLoaded(loader,null,lhData,subUrls);
  17784. }
  17785. }
  17786. Laya3D._onHierarchyInnerFirstLevResouLoaded=function(loader,processHandler,lhData,subUrls){
  17787. (processHandler)&& (processHandler.recover());
  17788. loader._cache=loader._createCache;
  17789. var item=lhData.data.type==="Scene3D" ? Scene3D._parse(lhData,loader._propertyParams,loader._constructParams):Sprite3D._parse(lhData,loader._propertyParams,loader._constructParams);
  17790. Laya3D._endLoad(loader,item,subUrls);
  17791. }
  17792. Laya3D._loadMesh=function(loader){
  17793. loader.on(/*laya.events.Event.LOADED*/"loaded",null,Laya3D._onMeshLmLoaded,[loader]);
  17794. loader.load(loader.url,/*laya.net.Loader.BUFFER*/"arraybuffer",false,null,true);
  17795. }
  17796. Laya3D._onMeshLmLoaded=function(loader,lmData){
  17797. loader._cache=loader._createCache;
  17798. var mesh=Mesh._parse(lmData,loader._propertyParams,loader._constructParams);
  17799. Laya3D._endLoad(loader,mesh);
  17800. }
  17801. Laya3D._loadMaterial=function(loader){
  17802. loader.on(/*laya.events.Event.LOADED*/"loaded",null,Laya3D._onMaterilLmatLoaded,[loader]);
  17803. loader.load(loader.url,/*laya.net.Loader.JSON*/"json",false,null,true);
  17804. }
  17805. Laya3D._onMaterilLmatLoaded=function(loader,lmatData){
  17806. var url=loader.url;
  17807. var urlVersion=Utils3D.getURLVerion(url);
  17808. var materialBasePath=URL.getPath(url);
  17809. var urls=[];
  17810. var subUrls=[];
  17811. var customProps=lmatData.customProps;
  17812. var formatSubUrl;
  17813. var version=lmatData.version;
  17814. switch (version){
  17815. case "LAYAMATERIAL:01":
  17816. case "LAYAMATERIAL:02":;
  17817. var i=0,n=0;
  17818. var textures=lmatData.props.textures;
  17819. if (textures){
  17820. for (i=0,n=textures.length;i < n;i++){
  17821. var tex2D=textures[i];
  17822. var tex2DPath=tex2D.path;
  17823. if (tex2DPath){
  17824. formatSubUrl=Laya3D.formatRelativePath(materialBasePath,tex2DPath);
  17825. (urlVersion)&& (formatSubUrl=formatSubUrl+urlVersion);
  17826. urls.push({url:formatSubUrl,constructParams:tex2D.constructParams,propertyParams:tex2D.propertyParams});
  17827. subUrls.push(formatSubUrl);
  17828. tex2D.path=formatSubUrl;
  17829. }
  17830. }
  17831. }
  17832. break ;
  17833. default :
  17834. throw new Error("Laya3D:unkonwn version.");
  17835. };
  17836. var urlCount=urls.length;
  17837. var totalProcessCount=urlCount+1;
  17838. var lmatWeight=1 / totalProcessCount;
  17839. Laya3D._onProcessChange(loader,0,lmatWeight,1.0);
  17840. if (urlCount > 0){
  17841. var processHandler=Handler.create(null,Laya3D._onProcessChange,[loader,lmatWeight,urlCount / totalProcessCount],false);
  17842. Laya3D._innerFourthLevelLoaderManager._create(urls,false,Handler.create(null,Laya3D._onMateialTexturesLoaded,[loader,processHandler,lmatData,subUrls]),processHandler,null,null,null,1,true);
  17843. }else {
  17844. Laya3D._onMateialTexturesLoaded(loader,null,lmatData,null);
  17845. }
  17846. }
  17847. Laya3D._onMateialTexturesLoaded=function(loader,processHandler,lmatData,subUrls){
  17848. loader._cache=loader._createCache;
  17849. var mat=BaseMaterial._parse(lmatData,loader._propertyParams,loader._constructParams);
  17850. Laya3D._endLoad(loader,mat,subUrls);
  17851. (processHandler)&& (processHandler.recover());
  17852. }
  17853. Laya3D._loadAvatar=function(loader){
  17854. loader.on(/*laya.events.Event.LOADED*/"loaded",null,function(data){
  17855. loader._cache=loader._createCache;
  17856. var avatar=Avatar._parse(data,loader._propertyParams,loader._constructParams);
  17857. Laya3D._endLoad(loader,avatar);
  17858. });
  17859. loader.load(loader.url,/*laya.net.Loader.JSON*/"json",false,null,true);
  17860. }
  17861. Laya3D._loadAnimationClip=function(loader){
  17862. loader.on(/*laya.events.Event.LOADED*/"loaded",null,function(data){
  17863. loader._cache=loader._createCache;
  17864. var clip=AnimationClip._parse(data,loader._propertyParams,loader._constructParams);
  17865. Laya3D._endLoad(loader,clip);
  17866. });
  17867. loader.load(loader.url,/*laya.net.Loader.BUFFER*/"arraybuffer",false,null,true);
  17868. }
  17869. Laya3D._loadTexture2D=function(loader){
  17870. var url=loader.url;
  17871. var index=url.lastIndexOf('.')+1;
  17872. var verIndex=url.indexOf('?');
  17873. var endIndex=verIndex==-1 ? url.length :verIndex;
  17874. var ext=url.substr(index,endIndex-index);
  17875. var type;
  17876. switch (ext){
  17877. case "jpg":
  17878. case "jpeg":
  17879. case "bmp":
  17880. case "gif":
  17881. case "png":
  17882. type="nativeimage";
  17883. break ;
  17884. case "dds":
  17885. case "ktx":
  17886. case "pvr":
  17887. type=/*laya.net.Loader.BUFFER*/"arraybuffer";
  17888. break ;
  17889. }
  17890. loader.on(/*laya.events.Event.LOADED*/"loaded",null,function(image){
  17891. loader._cache=loader._createCache;
  17892. var tex=Texture2D._parse(image,loader._propertyParams,loader._constructParams);
  17893. Laya3D._endLoad(loader,tex);
  17894. });
  17895. loader.load(loader.url,type,false,null,true);
  17896. }
  17897. Laya3D._loadTextureCube=function(loader){
  17898. loader.on(/*laya.events.Event.LOADED*/"loaded",null,Laya3D._onTextureCubeLtcLoaded,[loader]);
  17899. loader.load(loader.url,/*laya.net.Loader.JSON*/"json",false,null,true);
  17900. }
  17901. Laya3D._onTextureCubeLtcLoaded=function(loader,ltcData){
  17902. var ltcBasePath=URL.getPath(loader.url);
  17903. 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)];
  17904. var ltcWeight=1.0 / 7.0;
  17905. Laya3D._onProcessChange(loader,0,ltcWeight,1.0);
  17906. var processHandler=Handler.create(null,Laya3D._onProcessChange,[loader,ltcWeight,6 / 7],false);
  17907. Laya3D._innerFourthLevelLoaderManager.load(urls,Handler.create(null,Laya3D._onTextureCubeImagesLoaded,[loader,urls,processHandler]),processHandler,"nativeimage");
  17908. }
  17909. Laya3D._onTextureCubeImagesLoaded=function(loader,urls,processHandler){
  17910. var images=new Array(6);
  17911. for (var i=0;i < 6;i++)
  17912. images[i]=Loader.getRes(urls[i]);
  17913. loader._cache=loader._createCache;
  17914. var tex=TextureCube._parse(images,loader._propertyParams,loader._constructParams);
  17915. processHandler.recover();
  17916. for (i=0;i < 6;i++)
  17917. Loader.clearRes(urls[i]);
  17918. Laya3D._endLoad(loader,tex);
  17919. }
  17920. Laya3D._onProcessChange=function(loader,offset,weight,process){
  17921. process=offset+process *weight;
  17922. (process < 1.0)&& (loader.event(/*laya.events.Event.PROGRESS*/"progress",process));
  17923. }
  17924. Laya3D.init=function(width,height,config,compolete){
  17925. if (Laya3D._isInit)
  17926. return;
  17927. Laya3D._isInit=true;
  17928. config=config || Config3D._default;
  17929. config.cloneTo(Laya3D._config);
  17930. Laya3D._editerEnvironment=Laya3D._config._editerEnvironment;
  17931. var physics3D=window.Physics3D;
  17932. if (physics3D==null){
  17933. Laya3D._enbalePhysics=false;
  17934. Laya3D.__init__(width,height,Laya3D._config);
  17935. compolete && compolete.run();
  17936. }else {
  17937. Laya3D._enbalePhysics=true;
  17938. physics3D(Laya3D._config.defaultPhysicsMemory *1024 *1024).then(function(){
  17939. Laya3D.__init__(width,height,Laya3D._config);
  17940. compolete && compolete.run();
  17941. });
  17942. }
  17943. }
  17944. Laya3D.HIERARCHY="HIERARCHY";
  17945. Laya3D.MESH="MESH";
  17946. Laya3D.MATERIAL="MATERIAL";
  17947. Laya3D.TEXTURE2D="TEXTURE2D";
  17948. Laya3D.TEXTURECUBE="TEXTURECUBE";
  17949. Laya3D.ANIMATIONCLIP="ANIMATIONCLIP";
  17950. Laya3D.AVATAR="AVATAR";
  17951. Laya3D.TERRAINHEIGHTDATA="TERRAINHEIGHTDATA";
  17952. Laya3D.TERRAINRES="TERRAIN";
  17953. Laya3D._isInit=false;
  17954. Laya3D._enbalePhysics=false;
  17955. Laya3D._editerEnvironment=false;
  17956. __static(Laya3D,
  17957. ['_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();}
  17958. ]);
  17959. return Laya3D;
  17960. })()
  17961. /**
  17962. *<code>AnimatorControllerLayer</code> 类用于创建动画控制器层。
  17963. */
  17964. //class laya.d3.component.AnimatorControllerLayer
  17965. var AnimatorControllerLayer=(function(){
  17966. function AnimatorControllerLayer(name){
  17967. /**@private */
  17968. this._defaultState=null;
  17969. /**@private 0:常规播放、1:动态融合播放、2:固定融合播放*/
  17970. //this._playType=0;
  17971. /**@private */
  17972. //this._crossDuration=NaN;
  17973. /**@private */
  17974. //this._crossPlayState=null;
  17975. /**@private */
  17976. //this._crossMark=0;
  17977. /**@private */
  17978. //this._crossNodesOwnersCount=0;
  17979. /**@private */
  17980. //this._crossNodesOwners=null;
  17981. /**@private */
  17982. //this._crossNodesOwnersIndicesMap=null;
  17983. /**@private */
  17984. //this._srcCrossClipNodeIndices=null;
  17985. /**@private */
  17986. //this._destCrossClipNodeIndices=null;
  17987. /**@private */
  17988. //this._currentPlayState=null;
  17989. /**@private */
  17990. this._statesMap={};
  17991. /**@private */
  17992. //this._states=null;
  17993. /**@private */
  17994. //this._playStateInfo=null;
  17995. /**@private */
  17996. //this._crossPlayStateInfo=null;
  17997. /**层的名称。*/
  17998. //this.name=null;
  17999. /**名称。*/
  18000. //this.blendingMode=0;
  18001. /**权重。*/
  18002. //this.defaultWeight=0;
  18003. /**激活时是否自动播放*/
  18004. this.playOnWake=true;
  18005. this._playType=-1;
  18006. this._crossMark=0;
  18007. this._crossDuration=-1;
  18008. this._crossNodesOwnersIndicesMap={};
  18009. this._crossNodesOwnersCount=0;
  18010. this._crossNodesOwners=[];
  18011. this._currentPlayState=null;
  18012. this._states=[];
  18013. this._playStateInfo=new AnimatorPlayState();
  18014. this._crossPlayStateInfo=new AnimatorPlayState();
  18015. this._srcCrossClipNodeIndices=[];
  18016. this._destCrossClipNodeIndices=[];
  18017. this.name=name;
  18018. this.defaultWeight=1.0;
  18019. this.blendingMode=laya.d3.component.AnimatorControllerLayer.BLENDINGMODE_OVERRIDE;
  18020. }
  18021. __class(AnimatorControllerLayer,'laya.d3.component.AnimatorControllerLayer');
  18022. var __proto=AnimatorControllerLayer.prototype;
  18023. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  18024. /**
  18025. *@private
  18026. */
  18027. __proto.getAnimatorState=function(name){
  18028. var state=this._statesMap[name];
  18029. return state ? state :null;
  18030. }
  18031. /**
  18032. *@private
  18033. */
  18034. __proto.destroy=function(){
  18035. this._statesMap=null;
  18036. this._states=null;
  18037. this._playStateInfo=null;
  18038. this._crossPlayStateInfo=null;
  18039. this._defaultState=null;
  18040. }
  18041. /**
  18042. *克隆。
  18043. *@param destObject 克隆源。
  18044. */
  18045. __proto.cloneTo=function(destObject){
  18046. var dest=destObject;
  18047. dest.name=this.name;
  18048. dest.blendingMode=this.blendingMode;
  18049. dest.defaultWeight=this.defaultWeight;
  18050. dest.playOnWake=this.playOnWake;
  18051. }
  18052. /**
  18053. *克隆。
  18054. *@return 克隆副本。
  18055. */
  18056. __proto.clone=function(){
  18057. var dest=/*__JS__ */new this.constructor();
  18058. this.cloneTo(dest);
  18059. return dest;
  18060. }
  18061. /**
  18062. *设置默认动画状态。
  18063. *@param value 默认动画状态。
  18064. */
  18065. /**
  18066. *获取默认动画状态。
  18067. *@return 默认动画状态。
  18068. */
  18069. __getset(0,__proto,'defaultState',function(){
  18070. return this._defaultState;
  18071. },function(value){
  18072. this._defaultState=value;
  18073. this._statesMap[value.name]=value;
  18074. });
  18075. AnimatorControllerLayer.BLENDINGMODE_OVERRIDE=0;
  18076. AnimatorControllerLayer.BLENDINGMODE_ADDTIVE=1;
  18077. return AnimatorControllerLayer;
  18078. })()
  18079. /**
  18080. *<code>AnimatorState</code> 类用于创建动作状态。
  18081. */
  18082. //class laya.d3.component.AnimatorState
  18083. var AnimatorState=(function(){
  18084. function AnimatorState(){
  18085. /**@private */
  18086. //this._clip=null;
  18087. /**@private */
  18088. //this._currentFrameIndices=null;
  18089. /**@private */
  18090. //this._scripts=null;
  18091. /**名称。*/
  18092. //this.name=null;
  18093. /**动画播放速度,1.0为正常播放速度。*/
  18094. this.speed=1.0;
  18095. /**动作播放起始时间。*/
  18096. this.clipStart=0.0;
  18097. /**动作播放结束时间。*/
  18098. this.clipEnd=1.0;
  18099. this._nodeOwners=[];
  18100. }
  18101. __class(AnimatorState,'laya.d3.component.AnimatorState');
  18102. var __proto=AnimatorState.prototype;
  18103. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  18104. /**
  18105. *@private
  18106. */
  18107. __proto._resetFrameIndices=function(){
  18108. for (var i=0,n=this._currentFrameIndices.length;i < n;i++)
  18109. this._currentFrameIndices[i]=-1;
  18110. }
  18111. /**
  18112. *添加脚本。
  18113. *@param type 组件类型。
  18114. *@return 脚本。
  18115. *
  18116. */
  18117. __proto.addScript=function(type){
  18118. var script=new type();
  18119. this._scripts=this._scripts || [];
  18120. this._scripts.push(script);
  18121. return script;
  18122. }
  18123. /**
  18124. *获取脚本。
  18125. *@param type 组件类型。
  18126. *@return 脚本。
  18127. *
  18128. */
  18129. __proto.getScript=function(type){
  18130. if (this._scripts){
  18131. for (var i=0,n=this._scripts.length;i < n;i++){
  18132. var script=this._scripts[i];
  18133. if (Laya.__typeof(script,type))
  18134. return script;
  18135. }
  18136. }
  18137. return null;
  18138. }
  18139. /**
  18140. *获取脚本集合。
  18141. *@param type 组件类型。
  18142. *@return 脚本集合。
  18143. *
  18144. */
  18145. __proto.getScripts=function(type){
  18146. var coms;
  18147. if (this._scripts){
  18148. for (var i=0,n=this._scripts.length;i < n;i++){
  18149. var script=this._scripts[i];
  18150. if (Laya.__typeof(script,type)){
  18151. coms=coms ||[];
  18152. coms.push(script);
  18153. }
  18154. }
  18155. }
  18156. return coms;
  18157. }
  18158. /**
  18159. *克隆。
  18160. *@param destObject 克隆源。
  18161. */
  18162. __proto.cloneTo=function(destObject){
  18163. var dest=destObject;
  18164. dest.name=this.name;
  18165. dest.speed=this.speed;
  18166. dest.clipStart=this.clipStart;
  18167. dest.clipEnd=this.clipEnd;
  18168. dest.clip=this._clip;
  18169. }
  18170. /**
  18171. *克隆。
  18172. *@return 克隆副本。
  18173. */
  18174. __proto.clone=function(){
  18175. var dest=/*__JS__ */new this.constructor();
  18176. this.cloneTo(dest);
  18177. return dest;
  18178. }
  18179. /**
  18180. *设置动作。
  18181. *@param value 动作。
  18182. */
  18183. /**
  18184. *获取动作。
  18185. *@return 动作
  18186. */
  18187. __getset(0,__proto,'clip',function(){
  18188. return this._clip;
  18189. },function(value){
  18190. this._clip=value;
  18191. this._currentFrameIndices=new Int16Array(value._nodes.count);
  18192. this._resetFrameIndices();
  18193. });
  18194. return AnimatorState;
  18195. })()
  18196. /**
  18197. *<code>GradientSize</code> 类用于创建渐变尺寸。
  18198. */
  18199. //class laya.d3.core.particleShuriKen.module.GradientSize
  18200. var GradientSize=(function(){
  18201. function GradientSize(){
  18202. /**@private */
  18203. this._type=0;
  18204. /**@private */
  18205. this._separateAxes=false;
  18206. /**@private */
  18207. this._gradient=null;
  18208. /**@private */
  18209. this._gradientX=null;
  18210. /**@private */
  18211. this._gradientY=null;
  18212. /**@private */
  18213. this._gradientZ=null;
  18214. /**@private */
  18215. this._constantMin=NaN;
  18216. /**@private */
  18217. this._constantMax=NaN;
  18218. /**@private */
  18219. this._constantMinSeparate=null;
  18220. /**@private */
  18221. this._constantMaxSeparate=null;
  18222. /**@private */
  18223. this._gradientMin=null;
  18224. /**@private */
  18225. this._gradientMax=null;
  18226. /**@private */
  18227. this._gradientXMin=null;
  18228. /**@private */
  18229. this._gradientXMax=null;
  18230. /**@private */
  18231. this._gradientYMin=null;
  18232. /**@private */
  18233. this._gradientYMax=null;
  18234. /**@private */
  18235. this._gradientZMin=null;
  18236. /**@private */
  18237. this._gradientZMax=null;
  18238. }
  18239. __class(GradientSize,'laya.d3.core.particleShuriKen.module.GradientSize');
  18240. var __proto=GradientSize.prototype;
  18241. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  18242. /**
  18243. *获取最大尺寸。
  18244. */
  18245. __proto.getMaxSizeInGradient=function(){
  18246. var i=0,n=0;
  18247. var maxSize=-Number.MAX_VALUE;
  18248. switch (this._type){
  18249. case 0:
  18250. if (this._separateAxes){
  18251. for (i=0,n=this._gradientX.gradientCount;i < n;i++)
  18252. maxSize=Math.max(maxSize,this._gradientX.getValueByIndex(i));
  18253. for (i=0,n=this._gradientY.gradientCount;i < n;i++)
  18254. maxSize=Math.max(maxSize,this._gradientY.getValueByIndex(i));
  18255. }else {
  18256. for (i=0,n=this._gradient.gradientCount;i < n;i++)
  18257. maxSize=Math.max(maxSize,this._gradient.getValueByIndex(i));
  18258. }
  18259. break ;
  18260. case 1:
  18261. if (this._separateAxes){
  18262. maxSize=Math.max(this._constantMinSeparate.x,this._constantMaxSeparate.x);
  18263. maxSize=Math.max(maxSize,this._constantMinSeparate.y);
  18264. maxSize=Math.max(maxSize,this._constantMaxSeparate.y);
  18265. }else {
  18266. maxSize=Math.max(this._constantMin,this._constantMax);
  18267. }
  18268. break ;
  18269. case 2:
  18270. if (this._separateAxes){
  18271. for (i=0,n=this._gradientXMin.gradientCount;i < n;i++)
  18272. maxSize=Math.max(maxSize,this._gradientXMin.getValueByIndex(i));
  18273. for (i=0,n=this._gradientXMax.gradientCount;i < n;i++)
  18274. maxSize=Math.max(maxSize,this._gradientXMax.getValueByIndex(i));
  18275. for (i=0,n=this._gradientYMin.gradientCount;i < n;i++)
  18276. maxSize=Math.max(maxSize,this._gradientYMin.getValueByIndex(i));
  18277. for (i=0,n=this._gradientZMax.gradientCount;i < n;i++)
  18278. maxSize=Math.max(maxSize,this._gradientZMax.getValueByIndex(i));
  18279. }else {
  18280. for (i=0,n=this._gradientMin.gradientCount;i < n;i++)
  18281. maxSize=Math.max(maxSize,this._gradientMin.getValueByIndex(i));
  18282. for (i=0,n=this._gradientMax.gradientCount;i < n;i++)
  18283. maxSize=Math.max(maxSize,this._gradientMax.getValueByIndex(i));
  18284. }
  18285. break ;
  18286. }
  18287. return maxSize;
  18288. }
  18289. /**
  18290. *克隆。
  18291. *@param destObject 克隆源。
  18292. */
  18293. __proto.cloneTo=function(destObject){
  18294. var destGradientSize=destObject;
  18295. destGradientSize._type=this._type;
  18296. destGradientSize._separateAxes=this._separateAxes;
  18297. this._gradient.cloneTo(destGradientSize._gradient);
  18298. this._gradientX.cloneTo(destGradientSize._gradientX);
  18299. this._gradientY.cloneTo(destGradientSize._gradientY);
  18300. this._gradientZ.cloneTo(destGradientSize._gradientZ);
  18301. destGradientSize._constantMin=this._constantMin;
  18302. destGradientSize._constantMax=this._constantMax;
  18303. this._constantMinSeparate.cloneTo(destGradientSize._constantMinSeparate);
  18304. this._constantMaxSeparate.cloneTo(destGradientSize._constantMaxSeparate);
  18305. this._gradientMin.cloneTo(destGradientSize._gradientMin);
  18306. this._gradientMax.cloneTo(destGradientSize._gradientMax);
  18307. this._gradientXMin.cloneTo(destGradientSize._gradientXMin);
  18308. this._gradientXMax.cloneTo(destGradientSize._gradientXMax);
  18309. this._gradientYMin.cloneTo(destGradientSize._gradientYMin);
  18310. this._gradientYMax.cloneTo(destGradientSize._gradientYMax);
  18311. this._gradientZMin.cloneTo(destGradientSize._gradientZMin);
  18312. this._gradientZMax.cloneTo(destGradientSize._gradientZMax);
  18313. }
  18314. /**
  18315. *克隆。
  18316. *@return 克隆副本。
  18317. */
  18318. __proto.clone=function(){
  18319. var destGradientSize=/*__JS__ */new this.constructor();
  18320. this.cloneTo(destGradientSize);
  18321. return destGradientSize;
  18322. }
  18323. /**
  18324. *渐变尺寸Z。
  18325. */
  18326. __getset(0,__proto,'gradientZ',function(){
  18327. return this._gradientZ;
  18328. });
  18329. /**
  18330. *渐变尺寸。
  18331. */
  18332. __getset(0,__proto,'gradient',function(){
  18333. return this._gradient;
  18334. });
  18335. /**
  18336. *是否分轴。
  18337. */
  18338. __getset(0,__proto,'separateAxes',function(){
  18339. return this._separateAxes;
  18340. });
  18341. /**
  18342. *生命周期尺寸类型,0曲线模式,1随机双常量模式,2随机双曲线模式。
  18343. */
  18344. __getset(0,__proto,'type',function(){
  18345. return this._type;
  18346. });
  18347. /**
  18348. *渐变最小尺寸。
  18349. */
  18350. __getset(0,__proto,'gradientMin',function(){
  18351. return this._gradientMin;
  18352. });
  18353. /**
  18354. *最小随机双固定尺寸。
  18355. */
  18356. __getset(0,__proto,'constantMin',function(){
  18357. return this._constantMin;
  18358. });
  18359. /**
  18360. *渐变尺寸X。
  18361. */
  18362. __getset(0,__proto,'gradientX',function(){
  18363. return this._gradientX;
  18364. });
  18365. /**
  18366. *渐变尺寸Y。
  18367. */
  18368. __getset(0,__proto,'gradientY',function(){
  18369. return this._gradientY;
  18370. });
  18371. /**
  18372. *渐变最大尺寸。
  18373. */
  18374. __getset(0,__proto,'gradientMax',function(){
  18375. return this._gradientMax;
  18376. });
  18377. /**
  18378. *最大随机双固定尺寸。
  18379. */
  18380. __getset(0,__proto,'constantMax',function(){
  18381. return this._constantMax;
  18382. });
  18383. /**
  18384. *最小分轴随机双固定尺寸。
  18385. */
  18386. __getset(0,__proto,'constantMinSeparate',function(){
  18387. return this._constantMinSeparate;
  18388. });
  18389. /**
  18390. *最小分轴随机双固定尺寸。
  18391. */
  18392. __getset(0,__proto,'constantMaxSeparate',function(){
  18393. return this._constantMaxSeparate;
  18394. });
  18395. /**
  18396. *渐变最小尺寸X。
  18397. */
  18398. __getset(0,__proto,'gradientXMin',function(){
  18399. return this._gradientXMin;
  18400. });
  18401. /**
  18402. *渐变最大尺寸X。
  18403. */
  18404. __getset(0,__proto,'gradientXMax',function(){
  18405. return this._gradientXMax;
  18406. });
  18407. /**
  18408. *渐变最小尺寸Y。
  18409. */
  18410. __getset(0,__proto,'gradientYMin',function(){
  18411. return this._gradientYMin;
  18412. });
  18413. /**
  18414. *渐变最大尺寸Y。
  18415. */
  18416. __getset(0,__proto,'gradientYMax',function(){
  18417. return this._gradientYMax;
  18418. });
  18419. /**
  18420. *渐变最小尺寸Z。
  18421. */
  18422. __getset(0,__proto,'gradientZMin',function(){
  18423. return this._gradientZMin;
  18424. });
  18425. /**
  18426. *渐变最大尺寸Z。
  18427. */
  18428. __getset(0,__proto,'gradientZMax',function(){
  18429. return this._gradientZMax;
  18430. });
  18431. GradientSize.createByGradient=function(gradient){
  18432. var gradientSize=new GradientSize();
  18433. gradientSize._type=0;
  18434. gradientSize._separateAxes=false;
  18435. gradientSize._gradient=gradient;
  18436. return gradientSize;
  18437. }
  18438. GradientSize.createByGradientSeparate=function(gradientX,gradientY,gradientZ){
  18439. var gradientSize=new GradientSize();
  18440. gradientSize._type=0;
  18441. gradientSize._separateAxes=true;
  18442. gradientSize._gradientX=gradientX;
  18443. gradientSize._gradientY=gradientY;
  18444. gradientSize._gradientZ=gradientZ;
  18445. return gradientSize;
  18446. }
  18447. GradientSize.createByRandomTwoConstant=function(constantMin,constantMax){
  18448. var gradientSize=new GradientSize();
  18449. gradientSize._type=1;
  18450. gradientSize._separateAxes=false;
  18451. gradientSize._constantMin=constantMin;
  18452. gradientSize._constantMax=constantMax;
  18453. return gradientSize;
  18454. }
  18455. GradientSize.createByRandomTwoConstantSeparate=function(constantMinSeparate,constantMaxSeparate){
  18456. var gradientSize=new GradientSize();
  18457. gradientSize._type=1;
  18458. gradientSize._separateAxes=true;
  18459. gradientSize._constantMinSeparate=constantMinSeparate;
  18460. gradientSize._constantMaxSeparate=constantMaxSeparate;
  18461. return gradientSize;
  18462. }
  18463. GradientSize.createByRandomTwoGradient=function(gradientMin,gradientMax){
  18464. var gradientSize=new GradientSize();
  18465. gradientSize._type=2;
  18466. gradientSize._separateAxes=false;
  18467. gradientSize._gradientMin=gradientMin;
  18468. gradientSize._gradientMax=gradientMax;
  18469. return gradientSize;
  18470. }
  18471. GradientSize.createByRandomTwoGradientSeparate=function(gradientXMin,gradientXMax,gradientYMin,gradientYMax,gradientZMin,gradientZMax){
  18472. var gradientSize=new GradientSize();
  18473. gradientSize._type=2;
  18474. gradientSize._separateAxes=true;
  18475. gradientSize._gradientXMin=gradientXMin;
  18476. gradientSize._gradientXMax=gradientXMax;
  18477. gradientSize._gradientYMin=gradientYMin;
  18478. gradientSize._gradientYMax=gradientYMax;
  18479. gradientSize._gradientZMin=gradientZMin;
  18480. gradientSize._gradientZMax=gradientZMax;
  18481. return gradientSize;
  18482. }
  18483. return GradientSize;
  18484. })()
  18485. /**
  18486. *<code>VertexPositionNormalTexture</code> 类用于创建位置、纹理顶点结构。
  18487. */
  18488. //class laya.d3.graphics.Vertex.VertexPositionTexture0
  18489. var VertexPositionTexture0=(function(){
  18490. function VertexPositionTexture0(position,textureCoordinate0){
  18491. this._position=null;
  18492. this._textureCoordinate0=null;
  18493. this._position=position;
  18494. this._textureCoordinate0=textureCoordinate0;
  18495. }
  18496. __class(VertexPositionTexture0,'laya.d3.graphics.Vertex.VertexPositionTexture0');
  18497. var __proto=VertexPositionTexture0.prototype;
  18498. Laya.imps(__proto,{"laya.d3.graphics.IVertex":true})
  18499. __getset(0,__proto,'position',function(){
  18500. return this._position;
  18501. });
  18502. __getset(0,__proto,'textureCoordinate0',function(){
  18503. return this._textureCoordinate0;
  18504. });
  18505. __getset(0,__proto,'vertexDeclaration',function(){
  18506. return VertexPositionTexture0._vertexDeclaration;
  18507. });
  18508. __getset(1,VertexPositionTexture0,'vertexDeclaration',function(){
  18509. return VertexPositionTexture0._vertexDeclaration;
  18510. });
  18511. __static(VertexPositionTexture0,
  18512. ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(20,[
  18513. new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0),
  18514. new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE0*/2)]);}
  18515. ]);
  18516. return VertexPositionTexture0;
  18517. })()
  18518. /**
  18519. *<code>PixelLineData</code> 类用于表示线数据。
  18520. */
  18521. //class laya.d3.core.pixelLine.PixelLineData
  18522. var PixelLineData=(function(){
  18523. function PixelLineData(){
  18524. this.startPosition=new Vector3();
  18525. this.endPosition=new Vector3();
  18526. this.startColor=new Color();
  18527. this.endColor=new Color();
  18528. }
  18529. __class(PixelLineData,'laya.d3.core.pixelLine.PixelLineData');
  18530. var __proto=PixelLineData.prototype;
  18531. /**
  18532. *克隆。
  18533. *@param destObject 克隆源。
  18534. */
  18535. __proto.cloneTo=function(destObject){
  18536. this.startPosition.cloneTo(destObject.startPosition);
  18537. this.endPosition.cloneTo(destObject.endPosition);
  18538. this.startColor.cloneTo(destObject.startColor);
  18539. this.endColor.cloneTo(destObject.endColor);
  18540. }
  18541. return PixelLineData;
  18542. })()
  18543. /**
  18544. *<code>GradientRotation</code> 类用于创建渐变角速度。
  18545. */
  18546. //class laya.d3.core.particleShuriKen.module.GradientAngularVelocity
  18547. var GradientAngularVelocity=(function(){
  18548. function GradientAngularVelocity(){
  18549. /**@private */
  18550. this._type=0;
  18551. /**@private */
  18552. this._separateAxes=false;
  18553. /**@private */
  18554. this._constant=NaN;
  18555. /**@private */
  18556. this._constantSeparate=null;
  18557. /**@private */
  18558. this._gradient=null;
  18559. /**@private */
  18560. this._gradientX=null;
  18561. /**@private */
  18562. this._gradientY=null;
  18563. /**@private */
  18564. this._gradientZ=null;
  18565. /**@private */
  18566. this._gradientW=null;
  18567. /**@private */
  18568. this._constantMin=NaN;
  18569. /**@private */
  18570. this._constantMax=NaN;
  18571. /**@private */
  18572. this._constantMinSeparate=null;
  18573. /**@private */
  18574. this._constantMaxSeparate=null;
  18575. /**@private */
  18576. this._gradientMin=null;
  18577. /**@private */
  18578. this._gradientMax=null;
  18579. /**@private */
  18580. this._gradientXMin=null;
  18581. /**@private */
  18582. this._gradientXMax=null;
  18583. /**@private */
  18584. this._gradientYMin=null;
  18585. /**@private */
  18586. this._gradientYMax=null;
  18587. /**@private */
  18588. this._gradientZMin=null;
  18589. /**@private */
  18590. this._gradientZMax=null;
  18591. /**@private */
  18592. this._gradientWMin=null;
  18593. /**@private */
  18594. this._gradientWMax=null;
  18595. }
  18596. __class(GradientAngularVelocity,'laya.d3.core.particleShuriKen.module.GradientAngularVelocity');
  18597. var __proto=GradientAngularVelocity.prototype;
  18598. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  18599. /**
  18600. *克隆。
  18601. *@param destObject 克隆源。
  18602. */
  18603. __proto.cloneTo=function(destObject){
  18604. var destGradientAngularVelocity=destObject;
  18605. destGradientAngularVelocity._type=this._type;
  18606. destGradientAngularVelocity._separateAxes=this._separateAxes;
  18607. destGradientAngularVelocity._constant=this._constant;
  18608. this._constantSeparate.cloneTo(destGradientAngularVelocity._constantSeparate);
  18609. this._gradient.cloneTo(destGradientAngularVelocity._gradient);
  18610. this._gradientX.cloneTo(destGradientAngularVelocity._gradientX);
  18611. this._gradientY.cloneTo(destGradientAngularVelocity._gradientY);
  18612. this._gradientZ.cloneTo(destGradientAngularVelocity._gradientZ);
  18613. destGradientAngularVelocity._constantMin=this._constantMin;
  18614. destGradientAngularVelocity._constantMax=this._constantMax;
  18615. this._constantMinSeparate.cloneTo(destGradientAngularVelocity._constantMinSeparate);
  18616. this._constantMaxSeparate.cloneTo(destGradientAngularVelocity._constantMaxSeparate);
  18617. this._gradientMin.cloneTo(destGradientAngularVelocity._gradientMin);
  18618. this._gradientMax.cloneTo(destGradientAngularVelocity._gradientMax);
  18619. this._gradientXMin.cloneTo(destGradientAngularVelocity._gradientXMin);
  18620. this._gradientXMax.cloneTo(destGradientAngularVelocity._gradientXMax);
  18621. this._gradientYMin.cloneTo(destGradientAngularVelocity._gradientYMin);
  18622. this._gradientYMax.cloneTo(destGradientAngularVelocity._gradientYMax);
  18623. this._gradientZMin.cloneTo(destGradientAngularVelocity._gradientZMin);
  18624. this._gradientZMax.cloneTo(destGradientAngularVelocity._gradientZMax);
  18625. }
  18626. /**
  18627. *克隆。
  18628. *@return 克隆副本。
  18629. */
  18630. __proto.clone=function(){
  18631. var destGradientAngularVelocity=/*__JS__ */new this.constructor();
  18632. this.cloneTo(destGradientAngularVelocity);
  18633. return destGradientAngularVelocity;
  18634. }
  18635. /**
  18636. *渐变角速度Z。
  18637. */
  18638. __getset(0,__proto,'gradientZ',function(){
  18639. return this._gradientZ;
  18640. });
  18641. /**
  18642. *固定角速度。
  18643. */
  18644. __getset(0,__proto,'constant',function(){
  18645. return this._constant;
  18646. });
  18647. /**
  18648. *渐变角速度。
  18649. */
  18650. __getset(0,__proto,'gradient',function(){
  18651. return this._gradient;
  18652. });
  18653. /**
  18654. *是否分轴。
  18655. */
  18656. __getset(0,__proto,'separateAxes',function(){
  18657. return this._separateAxes;
  18658. });
  18659. /**
  18660. *生命周期角速度类型,0常量模式,1曲线模式,2随机双常量模式,3随机双曲线模式。
  18661. */
  18662. __getset(0,__proto,'type',function(){
  18663. return this._type;
  18664. });
  18665. /**
  18666. *分轴固定角速度。
  18667. */
  18668. __getset(0,__proto,'constantSeparate',function(){
  18669. return this._constantSeparate;
  18670. });
  18671. /**
  18672. *渐变角角速度X。
  18673. */
  18674. __getset(0,__proto,'gradientX',function(){
  18675. return this._gradientX;
  18676. });
  18677. /**
  18678. *渐变角速度Y。
  18679. */
  18680. __getset(0,__proto,'gradientY',function(){
  18681. return this._gradientY;
  18682. });
  18683. /**
  18684. *渐变角速度Z。
  18685. */
  18686. __getset(0,__proto,'gradientW',function(){
  18687. return this._gradientW;
  18688. });
  18689. /**
  18690. *最小渐变角速度。
  18691. */
  18692. __getset(0,__proto,'gradientMin',function(){
  18693. return this._gradientMin;
  18694. });
  18695. /**
  18696. *最小随机双固定角速度。
  18697. */
  18698. __getset(0,__proto,'constantMin',function(){
  18699. return this._constantMin;
  18700. });
  18701. /**
  18702. *最大渐变角速度。
  18703. */
  18704. __getset(0,__proto,'gradientMax',function(){
  18705. return this._gradientMax;
  18706. });
  18707. /**
  18708. *最大随机双固定角速度。
  18709. */
  18710. __getset(0,__proto,'constantMax',function(){
  18711. return this._constantMax;
  18712. });
  18713. /**
  18714. *最小渐变角速度Z。
  18715. */
  18716. __getset(0,__proto,'gradientWMin',function(){
  18717. return this._gradientWMin;
  18718. });
  18719. /**
  18720. *最小分轴随机双固定角速度。
  18721. */
  18722. __getset(0,__proto,'constantMinSeparate',function(){
  18723. return this._constantMinSeparate;
  18724. });
  18725. /**
  18726. *最大分轴随机双固定角速度。
  18727. */
  18728. __getset(0,__proto,'constantMaxSeparate',function(){
  18729. return this._constantMaxSeparate;
  18730. });
  18731. /**
  18732. *最小渐变角速度X。
  18733. */
  18734. __getset(0,__proto,'gradientXMin',function(){
  18735. return this._gradientXMin;
  18736. });
  18737. /**
  18738. *最大渐变角速度X。
  18739. */
  18740. __getset(0,__proto,'gradientXMax',function(){
  18741. return this._gradientXMax;
  18742. });
  18743. /**
  18744. *最大渐变角速度Z。
  18745. */
  18746. __getset(0,__proto,'gradientWMax',function(){
  18747. return this._gradientWMax;
  18748. });
  18749. /**
  18750. *最小渐变角速度Y。
  18751. */
  18752. __getset(0,__proto,'gradientYMin',function(){
  18753. return this._gradientYMin;
  18754. });
  18755. /**
  18756. *最大渐变角速度Y。
  18757. */
  18758. __getset(0,__proto,'gradientYMax',function(){
  18759. return this._gradientYMax;
  18760. });
  18761. /**
  18762. *最小渐变角速度Z。
  18763. */
  18764. __getset(0,__proto,'gradientZMin',function(){
  18765. return this._gradientZMin;
  18766. });
  18767. /**
  18768. *最大渐变角速度Z。
  18769. */
  18770. __getset(0,__proto,'gradientZMax',function(){
  18771. return this._gradientZMax;
  18772. });
  18773. GradientAngularVelocity.createByConstant=function(constant){
  18774. var gradientAngularVelocity=new GradientAngularVelocity();
  18775. gradientAngularVelocity._type=0;
  18776. gradientAngularVelocity._separateAxes=false;
  18777. gradientAngularVelocity._constant=constant;
  18778. return gradientAngularVelocity;
  18779. }
  18780. GradientAngularVelocity.createByConstantSeparate=function(separateConstant){
  18781. var gradientAngularVelocity=new GradientAngularVelocity();
  18782. gradientAngularVelocity._type=0;
  18783. gradientAngularVelocity._separateAxes=true;
  18784. gradientAngularVelocity._constantSeparate=separateConstant;
  18785. return gradientAngularVelocity;
  18786. }
  18787. GradientAngularVelocity.createByGradient=function(gradient){
  18788. var gradientAngularVelocity=new GradientAngularVelocity();
  18789. gradientAngularVelocity._type=1;
  18790. gradientAngularVelocity._separateAxes=false;
  18791. gradientAngularVelocity._gradient=gradient;
  18792. return gradientAngularVelocity;
  18793. }
  18794. GradientAngularVelocity.createByGradientSeparate=function(gradientX,gradientY,gradientZ){
  18795. var gradientAngularVelocity=new GradientAngularVelocity();
  18796. gradientAngularVelocity._type=1;
  18797. gradientAngularVelocity._separateAxes=true;
  18798. gradientAngularVelocity._gradientX=gradientX;
  18799. gradientAngularVelocity._gradientY=gradientY;
  18800. gradientAngularVelocity._gradientZ=gradientZ;
  18801. return gradientAngularVelocity;
  18802. }
  18803. GradientAngularVelocity.createByRandomTwoConstant=function(constantMin,constantMax){
  18804. var gradientAngularVelocity=new GradientAngularVelocity();
  18805. gradientAngularVelocity._type=2;
  18806. gradientAngularVelocity._separateAxes=false;
  18807. gradientAngularVelocity._constantMin=constantMin;
  18808. gradientAngularVelocity._constantMax=constantMax;
  18809. return gradientAngularVelocity;
  18810. }
  18811. GradientAngularVelocity.createByRandomTwoConstantSeparate=function(separateConstantMin,separateConstantMax){
  18812. var gradientAngularVelocity=new GradientAngularVelocity();
  18813. gradientAngularVelocity._type=2;
  18814. gradientAngularVelocity._separateAxes=true;
  18815. gradientAngularVelocity._constantMinSeparate=separateConstantMin;
  18816. gradientAngularVelocity._constantMaxSeparate=separateConstantMax;
  18817. return gradientAngularVelocity;
  18818. }
  18819. GradientAngularVelocity.createByRandomTwoGradient=function(gradientMin,gradientMax){
  18820. var gradientAngularVelocity=new GradientAngularVelocity();
  18821. gradientAngularVelocity._type=3;
  18822. gradientAngularVelocity._separateAxes=false;
  18823. gradientAngularVelocity._gradientMin=gradientMin;
  18824. gradientAngularVelocity._gradientMax=gradientMax;
  18825. return gradientAngularVelocity;
  18826. }
  18827. GradientAngularVelocity.createByRandomTwoGradientSeparate=function(gradientXMin,gradientXMax,gradientYMin,gradientYMax,gradientZMin,gradientZMax,gradientWMin,gradientWMax){
  18828. var gradientAngularVelocity=new GradientAngularVelocity();
  18829. gradientAngularVelocity._type=3;
  18830. gradientAngularVelocity._separateAxes=true;
  18831. gradientAngularVelocity._gradientXMin=gradientXMin;
  18832. gradientAngularVelocity._gradientXMax=gradientXMax;
  18833. gradientAngularVelocity._gradientYMin=gradientYMin;
  18834. gradientAngularVelocity._gradientYMax=gradientYMax;
  18835. gradientAngularVelocity._gradientZMin=gradientZMin;
  18836. gradientAngularVelocity._gradientZMax=gradientZMax;
  18837. gradientAngularVelocity._gradientWMin=gradientWMin;
  18838. gradientAngularVelocity._gradientWMax=gradientWMax;
  18839. return gradientAngularVelocity;
  18840. }
  18841. return GradientAngularVelocity;
  18842. })()
  18843. /**
  18844. *<code>Rand</code> 类用于通过32位无符号整型随机种子创建随机数。
  18845. */
  18846. //class laya.d3.math.Rand
  18847. var Rand=(function(){
  18848. function Rand(seed){
  18849. this._temp=new Uint32Array(1);
  18850. this.seeds=new Uint32Array(4);
  18851. this.seeds[0]=seed;
  18852. this.seeds[1]=this.seeds[0] *0x6C078965+1;
  18853. this.seeds[2]=this.seeds[1] *0x6C078965+1;
  18854. this.seeds[3]=this.seeds[2] *0x6C078965+1;
  18855. }
  18856. __class(Rand,'laya.d3.math.Rand');
  18857. var __proto=Rand.prototype;
  18858. /**
  18859. *获取无符号32位整形随机数。
  18860. *@return 无符号32位整形随机数。
  18861. */
  18862. __proto.getUint=function(){
  18863. this._temp[0]=this.seeds[0] ^ (this.seeds[0] << 11);
  18864. this.seeds[0]=this.seeds[1];
  18865. this.seeds[1]=this.seeds[2];
  18866. this.seeds[2]=this.seeds[3];
  18867. this.seeds[3]=(this.seeds[3] ^ (this.seeds[3] >>> 19))^ (this._temp[0] ^ (this._temp[0] >>> 8));
  18868. return this.seeds[3];
  18869. }
  18870. /**
  18871. *获取0到1之间的浮点随机数。
  18872. *@return 0到1之间的浮点随机数。
  18873. */
  18874. __proto.getFloat=function(){
  18875. this.getUint();
  18876. return (this.seeds[3] & 0x007FFFFF)*(1.0 / 8388607.0);
  18877. }
  18878. /**
  18879. *获取-1到1之间的浮点随机数。
  18880. *@return-1到1之间的浮点随机数。
  18881. */
  18882. __proto.getSignedFloat=function(){
  18883. return this.getFloat()*2.0-1.0;
  18884. }
  18885. /**
  18886. *设置随机种子。
  18887. *@param seed 随机种子。
  18888. */
  18889. /**
  18890. *获取随机种子。
  18891. *@return 随机种子。
  18892. */
  18893. __getset(0,__proto,'seed',function(){
  18894. return this.seeds[0];
  18895. },function(seed){
  18896. this.seeds[0]=seed;
  18897. this.seeds[1]=this.seeds[0] *0x6C078965+1;
  18898. this.seeds[2]=this.seeds[1] *0x6C078965+1;
  18899. this.seeds[3]=this.seeds[2] *0x6C078965+1;
  18900. });
  18901. Rand.getFloatFromInt=function(v){
  18902. return (v & 0x007FFFFF)*(1.0 / 8388607.0)
  18903. }
  18904. Rand.getByteFromInt=function(v){
  18905. return (v & 0x007FFFFF)>>> 15;
  18906. }
  18907. return Rand;
  18908. })()
  18909. /**
  18910. *<code>Physics</code> 类用于简单物理检测。
  18911. */
  18912. //class laya.d3.utils.Physics3DUtils
  18913. var Physics3DUtils=(function(){
  18914. /**
  18915. *创建一个 <code>Physics</code> 实例。
  18916. */
  18917. function Physics3DUtils(){}
  18918. __class(Physics3DUtils,'laya.d3.utils.Physics3DUtils');
  18919. Physics3DUtils.setColliderCollision=function(collider1,collider2,collsion){}
  18920. Physics3DUtils.getIColliderCollision=function(collider1,collider2){
  18921. return false;
  18922. }
  18923. Physics3DUtils.COLLISIONFILTERGROUP_DEFAULTFILTER=0x1;
  18924. Physics3DUtils.COLLISIONFILTERGROUP_STATICFILTER=0x2;
  18925. Physics3DUtils.COLLISIONFILTERGROUP_KINEMATICFILTER=0x4;
  18926. Physics3DUtils.COLLISIONFILTERGROUP_DEBRISFILTER=0x8;
  18927. Physics3DUtils.COLLISIONFILTERGROUP_SENSORTRIGGER=0x10;
  18928. Physics3DUtils.COLLISIONFILTERGROUP_CHARACTERFILTER=0x20;
  18929. Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER1=0x40;
  18930. Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER2=0x80;
  18931. Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER3=0x100;
  18932. Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER4=0x200;
  18933. Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER5=0x400;
  18934. Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER6=0x800;
  18935. Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER7=0x1000;
  18936. Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER8=0x2000;
  18937. Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER9=0x4000;
  18938. Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER10=0x8000;
  18939. Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER=-1;
  18940. __static(Physics3DUtils,
  18941. ['gravity',function(){return this.gravity=new Vector3(0,-9.81,0);}
  18942. ]);
  18943. return Physics3DUtils;
  18944. })()
  18945. /**
  18946. *<code>AnimationTransform3D</code> 类用于实现3D变换。
  18947. */
  18948. //class laya.d3.animation.AnimationTransform3D extends laya.events.EventDispatcher
  18949. var AnimationTransform3D=(function(_super){
  18950. function AnimationTransform3D(owner,localPosition,localRotation,localScale,worldMatrix){
  18951. /**@private */
  18952. //this._localMatrix=null;
  18953. /**@private */
  18954. //this._worldMatrix=null;
  18955. /**@private */
  18956. //this._localPosition=null;
  18957. /**@private */
  18958. //this._localRotation=null;
  18959. /**@private */
  18960. //this._localScale=null;
  18961. /**@private */
  18962. //this._localQuaternionUpdate=false;
  18963. /**@private */
  18964. //this._locaEulerlUpdate=false;
  18965. /**@private */
  18966. //this._localUpdate=false;
  18967. /**@private */
  18968. //this._parent=null;
  18969. /**@private */
  18970. //this._children=null;
  18971. /**@private */
  18972. //this._localRotationEuler=null;
  18973. /**@private */
  18974. //this._owner=null;
  18975. /**@private */
  18976. //this._worldUpdate=false;
  18977. AnimationTransform3D.__super.call(this);
  18978. this._owner=owner;
  18979. this._children=[];
  18980. this._localMatrix=new Float32Array(16);
  18981. if (Render.supportWebGLPlusAnimation){
  18982. /*__JS__ */this._localPosition=new ConchVector3(0,0,0,localPosition);
  18983. /*__JS__ */this._localRotation=new ConchQuaternion(0,0,0,1,localRotation);
  18984. /*__JS__ */this._localScale=new ConchVector3(0,0,0,localScale);
  18985. this._worldMatrix=worldMatrix;
  18986. }else {
  18987. this._localPosition=new Vector3();
  18988. this._localRotation=new Quaternion();
  18989. this._localScale=new Vector3();
  18990. this._worldMatrix=new Float32Array(16);
  18991. }
  18992. this._localQuaternionUpdate=false;
  18993. this._locaEulerlUpdate=false;
  18994. this._localUpdate=false;
  18995. this._worldUpdate=true;
  18996. }
  18997. __class(AnimationTransform3D,'laya.d3.animation.AnimationTransform3D',_super);
  18998. var __proto=AnimationTransform3D.prototype;
  18999. /**
  19000. *@private
  19001. */
  19002. __proto._getlocalMatrix=function(){
  19003. if (this._localUpdate){
  19004. Utils3D._createAffineTransformationArray(this._localPosition,this._localRotation,this._localScale,this._localMatrix);
  19005. this._localUpdate=false;
  19006. }
  19007. return this._localMatrix;
  19008. }
  19009. /**
  19010. *@private
  19011. */
  19012. __proto._onWorldTransform=function(){
  19013. if (!this._worldUpdate){
  19014. this._worldUpdate=true;
  19015. this.event(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged");
  19016. for (var i=0,n=this._children.length;i < n;i++)
  19017. this._children[i]._onWorldTransform();
  19018. }
  19019. }
  19020. /**
  19021. *获取世界矩阵。
  19022. *@return 世界矩阵。
  19023. */
  19024. __proto.getWorldMatrix=function(){
  19025. if (!Render.supportWebGLPlusAnimation && this._worldUpdate){
  19026. if (this._parent !=null){
  19027. Utils3D.matrix4x4MultiplyFFF(this._parent.getWorldMatrix(),this._getlocalMatrix(),this._worldMatrix);
  19028. }else {
  19029. var e=this._worldMatrix;
  19030. 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;
  19031. e[0]=e[5]=e[10]=e[15]=1;
  19032. }
  19033. this._worldUpdate=false;
  19034. }
  19035. if (Render.supportWebGLPlusAnimation && this._worldUpdate){
  19036. this._worldUpdate=false;
  19037. }
  19038. return this._worldMatrix;
  19039. }
  19040. /**
  19041. *设置父3D变换。
  19042. *@param value 父3D变换。
  19043. */
  19044. __proto.setParent=function(value){
  19045. if (this._parent!==value){
  19046. if (this._parent){
  19047. var parentChilds=this._parent._children;
  19048. var index=parentChilds.indexOf(this);
  19049. parentChilds.splice(index,1);
  19050. }
  19051. if (value){
  19052. value._children.push(this);
  19053. (value)&& (this._onWorldTransform());
  19054. }
  19055. this._parent=value;
  19056. }
  19057. }
  19058. /**
  19059. *@private
  19060. */
  19061. /**
  19062. *@private
  19063. */
  19064. __getset(0,__proto,'localPosition',function(){
  19065. return this._localPosition;
  19066. },function(value){
  19067. this._localPosition=value;
  19068. this._localUpdate=true;
  19069. this._onWorldTransform();
  19070. });
  19071. /*
  19072. *@private
  19073. */
  19074. /**
  19075. *@private
  19076. */
  19077. __getset(0,__proto,'localRotation',function(){
  19078. if (this._localQuaternionUpdate){
  19079. var euler=this._localRotationEuler;
  19080. Quaternion.createFromYawPitchRoll(euler.y / AnimationTransform3D._angleToRandin,euler.x / AnimationTransform3D._angleToRandin,euler.z / AnimationTransform3D._angleToRandin,this._localRotation);
  19081. this._localQuaternionUpdate=false;
  19082. }
  19083. return this._localRotation;
  19084. },function(value){
  19085. this._localRotation=value;
  19086. this._locaEulerlUpdate=true;
  19087. this._localQuaternionUpdate=false;
  19088. this._localUpdate=true;
  19089. this._onWorldTransform();
  19090. });
  19091. /**
  19092. *@private
  19093. */
  19094. /**
  19095. *@private
  19096. */
  19097. __getset(0,__proto,'localScale',function(){
  19098. return this._localScale;
  19099. },function(value){
  19100. this._localScale=value;
  19101. this._localUpdate=true;
  19102. this._onWorldTransform();
  19103. });
  19104. /**
  19105. *@private
  19106. */
  19107. /**
  19108. *@private
  19109. */
  19110. __getset(0,__proto,'localRotationEuler',function(){
  19111. if (this._locaEulerlUpdate){
  19112. this._localRotation.getYawPitchRoll(AnimationTransform3D._tempVector3);
  19113. var euler=AnimationTransform3D._tempVector3;
  19114. var localRotationEuler=this._localRotationEuler;
  19115. localRotationEuler.x=euler.y *AnimationTransform3D._angleToRandin;
  19116. localRotationEuler.y=euler.x *AnimationTransform3D._angleToRandin;
  19117. localRotationEuler.z=euler.z *AnimationTransform3D._angleToRandin;
  19118. this._locaEulerlUpdate=false;
  19119. }
  19120. return this._localRotationEuler;
  19121. },function(value){
  19122. this._localRotationEuler=value;
  19123. this._locaEulerlUpdate=false;
  19124. this._localQuaternionUpdate=true;
  19125. this._localUpdate=true;
  19126. this._onWorldTransform();
  19127. });
  19128. __static(AnimationTransform3D,
  19129. ['_tempVector3',function(){return this._tempVector3=new Vector3();},'_angleToRandin',function(){return this._angleToRandin=180 / Math.PI;}
  19130. ]);
  19131. return AnimationTransform3D;
  19132. })(EventDispatcher)
  19133. /**
  19134. *<code>Render</code> 类用于渲染器的父类,抽象类不允许实例。
  19135. */
  19136. //class laya.d3.core.render.BaseRender extends laya.events.EventDispatcher
  19137. var BaseRender=(function(_super){
  19138. function BaseRender(owner){
  19139. /**@private */
  19140. //this._id=0;
  19141. /**@private */
  19142. //this._lightmapScaleOffset=null;
  19143. /**@private */
  19144. //this._lightmapIndex=0;
  19145. /**@private */
  19146. //this._receiveShadow=false;
  19147. /**@private */
  19148. //this._materialsInstance=null;
  19149. /**@private */
  19150. //this._castShadow=false;
  19151. /**@private [实现IListPool接口]*/
  19152. this._indexInList=-1;
  19153. /**@private */
  19154. this._indexInCastShadowList=-1;
  19155. /**@private */
  19156. //this._bounds=null;
  19157. /**@private */
  19158. this._boundsChange=true;
  19159. /**@private */
  19160. //this._enable=false;
  19161. /**@private */
  19162. //this._shaderValues=null;
  19163. /**@private */
  19164. //this._defineDatas=null;
  19165. /**@private */
  19166. //this._scene=null;
  19167. /**@private */
  19168. //this._owner=null;
  19169. /**@private */
  19170. //this._renderElements=null;
  19171. /**@private */
  19172. //this._distanceForSort=NaN;
  19173. /**@private */
  19174. this._visible=true;
  19175. /**@private */
  19176. //this._octreeNode=null;
  19177. /**@private */
  19178. this._indexInOctreeMotionList=-1;
  19179. /**@private */
  19180. this._updateMark=-1;
  19181. /**@private */
  19182. this._updateRenderType=-1;
  19183. /**@private */
  19184. this._isPartOfStaticBatch=false;
  19185. /**@private */
  19186. this._staticBatch=null;
  19187. /**排序矫正值。*/
  19188. //this.sortingFudge=NaN;
  19189. /**@private [NATIVE]*/
  19190. //this._cullingBufferIndex=0;
  19191. BaseRender.__super.call(this);
  19192. this._sharedMaterials=[];
  19193. this._id=++BaseRender._uniqueIDCounter;
  19194. this._indexInCastShadowList=-1;
  19195. this._bounds=new Bounds(Vector3._ZERO,Vector3._ZERO);
  19196. if (Render.supportWebGLPlusCulling){
  19197. var length=FrustumCulling._cullingBufferLength;
  19198. this._cullingBufferIndex=length;
  19199. var cullingBuffer=FrustumCulling._cullingBuffer;
  19200. var resizeLength=length+7;
  19201. if (resizeLength >=cullingBuffer.length){
  19202. var temp=cullingBuffer;
  19203. cullingBuffer=FrustumCulling._cullingBuffer=new Float32Array(cullingBuffer.length+4096);
  19204. cullingBuffer.set(temp,0);
  19205. }
  19206. cullingBuffer[length]=2;
  19207. FrustumCulling._cullingBufferLength=resizeLength;
  19208. }
  19209. this._renderElements=[];
  19210. this._owner=owner;
  19211. this._enable=true;
  19212. this._materialsInstance=[];
  19213. this._shaderValues=new ShaderData(null);
  19214. this._defineDatas=new DefineDatas();
  19215. this.lightmapIndex=-1;
  19216. this._castShadow=false;
  19217. this.receiveShadow=false;
  19218. this.sortingFudge=0.0;
  19219. (owner)&& (this._owner.transform.on(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this,this._onWorldMatNeedChange));
  19220. }
  19221. __class(BaseRender,'laya.d3.core.render.BaseRender',_super);
  19222. var __proto=BaseRender.prototype;
  19223. Laya.imps(__proto,{"laya.resource.ISingletonElement":true,"laya.d3.core.scene.IOctreeObject":true})
  19224. /**
  19225. *@private
  19226. */
  19227. __proto._getOctreeNode=function(){
  19228. return this._octreeNode;
  19229. }
  19230. /**
  19231. *@private
  19232. */
  19233. __proto._setOctreeNode=function(value){
  19234. this._octreeNode=value;
  19235. }
  19236. /**
  19237. *@private
  19238. */
  19239. __proto._getIndexInMotionList=function(){
  19240. return this._indexInOctreeMotionList;
  19241. }
  19242. /**
  19243. *@private
  19244. */
  19245. __proto._setIndexInMotionList=function(value){
  19246. this._indexInOctreeMotionList=value;
  19247. }
  19248. /**
  19249. *@private
  19250. */
  19251. __proto._changeMaterialReference=function(lastValue,value){
  19252. (lastValue)&& (lastValue._removeReference());
  19253. value._addReference();
  19254. }
  19255. /**
  19256. *@private
  19257. */
  19258. __proto._getInstanceMaterial=function(material,index){
  19259. var insMat=/*__JS__ */new material.constructor();
  19260. material.cloneTo(insMat);
  19261. insMat.name=insMat.name+"(Instance)";
  19262. this._materialsInstance[index]=true;
  19263. this._changeMaterialReference(this._sharedMaterials[index],insMat);
  19264. this._sharedMaterials[index]=insMat;
  19265. return insMat;
  19266. }
  19267. /**
  19268. *@private
  19269. */
  19270. __proto._applyLightMapParams=function(){
  19271. if (this._scene && this._lightmapIndex >=0){
  19272. var lightMaps=this._scene.getlightmaps();
  19273. if (this._lightmapIndex < lightMaps.length){
  19274. this._defineDatas.add(RenderableSprite3D.SAHDERDEFINE_LIGHTMAP);
  19275. this._shaderValues.setTexture(RenderableSprite3D.LIGHTMAP,lightMaps[this._lightmapIndex]);
  19276. }else {
  19277. this._defineDatas.remove(RenderableSprite3D.SAHDERDEFINE_LIGHTMAP);
  19278. }
  19279. }else {
  19280. this._defineDatas.remove(RenderableSprite3D.SAHDERDEFINE_LIGHTMAP);
  19281. }
  19282. }
  19283. /**
  19284. *@private
  19285. */
  19286. __proto._onWorldMatNeedChange=function(flag){
  19287. this._boundsChange=true;
  19288. if (this._octreeNode){
  19289. flag &=/*laya.d3.core.Transform3D.TRANSFORM_WORLDPOSITION*/0x08 | /*laya.d3.core.Transform3D.TRANSFORM_WORLDQUATERNION*/0x10 | /*laya.d3.core.Transform3D.TRANSFORM_WORLDSCALE*/0x20;
  19290. if (flag){
  19291. if (this._indexInOctreeMotionList===-1)
  19292. this._octreeNode._octree.addMotionObject(this);
  19293. }
  19294. }
  19295. }
  19296. /**
  19297. *@private
  19298. */
  19299. __proto._calculateBoundingBox=function(){
  19300. throw("BaseRender: must override it.");
  19301. }
  19302. /**
  19303. *@private [实现ISingletonElement接口]
  19304. */
  19305. __proto._getIndexInList=function(){
  19306. return this._indexInList;
  19307. }
  19308. /**
  19309. *@private [实现ISingletonElement接口]
  19310. */
  19311. __proto._setIndexInList=function(index){
  19312. this._indexInList=index;
  19313. }
  19314. /**
  19315. *@private
  19316. */
  19317. __proto._setBelongScene=function(scene){
  19318. if (this._scene!==scene){
  19319. this._scene=scene;
  19320. this._applyLightMapParams();
  19321. }
  19322. }
  19323. /**
  19324. *@private
  19325. *@param boundFrustum 如果boundFrustum为空则为摄像机不裁剪模式。
  19326. */
  19327. __proto._needRender=function(boundFrustum){
  19328. return true;
  19329. }
  19330. /**
  19331. *@private
  19332. */
  19333. __proto._renderUpdate=function(context,transform){}
  19334. /**
  19335. *@private
  19336. */
  19337. __proto._renderUpdateWithCamera=function(context,transform){}
  19338. /**
  19339. *@private
  19340. */
  19341. __proto._revertBatchRenderUpdate=function(context){}
  19342. /**
  19343. *@private
  19344. */
  19345. __proto._destroy=function(){
  19346. (this._indexInOctreeMotionList!==-1)&& (this._octreeNode._octree.removeMotionObject(this));
  19347. this.offAll();
  19348. var i=0,n=0;
  19349. for (i=0,n=this._renderElements.length;i < n;i++)
  19350. this._renderElements[i].destroy();
  19351. for (i=0,n=this._sharedMaterials.length;i < n;i++)
  19352. (this._sharedMaterials[i].destroyed)|| (this._sharedMaterials[i]._removeReference());
  19353. this._renderElements=null;
  19354. this._owner=null;
  19355. this._sharedMaterials=null;
  19356. this._bounds=null;
  19357. this._lightmapScaleOffset=null;
  19358. }
  19359. /**
  19360. *获取包围盒,只读,不允许修改其值。
  19361. *@return 包围盒。
  19362. */
  19363. __getset(0,__proto,'bounds',function(){
  19364. if (this._boundsChange){
  19365. this._calculateBoundingBox();
  19366. this._boundsChange=false;
  19367. }
  19368. return this._bounds;
  19369. });
  19370. /**
  19371. *获取唯一标识ID,通常用于识别。
  19372. */
  19373. __getset(0,__proto,'id',function(){
  19374. return this._id;
  19375. });
  19376. /**
  19377. *设置第一个实例材质。
  19378. *@param value 第一个实例材质。
  19379. */
  19380. /**
  19381. *返回第一个实例材质,第一次使用会拷贝实例对象。
  19382. *@return 第一个实例材质。
  19383. */
  19384. __getset(0,__proto,'material',function(){
  19385. var material=this._sharedMaterials[0];
  19386. if (material && !this._materialsInstance[0]){
  19387. var insMat=this._getInstanceMaterial(material,0);
  19388. var renderElement=this._renderElements[0];
  19389. (renderElement)&& (renderElement.material=insMat);
  19390. }
  19391. return this._sharedMaterials[0];
  19392. },function(value){
  19393. this.sharedMaterial=value;
  19394. });
  19395. /**
  19396. *是否是静态的一部分。
  19397. */
  19398. __getset(0,__proto,'isPartOfStaticBatch',function(){
  19399. return this._isPartOfStaticBatch;
  19400. });
  19401. /**
  19402. *设置第一个材质。
  19403. *@param value 第一个材质。
  19404. */
  19405. /**
  19406. *返回第一个材质。
  19407. *@return 第一个材质。
  19408. */
  19409. __getset(0,__proto,'sharedMaterial',function(){
  19410. return this._sharedMaterials[0];
  19411. },function(value){
  19412. var lastValue=this._sharedMaterials[0];
  19413. if (lastValue!==value){
  19414. this._sharedMaterials[0]=value;
  19415. this._materialsInstance[0]=false;
  19416. this._changeMaterialReference(lastValue,value);
  19417. var renderElement=this._renderElements[0];
  19418. (renderElement)&& (renderElement.material=value);
  19419. }
  19420. });
  19421. /**
  19422. *设置光照贴图的索引。
  19423. *@param value 光照贴图的索引。
  19424. */
  19425. /**
  19426. *获取光照贴图的索引。
  19427. *@return 光照贴图的索引。
  19428. */
  19429. __getset(0,__proto,'lightmapIndex',function(){
  19430. return this._lightmapIndex;
  19431. },function(value){
  19432. if (this._lightmapIndex!==value){
  19433. this._lightmapIndex=value;
  19434. this._applyLightMapParams();
  19435. }
  19436. });
  19437. /**
  19438. *设置光照贴图的缩放和偏移。
  19439. *@param 光照贴图的缩放和偏移。
  19440. */
  19441. /**
  19442. *获取光照贴图的缩放和偏移。
  19443. *@return 光照贴图的缩放和偏移。
  19444. */
  19445. __getset(0,__proto,'lightmapScaleOffset',function(){
  19446. return this._lightmapScaleOffset;
  19447. },function(value){
  19448. this._lightmapScaleOffset=value;
  19449. this._shaderValues.setVector(RenderableSprite3D.LIGHTMAPSCALEOFFSET,value);
  19450. this._defineDatas.add(RenderableSprite3D.SHADERDEFINE_SCALEOFFSETLIGHTINGMAPUV);
  19451. });
  19452. /**
  19453. *设置是否产生阴影。
  19454. *@param value 是否产生阴影。
  19455. */
  19456. /**
  19457. *获取是否产生阴影。
  19458. *@return 是否产生阴影。
  19459. */
  19460. __getset(0,__proto,'castShadow',function(){
  19461. return this._castShadow;
  19462. },function(value){
  19463. if (this._castShadow!==value){
  19464. if (this._owner.activeInHierarchy){
  19465. if (value)
  19466. this._scene._addShadowCastRenderObject(this);
  19467. else
  19468. this._scene._removeShadowCastRenderObject(this);
  19469. }
  19470. this._castShadow=value;
  19471. }
  19472. });
  19473. /**
  19474. *设置是否可用。
  19475. *@param value 是否可用。
  19476. */
  19477. /**
  19478. *获取是否可用。
  19479. *@return 是否可用。
  19480. */
  19481. __getset(0,__proto,'enable',function(){
  19482. return this._enable;
  19483. },function(value){
  19484. this._enable=!!value;
  19485. });
  19486. /**
  19487. *设置实例材质列表。
  19488. *@param value 实例材质列表。
  19489. */
  19490. /**
  19491. *获取潜拷贝实例材质列表,第一次使用会拷贝实例对象。
  19492. *@return 浅拷贝实例材质列表。
  19493. */
  19494. __getset(0,__proto,'materials',function(){
  19495. for (var i=0,n=this._sharedMaterials.length;i < n;i++){
  19496. if (!this._materialsInstance[i]){
  19497. var insMat=this._getInstanceMaterial(this._sharedMaterials[i],i);
  19498. var renderElement=this._renderElements[i];
  19499. (renderElement)&& (renderElement.material=insMat);
  19500. }
  19501. }
  19502. return this._sharedMaterials.slice();
  19503. },function(value){
  19504. this.sharedMaterials=value;
  19505. });
  19506. /**
  19507. *设置材质列表。
  19508. *@param value 材质列表。
  19509. */
  19510. /**
  19511. *获取浅拷贝材质列表。
  19512. *@return 浅拷贝材质列表。
  19513. */
  19514. __getset(0,__proto,'sharedMaterials',function(){
  19515. return this._sharedMaterials.slice();
  19516. },function(value){
  19517. var mats=this._sharedMaterials;
  19518. for (var i=0,n=mats.length;i < n;i++)
  19519. mats[i]._removeReference();
  19520. if (value){
  19521. var count=value.length;
  19522. this._materialsInstance.length=count;
  19523. mats.length=count;
  19524. for (i=0;i < count;i++){
  19525. var lastMat=mats[i];
  19526. var mat=value[i];
  19527. if (lastMat!==mat){
  19528. this._materialsInstance[i]=false;
  19529. var renderElement=this._renderElements[i];
  19530. (renderElement)&& (renderElement.material=mat);
  19531. }
  19532. mat._addReference();
  19533. mats[i]=mat;
  19534. }
  19535. }else {
  19536. throw new Error("BaseRender: shadredMaterials value can't be null.");
  19537. }
  19538. });
  19539. /**
  19540. *设置是否接收阴影属性
  19541. */
  19542. /**
  19543. *获得是否接收阴影属性
  19544. */
  19545. __getset(0,__proto,'receiveShadow',function(){
  19546. return this._receiveShadow;
  19547. },function(value){
  19548. if (this._receiveShadow!==value){
  19549. this._receiveShadow=value;
  19550. if (value)
  19551. this._defineDatas.add(RenderableSprite3D.SHADERDEFINE_RECEIVE_SHADOW);
  19552. else
  19553. this._defineDatas.remove(RenderableSprite3D.SHADERDEFINE_RECEIVE_SHADOW);
  19554. }
  19555. });
  19556. BaseRender._uniqueIDCounter=0;
  19557. __static(BaseRender,
  19558. ['_tempBoundBoxCorners',function(){return this._tempBoundBoxCorners=/*new vector.<>*/[new Vector3(),new Vector3(),new Vector3(),new Vector3(),new Vector3(),new Vector3(),new Vector3(),new Vector3()];}
  19559. ]);
  19560. return BaseRender;
  19561. })(EventDispatcher)
  19562. /**
  19563. *<code>Animator</code> 类用于创建动画组件。
  19564. */
  19565. //class laya.d3.component.Animator extends laya.components.Component
  19566. var Animator=(function(_super){
  19567. function Animator(){
  19568. /**@private */
  19569. //this._speed=NaN;
  19570. /**@private */
  19571. //this._keyframeNodeOwnerMap=null;
  19572. /**@private */
  19573. //this._updateMark=0;
  19574. /**@private */
  19575. //this._controllerLayers=null;
  19576. /**@private */
  19577. //this._linkSprites=null;
  19578. /**@private */
  19579. //this._avatarNodeMap=null;
  19580. /**@private */
  19581. this._linkAvatarSpritesData={};
  19582. /**@private [NATIVE]*/
  19583. //this._animationNodeLocalPositions=null;
  19584. /**@private [NATIVE]*/
  19585. //this._animationNodeLocalRotations=null;
  19586. /**@private [NATIVE]*/
  19587. //this._animationNodeLocalScales=null;
  19588. /**@private [NATIVE]*/
  19589. //this._animationNodeWorldMatrixs=null;
  19590. /**@private [NATIVE]*/
  19591. //this._animationNodeParentIndices=null;
  19592. /**@private */
  19593. //this._avatar=null;
  19594. this._keyframeNodeOwners=[];
  19595. this._linkAvatarSprites=[];
  19596. this._renderableSprites=[];
  19597. this.cullingMode=2;
  19598. Animator.__super.call(this);
  19599. this._controllerLayers=[];
  19600. this._linkSprites={};
  19601. this._speed=1.0;
  19602. this._keyframeNodeOwnerMap={};
  19603. this._updateMark=0;
  19604. }
  19605. __class(Animator,'laya.d3.component.Animator',_super);
  19606. var __proto=Animator.prototype;
  19607. /**
  19608. *@private
  19609. */
  19610. __proto._linkToSprites=function(linkSprites){
  19611. for (var k in linkSprites){
  19612. var nodeOwner=this.owner;
  19613. var path=linkSprites[k];
  19614. for (var j=0,m=path.length;j < m;j++){
  19615. var p=path[j];
  19616. if (p===""){
  19617. break ;
  19618. }else {
  19619. nodeOwner=nodeOwner.getChildByName(p);
  19620. if (!nodeOwner)
  19621. break ;
  19622. }
  19623. }
  19624. (nodeOwner)&& (this.linkSprite3DToAvatarNode(k,nodeOwner));
  19625. }
  19626. }
  19627. /**
  19628. *@private
  19629. */
  19630. __proto._addKeyframeNodeOwner=function(clipOwners,node,propertyOwner){
  19631. var nodeIndex=node._indexInList;
  19632. var fullPath=node.fullPath;
  19633. var keyframeNodeOwner=this._keyframeNodeOwnerMap[fullPath];
  19634. if (keyframeNodeOwner){
  19635. keyframeNodeOwner.referenceCount++;
  19636. clipOwners[nodeIndex]=keyframeNodeOwner;
  19637. }else {
  19638. var property=propertyOwner;
  19639. for (var i=0,n=node.propertyCount;i < n;i++){
  19640. property=property[node.getPropertyByIndex(i)];
  19641. if (!property)
  19642. break ;
  19643. }
  19644. keyframeNodeOwner=this._keyframeNodeOwnerMap[fullPath]=new KeyframeNodeOwner();
  19645. keyframeNodeOwner.fullPath=fullPath;
  19646. keyframeNodeOwner.indexInList=this._keyframeNodeOwners.length;
  19647. keyframeNodeOwner.referenceCount=1;
  19648. keyframeNodeOwner.propertyOwner=propertyOwner;
  19649. var propertyCount=node.propertyCount;
  19650. var propertys=__newvec(propertyCount);
  19651. for (i=0;i < propertyCount;i++)
  19652. propertys[i]=node.getPropertyByIndex(i);
  19653. keyframeNodeOwner.property=propertys;
  19654. keyframeNodeOwner.type=node.type;
  19655. if (property){
  19656. if (node.type===0){
  19657. keyframeNodeOwner.defaultValue=property;
  19658. }else {
  19659. var defaultValue=new property.constructor();
  19660. property.cloneTo(defaultValue);
  19661. keyframeNodeOwner.defaultValue=defaultValue;
  19662. }
  19663. }
  19664. this._keyframeNodeOwners.push(keyframeNodeOwner);
  19665. clipOwners[nodeIndex]=keyframeNodeOwner;
  19666. }
  19667. }
  19668. /**
  19669. *@private
  19670. */
  19671. __proto._removeKeyframeNodeOwner=function(nodeOwners,node){
  19672. var fullPath=node.fullPath;
  19673. var keyframeNodeOwner=this._keyframeNodeOwnerMap[fullPath];
  19674. if (keyframeNodeOwner){
  19675. keyframeNodeOwner.referenceCount--;
  19676. if (keyframeNodeOwner.referenceCount===0){
  19677. delete this._keyframeNodeOwnerMap[fullPath];
  19678. this._keyframeNodeOwners.splice(this._keyframeNodeOwners.indexOf(keyframeNodeOwner),1);
  19679. }
  19680. nodeOwners[node._indexInList]=null;
  19681. }
  19682. }
  19683. /**
  19684. *@private
  19685. */
  19686. __proto._getOwnersByClip=function(clipStateInfo){
  19687. var frameNodes=clipStateInfo._clip._nodes;
  19688. var frameNodesCount=frameNodes.count;
  19689. var nodeOwners=clipStateInfo._nodeOwners;
  19690. nodeOwners.length=frameNodesCount;
  19691. for (var i=0;i < frameNodesCount;i++){
  19692. var node=frameNodes.getNodeByIndex(i);
  19693. var property=this._avatar ? this._avatarNodeMap[this._avatar._rootNode.name] :this.owner;
  19694. for (var j=0,m=node.ownerPathCount;j < m;j++){
  19695. var ownPat=node.getOwnerPathByIndex(j);
  19696. if (ownPat===""){
  19697. break ;
  19698. }else {
  19699. property=property.getChildByName(ownPat);
  19700. if (!property)
  19701. break ;
  19702. }
  19703. }
  19704. if (property){
  19705. var propertyOwner=node.propertyOwner;
  19706. (propertyOwner)&& (property=property[propertyOwner]);
  19707. property && this._addKeyframeNodeOwner(nodeOwners,node,property);
  19708. }
  19709. }
  19710. }
  19711. /**
  19712. *@private
  19713. */
  19714. __proto._updatePlayer=function(animatorState,playState,elapsedTime,islooping){
  19715. var clipDuration=animatorState._clip._duration *(animatorState.clipEnd-animatorState.clipStart);
  19716. var lastElapsedTime=playState._elapsedTime;
  19717. var elapsedPlaybackTime=lastElapsedTime+elapsedTime;
  19718. playState._lastElapsedTime=lastElapsedTime;
  19719. playState._elapsedTime=elapsedPlaybackTime;
  19720. var normalizedTime=elapsedPlaybackTime / clipDuration;
  19721. playState._normalizedTime=normalizedTime;
  19722. var playTime=normalizedTime % 1.0;
  19723. playState._normalizedPlayTime=playTime < 0 ? playTime+1.0 :playTime;
  19724. playState._duration=clipDuration;
  19725. var scripts=animatorState._scripts;
  19726. if ((!islooping && elapsedPlaybackTime >=clipDuration)){
  19727. playState._finish=true;
  19728. playState._elapsedTime=clipDuration;
  19729. playState._normalizedPlayTime=1.0;
  19730. if (scripts){
  19731. for (var i=0,n=scripts.length;i < n;i++)
  19732. scripts[i].onStateExit();
  19733. }
  19734. return;
  19735. }
  19736. if (scripts){
  19737. for (i=0,n=scripts.length;i < n;i++)
  19738. scripts[i].onStateUpdate();
  19739. }
  19740. }
  19741. /**
  19742. *@private
  19743. */
  19744. __proto._eventScript=function(scripts,events,eventIndex,endTime,front){
  19745. if (front){
  19746. for (var n=events.length;eventIndex < n;eventIndex++){
  19747. var event=events[eventIndex];
  19748. if (event.time <=endTime){
  19749. for (var j=0,m=scripts.length;j < m;j++){
  19750. var script=scripts[j];
  19751. var fun=script[event.eventName];
  19752. (fun)&& (fun.apply(script,event.params));
  19753. }
  19754. }else {
  19755. break ;
  19756. }
  19757. }
  19758. }else {
  19759. for (;eventIndex >=0;eventIndex--){
  19760. event=events[eventIndex];
  19761. if (event.time >=endTime){
  19762. for (j=0,m=scripts.length;j < m;j++){
  19763. script=scripts[j];
  19764. fun=script[event.eventName];
  19765. (fun)&& (fun.apply(script,event.params));
  19766. }
  19767. }else {
  19768. break ;
  19769. }
  19770. }
  19771. }
  19772. return eventIndex;
  19773. }
  19774. /**
  19775. *@private
  19776. */
  19777. __proto._updateEventScript=function(stateInfo,playStateInfo){
  19778. var scripts=(this.owner)._scripts;
  19779. if (scripts){
  19780. var clip=stateInfo._clip;
  19781. var events=clip._events;
  19782. var clipDuration=clip._duration;
  19783. var elapsedTime=playStateInfo._elapsedTime;
  19784. var time=elapsedTime % clipDuration;
  19785. var loopCount=Math.abs(Math.floor(elapsedTime / clipDuration)-Math.floor(playStateInfo._lastElapsedTime / clipDuration));
  19786. var frontPlay=playStateInfo._elapsedTime >=playStateInfo._lastElapsedTime;
  19787. if (playStateInfo._lastIsFront!==frontPlay){
  19788. if (frontPlay)
  19789. playStateInfo._playEventIndex++;
  19790. else
  19791. playStateInfo._playEventIndex--;
  19792. playStateInfo._lastIsFront=frontPlay;
  19793. }
  19794. if (loopCount==0){
  19795. playStateInfo._playEventIndex=this._eventScript(scripts,events,playStateInfo._playEventIndex,time,frontPlay);
  19796. }else {
  19797. if (frontPlay){
  19798. this._eventScript(scripts,events,playStateInfo._playEventIndex,clipDuration,true);
  19799. for (var i=0,n=loopCount-1;i < n;i++)
  19800. this._eventScript(scripts,events,0,clipDuration,true);
  19801. playStateInfo._playEventIndex=this._eventScript(scripts,events,0,time,true);
  19802. }else {
  19803. this._eventScript(scripts,events,playStateInfo._playEventIndex,0,false);
  19804. var eventIndex=events.length-1;
  19805. for (i=0,n=loopCount-1;i < n;i++)
  19806. this._eventScript(scripts,events,eventIndex,0,false);
  19807. playStateInfo._playEventIndex=this._eventScript(scripts,events,eventIndex,time,false);
  19808. }
  19809. }
  19810. }
  19811. }
  19812. /**
  19813. *@private
  19814. */
  19815. __proto._updateClipDatas=function(animatorState,addtive,playStateInfo,scale){
  19816. var clip=animatorState._clip;
  19817. var clipDuration=clip._duration;
  19818. var curPlayTime=animatorState.clipStart *clipDuration+playStateInfo._normalizedPlayTime *playStateInfo._duration;
  19819. var currentFrameIndices=animatorState._currentFrameIndices;
  19820. var frontPlay=playStateInfo._elapsedTime > playStateInfo._lastElapsedTime;
  19821. clip._evaluateClipDatasRealTime(clip._nodes,curPlayTime,currentFrameIndices,addtive,frontPlay);
  19822. }
  19823. /**
  19824. *@private
  19825. */
  19826. __proto._applyFloat=function(pro,proName,nodeOwner,additive,weight,isFirstLayer,data){
  19827. if (nodeOwner.updateMark===this._updateMark){
  19828. if (additive){
  19829. pro[proName]+=weight *(data);
  19830. }else {
  19831. var oriValue=pro[proName];
  19832. pro[proName]=oriValue+weight *(data-oriValue);
  19833. }
  19834. }else {
  19835. if (isFirstLayer){
  19836. if (additive)
  19837. pro[proName]=nodeOwner.defaultValue+data;
  19838. else
  19839. pro[proName]=data;
  19840. }else {
  19841. if (additive){
  19842. pro[proName]=nodeOwner.defaultValue+weight *(data);
  19843. }else {
  19844. var defValue=nodeOwner.defaultValue;
  19845. pro[proName]=defValue+weight *(data-defValue);
  19846. }
  19847. }
  19848. }
  19849. }
  19850. /**
  19851. *@private
  19852. */
  19853. __proto._applyPositionAndRotationEuler=function(nodeOwner,additive,weight,isFirstLayer,data,out){
  19854. if (nodeOwner.updateMark===this._updateMark){
  19855. if (additive){
  19856. out.x+=weight *data.x;
  19857. out.y+=weight *data.y;
  19858. out.z+=weight *data.z;
  19859. }else {
  19860. var oriX=out.x;
  19861. var oriY=out.y;
  19862. var oriZ=out.z;
  19863. out.x=oriX+weight *(data.x-oriX);
  19864. out.y=oriY+weight *(data.y-oriY);
  19865. out.z=oriZ+weight *(data.z-oriZ);
  19866. }
  19867. }else {
  19868. if (isFirstLayer){
  19869. if (additive){
  19870. var defValue=nodeOwner.defaultValue;
  19871. out.x=defValue.x+data.x;
  19872. out.y=defValue.y+data.y;
  19873. out.z=defValue.z+data.z;
  19874. }else {
  19875. out.x=data.x;
  19876. out.y=data.y;
  19877. out.z=data.z;
  19878. }
  19879. }else {
  19880. defValue=nodeOwner.defaultValue;
  19881. if (additive){
  19882. out.x=defValue.x+weight *data.x;
  19883. out.y=defValue.y+weight *data.y;
  19884. out.z=defValue.z+weight *data.z;
  19885. }else {
  19886. var defX=defValue.x;
  19887. var defY=defValue.y;
  19888. var defZ=defValue.z;
  19889. out.x=defX+weight *(data.x-defX);
  19890. out.y=defY+weight *(data.y-defY);
  19891. out.z=defZ+weight *(data.z-defZ);
  19892. }
  19893. }
  19894. }
  19895. }
  19896. /**
  19897. *@private
  19898. */
  19899. __proto._applyRotation=function(nodeOwner,additive,weight,isFirstLayer,clipRot,localRotation){
  19900. if (nodeOwner.updateMark===this._updateMark){
  19901. if (additive){
  19902. var tempQuat=Animator._tempQuaternion1;
  19903. Utils3D.quaternionWeight(clipRot,weight,tempQuat);
  19904. tempQuat.normalize(tempQuat);
  19905. Quaternion.multiply(localRotation,tempQuat,localRotation);
  19906. }else {
  19907. Quaternion.lerp(localRotation,clipRot,weight,localRotation);
  19908. }
  19909. }else {
  19910. if (isFirstLayer){
  19911. if (additive){
  19912. var defaultRot=nodeOwner.defaultValue;
  19913. Quaternion.multiply(defaultRot,clipRot,localRotation);
  19914. }else {
  19915. localRotation.x=clipRot.x;
  19916. localRotation.y=clipRot.y;
  19917. localRotation.z=clipRot.z;
  19918. localRotation.w=clipRot.w;
  19919. }
  19920. }else {
  19921. defaultRot=nodeOwner.defaultValue;
  19922. if (additive){
  19923. tempQuat=Animator._tempQuaternion1;
  19924. Utils3D.quaternionWeight(clipRot,weight,tempQuat);
  19925. tempQuat.normalize(tempQuat);
  19926. Quaternion.multiply(defaultRot,tempQuat,localRotation);
  19927. }else {
  19928. Quaternion.lerp(defaultRot,clipRot,weight,localRotation);
  19929. }
  19930. }
  19931. }
  19932. }
  19933. /**
  19934. *@private
  19935. */
  19936. __proto._applyScale=function(nodeOwner,additive,weight,isFirstLayer,clipSca,localScale){
  19937. if (nodeOwner.updateMark===this._updateMark){
  19938. if (additive){
  19939. var scale=Animator._tempVector31;
  19940. Utils3D.scaleWeight(clipSca,weight,scale);
  19941. localScale.x=localScale.x *scale.x;
  19942. localScale.y=localScale.y *scale.y;
  19943. localScale.z=localScale.z *scale.z;
  19944. }else {
  19945. Utils3D.scaleBlend(localScale,clipSca,weight,localScale);
  19946. }
  19947. }else {
  19948. if (isFirstLayer){
  19949. if (additive){
  19950. var defaultSca=nodeOwner.defaultValue;
  19951. localScale.x=defaultSca.x *clipSca.x;
  19952. localScale.y=defaultSca.y *clipSca.y;
  19953. localScale.z=defaultSca.z *clipSca.z;
  19954. }else {
  19955. localScale.x=clipSca.x;
  19956. localScale.y=clipSca.y;
  19957. localScale.z=clipSca.z;
  19958. }
  19959. }else {
  19960. defaultSca=nodeOwner.defaultValue;
  19961. if (additive){
  19962. scale=Animator._tempVector31;
  19963. Utils3D.scaleWeight(clipSca,weight,scale);
  19964. localScale.x=defaultSca.x *scale.x;
  19965. localScale.y=defaultSca.y *scale.y;
  19966. localScale.z=defaultSca.z *scale.z;
  19967. }else {
  19968. Utils3D.scaleBlend(defaultSca,clipSca,weight,localScale);
  19969. }
  19970. }
  19971. }
  19972. }
  19973. /**
  19974. *@private
  19975. */
  19976. __proto._applyCrossData=function(nodeOwner,additive,weight,isFirstLayer,srcValue,desValue,crossWeight){
  19977. var pro=nodeOwner.propertyOwner;
  19978. if (pro){
  19979. switch (nodeOwner.type){
  19980. case 0:;
  19981. var proPat=nodeOwner.property;
  19982. var m=proPat.length-1;
  19983. for (var j=0;j < m;j++){
  19984. pro=pro[proPat[j]];
  19985. if (!pro)
  19986. break ;
  19987. };
  19988. var crossValue=srcValue+crossWeight *(desValue-srcValue);
  19989. this._applyFloat(pro,proPat[m],nodeOwner,additive,weight,isFirstLayer,crossValue);
  19990. break ;
  19991. case 1:;
  19992. var localPos=pro.localPosition;
  19993. var position=Animator._tempVector30;
  19994. var srcX=srcValue.x,srcY=srcValue.y,srcZ=srcValue.z;
  19995. position.x=srcX+crossWeight *(desValue.x-srcX);
  19996. position.y=srcY+crossWeight *(desValue.y-srcY);
  19997. position.z=srcZ+crossWeight *(desValue.z-srcZ);
  19998. this._applyPositionAndRotationEuler(nodeOwner,additive,weight,isFirstLayer,position,localPos);
  19999. pro.localPosition=localPos;
  20000. break ;
  20001. case 2:;
  20002. var localRot=pro.localRotation;
  20003. var rotation=Animator._tempQuaternion0;
  20004. Quaternion.lerp(srcValue,desValue,crossWeight,rotation);
  20005. this._applyRotation(nodeOwner,additive,weight,isFirstLayer,rotation,localRot);
  20006. pro.localRotation=localRot;
  20007. break ;
  20008. case 3:;
  20009. var localSca=pro.localScale;
  20010. var scale=Animator._tempVector30;
  20011. Utils3D.scaleBlend(srcValue,desValue,crossWeight,scale);
  20012. this._applyScale(nodeOwner,additive,weight,isFirstLayer,scale,localSca);
  20013. pro.localScale=localSca;
  20014. break ;
  20015. case 4:;
  20016. var localEuler=pro.localRotationEuler;
  20017. var rotationEuler=Animator._tempVector30;
  20018. srcX=srcValue.x,srcY=srcValue.y,srcZ=srcValue.z;
  20019. rotationEuler.x=srcX+crossWeight *(desValue.x-srcX);
  20020. rotationEuler.y=srcY+crossWeight *(desValue.y-srcY);
  20021. rotationEuler.z=srcZ+crossWeight *(desValue.z-srcZ);
  20022. this._applyPositionAndRotationEuler(nodeOwner,additive,weight,isFirstLayer,rotationEuler,localEuler);
  20023. pro.localRotationEuler=localEuler;
  20024. break ;
  20025. }
  20026. nodeOwner.updateMark=this._updateMark;
  20027. }
  20028. }
  20029. /**
  20030. *@private
  20031. */
  20032. __proto._setClipDatasToNode=function(stateInfo,additive,weight,isFirstLayer){
  20033. var nodes=stateInfo._clip._nodes;
  20034. var nodeOwners=stateInfo._nodeOwners;
  20035. for (var i=0,n=nodes.count;i < n;i++){
  20036. var nodeOwner=nodeOwners[i];
  20037. if (nodeOwner){
  20038. var pro=nodeOwner.propertyOwner;
  20039. if (pro){
  20040. switch (nodeOwner.type){
  20041. case 0:;
  20042. var proPat=nodeOwner.property;
  20043. var m=proPat.length-1;
  20044. for (var j=0;j < m;j++){
  20045. pro=pro[proPat[j]];
  20046. if (!pro)
  20047. break ;
  20048. }
  20049. this._applyFloat(pro,proPat[m],nodeOwner,additive,weight,isFirstLayer,nodes.getNodeByIndex(i).data);
  20050. break ;
  20051. case 1:;
  20052. var localPos=pro.localPosition;
  20053. this._applyPositionAndRotationEuler(nodeOwner,additive,weight,isFirstLayer,nodes.getNodeByIndex(i).data,localPos);
  20054. pro.localPosition=localPos;
  20055. break ;
  20056. case 2:;
  20057. var localRot=pro.localRotation;
  20058. this._applyRotation(nodeOwner,additive,weight,isFirstLayer,nodes.getNodeByIndex(i).data,localRot);
  20059. pro.localRotation=localRot;
  20060. break ;
  20061. case 3:;
  20062. var localSca=pro.localScale;
  20063. this._applyScale(nodeOwner,additive,weight,isFirstLayer,nodes.getNodeByIndex(i).data,localSca);
  20064. pro.localScale=localSca;
  20065. break ;
  20066. case 4:;
  20067. var localEuler=pro.localRotationEuler;
  20068. this._applyPositionAndRotationEuler(nodeOwner,additive,weight,isFirstLayer,nodes.getNodeByIndex(i).data,localEuler);
  20069. pro.localRotationEuler=localEuler;
  20070. break ;
  20071. }
  20072. nodeOwner.updateMark=this._updateMark;
  20073. }
  20074. }
  20075. }
  20076. }
  20077. /**
  20078. *@private
  20079. */
  20080. __proto._setCrossClipDatasToNode=function(controllerLayer,srcState,destState,crossWeight,isFirstLayer){
  20081. var nodeOwners=controllerLayer._crossNodesOwners;
  20082. var ownerCount=controllerLayer._crossNodesOwnersCount;
  20083. var additive=controllerLayer.blendingMode!==AnimatorControllerLayer.BLENDINGMODE_OVERRIDE;
  20084. var weight=controllerLayer.defaultWeight;
  20085. var destDataIndices=controllerLayer._destCrossClipNodeIndices;
  20086. var destNodes=destState._clip._nodes;
  20087. var destNodeOwners=destState._nodeOwners;
  20088. var srcDataIndices=controllerLayer._srcCrossClipNodeIndices;
  20089. var srcNodeOwners=srcState._nodeOwners;
  20090. var srcNodes=srcState._clip._nodes;
  20091. for (var i=0;i < ownerCount;i++){
  20092. var nodeOwner=nodeOwners[i];
  20093. if (nodeOwner){
  20094. var srcIndex=srcDataIndices[i];
  20095. var destIndex=destDataIndices[i];
  20096. var srcValue=srcIndex!==-1 ? srcNodes.getNodeByIndex(srcIndex).data :destNodeOwners[destIndex].defaultValue;
  20097. var desValue=destIndex!==-1 ? destNodes.getNodeByIndex(destIndex).data :srcNodeOwners[srcIndex].defaultValue;
  20098. this._applyCrossData(nodeOwner,additive,weight,isFirstLayer,srcValue,desValue,crossWeight);
  20099. }
  20100. }
  20101. }
  20102. /**
  20103. *@private
  20104. */
  20105. __proto._setFixedCrossClipDatasToNode=function(controllerLayer,destState,crossWeight,isFirstLayer){
  20106. var nodeOwners=controllerLayer._crossNodesOwners;
  20107. var ownerCount=controllerLayer._crossNodesOwnersCount;
  20108. var additive=controllerLayer.blendingMode!==AnimatorControllerLayer.BLENDINGMODE_OVERRIDE;
  20109. var weight=controllerLayer.defaultWeight;
  20110. var destDataIndices=controllerLayer._destCrossClipNodeIndices;
  20111. var destNodes=destState._clip._nodes;
  20112. for (var i=0;i < ownerCount;i++){
  20113. var nodeOwner=nodeOwners[i];
  20114. if (nodeOwner){
  20115. var destIndex=destDataIndices[i];
  20116. var srcValue=nodeOwner.crossFixedValue;
  20117. var desValue=destIndex!==-1 ? destNodes.getNodeByIndex(destIndex).data :nodeOwner.defaultValue;
  20118. this._applyCrossData(nodeOwner,additive,weight,isFirstLayer,srcValue,desValue,crossWeight);
  20119. }
  20120. }
  20121. }
  20122. /**
  20123. *@private
  20124. */
  20125. __proto._revertDefaultKeyframeNodes=function(clipStateInfo){
  20126. var nodeOwners=clipStateInfo._nodeOwners;
  20127. for (var i=0,n=nodeOwners.length;i < n;i++){
  20128. var nodeOwner=nodeOwners[i];
  20129. if (nodeOwner){
  20130. var pro=nodeOwner.propertyOwner;
  20131. if (pro){
  20132. switch (nodeOwner.type){
  20133. case 0:;
  20134. var proPat=nodeOwner.property;
  20135. var m=proPat.length-1;
  20136. for (var j=0;j < m;j++){
  20137. pro=pro[proPat[j]];
  20138. if (!pro)
  20139. break ;
  20140. }
  20141. pro[proPat[m]]=nodeOwner.defaultValue;
  20142. break ;
  20143. case 1:;
  20144. var locPos=pro.localPosition;
  20145. var def=nodeOwner.defaultValue;
  20146. locPos.x=def.x;
  20147. locPos.y=def.y;
  20148. locPos.z=def.z;
  20149. pro.localPosition=locPos;
  20150. break ;
  20151. case 2:;
  20152. var locRot=pro.localRotation;
  20153. var defQua=nodeOwner.defaultValue;
  20154. locRot.x=defQua.x;
  20155. locRot.y=defQua.y;
  20156. locRot.z=defQua.z;
  20157. locRot.w=defQua.w;
  20158. pro.localRotation=locRot;
  20159. break ;
  20160. case 3:;
  20161. var locSca=pro.localScale;
  20162. def=nodeOwner.defaultValue;
  20163. locSca.x=def.x;
  20164. locSca.y=def.y;
  20165. locSca.z=def.z;
  20166. pro.localScale=locSca;
  20167. break ;
  20168. case 4:;
  20169. var locEul=pro.localRotationEuler;
  20170. def=nodeOwner.defaultValue;
  20171. locEul.x=def.x;
  20172. locEul.y=def.y;
  20173. locEul.z=def.z;
  20174. pro.localRotationEuler=locEul;
  20175. break ;
  20176. default :
  20177. throw "Animator:unknown type.";
  20178. }
  20179. }
  20180. }
  20181. }
  20182. }
  20183. /**
  20184. *@private
  20185. */
  20186. __proto._removeClip=function(clipStateInfos,statesMap,index,state){
  20187. var clip=state._clip;
  20188. clip._removeReference();
  20189. clipStateInfos.splice(index,1);
  20190. delete statesMap[state.name];
  20191. var clipStateInfo=clipStateInfos[index];
  20192. var frameNodes=clip._nodes;
  20193. var nodeOwners=clipStateInfo._nodeOwners;
  20194. for (var i=0,n=frameNodes.count;i < n;i++)
  20195. this._removeKeyframeNodeOwner(nodeOwners,frameNodes.getNodeByIndex(i));
  20196. }
  20197. /**
  20198. *@inheritDoc
  20199. */
  20200. __proto._onAdded=function(){
  20201. var parent=this.owner._parent;
  20202. (this.owner)._setHierarchyAnimator(this,parent ? (parent)._hierarchyAnimator :null);
  20203. (this.owner)._changeAnimatorToLinkSprite3DNoAvatar(this,true,/*new vector.<>*/[]);
  20204. }
  20205. /**
  20206. *@inheritDoc
  20207. */
  20208. __proto._onDestroy=function(){
  20209. for (var i=0,n=this._controllerLayers.length;i < n;i++){
  20210. var clipStateInfos=this._controllerLayers[i]._states;
  20211. for (var j=0,m=clipStateInfos.length;j < m;j++)
  20212. clipStateInfos[j]._clip._removeReference();
  20213. };
  20214. var parent=this.owner._parent;
  20215. (this.owner)._clearHierarchyAnimator(this,parent ? (parent)._hierarchyAnimator :null);
  20216. }
  20217. /**
  20218. *@inheritDoc
  20219. */
  20220. __proto._onEnableInScene=function(){
  20221. (this.owner._scene)._animatorPool.add(this);
  20222. }
  20223. /**
  20224. *@inheritDoc
  20225. */
  20226. __proto._onDisableInScene=function(){
  20227. (this.owner._scene)._animatorPool.remove(this);
  20228. }
  20229. /**
  20230. *@inheritDoc
  20231. */
  20232. __proto._onEnable=function(){
  20233. for (var i=0,n=this._controllerLayers.length;i < n;i++){
  20234. if (this._controllerLayers[i].playOnWake){
  20235. var defaultClip=this.getDefaultState(i);
  20236. (defaultClip)&& (this.play(null,i,0));
  20237. }
  20238. }
  20239. }
  20240. /**
  20241. *@private
  20242. */
  20243. __proto._handleSpriteOwnersBySprite=function(isLink,path,sprite){
  20244. for (var i=0,n=this._controllerLayers.length;i < n;i++){
  20245. var clipStateInfos=this._controllerLayers[i]._states;
  20246. for (var j=0,m=clipStateInfos.length;j < m;j++){
  20247. var clipStateInfo=clipStateInfos[j];
  20248. var clip=clipStateInfo._clip;
  20249. var nodePath=path.join("/");
  20250. var ownersNodes=clip._nodesMap[nodePath];
  20251. if (ownersNodes){
  20252. var nodeOwners=clipStateInfo._nodeOwners;
  20253. for (var k=0,p=ownersNodes.length;k < p;k++){
  20254. if (isLink)
  20255. this._addKeyframeNodeOwner(nodeOwners,ownersNodes[k],sprite);
  20256. else
  20257. this._removeKeyframeNodeOwner(nodeOwners,ownersNodes[k]);
  20258. }
  20259. }
  20260. }
  20261. }
  20262. }
  20263. /**
  20264. *@inheritDoc
  20265. */
  20266. __proto._parse=function(data){
  20267. var avatarData=data.avatar;
  20268. if (avatarData){
  20269. this.avatar=Loader.getRes(avatarData.path);
  20270. var linkSprites=avatarData.linkSprites;
  20271. this._linkSprites=linkSprites;
  20272. this._linkToSprites(linkSprites);
  20273. };
  20274. var clipPaths=data.clipPaths;
  20275. var play=data.playOnWake;
  20276. var layersData=data.layers;
  20277. for (var i=0;i < layersData.length;i++){
  20278. var layerData=layersData[i];
  20279. var animatorLayer=new AnimatorControllerLayer(layerData.name);
  20280. if (i===0)
  20281. animatorLayer.defaultWeight=1.0;
  20282. else
  20283. animatorLayer.defaultWeight=layerData.weight;
  20284. var blendingModeData=layerData.blendingMode;
  20285. (blendingModeData)&& (animatorLayer.blendingMode=blendingModeData);
  20286. this.addControllerLayer(animatorLayer);
  20287. var states=layerData.states;
  20288. for (var j=0,m=states.length;j < m;j++){
  20289. var state=states[j];
  20290. var clipPath=state.clipPath;
  20291. if (clipPath){
  20292. var name=state.name;
  20293. var motion;
  20294. motion=Loader.getRes(clipPath);
  20295. if (motion){
  20296. var animatorState=new AnimatorState();
  20297. animatorState.name=name;
  20298. animatorState.clip=motion;
  20299. this.addState(animatorState,i);
  20300. (j===0)&& (this.getControllerLayer(i).defaultState=animatorState);
  20301. }
  20302. }
  20303. }
  20304. (play!==undefined)&& (animatorLayer.playOnWake=play);
  20305. };
  20306. var cullingModeData=data.cullingMode;
  20307. (cullingModeData!==undefined)&& (this.cullingMode=cullingModeData);
  20308. }
  20309. /**
  20310. *@private
  20311. */
  20312. __proto._update=function(){
  20313. if (this._speed===0)
  20314. return;
  20315. var needRender=false;
  20316. if (this.cullingMode===2){
  20317. needRender=false;
  20318. for (var i=0,n=this._renderableSprites.length;i < n;i++){
  20319. if (this._renderableSprites[i]._render._visible){
  20320. needRender=true;
  20321. break ;
  20322. }
  20323. }
  20324. }else {
  20325. needRender=true;
  20326. }
  20327. this._updateMark++;
  20328. var timer=(this.owner._scene).timer;
  20329. var delta=timer._delta / 1000.0;
  20330. var timerScale=timer.scale;
  20331. for (i=0,n=this._controllerLayers.length;i < n;i++){
  20332. var controllerLayer=this._controllerLayers[i];
  20333. var playStateInfo=controllerLayer._playStateInfo;
  20334. var crossPlayStateInfo=controllerLayer._crossPlayStateInfo;
  20335. addtive=controllerLayer.blendingMode!==AnimatorControllerLayer.BLENDINGMODE_OVERRIDE;
  20336. switch (controllerLayer._playType){
  20337. case 0:;
  20338. var animatorState=controllerLayer._currentPlayState;
  20339. var clip=animatorState._clip;
  20340. var speed=this._speed *animatorState.speed;
  20341. var finish=playStateInfo._finish;
  20342. finish || this._updatePlayer(animatorState,playStateInfo,delta *speed,clip.islooping);
  20343. if (needRender){
  20344. var addtive=controllerLayer.blendingMode!==AnimatorControllerLayer.BLENDINGMODE_OVERRIDE;
  20345. this._updateClipDatas(animatorState,addtive,playStateInfo,timerScale *speed);
  20346. this._setClipDatasToNode(animatorState,addtive,controllerLayer.defaultWeight,i===0);
  20347. finish || this._updateEventScript(animatorState,playStateInfo);
  20348. }
  20349. break ;
  20350. case 1:
  20351. animatorState=controllerLayer._currentPlayState;
  20352. clip=animatorState._clip;
  20353. var crossClipState=controllerLayer._crossPlayState;
  20354. var crossClip=crossClipState._clip;
  20355. var crossDuratuion=controllerLayer._crossDuration;
  20356. var startPlayTime=crossPlayStateInfo._startPlayTime;
  20357. var crossClipDuration=crossClip._duration-startPlayTime;
  20358. var crossScale=crossDuratuion > crossClipDuration ? crossClipDuration / crossDuratuion :1.0;
  20359. var crossSpeed=this._speed *crossClipState.speed;
  20360. this._updatePlayer(crossClipState,crossPlayStateInfo,delta *crossScale *crossSpeed,crossClip.islooping);
  20361. var crossWeight=((crossPlayStateInfo._elapsedTime-startPlayTime)/ crossScale)/ crossDuratuion;
  20362. if (crossWeight >=1.0){
  20363. if (needRender){
  20364. this._updateClipDatas(crossClipState,addtive,crossPlayStateInfo,timerScale *crossSpeed);
  20365. this._setClipDatasToNode(crossClipState,addtive,controllerLayer.defaultWeight,i===0);
  20366. controllerLayer._playType=0;
  20367. controllerLayer._currentPlayState=crossClipState;
  20368. crossPlayStateInfo._cloneTo(playStateInfo);
  20369. }
  20370. }else {
  20371. if (!playStateInfo._finish){
  20372. speed=this._speed *animatorState.speed;
  20373. this._updatePlayer(animatorState,playStateInfo,delta *speed,clip.islooping);
  20374. if (needRender){
  20375. this._updateClipDatas(animatorState,addtive,playStateInfo,timerScale *speed);
  20376. }
  20377. }
  20378. if (needRender){
  20379. this._updateClipDatas(crossClipState,addtive,crossPlayStateInfo,timerScale *crossScale *crossSpeed);
  20380. this._setCrossClipDatasToNode(controllerLayer,animatorState,crossClipState,crossWeight,i===0);
  20381. }
  20382. }
  20383. if (needRender){
  20384. this._updateEventScript(animatorState,playStateInfo);
  20385. this._updateEventScript(crossClipState,crossPlayStateInfo);
  20386. }
  20387. break ;
  20388. case 2:
  20389. crossClipState=controllerLayer._crossPlayState;
  20390. crossClip=crossClipState._clip;
  20391. crossDuratuion=controllerLayer._crossDuration;
  20392. startPlayTime=crossPlayStateInfo._startPlayTime;
  20393. crossClipDuration=crossClip._duration-startPlayTime;
  20394. crossScale=crossDuratuion > crossClipDuration ? crossClipDuration / crossDuratuion :1.0;
  20395. crossSpeed=this._speed *crossClipState.speed;
  20396. this._updatePlayer(crossClipState,crossPlayStateInfo,delta *crossScale *crossSpeed,crossClip.islooping);
  20397. if (needRender){
  20398. crossWeight=((crossPlayStateInfo._elapsedTime-startPlayTime)/ crossScale)/ crossDuratuion;
  20399. if (crossWeight >=1.0){
  20400. this._updateClipDatas(crossClipState,addtive,crossPlayStateInfo,timerScale *crossSpeed);
  20401. this._setClipDatasToNode(crossClipState,addtive,1.0,i===0);
  20402. controllerLayer._playType=0;
  20403. controllerLayer._currentPlayState=crossClipState;
  20404. crossPlayStateInfo._cloneTo(playStateInfo);
  20405. }else {
  20406. this._updateClipDatas(crossClipState,addtive,crossPlayStateInfo,timerScale *crossScale *crossSpeed);
  20407. this._setFixedCrossClipDatasToNode(controllerLayer,crossClipState,crossWeight,i===0);
  20408. }
  20409. this._updateEventScript(crossClipState,crossPlayStateInfo);
  20410. }
  20411. break ;
  20412. }
  20413. }
  20414. if (needRender){
  20415. if (this._avatar){
  20416. Render.supportWebGLPlusAnimation && this._updateAnimationNodeWorldMatix(this._animationNodeLocalPositions,this._animationNodeLocalRotations,this._animationNodeLocalScales,this._animationNodeWorldMatrixs,this._animationNodeParentIndices);
  20417. this._updateAvatarNodesToSprite();
  20418. }
  20419. }
  20420. }
  20421. /**
  20422. *@private
  20423. */
  20424. __proto._cloneTo=function(dest){
  20425. var animator=dest;
  20426. animator.avatar=this.avatar;
  20427. for (var i=0,n=this._controllerLayers.length;i < n;i++){
  20428. var controllLayer=this._controllerLayers[i];
  20429. animator.addControllerLayer(controllLayer.clone());
  20430. var animatorStates=controllLayer._states;
  20431. for (var j=0,m=animatorStates.length;j < m;j++){
  20432. var state=animatorStates[j].clone();
  20433. animator.addState(state,i);
  20434. (j==0)&& (animator.getControllerLayer(i).defaultState=state);
  20435. }
  20436. }
  20437. animator._linkSprites=this._linkSprites;
  20438. animator._linkToSprites(this._linkSprites);
  20439. }
  20440. /**
  20441. *获取默认动画状态。
  20442. *@param layerIndex 层索引。
  20443. *@return 默认动画状态。
  20444. */
  20445. __proto.getDefaultState=function(layerIndex){
  20446. (layerIndex===void 0)&& (layerIndex=0);
  20447. var controllerLayer=this._controllerLayers[layerIndex];
  20448. return controllerLayer.defaultState;
  20449. }
  20450. /**
  20451. *添加动画状态。
  20452. *@param state 动画状态。
  20453. *@param layerIndex 层索引。
  20454. */
  20455. __proto.addState=function(state,layerIndex){
  20456. (layerIndex===void 0)&& (layerIndex=0);
  20457. var stateName=state.name;
  20458. var controllerLayer=this._controllerLayers[layerIndex];
  20459. var statesMap=controllerLayer._statesMap;
  20460. var states=controllerLayer._states;
  20461. if (statesMap[stateName]){
  20462. throw "Animator:this stat's name has exist.";
  20463. }else {
  20464. statesMap[stateName]=state;
  20465. states.push(state);
  20466. state._clip._addReference();
  20467. this._getOwnersByClip(state);
  20468. }
  20469. }
  20470. /**
  20471. *移除动画状态。
  20472. *@param state 动画状态。
  20473. *@param layerIndex 层索引。
  20474. */
  20475. __proto.removeState=function(state,layerIndex){
  20476. (layerIndex===void 0)&& (layerIndex=0);
  20477. var controllerLayer=this._controllerLayers[layerIndex];
  20478. var clipStateInfos=controllerLayer._states;
  20479. var statesMap=controllerLayer._statesMap;
  20480. var index=-1;
  20481. for (var i=0,n=clipStateInfos.length;i < n;i++){
  20482. if (clipStateInfos[i]===state){
  20483. index=i;
  20484. break ;
  20485. }
  20486. }
  20487. if (index!==-1)
  20488. this._removeClip(clipStateInfos,statesMap,index,state);
  20489. }
  20490. /**
  20491. *添加控制器层。
  20492. */
  20493. __proto.addControllerLayer=function(controllderLayer){
  20494. this._controllerLayers.push(controllderLayer);
  20495. }
  20496. /**
  20497. *获取控制器层。
  20498. */
  20499. __proto.getControllerLayer=function(layerInex){
  20500. (layerInex===void 0)&& (layerInex=0);
  20501. return this._controllerLayers[layerInex];
  20502. }
  20503. /**
  20504. *获取当前的播放状态。
  20505. *@param layerIndex 层索引。
  20506. *@return 动画播放状态。
  20507. */
  20508. __proto.getCurrentAnimatorPlayState=function(layerInex){
  20509. (layerInex===void 0)&& (layerInex=0);
  20510. return this._controllerLayers[layerInex]._playStateInfo;
  20511. }
  20512. /**
  20513. *播放动画。
  20514. *@param name 如果为null则播放默认动画,否则按名字播放动画片段。
  20515. *@param layerIndex 层索引。
  20516. *@param normalizedTime 归一化的播放起始时间。
  20517. */
  20518. __proto.play=function(name,layerIndex,normalizedTime){
  20519. (layerIndex===void 0)&& (layerIndex=0);
  20520. (normalizedTime===void 0)&& (normalizedTime=Number.NEGATIVE_INFINITY);
  20521. var controllerLayer=this._controllerLayers[layerIndex];
  20522. var defaultState=controllerLayer.defaultState;
  20523. if (!name && !defaultState)
  20524. throw new Error("Animator:must have default clip value,please set clip property.");
  20525. var curPlayState=controllerLayer._currentPlayState;
  20526. var playStateInfo=controllerLayer._playStateInfo;
  20527. var animatorState=name ? controllerLayer._statesMap[name] :defaultState;
  20528. var clipDuration=animatorState._clip._duration;
  20529. if (curPlayState!==animatorState){
  20530. if (normalizedTime!==Number.NEGATIVE_INFINITY)
  20531. playStateInfo._resetPlayState(clipDuration *normalizedTime);
  20532. else
  20533. playStateInfo._resetPlayState(0.0);
  20534. (curPlayState!==null && curPlayState!==animatorState)&& (this._revertDefaultKeyframeNodes(curPlayState));
  20535. controllerLayer._playType=0;
  20536. controllerLayer._currentPlayState=animatorState;
  20537. }else {
  20538. if (normalizedTime!==Number.NEGATIVE_INFINITY){
  20539. playStateInfo._resetPlayState(clipDuration *normalizedTime);
  20540. controllerLayer._playType=0;
  20541. }
  20542. };
  20543. var scripts=animatorState._scripts;
  20544. if (scripts){
  20545. for (var i=0,n=scripts.length;i < n;i++)
  20546. scripts[i].onStateEnter();
  20547. }
  20548. }
  20549. /**
  20550. *在当前动画状态和目标动画状态之间进行融合过渡播放。
  20551. *@param name 目标动画状态。
  20552. *@param transitionDuration 过渡时间,该值为当前动画状态的归一化时间,值在0.0~1.0之间。
  20553. *@param layerIndex 层索引。
  20554. *@param normalizedTime 归一化的播放起始时间。
  20555. */
  20556. __proto.crossFade=function(name,transitionDuration,layerIndex,normalizedTime){
  20557. (layerIndex===void 0)&& (layerIndex=0);
  20558. (normalizedTime===void 0)&& (normalizedTime=Number.NEGATIVE_INFINITY);
  20559. var controllerLayer=this._controllerLayers[layerIndex];
  20560. var destAnimatorState=controllerLayer._statesMap[name];
  20561. if (destAnimatorState){
  20562. var playType=controllerLayer._playType;
  20563. if (playType===-1){
  20564. this.play(name,layerIndex,normalizedTime);
  20565. return;
  20566. };
  20567. var crossPlayStateInfo=controllerLayer._crossPlayStateInfo;
  20568. var crossNodeOwners=controllerLayer._crossNodesOwners;
  20569. var crossNodeOwnerIndicesMap=controllerLayer._crossNodesOwnersIndicesMap;
  20570. var srcAnimatorState=controllerLayer._currentPlayState;
  20571. var destNodeOwners=destAnimatorState._nodeOwners;
  20572. var destCrossClipNodeIndices=controllerLayer._destCrossClipNodeIndices;
  20573. var destClip=destAnimatorState._clip;
  20574. var destNodes=destClip._nodes;
  20575. var destNodesMap=destClip._nodesDic;
  20576. switch (playType){
  20577. case 0:;
  20578. var srcNodeOwners=srcAnimatorState._nodeOwners;
  20579. var scrCrossClipNodeIndices=controllerLayer._srcCrossClipNodeIndices;
  20580. var srcClip=srcAnimatorState._clip;
  20581. var srcNodes=srcClip._nodes;
  20582. var srcNodesMap=srcClip._nodesDic;
  20583. controllerLayer._playType=1;
  20584. var crossMark=++controllerLayer._crossMark;
  20585. var crossCount=controllerLayer._crossNodesOwnersCount=0;
  20586. for (var i=0,n=srcNodes.count;i < n;i++){
  20587. var srcNode=srcNodes.getNodeByIndex(i);
  20588. var srcIndex=srcNode._indexInList;
  20589. var srcNodeOwner=srcNodeOwners[srcIndex];
  20590. if (srcNodeOwner){
  20591. var srcFullPath=srcNode.fullPath;
  20592. scrCrossClipNodeIndices[crossCount]=srcIndex;
  20593. var destNode=destNodesMap[srcFullPath];
  20594. if (destNode)
  20595. destCrossClipNodeIndices[crossCount]=destNode._indexInList;
  20596. else
  20597. destCrossClipNodeIndices[crossCount]=-1;
  20598. crossNodeOwnerIndicesMap[srcFullPath]=crossMark;
  20599. crossNodeOwners[crossCount]=srcNodeOwner;
  20600. crossCount++;
  20601. }
  20602. }
  20603. for (i=0,n=destNodes.count;i < n;i++){
  20604. destNode=destNodes.getNodeByIndex(i);
  20605. var destIndex=destNode._indexInList;
  20606. var destNodeOwner=destNodeOwners[destIndex];
  20607. if (destNodeOwner){
  20608. var destFullPath=destNode.fullPath;
  20609. if (!srcNodesMap[destFullPath]){
  20610. scrCrossClipNodeIndices[crossCount]=-1;
  20611. destCrossClipNodeIndices[crossCount]=destIndex;
  20612. crossNodeOwnerIndicesMap[destFullPath]=crossMark;
  20613. crossNodeOwners[crossCount]=destNodeOwner;
  20614. crossCount++;
  20615. }
  20616. }
  20617. }
  20618. break ;
  20619. case 1:
  20620. case 2:
  20621. controllerLayer._playType=2;
  20622. for (i=0,n=crossNodeOwners.length;i < n;i++){
  20623. var nodeOwner=crossNodeOwners[i];
  20624. nodeOwner.saveCrossFixedValue();
  20625. destNode=destNodesMap[nodeOwner.fullPath];
  20626. if (destNode)
  20627. destCrossClipNodeIndices[i]=destNode._indexInList;
  20628. else
  20629. destCrossClipNodeIndices[i]=-1;
  20630. }
  20631. crossCount=controllerLayer._crossNodesOwnersCount;
  20632. crossMark=controllerLayer._crossMark;
  20633. for (i=0,n=destNodes.count;i < n;i++){
  20634. destNode=destNodes.getNodeByIndex(i);
  20635. destIndex=destNode._indexInList;
  20636. destNodeOwner=destNodeOwners[destIndex];
  20637. if (destNodeOwner){
  20638. destFullPath=destNode.fullPath;
  20639. if (crossNodeOwnerIndicesMap[destFullPath]!==crossMark){
  20640. destCrossClipNodeIndices[crossCount]=destIndex;
  20641. crossNodeOwnerIndicesMap[destFullPath]=crossMark;
  20642. nodeOwner=destNodeOwners[destIndex];
  20643. crossNodeOwners[crossCount]=nodeOwner;
  20644. nodeOwner.saveCrossFixedValue();
  20645. crossCount++;
  20646. }
  20647. }
  20648. }
  20649. break ;
  20650. default :
  20651. }
  20652. controllerLayer._crossNodesOwnersCount=crossCount;
  20653. controllerLayer._crossPlayState=destAnimatorState;
  20654. controllerLayer._crossDuration=srcAnimatorState._clip._duration *transitionDuration;
  20655. if (normalizedTime!==Number.NEGATIVE_INFINITY)
  20656. crossPlayStateInfo._resetPlayState(destClip._duration *normalizedTime);
  20657. else
  20658. crossPlayStateInfo._resetPlayState(0.0);
  20659. };
  20660. var scripts=destAnimatorState._scripts;
  20661. if (scripts){
  20662. for (i=0,n=scripts.length;i < n;i++)
  20663. scripts[i].onStateEnter();
  20664. }
  20665. }
  20666. /**
  20667. *@private
  20668. */
  20669. __proto._getAvatarOwnersAndInitDatasAsync=function(){
  20670. for (var i=0,n=this._controllerLayers.length;i < n;i++){
  20671. var clipStateInfos=this._controllerLayers[i]._states;
  20672. for (var j=0,m=clipStateInfos.length;j < m;j++)
  20673. this._getOwnersByClip(clipStateInfos[j]);
  20674. }
  20675. this._avatar._cloneDatasToAnimator(this);
  20676. for (var k in this._linkAvatarSpritesData){
  20677. var sprites=this._linkAvatarSpritesData[k];
  20678. if (sprites){
  20679. for (var c=0,p=sprites.length;c < p;c++)
  20680. this._isLinkSpriteToAnimationNode(sprites[c],k,true);
  20681. }
  20682. }
  20683. }
  20684. /**
  20685. *@private
  20686. */
  20687. __proto._isLinkSpriteToAnimationNode=function(sprite,nodeName,isLink){
  20688. if (this._avatar){
  20689. var node=this._avatarNodeMap[nodeName];
  20690. if (node){
  20691. if (isLink){
  20692. sprite._transform._dummy=node.transform;
  20693. this._linkAvatarSprites.push(sprite);
  20694. var nodeTransform=node.transform;
  20695. var spriteTransform=sprite.transform;
  20696. if (!spriteTransform.owner.isStatic && nodeTransform){
  20697. var spriteWorldMatrix=spriteTransform.worldMatrix;
  20698. var ownParTra=(this.owner)._transform._parent;
  20699. if (ownParTra){
  20700. Utils3D.matrix4x4MultiplyMFM(ownParTra.worldMatrix,nodeTransform.getWorldMatrix(),spriteWorldMatrix);
  20701. }else {
  20702. var sprWorE=spriteWorldMatrix.elements;
  20703. var nodWorE=nodeTransform.getWorldMatrix();
  20704. for (var i=0;i < 16;i++)
  20705. sprWorE[i]=nodWorE[i];
  20706. }
  20707. spriteTransform.worldMatrix=spriteWorldMatrix;
  20708. }
  20709. }else {
  20710. sprite._transform._dummy=null;
  20711. this._linkAvatarSprites.splice(this._linkAvatarSprites.indexOf(sprite),1);
  20712. }
  20713. }
  20714. }
  20715. }
  20716. /**
  20717. *@private
  20718. */
  20719. __proto._isLinkSpriteToAnimationNodeData=function(sprite,nodeName,isLink){
  20720. var linkSprites=this._linkAvatarSpritesData[nodeName];
  20721. if (isLink){
  20722. linkSprites || (this._linkAvatarSpritesData[nodeName]=linkSprites=[]);
  20723. linkSprites.push(sprite);
  20724. }else {
  20725. linkSprites.splice(sprite,1);
  20726. }
  20727. }
  20728. /**
  20729. *@private
  20730. */
  20731. __proto._updateAvatarNodesToSprite=function(){
  20732. for (var i=0,n=this._linkAvatarSprites.length;i < n;i++){
  20733. var sprite=this._linkAvatarSprites[i];
  20734. var nodeTransform=sprite.transform._dummy;
  20735. var spriteTransform=sprite.transform;
  20736. if (!spriteTransform.owner.isStatic && nodeTransform){
  20737. var spriteWorldMatrix=spriteTransform.worldMatrix;
  20738. var ownTra=(this.owner)._transform;
  20739. Utils3D.matrix4x4MultiplyMFM(ownTra.worldMatrix,nodeTransform.getWorldMatrix(),spriteWorldMatrix);
  20740. spriteTransform.worldMatrix=spriteWorldMatrix;
  20741. }
  20742. }
  20743. }
  20744. /**
  20745. *关联精灵节点到Avatar节点,此Animator必须有Avatar文件。
  20746. *@param nodeName 关联节点的名字。
  20747. *@param sprite3D 精灵节点。
  20748. *@return 是否关联成功。
  20749. */
  20750. __proto.linkSprite3DToAvatarNode=function(nodeName,sprite3D){
  20751. this._isLinkSpriteToAnimationNodeData(sprite3D,nodeName,true);
  20752. this._isLinkSpriteToAnimationNode(sprite3D,nodeName,true);
  20753. return true;
  20754. }
  20755. /**
  20756. *解除精灵节点到Avatar节点的关联,此Animator必须有Avatar文件。
  20757. *@param sprite3D 精灵节点。
  20758. *@return 是否解除关联成功。
  20759. */
  20760. __proto.unLinkSprite3DToAvatarNode=function(sprite3D){
  20761. if (sprite3D._hierarchyAnimator===this){
  20762. var dummy=sprite3D.transform._dummy;
  20763. if (dummy){
  20764. var nodeName=dummy._owner.name;
  20765. this._isLinkSpriteToAnimationNodeData(sprite3D,nodeName,false);
  20766. this._isLinkSpriteToAnimationNode(sprite3D,nodeName,false);
  20767. return true;
  20768. }else {
  20769. return false;
  20770. }
  20771. }else {
  20772. throw("Animator:sprite3D must belong to this Animator");
  20773. return false;
  20774. }
  20775. }
  20776. /**
  20777. *@private
  20778. *[NATIVE]
  20779. */
  20780. __proto._updateAnimationNodeWorldMatix=function(localPositions,localRotations,localScales,worldMatrixs,parentIndices){
  20781. LayaGL.instance.updateAnimationNodeWorldMatix(localPositions,localRotations,localScales,parentIndices,worldMatrixs);
  20782. }
  20783. /**
  20784. *设置动画的播放速度,1.0为正常播放速度。
  20785. *@param 动画的播放速度。
  20786. */
  20787. /**
  20788. *获取动画的播放速度,1.0为正常播放速度。
  20789. *@return 动画的播放速度。
  20790. */
  20791. __getset(0,__proto,'speed',function(){
  20792. return this._speed;
  20793. },function(value){
  20794. this._speed=value;
  20795. });
  20796. /**
  20797. *设置avatar。
  20798. *@param value avatar。
  20799. */
  20800. /**
  20801. *获取avatar。
  20802. *@return avator。
  20803. */
  20804. __getset(0,__proto,'avatar',function(){
  20805. return this._avatar;
  20806. },function(value){
  20807. if (this._avatar!==value){
  20808. this._avatar=value;
  20809. if (value){
  20810. this._getAvatarOwnersAndInitDatasAsync();
  20811. (this.owner)._changeHierarchyAnimatorAvatar(this,value);
  20812. }else {
  20813. var parent=this.owner._parent;
  20814. (this.owner)._changeHierarchyAnimatorAvatar(this,parent ? (parent)._hierarchyAnimator._avatar :null);
  20815. }
  20816. }
  20817. });
  20818. Animator._update=function(scene){
  20819. var pool=scene._animatorPool;
  20820. var elements=pool.elements;
  20821. for (var i=0,n=pool.length;i < n;i++){
  20822. var animator=elements[i];
  20823. (animator && animator.enabled)&& (animator._update());
  20824. }
  20825. }
  20826. Animator._tempVector3Array0=new Float32Array(3);
  20827. Animator._tempVector3Array1=new Float32Array(3);
  20828. Animator._tempQuaternionArray0=new Float32Array(4);
  20829. Animator._tempQuaternionArray1=new Float32Array(4);
  20830. Animator.CULLINGMODE_ALWAYSANIMATE=0;
  20831. Animator.CULLINGMODE_CULLCOMPLETELY=2;
  20832. __static(Animator,
  20833. ['_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();}
  20834. ]);
  20835. return Animator;
  20836. })(Component)
  20837. /**
  20838. *@private
  20839. *<code>BufferState</code> 类用于实现渲染所需的Buffer状态集合。
  20840. */
  20841. //class laya.d3.core.BufferState extends laya.webgl.BufferStateBase
  20842. var BufferState=(function(_super){
  20843. /**
  20844. *创建一个 <code>BufferState</code> 实例。
  20845. */
  20846. function BufferState(){
  20847. BufferState.__super.call(this);
  20848. }
  20849. __class(BufferState,'laya.d3.core.BufferState',_super);
  20850. var __proto=BufferState.prototype;
  20851. /**
  20852. *@private
  20853. *vertexBuffer的vertexDeclaration不能为空,该函数比较消耗性能,建议初始化时使用。
  20854. */
  20855. __proto.applyVertexBuffer=function(vertexBuffer){
  20856. if (BufferStateBase._curBindedBufferState===this){
  20857. var gl=LayaGL.instance;
  20858. var verDec=vertexBuffer.vertexDeclaration;
  20859. var valueData=null;
  20860. if (Render.supportWebGLPlusRendering)
  20861. valueData=verDec._shaderValues._nativeArray;
  20862. else
  20863. valueData=verDec._shaderValues.getData();
  20864. vertexBuffer.bind();
  20865. for (var k in valueData){
  20866. var loc=parseInt(k);
  20867. var attribute=valueData[k];
  20868. gl.enableVertexAttribArray(loc);
  20869. gl.vertexAttribPointer(loc,attribute[0],attribute[1],!!attribute[2],attribute[3],attribute[4]);
  20870. }
  20871. }else {
  20872. throw "BufferState: must call bind() function first.";
  20873. }
  20874. }
  20875. /**
  20876. *@private
  20877. *vertexBuffers中的vertexDeclaration不能为空,该函数比较消耗性能,建议初始化时使用。
  20878. */
  20879. __proto.applyVertexBuffers=function(vertexBuffers){
  20880. if (BufferStateBase._curBindedBufferState===this){
  20881. var gl=LayaGL.instance;
  20882. for (var i=0,n=vertexBuffers.length;i < n;i++){
  20883. var verBuf=vertexBuffers[i];
  20884. var verDec=verBuf.vertexDeclaration;
  20885. var valueData=null;
  20886. if (Render.supportWebGLPlusRendering)
  20887. valueData=verDec._shaderValues._nativeArray;
  20888. else
  20889. valueData=verDec._shaderValues.getData();
  20890. verBuf.bind();
  20891. for (var k in valueData){
  20892. var loc=parseInt(k);
  20893. var attribute=valueData[k];
  20894. gl.enableVertexAttribArray(loc);
  20895. gl.vertexAttribPointer(loc,attribute[0],attribute[1],!!attribute[2],attribute[3],attribute[4]);
  20896. }
  20897. }
  20898. }else {
  20899. throw "BufferState: must call bind() function first.";
  20900. }
  20901. }
  20902. /**
  20903. *@private
  20904. */
  20905. __proto.applyInstanceVertexBuffer=function(vertexBuffer){
  20906. if (WebGLContext._angleInstancedArrays){
  20907. if (BufferStateBase._curBindedBufferState===this){
  20908. var gl=LayaGL.instance;
  20909. var verDec=vertexBuffer.vertexDeclaration;
  20910. var valueData=null;
  20911. if (Render.supportWebGLPlusRendering)
  20912. valueData=verDec._shaderValues._nativeArray;
  20913. else
  20914. valueData=verDec._shaderValues.getData();
  20915. vertexBuffer.bind();
  20916. for (var k in valueData){
  20917. var loc=parseInt(k);
  20918. var attribute=valueData[k];
  20919. gl.enableVertexAttribArray(loc);
  20920. gl.vertexAttribPointer(loc,attribute[0],attribute[1],!!attribute[2],attribute[3],attribute[4]);
  20921. WebGLContext._angleInstancedArrays.vertexAttribDivisorANGLE(loc,1);
  20922. }
  20923. }else {
  20924. throw "BufferState: must call bind() function first.";
  20925. }
  20926. }
  20927. }
  20928. /**
  20929. *@private
  20930. */
  20931. __proto.applyIndexBuffer=function(indexBuffer){
  20932. if (BufferStateBase._curBindedBufferState===this){
  20933. if (this._bindedIndexBuffer!==indexBuffer){
  20934. indexBuffer._bindForVAO();
  20935. this._bindedIndexBuffer=indexBuffer;
  20936. }
  20937. }else {
  20938. throw "BufferState: must call bind() function first.";
  20939. }
  20940. }
  20941. return BufferState;
  20942. })(BufferStateBase)
  20943. /**
  20944. *<code>PhysicsComponent</code> 类用于创建物理组件的父类。
  20945. */
  20946. //class laya.d3.physics.PhysicsComponent extends laya.components.Component
  20947. var PhysicsComponent=(function(_super){
  20948. function PhysicsComponent(collisionGroup,canCollideWith){
  20949. /**@private */
  20950. this._restitution=0.0;
  20951. /**@private */
  20952. this._friction=0.5;
  20953. /**@private */
  20954. this._rollingFriction=0.0;
  20955. /**@private */
  20956. this._ccdMotionThreshold=0.0;
  20957. /**@private */
  20958. this._ccdSweptSphereRadius=0.0;
  20959. /**@private */
  20960. this._colliderShape=null;
  20961. /**@private */
  20962. this._transformFlag=2147483647;
  20963. /**@private */
  20964. //this._nativeColliderObject=null;
  20965. /**@private */
  20966. //this._simulation=null;
  20967. /**@private */
  20968. this._enableProcessCollisions=true;
  20969. /**@private */
  20970. this._inPhysicUpdateListIndex=-1;
  20971. /**是否可以缩放Shape。 */
  20972. this.canScaleShape=true;
  20973. PhysicsComponent.__super.call(this);
  20974. this._collisionGroup=/*laya.d3.utils.Physics3DUtils.COLLISIONFILTERGROUP_DEFAULTFILTER*/0x1;
  20975. this._canCollideWith=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER;
  20976. this._collisionGroup=collisionGroup;
  20977. this._canCollideWith=canCollideWith;
  20978. PhysicsComponent._physicObjectsMap[this.id]=this;
  20979. }
  20980. __class(PhysicsComponent,'laya.d3.physics.PhysicsComponent',_super);
  20981. var __proto=PhysicsComponent.prototype;
  20982. /**
  20983. *@private
  20984. */
  20985. __proto._isValid=function(){
  20986. return this._simulation && this._colliderShape && this._enabled;
  20987. }
  20988. /**
  20989. *@inheritDoc
  20990. */
  20991. __proto._parse=function(data){
  20992. (data.collisionGroup !=null)&& (this.collisionGroup=data.collisionGroup);
  20993. (data.canCollideWith !=null)&& (this.canCollideWith=data.canCollideWith);
  20994. (data.ccdMotionThreshold !=null)&& (this.ccdMotionThreshold=data.ccdMotionThreshold);
  20995. (data.ccdSweptSphereRadius !=null)&& (this.ccdSweptSphereRadius=data.ccdSweptSphereRadius);
  20996. }
  20997. /**
  20998. *@private
  20999. */
  21000. __proto._parseShape=function(shapesData){
  21001. var shapeCount=shapesData.length;
  21002. if (shapeCount===1){
  21003. var shape=ColliderShape._creatShape(shapesData[0]);
  21004. this.colliderShape=shape;
  21005. }else {
  21006. var compoundShape=new CompoundColliderShape();
  21007. for (var i=0;i < shapeCount;i++){
  21008. shape=ColliderShape._creatShape(shapesData[i]);
  21009. compoundShape.addChildShape(shape);
  21010. }
  21011. this.colliderShape=compoundShape;
  21012. }
  21013. }
  21014. /**
  21015. *@private
  21016. */
  21017. __proto._onScaleChange=function(scale){
  21018. this._colliderShape._setScale(scale);
  21019. }
  21020. /**
  21021. *@private
  21022. */
  21023. __proto._setTransformFlag=function(type,value){
  21024. if (value)
  21025. this._transformFlag |=type;
  21026. else
  21027. this._transformFlag &=~type;
  21028. }
  21029. /**
  21030. *@private
  21031. */
  21032. __proto._getTransformFlag=function(type){
  21033. return (this._transformFlag & type)!=0;
  21034. }
  21035. /**
  21036. *@private
  21037. */
  21038. __proto._addToSimulation=function(){}
  21039. /**
  21040. *@private
  21041. */
  21042. __proto._removeFromSimulation=function(){}
  21043. /**
  21044. *@private
  21045. */
  21046. __proto._derivePhysicsTransformation=function(force){
  21047. this._innerDerivePhysicsTransformation(this._nativeColliderObject.getWorldTransform(),force);
  21048. }
  21049. /**
  21050. *@private
  21051. *通过渲染矩阵更新物理矩阵。
  21052. */
  21053. __proto._innerDerivePhysicsTransformation=function(physicTransformOut,force){
  21054. var transform=(this.owner)._transform;
  21055. var rotation=transform.rotation;
  21056. if (force || this._getTransformFlag(/*laya.d3.core.Transform3D.TRANSFORM_WORLDPOSITION*/0x08)){
  21057. var shapeOffset=this._colliderShape.localOffset;
  21058. var position=transform.position;
  21059. var nativePosition=PhysicsComponent._nativeVector30;
  21060. if (shapeOffset.x!==0 || shapeOffset.y!==0 || shapeOffset.z!==0){
  21061. var physicPosition=PhysicsComponent._tempVector30;
  21062. PhysicsComponent.physicVector3TransformQuat(shapeOffset,rotation.x,rotation.y,rotation.z,rotation.w,physicPosition);
  21063. Vector3.add(position,physicPosition,physicPosition);
  21064. nativePosition.setValue(-physicPosition.x,physicPosition.y,physicPosition.z);
  21065. }else {
  21066. nativePosition.setValue(-position.x,position.y,position.z);
  21067. }
  21068. physicTransformOut.setOrigin(nativePosition);
  21069. this._setTransformFlag(/*laya.d3.core.Transform3D.TRANSFORM_WORLDPOSITION*/0x08,false);
  21070. }
  21071. if (force || this._getTransformFlag(/*laya.d3.core.Transform3D.TRANSFORM_WORLDQUATERNION*/0x10)){
  21072. var shapeRotation=this._colliderShape.localRotation;
  21073. var nativeRotation=PhysicsComponent._nativeQuaternion0;
  21074. if (shapeRotation.x!==0 || shapeRotation.y!==0 || shapeRotation.z!==0 || shapeRotation.w!==1){
  21075. var physicRotation=PhysicsComponent._tempQuaternion0;
  21076. PhysicsComponent.physicQuaternionMultiply(rotation.x,rotation.y,rotation.z,rotation.w,shapeRotation,physicRotation);
  21077. nativeRotation.setValue(-physicRotation.x,physicRotation.y,physicRotation.z,-physicRotation.w);
  21078. }else {
  21079. nativeRotation.setValue(-rotation.x,rotation.y,rotation.z,-rotation.w);
  21080. }
  21081. physicTransformOut.setRotation(nativeRotation);
  21082. this._setTransformFlag(/*laya.d3.core.Transform3D.TRANSFORM_WORLDQUATERNION*/0x10,false);
  21083. }
  21084. if (force || this._getTransformFlag(/*laya.d3.core.Transform3D.TRANSFORM_WORLDSCALE*/0x20)){
  21085. this._onScaleChange(transform.scale);
  21086. this._setTransformFlag(/*laya.d3.core.Transform3D.TRANSFORM_WORLDSCALE*/0x20,false);
  21087. }
  21088. }
  21089. /**
  21090. *@private
  21091. *通过物理矩阵更新渲染矩阵。
  21092. */
  21093. __proto._updateTransformComponent=function(physicsTransform){
  21094. var localOffset=this._colliderShape.localOffset;
  21095. var localRotation=this._colliderShape.localRotation;
  21096. var transform=(this.owner)._transform;
  21097. var position=transform.position;
  21098. var rotation=transform.rotation;
  21099. var nativePosition=physicsTransform.getOrigin();
  21100. var nativeRotation=physicsTransform.getRotation();
  21101. var nativeRotX=-nativeRotation.x();
  21102. var nativeRotY=nativeRotation.y();
  21103. var nativeRotZ=nativeRotation.z();
  21104. var nativeRotW=-nativeRotation.w();
  21105. if (localOffset.x!==0 || localOffset.y!==0 || localOffset.z!==0){
  21106. var rotShapePosition=PhysicsComponent._tempVector30;
  21107. PhysicsComponent.physicVector3TransformQuat(localOffset,nativeRotX,nativeRotY,nativeRotZ,nativeRotW,rotShapePosition);
  21108. position.x=-nativePosition.x()-rotShapePosition.x;
  21109. position.y=nativePosition.y()-rotShapePosition.y;
  21110. position.z=nativePosition.z()-rotShapePosition.z;
  21111. }else {
  21112. position.x=-nativePosition.x();
  21113. position.y=nativePosition.y();
  21114. position.z=nativePosition.z();
  21115. }
  21116. transform.position=position;
  21117. if (localRotation.x!==0 || localRotation.y!==0 || localRotation.z!==0 || localRotation.w!==1){
  21118. var invertShapeRotaion=PhysicsComponent._tempQuaternion0;
  21119. localRotation.invert(invertShapeRotaion);
  21120. PhysicsComponent.physicQuaternionMultiply(nativeRotX,nativeRotY,nativeRotZ,nativeRotW,invertShapeRotaion,rotation);
  21121. }else {
  21122. rotation.x=nativeRotX;
  21123. rotation.y=nativeRotY;
  21124. rotation.z=nativeRotZ;
  21125. rotation.w=nativeRotW;
  21126. }
  21127. transform.rotation=rotation;
  21128. }
  21129. /**
  21130. *@inheritDoc
  21131. */
  21132. __proto._onEnable=function(){
  21133. this._simulation=(this.owner._scene).physicsSimulation;
  21134. this._nativeColliderObject.setContactProcessingThreshold(1e30);
  21135. if (this._colliderShape && this._enabled){
  21136. this._derivePhysicsTransformation(true);
  21137. this._addToSimulation();
  21138. }
  21139. }
  21140. /**
  21141. *@inheritDoc
  21142. */
  21143. __proto._onDisable=function(){
  21144. if (this._colliderShape && this._enabled){
  21145. this._removeFromSimulation();
  21146. (this._inPhysicUpdateListIndex!==-1)&& (this._simulation._physicsUpdateList.remove(this));
  21147. }
  21148. this._simulation=null;
  21149. }
  21150. /**
  21151. *@private
  21152. */
  21153. __proto._onShapeChange=function(colShape){
  21154. var btColObj=this._nativeColliderObject;
  21155. var flags=btColObj.getCollisionFlags();
  21156. if (colShape.needsCustomCollisionCallback){
  21157. if ((flags & 8)===0)
  21158. btColObj.setCollisionFlags(flags | 8);
  21159. }else {
  21160. if ((flags & 8)> 0)
  21161. btColObj.setCollisionFlags(flags ^ 8);
  21162. }
  21163. }
  21164. /**
  21165. *@inheritDoc
  21166. */
  21167. __proto._onAdded=function(){
  21168. this.enabled=this._enabled;
  21169. this.restitution=this._restitution;
  21170. this.friction=this._friction;
  21171. this.rollingFriction=this._rollingFriction;
  21172. this.ccdMotionThreshold=this._ccdMotionThreshold;
  21173. this.ccdSweptSphereRadius=this._ccdSweptSphereRadius;
  21174. (this.owner).transform.on(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this,this._onTransformChanged);
  21175. }
  21176. /**
  21177. *@inheritDoc
  21178. */
  21179. __proto._onDestroy=function(){
  21180. var physics3D=Laya3D._physics3D;
  21181. delete PhysicsComponent._physicObjectsMap[this.id];
  21182. physics3D.destroy(this._nativeColliderObject);
  21183. this._colliderShape.destroy();
  21184. _super.prototype._onDestroy.call(this);
  21185. this._nativeColliderObject=null;
  21186. this._colliderShape=null;
  21187. this._simulation=null;
  21188. (this.owner).transform.off(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this,this._onTransformChanged);
  21189. }
  21190. /**
  21191. *@private
  21192. */
  21193. __proto._onTransformChanged=function(flag){
  21194. if (PhysicsComponent._addUpdateList){
  21195. flag &=/*laya.d3.core.Transform3D.TRANSFORM_WORLDPOSITION*/0x08 | /*laya.d3.core.Transform3D.TRANSFORM_WORLDQUATERNION*/0x10 | /*laya.d3.core.Transform3D.TRANSFORM_WORLDSCALE*/0x20;
  21196. if (flag){
  21197. this._transformFlag |=flag;
  21198. if (this._isValid()&& this._inPhysicUpdateListIndex===-1)
  21199. this._simulation._physicsUpdateList.add(this);
  21200. }
  21201. }
  21202. }
  21203. /**
  21204. *@inheritDoc
  21205. */
  21206. __proto._cloneTo=function(dest){
  21207. var destPhysicsComponent=dest;
  21208. destPhysicsComponent.restitution=this._restitution;
  21209. destPhysicsComponent.friction=this._friction;
  21210. destPhysicsComponent.rollingFriction=this._rollingFriction;
  21211. destPhysicsComponent.ccdMotionThreshold=this._ccdMotionThreshold;
  21212. destPhysicsComponent.ccdSweptSphereRadius=this._ccdSweptSphereRadius;
  21213. destPhysicsComponent.collisionGroup=this._collisionGroup;
  21214. destPhysicsComponent.canCollideWith=this._canCollideWith;
  21215. destPhysicsComponent.canScaleShape=this.canScaleShape;
  21216. (this._colliderShape)&& (destPhysicsComponent.colliderShape=this._colliderShape.clone());
  21217. }
  21218. /**
  21219. *获取是否激活。
  21220. */
  21221. __getset(0,__proto,'isActive',function(){
  21222. return this._nativeColliderObject ? this._nativeColliderObject.isActive():false;
  21223. });
  21224. /**
  21225. *设置弹力。
  21226. *@param 弹力。
  21227. */
  21228. /**
  21229. *获取弹力。
  21230. *@return 弹力。
  21231. */
  21232. __getset(0,__proto,'restitution',function(){
  21233. return this._restitution;
  21234. },function(value){
  21235. this._restitution=value;
  21236. this._nativeColliderObject && this._nativeColliderObject.setRestitution(value);
  21237. });
  21238. /**
  21239. *设置摩擦力。
  21240. *@param value 摩擦力。
  21241. */
  21242. /**
  21243. *获取摩擦力。
  21244. *@return 摩擦力。
  21245. */
  21246. __getset(0,__proto,'friction',function(){
  21247. return this._friction;
  21248. },function(value){
  21249. this._friction=value;
  21250. this._nativeColliderObject && this._nativeColliderObject.setFriction(value);
  21251. });
  21252. /**
  21253. *设置滚动摩擦力。
  21254. *@param 滚动摩擦力。
  21255. */
  21256. /**
  21257. *获取滚动摩擦力。
  21258. *@return 滚动摩擦力。
  21259. */
  21260. __getset(0,__proto,'rollingFriction',function(){
  21261. return this._nativeColliderObject.getRollingFriction();
  21262. },function(value){
  21263. this._rollingFriction=value;
  21264. this._nativeColliderObject && this._nativeColliderObject.setRollingFriction(value);
  21265. });
  21266. /**
  21267. *设置用于连续碰撞检测(CCD)的速度阈值,当物体移动速度小于该值时不进行CCD检测,防止快速移动物体(例如:子弹)错误的穿过其它物体,0表示禁止。
  21268. *@param value 连续碰撞检测(CCD)的速度阈值。
  21269. */
  21270. /**
  21271. *获取用于连续碰撞检测(CCD)的速度阈值,当物体移动速度小于该值时不进行CCD检测,防止快速移动物体(例如:子弹)错误的穿过其它物体,0表示禁止。
  21272. *@return 连续碰撞检测(CCD)的速度阈值。
  21273. */
  21274. __getset(0,__proto,'ccdMotionThreshold',function(){
  21275. return this._ccdMotionThreshold;
  21276. },function(value){
  21277. this._ccdMotionThreshold=value;
  21278. this._nativeColliderObject && this._nativeColliderObject.setCcdMotionThreshold(value);
  21279. });
  21280. /**
  21281. *设置用于进入连续碰撞检测(CCD)范围的球半径。
  21282. *@param 球半径。
  21283. */
  21284. /**
  21285. *获取用于进入连续碰撞检测(CCD)范围的球半径。
  21286. *@return 球半径。
  21287. */
  21288. __getset(0,__proto,'ccdSweptSphereRadius',function(){
  21289. return this._ccdSweptSphereRadius;
  21290. },function(value){
  21291. this._ccdSweptSphereRadius=value;
  21292. this._nativeColliderObject && this._nativeColliderObject.setCcdSweptSphereRadius(value);
  21293. });
  21294. /**
  21295. *设置所属碰撞组。
  21296. *@param 所属碰撞组。
  21297. */
  21298. /**
  21299. *获取所属碰撞组。
  21300. *@return 所属碰撞组。
  21301. */
  21302. __getset(0,__proto,'collisionGroup',function(){
  21303. return this._collisionGroup;
  21304. },function(value){
  21305. if (this._collisionGroup!==value){
  21306. this._collisionGroup=value;
  21307. if (this._simulation && this._colliderShape && this._enabled){
  21308. this._removeFromSimulation();
  21309. this._addToSimulation();
  21310. }
  21311. }
  21312. });
  21313. /**
  21314. *获取模拟器。
  21315. *@return 模拟器。
  21316. */
  21317. __getset(0,__proto,'simulation',function(){
  21318. return this._simulation;
  21319. });
  21320. /**
  21321. *设置碰撞形状。
  21322. */
  21323. /**
  21324. *获取碰撞形状。
  21325. */
  21326. __getset(0,__proto,'colliderShape',function(){
  21327. return this._colliderShape;
  21328. },function(value){
  21329. var lastColliderShape=this._colliderShape;
  21330. if (lastColliderShape){
  21331. lastColliderShape._attatched=false;
  21332. lastColliderShape._attatchedCollisionObject=null;
  21333. }
  21334. this._colliderShape=value;
  21335. if (value){
  21336. if (value._attatched){
  21337. throw "PhysicsComponent: this shape has attatched to other entity.";
  21338. }else {
  21339. value._attatched=true;
  21340. value._attatchedCollisionObject=this;
  21341. }
  21342. if (this._nativeColliderObject){
  21343. this._nativeColliderObject.setCollisionShape(value._nativeShape);
  21344. var canInSimulation=this._simulation && this._enabled;
  21345. (canInSimulation && lastColliderShape)&& (this._removeFromSimulation());
  21346. this._onShapeChange(value);
  21347. if (canInSimulation){
  21348. this._derivePhysicsTransformation(true);
  21349. this._addToSimulation();
  21350. }
  21351. }
  21352. }else {
  21353. if (this._simulation && this._enabled)
  21354. lastColliderShape && this._removeFromSimulation();
  21355. }
  21356. });
  21357. /**
  21358. *@inheritDoc
  21359. */
  21360. __getset(0,__proto,'enabled',_super.prototype._$get_enabled,function(value){
  21361. if (this._simulation && this._colliderShape){
  21362. if (value){
  21363. this._derivePhysicsTransformation(true);
  21364. this._addToSimulation();
  21365. }else {
  21366. this._removeFromSimulation();
  21367. }
  21368. }
  21369. Laya.superSet(Component,this,'enabled',value);
  21370. });
  21371. /**
  21372. *设置可碰撞的碰撞组。
  21373. *@param 可碰撞组。
  21374. */
  21375. /**
  21376. *获取可碰撞的碰撞组。
  21377. *@return 可碰撞组。
  21378. */
  21379. __getset(0,__proto,'canCollideWith',function(){
  21380. return this._canCollideWith;
  21381. },function(value){
  21382. if (this._canCollideWith!==value){
  21383. this._canCollideWith=value;
  21384. if (this._simulation && this._colliderShape && this._enabled){
  21385. this._removeFromSimulation();
  21386. this._addToSimulation();
  21387. }
  21388. }
  21389. });
  21390. PhysicsComponent._createAffineTransformationArray=function(tranX,tranY,tranZ,rotX,rotY,rotZ,rotW,scale,outE){
  21391. var x2=rotX+rotX,y2=rotY+rotY,z2=rotZ+rotZ;
  21392. var xx=rotX *x2,xy=rotX *y2,xz=rotX *z2,yy=rotY *y2,yz=rotY *z2,zz=rotZ *z2;
  21393. var wx=rotW *x2,wy=rotW *y2,wz=rotW *z2,sx=scale[0],sy=scale[1],sz=scale[2];
  21394. outE[0]=(1-(yy+zz))*sx;
  21395. outE[1]=(xy+wz)*sx;
  21396. outE[2]=(xz-wy)*sx;
  21397. outE[3]=0;
  21398. outE[4]=(xy-wz)*sy;
  21399. outE[5]=(1-(xx+zz))*sy;
  21400. outE[6]=(yz+wx)*sy;
  21401. outE[7]=0;
  21402. outE[8]=(xz+wy)*sz;
  21403. outE[9]=(yz-wx)*sz;
  21404. outE[10]=(1-(xx+yy))*sz;
  21405. outE[11]=0;
  21406. outE[12]=tranX;
  21407. outE[13]=tranY;
  21408. outE[14]=tranZ;
  21409. outE[15]=1;
  21410. }
  21411. PhysicsComponent.physicVector3TransformQuat=function(source,qx,qy,qz,qw,out){
  21412. var x=source.x,y=source.y,z=source.z,
  21413. 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;
  21414. out.x=ix *qw+iw *-qx+iy *-qz-iz *-qy;
  21415. out.y=iy *qw+iw *-qy+iz *-qx-ix *-qz;
  21416. out.z=iz *qw+iw *-qz+ix *-qy-iy *-qx;
  21417. }
  21418. PhysicsComponent.physicQuaternionMultiply=function(lx,ly,lz,lw,right,out){
  21419. var rx=right.x;
  21420. var ry=right.y;
  21421. var rz=right.z;
  21422. var rw=right.w;
  21423. var a=(ly *rz-lz *ry);
  21424. var b=(lz *rx-lx *rz);
  21425. var c=(lx *ry-ly *rx);
  21426. var d=(lx *rx+ly *ry+lz *rz);
  21427. out.x=(lx *rw+rx *lw)+a;
  21428. out.y=(ly *rw+ry *lw)+b;
  21429. out.z=(lz *rw+rz *lw)+c;
  21430. out.w=lw *rw-d;
  21431. }
  21432. PhysicsComponent.ACTIVATIONSTATE_ACTIVE_TAG=1;
  21433. PhysicsComponent.ACTIVATIONSTATE_ISLAND_SLEEPING=2;
  21434. PhysicsComponent.ACTIVATIONSTATE_WANTS_DEACTIVATION=3;
  21435. PhysicsComponent.ACTIVATIONSTATE_DISABLE_DEACTIVATION=4;
  21436. PhysicsComponent.ACTIVATIONSTATE_DISABLE_SIMULATION=5;
  21437. PhysicsComponent.COLLISIONFLAGS_STATIC_OBJECT=1;
  21438. PhysicsComponent.COLLISIONFLAGS_KINEMATIC_OBJECT=2;
  21439. PhysicsComponent.COLLISIONFLAGS_NO_CONTACT_RESPONSE=4;
  21440. PhysicsComponent.COLLISIONFLAGS_CUSTOM_MATERIAL_CALLBACK=8;
  21441. PhysicsComponent.COLLISIONFLAGS_CHARACTER_OBJECT=16;
  21442. PhysicsComponent.COLLISIONFLAGS_DISABLE_VISUALIZE_OBJECT=32;
  21443. PhysicsComponent.COLLISIONFLAGS_DISABLE_SPU_COLLISION_PROCESSING=64;
  21444. PhysicsComponent._physicObjectsMap={};
  21445. PhysicsComponent._addUpdateList=true;
  21446. __static(PhysicsComponent,
  21447. ['_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);}
  21448. ]);
  21449. return PhysicsComponent;
  21450. })(Component)
  21451. /**
  21452. *<code>IndexBuffer3D</code> 类用于创建索引缓冲。
  21453. */
  21454. //class laya.d3.graphics.IndexBuffer3D extends laya.webgl.utils.Buffer
  21455. var IndexBuffer3D=(function(_super){
  21456. function IndexBuffer3D(indexType,indexCount,bufferUsage,canRead){
  21457. /**@private */
  21458. this._indexType=null;
  21459. /**@private */
  21460. this._indexTypeByteCount=0;
  21461. /**@private */
  21462. this._indexCount=0;
  21463. /**@private */
  21464. this._canRead=false;
  21465. (bufferUsage===void 0)&& (bufferUsage=0x88E4);
  21466. (canRead===void 0)&& (canRead=false);
  21467. IndexBuffer3D.__super.call(this);
  21468. this._indexType=indexType;
  21469. this._indexCount=indexCount;
  21470. this._bufferUsage=bufferUsage;
  21471. this._bufferType=/*laya.webgl.WebGLContext.ELEMENT_ARRAY_BUFFER*/0x8893;
  21472. this._canRead=canRead;
  21473. var byteLength=0;
  21474. if (indexType==/*CLASS CONST:laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort")
  21475. this._indexTypeByteCount=2;
  21476. else if (indexType==/*CLASS CONST:laya.d3.graphics.IndexBuffer3D.INDEXTYPE_UBYTE*/"ubyte")
  21477. this._indexTypeByteCount=1;
  21478. else
  21479. throw new Error("unidentification index type.");
  21480. byteLength=this._indexTypeByteCount *indexCount;
  21481. this._byteLength=byteLength;
  21482. var curBufSta=BufferStateBase._curBindedBufferState;
  21483. if (curBufSta){
  21484. if (curBufSta._bindedIndexBuffer===this){
  21485. LayaGL.instance.bufferData(this._bufferType,byteLength,this._bufferUsage);
  21486. }else {
  21487. curBufSta.unBind();
  21488. this.bind();
  21489. LayaGL.instance.bufferData(this._bufferType,byteLength,this._bufferUsage);
  21490. curBufSta.bind();
  21491. }
  21492. }else {
  21493. this.bind();
  21494. LayaGL.instance.bufferData(this._bufferType,byteLength,this._bufferUsage);
  21495. }
  21496. if (canRead){
  21497. if (indexType==/*CLASS CONST:laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort")
  21498. this._buffer=new Uint16Array(indexCount);
  21499. else if (indexType==/*CLASS CONST:laya.d3.graphics.IndexBuffer3D.INDEXTYPE_UBYTE*/"ubyte")
  21500. this._buffer=new Uint8Array(indexCount);
  21501. }
  21502. }
  21503. __class(IndexBuffer3D,'laya.d3.graphics.IndexBuffer3D',_super);
  21504. var __proto=IndexBuffer3D.prototype;
  21505. /**
  21506. *@inheritDoc
  21507. */
  21508. __proto._bindForVAO=function(){
  21509. if (BufferStateBase._curBindedBufferState){
  21510. LayaGL.instance.bindBuffer(/*laya.webgl.WebGLContext.ELEMENT_ARRAY_BUFFER*/0x8893,this._glBuffer);
  21511. }else {
  21512. throw "IndexBuffer3D: must bind current BufferState.";
  21513. }
  21514. }
  21515. /**
  21516. *@inheritDoc
  21517. */
  21518. __proto.bind=function(){
  21519. if (BufferStateBase._curBindedBufferState){
  21520. throw "IndexBuffer3D: must unbind current BufferState.";
  21521. }else {
  21522. if (Buffer._bindedIndexBuffer!==this._glBuffer){
  21523. LayaGL.instance.bindBuffer(/*laya.webgl.WebGLContext.ELEMENT_ARRAY_BUFFER*/0x8893,this._glBuffer);
  21524. Buffer._bindedIndexBuffer=this._glBuffer;
  21525. return true;
  21526. }else {
  21527. return false;
  21528. }
  21529. }
  21530. }
  21531. /**
  21532. *设置数据。
  21533. *@param data 索引数据。
  21534. *@param bufferOffset 索引缓冲中的偏移。
  21535. *@param dataStartIndex 索引数据的偏移。
  21536. *@param dataCount 索引数据的数量。
  21537. */
  21538. __proto.setData=function(data,bufferOffset,dataStartIndex,dataCount){
  21539. (bufferOffset===void 0)&& (bufferOffset=0);
  21540. (dataStartIndex===void 0)&& (dataStartIndex=0);
  21541. (dataCount===void 0)&& (dataCount=4294967295);
  21542. var byteCount=0;
  21543. if (this._indexType==/*CLASS CONST:laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort"){
  21544. byteCount=2;
  21545. if (dataStartIndex!==0 || dataCount!==4294967295)
  21546. data=new Uint16Array(data.buffer,dataStartIndex *byteCount,dataCount);
  21547. }else if (this._indexType==/*CLASS CONST:laya.d3.graphics.IndexBuffer3D.INDEXTYPE_UBYTE*/"ubyte"){
  21548. byteCount=1;
  21549. if (dataStartIndex!==0 || dataCount!==4294967295)
  21550. data=new Uint8Array(data.buffer,dataStartIndex *byteCount,dataCount);
  21551. };
  21552. var curBufSta=BufferStateBase._curBindedBufferState;
  21553. if (curBufSta){
  21554. if (curBufSta._bindedIndexBuffer===this){
  21555. LayaGL.instance.bufferSubData(this._bufferType,bufferOffset *byteCount,data);
  21556. }else {
  21557. curBufSta.unBind();
  21558. this.bind();
  21559. LayaGL.instance.bufferSubData(this._bufferType,bufferOffset *byteCount,data);
  21560. curBufSta.bind();
  21561. }
  21562. }else {
  21563. this.bind();
  21564. LayaGL.instance.bufferSubData(this._bufferType,bufferOffset *byteCount,data);
  21565. }
  21566. if (this._canRead){
  21567. if (bufferOffset!==0 || dataStartIndex!==0 || dataCount!==4294967295){
  21568. var maxLength=this._buffer.length-bufferOffset;
  21569. if (dataCount > maxLength)
  21570. dataCount=maxLength;
  21571. for (var i=0;i < dataCount;i++)
  21572. this._buffer[bufferOffset+i]=data[i];
  21573. }else {
  21574. this._buffer=data;
  21575. }
  21576. }
  21577. }
  21578. /**
  21579. *获取索引数据。
  21580. *@return 索引数据。
  21581. */
  21582. __proto.getData=function(){
  21583. if (this._canRead)
  21584. return this._buffer;
  21585. else
  21586. throw new Error("Can't read data from VertexBuffer with only write flag!");
  21587. }
  21588. /**
  21589. *@inheritDoc
  21590. */
  21591. __proto.destroy=function(){
  21592. _super.prototype.destroy.call(this);
  21593. this._buffer=null;
  21594. }
  21595. /**
  21596. *获取索引类型。
  21597. *@return 索引类型。
  21598. */
  21599. __getset(0,__proto,'indexType',function(){
  21600. return this._indexType;
  21601. });
  21602. /**
  21603. *获取索引类型字节数量。
  21604. *@return 索引类型字节数量。
  21605. */
  21606. __getset(0,__proto,'indexTypeByteCount',function(){
  21607. return this._indexTypeByteCount;
  21608. });
  21609. /**
  21610. *获取索引个数。
  21611. *@return 索引个数。
  21612. */
  21613. __getset(0,__proto,'indexCount',function(){
  21614. return this._indexCount;
  21615. });
  21616. /**
  21617. *获取是否可读。
  21618. *@return 是否可读。
  21619. */
  21620. __getset(0,__proto,'canRead',function(){
  21621. return this._canRead;
  21622. });
  21623. IndexBuffer3D.INDEXTYPE_UBYTE="ubyte";
  21624. IndexBuffer3D.INDEXTYPE_USHORT="ushort";
  21625. return IndexBuffer3D;
  21626. })(Buffer)
  21627. /**
  21628. *<code>ConstraintComponent</code> 类用于创建约束的父类。
  21629. */
  21630. //class laya.d3.physics.constraints.ConstraintComponent extends laya.components.Component
  21631. var ConstraintComponent=(function(_super){
  21632. function ConstraintComponent(){
  21633. /**@private */
  21634. this._nativeConstraint=null;
  21635. /**@private */
  21636. this._breakingImpulseThreshold=NaN;
  21637. /**@private */
  21638. this._connectedBody=null;
  21639. /**@private */
  21640. this._feedbackEnabled=false;
  21641. ConstraintComponent.__super.call(this);
  21642. }
  21643. __class(ConstraintComponent,'laya.d3.physics.constraints.ConstraintComponent',_super);
  21644. var __proto=ConstraintComponent.prototype;
  21645. /**
  21646. *@inheritDoc
  21647. */
  21648. __proto._onDestroy=function(){
  21649. var physics3D=Laya3D._physics3D;
  21650. physics3D.destroy(this._nativeConstraint);
  21651. this._nativeConstraint=null;
  21652. }
  21653. /**
  21654. *设置打破冲力阈值。
  21655. *@param value 打破冲力阈值。
  21656. */
  21657. /**
  21658. *获取打破冲力阈值。
  21659. *@return 打破冲力阈值。
  21660. */
  21661. __getset(0,__proto,'breakingImpulseThreshold',function(){
  21662. return this._breakingImpulseThreshold;
  21663. },function(value){
  21664. this._nativeConstraint.BreakingImpulseThreshold=value;
  21665. this._breakingImpulseThreshold=value;
  21666. });
  21667. /**
  21668. *@inheritDoc
  21669. */
  21670. /**
  21671. *@inheritDoc
  21672. */
  21673. __getset(0,__proto,'enabled',function(){
  21674. return Laya.superGet(Component,this,'enabled');
  21675. },function(value){
  21676. this._nativeConstraint.IsEnabled=value;
  21677. Laya.superSet(Component,this,'enabled',value);
  21678. });
  21679. /**
  21680. *获取应用的冲力。
  21681. */
  21682. __getset(0,__proto,'appliedImpulse',function(){
  21683. if (!this._feedbackEnabled){
  21684. this._nativeConstraint.EnableFeedback(true);
  21685. this._feedbackEnabled=true;
  21686. }
  21687. return this._nativeConstraint.AppliedImpulse;
  21688. });
  21689. /**
  21690. *设置已连接刚体。
  21691. *@param value 已连接刚体。
  21692. */
  21693. /**
  21694. *获取已连接的刚体。
  21695. *@return 已连接刚体。
  21696. */
  21697. __getset(0,__proto,'connectedBody',function(){
  21698. return this._connectedBody;
  21699. },function(value){
  21700. this._connectedBody=value;
  21701. });
  21702. return ConstraintComponent;
  21703. })(Component)
  21704. /**
  21705. *<code>VertexBuffer3D</code> 类用于创建顶点缓冲。
  21706. */
  21707. //class laya.d3.graphics.VertexBuffer3D extends laya.webgl.utils.Buffer
  21708. var VertexBuffer3D=(function(_super){
  21709. function VertexBuffer3D(byteLength,bufferUsage,canRead,dateType){
  21710. /**@private */
  21711. this._vertexCount=0;
  21712. /**@private */
  21713. this._canRead=false;
  21714. /**@private */
  21715. this._dataType=0;
  21716. /**@private */
  21717. this._vertexDeclaration=null;
  21718. (canRead===void 0)&& (canRead=false);
  21719. (dateType===void 0)&& (dateType=0);
  21720. VertexBuffer3D.__super.call(this);
  21721. this._vertexCount=-1;
  21722. this._bufferUsage=bufferUsage;
  21723. this._bufferType=/*laya.webgl.WebGLContext.ARRAY_BUFFER*/0x8892;
  21724. this._canRead=canRead;
  21725. this._dataType=dateType;
  21726. this._byteLength=byteLength;
  21727. this.bind();
  21728. LayaGL.instance.bufferData(this._bufferType,this._byteLength,this._bufferUsage);
  21729. if (canRead){
  21730. switch (dateType){
  21731. case 0:
  21732. this._buffer=new Float32Array(byteLength / 4);
  21733. break ;
  21734. case 1:
  21735. this._buffer=new Uint8Array(byteLength);
  21736. break ;
  21737. }
  21738. }
  21739. }
  21740. __class(VertexBuffer3D,'laya.d3.graphics.VertexBuffer3D',_super);
  21741. var __proto=VertexBuffer3D.prototype;
  21742. /**
  21743. *@inheritDoc
  21744. */
  21745. __proto.bind=function(){
  21746. if (Buffer._bindedVertexBuffer!==this._glBuffer){
  21747. LayaGL.instance.bindBuffer(/*laya.webgl.WebGLContext.ARRAY_BUFFER*/0x8892,this._glBuffer);
  21748. Buffer._bindedVertexBuffer=this._glBuffer;
  21749. return true;
  21750. }else {
  21751. return false;
  21752. }
  21753. }
  21754. /**
  21755. *设置数据。
  21756. *@param data 顶点数据。
  21757. *@param bufferOffset 顶点缓冲中的偏移。
  21758. *@param dataStartIndex 顶点数据的偏移。
  21759. *@param dataCount 顶点数据的数量。
  21760. */
  21761. __proto.setData=function(data,bufferOffset,dataStartIndex,dataCount){
  21762. (bufferOffset===void 0)&& (bufferOffset=0);
  21763. (dataStartIndex===void 0)&& (dataStartIndex=0);
  21764. (dataCount===void 0)&& (dataCount=4294967295);
  21765. this.bind();
  21766. var needSubData=dataStartIndex!==0 || dataCount!==4294967295;
  21767. if (needSubData){
  21768. switch (this._dataType){
  21769. case 0:
  21770. data=new Float32Array(data.buffer,dataStartIndex *4,dataCount);
  21771. break ;
  21772. case 1:
  21773. data=new Uint8Array(data.buffer,dataStartIndex,dataCount);
  21774. break ;
  21775. }
  21776. }
  21777. switch (this._dataType){
  21778. case 0:
  21779. LayaGL.instance.bufferSubData(this._bufferType,bufferOffset *4,data);
  21780. break ;
  21781. case 1:
  21782. LayaGL.instance.bufferSubData(this._bufferType,bufferOffset,data);
  21783. break ;
  21784. }
  21785. if (this._canRead)
  21786. this._buffer.set(data,bufferOffset);
  21787. }
  21788. /**
  21789. *获取顶点数据。
  21790. *@return 顶点数据。
  21791. */
  21792. __proto.getData=function(){
  21793. if (this._canRead)
  21794. return this._buffer;
  21795. else
  21796. throw new Error("Can't read data from VertexBuffer with only write flag!");
  21797. }
  21798. /**
  21799. *@inheritDoc
  21800. */
  21801. __proto.destroy=function(){
  21802. _super.prototype.destroy.call(this);
  21803. this._buffer=null;
  21804. this._vertexDeclaration=null;
  21805. }
  21806. /**
  21807. *获取顶点声明。
  21808. */
  21809. /**
  21810. *获取顶点声明。
  21811. */
  21812. __getset(0,__proto,'vertexDeclaration',function(){
  21813. return this._vertexDeclaration;
  21814. },function(value){
  21815. if (this._vertexDeclaration!==value){
  21816. this._vertexDeclaration=value;
  21817. this._vertexCount=value ? this._byteLength / value.vertexStride :-1;
  21818. }
  21819. });
  21820. /**
  21821. *获取顶点个数。
  21822. *@return 顶点个数。
  21823. */
  21824. __getset(0,__proto,'vertexCount',function(){
  21825. return this._vertexCount;
  21826. });
  21827. /**
  21828. *获取是否可读。
  21829. *@return 是否可读。
  21830. */
  21831. __getset(0,__proto,'canRead',function(){
  21832. return this._canRead;
  21833. });
  21834. VertexBuffer3D.DATATYPE_FLOAT32ARRAY=0;
  21835. VertexBuffer3D.DATATYPE_UINT8ARRAY=1;
  21836. return VertexBuffer3D;
  21837. })(Buffer)
  21838. /**
  21839. *<code>Script3D</code> 类用于创建脚本的父类,该类为抽象类,不允许实例。
  21840. */
  21841. //class laya.d3.component.Script3D extends laya.components.Component
  21842. var Script3D=(function(_super){
  21843. function Script3D(){
  21844. Script3D.__super.call(this);;
  21845. }
  21846. __class(Script3D,'laya.d3.component.Script3D',_super);
  21847. var __proto=Script3D.prototype;
  21848. /**
  21849. *@private
  21850. */
  21851. __proto._checkProcessTriggers=function(){
  21852. var prototype=laya.d3.component.Script3D.prototype;
  21853. if (this.onTriggerEnter!==prototype.onTriggerEnter)
  21854. return true;
  21855. if (this.onTriggerStay!==prototype.onTriggerStay)
  21856. return true;
  21857. if (this.onTriggerExit!==prototype.onTriggerExit)
  21858. return true;
  21859. return false;
  21860. }
  21861. /**
  21862. *@private
  21863. */
  21864. __proto._checkProcessCollisions=function(){
  21865. var prototype=laya.d3.component.Script3D.prototype;
  21866. if (this.onCollisionEnter!==prototype.onCollisionEnter)
  21867. return true;
  21868. if (this.onCollisionStay!==prototype.onCollisionStay)
  21869. return true;
  21870. if (this.onCollisionExit!==prototype.onCollisionExit)
  21871. return true;
  21872. return false;
  21873. }
  21874. /**
  21875. *@inheritDoc
  21876. */
  21877. __proto._onAwake=function(){
  21878. this.onAwake();
  21879. if (this.onStart!==laya.d3.component.Script3D.prototype.onStart)
  21880. Laya.startTimer.callLater(this,this.onStart);
  21881. }
  21882. /**
  21883. *@inheritDoc
  21884. */
  21885. __proto._onEnable=function(){
  21886. (this.owner)._scene._scriptPool.add(this);
  21887. var proto=laya.d3.component.Script3D.prototype;
  21888. if (this.onKeyDown!==proto.onKeyDown){
  21889. Laya.stage.on(/*laya.events.Event.KEY_DOWN*/"keydown",this,this.onKeyDown);
  21890. }
  21891. if (this.onKeyPress!==proto.onKeyPress){
  21892. Laya.stage.on(/*laya.events.Event.KEY_PRESS*/"keypress",this,this.onKeyUp);
  21893. }
  21894. if (this.onKeyUp!==proto.onKeyUp){
  21895. Laya.stage.on(/*laya.events.Event.KEY_UP*/"keyup",this,this.onKeyUp);
  21896. }
  21897. }
  21898. /**
  21899. *@inheritDoc
  21900. */
  21901. __proto._onDisable=function(){
  21902. (this.owner)._scene._scriptPool.remove(this);
  21903. this.owner.offAllCaller(this);
  21904. Laya.stage.offAllCaller(this);
  21905. }
  21906. /**
  21907. *@inheritDoc
  21908. */
  21909. __proto._isScript=function(){
  21910. return true;
  21911. }
  21912. /**
  21913. *@inheritDoc
  21914. */
  21915. __proto._onAdded=function(){
  21916. var sprite=this.owner;
  21917. var scripts=sprite._scripts;
  21918. scripts || (sprite._scripts=scripts=[]);
  21919. scripts.push(this);
  21920. if (!sprite._needProcessCollisions)
  21921. sprite._needProcessCollisions=this._checkProcessCollisions();
  21922. if (!sprite._needProcessTriggers)
  21923. sprite._needProcessTriggers=this._checkProcessTriggers();
  21924. }
  21925. /**
  21926. *@inheritDoc
  21927. */
  21928. __proto._onDestroy=function(){
  21929. var scripts=(this.owner)._scripts;
  21930. scripts.splice(scripts.indexOf(this),1);
  21931. var sprite=this.owner;
  21932. sprite._needProcessTriggers=false;
  21933. for (var i=0,n=scripts.length;i < n;i++){
  21934. if (scripts[i]._checkProcessTriggers()){
  21935. sprite._needProcessTriggers=true;
  21936. break ;
  21937. }
  21938. }
  21939. sprite._needProcessCollisions=false;
  21940. for (i=0,n=scripts.length;i < n;i++){
  21941. if (scripts[i]._checkProcessCollisions()){
  21942. sprite._needProcessCollisions=true;
  21943. break ;
  21944. }
  21945. }
  21946. this.onDestroy();
  21947. }
  21948. /**
  21949. *创建后只执行一次
  21950. *此方法为虚方法,使用时重写覆盖即可
  21951. */
  21952. __proto.onAwake=function(){}
  21953. /**
  21954. *每次启动后执行
  21955. *此方法为虚方法,使用时重写覆盖即可
  21956. */
  21957. __proto.onEnable=function(){}
  21958. /**
  21959. *第一次执行update之前执行,只会执行一次
  21960. *此方法为虚方法,使用时重写覆盖即可
  21961. */
  21962. __proto.onStart=function(){}
  21963. /**
  21964. *开始触发时执行
  21965. *此方法为虚方法,使用时重写覆盖即可
  21966. */
  21967. __proto.onTriggerEnter=function(other){}
  21968. /**
  21969. *持续触发时执行
  21970. *此方法为虚方法,使用时重写覆盖即可
  21971. */
  21972. __proto.onTriggerStay=function(other){}
  21973. /**
  21974. *结束触发时执行
  21975. *此方法为虚方法,使用时重写覆盖即可
  21976. */
  21977. __proto.onTriggerExit=function(other){}
  21978. /**
  21979. *开始碰撞时执行
  21980. *此方法为虚方法,使用时重写覆盖即可
  21981. */
  21982. __proto.onCollisionEnter=function(collision){}
  21983. /**
  21984. *持续碰撞时执行
  21985. *此方法为虚方法,使用时重写覆盖即可
  21986. */
  21987. __proto.onCollisionStay=function(collision){}
  21988. /**
  21989. *结束碰撞时执行
  21990. *此方法为虚方法,使用时重写覆盖即可
  21991. */
  21992. __proto.onCollisionExit=function(collision){}
  21993. /**
  21994. *鼠标按下时执行
  21995. *此方法为虚方法,使用时重写覆盖即可
  21996. */
  21997. __proto.onMouseDown=function(){}
  21998. /**
  21999. *鼠标拖拽时执行
  22000. *此方法为虚方法,使用时重写覆盖即可
  22001. */
  22002. __proto.onMouseDrag=function(){}
  22003. /**
  22004. *鼠标点击时执行
  22005. *此方法为虚方法,使用时重写覆盖即可
  22006. */
  22007. __proto.onMouseClick=function(){}
  22008. /**
  22009. *鼠标弹起时执行
  22010. *此方法为虚方法,使用时重写覆盖即可
  22011. */
  22012. __proto.onMouseUp=function(){}
  22013. /**
  22014. *鼠标进入时执行
  22015. *此方法为虚方法,使用时重写覆盖即可
  22016. */
  22017. __proto.onMouseEnter=function(){}
  22018. /**
  22019. *鼠标经过时执行
  22020. *此方法为虚方法,使用时重写覆盖即可
  22021. */
  22022. __proto.onMouseOver=function(){}
  22023. /**
  22024. *鼠标离开时执行
  22025. *此方法为虚方法,使用时重写覆盖即可
  22026. */
  22027. __proto.onMouseOut=function(){}
  22028. /**
  22029. *键盘按下时执行
  22030. *此方法为虚方法,使用时重写覆盖即可
  22031. */
  22032. __proto.onKeyDown=function(e){}
  22033. /**
  22034. *键盘产生一个字符时执行
  22035. *此方法为虚方法,使用时重写覆盖即可
  22036. */
  22037. __proto.onKeyPress=function(e){}
  22038. /**
  22039. *键盘抬起时执行
  22040. *此方法为虚方法,使用时重写覆盖即可
  22041. */
  22042. __proto.onKeyUp=function(e){}
  22043. /**
  22044. *每帧更新时执行
  22045. *此方法为虚方法,使用时重写覆盖即可
  22046. */
  22047. __proto.onUpdate=function(){}
  22048. /**
  22049. *每帧更新时执行,在update之后执行
  22050. *此方法为虚方法,使用时重写覆盖即可
  22051. */
  22052. __proto.onLateUpdate=function(){}
  22053. /**
  22054. *渲染之前执行
  22055. *此方法为虚方法,使用时重写覆盖即可
  22056. */
  22057. __proto.onPreRender=function(){}
  22058. /**
  22059. *渲染之后执行
  22060. *此方法为虚方法,使用时重写覆盖即可
  22061. */
  22062. __proto.onPostRender=function(){}
  22063. /**
  22064. *禁用时执行
  22065. *此方法为虚方法,使用时重写覆盖即可
  22066. */
  22067. __proto.onDisable=function(){}
  22068. /**
  22069. *销毁时执行
  22070. *此方法为虚方法,使用时重写覆盖即可
  22071. */
  22072. __proto.onDestroy=function(){}
  22073. /**
  22074. *@inheritDoc
  22075. */
  22076. __getset(0,__proto,'isSingleton',function(){
  22077. return false;
  22078. });
  22079. return Script3D;
  22080. })(Component)
  22081. /**
  22082. *<code>Transform3D</code> 类用于实现3D变换。
  22083. */
  22084. //class laya.d3.core.Transform3D extends laya.events.EventDispatcher
  22085. var Transform3D=(function(_super){
  22086. function Transform3D(owner){
  22087. /**@private */
  22088. this._owner=null;
  22089. /**@private */
  22090. this._children=null;
  22091. /**@private */
  22092. this._parent=null;
  22093. /**@private */
  22094. this._dummy=null;
  22095. /**@private */
  22096. this._transformFlag=0;
  22097. Transform3D.__super.call(this);
  22098. this._localPosition=new Vector3(0,0,0);
  22099. this._localRotation=new Quaternion(0,0,0,1);
  22100. this._localScale=new Vector3(1,1,1);
  22101. this._localRotationEuler=new Vector3(0,0,0);
  22102. this._localMatrix=new Matrix4x4();
  22103. this._position=new Vector3(0,0,0);
  22104. this._rotation=new Quaternion(0,0,0,1);
  22105. this._scale=new Vector3(1,1,1);
  22106. this._rotationEuler=new Vector3(0,0,0);
  22107. this._worldMatrix=new Matrix4x4();
  22108. this._owner=owner;
  22109. this._children=[];
  22110. this._setTransformFlag(0x01 | 0x02 | 0x04,false);
  22111. this._setTransformFlag(0x08 | 0x10 | 0x80 | 0x20 | 0x40,true);
  22112. }
  22113. __class(Transform3D,'laya.d3.core.Transform3D',_super);
  22114. var __proto=Transform3D.prototype;
  22115. /**
  22116. *@private
  22117. */
  22118. __proto._setTransformFlag=function(type,value){
  22119. if (value)
  22120. this._transformFlag |=type;
  22121. else
  22122. this._transformFlag &=~type;
  22123. }
  22124. /**
  22125. *@private
  22126. */
  22127. __proto._getTransformFlag=function(type){
  22128. return (this._transformFlag & type)!=0;
  22129. }
  22130. /**
  22131. *@private
  22132. */
  22133. __proto._setParent=function(value){
  22134. if (this._parent!==value){
  22135. if (this._parent){
  22136. var parentChilds=this._parent._children;
  22137. var index=parentChilds.indexOf(this);
  22138. parentChilds.splice(index,1);
  22139. }
  22140. if (value){
  22141. value._children.push(this);
  22142. (value)&& (this._onWorldTransform());
  22143. }
  22144. this._parent=value;
  22145. }
  22146. }
  22147. /**
  22148. *@private
  22149. */
  22150. __proto._updateLocalMatrix=function(){
  22151. Matrix4x4.createAffineTransformation(this._localPosition,this.localRotation,this._localScale,this._localMatrix);
  22152. }
  22153. /**
  22154. *@private
  22155. */
  22156. __proto._onWorldPositionRotationTransform=function(){
  22157. if (!this._getTransformFlag(0x40)|| !this._getTransformFlag(0x08)|| !this._getTransformFlag(0x10)|| !this._getTransformFlag(0x80)){
  22158. this._setTransformFlag(0x40 | 0x08 | 0x10 | 0x80,true);
  22159. this.event(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this._transformFlag);
  22160. for (var i=0,n=this._children.length;i < n;i++)
  22161. this._children[i]._onWorldPositionRotationTransform();
  22162. }
  22163. }
  22164. /**
  22165. *@private
  22166. */
  22167. __proto._onWorldPositionScaleTransform=function(){
  22168. if (!this._getTransformFlag(0x40)|| !this._getTransformFlag(0x08)|| !this._getTransformFlag(0x20)){
  22169. this._setTransformFlag(0x40 | 0x08 | 0x20,true);
  22170. this.event(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this._transformFlag);
  22171. for (var i=0,n=this._children.length;i < n;i++)
  22172. this._children[i]._onWorldPositionScaleTransform();
  22173. }
  22174. }
  22175. /**
  22176. *@private
  22177. */
  22178. __proto._onWorldPositionTransform=function(){
  22179. if (!this._getTransformFlag(0x40)|| !this._getTransformFlag(0x08)){
  22180. this._setTransformFlag(0x40 | 0x08,true);
  22181. this.event(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this._transformFlag);
  22182. for (var i=0,n=this._children.length;i < n;i++)
  22183. this._children[i]._onWorldPositionTransform();
  22184. }
  22185. }
  22186. /**
  22187. *@private
  22188. */
  22189. __proto._onWorldRotationTransform=function(){
  22190. if (!this._getTransformFlag(0x40)|| !this._getTransformFlag(0x10)|| !this._getTransformFlag(0x80)){
  22191. this._setTransformFlag(0x40 | 0x10 | 0x80,true);
  22192. this.event(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this._transformFlag);
  22193. for (var i=0,n=this._children.length;i < n;i++)
  22194. this._children[i]._onWorldPositionRotationTransform();
  22195. }
  22196. }
  22197. /**
  22198. *@private
  22199. */
  22200. __proto._onWorldScaleTransform=function(){
  22201. if (!this._getTransformFlag(0x40)|| !this._getTransformFlag(0x20)){
  22202. this._setTransformFlag(0x40 | 0x20,true);
  22203. this.event(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this._transformFlag);
  22204. for (var i=0,n=this._children.length;i < n;i++)
  22205. this._children[i]._onWorldPositionScaleTransform();
  22206. }
  22207. }
  22208. /**
  22209. *@private
  22210. */
  22211. __proto._onWorldTransform=function(){
  22212. if (!this._getTransformFlag(0x40)|| !this._getTransformFlag(0x08)|| !this._getTransformFlag(0x10)|| !this._getTransformFlag(0x80)|| !this._getTransformFlag(0x20)){
  22213. this._setTransformFlag(0x40 | 0x08 | 0x10 | 0x80 | 0x20,true);
  22214. this.event(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this._transformFlag);
  22215. for (var i=0,n=this._children.length;i < n;i++)
  22216. this._children[i]._onWorldTransform();
  22217. }
  22218. }
  22219. /**
  22220. *平移变换。
  22221. *@param translation 移动距离。
  22222. *@param isLocal 是否局部空间。
  22223. */
  22224. __proto.translate=function(translation,isLocal){
  22225. (isLocal===void 0)&& (isLocal=true);
  22226. if (isLocal){
  22227. Matrix4x4.createFromQuaternion(this.localRotation,Transform3D._tempMatrix0);
  22228. Vector3.transformCoordinate(translation,Transform3D._tempMatrix0,Transform3D._tempVector30);
  22229. Vector3.add(this.localPosition,Transform3D._tempVector30,this._localPosition);
  22230. this.localPosition=this._localPosition;
  22231. }else {
  22232. Vector3.add(this.position,translation,this._position);
  22233. this.position=this._position;
  22234. }
  22235. }
  22236. /**
  22237. *旋转变换。
  22238. *@param rotations 旋转幅度。
  22239. *@param isLocal 是否局部空间。
  22240. *@param isRadian 是否弧度制。
  22241. */
  22242. __proto.rotate=function(rotation,isLocal,isRadian){
  22243. (isLocal===void 0)&& (isLocal=true);
  22244. (isRadian===void 0)&& (isRadian=true);
  22245. var rot;
  22246. if (isRadian){
  22247. rot=rotation;
  22248. }else {
  22249. Vector3.scale(rotation,Math.PI / 180.0,Transform3D._tempVector30);
  22250. rot=Transform3D._tempVector30;
  22251. }
  22252. Quaternion.createFromYawPitchRoll(rot.y,rot.x,rot.z,Transform3D._tempQuaternion0);
  22253. if (isLocal){
  22254. Quaternion.multiply(this._localRotation,Transform3D._tempQuaternion0,this._localRotation);
  22255. this.localRotation=this._localRotation;
  22256. }else {
  22257. Quaternion.multiply(Transform3D._tempQuaternion0,this.rotation,this._rotation);
  22258. this.rotation=this._rotation;
  22259. }
  22260. }
  22261. /**
  22262. *获取向前方向。
  22263. *@param 前方向。
  22264. */
  22265. __proto.getForward=function(forward){
  22266. var worldMatElem=this.worldMatrix.elements;
  22267. forward.x=-worldMatElem[8];
  22268. forward.y=-worldMatElem[9];
  22269. forward.z=-worldMatElem[10];
  22270. }
  22271. /**
  22272. *获取向上方向。
  22273. *@param 上方向。
  22274. */
  22275. __proto.getUp=function(up){
  22276. var worldMatElem=this.worldMatrix.elements;
  22277. up.x=worldMatElem[4];
  22278. up.y=worldMatElem[5];
  22279. up.z=worldMatElem[6];
  22280. }
  22281. /**
  22282. *获取向右方向。
  22283. *@param 右方向。
  22284. */
  22285. __proto.getRight=function(right){
  22286. var worldMatElem=this.worldMatrix.elements;
  22287. right.x=worldMatElem[0];
  22288. right.y=worldMatElem[1];
  22289. right.z=worldMatElem[2];
  22290. }
  22291. /**
  22292. *观察目标位置。
  22293. *@param target 观察目标。
  22294. *@param up 向上向量。
  22295. *@param isLocal 是否局部空间。
  22296. */
  22297. __proto.lookAt=function(target,up,isLocal){
  22298. (isLocal===void 0)&& (isLocal=false);
  22299. var eye;
  22300. if (isLocal){
  22301. eye=this._localPosition;
  22302. 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)
  22303. return;
  22304. Quaternion.lookAt(this._localPosition,target,up,this._localRotation);
  22305. this._localRotation.invert(this._localRotation);
  22306. this.localRotation=this._localRotation;
  22307. }else {
  22308. var worldPosition=this.position;
  22309. eye=worldPosition;
  22310. 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)
  22311. return;
  22312. Quaternion.lookAt(worldPosition,target,up,this._rotation);
  22313. this._rotation.invert(this._rotation);
  22314. this.rotation=this._rotation;
  22315. }
  22316. }
  22317. /**
  22318. *@private
  22319. */
  22320. __getset(0,__proto,'_isFrontFaceInvert',function(){
  22321. var scale=this.scale;
  22322. var isInvert=scale.x < 0;
  22323. (scale.y < 0)&& (isInvert=!isInvert);
  22324. (scale.z < 0)&& (isInvert=!isInvert);
  22325. return isInvert;
  22326. });
  22327. /**
  22328. *获取所属精灵。
  22329. */
  22330. __getset(0,__proto,'owner',function(){
  22331. return this._owner;
  22332. });
  22333. /**
  22334. *设置局部位置Y轴分量。
  22335. *@param y 局部位置Y轴分量。
  22336. */
  22337. /**
  22338. *获取局部位置Y轴分量。
  22339. *@return 局部位置Y轴分量。
  22340. */
  22341. __getset(0,__proto,'localPositionY',function(){
  22342. return this._localPosition.y;
  22343. },function(y){
  22344. this._localPosition.y=y;
  22345. this.localPosition=this._localPosition;
  22346. });
  22347. /**
  22348. *设置局部缩放X。
  22349. *@param value 局部缩放X。
  22350. */
  22351. /**
  22352. *获取局部缩放X。
  22353. *@return 局部缩放X。
  22354. */
  22355. __getset(0,__proto,'localScaleX',function(){
  22356. return this._localScale.x;
  22357. },function(value){
  22358. this._localScale.x=value;
  22359. this.localScale=this._localScale;
  22360. });
  22361. /**
  22362. *获取世界矩阵是否需要更新。
  22363. *@return 世界矩阵是否需要更新。
  22364. */
  22365. __getset(0,__proto,'worldNeedUpdate',function(){
  22366. return this._getTransformFlag(0x40);
  22367. });
  22368. /**
  22369. *设置局部位置X轴分量。
  22370. *@param x 局部位置X轴分量。
  22371. */
  22372. /**
  22373. *获取局部位置X轴分量。
  22374. *@return 局部位置X轴分量。
  22375. */
  22376. __getset(0,__proto,'localPositionX',function(){
  22377. return this._localPosition.x;
  22378. },function(x){
  22379. this._localPosition.x=x;
  22380. this.localPosition=this._localPosition;
  22381. });
  22382. /**
  22383. *设置局部位置。
  22384. *@param value 局部位置。
  22385. */
  22386. /**
  22387. *获取局部位置。
  22388. *@return 局部位置。
  22389. */
  22390. __getset(0,__proto,'localPosition',function(){
  22391. return this._localPosition;
  22392. },function(value){
  22393. if (this._localPosition!==value)
  22394. value.cloneTo(this._localPosition);
  22395. this._setTransformFlag(0x04,true);
  22396. this._onWorldPositionTransform();
  22397. });
  22398. /**
  22399. *设置局部位置Z轴分量。
  22400. *@param z 局部位置Z轴分量。
  22401. */
  22402. /**
  22403. *获取局部位置Z轴分量。
  22404. *@return 局部位置Z轴分量。
  22405. */
  22406. __getset(0,__proto,'localPositionZ',function(){
  22407. return this._localPosition.z;
  22408. },function(z){
  22409. this._localPosition.z=z;
  22410. this.localPosition=this._localPosition;
  22411. });
  22412. /**
  22413. *设置局部旋转四元数X分量。
  22414. *@param x 局部旋转四元数X分量。
  22415. */
  22416. /**
  22417. *获取局部旋转四元数X分量。
  22418. *@return 局部旋转四元数X分量。
  22419. */
  22420. __getset(0,__proto,'localRotationX',function(){
  22421. return this.localRotation.x;
  22422. },function(x){
  22423. this._localRotation.x=x;
  22424. this.localRotation=this._localRotation;
  22425. });
  22426. /**
  22427. *设置局部旋转四元数Y分量。
  22428. *@param y 局部旋转四元数Y分量。
  22429. */
  22430. /**
  22431. *获取局部旋转四元数Y分量。
  22432. *@return 局部旋转四元数Y分量。
  22433. */
  22434. __getset(0,__proto,'localRotationY',function(){
  22435. return this.localRotation.y;
  22436. },function(y){
  22437. this._localRotation.y=y;
  22438. this.localRotation=this._localRotation;
  22439. });
  22440. /**
  22441. *设置局部旋转四元数Z分量。
  22442. *@param z 局部旋转四元数Z分量。
  22443. */
  22444. /**
  22445. *获取局部旋转四元数Z分量。
  22446. *@return 局部旋转四元数Z分量。
  22447. */
  22448. __getset(0,__proto,'localRotationZ',function(){
  22449. return this.localRotation.z;
  22450. },function(z){
  22451. this._localRotation.z=z;
  22452. this.localRotation=this._localRotation;
  22453. });
  22454. /**
  22455. *设置局部旋转四元数W分量。
  22456. *@param w 局部旋转四元数W分量。
  22457. */
  22458. /**
  22459. *获取局部旋转四元数W分量。
  22460. *@return 局部旋转四元数W分量。
  22461. */
  22462. __getset(0,__proto,'localRotationW',function(){
  22463. return this.localRotation.w;
  22464. },function(w){
  22465. this._localRotation.w=w;
  22466. this.localRotation=this._localRotation;
  22467. });
  22468. /**
  22469. *设置局部旋转。
  22470. *@param value 局部旋转。
  22471. */
  22472. /**
  22473. *获取局部旋转。
  22474. *@return 局部旋转。
  22475. */
  22476. __getset(0,__proto,'localRotation',function(){
  22477. if (this._getTransformFlag(0x01)){
  22478. var eulerE=this._localRotationEuler;
  22479. Quaternion.createFromYawPitchRoll(eulerE.y / Transform3D._angleToRandin,eulerE.x / Transform3D._angleToRandin,eulerE.z / Transform3D._angleToRandin,this._localRotation);
  22480. this._setTransformFlag(0x01,false);
  22481. }
  22482. return this._localRotation;
  22483. },function(value){
  22484. if (this._localRotation!==value)
  22485. value.cloneTo(this._localRotation);
  22486. this._localRotation.normalize(this._localRotation);
  22487. this._setTransformFlag(0x02 | 0x04,true);
  22488. this._setTransformFlag(0x01,false);
  22489. this._onWorldRotationTransform();
  22490. });
  22491. /**
  22492. *设置局部缩放Y。
  22493. *@param value 局部缩放Y。
  22494. */
  22495. /**
  22496. *获取局部缩放Y。
  22497. *@return 局部缩放Y。
  22498. */
  22499. __getset(0,__proto,'localScaleY',function(){
  22500. return this._localScale.y;
  22501. },function(value){
  22502. this._localScale.y=value;
  22503. this.localScale=this._localScale;
  22504. });
  22505. /**
  22506. *设置局部缩放Z。
  22507. *@param value 局部缩放Z。
  22508. */
  22509. /**
  22510. *获取局部缩放Z。
  22511. *@return 局部缩放Z。
  22512. */
  22513. __getset(0,__proto,'localScaleZ',function(){
  22514. return this._localScale.z;
  22515. },function(value){
  22516. this._localScale.z=value;
  22517. this.localScale=this._localScale;
  22518. });
  22519. /**
  22520. *设置世界位置。
  22521. *@param value 世界位置。
  22522. */
  22523. /**
  22524. *获取世界位置。
  22525. *@return 世界位置。
  22526. */
  22527. __getset(0,__proto,'position',function(){
  22528. if (this._getTransformFlag(0x08)){
  22529. if (this._parent !=null){
  22530. var parentPosition=this._parent.position;
  22531. Vector3.multiply(this._localPosition,this._parent.scale,Transform3D._tempVector30);
  22532. Vector3.transformQuat(Transform3D._tempVector30,this._parent.rotation,Transform3D._tempVector30);
  22533. Vector3.add(parentPosition,Transform3D._tempVector30,this._position);
  22534. }else {
  22535. this._localPosition.cloneTo(this._position);
  22536. }
  22537. this._setTransformFlag(0x08,false);
  22538. }
  22539. return this._position;
  22540. },function(value){
  22541. if (this._parent !=null){
  22542. Vector3.subtract(value,this._parent.position,this._localPosition);
  22543. var parentScale=this._parent.scale;
  22544. var psX=parentScale.x,psY=parentScale.y,psZ=parentScale.z;
  22545. if (psX!==1.0 || psY!==1.0 || psZ!==1.0){
  22546. var invertScale=Transform3D._tempVector30;
  22547. invertScale.x=1.0 / psX;
  22548. invertScale.y=1.0 / psY;
  22549. invertScale.z=1.0 / psZ;
  22550. Vector3.multiply(this._localPosition,invertScale,this._localPosition);
  22551. };
  22552. var parentRotation=this._parent.rotation;
  22553. parentRotation.invert(Transform3D._tempQuaternion0);
  22554. Vector3.transformQuat(this._localPosition,Transform3D._tempQuaternion0,this._localPosition);
  22555. }else {
  22556. value.cloneTo(this._localPosition);
  22557. }
  22558. this.localPosition=this._localPosition;
  22559. if (this._position!==value)
  22560. value.cloneTo(this._position);
  22561. this._setTransformFlag(0x08,false);
  22562. });
  22563. /**
  22564. *设置局部空间的Y轴欧拉角。
  22565. *@param value 局部空间的Y轴欧拉角。
  22566. */
  22567. /**
  22568. *获取局部空间的Y轴欧拉角。
  22569. *@return 局部空间的Y轴欧拉角。
  22570. */
  22571. __getset(0,__proto,'localRotationEulerY',function(){
  22572. return this.localRotationEuler.y;
  22573. },function(value){
  22574. this._localRotationEuler.y=value;
  22575. this.localRotationEuler=this._localRotationEuler;
  22576. });
  22577. /**
  22578. *设置局部缩放。
  22579. *@param value 局部缩放。
  22580. */
  22581. /**
  22582. *获取局部缩放。
  22583. *@return 局部缩放。
  22584. */
  22585. __getset(0,__proto,'localScale',function(){
  22586. return this._localScale;
  22587. },function(value){
  22588. if (this._localScale!==value)
  22589. value.cloneTo(this._localScale);
  22590. this._setTransformFlag(0x04,true);
  22591. this._onWorldScaleTransform();
  22592. });
  22593. /**
  22594. *设置局部空间的X轴欧拉角。
  22595. *@param value 局部空间的X轴欧拉角。
  22596. */
  22597. /**
  22598. *获取局部空间的X轴欧拉角。
  22599. *@return 局部空间的X轴欧拉角。
  22600. */
  22601. __getset(0,__proto,'localRotationEulerX',function(){
  22602. return this.localRotationEuler.x;
  22603. },function(value){
  22604. this._localRotationEuler.x=value;
  22605. this.localRotationEuler=this._localRotationEuler;
  22606. });
  22607. /**
  22608. *设置局部空间的Z轴欧拉角。
  22609. *@param value 局部空间的Z轴欧拉角。
  22610. */
  22611. /**
  22612. *获取局部空间的Z轴欧拉角。
  22613. *@return 局部空间的Z轴欧拉角。
  22614. */
  22615. __getset(0,__proto,'localRotationEulerZ',function(){
  22616. return this.localRotationEuler.z;
  22617. },function(value){
  22618. this._localRotationEuler.z=value;
  22619. this.localRotationEuler=this._localRotationEuler;
  22620. });
  22621. /**
  22622. *设置局部空间的欧拉角。
  22623. *@param value 欧拉角的旋转值。
  22624. */
  22625. /**
  22626. *获取局部空间欧拉角。
  22627. *@return 欧拉角的旋转值。
  22628. */
  22629. __getset(0,__proto,'localRotationEuler',function(){
  22630. if (this._getTransformFlag(0x02)){
  22631. this._localRotation.getYawPitchRoll(Transform3D._tempVector30);
  22632. var euler=Transform3D._tempVector30;
  22633. var localRotationEuler=this._localRotationEuler;
  22634. localRotationEuler.x=euler.y *Transform3D._angleToRandin;
  22635. localRotationEuler.y=euler.x *Transform3D._angleToRandin;
  22636. localRotationEuler.z=euler.z *Transform3D._angleToRandin;
  22637. this._setTransformFlag(0x02,false);
  22638. }
  22639. return this._localRotationEuler;
  22640. },function(value){
  22641. if (this._localRotationEuler!==value)
  22642. value.cloneTo(this._localRotationEuler);
  22643. this._setTransformFlag(0x02,false);
  22644. this._setTransformFlag(0x01 | 0x04,true);
  22645. this._onWorldRotationTransform();
  22646. });
  22647. /**
  22648. *设置局部矩阵。
  22649. *@param value 局部矩阵。
  22650. */
  22651. /**
  22652. *获取局部矩阵。
  22653. *@return 局部矩阵。
  22654. */
  22655. __getset(0,__proto,'localMatrix',function(){
  22656. if (this._getTransformFlag(0x04)){
  22657. this._updateLocalMatrix();
  22658. this._setTransformFlag(0x04,false);
  22659. }
  22660. return this._localMatrix;
  22661. },function(value){
  22662. if (this._localMatrix!==value)
  22663. value.cloneTo(this._localMatrix);
  22664. this._localMatrix.decomposeTransRotScale(this._localPosition,this._localRotation,this._localScale);
  22665. this._setTransformFlag(0x04,false);
  22666. this._onWorldTransform();
  22667. });
  22668. /**
  22669. *设置世界旋转。
  22670. *@param value 世界旋转。
  22671. */
  22672. /**
  22673. *获取世界旋转。
  22674. *@return 世界旋转。
  22675. */
  22676. __getset(0,__proto,'rotation',function(){
  22677. if (this._getTransformFlag(0x10)){
  22678. if (this._parent !=null)
  22679. Quaternion.multiply(this._parent.rotation,this.localRotation,this._rotation);
  22680. else
  22681. this.localRotation.cloneTo(this._rotation);
  22682. this._setTransformFlag(0x10,false);
  22683. }
  22684. return this._rotation;
  22685. },function(value){
  22686. if (this._parent !=null){
  22687. this._parent.rotation.invert(Transform3D._tempQuaternion0);
  22688. Quaternion.multiply(Transform3D._tempQuaternion0,value,this._localRotation);
  22689. }else {
  22690. value.cloneTo(this._localRotation);
  22691. }
  22692. this.localRotation=this._localRotation;
  22693. if (value!==this._rotation)
  22694. value.cloneTo(this._rotation);
  22695. this._setTransformFlag(0x10,false);
  22696. });
  22697. /**
  22698. *设置世界缩放。
  22699. *@param value 世界缩放。
  22700. */
  22701. /**
  22702. *获取世界缩放。
  22703. *@return 世界缩放。
  22704. */
  22705. __getset(0,__proto,'scale',function(){
  22706. if (!this._getTransformFlag(0x20))
  22707. return this._scale;
  22708. if (this._parent!==null)
  22709. Vector3.multiply(this._parent.scale,this._localScale,this._scale);
  22710. else
  22711. this._localScale.cloneTo(this._scale);
  22712. this._setTransformFlag(0x20,false);
  22713. return this._scale;
  22714. },function(value){
  22715. if (this._parent!==null){
  22716. var parScale=this._parent.scale;
  22717. var invParScale=Transform3D._tempVector30;
  22718. invParScale.x=1.0 / parScale.x;
  22719. invParScale.y=1.0 / parScale.y;
  22720. invParScale.z=1.0 / parScale.z;
  22721. Vector3.multiply(value,Transform3D._tempVector30,this._localScale);
  22722. }else {
  22723. value.cloneTo(this._localScale);
  22724. }
  22725. this.localScale=this._localScale;
  22726. if (this._scale!==value)
  22727. value.cloneTo(this._scale);
  22728. this._setTransformFlag(0x20,false);
  22729. });
  22730. /**
  22731. *设置世界空间的旋转角度。
  22732. *@param 欧拉角的旋转值,顺序为x、y、z。
  22733. */
  22734. /**
  22735. *获取世界空间的旋转角度。
  22736. *@return 欧拉角的旋转值,顺序为x、y、z。
  22737. */
  22738. __getset(0,__proto,'rotationEuler',function(){
  22739. if (this._getTransformFlag(0x80)){
  22740. this.rotation.getYawPitchRoll(Transform3D._tempVector30);
  22741. var eulerE=Transform3D._tempVector30;
  22742. var rotationEulerE=this._rotationEuler;
  22743. rotationEulerE.x=eulerE.y *Transform3D._angleToRandin;
  22744. rotationEulerE.y=eulerE.x *Transform3D._angleToRandin;
  22745. rotationEulerE.z=eulerE.z *Transform3D._angleToRandin;
  22746. this._setTransformFlag(0x80,false);
  22747. }
  22748. return this._rotationEuler;
  22749. },function(value){
  22750. Quaternion.createFromYawPitchRoll(value.y / Transform3D._angleToRandin,value.x / Transform3D._angleToRandin,value.z / Transform3D._angleToRandin,this._rotation);
  22751. this.rotation=this._rotation;
  22752. if (this._rotationEuler!==value)
  22753. value.cloneTo(this._rotationEuler);
  22754. this._setTransformFlag(0x80,false);
  22755. });
  22756. /**
  22757. *设置世界矩阵。
  22758. *@param value 世界矩阵。
  22759. */
  22760. /**
  22761. *获取世界矩阵。
  22762. *@return 世界矩阵。
  22763. */
  22764. __getset(0,__proto,'worldMatrix',function(){
  22765. if (this._getTransformFlag(0x40)){
  22766. if (this._parent !=null)
  22767. Matrix4x4.multiply(this._parent.worldMatrix,this.localMatrix,this._worldMatrix);
  22768. else
  22769. this.localMatrix.cloneTo(this._worldMatrix);
  22770. this._setTransformFlag(0x40,false);
  22771. }
  22772. return this._worldMatrix;
  22773. },function(value){
  22774. if (this._parent===null){
  22775. value.cloneTo(this._localMatrix);
  22776. }else {
  22777. this._parent.worldMatrix.invert(this._localMatrix);
  22778. Matrix4x4.multiply(this._localMatrix,value,this._localMatrix);
  22779. }
  22780. this.localMatrix=this._localMatrix;
  22781. if (this._worldMatrix!==value)
  22782. value.cloneTo(this._worldMatrix);
  22783. this._setTransformFlag(0x40,false);
  22784. });
  22785. Transform3D.TRANSFORM_LOCALQUATERNION=0x01;
  22786. Transform3D.TRANSFORM_LOCALEULER=0x02;
  22787. Transform3D.TRANSFORM_LOCALMATRIX=0x04;
  22788. Transform3D.TRANSFORM_WORLDPOSITION=0x08;
  22789. Transform3D.TRANSFORM_WORLDQUATERNION=0x10;
  22790. Transform3D.TRANSFORM_WORLDSCALE=0x20;
  22791. Transform3D.TRANSFORM_WORLDMATRIX=0x40;
  22792. Transform3D.TRANSFORM_WORLDEULER=0x80;
  22793. __static(Transform3D,
  22794. ['_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;}
  22795. ]);
  22796. return Transform3D;
  22797. })(EventDispatcher)
  22798. /**
  22799. *<code>ShaderPass</code> 类用于实现ShaderPass。
  22800. */
  22801. //class laya.d3.shader.ShaderPass extends laya.webgl.utils.ShaderCompile
  22802. var ShaderPass=(function(_super){
  22803. function ShaderPass(owner,vs,ps,stateMap){
  22804. /**@private */
  22805. //this._owner=null;
  22806. /**@private */
  22807. //this._stateMap=null;
  22808. /**@private */
  22809. //this._cacheSharders=null;
  22810. /**@private */
  22811. //this._publicValidDefine=0;
  22812. /**@private */
  22813. //this._spriteValidDefine=0;
  22814. /**@private */
  22815. //this._materialValidDefine=0;
  22816. /**@private */
  22817. //this._validDefineMap=null;
  22818. this._renderState=new RenderState();
  22819. this._owner=owner;
  22820. this._cacheSharders=[];
  22821. this._publicValidDefine=0;
  22822. this._spriteValidDefine=0;
  22823. this._materialValidDefine=0;
  22824. this._validDefineMap={};
  22825. ShaderPass.__super.call(this,vs,ps,null,this._validDefineMap);
  22826. var publicDefineMap=this._owner._publicDefinesMap;
  22827. var spriteDefineMap=this._owner._spriteDefinesMap;
  22828. var materialDefineMap=this._owner._materialDefinesMap;
  22829. for (var k in this._validDefineMap){
  22830. if (publicDefineMap[k] !=null)
  22831. this._publicValidDefine |=publicDefineMap[k];
  22832. else if (spriteDefineMap[k] !=null)
  22833. this._spriteValidDefine |=spriteDefineMap[k];
  22834. else if (materialDefineMap[k] !=null)
  22835. this._materialValidDefine |=materialDefineMap[k];
  22836. }
  22837. this._stateMap=stateMap;
  22838. }
  22839. __class(ShaderPass,'laya.d3.shader.ShaderPass',_super);
  22840. var __proto=ShaderPass.prototype;
  22841. /**
  22842. *@private
  22843. */
  22844. __proto._definesToNameDic=function(value,int2Name){
  22845. var o={};
  22846. var d=1;
  22847. for (var i=0;i < 32;i++){
  22848. d=1 << i;
  22849. if (d > value)break ;
  22850. if (value & d){
  22851. var name=int2Name[d];
  22852. o[name]="";
  22853. }
  22854. }
  22855. return o;
  22856. }
  22857. /**
  22858. *@inheritDoc
  22859. */
  22860. __proto._compileToTree=function(parent,lines,start,includefiles,defs){
  22861. var node,preNode;
  22862. var text,name,fname;
  22863. var ofs=0,words,noUseNode;
  22864. var i=0,n=0,j=0;
  22865. for (i=start;i < lines.length;i++){
  22866. text=lines[i];
  22867. if (text.length < 1)continue ;
  22868. ofs=text.indexOf("//");
  22869. if (ofs===0)continue ;
  22870. if (ofs >=0)text=text.substr(0,ofs);
  22871. node=noUseNode || new ShaderNode(includefiles);
  22872. noUseNode=null;
  22873. node.text=text;
  22874. if ((ofs=text.indexOf("#"))>=0){
  22875. name="#";
  22876. for (j=ofs+1,n=text.length;j < n;j++){
  22877. var c=text.charAt(j);
  22878. if (c===' ' || c==='\t' || c==='?')break ;
  22879. name+=c;
  22880. }
  22881. node.name=name;
  22882. switch (name){
  22883. case "#ifdef":
  22884. case "#ifndef":
  22885. node.setParent(parent);
  22886. parent=node;
  22887. if (defs){
  22888. words=text.substr(j).split(ShaderCompile._splitToWordExps3);
  22889. for (j=0;j < words.length;j++){
  22890. text=words[j];
  22891. text.length && (defs[text]=true);
  22892. }
  22893. }
  22894. continue ;
  22895. case "#if":
  22896. case "#elif":
  22897. node.setParent(parent);
  22898. parent=node;
  22899. if (defs){
  22900. words=text.substr(j).split(ShaderCompile._splitToWordExps3);
  22901. for (j=0;j < words.length;j++){
  22902. text=words[j];
  22903. text.length && text !="defined" && (defs[text]=true);
  22904. }
  22905. }
  22906. continue ;
  22907. case "#else":
  22908. parent=parent.parent;
  22909. preNode=parent.childs[parent.childs.length-1];
  22910. node.setParent(parent);
  22911. parent=node;
  22912. continue ;
  22913. case "#endif":
  22914. parent=parent.parent;
  22915. preNode=parent.childs[parent.childs.length-1];
  22916. node.setParent(parent);
  22917. continue ;
  22918. case "#include":
  22919. words=ShaderCompile.splitToWords(text,null);
  22920. var inlcudeFile=ShaderCompile.includes[words[1]];
  22921. if (!inlcudeFile){
  22922. throw "ShaderCompile error no this include file:"+words[1];
  22923. }
  22924. if ((ofs=words[0].indexOf("?"))< 0){
  22925. node.setParent(parent);
  22926. text=inlcudeFile.getWith(words[2]=='with' ? words[3] :null);
  22927. this._compileToTree(node,text.split('\n'),0,includefiles,defs);
  22928. node.text="";
  22929. continue ;
  22930. }
  22931. node.setCondition(words[0].substr(ofs+1),1);
  22932. node.text=inlcudeFile.getWith(words[2]=='with' ? words[3] :null);
  22933. break ;
  22934. case "#import":
  22935. words=ShaderCompile.splitToWords(text,null);
  22936. fname=words[1];
  22937. includefiles.push({node:node,file:ShaderCompile.includes[fname],ofs:node.text.length});
  22938. continue ;
  22939. }
  22940. }else {
  22941. preNode=parent.childs[parent.childs.length-1];
  22942. if (preNode && !preNode.name){
  22943. includefiles.length > 0 && ShaderCompile.splitToWords(text,preNode);
  22944. noUseNode=node;
  22945. preNode.text+="\n"+text;
  22946. continue ;
  22947. }
  22948. includefiles.length > 0 && ShaderCompile.splitToWords(text,node);
  22949. }
  22950. node.setParent(parent);
  22951. }
  22952. }
  22953. /**
  22954. *@private
  22955. */
  22956. __proto.withCompile=function(publicDefine,spriteDefine,materialDefine){
  22957. publicDefine &=this._publicValidDefine;
  22958. spriteDefine &=this._spriteValidDefine;
  22959. materialDefine &=this._materialValidDefine;
  22960. var shader;
  22961. var spriteDefShaders,materialDefShaders;
  22962. spriteDefShaders=this._cacheSharders[publicDefine];
  22963. if (spriteDefShaders){
  22964. materialDefShaders=spriteDefShaders[spriteDefine];
  22965. if (materialDefShaders){
  22966. shader=materialDefShaders[materialDefine];
  22967. if (shader)
  22968. return shader;
  22969. }else {
  22970. materialDefShaders=spriteDefShaders[spriteDefine]=[];
  22971. }
  22972. }else {
  22973. spriteDefShaders=this._cacheSharders[publicDefine]=[];
  22974. materialDefShaders=spriteDefShaders[spriteDefine]=[];
  22975. };
  22976. var publicDefGroup=this._definesToNameDic(publicDefine,this._owner._publicDefines);
  22977. var spriteDefGroup=this._definesToNameDic(spriteDefine,this._owner._spriteDefines);
  22978. var materialDefGroup=this._definesToNameDic(materialDefine,this._owner._materialDefines);
  22979. var key;
  22980. if (Shader3D.debugMode){
  22981. var publicDefGroupStr="";
  22982. for (key in publicDefGroup)
  22983. publicDefGroupStr+=key+" ";
  22984. var spriteDefGroupStr="";
  22985. for (key in spriteDefGroup)
  22986. spriteDefGroupStr+=key+" ";
  22987. var materialDefGroupStr="";
  22988. for (key in materialDefGroup)
  22989. materialDefGroupStr+=key+" ";
  22990. if (!WebGL.shaderHighPrecision)
  22991. publicDefine+=Shader3D.SHADERDEFINE_HIGHPRECISION;
  22992. 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");
  22993. };
  22994. var defMap={};
  22995. var defineStr="";
  22996. if (publicDefGroup){
  22997. for (key in publicDefGroup){
  22998. defineStr+="#define "+key+"\n";
  22999. defMap[key]=true;
  23000. }
  23001. }
  23002. if (spriteDefGroup){
  23003. for (key in spriteDefGroup){
  23004. defineStr+="#define "+key+"\n";
  23005. defMap[key]=true;
  23006. }
  23007. }
  23008. if (materialDefGroup){
  23009. for (key in materialDefGroup){
  23010. defineStr+="#define "+key+"\n";
  23011. defMap[key]=true;
  23012. }
  23013. };
  23014. var vs=this._VS.toscript(defMap,[]);
  23015. var vsVersion='';
  23016. if (vs[0].indexOf('#version')==0){
  23017. vsVersion=vs[0]+'\n';
  23018. vs.shift();
  23019. };
  23020. var ps=this._PS.toscript(defMap,[]);
  23021. var psVersion='';
  23022. if (ps[0].indexOf('#version')==0){
  23023. psVersion=ps[0]+'\n';
  23024. ps.shift();
  23025. }
  23026. 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);
  23027. materialDefShaders[materialDefine]=shader;
  23028. return shader;
  23029. }
  23030. /**
  23031. *获取渲染状态。
  23032. *@return 渲染状态。
  23033. */
  23034. __getset(0,__proto,'renderState',function(){
  23035. return this._renderState;
  23036. });
  23037. return ShaderPass;
  23038. })(ShaderCompile)
  23039. /**
  23040. *@private
  23041. *<code>MeshSprite3DDynamicBatchManager</code> 类用于网格精灵动态批处理管理。
  23042. */
  23043. //class laya.d3.graphics.MeshRenderDynamicBatchManager extends laya.d3.graphics.DynamicBatchManager
  23044. var MeshRenderDynamicBatchManager=(function(_super){
  23045. function MeshRenderDynamicBatchManager(){
  23046. /**@private [只读]*/
  23047. //this._updateCountMark=0;
  23048. this._instanceBatchOpaqueMarks=[];
  23049. this._vertexBatchOpaqueMarks=[];
  23050. this._cacheBufferStates=[];
  23051. MeshRenderDynamicBatchManager.__super.call(this);
  23052. SubMeshDynamicBatch.instance=new SubMeshDynamicBatch();
  23053. this._updateCountMark=0;
  23054. }
  23055. __class(MeshRenderDynamicBatchManager,'laya.d3.graphics.MeshRenderDynamicBatchManager',_super);
  23056. var __proto=MeshRenderDynamicBatchManager.prototype;
  23057. /**
  23058. *@private
  23059. */
  23060. __proto.getInstanceBatchOpaquaMark=function(lightMapIndex,receiveShadow,materialID,subMeshID){
  23061. var instanceLightMapMarks=(this._instanceBatchOpaqueMarks[lightMapIndex])|| (this._instanceBatchOpaqueMarks[lightMapIndex]=[]);
  23062. var instanceReceiveShadowMarks=(instanceLightMapMarks[receiveShadow ? 0 :1])|| (instanceLightMapMarks[receiveShadow ? 0 :1]=[]);
  23063. var instanceMaterialMarks=(instanceReceiveShadowMarks[materialID])|| (instanceReceiveShadowMarks[materialID]=[]);
  23064. return instanceMaterialMarks[subMeshID] || (instanceMaterialMarks[subMeshID]=new BatchMark());
  23065. }
  23066. /**
  23067. *@private
  23068. */
  23069. __proto.getVertexBatchOpaquaMark=function(lightMapIndex,receiveShadow,materialID,verDecID){
  23070. var dynLightMapMarks=(this._vertexBatchOpaqueMarks[lightMapIndex])|| (this._vertexBatchOpaqueMarks[lightMapIndex]=[]);
  23071. var dynReceiveShadowMarks=(dynLightMapMarks[receiveShadow ? 0 :1])|| (dynLightMapMarks[receiveShadow ? 0 :1]=[]);
  23072. var dynMaterialMarks=(dynReceiveShadowMarks[materialID])|| (dynReceiveShadowMarks[materialID]=[]);
  23073. return dynMaterialMarks[verDecID] || (dynMaterialMarks[verDecID]=new BatchMark());
  23074. }
  23075. /**
  23076. *@private
  23077. */
  23078. __proto._getBufferState=function(vertexDeclaration){
  23079. var bufferState=this._cacheBufferStates[vertexDeclaration.id];
  23080. if (!bufferState){
  23081. var instance=SubMeshDynamicBatch.instance;
  23082. bufferState=new BufferState();
  23083. bufferState.bind();
  23084. var vertexBuffer=instance._vertexBuffer;
  23085. vertexBuffer.vertexDeclaration=vertexDeclaration;
  23086. bufferState.applyVertexBuffer(vertexBuffer);
  23087. bufferState.applyIndexBuffer(instance._indexBuffer);
  23088. bufferState.unBind();
  23089. this._cacheBufferStates[vertexDeclaration.id]=bufferState;
  23090. }
  23091. return bufferState;
  23092. }
  23093. /**
  23094. *@inheritDoc
  23095. */
  23096. __proto._getBatchRenderElementFromPool=function(){
  23097. var renderElement=this._batchRenderElementPool [this._batchRenderElementPoolIndex++];
  23098. if (!renderElement){
  23099. renderElement=new SubMeshRenderElement();
  23100. this._batchRenderElementPool[this._batchRenderElementPoolIndex-1]=renderElement;
  23101. renderElement.vertexBatchElementList=[];
  23102. renderElement.instanceBatchElementList=[];
  23103. }
  23104. return renderElement;
  23105. }
  23106. /**
  23107. *@inheritDoc
  23108. */
  23109. __proto._clear=function(){
  23110. _super.prototype._clear.call(this);
  23111. this._updateCountMark++;
  23112. }
  23113. __static(MeshRenderDynamicBatchManager,
  23114. ['instance',function(){return this.instance=new MeshRenderDynamicBatchManager();}
  23115. ]);
  23116. return MeshRenderDynamicBatchManager;
  23117. })(DynamicBatchManager)
  23118. /**
  23119. *<code>SphereColliderShape</code> 类用于创建球形碰撞器。
  23120. */
  23121. //class laya.d3.physics.shape.SphereColliderShape extends laya.d3.physics.shape.ColliderShape
  23122. var SphereColliderShape=(function(_super){
  23123. function SphereColliderShape(radius){
  23124. /**@private */
  23125. //this._radius=NaN;
  23126. SphereColliderShape.__super.call(this);
  23127. (radius===void 0)&& (radius=0.5);
  23128. this._radius=radius;
  23129. this._type=/*laya.d3.physics.shape.ColliderShape.SHAPETYPES_SPHERE*/1;
  23130. this._nativeShape=new Laya3D._physics3D.btSphereShape(radius);
  23131. }
  23132. __class(SphereColliderShape,'laya.d3.physics.shape.SphereColliderShape',_super);
  23133. var __proto=SphereColliderShape.prototype;
  23134. /**
  23135. *@inheritDoc
  23136. */
  23137. __proto.clone=function(){
  23138. var dest=new SphereColliderShape(this._radius);
  23139. this.cloneTo(dest);
  23140. return dest;
  23141. }
  23142. /**
  23143. *获取半径。
  23144. */
  23145. __getset(0,__proto,'radius',function(){
  23146. return this._radius;
  23147. });
  23148. return SphereColliderShape;
  23149. })(ColliderShape)
  23150. /**
  23151. *<code>StaticPlaneColliderShape</code> 类用于创建静态平面碰撞器。
  23152. */
  23153. //class laya.d3.physics.shape.StaticPlaneColliderShape extends laya.d3.physics.shape.ColliderShape
  23154. var StaticPlaneColliderShape=(function(_super){
  23155. function StaticPlaneColliderShape(normal,offset){
  23156. /**@private */
  23157. //this._offset=NaN;
  23158. /**@private */
  23159. //this._normal=null;
  23160. StaticPlaneColliderShape.__super.call(this);
  23161. this._normal=normal;
  23162. this._offset=offset;
  23163. this._type=/*laya.d3.physics.shape.ColliderShape.SHAPETYPES_STATICPLANE*/6;
  23164. StaticPlaneColliderShape._nativeNormal.setValue(-normal.x,normal.y,normal.z);
  23165. this._nativeShape=new Laya3D._physics3D.btStaticPlaneShape(StaticPlaneColliderShape._nativeNormal,offset);
  23166. }
  23167. __class(StaticPlaneColliderShape,'laya.d3.physics.shape.StaticPlaneColliderShape',_super);
  23168. var __proto=StaticPlaneColliderShape.prototype;
  23169. /**
  23170. *@inheritDoc
  23171. */
  23172. __proto.clone=function(){
  23173. var dest=new StaticPlaneColliderShape(this._normal,this._offset);
  23174. this.cloneTo(dest);
  23175. return dest;
  23176. }
  23177. __static(StaticPlaneColliderShape,
  23178. ['_nativeNormal',function(){return this._nativeNormal=new Laya3D._physics3D.btVector3(0,0,0);}
  23179. ]);
  23180. return StaticPlaneColliderShape;
  23181. })(ColliderShape)
  23182. /**
  23183. *<code>SubMesh</code> 类用于创建子网格数据模板。
  23184. */
  23185. //class laya.d3.resource.models.SubMesh extends laya.d3.core.GeometryElement
  23186. var SubMesh=(function(_super){
  23187. function SubMesh(mesh){
  23188. /**@private */
  23189. this._mesh=null;
  23190. /**@private */
  23191. this._boneIndicesList=null;
  23192. /**@private */
  23193. this._subIndexBufferStart=null;
  23194. /**@private */
  23195. this._subIndexBufferCount=null;
  23196. /**@private */
  23197. this._skinAnimationDatas=null;
  23198. /**@private */
  23199. this._indexInMesh=0;
  23200. /**@private */
  23201. this._vertexStart=0;
  23202. /**@private */
  23203. this._indexStart=0;
  23204. /**@private */
  23205. this._indexCount=0;
  23206. /**@private */
  23207. this._indices=null;
  23208. /**@private [只读]*/
  23209. this._vertexBuffer=null;
  23210. /**@private [只读]*/
  23211. this._indexBuffer=null;
  23212. /**@private */
  23213. this._id=0;
  23214. SubMesh.__super.call(this);
  23215. this._id=++SubMesh._uniqueIDCounter;
  23216. this._mesh=mesh;
  23217. this._boneIndicesList=[];
  23218. this._subIndexBufferStart=[];
  23219. this._subIndexBufferCount=[];
  23220. }
  23221. __class(SubMesh,'laya.d3.resource.models.SubMesh',_super);
  23222. var __proto=SubMesh.prototype;
  23223. /**
  23224. *@inheritDoc
  23225. */
  23226. __proto._getType=function(){
  23227. return SubMesh._type;
  23228. }
  23229. /**
  23230. *@inheritDoc
  23231. */
  23232. __proto._render=function(state){
  23233. this._mesh._bufferState.bind();
  23234. var skinnedDatas=(state.renderElement.render)._skinnedData;
  23235. if (skinnedDatas){
  23236. var subSkinnedDatas=skinnedDatas[this._indexInMesh];
  23237. var boneIndicesListCount=this._boneIndicesList.length;
  23238. for (var i=0;i < boneIndicesListCount;i++){
  23239. state.shader.uploadCustomUniform(SkinnedMeshSprite3D.BONES,subSkinnedDatas[i]);
  23240. LayaGL.instance.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,this._subIndexBufferCount[i],/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,this._subIndexBufferStart[i] *2);
  23241. }
  23242. }else {
  23243. LayaGL.instance.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,this._indexCount,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,this._indexStart *2);
  23244. }
  23245. Stat.trianglesFaces+=this._indexCount / 3;
  23246. Stat.renderBatches++;
  23247. }
  23248. /**
  23249. *@private
  23250. */
  23251. __proto.getIndices=function(){
  23252. return this._indices;
  23253. }
  23254. /**
  23255. *@inheritDoc
  23256. */
  23257. __proto.destroy=function(){
  23258. if (this._destroyed)
  23259. return;
  23260. _super.prototype.destroy.call(this);
  23261. this._indexBuffer.destroy();
  23262. this._indexBuffer=null;
  23263. this._mesh=null;
  23264. this._boneIndicesList=null;
  23265. this._subIndexBufferStart=null;
  23266. this._subIndexBufferCount=null;
  23267. this._skinAnimationDatas=null;
  23268. }
  23269. SubMesh._uniqueIDCounter=0;
  23270. __static(SubMesh,
  23271. ['_type',function(){return this._type=GeometryElement._typeCounter++;}
  23272. ]);
  23273. return SubMesh;
  23274. })(GeometryElement)
  23275. /**
  23276. *@private
  23277. *<code>MeshSprite3DStaticBatchManager</code> 类用于网格精灵静态批处理管理。
  23278. */
  23279. //class laya.d3.graphics.MeshRenderStaticBatchManager extends laya.d3.graphics.StaticBatchManager
  23280. var MeshRenderStaticBatchManager=(function(_super){
  23281. function MeshRenderStaticBatchManager(){
  23282. /**@private [只读]*/
  23283. //this._updateCountMark=0;
  23284. this._opaqueBatchMarks=[];
  23285. MeshRenderStaticBatchManager.__super.call(this);
  23286. this._updateCountMark=0;
  23287. }
  23288. __class(MeshRenderStaticBatchManager,'laya.d3.graphics.MeshRenderStaticBatchManager',_super);
  23289. var __proto=MeshRenderStaticBatchManager.prototype;
  23290. /**
  23291. *@inheritDoc
  23292. */
  23293. __proto._compare=function(left,right){
  23294. var lRender=left._render,rRender=right._render;
  23295. var leftGeo=(left).meshFilter.sharedMesh,rightGeo=(right).meshFilter.sharedMesh;
  23296. var lightOffset=lRender.lightmapIndex-rRender.lightmapIndex;
  23297. if (lightOffset===0){
  23298. var receiveShadowOffset=(lRender.receiveShadow ? 1 :0)-(rRender.receiveShadow ? 1 :0);
  23299. if (receiveShadowOffset===0){
  23300. var materialOffset=lRender.sharedMaterial.id-rRender.sharedMaterial.id;
  23301. if (materialOffset===0){
  23302. var verDec=leftGeo._vertexBuffers[0].vertexDeclaration.id-rightGeo._vertexBuffers[0].vertexDeclaration.id;
  23303. if (verDec===0){
  23304. return rightGeo._indexBuffer.indexCount-leftGeo._indexBuffer.indexCount;
  23305. }else {
  23306. return verDec;
  23307. }
  23308. }else {
  23309. return materialOffset;
  23310. }
  23311. }else {
  23312. return receiveShadowOffset;
  23313. }
  23314. }else {
  23315. return lightOffset;
  23316. }
  23317. }
  23318. /**
  23319. *@inheritDoc
  23320. */
  23321. __proto._getBatchRenderElementFromPool=function(){
  23322. var renderElement=this._batchRenderElementPool[this._batchRenderElementPoolIndex++];
  23323. if (!renderElement){
  23324. renderElement=new SubMeshRenderElement();
  23325. this._batchRenderElementPool[this._batchRenderElementPoolIndex-1]=renderElement;
  23326. renderElement.staticBatchElementList=[];
  23327. }
  23328. return renderElement;
  23329. }
  23330. /**
  23331. *@private
  23332. */
  23333. __proto._getStaticBatch=function(rootOwner,number){
  23334. var key=rootOwner ? rootOwner.id :0;
  23335. var batchOwner=this._staticBatches[key];
  23336. (batchOwner)|| (batchOwner=this._staticBatches[key]=[]);
  23337. return (batchOwner[number])|| (batchOwner[number]=new SubMeshStaticBatch(rootOwner,number,MeshRenderStaticBatchManager._verDec));
  23338. }
  23339. /**
  23340. *@inheritDoc
  23341. */
  23342. __proto._initStaticBatchs=function(rootOwner){
  23343. this._quickSort(this._initBatchSprites,0,this._initBatchSprites.length-1);
  23344. var lastCanMerage=false;
  23345. var curStaticBatch;
  23346. var batchNumber=0;
  23347. for (var i=0,n=this._initBatchSprites.length;i < n;i++){
  23348. var sprite=this._initBatchSprites[i];
  23349. if (lastCanMerage){
  23350. if (curStaticBatch.addTest(sprite)){
  23351. curStaticBatch.add(sprite);
  23352. }else {
  23353. lastCanMerage=false;
  23354. batchNumber++;
  23355. }
  23356. }else {
  23357. var lastIndex=n-1;
  23358. if (i!==lastIndex){
  23359. curStaticBatch=this._getStaticBatch(rootOwner,batchNumber);
  23360. curStaticBatch.add(sprite);
  23361. lastCanMerage=true;
  23362. }
  23363. }
  23364. }
  23365. for (var key in this._staticBatches){
  23366. var batches=this._staticBatches[key];
  23367. for (i=0,n=batches.length;i < n;i++)
  23368. batches[i].finishInit();
  23369. }
  23370. this._initBatchSprites.length=0;
  23371. }
  23372. /**
  23373. *@private
  23374. */
  23375. __proto._destroyRenderSprite=function(sprite){
  23376. var staticBatch=sprite._render._staticBatch;
  23377. staticBatch.remove(sprite);
  23378. if (staticBatch._batchElements.length===0){
  23379. var owner=staticBatch.batchOwner;
  23380. var ownerID=owner ? owner.id :0;
  23381. var batches=this._staticBatches[ownerID];
  23382. batches[staticBatch.number]=null;
  23383. staticBatch.dispose();
  23384. var empty=true;
  23385. for (var i=0;i < batches.length;i++){
  23386. if (batches[i])
  23387. empty=false;
  23388. }
  23389. if (empty){
  23390. delete this._staticBatches[ownerID];
  23391. }
  23392. }
  23393. }
  23394. /**
  23395. *@inheritDoc
  23396. */
  23397. __proto._clear=function(){
  23398. _super.prototype._clear.call(this);
  23399. this._updateCountMark++;
  23400. }
  23401. /**
  23402. *@inheritDoc
  23403. */
  23404. __proto._garbageCollection=function(){
  23405. for (var key in this._staticBatches){
  23406. var batches=this._staticBatches[key];
  23407. for (var i=0,n=batches.length;i < n;i++){
  23408. var staticBatch=batches[i];
  23409. if (staticBatch._batchElements.length===0){
  23410. staticBatch.dispose();
  23411. batches.splice(i,1);
  23412. i--,n--;
  23413. if (n===0)
  23414. delete this._staticBatches[key];
  23415. }
  23416. }
  23417. }
  23418. }
  23419. /**
  23420. *@private
  23421. */
  23422. __proto.getBatchOpaquaMark=function(lightMapIndex,receiveShadow,materialID,staticBatchID){
  23423. var staLightMapMarks=(this._opaqueBatchMarks[lightMapIndex])|| (this._opaqueBatchMarks[lightMapIndex]=[]);
  23424. var staReceiveShadowMarks=(staLightMapMarks[receiveShadow])|| (staLightMapMarks[receiveShadow]=[]);
  23425. var staMaterialMarks=(staReceiveShadowMarks[materialID])|| (staReceiveShadowMarks[materialID]=[]);
  23426. return (staMaterialMarks[staticBatchID])|| (staMaterialMarks[staticBatchID]=new BatchMark);
  23427. }
  23428. __static(MeshRenderStaticBatchManager,
  23429. ['_verDec',function(){return this._verDec=VertexMesh.getVertexDeclaration("POSITION,NORMAL,COLOR,UV,UV1,TANGENT");},'instance',function(){return this.instance=new MeshRenderStaticBatchManager();}
  23430. ]);
  23431. return MeshRenderStaticBatchManager;
  23432. })(StaticBatchManager)
  23433. /**
  23434. *<code>TrailGeometry</code> 类用于创建拖尾渲染单元。
  23435. */
  23436. //class laya.d3.core.trail.TrailGeometry extends laya.d3.core.GeometryElement
  23437. var TrailGeometry=(function(_super){
  23438. function TrailGeometry(owner){
  23439. /**@private */
  23440. this._floatCountPerVertices1=8;
  23441. /**@private */
  23442. this._floatCountPerVertices2=1;
  23443. /**@private */
  23444. this._increaseSegementCount=128;
  23445. /**@private */
  23446. this._activeIndex=0;
  23447. /**@private */
  23448. this._endIndex=0;
  23449. /**@private */
  23450. this._needAddFirstVertex=false;
  23451. /**@private */
  23452. this._isTempEndVertex=false;
  23453. /**@private */
  23454. this._subBirthTime=null;
  23455. /**@private */
  23456. this._subDistance=null;
  23457. /**@private */
  23458. this._segementCount=0;
  23459. /**@private */
  23460. this._vertices1=null;
  23461. /**@private */
  23462. this._vertices2=null;
  23463. /**@private */
  23464. this._vertexBuffer1=null;
  23465. /**@private */
  23466. this._vertexBuffer2=null;
  23467. /**@private */
  23468. this._owner=null;
  23469. TrailGeometry.__super.call(this);
  23470. this._lastFixedVertexPosition=new Vector3();
  23471. this._bufferState=new BufferState();
  23472. this._owner=owner;;
  23473. this._resizeData(this._increaseSegementCount,this._bufferState);
  23474. }
  23475. __class(TrailGeometry,'laya.d3.core.trail.TrailGeometry',_super);
  23476. var __proto=TrailGeometry.prototype;
  23477. /**
  23478. *@private
  23479. */
  23480. __proto._resizeData=function(segementCount,bufferState){
  23481. this._segementCount=this._increaseSegementCount;
  23482. this._subBirthTime=new Float32Array(segementCount);
  23483. this._subDistance=new Float32Array(segementCount);
  23484. var vertexCount=segementCount *2;
  23485. var vertexDeclaration1=VertexTrail.vertexDeclaration1;
  23486. var vertexDeclaration2=VertexTrail.vertexDeclaration2;
  23487. var vertexBuffers=[];
  23488. var vertexbuffer1Size=vertexCount *vertexDeclaration1.vertexStride;
  23489. var vertexbuffer2Size=vertexCount *vertexDeclaration2.vertexStride;
  23490. var memorySize=vertexbuffer1Size+vertexbuffer2Size;
  23491. this._vertices1=new Float32Array(vertexCount *this._floatCountPerVertices1);
  23492. this._vertexBuffer1=new VertexBuffer3D(vertexbuffer1Size,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,false);
  23493. this._vertexBuffer1.vertexDeclaration=vertexDeclaration1;
  23494. this._vertices2=new Float32Array(vertexCount *this._floatCountPerVertices2);
  23495. this._vertexBuffer2=new VertexBuffer3D(vertexbuffer2Size,/*laya.webgl.WebGLContext.DYNAMIC_DRAW*/0x88E8,false);
  23496. this._vertexBuffer2.vertexDeclaration=vertexDeclaration2;
  23497. vertexBuffers.push(this._vertexBuffer1);
  23498. vertexBuffers.push(this._vertexBuffer2);
  23499. bufferState.bind();
  23500. bufferState.applyVertexBuffers(vertexBuffers);
  23501. bufferState.unBind();
  23502. Resource._addMemory(memorySize,memorySize);
  23503. }
  23504. /**
  23505. *@private
  23506. */
  23507. __proto._resetData=function(){
  23508. var count=this._endIndex-this._activeIndex;
  23509. if (count==this._segementCount){
  23510. this._vertexBuffer1.destroy();
  23511. this._vertexBuffer2.destroy();
  23512. this._segementCount+=this._increaseSegementCount;
  23513. this._resizeData(this._segementCount,this._bufferState);
  23514. }
  23515. this._vertexBuffer1.setData(this._vertices1,0,this._floatCountPerVertices1 *2 *this._activeIndex,this._floatCountPerVertices1 *2 *count);
  23516. this._vertexBuffer2.setData(this._vertices2,0,this._floatCountPerVertices2 *2 *this._activeIndex,this._floatCountPerVertices2 *2 *count);
  23517. var offset=this._activeIndex *4;
  23518. var rightSubDistance=new Float32Array(this._subDistance.buffer,offset,count);
  23519. var rightSubBirthTime=new Float32Array(this._subBirthTime.buffer,offset,count);
  23520. this._subDistance.set(rightSubDistance,0);
  23521. this._subBirthTime.set(rightSubBirthTime,0);
  23522. this._endIndex=count;
  23523. this._activeIndex=0;
  23524. }
  23525. /**
  23526. *@private
  23527. *更新Trail数据
  23528. */
  23529. __proto._updateTrail=function(camera,lastPosition,position){
  23530. if (!Vector3.equals(lastPosition,position)){
  23531. if ((this._endIndex-this._activeIndex)===0)
  23532. this._addTrailByFirstPosition(camera,position);
  23533. else
  23534. this._addTrailByNextPosition(camera,position);
  23535. }
  23536. }
  23537. /**
  23538. *@private
  23539. *通过起始位置添加TrailRenderElement起始数据
  23540. */
  23541. __proto._addTrailByFirstPosition=function(camera,position){
  23542. (this._endIndex===this._segementCount)&& (this._resetData());
  23543. this._subDistance[this._endIndex]=0;
  23544. this._subBirthTime[this._endIndex]=this._owner._curtime;
  23545. this._endIndex++;
  23546. position.cloneTo(this._lastFixedVertexPosition);
  23547. this._needAddFirstVertex=true;
  23548. }
  23549. /**
  23550. *@private
  23551. *通过位置更新TrailRenderElement数据
  23552. */
  23553. __proto._addTrailByNextPosition=function(camera,position){
  23554. var delVector3=TrailGeometry._tempVector30;
  23555. var pointAtoBVector3=TrailGeometry._tempVector31;
  23556. Vector3.subtract(position,this._lastFixedVertexPosition,delVector3);
  23557. var forward=TrailGeometry._tempVector32;
  23558. switch (this._owner.alignment){
  23559. case /*laya.d3.core.trail.TrailFilter.ALIGNMENT_VIEW*/0:
  23560. camera.transform.getForward(forward);
  23561. Vector3.cross(delVector3,forward,pointAtoBVector3);
  23562. break ;
  23563. case /*laya.d3.core.trail.TrailFilter.ALIGNMENT_TRANSFORM_Z*/1:
  23564. this._owner._owner.transform.getForward(forward);
  23565. Vector3.cross(delVector3,forward,pointAtoBVector3);
  23566. break ;
  23567. }
  23568. Vector3.normalize(pointAtoBVector3,pointAtoBVector3);
  23569. Vector3.scale(pointAtoBVector3,this._owner.widthMultiplier / 2,pointAtoBVector3);
  23570. var delLength=Vector3.scalarLength(delVector3);
  23571. var tempEndIndex=0;
  23572. var offset=NaN;
  23573. if (this._needAddFirstVertex){
  23574. this._updateVerticesByPositionData(position,pointAtoBVector3,this._endIndex-1);
  23575. this._needAddFirstVertex=false;
  23576. }
  23577. if (delLength-this._owner.minVertexDistance >=MathUtils3D.zeroTolerance){
  23578. if (this._isTempEndVertex){
  23579. tempEndIndex=this._endIndex-1;
  23580. offset=delLength-this._subDistance[tempEndIndex];
  23581. this._updateVerticesByPosition(position,pointAtoBVector3,delLength,tempEndIndex);
  23582. this._owner._totalLength+=offset;
  23583. }else {
  23584. (this._endIndex===this._segementCount)&& (this._resetData());
  23585. this._updateVerticesByPosition(position,pointAtoBVector3,delLength,this._endIndex);
  23586. this._owner._totalLength+=delLength;
  23587. this._endIndex++;
  23588. }
  23589. position.cloneTo(this._lastFixedVertexPosition);
  23590. this._isTempEndVertex=false;
  23591. }else {
  23592. if (this._isTempEndVertex){
  23593. tempEndIndex=this._endIndex-1;
  23594. offset=delLength-this._subDistance[tempEndIndex];
  23595. this._updateVerticesByPosition(position,pointAtoBVector3,delLength,tempEndIndex);
  23596. this._owner._totalLength+=offset;
  23597. }else {
  23598. (this._endIndex===this._segementCount)&& (this._resetData());
  23599. this._updateVerticesByPosition(position,pointAtoBVector3,delLength,this._endIndex);
  23600. this._owner._totalLength+=delLength;
  23601. this._endIndex++;
  23602. }
  23603. this._isTempEndVertex=true;
  23604. }
  23605. }
  23606. /**
  23607. *@private
  23608. *通过位置更新顶点数据
  23609. */
  23610. __proto._updateVerticesByPositionData=function(position,pointAtoBVector3,index){
  23611. var vertexOffset=this._floatCountPerVertices1 *2 *index;
  23612. var curtime=this._owner._curtime;
  23613. this._vertices1[vertexOffset]=position.x;
  23614. this._vertices1[vertexOffset+1]=position.y;
  23615. this._vertices1[vertexOffset+2]=position.z;
  23616. this._vertices1[vertexOffset+3]=-pointAtoBVector3.x;
  23617. this._vertices1[vertexOffset+4]=-pointAtoBVector3.y;
  23618. this._vertices1[vertexOffset+5]=-pointAtoBVector3.z;
  23619. this._vertices1[vertexOffset+6]=curtime;
  23620. this._vertices1[vertexOffset+7]=1.0;
  23621. this._vertices1[vertexOffset+8]=position.x;
  23622. this._vertices1[vertexOffset+9]=position.y;
  23623. this._vertices1[vertexOffset+10]=position.z;
  23624. this._vertices1[vertexOffset+11]=pointAtoBVector3.x;
  23625. this._vertices1[vertexOffset+12]=pointAtoBVector3.y;
  23626. this._vertices1[vertexOffset+13]=pointAtoBVector3.z;
  23627. this._vertices1[vertexOffset+14]=curtime;
  23628. this._vertices1[vertexOffset+15]=0.0;
  23629. var floatCount=this._floatCountPerVertices1 *2;
  23630. this._vertexBuffer1.setData(this._vertices1,vertexOffset,vertexOffset,floatCount);
  23631. }
  23632. /**
  23633. *@private
  23634. *通过位置更新顶点数据、距离、出生时间
  23635. */
  23636. __proto._updateVerticesByPosition=function(position,pointAtoBVector3,delDistance,index){
  23637. this._updateVerticesByPositionData(position,pointAtoBVector3,index);
  23638. this._subDistance[index]=delDistance;
  23639. this._subBirthTime[index]=this._owner._curtime;
  23640. }
  23641. /**
  23642. *@private
  23643. *更新VertexBuffer2数据
  23644. */
  23645. __proto._updateVertexBufferUV=function(){
  23646. var vertexCount=this._endIndex;
  23647. var curLength=0;
  23648. for (var i=this._activeIndex,j=vertexCount;i < j;i++){
  23649. (i!==this._activeIndex)&& (curLength+=this._subDistance[i]);
  23650. var uvX=NaN;
  23651. if (this._owner.textureMode==/*laya.d3.core.TextureMode.Stretch*/0)
  23652. uvX=1.0-curLength / this._owner._totalLength;
  23653. else
  23654. uvX=1.0-(this._owner._totalLength-curLength);
  23655. this._vertices2[i *2]=uvX;
  23656. this._vertices2[i *2+1]=uvX;
  23657. };
  23658. var offset=this._activeIndex *2;
  23659. this._vertexBuffer2.setData(this._vertices2,offset,offset,vertexCount *2-offset);
  23660. }
  23661. /**
  23662. *@private
  23663. */
  23664. __proto._updateDisappear=function(){
  23665. var count=this._endIndex;
  23666. for (var i=this._activeIndex;i < count;i++){
  23667. if (this._owner._curtime-this._subBirthTime[i] >=this._owner.time+MathUtils3D.zeroTolerance){
  23668. var nextIndex=i+1;
  23669. if (nextIndex!==count)
  23670. this._owner._totalLength-=this._subDistance[nextIndex];
  23671. if (this._isTempEndVertex && (nextIndex===count-1)){
  23672. var offset=this._floatCountPerVertices1 *i *2;
  23673. var fixedPos=this._lastFixedVertexPosition;
  23674. fixedPos.x=this._vertices1[0];
  23675. fixedPos.y=this._vertices1[1];
  23676. fixedPos.z=this._vertices1[2];
  23677. this._isTempEndVertex=false;
  23678. }
  23679. this._activeIndex++;
  23680. }else {
  23681. break ;
  23682. }
  23683. }
  23684. }
  23685. /**
  23686. *@inheritDoc
  23687. */
  23688. __proto._getType=function(){
  23689. return TrailGeometry._type;
  23690. }
  23691. /**
  23692. *@inheritDoc
  23693. */
  23694. __proto._prepareRender=function(state){
  23695. return this._endIndex-this._activeIndex > 1;
  23696. }
  23697. /**
  23698. *@inheritDoc
  23699. */
  23700. __proto._render=function(state){
  23701. this._bufferState.bind();
  23702. var start=this._activeIndex *2;
  23703. var count=this._endIndex *2-start;
  23704. LayaGL.instance.drawArrays(/*laya.webgl.WebGLContext.TRIANGLE_STRIP*/0x0005,start,count);
  23705. Stat.renderBatches++;
  23706. Stat.trianglesFaces+=count-2;
  23707. }
  23708. /**
  23709. *@inheritDoc
  23710. */
  23711. __proto.destroy=function(){
  23712. _super.prototype.destroy.call(this);
  23713. var memorySize=this._vertexBuffer1._byteLength+this._vertexBuffer2._byteLength;
  23714. Resource._addMemory(-memorySize,-memorySize);
  23715. this._bufferState.destroy();
  23716. this._vertexBuffer1.destroy();
  23717. this._vertexBuffer2.destroy();
  23718. this._bufferState=null;
  23719. this._vertices1=null;
  23720. this._vertexBuffer1=null;
  23721. this._vertices2=null;
  23722. this._vertexBuffer2=null;
  23723. this._subBirthTime=null;
  23724. this._subDistance=null;
  23725. this._lastFixedVertexPosition=null;
  23726. }
  23727. __static(TrailGeometry,
  23728. ['_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++;}
  23729. ]);
  23730. return TrailGeometry;
  23731. })(GeometryElement)
  23732. /**
  23733. *<code>VertexShurikenParticle</code> 类用于创建粒子顶点结构。
  23734. */
  23735. //class laya.d3.graphics.Vertex.VertexShurikenParticleMesh extends laya.d3.graphics.Vertex.VertexShuriKenParticle
  23736. var VertexShurikenParticleMesh=(function(_super){
  23737. function VertexShurikenParticleMesh(cornerTextureCoordinate,positionStartLifeTime,velocity,startColor,startSize,startRotation0,startRotation1,startRotation2,ageAddScale,time,startSpeed,randoms0,randoms1,simulationWorldPostion){
  23738. /**@private */
  23739. this._cornerTextureCoordinate=null;
  23740. /**@private */
  23741. this._positionStartLifeTime=null;
  23742. /**@private */
  23743. this._velocity=null;
  23744. /**@private */
  23745. this._startColor=null;
  23746. /**@private */
  23747. this._startSize=null;
  23748. /**@private */
  23749. this._startRotation0=null;
  23750. /**@private */
  23751. this._startRotation1=null;
  23752. /**@private */
  23753. this._startRotation2=null;
  23754. /**@private */
  23755. this._startLifeTime=NaN;
  23756. /**@private */
  23757. this._time=NaN;
  23758. /**@private */
  23759. this._startSpeed=NaN;
  23760. /**@private */
  23761. this._randoms0=null;
  23762. /**@private */
  23763. this._randoms1=null;
  23764. /**@private */
  23765. this._simulationWorldPostion=null;
  23766. VertexShurikenParticleMesh.__super.call(this);
  23767. this._cornerTextureCoordinate=cornerTextureCoordinate;
  23768. this._positionStartLifeTime=positionStartLifeTime;
  23769. this._velocity=velocity;
  23770. this._startColor=startColor;
  23771. this._startSize=startSize;
  23772. this._startRotation0=startRotation0;
  23773. this._startRotation1=startRotation1;
  23774. this._startRotation2=startRotation2;
  23775. this._startLifeTime=ageAddScale;
  23776. this._time=time;
  23777. this._startSpeed=startSpeed;
  23778. this._randoms0=this.random0;
  23779. this._randoms1=this.random1;
  23780. this._simulationWorldPostion=simulationWorldPostion;
  23781. }
  23782. __class(VertexShurikenParticleMesh,'laya.d3.graphics.Vertex.VertexShurikenParticleMesh',_super);
  23783. var __proto=VertexShurikenParticleMesh.prototype;
  23784. __getset(0,__proto,'cornerTextureCoordinate',function(){
  23785. return this._cornerTextureCoordinate;
  23786. });
  23787. __getset(0,__proto,'velocity',function(){
  23788. return this._velocity;
  23789. });
  23790. __getset(0,__proto,'position',function(){
  23791. return this._positionStartLifeTime;
  23792. });
  23793. __getset(0,__proto,'random0',function(){
  23794. return this._randoms0;
  23795. });
  23796. __getset(0,__proto,'startSize',function(){
  23797. return this._startSize;
  23798. });
  23799. __getset(0,__proto,'startColor',function(){
  23800. return this._startColor;
  23801. });
  23802. __getset(0,__proto,'startRotation0',function(){
  23803. return this._startRotation0;
  23804. });
  23805. __getset(0,__proto,'startRotation1',function(){
  23806. return this._startRotation1;
  23807. });
  23808. __getset(0,__proto,'random1',function(){
  23809. return this._randoms1;
  23810. });
  23811. __getset(0,__proto,'startRotation2',function(){
  23812. return this._startRotation2;
  23813. });
  23814. __getset(0,__proto,'startLifeTime',function(){
  23815. return this._startLifeTime;
  23816. });
  23817. __getset(0,__proto,'time',function(){
  23818. return this._time;
  23819. });
  23820. __getset(0,__proto,'startSpeed',function(){
  23821. return this._startSpeed;
  23822. });
  23823. __getset(0,__proto,'simulationWorldPostion',function(){
  23824. return this._simulationWorldPostion;
  23825. });
  23826. __getset(1,VertexShurikenParticleMesh,'vertexDeclaration',function(){
  23827. return VertexShurikenParticleMesh._vertexDeclaration;
  23828. },laya.d3.graphics.Vertex.VertexShuriKenParticle._$SET_vertexDeclaration);
  23829. __static(VertexShurikenParticleMesh,
  23830. ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(172,[
  23831. new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_POSITION0*/1),
  23832. new VertexElement(12,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_COLOR0*/2),
  23833. new VertexElement(28,/*laya.d3.graphics.VertexElementFormat.Vector2*/"vector2",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_TEXTURECOORDINATE0*/3),
  23834. new VertexElement(36,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_SHAPEPOSITIONSTARTLIFETIME*/4),
  23835. new VertexElement(52,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_DIRECTIONTIME*/5),
  23836. new VertexElement(68,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_STARTCOLOR0*/6),
  23837. new VertexElement(84,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_STARTSIZE*/8),
  23838. new VertexElement(96,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_STARTROTATION*/9),
  23839. new VertexElement(108,/*laya.d3.graphics.VertexElementFormat.Single*/"single",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_STARTSPEED*/10),
  23840. new VertexElement(112,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_RANDOM0*/11),
  23841. new VertexElement(128,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_RANDOM1*/12),
  23842. new VertexElement(144,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_SIMULATIONWORLDPOSTION*/13),
  23843. new VertexElement(156,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_SIMULATIONWORLDROTATION*/14)]);}
  23844. ]);
  23845. return VertexShurikenParticleMesh;
  23846. })(VertexShuriKenParticle)
  23847. /**
  23848. *<code>SphereShape</code> 类用于创建球形粒子形状。
  23849. */
  23850. //class laya.d3.core.particleShuriKen.module.shape.SphereShape extends laya.d3.core.particleShuriKen.module.shape.BaseShape
  23851. var SphereShape=(function(_super){
  23852. function SphereShape(){
  23853. /**发射器半径。*/
  23854. this.radius=NaN;
  23855. /**从外壳发射。*/
  23856. this.emitFromShell=false;
  23857. SphereShape.__super.call(this);
  23858. this.radius=1.0;
  23859. this.emitFromShell=false;
  23860. this.randomDirection=false;
  23861. }
  23862. __class(SphereShape,'laya.d3.core.particleShuriKen.module.shape.SphereShape',_super);
  23863. var __proto=SphereShape.prototype;
  23864. /**
  23865. *@inheritDoc
  23866. */
  23867. __proto._getShapeBoundBox=function(boundBox){
  23868. var min=boundBox.min;
  23869. min.x=min.y=min.z=-this.radius;
  23870. var max=boundBox.max;
  23871. max.x=max.y=max.z=this.radius;
  23872. }
  23873. /**
  23874. *@inheritDoc
  23875. */
  23876. __proto._getSpeedBoundBox=function(boundBox){
  23877. var min=boundBox.min;
  23878. min.x=min.y=min.z=-1;
  23879. var max=boundBox.max;
  23880. max.x=max.y=max.z=1;
  23881. }
  23882. /**
  23883. *用于生成粒子初始位置和方向。
  23884. *@param position 粒子位置。
  23885. *@param direction 粒子方向。
  23886. */
  23887. __proto.generatePositionAndDirection=function(position,direction,rand,randomSeeds){
  23888. if (rand){
  23889. rand.seed=randomSeeds[16];
  23890. if (this.emitFromShell)
  23891. ShapeUtils._randomPointUnitSphere(position,rand);
  23892. else
  23893. ShapeUtils._randomPointInsideUnitSphere(position,rand);
  23894. randomSeeds[16]=rand.seed;
  23895. }else {
  23896. if (this.emitFromShell)
  23897. ShapeUtils._randomPointUnitSphere(position);
  23898. else
  23899. ShapeUtils._randomPointInsideUnitSphere(position);
  23900. }
  23901. Vector3.scale(position,this.radius,position);
  23902. if (this.randomDirection){
  23903. if (rand){
  23904. rand.seed=randomSeeds[17];
  23905. ShapeUtils._randomPointUnitSphere(direction,rand);
  23906. randomSeeds[17]=rand.seed;
  23907. }else {
  23908. ShapeUtils._randomPointUnitSphere(direction);
  23909. }
  23910. }else {
  23911. position.cloneTo(direction);
  23912. }
  23913. }
  23914. __proto.cloneTo=function(destObject){
  23915. _super.prototype.cloneTo.call(this,destObject);
  23916. var destShape=destObject;
  23917. destShape.radius=this.radius;
  23918. destShape.emitFromShell=this.emitFromShell;
  23919. destShape.randomDirection=this.randomDirection;
  23920. }
  23921. return SphereShape;
  23922. })(BaseShape)
  23923. /**
  23924. *<code>SimpleSingletonList</code> 类用于实现单例队列。
  23925. */
  23926. //class laya.d3.component.SimpleSingletonList extends laya.d3.component.SingletonList
  23927. var SimpleSingletonList=(function(_super){
  23928. /**
  23929. *创建一个新的 <code>SimpleSingletonList</code> 实例。
  23930. */
  23931. function SimpleSingletonList(){
  23932. SimpleSingletonList.__super.call(this);
  23933. }
  23934. __class(SimpleSingletonList,'laya.d3.component.SimpleSingletonList',_super);
  23935. var __proto=SimpleSingletonList.prototype;
  23936. /**
  23937. *@private
  23938. */
  23939. __proto.add=function(element){
  23940. var index=element._getIndexInList();
  23941. if (index!==-1)
  23942. // throw "SimpleSingletonList:"+element+" has in SingletonList.";
  23943. return;
  23944. this._add(element);
  23945. element._setIndexInList(this.length++);
  23946. }
  23947. /**
  23948. *@private
  23949. */
  23950. __proto.remove=function(element){
  23951. var index=element._getIndexInList();
  23952. this.length--;
  23953. if (index!==this.length){
  23954. var end=this.elements[this.length];
  23955. this.elements[index]=end;
  23956. if(end){
  23957. end._setIndexInList(index);
  23958. }
  23959. }
  23960. if(element){
  23961. element._setIndexInList(-1);
  23962. }
  23963. }
  23964. return SimpleSingletonList;
  23965. })(SingletonList)
  23966. /**
  23967. *<code>CastShadowList</code> 类用于实现产生阴影者队列。
  23968. */
  23969. //class laya.d3.CastShadowList extends laya.d3.component.SingletonList
  23970. var CastShadowList=(function(_super){
  23971. /**
  23972. *创建一个新的 <code>CastShadowList</code> 实例。
  23973. */
  23974. function CastShadowList(){
  23975. CastShadowList.__super.call(this);
  23976. }
  23977. __class(CastShadowList,'laya.d3.CastShadowList',_super);
  23978. var __proto=CastShadowList.prototype;
  23979. /**
  23980. *@private
  23981. */
  23982. __proto.add=function(element){
  23983. var index=element._indexInCastShadowList;
  23984. if (index!==-1)
  23985. throw "CastShadowList:element has in CastShadowList.";
  23986. this._add(element);
  23987. element._indexInCastShadowList=this.length++;
  23988. }
  23989. /**
  23990. *@private
  23991. */
  23992. __proto.remove=function(element){
  23993. var index=element._indexInCastShadowList;
  23994. this.length--;
  23995. if (index!==this.length){
  23996. var end=this.elements[this.length];
  23997. this.elements[index]=end;
  23998. end._indexInCastShadowList=index;
  23999. }
  24000. element._indexInCastShadowList=-1;
  24001. }
  24002. return CastShadowList;
  24003. })(SingletonList)
  24004. /**
  24005. *<code>HemisphereShape</code> 类用于创建半球形粒子形状。
  24006. */
  24007. //class laya.d3.core.particleShuriKen.module.shape.HemisphereShape extends laya.d3.core.particleShuriKen.module.shape.BaseShape
  24008. var HemisphereShape=(function(_super){
  24009. function HemisphereShape(){
  24010. /**发射器半径。*/
  24011. this.radius=NaN;
  24012. /**从外壳发射。*/
  24013. this.emitFromShell=false;
  24014. HemisphereShape.__super.call(this);
  24015. this.radius=1.0;
  24016. this.emitFromShell=false;
  24017. this.randomDirection=false;
  24018. }
  24019. __class(HemisphereShape,'laya.d3.core.particleShuriKen.module.shape.HemisphereShape',_super);
  24020. var __proto=HemisphereShape.prototype;
  24021. /**
  24022. *@inheritDoc
  24023. */
  24024. __proto._getShapeBoundBox=function(boundBox){
  24025. var min=boundBox.min;
  24026. min.x=min.y=min.z=-this.radius;
  24027. var max=boundBox.max;
  24028. max.x=max.y=this.radius;
  24029. max.z=0;
  24030. }
  24031. /**
  24032. *@inheritDoc
  24033. */
  24034. __proto._getSpeedBoundBox=function(boundBox){
  24035. var min=boundBox.min;
  24036. min.x=min.y=-1;
  24037. min.z=0;
  24038. var max=boundBox.max;
  24039. max.x=max.y=max.z=1;
  24040. }
  24041. /**
  24042. *用于生成粒子初始位置和方向。
  24043. *@param position 粒子位置。
  24044. *@param direction 粒子方向。
  24045. */
  24046. __proto.generatePositionAndDirection=function(position,direction,rand,randomSeeds){
  24047. if (rand){
  24048. rand.seed=randomSeeds[16];
  24049. if (this.emitFromShell)
  24050. ShapeUtils._randomPointUnitSphere(position,rand);
  24051. else
  24052. ShapeUtils._randomPointInsideUnitSphere(position,rand);
  24053. randomSeeds[16]=rand.seed;
  24054. }else {
  24055. if (this.emitFromShell)
  24056. ShapeUtils._randomPointUnitSphere(position);
  24057. else
  24058. ShapeUtils._randomPointInsideUnitSphere(position);
  24059. }
  24060. Vector3.scale(position,this.radius,position);
  24061. var z=position.z;
  24062. (z < 0.0)&& (position.z=z *-1.0);
  24063. if (this.randomDirection){
  24064. if (rand){
  24065. rand.seed=randomSeeds[17];
  24066. ShapeUtils._randomPointUnitSphere(direction,rand);
  24067. randomSeeds[17]=rand.seed;
  24068. }else {
  24069. ShapeUtils._randomPointUnitSphere(direction);
  24070. }
  24071. }else {
  24072. position.cloneTo(direction);
  24073. }
  24074. }
  24075. __proto.cloneTo=function(destObject){
  24076. _super.prototype.cloneTo.call(this,destObject);
  24077. var destShape=destObject;
  24078. destShape.radius=this.radius;
  24079. destShape.emitFromShell=this.emitFromShell;
  24080. destShape.randomDirection=this.randomDirection;
  24081. }
  24082. return HemisphereShape;
  24083. })(BaseShape)
  24084. /**
  24085. *@private
  24086. */
  24087. //class laya.d3.graphics.SubMeshInstanceBatch extends laya.d3.core.GeometryElement
  24088. var SubMeshInstanceBatch=(function(_super){
  24089. function SubMeshInstanceBatch(){
  24090. /**@private */
  24091. this.maxInstanceCount=1024;
  24092. SubMeshInstanceBatch.__super.call(this);
  24093. this.instanceWorldMatrixData=new Float32Array(this.maxInstanceCount *16);
  24094. this.instanceMVPMatrixData=new Float32Array(this.maxInstanceCount *16);
  24095. this.instanceWorldMatrixBuffer=new VertexBuffer3D(this.instanceWorldMatrixData.length *4,/*laya.webgl.WebGLContext.DYNAMIC_DRAW*/0x88E8);
  24096. this.instanceMVPMatrixBuffer=new VertexBuffer3D(this.instanceMVPMatrixData.length *4,/*laya.webgl.WebGLContext.DYNAMIC_DRAW*/0x88E8);
  24097. this.instanceWorldMatrixBuffer.vertexDeclaration=VertexMesh.instanceWorldMatrixDeclaration;
  24098. this.instanceMVPMatrixBuffer.vertexDeclaration=VertexMesh.instanceMVPMatrixDeclaration;
  24099. }
  24100. __class(SubMeshInstanceBatch,'laya.d3.graphics.SubMeshInstanceBatch',_super);
  24101. var __proto=SubMeshInstanceBatch.prototype;
  24102. /**
  24103. *@inheritDoc
  24104. */
  24105. __proto._render=function(state){
  24106. var element=state.renderElement;
  24107. var subMesh=element.instanceSubMesh;
  24108. var count=element.instanceBatchElementList.length;
  24109. var indexCount=subMesh._indexCount;
  24110. subMesh._mesh._instanceBufferState.bind();
  24111. WebGLContext._angleInstancedArrays.drawElementsInstancedANGLE(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,indexCount,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,subMesh._indexStart *2,count);
  24112. Stat.renderBatches++;
  24113. Stat.savedRenderBatches+=count-1;
  24114. Stat.trianglesFaces+=indexCount *count / 3;
  24115. }
  24116. __static(SubMeshInstanceBatch,
  24117. ['instance',function(){return this.instance=new SubMeshInstanceBatch();}
  24118. ]);
  24119. return SubMeshInstanceBatch;
  24120. })(GeometryElement)
  24121. /**
  24122. *<code>TerrainFilter</code> 类用于创建TerrainFilter过滤器。
  24123. */
  24124. //class laya.d3.terrain.TerrainFilter extends laya.d3.core.GeometryElement
  24125. var TerrainFilter=(function(_super){
  24126. function TerrainFilter(owner,chunkOffsetX,chunkOffsetZ,gridSize,terrainHeightData,heightDataWidth,heightDataHeight,cameraCoordinateInverse){
  24127. this._owner=null;
  24128. this._gridSize=NaN;
  24129. this.memorySize=0;
  24130. this._numberVertices=0;
  24131. this._maxNumberIndices=0;
  24132. this._currentNumberIndices=0;
  24133. this._numberTriangle=0;
  24134. this._vertexBuffer=null;
  24135. this._indexBuffer=null;
  24136. this._indexArrayBuffer=null;
  24137. this._boundingBoxCorners=null;
  24138. this._leafs=null;
  24139. this._leafNum=0;
  24140. this._terrainHeightData=null;
  24141. this._terrainHeightDataWidth=0;
  24142. this._terrainHeightDataHeight=0;
  24143. this._chunkOffsetX=0;
  24144. this._chunkOffsetZ=0;
  24145. this._cameraCoordinateInverse=false;
  24146. this._cameraPos=null;
  24147. this._currentLOD=0;
  24148. //LOD级别 4个叶子节点 第1个叶子的level<<24+第2个叶子的level<<16+第3个叶子的level<<8+第4个叶子的level
  24149. this._perspectiveFactor=NaN;
  24150. this._LODTolerance=0;
  24151. /**@private */
  24152. this._boundingSphere=null;
  24153. /**@private */
  24154. this._boundingBox=null;
  24155. TerrainFilter.__super.call(this);
  24156. this._bufferState=new BufferState();
  24157. this._owner=owner;
  24158. this._cameraPos=new Vector3();
  24159. this._chunkOffsetX=chunkOffsetX;
  24160. this._chunkOffsetZ=chunkOffsetZ;
  24161. this._gridSize=gridSize;
  24162. this._terrainHeightData=terrainHeightData;
  24163. this._terrainHeightDataWidth=heightDataWidth;
  24164. this._terrainHeightDataHeight=heightDataHeight;
  24165. this._leafNum=(TerrainLeaf.CHUNK_GRID_NUM / TerrainLeaf.LEAF_GRID_NUM)*(TerrainLeaf.CHUNK_GRID_NUM / TerrainLeaf.LEAF_GRID_NUM);
  24166. this._leafs=__newvec(this._leafNum);
  24167. this._cameraCoordinateInverse=cameraCoordinateInverse;
  24168. for (var i=0;i < this._leafNum;i++){
  24169. this._leafs[i]=new TerrainLeaf();
  24170. }
  24171. this.recreateResource();
  24172. }
  24173. __class(TerrainFilter,'laya.d3.terrain.TerrainFilter',_super);
  24174. var __proto=TerrainFilter.prototype;
  24175. __proto.recreateResource=function(){
  24176. this._currentNumberIndices=0;
  24177. this._numberTriangle=0;
  24178. var nLeafVertexCount=TerrainLeaf.LEAF_VERTEXT_COUNT;
  24179. var nLeafIndexCount=TerrainLeaf.LEAF_MAX_INDEX_COUNT;
  24180. this._numberVertices=nLeafVertexCount *this._leafNum;
  24181. this._maxNumberIndices=nLeafIndexCount *this._leafNum;
  24182. this._indexArrayBuffer=new Uint16Array(this._maxNumberIndices);
  24183. var vertexDeclaration=VertexPositionTerrain.vertexDeclaration;
  24184. var vertexFloatStride=vertexDeclaration.vertexStride / 4;
  24185. var vertices=new Float32Array(this._numberVertices *vertexFloatStride);
  24186. var nNum=TerrainLeaf.CHUNK_GRID_NUM / TerrainLeaf.LEAF_GRID_NUM;
  24187. var i=0,x=0,z=0;
  24188. for (i=0;i < this._leafNum;i++){
  24189. x=i % nNum;
  24190. z=Math.floor(i / nNum);
  24191. 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);
  24192. }
  24193. for (i=0;i < this._leafNum;i++){
  24194. x=i % nNum;
  24195. z=Math.floor(i / nNum);
  24196. 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);
  24197. }
  24198. this.assembleIndexInit();
  24199. this._vertexBuffer=new VertexBuffer3D(vertexDeclaration.vertexStride *this._numberVertices,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,false);
  24200. this._vertexBuffer.vertexDeclaration=vertexDeclaration;
  24201. this._indexBuffer=new IndexBuffer3D(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",this._maxNumberIndices,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,false);
  24202. this._vertexBuffer.setData(vertices);
  24203. this._indexBuffer.setData(this._indexArrayBuffer);
  24204. this.memorySize=(this._vertexBuffer._byteLength+this._indexBuffer._byteLength)*2;
  24205. this.calcOriginalBoudingBoxAndSphere();
  24206. this._bufferState.bind();
  24207. this._bufferState.applyVertexBuffer(this._vertexBuffer);
  24208. this._bufferState.applyIndexBuffer(this._indexBuffer);
  24209. this._bufferState.unBind();
  24210. }
  24211. __proto.setLODLevel=function(leafsLODLevel){
  24212. if (leafsLODLevel.length !=4)return true;
  24213. var nLOD=((leafsLODLevel[0]+1)<< 24)+((leafsLODLevel[1]+1)<< 16)+((leafsLODLevel[2]+1)<< 8)+(leafsLODLevel[3]+1);
  24214. if (this._currentLOD==nLOD){
  24215. return false;
  24216. }
  24217. this._currentLOD=nLOD;
  24218. return true;
  24219. }
  24220. __proto.assembleIndexInit=function(){
  24221. this._currentNumberIndices=0;
  24222. this._numberTriangle=0;
  24223. var nOffsetIndex=0;
  24224. for (var i=0;i < this._leafNum;i++){
  24225. var planeLODIndex=TerrainLeaf.getPlaneLODIndex(i,0);
  24226. this._indexArrayBuffer.set(planeLODIndex,nOffsetIndex);
  24227. nOffsetIndex+=planeLODIndex.length;
  24228. var skirtLODIndex=TerrainLeaf.getSkirtLODIndex(i,0);
  24229. this._indexArrayBuffer.set(skirtLODIndex,nOffsetIndex);
  24230. nOffsetIndex+=skirtLODIndex.length;
  24231. this._currentNumberIndices+=(planeLODIndex.length+skirtLODIndex.length);
  24232. }
  24233. this._numberTriangle=this._currentNumberIndices / 3;
  24234. }
  24235. __proto.isNeedAssemble=function(camera,cameraPostion){
  24236. var perspectiveFactor=Math.min(camera.viewport.width,camera.viewport.height)/ (2 *Math.tan(Math.PI *camera.fieldOfView / 180.0));
  24237. if (this._perspectiveFactor !=perspectiveFactor){
  24238. this._perspectiveFactor=perspectiveFactor;
  24239. return 1;
  24240. }
  24241. if (this._LODTolerance !=Terrain.LOD_TOLERANCE_VALUE){
  24242. this._LODTolerance=Terrain.LOD_TOLERANCE_VALUE;
  24243. return 1;
  24244. }
  24245. if (Vector3.equals(cameraPostion,this._cameraPos)==false){
  24246. this._cameraPos.x=cameraPostion.x;
  24247. this._cameraPos.y=cameraPostion.y;
  24248. this._cameraPos.z=cameraPostion.z;
  24249. return 2;
  24250. }
  24251. return 0;
  24252. }
  24253. __proto.assembleIndex=function(camera,cameraPostion){
  24254. var nNeedType=this.isNeedAssemble(camera,cameraPostion);
  24255. if (nNeedType > 0){
  24256. for (var i=0;i < this._leafNum;i++){
  24257. TerrainFilter._TEMP_ARRAY_BUFFER[i]=this._leafs[i].determineLod(cameraPostion,this._perspectiveFactor,Terrain.LOD_TOLERANCE_VALUE,nNeedType==1);
  24258. }
  24259. if (this.setLODLevel(TerrainFilter._TEMP_ARRAY_BUFFER)){
  24260. this._currentNumberIndices=0;
  24261. this._numberTriangle=0;
  24262. var nOffsetIndex=0;
  24263. for (i=0;i < this._leafNum;i++){
  24264. var nLODLevel=TerrainFilter._TEMP_ARRAY_BUFFER[i];
  24265. var planeLODIndex=TerrainLeaf.getPlaneLODIndex(i,nLODLevel);
  24266. this._indexArrayBuffer.set(planeLODIndex,nOffsetIndex);
  24267. nOffsetIndex+=planeLODIndex.length;
  24268. var skirtLODIndex=TerrainLeaf.getSkirtLODIndex(i,nLODLevel);
  24269. this._indexArrayBuffer.set(skirtLODIndex,nOffsetIndex);
  24270. nOffsetIndex+=skirtLODIndex.length;
  24271. this._currentNumberIndices+=(planeLODIndex.length+skirtLODIndex.length);
  24272. }
  24273. this._numberTriangle=this._currentNumberIndices / 3;
  24274. return true;
  24275. }
  24276. }
  24277. return false;
  24278. }
  24279. __proto.calcOriginalBoudingBoxAndSphere=function(){
  24280. var sizeOfY=new Vector2(2147483647,-2147483647);
  24281. for (var i=0;i < this._leafNum;i++){
  24282. sizeOfY.x=this._leafs[i]._sizeOfY.x < sizeOfY.x ? this._leafs[i]._sizeOfY.x :sizeOfY.x;
  24283. sizeOfY.y=this._leafs[i]._sizeOfY.y > sizeOfY.y ? this._leafs[i]._sizeOfY.y :sizeOfY.y;
  24284. };
  24285. var min=new Vector3(this._chunkOffsetX *TerrainLeaf.CHUNK_GRID_NUM *this._gridSize,sizeOfY.x,this._chunkOffsetZ *TerrainLeaf.CHUNK_GRID_NUM *this._gridSize);
  24286. var max=new Vector3((this._chunkOffsetX+1)*TerrainLeaf.CHUNK_GRID_NUM *this._gridSize,sizeOfY.y,(this._chunkOffsetZ+1)*TerrainLeaf.CHUNK_GRID_NUM *this._gridSize);
  24287. if (TerrainLeaf.__ADAPT_MATRIX__){
  24288. Vector3.transformV3ToV3(min,TerrainLeaf.__ADAPT_MATRIX__,min);
  24289. Vector3.transformV3ToV3(max,TerrainLeaf.__ADAPT_MATRIX__,max);
  24290. }
  24291. this._boundingBox=new BoundBox(min,max);
  24292. var size=new Vector3();
  24293. Vector3.subtract(max,min,size);
  24294. Vector3.scale(size,0.5,size);
  24295. var center=new Vector3();
  24296. Vector3.add(min,size,center);
  24297. this._boundingSphere=new BoundSphere(center,Vector3.scalarLength(size));
  24298. this._boundingBoxCorners=__newvec(8,null);
  24299. this._boundingBox.getCorners(this._boundingBoxCorners);
  24300. }
  24301. __proto.calcLeafBoudingBox=function(worldMatrix){
  24302. for (var i=0;i < this._leafNum;i++){
  24303. this._leafs[i].calcLeafBoudingBox(worldMatrix);
  24304. }
  24305. }
  24306. __proto.calcLeafBoudingSphere=function(worldMatrix,maxScale){
  24307. for (var i=0;i < this._leafNum;i++){
  24308. this._leafs[i].calcLeafBoudingSphere(worldMatrix,maxScale);
  24309. }
  24310. }
  24311. __proto._getVertexBuffer=function(index){
  24312. (index===void 0)&& (index=0);
  24313. if (index==0){
  24314. return this._vertexBuffer;
  24315. }
  24316. return null;
  24317. }
  24318. __proto._getIndexBuffer=function(){
  24319. return this._indexBuffer;
  24320. }
  24321. /**
  24322. *@inheritDoc
  24323. */
  24324. __proto._getType=function(){
  24325. return TerrainFilter._type;
  24326. }
  24327. /**
  24328. *@inheritDoc
  24329. */
  24330. __proto._prepareRender=function(state){
  24331. return true;
  24332. }
  24333. /**
  24334. *@inheritDoc
  24335. */
  24336. __proto._render=function(state){
  24337. this._bufferState.bind();
  24338. 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);
  24339. Stat.trianglesFaces+=this._numberTriangle;
  24340. Stat.renderBatches++;
  24341. }
  24342. /**
  24343. *@inheritDoc
  24344. */
  24345. __proto.destroy=function(){
  24346. this._owner=null;
  24347. this._bufferState.destroy();
  24348. if (this._vertexBuffer)this._vertexBuffer.destroy();
  24349. if (this._indexBuffer)this._indexBuffer.destroy();
  24350. }
  24351. __static(TerrainFilter,
  24352. ['_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++;}
  24353. ]);
  24354. return TerrainFilter;
  24355. })(GeometryElement)
  24356. /**
  24357. *<code>CircleShape</code> 类用于创建环形粒子形状。
  24358. */
  24359. //class laya.d3.core.particleShuriKen.module.shape.CircleShape extends laya.d3.core.particleShuriKen.module.shape.BaseShape
  24360. var CircleShape=(function(_super){
  24361. function CircleShape(){
  24362. /**发射器半径。*/
  24363. this.radius=NaN;
  24364. /**环形弧度。*/
  24365. this.arc=NaN;
  24366. /**从边缘发射。*/
  24367. this.emitFromEdge=false;
  24368. CircleShape.__super.call(this);
  24369. this.radius=1.0;
  24370. this.arc=360.0 / 180.0 *Math.PI;
  24371. this.emitFromEdge=false;
  24372. this.randomDirection=false;
  24373. }
  24374. __class(CircleShape,'laya.d3.core.particleShuriKen.module.shape.CircleShape',_super);
  24375. var __proto=CircleShape.prototype;
  24376. /**
  24377. *@inheritDoc
  24378. */
  24379. __proto._getShapeBoundBox=function(boundBox){
  24380. var min=boundBox.min;
  24381. min.x=min.z=-this.radius;
  24382. min.y=0;
  24383. var max=boundBox.max;
  24384. max.x=max.z=this.radius;
  24385. max.y=0;
  24386. }
  24387. /**
  24388. *@inheritDoc
  24389. */
  24390. __proto._getSpeedBoundBox=function(boundBox){
  24391. var min=boundBox.min;
  24392. min.x=min.y=-1;
  24393. min.z=0;
  24394. var max=boundBox.max;
  24395. max.x=max.y=1;
  24396. max.z=0;
  24397. }
  24398. /**
  24399. *用于生成粒子初始位置和方向。
  24400. *@param position 粒子位置。
  24401. *@param direction 粒子方向。
  24402. */
  24403. __proto.generatePositionAndDirection=function(position,direction,rand,randomSeeds){
  24404. var positionPoint=CircleShape._tempPositionPoint;
  24405. if (rand){
  24406. rand.seed=randomSeeds[16];
  24407. if (this.emitFromEdge)
  24408. ShapeUtils._randomPointUnitArcCircle(this.arc,CircleShape._tempPositionPoint,rand);
  24409. else
  24410. ShapeUtils._randomPointInsideUnitArcCircle(this.arc,CircleShape._tempPositionPoint,rand);
  24411. randomSeeds[16]=rand.seed;
  24412. }else {
  24413. if (this.emitFromEdge)
  24414. ShapeUtils._randomPointUnitArcCircle(this.arc,CircleShape._tempPositionPoint);
  24415. else
  24416. ShapeUtils._randomPointInsideUnitArcCircle(this.arc,CircleShape._tempPositionPoint);
  24417. }
  24418. position.x=-positionPoint.x;
  24419. position.y=positionPoint.y;
  24420. position.z=0;
  24421. Vector3.scale(position,this.radius,position);
  24422. if (this.randomDirection){
  24423. if (rand){
  24424. rand.seed=randomSeeds[17];
  24425. ShapeUtils._randomPointUnitSphere(direction,rand);
  24426. randomSeeds[17]=rand.seed;
  24427. }else {
  24428. ShapeUtils._randomPointUnitSphere(direction);
  24429. }
  24430. }else {
  24431. position.cloneTo(direction);
  24432. }
  24433. }
  24434. __proto.cloneTo=function(destObject){
  24435. _super.prototype.cloneTo.call(this,destObject);
  24436. var destShape=destObject;
  24437. destShape.radius=this.radius;
  24438. destShape.arc=this.arc;
  24439. destShape.emitFromEdge=this.emitFromEdge;
  24440. destShape.randomDirection=this.randomDirection;
  24441. }
  24442. __static(CircleShape,
  24443. ['_tempPositionPoint',function(){return this._tempPositionPoint=new Vector2();}
  24444. ]);
  24445. return CircleShape;
  24446. })(BaseShape)
  24447. /**
  24448. *<code>MeshColliderShape</code> 类用于创建网格碰撞器。
  24449. */
  24450. //class laya.d3.physics.shape.MeshColliderShape extends laya.d3.physics.shape.ColliderShape
  24451. var MeshColliderShape=(function(_super){
  24452. function MeshColliderShape(){
  24453. /**@private */
  24454. this._mesh=null;
  24455. /**@private */
  24456. this._convex=false;
  24457. MeshColliderShape.__super.call(this);
  24458. }
  24459. __class(MeshColliderShape,'laya.d3.physics.shape.MeshColliderShape',_super);
  24460. var __proto=MeshColliderShape.prototype;
  24461. /**
  24462. *@inheritDoc
  24463. */
  24464. __proto._setScale=function(value){
  24465. if (this._compoundParent){
  24466. this.updateLocalTransformations();
  24467. }else {
  24468. ColliderShape._nativeScale.setValue(value.x,value.y,value.z);
  24469. this._nativeShape.setLocalScaling(ColliderShape._nativeScale);
  24470. this._nativeShape.updateBound();
  24471. }
  24472. }
  24473. /**
  24474. *@inheritDoc
  24475. */
  24476. __proto.cloneTo=function(destObject){
  24477. var destMeshCollider=destObject;
  24478. destMeshCollider.convex=this._convex;
  24479. destMeshCollider.mesh=this._mesh;
  24480. _super.prototype.cloneTo.call(this,destObject);
  24481. }
  24482. /**
  24483. *@inheritDoc
  24484. */
  24485. __proto.clone=function(){
  24486. var dest=new MeshColliderShape();
  24487. this.cloneTo(dest);
  24488. return dest;
  24489. }
  24490. /**
  24491. *@inheritDoc
  24492. */
  24493. __proto.destroy=function(){
  24494. if (this._nativeShape){
  24495. var physics3D=Laya3D._physics3D;
  24496. physics3D.destroy(this._nativeShape);
  24497. this._nativeShape=null;
  24498. }
  24499. }
  24500. /**
  24501. *设置网格。
  24502. *@param 网格。
  24503. */
  24504. /**
  24505. *获取网格。
  24506. *@return 网格。
  24507. */
  24508. __getset(0,__proto,'mesh',function(){
  24509. return this._mesh;
  24510. },function(value){
  24511. if (this._mesh!==value){
  24512. var physics3D=Laya3D._physics3D;
  24513. if (this._mesh){
  24514. physics3D.destroy(this._nativeShape);
  24515. }
  24516. if (value){
  24517. this._nativeShape=new physics3D.btGImpactMeshShape(value._getPhysicMesh());
  24518. this._nativeShape.updateBound();
  24519. }
  24520. this._mesh=value;
  24521. }
  24522. });
  24523. /**
  24524. *设置是否使用凸多边形。
  24525. *@param value 是否使用凸多边形。
  24526. */
  24527. /**
  24528. *获取是否使用凸多边形。
  24529. *@return 是否使用凸多边形。
  24530. */
  24531. __getset(0,__proto,'convex',function(){
  24532. return this._convex;
  24533. },function(value){
  24534. this._convex=value;
  24535. });
  24536. return MeshColliderShape;
  24537. })(ColliderShape)
  24538. /**
  24539. *<code>BoxColliderShape</code> 类用于创建盒子形状碰撞器。
  24540. */
  24541. //class laya.d3.physics.shape.BoxColliderShape extends laya.d3.physics.shape.ColliderShape
  24542. var BoxColliderShape=(function(_super){
  24543. function BoxColliderShape(sizeX,sizeY,sizeZ){
  24544. /**@private */
  24545. //this._sizeX=NaN;
  24546. /**@private */
  24547. //this._sizeY=NaN;
  24548. /**@private */
  24549. //this._sizeZ=NaN;
  24550. BoxColliderShape.__super.call(this);
  24551. (sizeX===void 0)&& (sizeX=1.0);
  24552. (sizeY===void 0)&& (sizeY=1.0);
  24553. (sizeZ===void 0)&& (sizeZ=1.0);
  24554. this._sizeX=sizeX;
  24555. this._sizeY=sizeY;
  24556. this._sizeZ=sizeZ;
  24557. this._type=/*laya.d3.physics.shape.ColliderShape.SHAPETYPES_BOX*/0;
  24558. BoxColliderShape._nativeSize.setValue(sizeX / 2,sizeY / 2,sizeZ / 2);
  24559. this._nativeShape=new Laya3D._physics3D.btBoxShape(BoxColliderShape._nativeSize);
  24560. }
  24561. __class(BoxColliderShape,'laya.d3.physics.shape.BoxColliderShape',_super);
  24562. var __proto=BoxColliderShape.prototype;
  24563. /**
  24564. *@inheritDoc
  24565. */
  24566. __proto.clone=function(){
  24567. var dest=new BoxColliderShape(this._sizeX,this._sizeY,this._sizeZ);
  24568. this.cloneTo(dest);
  24569. return dest;
  24570. }
  24571. /**
  24572. *获取X轴尺寸。
  24573. */
  24574. __getset(0,__proto,'sizeX',function(){
  24575. return this._sizeX;
  24576. });
  24577. /**
  24578. *获取Y轴尺寸。
  24579. */
  24580. __getset(0,__proto,'sizeY',function(){
  24581. return this._sizeY;
  24582. });
  24583. /**
  24584. *获取Z轴尺寸。
  24585. */
  24586. __getset(0,__proto,'sizeZ',function(){
  24587. return this._sizeZ;
  24588. });
  24589. __static(BoxColliderShape,
  24590. ['_nativeSize',function(){return this._nativeSize=new Laya3D._physics3D.btVector3(0,0,0);}
  24591. ]);
  24592. return BoxColliderShape;
  24593. })(ColliderShape)
  24594. /**
  24595. *@private
  24596. *<code>SetRenderTargetCMD</code> 类用于创建设置渲染目标指令。
  24597. */
  24598. //class laya.d3.core.render.command.SetRenderTargetCMD extends laya.d3.core.render.command.Command
  24599. var SetRenderTargetCMD=(function(_super){
  24600. function SetRenderTargetCMD(){
  24601. /**@private */
  24602. this._renderTexture=null;
  24603. SetRenderTargetCMD.__super.call(this);
  24604. }
  24605. __class(SetRenderTargetCMD,'laya.d3.core.render.command.SetRenderTargetCMD',_super);
  24606. var __proto=SetRenderTargetCMD.prototype;
  24607. /**
  24608. *@inheritDoc
  24609. */
  24610. __proto.run=function(){
  24611. this._renderTexture._start();
  24612. }
  24613. /**
  24614. *@inheritDoc
  24615. */
  24616. __proto.recover=function(){
  24617. SetRenderTargetCMD._pool.push(this);
  24618. this._renderTexture=null;
  24619. }
  24620. SetRenderTargetCMD.create=function(renderTexture){
  24621. var cmd;
  24622. cmd=SetRenderTargetCMD._pool.length > 0 ? SetRenderTargetCMD._pool.pop():new SetRenderTargetCMD();
  24623. cmd._renderTexture=renderTexture;
  24624. return cmd;
  24625. }
  24626. SetRenderTargetCMD._pool=[];
  24627. return SetRenderTargetCMD;
  24628. })(Command)
  24629. /**
  24630. *<code>PhysicsUpdateList</code> 类用于实现物理更新队列。
  24631. */
  24632. //class laya.d3.physics.PhysicsUpdateList extends laya.d3.component.SingletonList
  24633. var PhysicsUpdateList=(function(_super){
  24634. /**
  24635. *创建一个新的 <code>PhysicsUpdateList</code> 实例。
  24636. */
  24637. function PhysicsUpdateList(){
  24638. PhysicsUpdateList.__super.call(this);
  24639. }
  24640. __class(PhysicsUpdateList,'laya.d3.physics.PhysicsUpdateList',_super);
  24641. var __proto=PhysicsUpdateList.prototype;
  24642. /**
  24643. *@private
  24644. */
  24645. __proto.add=function(element){
  24646. var index=element._inPhysicUpdateListIndex;
  24647. if (index!==-1)
  24648. throw "PhysicsUpdateList:element has in PhysicsUpdateList.";
  24649. this._add(element);
  24650. element._inPhysicUpdateListIndex=this.length++;
  24651. }
  24652. /**
  24653. *@private
  24654. */
  24655. __proto.remove=function(element){
  24656. var index=element._inPhysicUpdateListIndex;
  24657. this.length--;
  24658. if (index!==this.length){
  24659. var end=this.elements[this.length];
  24660. this.elements[index]=end;
  24661. end._inPhysicUpdateListIndex=index;
  24662. }
  24663. element._inPhysicUpdateListIndex=-1;
  24664. }
  24665. return PhysicsUpdateList;
  24666. })(SingletonList)
  24667. /**
  24668. *<code>ConeShape</code> 类用于创建锥形粒子形状。
  24669. */
  24670. //class laya.d3.core.particleShuriKen.module.shape.ConeShape extends laya.d3.core.particleShuriKen.module.shape.BaseShape
  24671. var ConeShape=(function(_super){
  24672. function ConeShape(){
  24673. /**发射角度。*/
  24674. this.angle=NaN;
  24675. /**发射器半径。*/
  24676. this.radius=NaN;
  24677. /**椎体长度。*/
  24678. this.length=NaN;
  24679. /**发射类型,0为Base,1为BaseShell,2为Volume,3为VolumeShell。*/
  24680. this.emitType=0;
  24681. ConeShape.__super.call(this);
  24682. this.angle=25.0 / 180.0 *Math.PI;
  24683. this.radius=1.0;
  24684. this.length=5.0;
  24685. this.emitType=0;
  24686. this.randomDirection=false;
  24687. }
  24688. __class(ConeShape,'laya.d3.core.particleShuriKen.module.shape.ConeShape',_super);
  24689. var __proto=ConeShape.prototype;
  24690. /**
  24691. *@inheritDoc
  24692. */
  24693. __proto._getShapeBoundBox=function(boundBox){
  24694. var coneRadius2=this.radius+this.length *Math.sin(this.angle);
  24695. var coneLength=this.length *Math.cos(this.angle);
  24696. var min=boundBox.min;
  24697. min.x=min.y=-coneRadius2;
  24698. min.z=0;
  24699. var max=boundBox.max;
  24700. max.x=max.y=coneRadius2;
  24701. max.z=coneLength;
  24702. }
  24703. /**
  24704. *@inheritDoc
  24705. */
  24706. __proto._getSpeedBoundBox=function(boundBox){
  24707. var sinA=Math.sin(this.angle);
  24708. var min=boundBox.min;
  24709. min.x=min.y=-sinA;
  24710. min.z=0;
  24711. var max=boundBox.max;
  24712. max.x=max.y=sinA;
  24713. max.z=1;
  24714. }
  24715. /**
  24716. *用于生成粒子初始位置和方向。
  24717. *@param position 粒子位置。
  24718. *@param direction 粒子方向。
  24719. */
  24720. __proto.generatePositionAndDirection=function(position,direction,rand,randomSeeds){
  24721. var positionPointE=ConeShape._tempPositionPoint;
  24722. var positionX=NaN;
  24723. var positionY=NaN;
  24724. var directionPointE;
  24725. var dirCosA=Math.cos(this.angle);
  24726. var dirSinA=Math.sin(this.angle);
  24727. switch (this.emitType){
  24728. case 0:
  24729. if (rand){
  24730. rand.seed=randomSeeds[16];
  24731. ShapeUtils._randomPointInsideUnitCircle(ConeShape._tempPositionPoint,rand);
  24732. randomSeeds[16]=rand.seed;
  24733. }else {
  24734. ShapeUtils._randomPointInsideUnitCircle(ConeShape._tempPositionPoint);
  24735. }
  24736. positionX=positionPointE.x;
  24737. positionY=positionPointE.y;
  24738. position.x=positionX *this.radius;
  24739. position.y=positionY *this.radius;
  24740. position.z=0;
  24741. if (this.randomDirection){
  24742. if (rand){
  24743. rand.seed=randomSeeds[17];
  24744. ShapeUtils._randomPointInsideUnitCircle(ConeShape._tempDirectionPoint,rand);
  24745. randomSeeds[17]=rand.seed;
  24746. }else {
  24747. ShapeUtils._randomPointInsideUnitCircle(ConeShape._tempDirectionPoint);
  24748. }
  24749. directionPointE=ConeShape._tempDirectionPoint;
  24750. direction.x=directionPointE.x *dirSinA;
  24751. direction.y=directionPointE.y *dirSinA;
  24752. }else {
  24753. direction.x=positionX *dirSinA;
  24754. direction.y=positionY *dirSinA;
  24755. }
  24756. direction.z=dirCosA;
  24757. break ;
  24758. case 1:
  24759. if (rand){
  24760. rand.seed=randomSeeds[16];
  24761. ShapeUtils._randomPointUnitCircle(ConeShape._tempPositionPoint,rand);
  24762. randomSeeds[16]=rand.seed;
  24763. }else {
  24764. ShapeUtils._randomPointUnitCircle(ConeShape._tempPositionPoint);
  24765. }
  24766. positionX=positionPointE.x;
  24767. positionY=positionPointE.y;
  24768. position.x=positionX *this.radius;
  24769. position.y=positionY *this.radius;
  24770. position.z=0;
  24771. if (this.randomDirection){
  24772. if (rand){
  24773. rand.seed=randomSeeds[17];
  24774. ShapeUtils._randomPointInsideUnitCircle(ConeShape._tempDirectionPoint,rand);
  24775. randomSeeds[17]=rand.seed;
  24776. }else {
  24777. ShapeUtils._randomPointInsideUnitCircle(ConeShape._tempDirectionPoint);
  24778. }
  24779. directionPointE=ConeShape._tempDirectionPoint;
  24780. direction.x=directionPointE.x *dirSinA;
  24781. direction.y=directionPointE.y *dirSinA;
  24782. }else {
  24783. direction.x=positionX *dirSinA;
  24784. direction.y=positionY *dirSinA;
  24785. }
  24786. direction.z=dirCosA;
  24787. break ;
  24788. case 2:
  24789. if (rand){
  24790. rand.seed=randomSeeds[16];
  24791. ShapeUtils._randomPointInsideUnitCircle(ConeShape._tempPositionPoint,rand);
  24792. }else {
  24793. ShapeUtils._randomPointInsideUnitCircle(ConeShape._tempPositionPoint);
  24794. }
  24795. positionX=positionPointE.x;
  24796. positionY=positionPointE.y;
  24797. position.x=positionX *this.radius;
  24798. position.y=positionY *this.radius;
  24799. position.z=0;
  24800. direction.x=positionX *dirSinA;
  24801. direction.y=positionY *dirSinA;
  24802. direction.z=dirCosA;
  24803. Vector3.normalize(direction,direction);
  24804. if (rand){
  24805. Vector3.scale(direction,this.length *rand.getFloat(),direction);
  24806. randomSeeds[16]=rand.seed;
  24807. }else {
  24808. Vector3.scale(direction,this.length *Math.random(),direction);
  24809. }
  24810. Vector3.add(position,direction,position);
  24811. if (this.randomDirection){
  24812. if (rand){
  24813. rand.seed=randomSeeds[17];
  24814. ShapeUtils._randomPointUnitSphere(direction,rand);
  24815. randomSeeds[17]=rand.seed;
  24816. }else {
  24817. ShapeUtils._randomPointUnitSphere(direction);
  24818. }
  24819. }
  24820. break ;
  24821. case 3:
  24822. if (rand){
  24823. rand.seed=randomSeeds[16];
  24824. ShapeUtils._randomPointUnitCircle(ConeShape._tempPositionPoint,rand);
  24825. }else {
  24826. ShapeUtils._randomPointUnitCircle(ConeShape._tempPositionPoint);
  24827. }
  24828. positionX=positionPointE.x;
  24829. positionY=positionPointE.y;
  24830. position.x=positionX *this.radius;
  24831. position.y=positionY *this.radius;
  24832. position.z=0;
  24833. direction.x=positionX *dirSinA;
  24834. direction.y=positionY *dirSinA;
  24835. direction.z=dirCosA;
  24836. Vector3.normalize(direction,direction);
  24837. if (rand){
  24838. Vector3.scale(direction,this.length *rand.getFloat(),direction);
  24839. randomSeeds[16]=rand.seed;
  24840. }else {
  24841. Vector3.scale(direction,this.length *Math.random(),direction);
  24842. }
  24843. Vector3.add(position,direction,position);
  24844. if (this.randomDirection){
  24845. if (rand){
  24846. rand.seed=randomSeeds[17];
  24847. ShapeUtils._randomPointUnitSphere(direction,rand);
  24848. randomSeeds[17]=rand.seed;
  24849. }else {
  24850. ShapeUtils._randomPointUnitSphere(direction);
  24851. }
  24852. }
  24853. break ;
  24854. default :
  24855. throw new Error("ConeShape:emitType is invalid.");
  24856. }
  24857. }
  24858. __proto.cloneTo=function(destObject){
  24859. _super.prototype.cloneTo.call(this,destObject);
  24860. var destShape=destObject;
  24861. destShape.angle=this.angle;
  24862. destShape.radius=this.radius;
  24863. destShape.length=this.length;
  24864. destShape.emitType=this.emitType;
  24865. destShape.randomDirection=this.randomDirection;
  24866. }
  24867. __static(ConeShape,
  24868. ['_tempPositionPoint',function(){return this._tempPositionPoint=new Vector2();},'_tempDirectionPoint',function(){return this._tempDirectionPoint=new Vector2();}
  24869. ]);
  24870. return ConeShape;
  24871. })(BaseShape)
  24872. /**
  24873. *@private
  24874. *<code>SubMeshStaticBatch</code> 类用于网格静态合并。
  24875. */
  24876. //class laya.d3.graphics.SubMeshStaticBatch extends laya.d3.core.GeometryElement
  24877. var SubMeshStaticBatch=(function(_super){
  24878. function SubMeshStaticBatch(batchOwner,number,vertexDeclaration){
  24879. /**@private */
  24880. //this._currentBatchVertexCount=0;
  24881. /**@private */
  24882. //this._currentBatchIndexCount=0;
  24883. /**@private */
  24884. //this._vertexDeclaration=null;
  24885. /**@private */
  24886. //this._vertexBuffer=null;
  24887. /**@private */
  24888. //this._indexBuffer=null;
  24889. /**@private */
  24890. //this._batchElements=null;
  24891. /**@private */
  24892. //this._batchID=0;
  24893. /**@private [只读]*/
  24894. //this.batchOwner=null;
  24895. /**@private [只读]*/
  24896. //this.number=0;
  24897. SubMeshStaticBatch.__super.call(this);
  24898. this._bufferState=new BufferState();
  24899. this._batchID=SubMeshStaticBatch._batchIDCounter++;
  24900. this._batchElements=[];
  24901. this._currentBatchVertexCount=0;
  24902. this._currentBatchIndexCount=0;
  24903. this._vertexDeclaration=vertexDeclaration;
  24904. this.batchOwner=batchOwner;
  24905. this.number=number;
  24906. }
  24907. __class(SubMeshStaticBatch,'laya.d3.graphics.SubMeshStaticBatch',_super);
  24908. var __proto=SubMeshStaticBatch.prototype;
  24909. Laya.imps(__proto,{"laya.resource.IDispose":true})
  24910. /**
  24911. *@private
  24912. */
  24913. __proto._getStaticBatchBakedVertexs=function(batchVertices,batchOffset,batchOwnerTransform,transform,render,mesh){
  24914. var vertexBuffer=mesh._vertexBuffers[0];
  24915. var vertexDeclaration=vertexBuffer.vertexDeclaration;
  24916. var positionOffset=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0).offset / 4;
  24917. var normalElement=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_NORMAL0*/3);
  24918. var normalOffset=normalElement ? normalElement.offset / 4 :-1;
  24919. var colorElement=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_COLOR0*/1);
  24920. var colorOffset=colorElement ? colorElement.offset / 4 :-1;
  24921. var uv0Element=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE0*/2);
  24922. var uv0Offset=uv0Element ? uv0Element.offset / 4 :-1;
  24923. var uv1Element=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE1*/7);
  24924. var uv1Offset=uv1Element ? uv1Element.offset / 4 :-1;
  24925. var tangentElement=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_TANGENT0*/4);
  24926. var sTangentOffset=tangentElement ? tangentElement.offset / 4 :-1;
  24927. var bakeVertexFloatCount=18;
  24928. var oriVertexFloatCount=vertexDeclaration.vertexStride / 4;
  24929. var oriVertexes=vertexBuffer.getData();
  24930. var worldMat;
  24931. if (batchOwnerTransform){
  24932. var rootMat=batchOwnerTransform.worldMatrix;
  24933. rootMat.invert(SubMeshStaticBatch._tempMatrix4x40);
  24934. worldMat=SubMeshStaticBatch._tempMatrix4x41;
  24935. Matrix4x4.multiply(SubMeshStaticBatch._tempMatrix4x40,transform.worldMatrix,worldMat);
  24936. }else {
  24937. worldMat=transform.worldMatrix;
  24938. };
  24939. var rotation=SubMeshStaticBatch._tempQuaternion0;
  24940. worldMat.decomposeTransRotScale(SubMeshStaticBatch._tempVector30,rotation,SubMeshStaticBatch._tempVector31);
  24941. var lightmapScaleOffset=render.lightmapScaleOffset;
  24942. var vertexCount=mesh.vertexCount;
  24943. for (var i=0;i < vertexCount;i++){
  24944. var oriOffset=i *oriVertexFloatCount;
  24945. var bakeOffset=(i+batchOffset)*bakeVertexFloatCount;
  24946. Utils3D.transformVector3ArrayToVector3ArrayCoordinate(oriVertexes,oriOffset+positionOffset,worldMat,batchVertices,bakeOffset+0);
  24947. if (normalOffset!==-1)
  24948. Utils3D.transformVector3ArrayByQuat(oriVertexes,oriOffset+normalOffset,rotation,batchVertices,bakeOffset+3);
  24949. var j=0,m=0;
  24950. var bakOff=bakeOffset+6;
  24951. if (colorOffset!==-1){
  24952. var oriOff=oriOffset+colorOffset;
  24953. for (j=0,m=4;j < m;j++)
  24954. batchVertices[bakOff+j]=oriVertexes[oriOff+j];
  24955. }else {
  24956. for (j=0,m=4;j < m;j++)
  24957. batchVertices[bakOff+j]=1.0;
  24958. }
  24959. if (uv0Offset!==-1){
  24960. var absUv0Offset=oriOffset+uv0Offset;
  24961. batchVertices[bakeOffset+10]=oriVertexes[absUv0Offset];
  24962. batchVertices[bakeOffset+11]=oriVertexes[absUv0Offset+1];
  24963. }
  24964. if (lightmapScaleOffset){
  24965. if (uv1Offset!==-1)
  24966. Utils3D.transformLightingMapTexcoordArray(oriVertexes,oriOffset+uv1Offset,lightmapScaleOffset,batchVertices,bakeOffset+12);
  24967. else
  24968. Utils3D.transformLightingMapTexcoordArray(oriVertexes,oriOffset+uv0Offset,lightmapScaleOffset,batchVertices,bakeOffset+12);
  24969. }
  24970. if (sTangentOffset!==-1){
  24971. var absSTanegntOffset=oriOffset+sTangentOffset;
  24972. batchVertices[bakeOffset+14]=oriVertexes[absSTanegntOffset];
  24973. batchVertices[bakeOffset+15]=oriVertexes[absSTanegntOffset+1];
  24974. batchVertices[bakeOffset+16]=oriVertexes[absSTanegntOffset+2];
  24975. batchVertices[bakeOffset+17]=oriVertexes[absSTanegntOffset+3];
  24976. }
  24977. }
  24978. return vertexCount;
  24979. }
  24980. /**
  24981. *@private
  24982. */
  24983. __proto.addTest=function(sprite){
  24984. var vertexCount=0;
  24985. var subMeshVertexCount=((sprite).meshFilter.sharedMesh).vertexCount;
  24986. vertexCount=this._currentBatchVertexCount+subMeshVertexCount;
  24987. if (vertexCount > 65535)
  24988. return false;
  24989. return true;
  24990. }
  24991. /**
  24992. *@private
  24993. */
  24994. __proto.add=function(sprite){
  24995. var oldStaticBatch=sprite._render._staticBatch;
  24996. (oldStaticBatch)&& (oldStaticBatch.remove(sprite));
  24997. var mesh=(sprite).meshFilter.sharedMesh;
  24998. var subMeshVertexCount=mesh.vertexCount;
  24999. this._batchElements.push(sprite);
  25000. var render=sprite._render;
  25001. render._isPartOfStaticBatch=true;
  25002. render._staticBatch=this;
  25003. var renderElements=render._renderElements;
  25004. for (var i=0,n=renderElements.length;i < n;i++)
  25005. renderElements[i].staticBatch=this;
  25006. this._currentBatchIndexCount+=mesh._indexBuffer.indexCount;
  25007. this._currentBatchVertexCount+=subMeshVertexCount;
  25008. }
  25009. /**
  25010. *@private
  25011. */
  25012. __proto.remove=function(sprite){
  25013. var mesh=(sprite).meshFilter.sharedMesh;
  25014. var index=this._batchElements.indexOf(sprite);
  25015. if (index!==-1){
  25016. this._batchElements.splice(index,1);
  25017. var render=sprite._render;
  25018. var renderElements=sprite._render._renderElements;
  25019. for (var i=0,n=renderElements.length;i < n;i++)
  25020. renderElements[i].staticBatch=null;
  25021. var meshVertexCount=mesh.vertexCount;
  25022. this._currentBatchIndexCount=this._currentBatchIndexCount-mesh._indexBuffer.indexCount;
  25023. this._currentBatchVertexCount=this._currentBatchVertexCount-meshVertexCount;
  25024. sprite._render._isPartOfStaticBatch=false;
  25025. }
  25026. }
  25027. /**
  25028. *@private
  25029. */
  25030. __proto.finishInit=function(){
  25031. if (this._vertexBuffer){
  25032. this._vertexBuffer.destroy();
  25033. this._indexBuffer.destroy();
  25034. Resource._addGPUMemory(-(this._vertexBuffer._byteLength+this._indexBuffer._byteLength));
  25035. };
  25036. var batchVertexCount=0;
  25037. var batchIndexCount=0;
  25038. var rootOwner=this.batchOwner;
  25039. var floatStride=this._vertexDeclaration.vertexStride / 4;
  25040. var vertexDatas=new Float32Array(floatStride *this._currentBatchVertexCount);
  25041. var indexDatas=new Uint16Array(this._currentBatchIndexCount);
  25042. this._vertexBuffer=new VertexBuffer3D(this._vertexDeclaration.vertexStride *this._currentBatchVertexCount,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4);
  25043. this._vertexBuffer.vertexDeclaration=this._vertexDeclaration;
  25044. this._indexBuffer=new IndexBuffer3D(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",this._currentBatchIndexCount,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4);
  25045. for (var i=0,n=this._batchElements.length;i < n;i++){
  25046. var sprite=this._batchElements [i];
  25047. var mesh=sprite.meshFilter.sharedMesh;
  25048. var meshVerCount=this._getStaticBatchBakedVertexs(vertexDatas,batchVertexCount,rootOwner ? rootOwner._transform :null,sprite._transform,(sprite._render),mesh);
  25049. var indices=mesh._indexBuffer.getData();
  25050. var indexOffset=batchVertexCount;
  25051. var indexEnd=batchIndexCount+indices.length;
  25052. var elements=sprite._render._renderElements;
  25053. for (var j=0,m=mesh.subMeshCount;j < m;j++){
  25054. var subMesh=mesh._subMeshes[j];
  25055. var start=batchIndexCount+subMesh._indexStart;
  25056. var element=elements [j];
  25057. element.staticBatchIndexStart=start;
  25058. element.staticBatchIndexEnd=start+subMesh._indexCount;
  25059. }
  25060. indexDatas.set(indices,batchIndexCount);
  25061. var k=0;
  25062. var isInvert=rootOwner ? (sprite._transform._isFrontFaceInvert!==rootOwner.transform._isFrontFaceInvert):sprite._transform._isFrontFaceInvert;
  25063. if (isInvert){
  25064. for (k=batchIndexCount;k < indexEnd;k+=3){
  25065. indexDatas[k]=indexOffset+indexDatas[k];
  25066. var index1=indexDatas[k+1];
  25067. var index2=indexDatas[k+2];
  25068. indexDatas[k+1]=indexOffset+index2;
  25069. indexDatas[k+2]=indexOffset+index1;
  25070. }
  25071. }else {
  25072. for (k=batchIndexCount;k < indexEnd;k+=3){
  25073. indexDatas[k]=indexOffset+indexDatas[k];
  25074. indexDatas[k+1]=indexOffset+indexDatas[k+1];
  25075. indexDatas[k+2]=indexOffset+indexDatas[k+2];
  25076. }
  25077. }
  25078. batchIndexCount+=indices.length;
  25079. batchVertexCount+=meshVerCount;
  25080. }
  25081. this._vertexBuffer.setData(vertexDatas);
  25082. this._indexBuffer.setData(indexDatas);
  25083. var memorySize=this._vertexBuffer._byteLength+this._indexBuffer._byteLength;
  25084. Resource._addGPUMemory(memorySize);
  25085. this._bufferState.bind();
  25086. this._bufferState.applyVertexBuffer(this._vertexBuffer);
  25087. this._bufferState.applyIndexBuffer(this._indexBuffer);
  25088. this._bufferState.unBind();
  25089. }
  25090. /**
  25091. *@inheritDoc
  25092. */
  25093. __proto._render=function(state){
  25094. this._bufferState.bind();
  25095. var element=state.renderElement;
  25096. var batchElementList=(element).staticBatchElementList;
  25097. var from=0;
  25098. var end=0;
  25099. var count=batchElementList.length;
  25100. for (var i=1;i < count;i++){
  25101. var lastElement=batchElementList[i-1];
  25102. if (lastElement.staticBatchIndexEnd===batchElementList[i].staticBatchIndexStart){
  25103. end++;
  25104. continue ;
  25105. }else {
  25106. var start=batchElementList[from].staticBatchIndexStart;
  25107. var indexCount=batchElementList[end].staticBatchIndexEnd-start;
  25108. LayaGL.instance.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,indexCount,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,start *2);
  25109. from=++end;
  25110. Stat.trianglesFaces+=indexCount / 3;
  25111. }
  25112. }
  25113. start=batchElementList[from].staticBatchIndexStart;
  25114. indexCount=batchElementList[end].staticBatchIndexEnd-start;
  25115. LayaGL.instance.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,indexCount,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,start *2);
  25116. Stat.renderBatches++;
  25117. Stat.savedRenderBatches+=count-1;
  25118. Stat.trianglesFaces+=indexCount / 3;
  25119. }
  25120. /**
  25121. *@private
  25122. */
  25123. __proto.dispose=function(){
  25124. var memorySize=this._vertexBuffer._byteLength+this._indexBuffer._byteLength;
  25125. Resource._addGPUMemory(-memorySize);
  25126. this._batchElements=null;
  25127. this.batchOwner=null;
  25128. this._vertexDeclaration=null;
  25129. this._bufferState.destroy();
  25130. this._vertexBuffer.destroy();
  25131. this._indexBuffer.destroy();
  25132. this._vertexBuffer=null;
  25133. this._indexBuffer=null;
  25134. this._bufferState=null;
  25135. }
  25136. SubMeshStaticBatch.maxBatchVertexCount=65535;
  25137. SubMeshStaticBatch._batchIDCounter=0;
  25138. __static(SubMeshStaticBatch,
  25139. ['_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();}
  25140. ]);
  25141. return SubMeshStaticBatch;
  25142. })(GeometryElement)
  25143. /**
  25144. *<code>PixelLineFilter</code> 类用于线过滤器。
  25145. */
  25146. //class laya.d3.core.pixelLine.PixelLineFilter extends laya.d3.core.GeometryElement
  25147. var PixelLineFilter=(function(_super){
  25148. function PixelLineFilter(owner,maxLineCount){
  25149. /**@private */
  25150. this._floatCountPerVertices=7;
  25151. /**@private */
  25152. this._owner=null;
  25153. /**@private */
  25154. this._vertexBuffer=null;
  25155. /**@private */
  25156. this._vertices=null;
  25157. /**@private */
  25158. this._maxLineCount=0;
  25159. /**@private */
  25160. this._lineCount=0;
  25161. PixelLineFilter.__super.call(this);
  25162. this._minUpdate=Number.MAX_VALUE;
  25163. this._maxUpdate=Number.MIN_VALUE;
  25164. this._bufferState=new BufferState();
  25165. var pointCount=maxLineCount *2;
  25166. this._owner=owner;
  25167. this._maxLineCount=maxLineCount;
  25168. this._vertices=new Float32Array(pointCount *this._floatCountPerVertices);
  25169. this._vertexBuffer=new VertexBuffer3D(PixelLineVertex.vertexDeclaration.vertexStride *pointCount,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,false);
  25170. this._vertexBuffer.vertexDeclaration=PixelLineVertex.vertexDeclaration;
  25171. this._bufferState.bind();
  25172. this._bufferState.applyVertexBuffer(this._vertexBuffer);
  25173. this._bufferState.unBind();
  25174. }
  25175. __class(PixelLineFilter,'laya.d3.core.pixelLine.PixelLineFilter',_super);
  25176. var __proto=PixelLineFilter.prototype;
  25177. /**
  25178. *@inheritDoc
  25179. */
  25180. __proto._getType=function(){
  25181. return PixelLineFilter._type;
  25182. }
  25183. /**
  25184. *@private
  25185. */
  25186. __proto._resizeLineData=function(maxCount){
  25187. var pointCount=maxCount *2;
  25188. var lastVertices=this._vertices;
  25189. this._vertexBuffer.destroy();
  25190. this._maxLineCount=maxCount;
  25191. var vertexCount=pointCount *this._floatCountPerVertices;
  25192. this._vertices=new Float32Array(vertexCount);
  25193. this._vertexBuffer=new VertexBuffer3D(PixelLineVertex.vertexDeclaration.vertexStride *pointCount,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,false);
  25194. this._vertexBuffer.vertexDeclaration=PixelLineVertex.vertexDeclaration;
  25195. if (vertexCount < lastVertices.length){
  25196. this._vertices.set(new Float32Array(lastVertices.buffer,0,vertexCount));
  25197. this._vertexBuffer.setData(this._vertices,0,0,vertexCount);
  25198. }else {
  25199. this._vertices.set(lastVertices);
  25200. this._vertexBuffer.setData(this._vertices,0,0,lastVertices.length);
  25201. }
  25202. this._bufferState.bind();
  25203. this._bufferState.applyVertexBuffer(this._vertexBuffer);
  25204. this._bufferState.unBind();
  25205. }
  25206. /**
  25207. *@private
  25208. */
  25209. __proto._updateLineVertices=function(offset,startPosition,endPosition,startColor,endColor){
  25210. if (startPosition){
  25211. this._vertices[offset+0]=startPosition.x;
  25212. this._vertices[offset+1]=startPosition.y;
  25213. this._vertices[offset+2]=startPosition.z;
  25214. }
  25215. if (startColor){
  25216. this._vertices[offset+3]=startColor.r;
  25217. this._vertices[offset+4]=startColor.g;
  25218. this._vertices[offset+5]=startColor.b;
  25219. this._vertices[offset+6]=startColor.a;
  25220. }
  25221. if (endPosition){
  25222. this._vertices[offset+7]=endPosition.x;
  25223. this._vertices[offset+8]=endPosition.y;
  25224. this._vertices[offset+9]=endPosition.z;
  25225. }
  25226. if (endColor){
  25227. this._vertices[offset+10]=endColor.r;
  25228. this._vertices[offset+11]=endColor.g;
  25229. this._vertices[offset+12]=endColor.b;
  25230. this._vertices[offset+13]=endColor.a;
  25231. }
  25232. this._minUpdate=Math.min(this._minUpdate,offset);
  25233. this._maxUpdate=Math.max(this._maxUpdate,offset+this._floatCountPerVertices *2);
  25234. }
  25235. /**
  25236. *@private
  25237. */
  25238. __proto._removeLineData=function(index){
  25239. var floatCount=this._floatCountPerVertices *2;
  25240. var nextIndex=index+1;
  25241. var offset=index *floatCount;
  25242. var nextOffset=nextIndex *floatCount;
  25243. var rightPartVertices=new Float32Array(this._vertices.buffer,nextIndex *floatCount *4,(this._lineCount-nextIndex)*floatCount);
  25244. this._vertices.set(rightPartVertices,offset);
  25245. this._minUpdate=offset;
  25246. this._maxUpdate=offset+this._floatCountPerVertices *2;
  25247. this._lineCount--;
  25248. }
  25249. /**
  25250. *@private
  25251. */
  25252. __proto._updateLineData=function(index,startPosition,endPosition,startColor,endColor){
  25253. var floatCount=this._floatCountPerVertices *2;
  25254. var offset=index *floatCount;
  25255. this._updateLineVertices(offset,startPosition,endPosition,startColor,endColor);
  25256. }
  25257. /**
  25258. *@private
  25259. */
  25260. __proto._updateLineDatas=function(index,data){
  25261. var floatCount=this._floatCountPerVertices *2;
  25262. var offset=index *floatCount;
  25263. var count=data.length;
  25264. for (var i=0;i < count;i++){
  25265. var line=data[i];
  25266. this._updateLineVertices((index+i)*floatCount,line.startPosition,line.endPosition,line.startColor,line.endColor);
  25267. }
  25268. }
  25269. /**
  25270. *获取线段数据
  25271. *@return 线段数据。
  25272. */
  25273. __proto._getLineData=function(index,out){
  25274. var startPosition=out.startPosition;
  25275. var startColor=out.startColor;
  25276. var endPosition=out.endPosition;
  25277. var endColor=out.endColor;
  25278. var vertices=this._vertices;
  25279. var offset=index *this._floatCountPerVertices *2;
  25280. startPosition.x=vertices[offset+0];
  25281. startPosition.y=vertices[offset+1];
  25282. startPosition.z=vertices[offset+2];
  25283. startColor.r=vertices[offset+3];
  25284. startColor.g=vertices[offset+4];
  25285. startColor.b=vertices[offset+5];
  25286. startColor.a=vertices[offset+6];
  25287. endPosition.x=vertices[offset+7];
  25288. endPosition.y=vertices[offset+8];
  25289. endPosition.z=vertices[offset+9];
  25290. endColor.r=vertices[offset+10];
  25291. endColor.g=vertices[offset+11];
  25292. endColor.b=vertices[offset+12];
  25293. endColor.a=vertices[offset+13];
  25294. }
  25295. /**
  25296. *@inheritDoc
  25297. */
  25298. __proto._prepareRender=function(state){
  25299. return true;
  25300. }
  25301. /**
  25302. *@inheritDoc
  25303. */
  25304. __proto._render=function(state){
  25305. if (this._minUpdate!==Number.MAX_VALUE && this._maxUpdate!==Number.MIN_VALUE){
  25306. this._vertexBuffer.setData(this._vertices,this._minUpdate,this._minUpdate,this._maxUpdate-this._minUpdate);
  25307. this._minUpdate=Number.MAX_VALUE;
  25308. this._maxUpdate=Number.MIN_VALUE;
  25309. }
  25310. if (this._lineCount > 0){
  25311. this._bufferState.bind();
  25312. LayaGL.instance.drawArrays(/*laya.webgl.WebGLContext.LINES*/0x0001,0,this._lineCount *2);
  25313. Stat.renderBatches++;
  25314. }
  25315. }
  25316. /**
  25317. *@inheritDoc
  25318. */
  25319. __proto.destroy=function(){
  25320. if (this._destroyed)
  25321. return;
  25322. _super.prototype.destroy.call(this);
  25323. this._bufferState.destroy();
  25324. this._vertexBuffer.destroy();
  25325. this._bufferState=null;
  25326. this._vertexBuffer=null;
  25327. this._vertices=null;
  25328. }
  25329. __static(PixelLineFilter,
  25330. ['_type',function(){return this._type=GeometryElement._typeCounter++;}
  25331. ]);
  25332. return PixelLineFilter;
  25333. })(GeometryElement)
  25334. /**
  25335. *<code>VertexShurikenParticle</code> 类用于创建粒子顶点结构。
  25336. */
  25337. //class laya.d3.graphics.Vertex.VertexShurikenParticleBillboard extends laya.d3.graphics.Vertex.VertexShuriKenParticle
  25338. var VertexShurikenParticleBillboard=(function(_super){
  25339. function VertexShurikenParticleBillboard(cornerTextureCoordinate,positionStartLifeTime,velocity,startColor,startSize,startRotation0,startRotation1,startRotation2,ageAddScale,time,startSpeed,randoms0,randoms1,simulationWorldPostion){
  25340. /**@private */
  25341. this._cornerTextureCoordinate=null;
  25342. /**@private */
  25343. this._positionStartLifeTime=null;
  25344. /**@private */
  25345. this._velocity=null;
  25346. /**@private */
  25347. this._startColor=null;
  25348. /**@private */
  25349. this._startSize=null;
  25350. /**@private */
  25351. this._startRotation0=null;
  25352. /**@private */
  25353. this._startRotation1=null;
  25354. /**@private */
  25355. this._startRotation2=null;
  25356. /**@private */
  25357. this._startLifeTime=NaN;
  25358. /**@private */
  25359. this._time=NaN;
  25360. /**@private */
  25361. this._startSpeed=NaN;
  25362. /**@private */
  25363. this._randoms0=null;
  25364. /**@private */
  25365. this._randoms1=null;
  25366. /**@private */
  25367. this._simulationWorldPostion=null;
  25368. VertexShurikenParticleBillboard.__super.call(this);
  25369. this._cornerTextureCoordinate=cornerTextureCoordinate;
  25370. this._positionStartLifeTime=positionStartLifeTime;
  25371. this._velocity=velocity;
  25372. this._startColor=startColor;
  25373. this._startSize=startSize;
  25374. this._startRotation0=startRotation0;
  25375. this._startRotation1=startRotation1;
  25376. this._startRotation2=startRotation2;
  25377. this._startLifeTime=ageAddScale;
  25378. this._time=time;
  25379. this._startSpeed=startSpeed;
  25380. this._randoms0=this.random0;
  25381. this._randoms1=this.random1;
  25382. this._simulationWorldPostion=simulationWorldPostion;
  25383. }
  25384. __class(VertexShurikenParticleBillboard,'laya.d3.graphics.Vertex.VertexShurikenParticleBillboard',_super);
  25385. var __proto=VertexShurikenParticleBillboard.prototype;
  25386. __getset(0,__proto,'cornerTextureCoordinate',function(){
  25387. return this._cornerTextureCoordinate;
  25388. });
  25389. __getset(0,__proto,'random1',function(){
  25390. return this._randoms1;
  25391. });
  25392. __getset(0,__proto,'startRotation2',function(){
  25393. return this._startRotation2;
  25394. });
  25395. __getset(0,__proto,'positionStartLifeTime',function(){
  25396. return this._positionStartLifeTime;
  25397. });
  25398. __getset(0,__proto,'velocity',function(){
  25399. return this._velocity;
  25400. });
  25401. __getset(0,__proto,'random0',function(){
  25402. return this._randoms0;
  25403. });
  25404. __getset(0,__proto,'startSize',function(){
  25405. return this._startSize;
  25406. });
  25407. __getset(0,__proto,'startColor',function(){
  25408. return this._startColor;
  25409. });
  25410. __getset(0,__proto,'startRotation0',function(){
  25411. return this._startRotation0;
  25412. });
  25413. __getset(0,__proto,'startRotation1',function(){
  25414. return this._startRotation1;
  25415. });
  25416. __getset(0,__proto,'startLifeTime',function(){
  25417. return this._startLifeTime;
  25418. });
  25419. __getset(0,__proto,'time',function(){
  25420. return this._time;
  25421. });
  25422. __getset(0,__proto,'startSpeed',function(){
  25423. return this._startSpeed;
  25424. });
  25425. __getset(0,__proto,'simulationWorldPostion',function(){
  25426. return this._simulationWorldPostion;
  25427. });
  25428. __getset(1,VertexShurikenParticleBillboard,'vertexDeclaration',function(){
  25429. return VertexShurikenParticleBillboard._vertexDeclaration;
  25430. },laya.d3.graphics.Vertex.VertexShuriKenParticle._$SET_vertexDeclaration);
  25431. __static(VertexShurikenParticleBillboard,
  25432. ['_vertexDeclaration',function(){return this._vertexDeclaration=new VertexDeclaration(152,[
  25433. new VertexElement(0,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_CORNERTEXTURECOORDINATE0*/0),
  25434. new VertexElement(16,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_SHAPEPOSITIONSTARTLIFETIME*/4),
  25435. new VertexElement(32,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_DIRECTIONTIME*/5),
  25436. new VertexElement(48,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_STARTCOLOR0*/6),
  25437. new VertexElement(64,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_STARTSIZE*/8),
  25438. new VertexElement(76,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_STARTROTATION*/9),
  25439. new VertexElement(88,/*laya.d3.graphics.VertexElementFormat.Single*/"single",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_STARTSPEED*/10),
  25440. new VertexElement(92,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_RANDOM0*/11),
  25441. new VertexElement(108,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_RANDOM1*/12),
  25442. new VertexElement(124,/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_SIMULATIONWORLDPOSTION*/13),
  25443. new VertexElement(136,/*laya.d3.graphics.VertexElementFormat.Vector4*/"vector4",/*laya.d3.graphics.Vertex.VertexShuriKenParticle.PARTICLE_SIMULATIONWORLDROTATION*/14)]);}
  25444. ]);
  25445. return VertexShurikenParticleBillboard;
  25446. })(VertexShuriKenParticle)
  25447. /**
  25448. *<code>ConeColliderShape</code> 类用于创建圆柱碰撞器。
  25449. */
  25450. //class laya.d3.physics.shape.ConeColliderShape extends laya.d3.physics.shape.ColliderShape
  25451. var ConeColliderShape=(function(_super){
  25452. function ConeColliderShape(radius,height,orientation){
  25453. /**@private */
  25454. //this._orientation=0;
  25455. /**@private */
  25456. this._radius=1;
  25457. /**@private */
  25458. this._height=0.5;
  25459. ConeColliderShape.__super.call(this);
  25460. (radius===void 0)&& (radius=0.5);
  25461. (height===void 0)&& (height=1.0);
  25462. (orientation===void 0)&& (orientation=/*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPY*/1);
  25463. this._radius=radius;
  25464. this._height=height;
  25465. this._orientation=orientation;
  25466. this._type=/*laya.d3.physics.shape.ColliderShape.SHAPETYPES_CYLINDER*/2;
  25467. switch (orientation){
  25468. case /*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPX*/0:
  25469. this._nativeShape=new Laya3D._physics3D.btConeShapeX(radius,height);
  25470. break ;
  25471. case /*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPY*/1:
  25472. this._nativeShape=new Laya3D._physics3D.btConeShape(radius,height);
  25473. break ;
  25474. case /*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPZ*/2:
  25475. this._nativeShape=new Laya3D._physics3D.btConeShapeZ(radius,height);
  25476. break ;
  25477. default :
  25478. throw "ConeColliderShape:unknown orientation.";
  25479. }
  25480. }
  25481. __class(ConeColliderShape,'laya.d3.physics.shape.ConeColliderShape',_super);
  25482. var __proto=ConeColliderShape.prototype;
  25483. /**
  25484. *@inheritDoc
  25485. */
  25486. __proto.clone=function(){
  25487. var dest=new ConeColliderShape(this._radius,this._height,this._orientation);
  25488. this.cloneTo(dest);
  25489. return dest;
  25490. }
  25491. /**
  25492. *获取半径。
  25493. */
  25494. __getset(0,__proto,'radius',function(){
  25495. return this._radius;
  25496. });
  25497. /**
  25498. *获取高度。
  25499. */
  25500. __getset(0,__proto,'height',function(){
  25501. return this._height;
  25502. });
  25503. /**
  25504. *获取方向。
  25505. */
  25506. __getset(0,__proto,'orientation',function(){
  25507. return this._orientation;
  25508. });
  25509. return ConeColliderShape;
  25510. })(ColliderShape)
  25511. /**
  25512. *@private
  25513. *<code>BlitCMD</code> 类用于创建从一张渲染目标输出到另外一张渲染目标指令。
  25514. */
  25515. //class laya.d3.core.render.command.BlitCMD extends laya.d3.core.render.command.Command
  25516. var BlitCMD=(function(_super){
  25517. function BlitCMD(){
  25518. /**@private */
  25519. this._source=null;
  25520. /**@private */
  25521. this._dest=null;
  25522. /**@private */
  25523. this._shader=null;
  25524. /**@private */
  25525. this._shaderData=null;
  25526. /**@private */
  25527. this._subShader=0;
  25528. BlitCMD.__super.call(this);
  25529. }
  25530. __class(BlitCMD,'laya.d3.core.render.command.BlitCMD',_super);
  25531. var __proto=BlitCMD.prototype;
  25532. /**
  25533. *@inheritDoc
  25534. */
  25535. __proto.run=function(){
  25536. this._shaderData.setTexture(CommandBuffer.SCREENTEXTURE_ID,this._source);
  25537. var dest=this._dest;
  25538. if (dest)
  25539. dest._start();
  25540. var subShader=this._shader.getSubShaderAt(this._subShader);
  25541. var passes=subShader._passes;
  25542. for (var i=0,n=passes.length;i < n;i++){
  25543. var shaderPass=passes[i].withCompile(0,0,0);
  25544. shaderPass.bind();
  25545. (this._shaderData)&& (shaderPass.uploadUniforms(shaderPass._materialUniformParamsMap,this._shaderData,true));
  25546. shaderPass.uploadRenderStateBlendDepth(this._shaderData);
  25547. shaderPass.uploadRenderStateFrontFace(this._shaderData,true,null);
  25548. ScreenQuad.instance.render();
  25549. }
  25550. if (dest)
  25551. dest._end();
  25552. }
  25553. /**
  25554. *@inheritDoc
  25555. */
  25556. __proto.recover=function(){
  25557. BlitCMD._pool.push(this);
  25558. this._dest=null;
  25559. this._shader=null;
  25560. this._shaderData=null;
  25561. }
  25562. BlitCMD.create=function(source,dest,shader,shaderData,subShader){
  25563. (subShader===void 0)&& (subShader=0);
  25564. var cmd;
  25565. cmd=BlitCMD._pool.length > 0 ? BlitCMD._pool.pop():new BlitCMD();
  25566. cmd._source=source;
  25567. cmd._dest=dest;
  25568. cmd._shader=shader;
  25569. cmd._shaderData=shaderData;
  25570. cmd._subShader=subShader;
  25571. return cmd;
  25572. }
  25573. BlitCMD._pool=[];
  25574. return BlitCMD;
  25575. })(Command)
  25576. /**
  25577. *<code>BloomEffect</code> 类用于创建泛光效果。
  25578. */
  25579. //class laya.d3.core.render.BloomEffect extends laya.d3.core.render.PostProcessEffect
  25580. var BloomEffect=(function(_super){
  25581. function BloomEffect(){
  25582. /**@private */
  25583. this._shader=null;
  25584. /**@private */
  25585. this._pyramid=null;
  25586. /**@private */
  25587. this._intensity=0.0;
  25588. /**@private */
  25589. this._threshold=1.0;
  25590. /**@private */
  25591. this._softKnee=0.5;
  25592. /**@private */
  25593. this._diffusion=7.0;
  25594. /**@private */
  25595. this._anamorphicRatio=0.0;
  25596. /**@private */
  25597. this._dirtIntensity=0.0;
  25598. /**限制泛光像素的数量,该值在伽马空间。*/
  25599. this.clamp=65472.0;
  25600. /**是否开启快速模式。该模式通过降低质量来提升性能。*/
  25601. this.fastMode=false;
  25602. /**镜头污渍纹路,用于为泛光特效增加污渍灰尘效果*/
  25603. this.dirtTexture=null;
  25604. BloomEffect.__super.call(this);
  25605. this._shaderData=new ShaderData();
  25606. this._linearColor=new Color();
  25607. this._shaderThreshold=new Vector4();
  25608. this._shaderParams=new Vector4();
  25609. this._shaderSetting=new Vector4();
  25610. this._dirtTileOffset=new Vector4();
  25611. this.color=new Color(1.0,1.0,1.0,1.0);
  25612. this._shader=Shader3D.find("PostProcessBloom");
  25613. this._pyramid=new Array(16 *2);
  25614. }
  25615. __class(BloomEffect,'laya.d3.core.render.BloomEffect',_super);
  25616. var __proto=BloomEffect.prototype;
  25617. /**
  25618. *@inheritDoc
  25619. */
  25620. __proto.render=function(context){
  25621. var cmd=context.command;
  25622. var viewport=context.camera.viewport;
  25623. this._shaderData.setTexture(BloomEffect.SHADERVALUE_AUTOEXPOSURETEX,Texture2D.whiteTexture);
  25624. var ratio=this._anamorphicRatio;
  25625. var rw=ratio < 0 ?-ratio :0;
  25626. var rh=ratio > 0 ? ratio :0;
  25627. var tw=Math.floor(viewport.width / (2-rw));
  25628. var th=Math.floor(viewport.height / (2-rh));
  25629. var s=Math.max(tw,th);
  25630. var logs=NaN;
  25631. /*__JS__ */logs=Math.log2(s)+this._diffusion-10;
  25632. var logsInt=Math.floor(logs);
  25633. var iterations=Math.min(Math.max(logsInt,1),16);
  25634. var sampleScale=0.5+logs-logsInt;
  25635. this._shaderData.setNumber(BloomEffect.SHADERVALUE_SAMPLESCALE,sampleScale);
  25636. var lthresh=Utils3D.gammaToLinearSpace(this.threshold);
  25637. var knee=lthresh *this._softKnee+1e-5;
  25638. this._shaderThreshold.setValue(lthresh,lthresh-knee,knee *2,0.25 / knee);
  25639. this._shaderData.setVector(BloomEffect.SHADERVALUE_THRESHOLD,this._shaderThreshold);
  25640. var lclamp=Utils3D.gammaToLinearSpace(this.clamp);
  25641. this._shaderParams.setValue(lclamp,0,0,0);
  25642. this._shaderData.setVector(BloomEffect.SHADERVALUE_PARAMS,this._shaderParams);
  25643. var qualityOffset=this.fastMode ? 1 :0;
  25644. var lastDownTexture=context.source;
  25645. for (var i=0;i < iterations;i++){
  25646. var downIndex=i *2;
  25647. var upIndex=downIndex+1;
  25648. var subShader=i==0 ? 0+qualityOffset :2+qualityOffset;
  25649. 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);
  25650. 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);
  25651. this._pyramid[downIndex]=mipDownTexture;
  25652. this._pyramid[upIndex]=mipUpTexture;
  25653. cmd.blit(lastDownTexture,mipDownTexture,this._shader,this._shaderData,subShader);
  25654. lastDownTexture=mipDownTexture;
  25655. tw=Math.max(tw / 2,1);
  25656. th=Math.max(th / 2,1);
  25657. };
  25658. var lastUpTexture=this._pyramid[2 *iterations-3];
  25659. for (i=iterations-2;i >=0;i--){
  25660. downIndex=i *2;
  25661. upIndex=downIndex+1;
  25662. mipDownTexture=this._pyramid[downIndex];
  25663. mipUpTexture=this._pyramid[upIndex];
  25664. cmd.setShaderDataTexture(this._shaderData,BloomEffect.SHADERVALUE_BLOOMTEX,mipDownTexture);
  25665. cmd.blit(lastUpTexture,mipUpTexture,this._shader,this._shaderData,4+qualityOffset);
  25666. lastUpTexture=mipUpTexture;
  25667. };
  25668. var linearColor=this._linearColor;
  25669. this.color.toLinear(linearColor);
  25670. var intensity=Math.pow(2,this._intensity / 10.0)-1.0;
  25671. var shaderSettings=this._shaderSetting;
  25672. this._shaderSetting.setValue(sampleScale,intensity,this._dirtIntensity,iterations);
  25673. var dirtTexture=dirtTexture ? dirtTexture :Texture2D.blackTexture;
  25674. var dirtRatio=dirtTexture.width / dirtTexture.height;
  25675. var screenRatio=viewport.width / viewport.height;
  25676. var dirtTileOffset=this._dirtTileOffset;
  25677. dirtTileOffset.setValue(1.0,1.0,0.0,0.0);
  25678. if (dirtRatio > screenRatio)
  25679. dirtTileOffset.setValue(screenRatio / dirtRatio,1.0,(1.0-dirtTileOffset.x)*0.5,0.0);
  25680. else if (dirtRatio < screenRatio)
  25681. dirtTileOffset.setValue(1.0,dirtRatio / screenRatio,0.0,(1.0-dirtTileOffset.y)*0.5);
  25682. var compositeShaderData=context.compositeShaderData;
  25683. var compositeDefineData=context.compositeDefineData;
  25684. if (this.fastMode)
  25685. compositeDefineData.add(PostProcess.SHADERDEFINE_BLOOM_LOW);
  25686. else
  25687. compositeDefineData.add(PostProcess.SHADERDEFINE_BLOOM);
  25688. compositeShaderData.setVector(PostProcess.SHADERVALUE_BLOOM_DIRTTILEOFFSET,dirtTileOffset);
  25689. compositeShaderData.setVector(PostProcess.SHADERVALUE_BLOOM_SETTINGS,shaderSettings);
  25690. compositeShaderData.setVector(PostProcess.SHADERVALUE_BLOOM_COLOR,new Vector4(linearColor.r,linearColor.g,linearColor.b,linearColor.a));
  25691. compositeShaderData.setTexture(PostProcess.SHADERVALUE_BLOOM_DIRTTEX,dirtTexture);
  25692. compositeShaderData.setTexture(PostProcess.SHADERVALUE_BLOOMTEX,lastUpTexture);
  25693. for (i=0;i < iterations;i++){
  25694. downIndex=i *2;
  25695. upIndex=downIndex+1;
  25696. if (this._pyramid[downIndex] !=lastUpTexture)
  25697. RenderTexture.setReleaseTemporary(this._pyramid[downIndex]);
  25698. if (this._pyramid[upIndex] !=lastUpTexture)
  25699. RenderTexture.setReleaseTemporary(this._pyramid[upIndex]);
  25700. }
  25701. context.tempRenderTextures.push(lastUpTexture);
  25702. }
  25703. /**
  25704. *设置软膝盖过渡强度,在阈值以下进行渐变过渡(0为完全硬过度,1为完全软过度)。
  25705. *@param value 软膝盖值。
  25706. */
  25707. /**
  25708. *获取软膝盖过渡强度,在阈值以下进行渐变过渡(0为完全硬过度,1为完全软过度)。
  25709. *@return 软膝盖值。
  25710. */
  25711. __getset(0,__proto,'softKnee',function(){
  25712. return this._softKnee;
  25713. },function(value){
  25714. this._softKnee=Math.min(Math.max(value,0.0),1.0);
  25715. });
  25716. /**
  25717. *设置泛光过滤器强度,最小值为0。
  25718. *@param value 强度。
  25719. */
  25720. /**
  25721. *获取泛光过滤器强度,最小值为0。
  25722. *@return 强度。
  25723. */
  25724. __getset(0,__proto,'intensity',function(){
  25725. return this._intensity;
  25726. },function(value){
  25727. this._intensity=Math.max(value,0.0);
  25728. });
  25729. /**
  25730. *获取泛光阈值,在该阈值亮度以下的像素会被过滤掉,该值在伽马空间。
  25731. *@param value 阈值。
  25732. */
  25733. /**
  25734. *设置泛光阈值,在该阈值亮度以下的像素会被过滤掉,该值在伽马空间。
  25735. *@return 阈值。
  25736. */
  25737. __getset(0,__proto,'threshold',function(){
  25738. return this._threshold;
  25739. },function(value){
  25740. this._threshold=Math.max(value,0.0);
  25741. });
  25742. /**
  25743. *设置形变比,通过扭曲泛光产生视觉上形变,负值为垂直扭曲,正值为水平扭曲。
  25744. *@param value 形变比。
  25745. */
  25746. /**
  25747. *获取形变比,通过扭曲泛光产生视觉上形变,负值为垂直扭曲,正值为水平扭曲。
  25748. *@return 形变比。
  25749. */
  25750. __getset(0,__proto,'anamorphicRatio',function(){
  25751. return this._anamorphicRatio;
  25752. },function(value){
  25753. this._anamorphicRatio=Math.min(Math.max(value,-1.0),1.0);
  25754. });
  25755. /**
  25756. *设置扩散值,改变泛光的扩散范围,最好使用整数值保证效果,该值会改变内部的迭代次数,范围是1到10。
  25757. *@param value 光晕的扩散范围。
  25758. */
  25759. /**
  25760. *获取扩散值,改变泛光的扩散范围,最好使用整数值保证效果,该值会改变内部的迭代次数,范围是1到10。
  25761. *@return 光晕的扩散范围。
  25762. */
  25763. __getset(0,__proto,'diffusion',function(){
  25764. return this._diffusion;
  25765. },function(value){
  25766. this._diffusion=Math.min(Math.max(value,1),10);
  25767. });
  25768. /**
  25769. *设置污渍强度。
  25770. *@param value 污渍强度。
  25771. */
  25772. /**
  25773. *获取污渍强度。
  25774. *@return 污渍强度。
  25775. */
  25776. __getset(0,__proto,'dirtIntensity',function(){
  25777. return this._dirtIntensity;
  25778. },function(value){
  25779. this._dirtIntensity=Math.max(value,0.0);
  25780. });
  25781. BloomEffect.SUBSHADER_PREFILTER13=0;
  25782. BloomEffect.SUBSHADER_PREFILTER4=1;
  25783. BloomEffect.SUBSHADER_DOWNSAMPLE13=2;
  25784. BloomEffect.SUBSHADER_DOWNSAMPLE4=3;
  25785. BloomEffect.SUBSHADER_UPSAMPLETENT=4;
  25786. BloomEffect.SUBSHADER_UPSAMPLEBOX=5;
  25787. BloomEffect.MAXPYRAMIDSIZE=16;
  25788. __static(BloomEffect,
  25789. ['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");}
  25790. ]);
  25791. return BloomEffect;
  25792. })(PostProcessEffect)
  25793. /**
  25794. *<code>CapsuleColliderShape</code> 类用于创建胶囊形状碰撞器。
  25795. */
  25796. //class laya.d3.physics.shape.CapsuleColliderShape extends laya.d3.physics.shape.ColliderShape
  25797. var CapsuleColliderShape=(function(_super){
  25798. function CapsuleColliderShape(radius,length,orientation){
  25799. /**@private */
  25800. //this._radius=NaN;
  25801. /**@private */
  25802. //this._length=NaN;
  25803. /**@private */
  25804. //this._orientation=0;
  25805. CapsuleColliderShape.__super.call(this);
  25806. (radius===void 0)&& (radius=0.5);
  25807. (length===void 0)&& (length=1.25);
  25808. (orientation===void 0)&& (orientation=/*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPY*/1);
  25809. this._radius=radius;
  25810. this._length=length;
  25811. this._orientation=orientation;
  25812. this._type=/*laya.d3.physics.shape.ColliderShape.SHAPETYPES_CAPSULE*/3;
  25813. switch (orientation){
  25814. case /*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPX*/0:
  25815. this._nativeShape=new Laya3D._physics3D.btCapsuleShapeX(radius,length-radius *2);
  25816. break ;
  25817. case /*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPY*/1:
  25818. this._nativeShape=new Laya3D._physics3D.btCapsuleShape(radius,length-radius *2);
  25819. break ;
  25820. case /*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPZ*/2:
  25821. this._nativeShape=new Laya3D._physics3D.btCapsuleShapeZ(radius,length-radius *2);
  25822. break ;
  25823. default :
  25824. throw "CapsuleColliderShape:unknown orientation.";
  25825. }
  25826. }
  25827. __class(CapsuleColliderShape,'laya.d3.physics.shape.CapsuleColliderShape',_super);
  25828. var __proto=CapsuleColliderShape.prototype;
  25829. /**
  25830. *@inheritDoc
  25831. */
  25832. __proto._setScale=function(value){
  25833. var fixScale=CapsuleColliderShape._tempVector30;
  25834. switch (this.orientation){
  25835. case /*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPX*/0:
  25836. fixScale.x=value.x;
  25837. fixScale.y=fixScale.z=Math.max(value.y,value.z);
  25838. break ;
  25839. case /*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPY*/1:
  25840. fixScale.y=value.y;
  25841. fixScale.x=fixScale.z=Math.max(value.x,value.z);
  25842. break ;
  25843. case /*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPZ*/2:
  25844. fixScale.z=value.z;
  25845. fixScale.x=fixScale.y=Math.max(value.x,value.y);
  25846. break ;
  25847. default :
  25848. throw "CapsuleColliderShape:unknown orientation.";
  25849. }
  25850. _super.prototype._setScale.call(this,fixScale);
  25851. }
  25852. /**
  25853. *@inheritDoc
  25854. */
  25855. __proto.clone=function(){
  25856. var dest=new CapsuleColliderShape(this._radius,this._length,this._orientation);
  25857. this.cloneTo(dest);
  25858. return dest;
  25859. }
  25860. /**
  25861. *获取半径。
  25862. */
  25863. __getset(0,__proto,'radius',function(){
  25864. return this._radius;
  25865. });
  25866. /**
  25867. *获取长度。
  25868. */
  25869. __getset(0,__proto,'length',function(){
  25870. return this._length;
  25871. });
  25872. /**
  25873. *获取方向。
  25874. */
  25875. __getset(0,__proto,'orientation',function(){
  25876. return this._orientation;
  25877. });
  25878. __static(CapsuleColliderShape,
  25879. ['_tempVector30',function(){return this._tempVector30=new Vector3();}
  25880. ]);
  25881. return CapsuleColliderShape;
  25882. })(ColliderShape)
  25883. /**
  25884. *<code>ShurikenParticleSystem</code> 类用于创建3D粒子数据模板。
  25885. */
  25886. //class laya.d3.core.particleShuriKen.ShurikenParticleSystem extends laya.d3.core.GeometryElement
  25887. var ShurikenParticleSystem=(function(_super){
  25888. function ShurikenParticleSystem(owner){
  25889. /**@private */
  25890. //this._boundingSphere=null;
  25891. /**@private */
  25892. //this._boundingBox=null;
  25893. /**@private */
  25894. //this._boundingBoxCorners=null;
  25895. /**@private */
  25896. //this._owner=null;
  25897. /**@private */
  25898. //this._ownerRender=null;
  25899. /**@private */
  25900. //this._vertices=null;
  25901. /**@private */
  25902. //this._floatCountPerVertex=0;
  25903. /**@private */
  25904. //this._startLifeTimeIndex=0;
  25905. /**@private */
  25906. //this._timeIndex=0;
  25907. /**@private */
  25908. //this._simulateUpdate=false;
  25909. /**@private */
  25910. //this._firstActiveElement=0;
  25911. /**@private */
  25912. //this._firstNewElement=0;
  25913. /**@private */
  25914. //this._firstFreeElement=0;
  25915. /**@private */
  25916. //this._firstRetiredElement=0;
  25917. /**@private */
  25918. //this._drawCounter=0;
  25919. /**@private */
  25920. //this._bufferMaxParticles=0;
  25921. /**@private */
  25922. //this._emission=null;
  25923. /**@private */
  25924. //this._shape=null;
  25925. /**@private */
  25926. //this._isEmitting=false;
  25927. /**@private */
  25928. //this._isPlaying=false;
  25929. /**@private */
  25930. //this._isPaused=false;
  25931. /**@private */
  25932. //this._playStartDelay=NaN;
  25933. /**@private 发射的累计时间。*/
  25934. //this._frameRateTime=NaN;
  25935. /**@private 一次循环内的累计时间。*/
  25936. //this._emissionTime=NaN;
  25937. /**@private */
  25938. //this._totalDelayTime=NaN;
  25939. /**@private */
  25940. //this._burstsIndex=0;
  25941. /**@private */
  25942. //this._velocityOverLifetime=null;
  25943. /**@private */
  25944. //this._colorOverLifetime=null;
  25945. /**@private */
  25946. //this._sizeOverLifetime=null;
  25947. /**@private */
  25948. //this._rotationOverLifetime=null;
  25949. /**@private */
  25950. //this._textureSheetAnimation=null;
  25951. /**@private */
  25952. //this._startLifetimeType=0;
  25953. /**@private */
  25954. //this._startLifetimeConstant=NaN;
  25955. /**@private */
  25956. //this._startLifeTimeGradient=null;
  25957. /**@private */
  25958. //this._startLifetimeConstantMin=NaN;
  25959. /**@private */
  25960. //this._startLifetimeConstantMax=NaN;
  25961. /**@private */
  25962. //this._startLifeTimeGradientMin=null;
  25963. /**@private */
  25964. //this._startLifeTimeGradientMax=null;
  25965. /**@private */
  25966. //this._maxStartLifetime=NaN;
  25967. /**@private */
  25968. //this._vertexStride=0;
  25969. /**@private */
  25970. //this._indexStride=0;
  25971. /**@private */
  25972. //this._vertexBuffer=null;
  25973. /**@private */
  25974. //this._indexBuffer=null;
  25975. /**@private */
  25976. //this._currentTime=NaN;
  25977. /**@private */
  25978. //this._startUpdateLoopCount=0;
  25979. /**@private */
  25980. //this._rand=null;
  25981. /**@private */
  25982. //this._randomSeeds=null;
  25983. /**粒子运行的总时长,单位为秒。*/
  25984. //this.duration=NaN;
  25985. /**是否循环。*/
  25986. //this.looping=false;
  25987. /**是否预热。暂不支持*/
  25988. //this.prewarm=false;
  25989. /**开始延迟类型,0为常量模式,1为随机随机双常量模式,不能和prewarm一起使用。*/
  25990. //this.startDelayType=0;
  25991. /**开始播放延迟,不能和prewarm一起使用。*/
  25992. //this.startDelay=NaN;
  25993. /**开始播放最小延迟,不能和prewarm一起使用。*/
  25994. //this.startDelayMin=NaN;
  25995. /**开始播放最大延迟,不能和prewarm一起使用。*/
  25996. //this.startDelayMax=NaN;
  25997. /**开始速度模式,0为恒定速度,2为两个恒定速度的随机插值。缺少1、3模式*/
  25998. //this.startSpeedType=0;
  25999. /**开始速度,0模式。*/
  26000. //this.startSpeedConstant=NaN;
  26001. /**最小开始速度,1模式。*/
  26002. //this.startSpeedConstantMin=NaN;
  26003. /**最大开始速度,1模式。*/
  26004. //this.startSpeedConstantMax=NaN;
  26005. /**开始尺寸是否为3D模式。*/
  26006. //this.threeDStartSize=false;
  26007. /**开始尺寸模式,0为恒定尺寸,2为两个恒定尺寸的随机插值。缺少1、3模式和对应的二种3D模式*/
  26008. //this.startSizeType=0;
  26009. /**开始尺寸,0模式。*/
  26010. //this.startSizeConstant=NaN;
  26011. /**开始三维尺寸,0模式。*/
  26012. //this.startSizeConstantSeparate=null;
  26013. /**最小开始尺寸,2模式。*/
  26014. //this.startSizeConstantMin=NaN;
  26015. /**最大开始尺寸,2模式。*/
  26016. //this.startSizeConstantMax=NaN;
  26017. /**最小三维开始尺寸,2模式。*/
  26018. //this.startSizeConstantMinSeparate=null;
  26019. /**最大三维开始尺寸,2模式。*/
  26020. //this.startSizeConstantMaxSeparate=null;
  26021. /**3D开始旋转,暂不支持*/
  26022. //this.threeDStartRotation=false;
  26023. /**开始旋转模式,0为恒定尺寸,2为两个恒定旋转的随机插值,缺少2种模式,和对应的四种3D模式。*/
  26024. //this.startRotationType=0;
  26025. /**开始旋转,0模式。*/
  26026. //this.startRotationConstant=NaN;
  26027. /**开始三维旋转,0模式。*/
  26028. //this.startRotationConstantSeparate=null;
  26029. /**最小开始旋转,1模式。*/
  26030. //this.startRotationConstantMin=NaN;
  26031. /**最大开始旋转,1模式。*/
  26032. //this.startRotationConstantMax=NaN;
  26033. /**最小开始三维旋转,1模式。*/
  26034. //this.startRotationConstantMinSeparate=null;
  26035. /**最大开始三维旋转,1模式。*/
  26036. //this.startRotationConstantMaxSeparate=null;
  26037. /**随机旋转方向,范围为0.0到1.0*/
  26038. //this.randomizeRotationDirection=NaN;
  26039. /**开始颜色模式,0为恒定颜色,2为两个恒定颜色的随机插值,缺少2种模式。*/
  26040. //this.startColorType=0;
  26041. /**开始颜色,0模式。*/
  26042. //this.startColorConstant=null;
  26043. /**最小开始颜色,1模式。*/
  26044. //this.startColorConstantMin=null;
  26045. /**最大开始颜色,1模式。*/
  26046. //this.startColorConstantMax=null;
  26047. /**重力敏感度。*/
  26048. //this.gravityModifier=NaN;
  26049. /**模拟器空间,0为World,1为Local。暂不支持Custom。*/
  26050. //this.simulationSpace=0;
  26051. /**缩放模式,0为Hiercachy,1为Local,2为World。*/
  26052. //this.scaleMode=0;
  26053. /**激活时是否自动播放。*/
  26054. //this.playOnAwake=false;
  26055. /**随机种子,注:play()前设置有效。*/
  26056. //this.randomSeed=null;
  26057. /**是否使用随机种子。 */
  26058. //this.autoRandomSeed=false;
  26059. /**是否为性能模式,性能模式下会延迟粒子释放。*/
  26060. //this.isPerformanceMode=false;
  26061. ShurikenParticleSystem.__super.call(this);
  26062. this._tempRotationMatrix=new Matrix4x4();
  26063. this._uvLength=new Vector2();
  26064. this._bufferState=new BufferState();
  26065. this._firstActiveElement=0;
  26066. this._firstNewElement=0;
  26067. this._firstFreeElement=0;
  26068. this._firstRetiredElement=0;
  26069. this._owner=owner;
  26070. this._ownerRender=owner.particleRenderer;
  26071. this._boundingBoxCorners=__newvec(8,null);
  26072. this._boundingSphere=new BoundSphere(new Vector3(),Number.MAX_VALUE);
  26073. 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));
  26074. this._currentTime=0;
  26075. this._isEmitting=false;
  26076. this._isPlaying=false;
  26077. this._isPaused=false;
  26078. this._burstsIndex=0;
  26079. this._frameRateTime=0;
  26080. this._emissionTime=0;
  26081. this._totalDelayTime=0;
  26082. this._simulateUpdate=false;
  26083. this._bufferMaxParticles=1;
  26084. this.duration=5.0;
  26085. this.looping=true;
  26086. this.prewarm=false;
  26087. this.startDelayType=0;
  26088. this.startDelay=0.0;
  26089. this.startDelayMin=0.0;
  26090. this.startDelayMax=0.0;
  26091. this._startLifetimeType=0;
  26092. this._startLifetimeConstant=5.0;
  26093. this._startLifeTimeGradient=new GradientDataNumber();
  26094. this._startLifetimeConstantMin=0.0;
  26095. this._startLifetimeConstantMax=5.0;
  26096. this._startLifeTimeGradientMin=new GradientDataNumber();
  26097. this._startLifeTimeGradientMax=new GradientDataNumber();
  26098. this._maxStartLifetime=5.0;
  26099. this.startSpeedType=0;
  26100. this.startSpeedConstant=5.0;
  26101. this.startSpeedConstantMin=0.0;
  26102. this.startSpeedConstantMax=5.0;
  26103. this.threeDStartSize=false;
  26104. this.startSizeType=0;
  26105. this.startSizeConstant=1;
  26106. this.startSizeConstantSeparate=new Vector3(1,1,1);
  26107. this.startSizeConstantMin=0;
  26108. this.startSizeConstantMax=1;
  26109. this.startSizeConstantMinSeparate=new Vector3(0,0,0);
  26110. this.startSizeConstantMaxSeparate=new Vector3(1,1,1);
  26111. this.threeDStartRotation=false;
  26112. this.startRotationType=0;
  26113. this.startRotationConstant=0;
  26114. this.startRotationConstantSeparate=new Vector3(0,0,0);
  26115. this.startRotationConstantMin=0.0;
  26116. this.startRotationConstantMax=0.0;
  26117. this.startRotationConstantMinSeparate=new Vector3(0,0,0);
  26118. this.startRotationConstantMaxSeparate=new Vector3(0,0,0);
  26119. this.randomizeRotationDirection=0.0;
  26120. this.startColorType=0;
  26121. this.startColorConstant=new Vector4(1,1,1,1);
  26122. this.startColorConstantMin=new Vector4(1,1,1,1);
  26123. this.startColorConstantMax=new Vector4(1,1,1,1);
  26124. this.gravityModifier=0.0;
  26125. this.simulationSpace=1;
  26126. this.scaleMode=0;
  26127. this.playOnAwake=true;
  26128. this._rand=new Rand(0);
  26129. this.autoRandomSeed=true;
  26130. this.randomSeed=new Uint32Array(1);
  26131. this._randomSeeds=new Uint32Array(ShurikenParticleSystem._RANDOMOFFSET.length);
  26132. this.isPerformanceMode=true;
  26133. this._emission=new Emission();
  26134. this._emission.enbale=true;
  26135. }
  26136. __class(ShurikenParticleSystem,'laya.d3.core.particleShuriKen.ShurikenParticleSystem',_super);
  26137. var __proto=ShurikenParticleSystem.prototype;
  26138. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  26139. __proto._getVertexBuffer=function(index){
  26140. (index===void 0)&& (index=0);
  26141. if (index===0)
  26142. return this._vertexBuffer;
  26143. else
  26144. return null;
  26145. }
  26146. __proto._getIndexBuffer=function(){
  26147. return this._indexBuffer;
  26148. }
  26149. /**
  26150. *@private
  26151. */
  26152. __proto._generateBoundingSphere=function(){
  26153. var centerE=this._boundingSphere.center;
  26154. centerE.x=0;
  26155. centerE.y=0;
  26156. centerE.z=0;
  26157. this._boundingSphere.radius=Number.MAX_VALUE;
  26158. }
  26159. /**
  26160. *@private
  26161. */
  26162. __proto._generateBoundingBox=function(){
  26163. var particle=this._owner;
  26164. var particleRender=particle.particleRenderer;
  26165. var boundMin=this._boundingBox.min;
  26166. var boundMax=this._boundingBox.max;
  26167. var i=0,n=0;
  26168. var maxStartLifeTime=NaN;
  26169. switch (this.startLifetimeType){
  26170. case 0:
  26171. maxStartLifeTime=this.startLifetimeConstant;
  26172. break ;
  26173. case 1:
  26174. maxStartLifeTime=-Number.MAX_VALUE;
  26175. var startLifeTimeGradient=startLifeTimeGradient;
  26176. for (i=0,n=startLifeTimeGradient.gradientCount;i < n;i++)
  26177. maxStartLifeTime=Math.max(maxStartLifeTime,startLifeTimeGradient.getValueByIndex(i));
  26178. break ;
  26179. case 2:
  26180. maxStartLifeTime=Math.max(this.startLifetimeConstantMin,this.startLifetimeConstantMax);
  26181. break ;
  26182. case 3:
  26183. maxStartLifeTime=-Number.MAX_VALUE;
  26184. var startLifeTimeGradientMin=startLifeTimeGradientMin;
  26185. for (i=0,n=startLifeTimeGradientMin.gradientCount;i < n;i++)
  26186. maxStartLifeTime=Math.max(maxStartLifeTime,startLifeTimeGradientMin.getValueByIndex(i));
  26187. var startLifeTimeGradientMax=startLifeTimeGradientMax;
  26188. for (i=0,n=startLifeTimeGradientMax.gradientCount;i < n;i++)
  26189. maxStartLifeTime=Math.max(maxStartLifeTime,startLifeTimeGradientMax.getValueByIndex(i));
  26190. break ;
  26191. };
  26192. var minStartSpeed=NaN,maxStartSpeed=NaN;
  26193. switch (this.startSpeedType){
  26194. case 0:
  26195. minStartSpeed=maxStartSpeed=this.startSpeedConstant;
  26196. break ;
  26197. case 1:
  26198. break ;
  26199. case 2:
  26200. minStartSpeed=this.startLifetimeConstantMin;
  26201. maxStartSpeed=this.startLifetimeConstantMax;
  26202. break ;
  26203. case 3:
  26204. break ;
  26205. };
  26206. var minPosition,maxPosition,minDirection,maxDirection;
  26207. if (this._shape && this._shape.enable){
  26208. }else {
  26209. minPosition=maxPosition=Vector3._ZERO;
  26210. minDirection=Vector3._ZERO;
  26211. maxDirection=Vector3._UnitZ;
  26212. };
  26213. var startMinVelocity=new Vector3(minDirection.x *minStartSpeed,minDirection.y *minStartSpeed,minDirection.z *minStartSpeed);
  26214. var startMaxVelocity=new Vector3(maxDirection.x *maxStartSpeed,maxDirection.y *maxStartSpeed,maxDirection.z *maxStartSpeed);
  26215. if (this._velocityOverLifetime && this._velocityOverLifetime.enbale){
  26216. var lifeMinVelocity;
  26217. var lifeMaxVelocity;
  26218. var velocity=this._velocityOverLifetime.velocity;
  26219. switch (velocity.type){
  26220. case 0:
  26221. lifeMinVelocity=lifeMaxVelocity=velocity.constant;
  26222. break ;
  26223. case 1:
  26224. lifeMinVelocity=lifeMaxVelocity=new Vector3(velocity.gradientX.getAverageValue(),velocity.gradientY.getAverageValue(),velocity.gradientZ.getAverageValue());
  26225. break ;
  26226. case 2:
  26227. lifeMinVelocity=velocity.constantMin;
  26228. lifeMaxVelocity=velocity.constantMax;
  26229. break ;
  26230. case 3:
  26231. lifeMinVelocity=new Vector3(velocity.gradientXMin.getAverageValue(),velocity.gradientYMin.getAverageValue(),velocity.gradientZMin.getAverageValue());
  26232. lifeMaxVelocity=new Vector3(velocity.gradientXMax.getAverageValue(),velocity.gradientYMax.getAverageValue(),velocity.gradientZMax.getAverageValue());
  26233. break ;
  26234. }
  26235. };
  26236. var positionScale,velocityScale;
  26237. var transform=this._owner.transform;
  26238. var worldPosition=transform.position;
  26239. var sizeScale=ShurikenParticleSystem._tempVector39;
  26240. var renderMode=particleRender.renderMode;
  26241. switch (this.scaleMode){
  26242. case 0:;
  26243. var scale=transform.scale;
  26244. positionScale=scale;
  26245. sizeScale.x=scale.x;
  26246. sizeScale.y=scale.z;
  26247. sizeScale.z=scale.y;
  26248. (renderMode===1)&& (velocityScale=scale);
  26249. break ;
  26250. case 1:;
  26251. var localScale=transform.localScale;
  26252. positionScale=localScale;
  26253. sizeScale.x=localScale.x;
  26254. sizeScale.y=localScale.z;
  26255. sizeScale.z=localScale.y;
  26256. (renderMode===1)&& (velocityScale=localScale);
  26257. break ;
  26258. case 2:
  26259. positionScale=transform.scale;
  26260. sizeScale.x=sizeScale.y=sizeScale.z=1;
  26261. (renderMode===1)&& (velocityScale=Vector3._ONE);
  26262. break ;
  26263. };
  26264. var minStratPosition,maxStratPosition;
  26265. if (this._velocityOverLifetime && this._velocityOverLifetime.enbale){
  26266. }else {
  26267. minStratPosition=new Vector3(startMinVelocity.x *maxStartLifeTime,startMinVelocity.y *maxStartLifeTime,startMinVelocity.z *maxStartLifeTime);
  26268. maxStratPosition=new Vector3(startMaxVelocity.x *maxStartLifeTime,startMaxVelocity.y *maxStartLifeTime,startMaxVelocity.z *maxStartLifeTime);
  26269. if (this.scaleMode !=2){
  26270. Vector3.add(minPosition,minStratPosition,boundMin);
  26271. Vector3.multiply(positionScale,boundMin,boundMin);
  26272. Vector3.add(maxPosition,maxStratPosition,boundMax);
  26273. Vector3.multiply(positionScale,boundMax,boundMax);
  26274. }else {
  26275. Vector3.multiply(positionScale,minPosition,boundMin);
  26276. Vector3.add(boundMin,minStratPosition,boundMin);
  26277. Vector3.multiply(positionScale,maxPosition,boundMax);
  26278. Vector3.add(boundMax,maxStratPosition,boundMax);
  26279. }
  26280. }
  26281. switch (this.simulationSpace){
  26282. case 0:
  26283. break ;
  26284. case 1:
  26285. Vector3.add(boundMin,worldPosition,boundMin);
  26286. Vector3.add(boundMax,worldPosition,boundMax);
  26287. break ;
  26288. };
  26289. var maxSize=NaN,maxSizeY=NaN;
  26290. switch (this.startSizeType){
  26291. case 0:
  26292. if (this.threeDStartSize){
  26293. var startSizeConstantSeparate=startSizeConstantSeparate;
  26294. maxSize=Math.max(startSizeConstantSeparate.x,startSizeConstantSeparate.y);
  26295. if (renderMode===1)
  26296. maxSizeY=startSizeConstantSeparate.y;
  26297. }else {
  26298. maxSize=this.startSizeConstant;
  26299. if (renderMode===1)
  26300. maxSizeY=this.startSizeConstant;
  26301. }
  26302. break ;
  26303. case 1:
  26304. break ;
  26305. case 2:
  26306. if (this.threeDStartSize){
  26307. var startSizeConstantMaxSeparate=startSizeConstantMaxSeparate;
  26308. maxSize=Math.max(startSizeConstantMaxSeparate.x,startSizeConstantMaxSeparate.y);
  26309. if (renderMode===1)
  26310. maxSizeY=startSizeConstantMaxSeparate.y;
  26311. }else {
  26312. maxSize=this.startSizeConstantMax;
  26313. if (renderMode===1)
  26314. maxSizeY=this.startSizeConstantMax;
  26315. }
  26316. break ;
  26317. case 3:
  26318. break ;
  26319. }
  26320. if (this._sizeOverLifetime && this._sizeOverLifetime.enbale){
  26321. var size=this._sizeOverLifetime.size;
  26322. maxSize *=this._sizeOverLifetime.size.getMaxSizeInGradient();
  26323. };
  26324. var threeDMaxSize=ShurikenParticleSystem._tempVector30;
  26325. var rotSize=NaN,nonRotSize=NaN;
  26326. switch (renderMode){
  26327. case 0:
  26328. rotSize=maxSize *ShurikenParticleSystem.halfKSqrtOf2;
  26329. Vector3.scale(sizeScale,maxSize,threeDMaxSize);
  26330. Vector3.subtract(boundMin,threeDMaxSize,boundMin);
  26331. Vector3.add(boundMax,threeDMaxSize,boundMax);
  26332. break ;
  26333. case 1:;
  26334. var maxStretchPosition=ShurikenParticleSystem._tempVector31;
  26335. var maxStretchVelocity=ShurikenParticleSystem._tempVector32;
  26336. var minStretchVelocity=ShurikenParticleSystem._tempVector33;
  26337. var minStretchPosition=ShurikenParticleSystem._tempVector34;
  26338. if (this._velocityOverLifetime && this._velocityOverLifetime.enbale){
  26339. }else {
  26340. Vector3.multiply(velocityScale,startMaxVelocity,maxStretchVelocity);
  26341. Vector3.multiply(velocityScale,startMinVelocity,minStretchVelocity);
  26342. };
  26343. var sizeStretch=maxSizeY *particleRender.stretchedBillboardLengthScale;
  26344. var maxStretchLength=Vector3.scalarLength(maxStretchVelocity)*particleRender.stretchedBillboardSpeedScale+sizeStretch;
  26345. var minStretchLength=Vector3.scalarLength(minStretchVelocity)*particleRender.stretchedBillboardSpeedScale+sizeStretch;
  26346. var norMaxStretchVelocity=ShurikenParticleSystem._tempVector35;
  26347. var norMinStretchVelocity=ShurikenParticleSystem._tempVector36;
  26348. Vector3.normalize(maxStretchVelocity,norMaxStretchVelocity);
  26349. Vector3.scale(norMaxStretchVelocity,maxStretchLength,minStretchPosition);
  26350. Vector3.subtract(maxStratPosition,minStretchPosition,minStretchPosition);
  26351. Vector3.normalize(minStretchVelocity,norMinStretchVelocity);
  26352. Vector3.scale(norMinStretchVelocity,minStretchLength,maxStretchPosition);
  26353. Vector3.add(minStratPosition,maxStretchPosition,maxStretchPosition);
  26354. rotSize=maxSize *ShurikenParticleSystem.halfKSqrtOf2;
  26355. Vector3.scale(sizeScale,rotSize,threeDMaxSize);
  26356. var halfNorMaxStretchVelocity=ShurikenParticleSystem._tempVector37;
  26357. var halfNorMinStretchVelocity=ShurikenParticleSystem._tempVector38;
  26358. Vector3.scale(norMaxStretchVelocity,0.5,halfNorMaxStretchVelocity);
  26359. Vector3.scale(norMinStretchVelocity,0.5,halfNorMinStretchVelocity);
  26360. Vector3.multiply(halfNorMaxStretchVelocity,sizeScale,halfNorMaxStretchVelocity);
  26361. Vector3.multiply(halfNorMinStretchVelocity,sizeScale,halfNorMinStretchVelocity);
  26362. Vector3.add(boundMin,halfNorMinStretchVelocity,boundMin);
  26363. Vector3.min(boundMin,minStretchPosition,boundMin);
  26364. Vector3.subtract(boundMin,threeDMaxSize,boundMin);
  26365. Vector3.subtract(boundMax,halfNorMaxStretchVelocity,boundMax);
  26366. Vector3.max(boundMax,maxStretchPosition,boundMax);
  26367. Vector3.add(boundMax,threeDMaxSize,boundMax);
  26368. break ;
  26369. case 2:
  26370. maxSize *=Math.cos(0.78539816339744830961566084581988);
  26371. nonRotSize=maxSize *0.5;
  26372. threeDMaxSize.x=sizeScale.x *nonRotSize;
  26373. threeDMaxSize.y=sizeScale.z *nonRotSize;
  26374. Vector3.subtract(boundMin,threeDMaxSize,boundMin);
  26375. Vector3.add(boundMax,threeDMaxSize,boundMax);
  26376. break ;
  26377. case 3:
  26378. maxSize *=Math.cos(0.78539816339744830961566084581988);
  26379. nonRotSize=maxSize *0.5;
  26380. Vector3.scale(sizeScale,nonRotSize,threeDMaxSize);
  26381. Vector3.subtract(boundMin,threeDMaxSize,boundMin);
  26382. Vector3.add(boundMax,threeDMaxSize,boundMax);
  26383. break ;
  26384. }
  26385. this._boundingBox.getCorners(this._boundingBoxCorners);
  26386. }
  26387. /**
  26388. *@private
  26389. */
  26390. __proto._updateEmission=function(){
  26391. if (!this.isAlive)
  26392. return;
  26393. if (this._simulateUpdate){
  26394. this._simulateUpdate=false;
  26395. }
  26396. else{
  26397. var elapsedTime=(this._startUpdateLoopCount!==Stat.loopCount && !this._isPaused)?(this._owner._scene).timer._delta / 1000.0:0;
  26398. elapsedTime=Math.min(ShurikenParticleSystem._maxElapsedTime,elapsedTime);
  26399. this._updateParticles(elapsedTime);
  26400. }
  26401. }
  26402. /**
  26403. *@private
  26404. */
  26405. __proto._updateParticles=function(elapsedTime){
  26406. if (this._ownerRender.renderMode===4 && !this._ownerRender.mesh)
  26407. return;
  26408. this._currentTime+=elapsedTime;
  26409. this._retireActiveParticles();
  26410. this._freeRetiredParticles();
  26411. this._totalDelayTime+=elapsedTime;
  26412. if (this._totalDelayTime < this._playStartDelay){
  26413. return;
  26414. }
  26415. if (this._emission.enbale&&this._isEmitting &&!this._isPaused)
  26416. this._advanceTime(elapsedTime,this._currentTime);
  26417. }
  26418. /**
  26419. *@private
  26420. */
  26421. __proto._updateParticlesSimulationRestart=function(time){
  26422. this._firstActiveElement=0;
  26423. this._firstNewElement=0;
  26424. this._firstFreeElement=0;
  26425. this._firstRetiredElement=0;
  26426. this._burstsIndex=0;
  26427. this._frameRateTime=time;
  26428. this._emissionTime=0;
  26429. this._totalDelayTime=0;
  26430. this._currentTime=time;
  26431. var delayTime=time;
  26432. if (delayTime < this._playStartDelay){
  26433. this._totalDelayTime=delayTime;
  26434. return;
  26435. }
  26436. if (this._emission.enbale)
  26437. this._advanceTime(time,time);
  26438. }
  26439. /**
  26440. *@private
  26441. */
  26442. __proto._retireActiveParticles=function(){
  26443. var epsilon=0.0001;
  26444. while (this._firstActiveElement !=this._firstNewElement){
  26445. var index=this._firstActiveElement *this._floatCountPerVertex *this._vertexStride;
  26446. var timeIndex=index+this._timeIndex;
  26447. var particleAge=this._currentTime-this._vertices[timeIndex];
  26448. if (particleAge+epsilon < this._vertices[index+this._startLifeTimeIndex])
  26449. break ;
  26450. this._vertices[timeIndex]=this._drawCounter;
  26451. this._firstActiveElement++;
  26452. if (this._firstActiveElement >=this._bufferMaxParticles)
  26453. this._firstActiveElement=0;
  26454. }
  26455. }
  26456. /**
  26457. *@private
  26458. */
  26459. __proto._freeRetiredParticles=function(){
  26460. while (this._firstRetiredElement !=this._firstActiveElement){
  26461. var age=this._drawCounter-this._vertices[this._firstRetiredElement *this._floatCountPerVertex *this._vertexStride+this._timeIndex];
  26462. if (this.isPerformanceMode)
  26463. if (age < 3)
  26464. break ;
  26465. this._firstRetiredElement++;
  26466. if (this._firstRetiredElement >=this._bufferMaxParticles)
  26467. this._firstRetiredElement=0;
  26468. }
  26469. }
  26470. /**
  26471. *@private
  26472. */
  26473. __proto._burst=function(fromTime,toTime){
  26474. var totalEmitCount=0;
  26475. var bursts=this._emission._bursts;
  26476. for (var n=bursts.length;this._burstsIndex < n;this._burstsIndex++){
  26477. var burst=bursts[this._burstsIndex];
  26478. var burstTime=burst.time;
  26479. if (fromTime<=burstTime && burstTime < toTime){
  26480. var emitCount=0;
  26481. if (this.autoRandomSeed){
  26482. emitCount=MathUtil.lerp(burst.minCount,burst.maxCount,Math.random());
  26483. }else {
  26484. this._rand.seed=this._randomSeeds[0];
  26485. emitCount=MathUtil.lerp(burst.minCount,burst.maxCount,this._rand.getFloat());
  26486. this._randomSeeds[0]=this._rand.seed;
  26487. }
  26488. totalEmitCount+=emitCount;
  26489. }else {
  26490. break ;
  26491. }
  26492. }
  26493. return totalEmitCount;
  26494. }
  26495. /**
  26496. *@private
  26497. */
  26498. __proto._advanceTime=function(elapsedTime,emitTime){
  26499. var i=0;
  26500. var lastEmissionTime=this._emissionTime;
  26501. this._emissionTime+=elapsedTime;
  26502. var totalEmitCount=0;
  26503. if (this._emissionTime > this.duration){
  26504. if (this.looping){
  26505. totalEmitCount+=this._burst(lastEmissionTime,this._emissionTime);
  26506. this._emissionTime-=this.duration;
  26507. this._burstsIndex=0;
  26508. totalEmitCount+=this._burst(0,this._emissionTime);
  26509. }else {
  26510. totalEmitCount=Math.min(this.maxParticles-this.aliveParticleCount,totalEmitCount);
  26511. for (i=0;i < totalEmitCount;i++)
  26512. this.emit(emitTime);
  26513. this._isPlaying=false;
  26514. this.stop();
  26515. return;
  26516. }
  26517. }else {
  26518. totalEmitCount+=this._burst(lastEmissionTime,this._emissionTime);
  26519. }
  26520. totalEmitCount=Math.min(this.maxParticles-this.aliveParticleCount,totalEmitCount);
  26521. for (i=0;i < totalEmitCount;i++)
  26522. this.emit(emitTime);
  26523. var emissionRate=this.emission.emissionRate;
  26524. if (emissionRate>0){
  26525. var minEmissionTime=1/emissionRate;
  26526. this._frameRateTime+=minEmissionTime;
  26527. this._frameRateTime=this._currentTime-(this._currentTime-this._frameRateTime)% this._maxStartLifetime;
  26528. while (this._frameRateTime <=emitTime){
  26529. if (this.emit(this._frameRateTime))
  26530. this._frameRateTime+=minEmissionTime;
  26531. else
  26532. break ;
  26533. }
  26534. this._frameRateTime=Math.floor(emitTime / minEmissionTime)*minEmissionTime;
  26535. }
  26536. }
  26537. /**
  26538. *@private
  26539. */
  26540. __proto._initBufferDatas=function(){
  26541. if (this._vertexBuffer){
  26542. this._vertexBuffer.destroy();
  26543. this._indexBuffer.destroy();
  26544. };
  26545. var render=this._ownerRender;
  26546. var renderMode=render.renderMode;
  26547. if (renderMode!==-1 && this.maxParticles > 0){
  26548. var indices,i=0,j=0,m=0,indexOffset=0,perPartOffset=0,vertexDeclaration;;
  26549. var vbMemorySize=0,memorySize=0;
  26550. var mesh=render.mesh;
  26551. if (renderMode===4){
  26552. if(mesh){
  26553. var vertexBufferCount=mesh._vertexBuffers.length;
  26554. if (vertexBufferCount > 1){
  26555. throw new Error("ShurikenParticleSystem: submesh Count mesh be One or all subMeshes have the same vertexDeclaration.");
  26556. }else {
  26557. vertexDeclaration=VertexShurikenParticleMesh.vertexDeclaration;
  26558. this._floatCountPerVertex=vertexDeclaration.vertexStride/4;
  26559. this._startLifeTimeIndex=12;
  26560. this._timeIndex=16;
  26561. this._vertexStride=mesh._vertexBuffers[0].vertexCount;
  26562. var totalVertexCount=this._bufferMaxParticles *this._vertexStride;
  26563. var vbCount=Math.floor(totalVertexCount / 65535)+1;
  26564. var lastVBVertexCount=totalVertexCount % 65535;
  26565. if (vbCount > 1){
  26566. throw new Error("ShurikenParticleSystem:the maxParticleCount multiply mesh vertexCount is large than 65535.");
  26567. }
  26568. vbMemorySize=vertexDeclaration.vertexStride *lastVBVertexCount;
  26569. this._vertexBuffer=new VertexBuffer3D(vbMemorySize,/*laya.webgl.WebGLContext.DYNAMIC_DRAW*/0x88E8);
  26570. this._vertexBuffer.vertexDeclaration=vertexDeclaration;
  26571. this._vertices=new Float32Array(this._floatCountPerVertex *lastVBVertexCount);
  26572. this._indexStride=mesh._indexBuffer.indexCount;
  26573. var indexDatas=mesh._indexBuffer.getData();
  26574. var indexCount=this._bufferMaxParticles *this._indexStride;
  26575. this._indexBuffer=new IndexBuffer3D(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",indexCount,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4);
  26576. indices=new Uint16Array(indexCount);
  26577. memorySize=vbMemorySize+indexCount *2;
  26578. indexOffset=0;
  26579. for (i=0;i < this._bufferMaxParticles;i++){
  26580. var indexValueOffset=i *this._vertexStride;
  26581. for (j=0,m=indexDatas.length;j < m;j++)
  26582. indices[indexOffset++]=indexValueOffset+indexDatas[j];
  26583. }
  26584. this._indexBuffer.setData(indices);
  26585. this._bufferState.bind();
  26586. this._bufferState.applyVertexBuffer(this._vertexBuffer);
  26587. this._bufferState.applyIndexBuffer(this._indexBuffer);
  26588. this._bufferState.unBind();
  26589. }
  26590. }
  26591. }else {
  26592. vertexDeclaration=VertexShurikenParticleBillboard.vertexDeclaration;
  26593. this._floatCountPerVertex=vertexDeclaration.vertexStride/4;
  26594. this._startLifeTimeIndex=7;
  26595. this._timeIndex=11;
  26596. this._vertexStride=4;
  26597. vbMemorySize=vertexDeclaration.vertexStride *this._bufferMaxParticles *this._vertexStride;
  26598. this._vertexBuffer=new VertexBuffer3D(vbMemorySize,/*laya.webgl.WebGLContext.DYNAMIC_DRAW*/0x88E8);
  26599. this._vertexBuffer.vertexDeclaration=vertexDeclaration;
  26600. this._vertices=new Float32Array(this._floatCountPerVertex *this._bufferMaxParticles *this._vertexStride);
  26601. for (i=0;i < this._bufferMaxParticles;i++){
  26602. perPartOffset=i *this._floatCountPerVertex *this._vertexStride;
  26603. this._vertices[perPartOffset]=-0.5;
  26604. this._vertices[perPartOffset+1]=-0.5;
  26605. this._vertices[perPartOffset+2]=0;
  26606. this._vertices[perPartOffset+3]=1;
  26607. perPartOffset+=this._floatCountPerVertex;
  26608. this._vertices[perPartOffset]=0.5;
  26609. this._vertices[perPartOffset+1]=-0.5;
  26610. this._vertices[perPartOffset+2]=1;
  26611. this._vertices[perPartOffset+3]=1;
  26612. perPartOffset+=this._floatCountPerVertex
  26613. this._vertices[perPartOffset]=0.5;
  26614. this._vertices[perPartOffset+1]=0.5;
  26615. this._vertices[perPartOffset+2]=1;
  26616. this._vertices[perPartOffset+3]=0;
  26617. perPartOffset+=this._floatCountPerVertex
  26618. this._vertices[perPartOffset]=-0.5;
  26619. this._vertices[perPartOffset+1]=0.5;
  26620. this._vertices[perPartOffset+2]=0;
  26621. this._vertices[perPartOffset+3]=0;
  26622. }
  26623. this._indexStride=6;
  26624. this._indexBuffer=new IndexBuffer3D(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",this._bufferMaxParticles *6,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4);
  26625. indices=new Uint16Array(this._bufferMaxParticles *6);
  26626. for (i=0;i < this._bufferMaxParticles;i++){
  26627. indexOffset=i *6;
  26628. var firstVertex=i *this._vertexStride,secondVertex=firstVertex+2;
  26629. indices[indexOffset++]=firstVertex;
  26630. indices[indexOffset++]=secondVertex;
  26631. indices[indexOffset++]=firstVertex+1;
  26632. indices[indexOffset++]=firstVertex;
  26633. indices[indexOffset++]=firstVertex+3;
  26634. indices[indexOffset++]=secondVertex;
  26635. }
  26636. this._indexBuffer.setData(indices);
  26637. memorySize=vbMemorySize+this._bufferMaxParticles *6 *2;
  26638. this._bufferState.bind();
  26639. this._bufferState.applyVertexBuffer(this._vertexBuffer);
  26640. this._bufferState.applyIndexBuffer(this._indexBuffer);
  26641. this._bufferState.unBind();
  26642. }
  26643. Resource._addMemory(memorySize,memorySize);
  26644. }
  26645. }
  26646. /**
  26647. *@private
  26648. */
  26649. __proto.destroy=function(){
  26650. _super.prototype.destroy.call(this);
  26651. var memorySize=this._vertexBuffer._byteLength+this._indexBuffer.indexCount *2;
  26652. Resource._addMemory(-memorySize,-memorySize);
  26653. this._bufferState.destroy();
  26654. this._vertexBuffer.destroy();
  26655. this._indexBuffer.destroy();
  26656. this._emission.destroy();
  26657. this._bufferState=null;
  26658. this._vertexBuffer=null;
  26659. this._indexBuffer=null;
  26660. this._owner=null;
  26661. this._vertices=null;
  26662. this._indexBuffer=null;
  26663. this._emission=null;
  26664. this._shape=null;
  26665. this.startLifeTimeGradient=null;
  26666. this.startLifeTimeGradientMin=null;
  26667. this.startLifeTimeGradientMax=null;
  26668. this.startSizeConstantSeparate=null;
  26669. this.startSizeConstantMinSeparate=null;
  26670. this.startSizeConstantMaxSeparate=null;
  26671. this.startRotationConstantSeparate=null;
  26672. this.startRotationConstantMinSeparate=null;
  26673. this.startRotationConstantMaxSeparate=null;
  26674. this.startColorConstant=null;
  26675. this.startColorConstantMin=null;
  26676. this.startColorConstantMax=null;
  26677. this._velocityOverLifetime=null;
  26678. this._colorOverLifetime=null;
  26679. this._sizeOverLifetime=null;
  26680. this._rotationOverLifetime=null;
  26681. this._textureSheetAnimation=null;
  26682. }
  26683. /**
  26684. *发射一个粒子。
  26685. */
  26686. __proto.emit=function(time){
  26687. var position=ShurikenParticleSystem._tempPosition;
  26688. var direction=ShurikenParticleSystem._tempDirection;
  26689. if (this._shape&&this._shape.enable){
  26690. if (this.autoRandomSeed)
  26691. this._shape.generatePositionAndDirection(position,direction);
  26692. else
  26693. this._shape.generatePositionAndDirection(position,direction,this._rand,this._randomSeeds);
  26694. }else {
  26695. position.x=position.y=position.z=0;
  26696. direction.x=direction.y=0;
  26697. direction.z=1;
  26698. }
  26699. return this.addParticle(position,direction,time);
  26700. }
  26701. //TODO:提前判断优化
  26702. __proto.addParticle=function(position,direction,time){
  26703. Vector3.normalize(direction,direction);
  26704. var nextFreeParticle=this._firstFreeElement+1;
  26705. if (nextFreeParticle >=this._bufferMaxParticles)
  26706. nextFreeParticle=0;
  26707. if (nextFreeParticle===this._firstRetiredElement)
  26708. return false;
  26709. ShurikenParticleData.create(this,this._ownerRender,this._owner.transform);
  26710. var particleAge=this._currentTime-time;
  26711. if (particleAge >=ShurikenParticleData.startLifeTime)
  26712. return true;
  26713. var randomVelocityX=NaN,randomVelocityY=NaN,randomVelocityZ=NaN,randomColor=NaN,randomSize=NaN,randomRotation=NaN,randomTextureAnimation=NaN;
  26714. var needRandomVelocity=this._velocityOverLifetime && this._velocityOverLifetime.enbale;
  26715. if (needRandomVelocity){
  26716. var velocityType=this._velocityOverLifetime.velocity.type;
  26717. if (velocityType===2 || velocityType===3){
  26718. if (this.autoRandomSeed){
  26719. randomVelocityX=Math.random();
  26720. randomVelocityY=Math.random();
  26721. randomVelocityZ=Math.random();
  26722. }else {
  26723. this._rand.seed=this._randomSeeds[9];
  26724. randomVelocityX=this._rand.getFloat();
  26725. randomVelocityY=this._rand.getFloat();
  26726. randomVelocityZ=this._rand.getFloat();
  26727. this._randomSeeds[9]=this._rand.seed;
  26728. }
  26729. }else {
  26730. needRandomVelocity=false;
  26731. }
  26732. }else {
  26733. needRandomVelocity=false;
  26734. };
  26735. var needRandomColor=this._colorOverLifetime && this._colorOverLifetime.enbale;
  26736. if (needRandomColor){
  26737. var colorType=this._colorOverLifetime.color.type;
  26738. if (colorType===3){
  26739. if (this.autoRandomSeed){
  26740. randomColor=Math.random();
  26741. }else {
  26742. this._rand.seed=this._randomSeeds[10];
  26743. randomColor=this._rand.getFloat();
  26744. this._randomSeeds[10]=this._rand.seed;
  26745. }
  26746. }else {
  26747. needRandomColor=false;
  26748. }
  26749. }else {
  26750. needRandomColor=false;
  26751. };
  26752. var needRandomSize=this._sizeOverLifetime && this._sizeOverLifetime.enbale;
  26753. if (needRandomSize){
  26754. var sizeType=this._sizeOverLifetime.size.type;
  26755. if (sizeType===3){
  26756. if (this.autoRandomSeed){
  26757. randomSize=Math.random();
  26758. }else {
  26759. this._rand.seed=this._randomSeeds[11];
  26760. randomSize=this._rand.getFloat();
  26761. this._randomSeeds[11]=this._rand.seed;
  26762. }
  26763. }else {
  26764. needRandomSize=false;
  26765. }
  26766. }else {
  26767. needRandomSize=false;
  26768. };
  26769. var needRandomRotation=this._rotationOverLifetime && this._rotationOverLifetime.enbale;
  26770. if (needRandomRotation){
  26771. var rotationType=this._rotationOverLifetime.angularVelocity.type;
  26772. if (rotationType===2 || rotationType===3){
  26773. if (this.autoRandomSeed){
  26774. randomRotation=Math.random();
  26775. }else {
  26776. this._rand.seed=this._randomSeeds[12];
  26777. randomRotation=this._rand.getFloat();
  26778. this._randomSeeds[12]=this._rand.seed;
  26779. }
  26780. }else {
  26781. needRandomRotation=false;
  26782. }
  26783. }else {
  26784. needRandomRotation=false;
  26785. };
  26786. var needRandomTextureAnimation=this._textureSheetAnimation && this._textureSheetAnimation.enable;
  26787. if (needRandomTextureAnimation){
  26788. var textureAnimationType=this._textureSheetAnimation.frame.type;
  26789. if (textureAnimationType===3){
  26790. if (this.autoRandomSeed){
  26791. randomTextureAnimation=Math.random();
  26792. }else {
  26793. this._rand.seed=this._randomSeeds[15];
  26794. randomTextureAnimation=this._rand.getFloat();
  26795. this._randomSeeds[15]=this._rand.seed;
  26796. }
  26797. }else {
  26798. needRandomTextureAnimation=false;
  26799. }
  26800. }else {
  26801. needRandomTextureAnimation=false;
  26802. };
  26803. var startIndex=this._firstFreeElement *this._floatCountPerVertex *this._vertexStride;
  26804. var subU=ShurikenParticleData.startUVInfo[0];
  26805. var subV=ShurikenParticleData.startUVInfo[1];
  26806. var startU=ShurikenParticleData.startUVInfo[2];
  26807. var startV=ShurikenParticleData.startUVInfo[3];
  26808. var meshVertices,meshVertexStride=0,meshPosOffset=0,meshCorOffset=0,meshUVOffset=0,meshVertexIndex=0;
  26809. var render=this._ownerRender;
  26810. if (render.renderMode===4){
  26811. var meshVB=render.mesh._vertexBuffers[0];
  26812. meshVertices=meshVB.getData();
  26813. var meshVertexDeclaration=meshVB.vertexDeclaration;
  26814. meshPosOffset=meshVertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0).offset / 4;
  26815. var colorElement=meshVertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_COLOR0*/1);
  26816. meshCorOffset=colorElement?colorElement.offset / 4:-1;
  26817. var uvElement=meshVertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE0*/2);
  26818. meshUVOffset=uvElement?uvElement.offset / 4:-1;
  26819. meshVertexStride=meshVertexDeclaration.vertexStride / 4;
  26820. meshVertexIndex=0;
  26821. }else {
  26822. this._vertices[startIndex+2]=startU;
  26823. this._vertices[startIndex+3]=startV+subV;
  26824. var secondOffset=startIndex+this._floatCountPerVertex;
  26825. this._vertices[secondOffset+2]=startU+subU;
  26826. this._vertices[secondOffset+3]=startV+subV;
  26827. var thirdOffset=secondOffset+this._floatCountPerVertex;
  26828. this._vertices[thirdOffset+2]=startU+subU;
  26829. this._vertices[thirdOffset+3]=startV;
  26830. var fourthOffset=thirdOffset+this._floatCountPerVertex;
  26831. this._vertices[fourthOffset+2]=startU;
  26832. this._vertices[fourthOffset+3]=startV;
  26833. }
  26834. for (var i=startIndex,n=startIndex+this._floatCountPerVertex *this._vertexStride;i < n;i+=this._floatCountPerVertex){
  26835. var offset=0;
  26836. if (render.renderMode===4){
  26837. offset=i;
  26838. var vertexOffset=meshVertexStride *(meshVertexIndex++);
  26839. var meshOffset=vertexOffset+meshPosOffset;
  26840. this._vertices[offset++]=meshVertices[meshOffset++];
  26841. this._vertices[offset++]=meshVertices[meshOffset++];
  26842. this._vertices[offset++]=meshVertices[meshOffset];
  26843. if (meshCorOffset===-1){
  26844. this._vertices[offset++]=1.0;
  26845. this._vertices[offset++]=1.0;
  26846. this._vertices[offset++]=1.0;
  26847. this._vertices[offset++]=1.0;
  26848. }
  26849. else{
  26850. meshOffset=vertexOffset+meshCorOffset;
  26851. this._vertices[offset++]=meshVertices[meshOffset++];
  26852. this._vertices[offset++]=meshVertices[meshOffset++];
  26853. this._vertices[offset++]=meshVertices[meshOffset++];
  26854. this._vertices[offset++]=meshVertices[meshOffset];
  26855. }
  26856. if (meshUVOffset===-1){
  26857. this._vertices[offset++]=0.0;
  26858. this._vertices[offset++]=0.0;
  26859. }
  26860. else{
  26861. meshOffset=vertexOffset+meshUVOffset;
  26862. this._vertices[offset++]=startU+meshVertices[meshOffset++] *subU;
  26863. this._vertices[offset++]=startV+meshVertices[meshOffset] *subV;
  26864. }
  26865. }else {
  26866. offset=i+4;
  26867. }
  26868. this._vertices[offset++]=position.x;
  26869. this._vertices[offset++]=position.y;
  26870. this._vertices[offset++]=position.z;
  26871. this._vertices[offset++]=ShurikenParticleData.startLifeTime;
  26872. this._vertices[offset++]=direction.x;
  26873. this._vertices[offset++]=direction.y;
  26874. this._vertices[offset++]=direction.z;
  26875. this._vertices[offset++]=time;
  26876. this._vertices[offset++]=ShurikenParticleData.startColor.x;
  26877. this._vertices[offset++]=ShurikenParticleData.startColor.y;
  26878. this._vertices[offset++]=ShurikenParticleData.startColor.z;
  26879. this._vertices[offset++]=ShurikenParticleData.startColor.w;
  26880. this._vertices[offset++]=ShurikenParticleData.startSize[0];
  26881. this._vertices[offset++]=ShurikenParticleData.startSize[1];
  26882. this._vertices[offset++]=ShurikenParticleData.startSize[2];
  26883. this._vertices[offset++]=ShurikenParticleData.startRotation[0];
  26884. this._vertices[offset++]=ShurikenParticleData.startRotation[1];
  26885. this._vertices[offset++]=ShurikenParticleData.startRotation[2];
  26886. this._vertices[offset++]=ShurikenParticleData.startSpeed;
  26887. needRandomColor && (this._vertices[offset+1]=randomColor);
  26888. needRandomSize && (this._vertices[offset+2]=randomSize);
  26889. needRandomRotation && (this._vertices[offset+3]=randomRotation);
  26890. needRandomTextureAnimation && (this._vertices[offset+4]=randomTextureAnimation);
  26891. if (needRandomVelocity){
  26892. this._vertices[offset+5]=randomVelocityX;
  26893. this._vertices[offset+6]=randomVelocityY;
  26894. this._vertices[offset+7]=randomVelocityZ;
  26895. }
  26896. switch(this.simulationSpace){
  26897. case 0:
  26898. offset+=8;
  26899. this._vertices[offset++]=ShurikenParticleData.simulationWorldPostion[0];
  26900. this._vertices[offset++]=ShurikenParticleData.simulationWorldPostion[1];
  26901. this._vertices[offset++]=ShurikenParticleData.simulationWorldPostion[2];
  26902. this._vertices[offset++]=ShurikenParticleData.simulationWorldRotation[0];
  26903. this._vertices[offset++]=ShurikenParticleData.simulationWorldRotation[1];
  26904. this._vertices[offset++]=ShurikenParticleData.simulationWorldRotation[2];
  26905. this._vertices[offset++]=ShurikenParticleData.simulationWorldRotation[3];
  26906. break ;
  26907. case 1:
  26908. break ;
  26909. default :
  26910. throw new Error("ShurikenParticleMaterial: SimulationSpace value is invalid.");
  26911. }
  26912. }
  26913. this._firstFreeElement=nextFreeParticle;
  26914. return true;
  26915. }
  26916. __proto.addNewParticlesToVertexBuffer=function(){
  26917. var start=0;
  26918. if (this._firstNewElement < this._firstFreeElement){
  26919. start=this._firstNewElement *this._vertexStride *this._floatCountPerVertex;
  26920. this._vertexBuffer.setData(this._vertices,start,start,(this._firstFreeElement-this._firstNewElement)*this._vertexStride *this._floatCountPerVertex);
  26921. }else {
  26922. start=this._firstNewElement *this._vertexStride *this._floatCountPerVertex;
  26923. this._vertexBuffer.setData(this._vertices,start,start,(this._bufferMaxParticles-this._firstNewElement)*this._vertexStride *this._floatCountPerVertex);
  26924. if (this._firstFreeElement > 0){
  26925. this._vertexBuffer.setData(this._vertices,0,0,this._firstFreeElement *this._vertexStride *this._floatCountPerVertex);
  26926. }
  26927. }
  26928. this._firstNewElement=this._firstFreeElement;
  26929. }
  26930. /**
  26931. *@inheritDoc
  26932. */
  26933. __proto._getType=function(){
  26934. return ShurikenParticleSystem._type;
  26935. }
  26936. /**
  26937. *@inheritDoc
  26938. */
  26939. __proto._prepareRender=function(state){
  26940. this._updateEmission();
  26941. if (this._firstNewElement !=this._firstFreeElement)
  26942. this.addNewParticlesToVertexBuffer();
  26943. this._drawCounter++;
  26944. if (this._firstActiveElement !=this._firstFreeElement)
  26945. return true;
  26946. else
  26947. return false;
  26948. }
  26949. /**
  26950. *@private
  26951. */
  26952. __proto._render=function(state){
  26953. this._bufferState.bind();
  26954. var indexCount=0;
  26955. var gl=LayaGL.instance;
  26956. if (this._firstActiveElement < this._firstFreeElement){
  26957. indexCount=(this._firstFreeElement-this._firstActiveElement)*this._indexStride;
  26958. gl.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,indexCount,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,2 *this._firstActiveElement *this._indexStride);
  26959. Stat.trianglesFaces+=indexCount / 3;
  26960. Stat.renderBatches++;
  26961. }else {
  26962. indexCount=(this._bufferMaxParticles-this._firstActiveElement)*this._indexStride;
  26963. gl.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,indexCount,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,2 *this._firstActiveElement *this._indexStride);
  26964. Stat.trianglesFaces+=indexCount / 3;
  26965. Stat.renderBatches++;
  26966. if (this._firstFreeElement > 0){
  26967. indexCount=this._firstFreeElement *this._indexStride;
  26968. gl.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,indexCount,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,0);
  26969. Stat.trianglesFaces+=indexCount / 3;
  26970. Stat.renderBatches++;
  26971. }
  26972. }
  26973. }
  26974. /**
  26975. *开始发射粒子。
  26976. */
  26977. __proto.play=function(){
  26978. this._burstsIndex=0;
  26979. this._isEmitting=true;
  26980. this._isPlaying=true;
  26981. this._isPaused=false;
  26982. this._emissionTime=0;
  26983. this._totalDelayTime=0;
  26984. if (!this.autoRandomSeed){
  26985. for (var i=0,n=this._randomSeeds.length;i < n;i++)
  26986. this._randomSeeds[i]=this.randomSeed[0]+ShurikenParticleSystem._RANDOMOFFSET[i];
  26987. }
  26988. switch (this.startDelayType){
  26989. case 0:
  26990. this._playStartDelay=this.startDelay;
  26991. break ;
  26992. case 1:
  26993. if (this.autoRandomSeed){
  26994. this._playStartDelay=MathUtil.lerp(this.startDelayMin,this.startDelayMax,Math.random());
  26995. }else {
  26996. this._rand.seed=this._randomSeeds[2];
  26997. this._playStartDelay=MathUtil.lerp(this.startDelayMin,this.startDelayMax,this._rand.getFloat());
  26998. this._randomSeeds[2]=this._rand.seed;
  26999. }
  27000. break ;
  27001. default :
  27002. throw new Error("Utils3D: startDelayType is invalid.");
  27003. }
  27004. this._frameRateTime=this._currentTime+this._playStartDelay;
  27005. this._startUpdateLoopCount=Stat.loopCount;
  27006. }
  27007. /**
  27008. *暂停发射粒子。
  27009. */
  27010. __proto.pause=function(){
  27011. this._isPaused=true;
  27012. }
  27013. /**
  27014. *通过指定时间增加粒子播放进度,并暂停播放。
  27015. *@param time 进度时间.如果restart为true,粒子播放时间会归零后再更新进度。
  27016. *@param restart 是否重置播放状态。
  27017. */
  27018. __proto.simulate=function(time,restart){
  27019. (restart===void 0)&& (restart=true);
  27020. this._simulateUpdate=true;
  27021. if (restart){
  27022. this._updateParticlesSimulationRestart(time);
  27023. }
  27024. else{
  27025. this._isPaused=false;
  27026. this._updateParticles(time);
  27027. }
  27028. this.pause();
  27029. }
  27030. /**
  27031. *停止发射粒子。
  27032. */
  27033. __proto.stop=function(){
  27034. this._burstsIndex=0;
  27035. this._isEmitting=false;
  27036. this._emissionTime=0;
  27037. }
  27038. /**
  27039. *克隆。
  27040. *@param destObject 克隆源。
  27041. */
  27042. __proto.cloneTo=function(destObject){
  27043. var dest=destObject;
  27044. dest.duration=this.duration;
  27045. dest.looping=this.looping;
  27046. dest.prewarm=this.prewarm;
  27047. dest.startDelayType=this.startDelayType;
  27048. dest.startDelay=this.startDelay;
  27049. dest.startDelayMin=this.startDelayMin;
  27050. dest.startDelayMax=this.startDelayMax;
  27051. dest._maxStartLifetime=this._maxStartLifetime;
  27052. dest.startLifetimeType=this.startLifetimeType;
  27053. dest.startLifetimeConstant=this.startLifetimeConstant;
  27054. this.startLifeTimeGradient.cloneTo(dest.startLifeTimeGradient);
  27055. dest.startLifetimeConstantMin=this.startLifetimeConstantMin;
  27056. dest.startLifetimeConstantMax=this.startLifetimeConstantMax;
  27057. this.startLifeTimeGradientMin.cloneTo(dest.startLifeTimeGradientMin);
  27058. this.startLifeTimeGradientMax.cloneTo(dest.startLifeTimeGradientMax);
  27059. dest.startSpeedType=this.startSpeedType;
  27060. dest.startSpeedConstant=this.startSpeedConstant;
  27061. dest.startSpeedConstantMin=this.startSpeedConstantMin;
  27062. dest.startSpeedConstantMax=this.startSpeedConstantMax;
  27063. dest.threeDStartSize=this.threeDStartSize;
  27064. dest.startSizeType=this.startSizeType;
  27065. dest.startSizeConstant=this.startSizeConstant;
  27066. this.startSizeConstantSeparate.cloneTo(dest.startSizeConstantSeparate);
  27067. dest.startSizeConstantMin=this.startSizeConstantMin;
  27068. dest.startSizeConstantMax=this.startSizeConstantMax;
  27069. this.startSizeConstantMinSeparate.cloneTo(dest.startSizeConstantMinSeparate);
  27070. this.startSizeConstantMaxSeparate.cloneTo(dest.startSizeConstantMaxSeparate);
  27071. dest.threeDStartRotation=this.threeDStartRotation;
  27072. dest.startRotationType=this.startRotationType;
  27073. dest.startRotationConstant=this.startRotationConstant;
  27074. this.startRotationConstantSeparate.cloneTo(dest.startRotationConstantSeparate);
  27075. dest.startRotationConstantMin=this.startRotationConstantMin;
  27076. dest.startRotationConstantMax=this.startRotationConstantMax;
  27077. this.startRotationConstantMinSeparate.cloneTo(dest.startRotationConstantMinSeparate);
  27078. this.startRotationConstantMaxSeparate.cloneTo(dest.startRotationConstantMaxSeparate);
  27079. dest.randomizeRotationDirection=this.randomizeRotationDirection;
  27080. dest.startColorType=this.startColorType;
  27081. this.startColorConstant.cloneTo(dest.startColorConstant);
  27082. this.startColorConstantMin.cloneTo(dest.startColorConstantMin);
  27083. this.startColorConstantMax.cloneTo(dest.startColorConstantMax);
  27084. dest.gravityModifier=this.gravityModifier;
  27085. dest.simulationSpace=this.simulationSpace;
  27086. dest.scaleMode=this.scaleMode;
  27087. dest.playOnAwake=this.playOnAwake;
  27088. dest.maxParticles=this.maxParticles;
  27089. (this._emission)&& (dest._emission=this._emission.clone());
  27090. (this.shape)&& (dest.shape=this.shape.clone());
  27091. (this.velocityOverLifetime)&& (dest.velocityOverLifetime=this.velocityOverLifetime.clone());
  27092. (this.colorOverLifetime)&& (dest.colorOverLifetime=this.colorOverLifetime.clone());
  27093. (this.sizeOverLifetime)&& (dest.sizeOverLifetime=this.sizeOverLifetime.clone());
  27094. (this.rotationOverLifetime)&& (dest.rotationOverLifetime=this.rotationOverLifetime.clone());
  27095. (this.textureSheetAnimation)&& (dest.textureSheetAnimation=this.textureSheetAnimation.clone());
  27096. dest.isPerformanceMode=this.isPerformanceMode;
  27097. dest._isEmitting=this._isEmitting;
  27098. dest._isPlaying=this._isPlaying;
  27099. dest._isPaused=this._isPaused;
  27100. dest._playStartDelay=this._playStartDelay;
  27101. dest._frameRateTime=this._frameRateTime;
  27102. dest._emissionTime=this._emissionTime;
  27103. dest._totalDelayTime=this._totalDelayTime;
  27104. dest._burstsIndex=this._burstsIndex;
  27105. }
  27106. /**
  27107. *克隆。
  27108. *@return 克隆副本。
  27109. */
  27110. __proto.clone=function(){
  27111. var dest=/*__JS__ */new this.constructor();
  27112. this.cloneTo(dest);
  27113. return dest;
  27114. }
  27115. /**设置最大粒子数,注意:谨慎修改此属性,有性能损耗。*/
  27116. /**获取最大粒子数。*/
  27117. __getset(0,__proto,'maxParticles',function(){
  27118. return this._bufferMaxParticles-1;
  27119. },function(value){
  27120. var newMaxParticles=value+1;
  27121. if (newMaxParticles!==this._bufferMaxParticles){
  27122. this._bufferMaxParticles=newMaxParticles;
  27123. this._initBufferDatas();
  27124. }
  27125. });
  27126. /**
  27127. *是否正在发射。
  27128. */
  27129. __getset(0,__proto,'isEmitting',function(){
  27130. return this._isEmitting;
  27131. });
  27132. /**
  27133. *是否存活。
  27134. */
  27135. __getset(0,__proto,'isAlive',function(){
  27136. if (this._isPlaying || this.aliveParticleCount > 0)
  27137. return true;
  27138. return false;
  27139. });
  27140. /**
  27141. *设置形状。
  27142. */
  27143. /**
  27144. *获取形状。
  27145. */
  27146. __getset(0,__proto,'shape',function(){
  27147. return this._shape;
  27148. },function(value){
  27149. if (this._shape!==value){
  27150. if (value&&value.enable)
  27151. this._owner._render._defineDatas.add(ShuriKenParticle3D.SHADERDEFINE_SHAPE);
  27152. else
  27153. this._owner._render._defineDatas.remove(ShuriKenParticle3D.SHADERDEFINE_SHAPE);
  27154. this._shape=value;
  27155. }
  27156. });
  27157. /**
  27158. *设置生命周期旋转,注意:如修改该值的某些属性,需重新赋值此属性才可生效。
  27159. *@param value 生命周期旋转。
  27160. */
  27161. /**
  27162. *获取生命周期旋转,注意:如修改该值的某些属性,需重新赋值此属性才可生效。
  27163. *@return 生命周期旋转。
  27164. */
  27165. __getset(0,__proto,'rotationOverLifetime',function(){
  27166. return this._rotationOverLifetime;
  27167. },function(value){
  27168. var defDat=this._owner._render._defineDatas;
  27169. var shaDat=this._owner._render._shaderValues;
  27170. if (value){
  27171. var rotation=value.angularVelocity;
  27172. if (!rotation)
  27173. return;
  27174. var rotationSeparate=rotation.separateAxes;
  27175. var rotationType=rotation.type;
  27176. if (value.enbale){
  27177. if (rotationSeparate)
  27178. defDat.add(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE);
  27179. else
  27180. defDat.add(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIME);
  27181. switch (rotationType){
  27182. case 0:
  27183. defDat.add(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT);
  27184. break ;
  27185. case 1:
  27186. defDat.add(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE);
  27187. break ;
  27188. case 2:
  27189. defDat.add(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS);
  27190. break ;
  27191. case 3:
  27192. defDat.add(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES);
  27193. break ;
  27194. }
  27195. }else {
  27196. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIME);
  27197. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE);
  27198. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT);
  27199. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE);
  27200. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS);
  27201. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES);
  27202. }
  27203. switch (rotationType){
  27204. case 0:
  27205. if (rotationSeparate){
  27206. shaDat.setVector3(ShuriKenParticle3D.ROLANGULARVELOCITYCONSTSEPRARATE,rotation.constantSeparate);
  27207. }else {
  27208. shaDat.setNumber(ShuriKenParticle3D.ROLANGULARVELOCITYCONST,rotation.constant);
  27209. }
  27210. break ;
  27211. case 1:
  27212. if (rotationSeparate){
  27213. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTX,rotation.gradientX._elements);
  27214. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTY,rotation.gradientY._elements);
  27215. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTZ,rotation.gradientZ._elements);
  27216. }else {
  27217. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENT,rotation.gradient._elements);
  27218. }
  27219. break ;
  27220. case 2:
  27221. if (rotationSeparate){
  27222. shaDat.setVector3(ShuriKenParticle3D.ROLANGULARVELOCITYCONSTSEPRARATE,rotation.constantMinSeparate);
  27223. shaDat.setVector3(ShuriKenParticle3D.ROLANGULARVELOCITYCONSTMAXSEPRARATE,rotation.constantMaxSeparate);
  27224. }else {
  27225. shaDat.setNumber(ShuriKenParticle3D.ROLANGULARVELOCITYCONST,rotation.constantMin);
  27226. shaDat.setNumber(ShuriKenParticle3D.ROLANGULARVELOCITYCONSTMAX,rotation.constantMax);
  27227. }
  27228. break ;
  27229. case 3:
  27230. if (rotationSeparate){
  27231. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTX,rotation.gradientXMin._elements);
  27232. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTXMAX,rotation.gradientXMax._elements);
  27233. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTY,rotation.gradientYMin._elements);
  27234. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTYMAX,rotation.gradientYMax._elements);
  27235. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTZ,rotation.gradientZMin._elements);
  27236. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTZMAX,rotation.gradientZMax._elements);
  27237. }else {
  27238. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENT,rotation.gradientMin._elements);
  27239. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTMAX,rotation.gradientMax._elements);
  27240. }
  27241. break ;
  27242. }
  27243. }else {
  27244. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIME);
  27245. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE);
  27246. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT);
  27247. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE);
  27248. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS);
  27249. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES);
  27250. shaDat.setVector(ShuriKenParticle3D.ROLANGULARVELOCITYCONSTSEPRARATE,null);
  27251. shaDat.setVector(ShuriKenParticle3D.ROLANGULARVELOCITYCONSTMAXSEPRARATE,null);
  27252. shaDat.setNumber(ShuriKenParticle3D.ROLANGULARVELOCITYCONST,undefined);
  27253. shaDat.setNumber(ShuriKenParticle3D.ROLANGULARVELOCITYCONSTMAX,undefined);
  27254. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTX,null);
  27255. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTXMAX,null);
  27256. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTY,null);
  27257. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTYMAX,null);
  27258. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTZ,null);
  27259. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTZMAX,null);
  27260. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTWMAX,null);
  27261. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENT,null);
  27262. shaDat.setBuffer(ShuriKenParticle3D.ROLANGULARVELOCITYGRADIENTMAX,null);
  27263. }
  27264. this._rotationOverLifetime=value;
  27265. });
  27266. /**
  27267. *获取发射器。
  27268. */
  27269. __getset(0,__proto,'emission',function(){
  27270. return this._emission;
  27271. });
  27272. /**
  27273. *获取一次循环内的累计时间。
  27274. *@return 一次循环内的累计时间。
  27275. */
  27276. __getset(0,__proto,'emissionTime',function(){
  27277. return this._emissionTime > this.duration ? this.duration :this._emissionTime;
  27278. });
  27279. /**
  27280. *粒子存活个数。
  27281. */
  27282. __getset(0,__proto,'aliveParticleCount',function(){
  27283. if (this._firstNewElement >=this._firstRetiredElement)
  27284. return this._firstNewElement-this._firstRetiredElement;
  27285. else
  27286. return this._bufferMaxParticles-this._firstRetiredElement+this._firstNewElement;
  27287. });
  27288. /**
  27289. *是否正在播放。
  27290. */
  27291. __getset(0,__proto,'isPlaying',function(){
  27292. return this._isPlaying;
  27293. });
  27294. /**
  27295. *是否已暂停。
  27296. */
  27297. __getset(0,__proto,'isPaused',function(){
  27298. return this._isPaused;
  27299. });
  27300. /**
  27301. *设置开始生命周期模式,0为固定时间,1为渐变时间,2为两个固定之间的随机插值,3为两个渐变时间的随机插值。
  27302. */
  27303. /**
  27304. *获取开始生命周期模式,0为固定时间,1为渐变时间,2为两个固定之间的随机插值,3为两个渐变时间的随机插值。
  27305. */
  27306. __getset(0,__proto,'startLifetimeType',function(){
  27307. return this._startLifetimeType;
  27308. },function(value){
  27309. var i=0,n=0;
  27310. switch (this.startLifetimeType){
  27311. case 0:
  27312. this._maxStartLifetime=this.startLifetimeConstant;
  27313. break ;
  27314. case 1:
  27315. this._maxStartLifetime=-Number.MAX_VALUE;
  27316. var startLifeTimeGradient=startLifeTimeGradient;
  27317. for (i=0,n=startLifeTimeGradient.gradientCount;i < n;i++)
  27318. this._maxStartLifetime=Math.max(this._maxStartLifetime,startLifeTimeGradient.getValueByIndex(i));
  27319. break ;
  27320. case 2:
  27321. this._maxStartLifetime=Math.max(this.startLifetimeConstantMin,this.startLifetimeConstantMax);
  27322. break ;
  27323. case 3:
  27324. this._maxStartLifetime=-Number.MAX_VALUE;
  27325. var startLifeTimeGradientMin=startLifeTimeGradientMin;
  27326. for (i=0,n=startLifeTimeGradientMin.gradientCount;i < n;i++)
  27327. this._maxStartLifetime=Math.max(this._maxStartLifetime,startLifeTimeGradientMin.getValueByIndex(i));
  27328. var startLifeTimeGradientMax=startLifeTimeGradientMax;
  27329. for (i=0,n=startLifeTimeGradientMax.gradientCount;i < n;i++)
  27330. this._maxStartLifetime=Math.max(this._maxStartLifetime,startLifeTimeGradientMax.getValueByIndex(i));
  27331. break ;
  27332. }
  27333. this._startLifetimeType=value;
  27334. });
  27335. /**
  27336. *设置开始生命周期,0模式,单位为秒。
  27337. */
  27338. /**
  27339. *获取开始生命周期,0模式,单位为秒。
  27340. */
  27341. __getset(0,__proto,'startLifetimeConstant',function(){
  27342. return this._startLifetimeConstant;
  27343. },function(value){
  27344. if(this._startLifetimeType===0)
  27345. this._maxStartLifetime=value;
  27346. this._startLifetimeConstant=value;
  27347. });
  27348. /**
  27349. *设置最小开始生命周期,2模式,单位为秒。
  27350. */
  27351. /**
  27352. *获取最小开始生命周期,2模式,单位为秒。
  27353. */
  27354. __getset(0,__proto,'startLifetimeConstantMin',function(){
  27355. return this._startLifetimeConstantMin;
  27356. },function(value){
  27357. if (this._startLifetimeType===2)
  27358. this._maxStartLifetime=Math.max(value,this._startLifetimeConstantMax);
  27359. this._startLifetimeConstantMin=value;
  27360. });
  27361. /**
  27362. *设置开始渐变生命周期,1模式,单位为秒。
  27363. */
  27364. /**
  27365. *获取开始渐变生命周期,1模式,单位为秒。
  27366. */
  27367. __getset(0,__proto,'startLifeTimeGradient',function(){
  27368. return this._startLifeTimeGradient;
  27369. },function(value){
  27370. if (this._startLifetimeType===1){
  27371. this._maxStartLifetime=-Number.MAX_VALUE;
  27372. for (var i=0,n=value.gradientCount;i < n;i++)
  27373. this._maxStartLifetime=Math.max(this._maxStartLifetime,value.getValueByIndex(i));
  27374. }
  27375. this._startLifeTimeGradient=value;
  27376. });
  27377. /**
  27378. *设置最大开始生命周期,2模式,单位为秒。
  27379. */
  27380. /**
  27381. *获取最大开始生命周期,2模式,单位为秒。
  27382. */
  27383. __getset(0,__proto,'startLifetimeConstantMax',function(){
  27384. return this._startLifetimeConstantMax;
  27385. },function(value){
  27386. if (this._startLifetimeType===2)
  27387. this._maxStartLifetime=Math.max(this._startLifetimeConstantMin,value);
  27388. this._startLifetimeConstantMax=value;
  27389. });
  27390. /**
  27391. *设置开始渐变最小生命周期,3模式,单位为秒。
  27392. */
  27393. /**
  27394. *获取开始渐变最小生命周期,3模式,单位为秒。
  27395. */
  27396. __getset(0,__proto,'startLifeTimeGradientMin',function(){
  27397. return this._startLifeTimeGradientMin;
  27398. },function(value){
  27399. if (this._startLifetimeType===3){
  27400. var i=0,n=0;
  27401. this._maxStartLifetime=-Number.MAX_VALUE;
  27402. for (i=0,n=value.gradientCount;i < n;i++)
  27403. this._maxStartLifetime=Math.max(this._maxStartLifetime,value.getValueByIndex(i));
  27404. for (i=0,n=this._startLifeTimeGradientMax.gradientCount;i < n;i++)
  27405. this._maxStartLifetime=Math.max(this._maxStartLifetime,this._startLifeTimeGradientMax.getValueByIndex(i));
  27406. }
  27407. this._startLifeTimeGradientMin=value;
  27408. });
  27409. /**
  27410. *设置开始渐变最大生命周期,3模式,单位为秒。
  27411. */
  27412. /**
  27413. *获取开始渐变最大生命周期,3模式,单位为秒。
  27414. */
  27415. __getset(0,__proto,'startLifeTimeGradientMax',function(){
  27416. return this._startLifeTimeGradientMax;
  27417. },function(value){
  27418. if (this._startLifetimeType===3){
  27419. var i=0,n=0;
  27420. this._maxStartLifetime=-Number.MAX_VALUE;
  27421. for (i=0,n=this._startLifeTimeGradientMin.gradientCount;i < n;i++)
  27422. this._maxStartLifetime=Math.max(this._maxStartLifetime,this._startLifeTimeGradientMin.getValueByIndex(i));
  27423. for (i=0,n=value.gradientCount;i < n;i++)
  27424. this._maxStartLifetime=Math.max(this._maxStartLifetime,value.getValueByIndex(i));
  27425. }
  27426. this._startLifeTimeGradientMax=value;
  27427. });
  27428. /**
  27429. *设置生命周期速度,注意:如修改该值的某些属性,需重新赋值此属性才可生效。
  27430. *@param value 生命周期速度.
  27431. */
  27432. /**
  27433. *获取生命周期速度,注意:如修改该值的某些属性,需重新赋值此属性才可生效。
  27434. *@return 生命周期速度.
  27435. */
  27436. __getset(0,__proto,'velocityOverLifetime',function(){
  27437. return this._velocityOverLifetime;
  27438. },function(value){
  27439. var defDat=this._owner._render._defineDatas;
  27440. var shaDat=this._owner._render._shaderValues;
  27441. if (value){
  27442. var velocity=value.velocity;
  27443. var velocityType=velocity.type;
  27444. if (value.enbale){
  27445. switch (velocityType){
  27446. case 0:
  27447. defDat.add(ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMECONSTANT);
  27448. break ;
  27449. case 1:
  27450. defDat.add(ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMECURVE);
  27451. break ;
  27452. case 2:
  27453. defDat.add(ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCONSTANT);
  27454. break ;
  27455. case 3:
  27456. defDat.add(ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCURVE);
  27457. break ;
  27458. }
  27459. }else {
  27460. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMECONSTANT);
  27461. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMECURVE);
  27462. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCONSTANT);
  27463. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCURVE);
  27464. }
  27465. switch (velocityType){
  27466. case 0:
  27467. shaDat.setVector3(ShuriKenParticle3D.VOLVELOCITYCONST,velocity.constant);
  27468. break ;
  27469. case 1:
  27470. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTX,velocity.gradientX._elements);
  27471. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTY,velocity.gradientY._elements);
  27472. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTZ,velocity.gradientZ._elements);
  27473. break ;
  27474. case 2:
  27475. shaDat.setVector3(ShuriKenParticle3D.VOLVELOCITYCONST,velocity.constantMin);
  27476. shaDat.setVector3(ShuriKenParticle3D.VOLVELOCITYCONSTMAX,velocity.constantMax);
  27477. break ;
  27478. case 3:
  27479. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTX,velocity.gradientXMin._elements);
  27480. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTXMAX,velocity.gradientXMax._elements);
  27481. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTY,velocity.gradientYMin._elements);
  27482. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTYMAX,velocity.gradientYMax._elements);
  27483. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTZ,velocity.gradientZMin._elements);
  27484. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTZMAX,velocity.gradientZMax._elements);
  27485. break ;
  27486. }
  27487. shaDat.setInt(ShuriKenParticle3D.VOLSPACETYPE,value.space);
  27488. }else {
  27489. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMECONSTANT);
  27490. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMECURVE);
  27491. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCONSTANT);
  27492. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCURVE);
  27493. shaDat.setVector(ShuriKenParticle3D.VOLVELOCITYCONST,null);
  27494. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTX,null);
  27495. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTY,null);
  27496. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTZ,null);
  27497. shaDat.setVector(ShuriKenParticle3D.VOLVELOCITYCONST,null);
  27498. shaDat.setVector(ShuriKenParticle3D.VOLVELOCITYCONSTMAX,null);
  27499. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTX,null);
  27500. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTXMAX,null);
  27501. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTY,null);
  27502. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTYMAX,null);
  27503. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTZ,null);
  27504. shaDat.setBuffer(ShuriKenParticle3D.VOLVELOCITYGRADIENTZMAX,null);
  27505. shaDat.setInt(ShuriKenParticle3D.VOLSPACETYPE,undefined);
  27506. }
  27507. this._velocityOverLifetime=value;
  27508. });
  27509. /**
  27510. *设置生命周期颜色,注意:如修改该值的某些属性,需重新赋值此属性才可生效。
  27511. *@param value 生命周期颜色
  27512. */
  27513. /**
  27514. *获取生命周期颜色,注意:如修改该值的某些属性,需重新赋值此属性才可生效。
  27515. *@return 生命周期颜色
  27516. */
  27517. __getset(0,__proto,'colorOverLifetime',function(){
  27518. return this._colorOverLifetime;
  27519. },function(value){
  27520. var defDat=this._owner._render._defineDatas;
  27521. var shaDat=this._owner._render._shaderValues;
  27522. if (value){
  27523. var color=value.color;
  27524. if (value.enbale){
  27525. switch (color.type){
  27526. case 1:
  27527. defDat.add(ShuriKenParticle3D.SHADERDEFINE_COLOROVERLIFETIME);
  27528. break ;
  27529. case 3:
  27530. defDat.add(ShuriKenParticle3D.SHADERDEFINE_RANDOMCOLOROVERLIFETIME);
  27531. break ;
  27532. }
  27533. }else {
  27534. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_COLOROVERLIFETIME);
  27535. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_RANDOMCOLOROVERLIFETIME);
  27536. }
  27537. switch (color.type){
  27538. case 1:;
  27539. var gradientColor=color.gradient;
  27540. shaDat.setBuffer(ShuriKenParticle3D.COLOROVERLIFEGRADIENTALPHAS,gradientColor._alphaElements);
  27541. shaDat.setBuffer(ShuriKenParticle3D.COLOROVERLIFEGRADIENTCOLORS,gradientColor._rgbElements);
  27542. break ;
  27543. case 3:;
  27544. var minGradientColor=color.gradientMin;
  27545. var maxGradientColor=color.gradientMax;
  27546. shaDat.setBuffer(ShuriKenParticle3D.COLOROVERLIFEGRADIENTALPHAS,minGradientColor._alphaElements);
  27547. shaDat.setBuffer(ShuriKenParticle3D.COLOROVERLIFEGRADIENTCOLORS,minGradientColor._rgbElements);
  27548. shaDat.setBuffer(ShuriKenParticle3D.MAXCOLOROVERLIFEGRADIENTALPHAS,maxGradientColor._alphaElements);
  27549. shaDat.setBuffer(ShuriKenParticle3D.MAXCOLOROVERLIFEGRADIENTCOLORS,maxGradientColor._rgbElements);
  27550. break ;
  27551. }
  27552. }else {
  27553. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_COLOROVERLIFETIME);
  27554. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_RANDOMCOLOROVERLIFETIME);
  27555. shaDat.setBuffer(ShuriKenParticle3D.COLOROVERLIFEGRADIENTALPHAS,gradientColor._alphaElements);
  27556. shaDat.setBuffer(ShuriKenParticle3D.COLOROVERLIFEGRADIENTCOLORS,gradientColor._rgbElements);
  27557. shaDat.setBuffer(ShuriKenParticle3D.COLOROVERLIFEGRADIENTALPHAS,minGradientColor._alphaElements);
  27558. shaDat.setBuffer(ShuriKenParticle3D.COLOROVERLIFEGRADIENTCOLORS,minGradientColor._rgbElements);
  27559. shaDat.setBuffer(ShuriKenParticle3D.MAXCOLOROVERLIFEGRADIENTALPHAS,maxGradientColor._alphaElements);
  27560. shaDat.setBuffer(ShuriKenParticle3D.MAXCOLOROVERLIFEGRADIENTCOLORS,maxGradientColor._rgbElements);
  27561. }
  27562. this._colorOverLifetime=value;
  27563. });
  27564. /**
  27565. *设置生命周期尺寸,注意:如修改该值的某些属性,需重新赋值此属性才可生效。
  27566. *@param value 生命周期尺寸
  27567. */
  27568. /**
  27569. *获取生命周期尺寸,注意:如修改该值的某些属性,需重新赋值此属性才可生效。
  27570. *@return 生命周期尺寸
  27571. */
  27572. __getset(0,__proto,'sizeOverLifetime',function(){
  27573. return this._sizeOverLifetime;
  27574. },function(value){
  27575. var defDat=this._owner._render._defineDatas;
  27576. var shaDat=this._owner._render._shaderValues;
  27577. if (value){
  27578. var size=value.size;
  27579. var sizeSeparate=size.separateAxes;
  27580. var sizeType=size.type;
  27581. if (value.enbale){
  27582. switch (sizeType){
  27583. case 0:
  27584. if (sizeSeparate)
  27585. defDat.add(ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMECURVESEPERATE);
  27586. else
  27587. defDat.add(ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMECURVE);
  27588. break ;
  27589. case 2:
  27590. if (sizeSeparate)
  27591. defDat.add(ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVESSEPERATE);
  27592. else
  27593. defDat.add(ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVES);
  27594. break ;
  27595. }
  27596. }else {
  27597. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMECURVE);
  27598. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMECURVESEPERATE);
  27599. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVES);
  27600. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVESSEPERATE);
  27601. }
  27602. switch (sizeType){
  27603. case 0:
  27604. if (sizeSeparate){
  27605. shaDat.setBuffer(ShuriKenParticle3D.SOLSIZEGRADIENTX,size.gradientX._elements);
  27606. shaDat.setBuffer(ShuriKenParticle3D.SOLSIZEGRADIENTY,size.gradientY._elements);
  27607. shaDat.setBuffer(ShuriKenParticle3D.SOLSizeGradientZ,size.gradientZ._elements);
  27608. }else {
  27609. shaDat.setBuffer(ShuriKenParticle3D.SOLSIZEGRADIENT,size.gradient._elements);
  27610. }
  27611. break ;
  27612. case 2:
  27613. if (sizeSeparate){
  27614. shaDat.setBuffer(ShuriKenParticle3D.SOLSIZEGRADIENTX,size.gradientXMin._elements);
  27615. shaDat.setBuffer(ShuriKenParticle3D.SOLSIZEGRADIENTXMAX,size.gradientXMax._elements);
  27616. shaDat.setBuffer(ShuriKenParticle3D.SOLSIZEGRADIENTY,size.gradientYMin._elements);
  27617. shaDat.setBuffer(ShuriKenParticle3D.SOLSIZEGRADIENTYMAX,size.gradientYMax._elements);
  27618. shaDat.setBuffer(ShuriKenParticle3D.SOLSizeGradientZ,size.gradientZMin._elements);
  27619. shaDat.setBuffer(ShuriKenParticle3D.SOLSizeGradientZMAX,size.gradientZMax._elements);
  27620. }else {
  27621. shaDat.setBuffer(ShuriKenParticle3D.SOLSIZEGRADIENT,size.gradientMin._elements);
  27622. shaDat.setBuffer(ShuriKenParticle3D.SOLSizeGradientMax,size.gradientMax._elements);
  27623. }
  27624. break ;
  27625. }
  27626. }else {
  27627. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMECURVE);
  27628. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMECURVESEPERATE);
  27629. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVES);
  27630. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVESSEPERATE);
  27631. shaDat.setBuffer(ShuriKenParticle3D.SOLSIZEGRADIENTX,null);
  27632. shaDat.setBuffer(ShuriKenParticle3D.SOLSIZEGRADIENTXMAX,null);
  27633. shaDat.setBuffer(ShuriKenParticle3D.SOLSIZEGRADIENTY,null);
  27634. shaDat.setBuffer(ShuriKenParticle3D.SOLSIZEGRADIENTYMAX,null);
  27635. shaDat.setBuffer(ShuriKenParticle3D.SOLSizeGradientZ,null);
  27636. shaDat.setBuffer(ShuriKenParticle3D.SOLSizeGradientZMAX,null);
  27637. shaDat.setBuffer(ShuriKenParticle3D.SOLSIZEGRADIENT,null);
  27638. shaDat.setBuffer(ShuriKenParticle3D.SOLSizeGradientMax,null);
  27639. }
  27640. this._sizeOverLifetime=value;
  27641. });
  27642. /**
  27643. *设置生命周期纹理动画,注意:如修改该值的某些属性,需重新赋值此属性才可生效。
  27644. *@param value 生命周期纹理动画。
  27645. */
  27646. /**
  27647. *获取生命周期纹理动画,注意:如修改该值的某些属性,需重新赋值此属性才可生效。
  27648. *@return 生命周期纹理动画。
  27649. */
  27650. __getset(0,__proto,'textureSheetAnimation',function(){
  27651. return this._textureSheetAnimation;
  27652. },function(value){
  27653. var defDat=this._owner._render._defineDatas;
  27654. var shaDat=this._owner._render._shaderValues;
  27655. if (value){
  27656. var frameOverTime=value.frame;
  27657. var textureAniType=frameOverTime.type;
  27658. if (value.enable){
  27659. switch (textureAniType){
  27660. case 1:
  27661. defDat.add(ShuriKenParticle3D.SHADERDEFINE_TEXTURESHEETANIMATIONCURVE);
  27662. break ;
  27663. case 3:
  27664. defDat.add(ShuriKenParticle3D.SHADERDEFINE_TEXTURESHEETANIMATIONRANDOMCURVE);
  27665. break ;
  27666. }
  27667. }else {
  27668. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_TEXTURESHEETANIMATIONCURVE);
  27669. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_TEXTURESHEETANIMATIONRANDOMCURVE);
  27670. }
  27671. if (textureAniType===1 || textureAniType===3){
  27672. shaDat.setNumber(ShuriKenParticle3D.TEXTURESHEETANIMATIONCYCLES,value.cycles);
  27673. var title=value.tiles;
  27674. var _uvLengthE=this._uvLength;
  27675. _uvLengthE.x=1.0 / title.x;
  27676. _uvLengthE.y=1.0 / title.y;
  27677. shaDat.setVector2(ShuriKenParticle3D.TEXTURESHEETANIMATIONSUBUVLENGTH,this._uvLength);
  27678. }
  27679. switch (textureAniType){
  27680. case 1:
  27681. shaDat.setBuffer(ShuriKenParticle3D.TEXTURESHEETANIMATIONGRADIENTUVS,frameOverTime.frameOverTimeData._elements);
  27682. break ;
  27683. case 3:
  27684. shaDat.setBuffer(ShuriKenParticle3D.TEXTURESHEETANIMATIONGRADIENTUVS,frameOverTime.frameOverTimeDataMin._elements);
  27685. shaDat.setBuffer(ShuriKenParticle3D.TEXTURESHEETANIMATIONGRADIENTMAXUVS,frameOverTime.frameOverTimeDataMax._elements);
  27686. break ;
  27687. }
  27688. }else {
  27689. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_TEXTURESHEETANIMATIONCURVE);
  27690. defDat.remove(ShuriKenParticle3D.SHADERDEFINE_TEXTURESHEETANIMATIONRANDOMCURVE);
  27691. shaDat.setNumber(ShuriKenParticle3D.TEXTURESHEETANIMATIONCYCLES,undefined);
  27692. shaDat.setVector(ShuriKenParticle3D.TEXTURESHEETANIMATIONSUBUVLENGTH,null);
  27693. shaDat.setBuffer(ShuriKenParticle3D.TEXTURESHEETANIMATIONGRADIENTUVS,null);
  27694. shaDat.setBuffer(ShuriKenParticle3D.TEXTURESHEETANIMATIONGRADIENTMAXUVS,null);
  27695. }
  27696. this._textureSheetAnimation=value;
  27697. });
  27698. ShurikenParticleSystem.halfKSqrtOf2=1.42 *0.5;
  27699. __static(ShurikenParticleSystem,
  27700. ['_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++;}
  27701. ]);
  27702. return ShurikenParticleSystem;
  27703. })(GeometryElement)
  27704. /**
  27705. *@private
  27706. *<code>SetShaderDataTextureCMD</code> 类用于创建设置渲染目标指令。
  27707. */
  27708. //class laya.d3.core.render.command.SetShaderDataTextureCMD extends laya.d3.core.render.command.Command
  27709. var SetShaderDataTextureCMD=(function(_super){
  27710. function SetShaderDataTextureCMD(){
  27711. /**@private */
  27712. this._shaderData=null;
  27713. /**@private */
  27714. this._nameID=0;
  27715. /**@private */
  27716. this._texture=null;
  27717. SetShaderDataTextureCMD.__super.call(this);
  27718. }
  27719. __class(SetShaderDataTextureCMD,'laya.d3.core.render.command.SetShaderDataTextureCMD',_super);
  27720. var __proto=SetShaderDataTextureCMD.prototype;
  27721. /**
  27722. *@inheritDoc
  27723. */
  27724. __proto.run=function(){
  27725. this._shaderData.setTexture(this._nameID,this._texture);
  27726. }
  27727. /**
  27728. *@inheritDoc
  27729. */
  27730. __proto.recover=function(){
  27731. SetShaderDataTextureCMD._pool.push(this);
  27732. this._shaderData=null;
  27733. this._nameID=0;
  27734. this._texture=null;
  27735. }
  27736. SetShaderDataTextureCMD.create=function(shaderData,nameID,texture){
  27737. var cmd;
  27738. cmd=SetShaderDataTextureCMD._pool.length > 0 ? SetShaderDataTextureCMD._pool.pop():new SetShaderDataTextureCMD();
  27739. cmd._shaderData=shaderData;
  27740. cmd._nameID=nameID;
  27741. cmd._texture=texture;
  27742. return cmd;
  27743. }
  27744. SetShaderDataTextureCMD._pool=[];
  27745. return SetShaderDataTextureCMD;
  27746. })(Command)
  27747. /**
  27748. *<code>BoxShape</code> 类用于创建球形粒子形状。
  27749. */
  27750. //class laya.d3.core.particleShuriKen.module.shape.BoxShape extends laya.d3.core.particleShuriKen.module.shape.BaseShape
  27751. var BoxShape=(function(_super){
  27752. function BoxShape(){
  27753. /**发射器X轴长度。*/
  27754. this.x=NaN;
  27755. /**发射器Y轴长度。*/
  27756. this.y=NaN;
  27757. /**发射器Z轴长度。*/
  27758. this.z=NaN;
  27759. BoxShape.__super.call(this);
  27760. this.x=1.0;
  27761. this.y=1.0;
  27762. this.z=1.0;
  27763. this.randomDirection=false;
  27764. }
  27765. __class(BoxShape,'laya.d3.core.particleShuriKen.module.shape.BoxShape',_super);
  27766. var __proto=BoxShape.prototype;
  27767. /**
  27768. *@inheritDoc
  27769. */
  27770. __proto._getShapeBoundBox=function(boundBox){
  27771. var min=boundBox.min;
  27772. min.x=-this.x *0.5;
  27773. min.y=-this.y *0.5;
  27774. min.z=-this.z *0.5;
  27775. var max=boundBox.max;
  27776. max.x=this.x *0.5;
  27777. max.y=this.y *0.5;
  27778. max.z=this.z *0.5;
  27779. }
  27780. /**
  27781. *@inheritDoc
  27782. */
  27783. __proto._getSpeedBoundBox=function(boundBox){
  27784. var min=boundBox.min;
  27785. min.x=0.0;
  27786. min.y=0.0;
  27787. min.z=0.0;
  27788. var max=boundBox.max;
  27789. max.x=0.0;
  27790. max.y=1.0;
  27791. max.z=0.0;
  27792. }
  27793. /**
  27794. *用于生成粒子初始位置和方向。
  27795. *@param position 粒子位置。
  27796. *@param direction 粒子方向。
  27797. */
  27798. __proto.generatePositionAndDirection=function(position,direction,rand,randomSeeds){
  27799. if (rand){
  27800. rand.seed=randomSeeds[16];
  27801. ShapeUtils._randomPointInsideHalfUnitBox(position,rand);
  27802. randomSeeds[16]=rand.seed;
  27803. }else {
  27804. ShapeUtils._randomPointInsideHalfUnitBox(position);
  27805. }
  27806. position.x=this.x *position.x;
  27807. position.y=this.y *position.y;
  27808. position.z=this.z *position.z;
  27809. if (this.randomDirection){
  27810. if (rand){
  27811. rand.seed=randomSeeds[17];
  27812. ShapeUtils._randomPointUnitSphere(direction,rand);
  27813. randomSeeds[17]=rand.seed;
  27814. }else {
  27815. ShapeUtils._randomPointUnitSphere(direction);
  27816. }
  27817. }else {
  27818. direction.x=0.0;
  27819. direction.y=0.0;
  27820. direction.z=1.0;
  27821. }
  27822. }
  27823. __proto.cloneTo=function(destObject){
  27824. _super.prototype.cloneTo.call(this,destObject);
  27825. var destShape=destObject;
  27826. destShape.x=this.x;
  27827. destShape.y=this.y;
  27828. destShape.z=this.z;
  27829. destShape.randomDirection=this.randomDirection;
  27830. }
  27831. return BoxShape;
  27832. })(BaseShape)
  27833. /**
  27834. *@private
  27835. *<code>SubMeshDynamicBatch</code> 类用于网格动态合并。
  27836. */
  27837. //class laya.d3.graphics.SubMeshDynamicBatch extends laya.d3.core.GeometryElement
  27838. var SubMeshDynamicBatch=(function(_super){
  27839. function SubMeshDynamicBatch(){
  27840. /**@private */
  27841. this._vertices=null;
  27842. /**@private */
  27843. this._indices=null;
  27844. /**@private */
  27845. this._positionOffset=0;
  27846. /**@private */
  27847. this._normalOffset=0;
  27848. /**@private */
  27849. this._colorOffset=0;
  27850. /**@private */
  27851. this._uv0Offset=0;
  27852. /**@private */
  27853. this._uv1Offset=0;
  27854. /**@private */
  27855. this._sTangentOffset=0;
  27856. /**@private */
  27857. this._vertexBuffer=null;
  27858. /**@private */
  27859. this._indexBuffer=null;
  27860. SubMeshDynamicBatch.__super.call(this);
  27861. this._bufferState=new BufferState();
  27862. var maxVerDec=VertexMesh.getVertexDeclaration("POSITION,NORMAL,COLOR,UV,UV1,TANGENT");
  27863. var maxByteCount=maxVerDec.vertexStride *32000;
  27864. this._vertices=new Float32Array(maxByteCount / 4);
  27865. this._vertexBuffer=new VertexBuffer3D(maxByteCount,/*laya.webgl.WebGLContext.DYNAMIC_DRAW*/0x88E8);
  27866. this._indices=new Int16Array(/*CLASS CONST:laya.d3.graphics.SubMeshDynamicBatch.maxIndicesCount*/32000);
  27867. this._indexBuffer=new IndexBuffer3D(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",this._indices.length,/*laya.webgl.WebGLContext.DYNAMIC_DRAW*/0x88E8);
  27868. var memorySize=this._vertexBuffer._byteLength+this._indexBuffer._byteLength;
  27869. Resource._addMemory(memorySize,memorySize);
  27870. }
  27871. __class(SubMeshDynamicBatch,'laya.d3.graphics.SubMeshDynamicBatch',_super);
  27872. var __proto=SubMeshDynamicBatch.prototype;
  27873. /**
  27874. *@private
  27875. */
  27876. __proto._getBatchVertices=function(vertexDeclaration,batchVertices,batchOffset,transform,element,subMesh){
  27877. var vertexFloatCount=vertexDeclaration.vertexStride / 4;
  27878. var oriVertexes=subMesh._vertexBuffer.getData();
  27879. var lightmapScaleOffset=element.render.lightmapScaleOffset;
  27880. var multiSubMesh=element._dynamicMultiSubMesh;
  27881. var vertexCount=element._dynamicVertexCount;
  27882. element._computeWorldPositionsAndNormals(this._positionOffset,this._normalOffset,multiSubMesh,vertexCount);
  27883. var worldPositions=element._dynamicWorldPositions;
  27884. var worldNormals=element._dynamicWorldNormals;
  27885. var indices=subMesh._indices;
  27886. for (var i=0;i < vertexCount;i++){
  27887. var index=multiSubMesh ? indices[i] :i;
  27888. var oriOffset=index *vertexFloatCount;
  27889. var bakeOffset=(i+batchOffset)*vertexFloatCount;
  27890. var oriOff=i *3;
  27891. var bakOff=bakeOffset+this._positionOffset;
  27892. batchVertices[bakOff]=worldPositions[oriOff];
  27893. batchVertices[bakOff+1]=worldPositions[oriOff+1];
  27894. batchVertices[bakOff+2]=worldPositions[oriOff+2];
  27895. if (this._normalOffset!==-1){
  27896. bakOff=bakeOffset+this._normalOffset;
  27897. batchVertices[bakOff]=worldNormals[oriOff];
  27898. batchVertices[bakOff+1]=worldNormals[oriOff+1];
  27899. batchVertices[bakOff+2]=worldNormals[oriOff+2];
  27900. }
  27901. if (this._colorOffset!==-1){
  27902. bakOff=bakeOffset+this._colorOffset;
  27903. oriOff=oriOffset+this._colorOffset;
  27904. batchVertices[bakOff]=oriVertexes[oriOff];
  27905. batchVertices[bakOff+1]=oriVertexes[oriOff+1];
  27906. batchVertices[bakOff+2]=oriVertexes[oriOff+2];
  27907. batchVertices[bakOff+3]=oriVertexes[oriOff+3];
  27908. }
  27909. if (this._uv0Offset!==-1){
  27910. bakOff=bakeOffset+this._uv0Offset;
  27911. oriOff=oriOffset+this._uv0Offset;
  27912. batchVertices[bakOff]=oriVertexes[oriOff];
  27913. batchVertices[bakOff+1]=oriVertexes[oriOff+1];
  27914. }
  27915. if (this._sTangentOffset!==-1){
  27916. bakOff=bakeOffset+this._sTangentOffset;
  27917. oriOff=oriOffset+this._sTangentOffset;
  27918. batchVertices[bakOff]=oriVertexes[oriOff];
  27919. batchVertices[bakOff+1]=oriVertexes[oriOff+1];
  27920. batchVertices[bakOff+2]=oriVertexes[oriOff+2];
  27921. batchVertices[bakOff+3]=oriVertexes[oriOff+3];
  27922. bakOff=bakeOffset+this._sTangentOffset;
  27923. oriOff=oriOffset+this._sTangentOffset;
  27924. batchVertices[bakOff]=oriVertexes[oriOff];
  27925. batchVertices[bakOff+1]=oriVertexes[oriOff+1];
  27926. batchVertices[bakOff+2]=oriVertexes[oriOff+2];
  27927. batchVertices[bakOff+3]=oriVertexes[oriOff+3];
  27928. }
  27929. }
  27930. }
  27931. /**
  27932. *@private
  27933. */
  27934. __proto._getBatchIndices=function(batchIndices,batchIndexCount,batchVertexCount,transform,subMesh,multiSubMesh){
  27935. var subIndices=subMesh._indices;
  27936. var k=0,m=0,batchOffset=0;
  27937. var isInvert=transform._isFrontFaceInvert;
  27938. if (multiSubMesh){
  27939. if (isInvert){
  27940. for (k=0,m=subIndices.length;k < m;k+=3){
  27941. batchOffset=batchIndexCount+k;
  27942. var index=batchVertexCount+k;
  27943. batchIndices[batchOffset]=index;
  27944. batchIndices[batchOffset+1]=index+2;
  27945. batchIndices[batchOffset+2]=index+1;
  27946. }
  27947. }else {
  27948. for (k=m,m=subIndices.length;k < m;k+=3){
  27949. batchOffset=batchIndexCount+k;
  27950. index=batchVertexCount+k;
  27951. batchIndices[batchOffset]=index;
  27952. batchIndices[batchOffset+1]=index+1;
  27953. batchIndices[batchOffset+2]=index+2;
  27954. }
  27955. }
  27956. }else {
  27957. if (isInvert){
  27958. for (k=0,m=subIndices.length;k < m;k+=3){
  27959. batchOffset=batchIndexCount+k;
  27960. batchIndices[batchOffset]=batchVertexCount+subIndices[k];
  27961. batchIndices[batchOffset+1]=batchVertexCount+subIndices[k+2];
  27962. batchIndices[batchOffset+2]=batchVertexCount+subIndices[k+1];
  27963. }
  27964. }else {
  27965. for (k=m,m=subIndices.length;k < m;k+=3){
  27966. batchOffset=batchIndexCount+k;
  27967. batchIndices[batchOffset]=batchVertexCount+subIndices[k];
  27968. batchIndices[batchOffset+1]=batchVertexCount+subIndices[k+1];
  27969. batchIndices[batchOffset+2]=batchVertexCount+subIndices[k+2];
  27970. }
  27971. }
  27972. }
  27973. }
  27974. /**
  27975. *@private
  27976. */
  27977. __proto._flush=function(vertexCount,indexCount){
  27978. this._vertexBuffer.setData(this._vertices,0,0,vertexCount *(this._vertexBuffer.vertexDeclaration.vertexStride / 4));
  27979. this._indexBuffer.setData(this._indices,0,0,indexCount);
  27980. LayaGL.instance.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,indexCount,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,0);
  27981. }
  27982. /**
  27983. *@inheritDoc
  27984. */
  27985. __proto._prepareRender=function(state){
  27986. var element=state.renderElement;
  27987. var vertexDeclaration=element.vertexBatchVertexDeclaration;
  27988. this._bufferState=MeshRenderDynamicBatchManager.instance._getBufferState(vertexDeclaration);
  27989. this._positionOffset=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0).offset / 4;
  27990. var normalElement=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_NORMAL0*/3);
  27991. this._normalOffset=normalElement ? normalElement.offset / 4 :-1;
  27992. var colorElement=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_COLOR0*/1);
  27993. this._colorOffset=colorElement ? colorElement.offset / 4 :-1;
  27994. var uv0Element=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE0*/2);
  27995. this._uv0Offset=uv0Element ? uv0Element.offset / 4 :-1;
  27996. var uv1Element=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_TEXTURECOORDINATE1*/7);
  27997. this._uv1Offset=uv1Element ? uv1Element.offset / 4 :-1;
  27998. var tangentElement=vertexDeclaration.getVertexElementByUsage(/*laya.d3.graphics.Vertex.VertexMesh.MESH_TANGENT0*/4);
  27999. this._sTangentOffset=tangentElement ? tangentElement.offset / 4 :-1;
  28000. return true;
  28001. }
  28002. /**
  28003. *@inheritDoc
  28004. */
  28005. __proto._render=function(context){
  28006. this._bufferState.bind();
  28007. var element=context.renderElement;
  28008. var vertexDeclaration=element.vertexBatchVertexDeclaration;
  28009. var batchElements=element.vertexBatchElementList;
  28010. var batchVertexCount=0;
  28011. var batchIndexCount=0;
  28012. var floatStride=vertexDeclaration.vertexStride / 4;
  28013. var renderBatchCount=0;
  28014. var elementCount=batchElements.length;
  28015. for (var i=0;i < elementCount;i++){
  28016. var subElement=batchElements [i];
  28017. var subMesh=subElement._geometry;
  28018. var indexCount=subMesh._indexCount;
  28019. if (batchIndexCount+indexCount > /*CLASS CONST:laya.d3.graphics.SubMeshDynamicBatch.maxIndicesCount*/32000){
  28020. this._flush(batchVertexCount,batchIndexCount);
  28021. renderBatchCount++;
  28022. Stat.trianglesFaces+=batchIndexCount / 3;
  28023. batchVertexCount=batchIndexCount=0;
  28024. };
  28025. var transform=subElement._transform;
  28026. this._getBatchVertices(vertexDeclaration,this._vertices,batchVertexCount,transform,subElement,subMesh);
  28027. this._getBatchIndices(this._indices,batchIndexCount,batchVertexCount,transform,subMesh,subElement._dynamicMultiSubMesh);
  28028. batchVertexCount+=subElement._dynamicVertexCount;
  28029. batchIndexCount+=indexCount;
  28030. }
  28031. this._flush(batchVertexCount,batchIndexCount);
  28032. renderBatchCount++;
  28033. Stat.renderBatches+=renderBatchCount;
  28034. Stat.savedRenderBatches+=elementCount-renderBatchCount;
  28035. Stat.trianglesFaces+=batchIndexCount / 3;
  28036. }
  28037. SubMeshDynamicBatch.maxAllowVertexCount=10;
  28038. SubMeshDynamicBatch.maxAllowAttribueCount=900;
  28039. SubMeshDynamicBatch.maxIndicesCount=32000;
  28040. SubMeshDynamicBatch.instance=null;
  28041. return SubMeshDynamicBatch;
  28042. })(GeometryElement)
  28043. /**
  28044. *<code>CompoundColliderShape</code> 类用于创建盒子形状碰撞器。
  28045. */
  28046. //class laya.d3.physics.shape.CompoundColliderShape extends laya.d3.physics.shape.ColliderShape
  28047. var CompoundColliderShape=(function(_super){
  28048. function CompoundColliderShape(){
  28049. CompoundColliderShape.__super.call(this);
  28050. this._childColliderShapes=[];
  28051. this._type=/*laya.d3.physics.shape.ColliderShape.SHAPETYPES_COMPOUND*/5;
  28052. this._nativeShape=new Laya3D._physics3D.btCompoundShape();
  28053. }
  28054. __class(CompoundColliderShape,'laya.d3.physics.shape.CompoundColliderShape',_super);
  28055. var __proto=CompoundColliderShape.prototype;
  28056. /**
  28057. *@private
  28058. */
  28059. __proto._clearChildShape=function(shape){
  28060. shape._attatched=false;
  28061. shape._compoundParent=null;
  28062. shape._indexInCompound=-1;
  28063. }
  28064. /**
  28065. *@inheritDoc
  28066. */
  28067. __proto._addReference=function(){}
  28068. /**
  28069. *@inheritDoc
  28070. */
  28071. __proto._removeReference=function(){}
  28072. /**
  28073. *@private
  28074. */
  28075. __proto._updateChildTransform=function(shape){
  28076. var offset=shape.localOffset;
  28077. var rotation=shape.localRotation;
  28078. var nativeOffset=ColliderShape._nativeVector30;
  28079. var nativeQuaternion=ColliderShape._nativQuaternion0;
  28080. var nativeTransform=ColliderShape._nativeTransform0;
  28081. nativeOffset.setValue(-offset.x,offset.y,offset.z);
  28082. nativeQuaternion.setValue(-rotation.x,rotation.y,rotation.z,-rotation.w);
  28083. nativeTransform.setOrigin(nativeOffset);
  28084. nativeTransform.setRotation(nativeQuaternion);
  28085. this._nativeShape.updateChildTransform(shape._indexInCompound,nativeTransform,true);
  28086. }
  28087. /**
  28088. *添加子碰撞器形状。
  28089. *@param shape 子碰撞器形状。
  28090. */
  28091. __proto.addChildShape=function(shape){
  28092. if (shape._attatched)
  28093. throw "CompoundColliderShape: this shape has attatched to other entity.";
  28094. shape._attatched=true;
  28095. shape._compoundParent=this;
  28096. shape._indexInCompound=this._childColliderShapes.length;
  28097. this._childColliderShapes.push(shape);
  28098. var offset=shape.localOffset;
  28099. var rotation=shape.localRotation;
  28100. CompoundColliderShape._nativeOffset.setValue(-offset.x,offset.y,offset.z);
  28101. CompoundColliderShape._nativRotation.setValue(-rotation.x,rotation.y,rotation.z,-rotation.w);
  28102. CompoundColliderShape._nativeTransform.setOrigin(CompoundColliderShape._nativeOffset);
  28103. CompoundColliderShape._nativeTransform.setRotation(CompoundColliderShape._nativRotation);
  28104. var nativeScale=this._nativeShape.getLocalScaling();
  28105. this._nativeShape.setLocalScaling(CompoundColliderShape._nativeVector3One);
  28106. this._nativeShape.addChildShape(CompoundColliderShape._nativeTransform,shape._nativeShape);
  28107. this._nativeShape.setLocalScaling(nativeScale);
  28108. (this._attatchedCollisionObject)&& (this._attatchedCollisionObject.colliderShape=this);
  28109. }
  28110. /**
  28111. *移除子碰撞器形状。
  28112. *@param shape 子碰撞器形状。
  28113. */
  28114. __proto.removeChildShape=function(shape){
  28115. if (shape._compoundParent===this){
  28116. var index=shape._indexInCompound;
  28117. this._clearChildShape(shape);
  28118. var endShape=this._childColliderShapes[this._childColliderShapes.length-1];
  28119. endShape._indexInCompound=index;
  28120. this._childColliderShapes[index]=endShape;
  28121. this._childColliderShapes.pop();
  28122. this._nativeShape.removeChildShapeByIndex(index);
  28123. }
  28124. }
  28125. /**
  28126. *清空子碰撞器形状。
  28127. */
  28128. __proto.clearChildShape=function(){
  28129. for (var i=0,n=this._childColliderShapes.length;i < n;i++){
  28130. this._clearChildShape(this._childColliderShapes[i]);
  28131. this._nativeShape.removeChildShapeByIndex(0);
  28132. }
  28133. this._childColliderShapes.length=0;
  28134. }
  28135. /**
  28136. *获取子形状数量。
  28137. *@return
  28138. */
  28139. __proto.getChildShapeCount=function(){
  28140. return this._childColliderShapes.length;
  28141. }
  28142. /**
  28143. *@inheritDoc
  28144. */
  28145. __proto.cloneTo=function(destObject){
  28146. var destCompoundColliderShape=destObject;
  28147. destCompoundColliderShape.clearChildShape();
  28148. for (var i=0,n=this._childColliderShapes.length;i < n;i++)
  28149. destCompoundColliderShape.addChildShape(this._childColliderShapes[i].clone());
  28150. }
  28151. /**
  28152. *@inheritDoc
  28153. */
  28154. __proto.clone=function(){
  28155. var dest=new CompoundColliderShape();
  28156. this.cloneTo(dest);
  28157. return dest;
  28158. }
  28159. /**
  28160. *@inheritDoc
  28161. */
  28162. __proto.destroy=function(){
  28163. _super.prototype.destroy.call(this);
  28164. for (var i=0,n=this._childColliderShapes.length;i < n;i++){
  28165. var childShape=this._childColliderShapes[i];
  28166. if (childShape._referenceCount===0)
  28167. childShape.destroy();
  28168. }
  28169. }
  28170. __static(CompoundColliderShape,
  28171. ['_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);}
  28172. ]);
  28173. return CompoundColliderShape;
  28174. })(ColliderShape)
  28175. /**
  28176. *<code>OctreeMotionList</code> 类用于实现物理更新队列。
  28177. */
  28178. //class laya.d3.core.scene.OctreeMotionList extends laya.d3.component.SingletonList
  28179. var OctreeMotionList=(function(_super){
  28180. /**
  28181. *创建一个新的 <code>OctreeMotionList</code> 实例。
  28182. */
  28183. function OctreeMotionList(){
  28184. OctreeMotionList.__super.call(this);
  28185. }
  28186. __class(OctreeMotionList,'laya.d3.core.scene.OctreeMotionList',_super);
  28187. var __proto=OctreeMotionList.prototype;
  28188. /**
  28189. *@private
  28190. */
  28191. __proto.add=function(element){
  28192. var index=element._getIndexInMotionList();
  28193. if (index!==-1)
  28194. throw "OctreeMotionList:element has in PhysicsUpdateList.";
  28195. this._add(element);
  28196. element._setIndexInMotionList(this.length++);
  28197. }
  28198. /**
  28199. *@private
  28200. */
  28201. __proto.remove=function(element){
  28202. var index=element._getIndexInMotionList();
  28203. this.length--;
  28204. if (index!==this.length){
  28205. var end=this.elements[this.length];
  28206. this.elements[index]=end;
  28207. end._inPhysicUpdateListIndex=index;
  28208. }
  28209. element._setIndexInMotionList(-1);
  28210. }
  28211. return OctreeMotionList;
  28212. })(SingletonList)
  28213. /**
  28214. *<code>CylinderColliderShape</code> 类用于创建圆柱碰撞器。
  28215. */
  28216. //class laya.d3.physics.shape.CylinderColliderShape extends laya.d3.physics.shape.ColliderShape
  28217. var CylinderColliderShape=(function(_super){
  28218. function CylinderColliderShape(radius,height,orientation){
  28219. /**@private */
  28220. //this._orientation=0;
  28221. /**@private */
  28222. this._radius=1;
  28223. /**@private */
  28224. this._height=0.5;
  28225. CylinderColliderShape.__super.call(this);
  28226. (radius===void 0)&& (radius=0.5);
  28227. (height===void 0)&& (height=1.0);
  28228. (orientation===void 0)&& (orientation=/*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPY*/1);
  28229. this._radius=radius;
  28230. this._height=height;
  28231. this._orientation=orientation;
  28232. this._type=/*laya.d3.physics.shape.ColliderShape.SHAPETYPES_CYLINDER*/2;
  28233. switch (orientation){
  28234. case /*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPX*/0:
  28235. CylinderColliderShape._nativeSize.setValue(height / 2,radius,radius);
  28236. this._nativeShape=new Laya3D._physics3D.btCylinderShapeX(CylinderColliderShape._nativeSize);
  28237. break ;
  28238. case /*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPY*/1:
  28239. CylinderColliderShape._nativeSize.setValue(radius,height / 2,radius);
  28240. this._nativeShape=new Laya3D._physics3D.btCylinderShape(CylinderColliderShape._nativeSize);
  28241. break ;
  28242. case /*laya.d3.physics.shape.ColliderShape.SHAPEORIENTATION_UPZ*/2:
  28243. CylinderColliderShape._nativeSize.setValue(radius,radius,height / 2);
  28244. this._nativeShape=new Laya3D._physics3D.btCylinderShapeZ(CylinderColliderShape._nativeSize);
  28245. break ;
  28246. default :
  28247. throw "CapsuleColliderShape:unknown orientation.";
  28248. }
  28249. }
  28250. __class(CylinderColliderShape,'laya.d3.physics.shape.CylinderColliderShape',_super);
  28251. var __proto=CylinderColliderShape.prototype;
  28252. /**
  28253. *@inheritDoc
  28254. */
  28255. __proto.clone=function(){
  28256. var dest=new CylinderColliderShape(this._radius,this._height,this._orientation);
  28257. this.cloneTo(dest);
  28258. return dest;
  28259. }
  28260. /**
  28261. *获取半径。
  28262. */
  28263. __getset(0,__proto,'radius',function(){
  28264. return this._radius;
  28265. });
  28266. /**
  28267. *获取高度。
  28268. */
  28269. __getset(0,__proto,'height',function(){
  28270. return this._height;
  28271. });
  28272. /**
  28273. *获取方向。
  28274. */
  28275. __getset(0,__proto,'orientation',function(){
  28276. return this._orientation;
  28277. });
  28278. __static(CylinderColliderShape,
  28279. ['_nativeSize',function(){return this._nativeSize=new Laya3D._physics3D.btVector3(0,0,0);}
  28280. ]);
  28281. return CylinderColliderShape;
  28282. })(ColliderShape)
  28283. /**
  28284. *<code>SkyDome</code> 类用于创建天空盒。
  28285. */
  28286. //class laya.d3.resource.models.SkyDome extends laya.d3.resource.models.SkyMesh
  28287. var SkyDome=(function(_super){
  28288. function SkyDome(stacks,slices){
  28289. /**@private */
  28290. this._stacks=0;
  28291. /**@private */
  28292. this._slices=0;
  28293. SkyDome.__super.call(this);
  28294. (stacks===void 0)&& (stacks=48);
  28295. (slices===void 0)&& (slices=48);
  28296. this._stacks=stacks;
  28297. this._slices=slices;
  28298. var vertexDeclaration=VertexPositionTexture0.vertexDeclaration;
  28299. var vertexFloatCount=vertexDeclaration.vertexStride / 4;
  28300. var numberVertices=(this._stacks+1)*(this._slices+1);
  28301. var numberIndices=(3 *this._stacks *(this._slices+1))*2;
  28302. var vertices=new Float32Array(numberVertices *vertexFloatCount);
  28303. var indices=new Uint16Array(numberIndices);
  28304. var stackAngle=Math.PI / this._stacks;
  28305. var sliceAngle=(Math.PI *2.0)/ this._slices;
  28306. var vertexIndex=0;
  28307. var vertexCount=0;
  28308. var indexCount=0;
  28309. for (var stack=0;stack < (this._stacks+1);stack++){
  28310. var r=Math.sin(stack *stackAngle);
  28311. var y=Math.cos(stack *stackAngle);
  28312. for (var slice=0;slice < (this._slices+1);slice++){
  28313. var x=r *Math.sin(slice *sliceAngle);
  28314. var z=r *Math.cos(slice *sliceAngle);
  28315. vertices[vertexCount+0]=x *SkyDome._radius;
  28316. vertices[vertexCount+1]=y *SkyDome._radius;
  28317. vertices[vertexCount+2]=z *SkyDome._radius;
  28318. vertices[vertexCount+3]=-(slice / this._slices)+0.75;
  28319. vertices[vertexCount+4]=stack / this._stacks;
  28320. vertexCount+=vertexFloatCount;
  28321. if (stack !=(this._stacks-1)){
  28322. indices[indexCount++]=vertexIndex+1;
  28323. indices[indexCount++]=vertexIndex;
  28324. indices[indexCount++]=vertexIndex+(this._slices+1);
  28325. indices[indexCount++]=vertexIndex+(this._slices+1);
  28326. indices[indexCount++]=vertexIndex;
  28327. indices[indexCount++]=vertexIndex+(this._slices);
  28328. vertexIndex++;
  28329. }
  28330. }
  28331. }
  28332. this._vertexBuffer=new VertexBuffer3D(vertices.length *4,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,false);
  28333. this._vertexBuffer.vertexDeclaration=vertexDeclaration;
  28334. this._indexBuffer=new IndexBuffer3D(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",indices.length,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,false);
  28335. this._vertexBuffer.setData(vertices);
  28336. this._indexBuffer.setData(indices);
  28337. var bufferState=new BufferState();
  28338. bufferState.bind();
  28339. bufferState.applyVertexBuffer(this._vertexBuffer);
  28340. bufferState.applyIndexBuffer(this._indexBuffer);
  28341. bufferState.unBind();
  28342. this._bufferState=bufferState;
  28343. }
  28344. __class(SkyDome,'laya.d3.resource.models.SkyDome',_super);
  28345. var __proto=SkyDome.prototype;
  28346. __proto._render=function(state){
  28347. var indexCount=this._indexBuffer.indexCount;
  28348. LayaGL.instance.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,indexCount,/*laya.webgl.WebGLContext.UNSIGNED_SHORT*/0x1403,0);
  28349. Stat.trianglesFaces+=indexCount / 3;
  28350. Stat.renderBatches++;
  28351. }
  28352. /**
  28353. *获取堆数。
  28354. */
  28355. __getset(0,__proto,'stacks',function(){
  28356. return this._stacks;
  28357. });
  28358. /**
  28359. *获取层数。
  28360. */
  28361. __getset(0,__proto,'slices',function(){
  28362. return this._slices;
  28363. });
  28364. SkyDome.__init__=function(){
  28365. SkyDome.instance=new SkyDome();
  28366. }
  28367. SkyDome._radius=1;
  28368. SkyDome.instance=null;
  28369. return SkyDome;
  28370. })(SkyMesh)
  28371. /**
  28372. *@private
  28373. */
  28374. //class laya.d3.core.render.SubMeshRenderElement extends laya.d3.core.render.RenderElement
  28375. var SubMeshRenderElement=(function(_super){
  28376. function SubMeshRenderElement(){
  28377. /**@private */
  28378. //this._dynamicWorldPositionNormalNeedUpdate=false;
  28379. /**@private */
  28380. //this._dynamicVertexBatch=false;
  28381. /**@private */
  28382. //this._dynamicMultiSubMesh=false;
  28383. /**@private */
  28384. //this._dynamicVertexCount=0;
  28385. /**@private */
  28386. //this._dynamicWorldPositions=null;
  28387. /**@private */
  28388. //this._dynamicWorldNormals=null;
  28389. /**@private */
  28390. //this.staticBatchIndexStart=0;
  28391. /**@private */
  28392. //this.staticBatchIndexEnd=0;
  28393. /**@private */
  28394. //this.staticBatchElementList=null;
  28395. /**@private */
  28396. //this.instanceSubMesh=null;
  28397. /**@private */
  28398. //this.instanceBatchElementList=null;
  28399. /**@private */
  28400. //this.vertexBatchElementList=null;
  28401. /**@private */
  28402. //this.vertexBatchVertexDeclaration=null;
  28403. SubMeshRenderElement.__super.call(this);
  28404. this._dynamicWorldPositionNormalNeedUpdate=true;
  28405. }
  28406. __class(SubMeshRenderElement,'laya.d3.core.render.SubMeshRenderElement',_super);
  28407. var __proto=SubMeshRenderElement.prototype;
  28408. /**
  28409. *@private
  28410. */
  28411. __proto._onWorldMatrixChanged=function(){
  28412. this._dynamicWorldPositionNormalNeedUpdate=true;
  28413. }
  28414. /**
  28415. *@inheritDoc
  28416. */
  28417. __proto._computeWorldPositionsAndNormals=function(positionOffset,normalOffset,multiSubMesh,vertexCount){
  28418. if (this._dynamicWorldPositionNormalNeedUpdate){
  28419. var subMesh=this._geometry;
  28420. var vertexBuffer=subMesh._vertexBuffer;
  28421. var vertexFloatCount=vertexBuffer.vertexDeclaration.vertexStride / 4;
  28422. var oriVertexes=vertexBuffer.getData();
  28423. var worldMat=this._transform.worldMatrix;
  28424. var rotation=this._transform.rotation;
  28425. var indices=subMesh._indices;
  28426. for (var i=0;i < vertexCount;i++){
  28427. var index=multiSubMesh ? indices[i] :i;
  28428. var oriOffset=index *vertexFloatCount;
  28429. var bakeOffset=i *3;
  28430. Utils3D.transformVector3ArrayToVector3ArrayCoordinate(oriVertexes,oriOffset+positionOffset,worldMat,this._dynamicWorldPositions,bakeOffset);
  28431. (normalOffset!==-1)&& (Utils3D.transformVector3ArrayByQuat(oriVertexes,oriOffset+normalOffset,rotation,this._dynamicWorldNormals,bakeOffset));
  28432. }
  28433. this._dynamicWorldPositionNormalNeedUpdate=false;
  28434. }
  28435. }
  28436. /**
  28437. *@inheritDoc
  28438. */
  28439. __proto.setTransform=function(transform){
  28440. if (this._transform!==transform){
  28441. (this._transform)&& (this._transform.off(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this,this._onWorldMatrixChanged));
  28442. (transform)&& (transform.on(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this,this._onWorldMatrixChanged));
  28443. this._dynamicWorldPositionNormalNeedUpdate=true;
  28444. this._transform=transform;
  28445. }
  28446. }
  28447. /**
  28448. *@inheritDoc
  28449. */
  28450. __proto.setGeometry=function(geometry){
  28451. if (this._geometry!==geometry){
  28452. var subMesh=geometry;
  28453. var mesh=subMesh._mesh;
  28454. if (mesh){
  28455. var multiSubMesh=mesh._subMeshCount > 1;
  28456. var dynBatVerCount=multiSubMesh ? subMesh._indexCount :mesh._vertexCount;
  28457. if (dynBatVerCount <=/*laya.d3.graphics.SubMeshDynamicBatch.maxAllowVertexCount*/10){
  28458. var length=dynBatVerCount *3;
  28459. this._dynamicVertexBatch=true;
  28460. this._dynamicWorldPositions=new Float32Array(length);
  28461. this._dynamicWorldNormals=new Float32Array(length);
  28462. this._dynamicVertexCount=dynBatVerCount;
  28463. this._dynamicMultiSubMesh=multiSubMesh;
  28464. }else {
  28465. this._dynamicVertexBatch=false;
  28466. }
  28467. }
  28468. this._geometry=geometry;
  28469. }
  28470. }
  28471. /**
  28472. *@inheritDoc
  28473. */
  28474. __proto.addToOpaqueRenderQueue=function(context,queue){
  28475. var subMeshStaticBatch=this.staticBatch;
  28476. var elements=queue.elements;
  28477. if (subMeshStaticBatch){
  28478. var staManager=MeshRenderStaticBatchManager.instance;
  28479. var staBatchMarks=staManager.getBatchOpaquaMark(this.render.lightmapIndex+1,this.render.receiveShadow,this.material.id,subMeshStaticBatch._batchID);
  28480. if (staManager._updateCountMark===staBatchMarks.updateMark){
  28481. var staBatchIndex=staBatchMarks.indexInList;
  28482. if (staBatchMarks.batched){
  28483. elements[staBatchIndex].staticBatchElementList.push(this);
  28484. }else {
  28485. var staOriElement=elements[staBatchIndex];
  28486. var staOriRender=staOriElement.render;
  28487. var staBatchElement=staManager._getBatchRenderElementFromPool();
  28488. staBatchElement.renderType=/*laya.d3.core.render.RenderElement.RENDERTYPE_STATICBATCH*/1;
  28489. staBatchElement.setGeometry(subMeshStaticBatch);
  28490. staBatchElement.material=staOriElement.material;
  28491. var staRootOwner=subMeshStaticBatch.batchOwner;
  28492. var staBatchTransform=staRootOwner ? staRootOwner._transform :null;
  28493. staBatchElement.setTransform(staBatchTransform);
  28494. staBatchElement.render=staOriRender;
  28495. var staBatchList=staBatchElement.staticBatchElementList;
  28496. staBatchList.length=0;
  28497. staBatchList.push(staOriElement);
  28498. staBatchList.push(this);
  28499. elements[staBatchIndex]=staBatchElement;
  28500. staBatchMarks.batched=true;
  28501. }
  28502. }else {
  28503. staBatchMarks.updateMark=staManager._updateCountMark;
  28504. staBatchMarks.indexInList=elements.length;
  28505. staBatchMarks.batched=false;
  28506. elements.push(this);
  28507. }
  28508. }else if (this.material._shader._enableInstancing && WebGLContext._angleInstancedArrays){
  28509. var subMesh=this._geometry;
  28510. var insManager=MeshRenderDynamicBatchManager.instance;
  28511. var insBatchMarks=insManager.getInstanceBatchOpaquaMark(this.render.lightmapIndex+1,this.render.receiveShadow,this.material.id,subMesh._id);
  28512. if (insManager._updateCountMark===insBatchMarks.updateMark){
  28513. var insBatchIndex=insBatchMarks.indexInList;
  28514. if (insBatchMarks.batched){
  28515. var instanceBatchElementList=elements[insBatchIndex].instanceBatchElementList;
  28516. if (instanceBatchElementList.length===SubMeshInstanceBatch.instance.maxInstanceCount){
  28517. insBatchMarks.updateMark=insManager._updateCountMark;
  28518. insBatchMarks.indexInList=elements.length;
  28519. insBatchMarks.batched=false;
  28520. elements.push(this);
  28521. }else {
  28522. instanceBatchElementList.push(this);
  28523. }
  28524. }else {
  28525. var insOriElement=elements[insBatchIndex];
  28526. var insOriRender=insOriElement.render;
  28527. var insBatchElement=insManager._getBatchRenderElementFromPool();
  28528. insBatchElement.renderType=/*laya.d3.core.render.RenderElement.RENDERTYPE_INSTANCEBATCH*/2;
  28529. insBatchElement.setGeometry(SubMeshInstanceBatch.instance);
  28530. insBatchElement.material=insOriElement.material;
  28531. insBatchElement.setTransform(null);
  28532. insBatchElement.render=insOriRender;
  28533. insBatchElement.instanceSubMesh=subMesh;
  28534. var insBatchList=insBatchElement.instanceBatchElementList;
  28535. insBatchList.length=0;
  28536. insBatchList.push(insOriElement);
  28537. insBatchList.push(this);
  28538. elements[insBatchIndex]=insBatchElement;
  28539. insBatchMarks.batched=true;
  28540. }
  28541. }else {
  28542. insBatchMarks.updateMark=insManager._updateCountMark;
  28543. insBatchMarks.indexInList=elements.length;
  28544. insBatchMarks.batched=false;
  28545. elements.push(this);
  28546. }
  28547. }else if (this._dynamicVertexBatch){
  28548. var verDec=(this._geometry)._vertexBuffer.vertexDeclaration;
  28549. var dynManager=MeshRenderDynamicBatchManager.instance;
  28550. var dynBatchMarks=dynManager.getVertexBatchOpaquaMark(this.render.lightmapIndex+1,this.render.receiveShadow,this.material.id,verDec.id);
  28551. if (dynManager._updateCountMark===dynBatchMarks.updateMark){
  28552. var dynBatchIndex=dynBatchMarks.indexInList;
  28553. if (dynBatchMarks.batched){
  28554. elements[dynBatchIndex].vertexBatchElementList.push(this);
  28555. }else {
  28556. var dynOriElement=elements[dynBatchIndex];
  28557. var dynOriRender=dynOriElement.render;
  28558. var dynBatchElement=dynManager._getBatchRenderElementFromPool();
  28559. dynBatchElement.renderType=/*laya.d3.core.render.RenderElement.RENDERTYPE_VERTEXBATCH*/3;
  28560. dynBatchElement.setGeometry(SubMeshDynamicBatch.instance);
  28561. dynBatchElement.material=dynOriElement.material;
  28562. dynBatchElement.setTransform(null);
  28563. dynBatchElement.render=dynOriRender;
  28564. dynBatchElement.vertexBatchVertexDeclaration=verDec;
  28565. var dynBatchList=dynBatchElement.vertexBatchElementList;
  28566. dynBatchList.length=0;
  28567. dynBatchList.push(dynOriElement);
  28568. dynBatchList.push(this);
  28569. elements[dynBatchIndex]=dynBatchElement;
  28570. dynBatchMarks.batched=true;
  28571. }
  28572. }else {
  28573. dynBatchMarks.updateMark=dynManager._updateCountMark;
  28574. dynBatchMarks.indexInList=elements.length;
  28575. dynBatchMarks.batched=false;
  28576. elements.push(this);
  28577. }
  28578. }else {
  28579. elements.push(this);
  28580. }
  28581. }
  28582. /**
  28583. *@inheritDoc
  28584. */
  28585. __proto.addToTransparentRenderQueue=function(context,queue){
  28586. var subMeshStaticBatch=this.staticBatch;
  28587. var elements=queue.elements;
  28588. if (subMeshStaticBatch){
  28589. var staManager=MeshRenderStaticBatchManager.instance;
  28590. var staLastElement=queue.lastTransparentRenderElement;
  28591. if (staLastElement){
  28592. var staLastRender=staLastElement.render;
  28593. if (staLastElement._geometry._getType()!==this._geometry._getType()|| staLastElement.staticBatch!==subMeshStaticBatch || staLastElement.material!==this.material || staLastRender.receiveShadow!==this.render.receiveShadow || staLastRender.lightmapIndex!==this.render.lightmapIndex){
  28594. elements.push(this);
  28595. queue.lastTransparentBatched=false;
  28596. }else {
  28597. if (queue.lastTransparentBatched){
  28598. (elements [elements.length-1]).staticBatchElementList.push((this));
  28599. }else {
  28600. var staBatchElement=staManager._getBatchRenderElementFromPool();
  28601. staBatchElement.renderType=/*laya.d3.core.render.RenderElement.RENDERTYPE_STATICBATCH*/1;
  28602. staBatchElement.setGeometry(subMeshStaticBatch);
  28603. staBatchElement.material=staLastElement.material;
  28604. var staRootOwner=subMeshStaticBatch.batchOwner;
  28605. var staBatchTransform=staRootOwner ? staRootOwner._transform :null;
  28606. staBatchElement.setTransform(staBatchTransform);
  28607. staBatchElement.render=this.render;
  28608. var staBatchList=staBatchElement.staticBatchElementList;
  28609. staBatchList.length=0;
  28610. staBatchList.push(staLastElement);
  28611. staBatchList.push(this);
  28612. elements[elements.length-1]=staBatchElement;
  28613. }
  28614. queue.lastTransparentBatched=true;
  28615. }
  28616. }else {
  28617. elements.push(this);
  28618. queue.lastTransparentBatched=false;
  28619. }
  28620. }else if (this.material._shader._enableInstancing && WebGLContext._angleInstancedArrays){
  28621. var subMesh=this._geometry;
  28622. var insManager=MeshRenderDynamicBatchManager.instance;
  28623. var insLastElement=queue.lastTransparentRenderElement;
  28624. if (insLastElement){
  28625. var insLastRender=insLastElement.render;
  28626. if (insLastElement._geometry._getType()!==this._geometry._getType()|| (insLastElement._geometry)!==subMesh || insLastElement.material!==this.material || insLastRender.receiveShadow!==this.render.receiveShadow || insLastRender.lightmapIndex!==this.render.lightmapIndex){
  28627. elements.push(this);
  28628. queue.lastTransparentBatched=false;
  28629. }else {
  28630. if (queue.lastTransparentBatched){
  28631. (elements [elements.length-1]).instanceBatchElementList.push((this));
  28632. }else {
  28633. var insBatchElement=insManager._getBatchRenderElementFromPool();
  28634. insBatchElement.renderType=/*laya.d3.core.render.RenderElement.RENDERTYPE_INSTANCEBATCH*/2;
  28635. insBatchElement.setGeometry(SubMeshInstanceBatch.instance);
  28636. insBatchElement.material=insLastElement.material;
  28637. insBatchElement.setTransform(null);
  28638. insBatchElement.render=this.render;
  28639. insBatchElement.instanceSubMesh=subMesh;
  28640. var insBatchList=insBatchElement.instanceBatchElementList;
  28641. insBatchList.length=0;
  28642. insBatchList.push(insLastElement);
  28643. insBatchList.push(this);
  28644. elements[elements.length-1]=insBatchElement;
  28645. }
  28646. queue.lastTransparentBatched=true;
  28647. }
  28648. }else {
  28649. elements.push(this);
  28650. queue.lastTransparentBatched=false;
  28651. }
  28652. }else if (this._dynamicVertexBatch){
  28653. var verDec=(this._geometry)._vertexBuffer.vertexDeclaration;
  28654. var dynManager=MeshRenderDynamicBatchManager.instance;
  28655. var dynLastElement=queue.lastTransparentRenderElement;
  28656. if (dynLastElement){
  28657. var dynLastRender=dynLastElement.render;
  28658. 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){
  28659. elements.push(this);
  28660. queue.lastTransparentBatched=false;
  28661. }else {
  28662. if (queue.lastTransparentBatched){
  28663. (elements [elements.length-1]).vertexBatchElementList.push((this));
  28664. }else {
  28665. var dynBatchElement=dynManager._getBatchRenderElementFromPool();
  28666. dynBatchElement.renderType=/*laya.d3.core.render.RenderElement.RENDERTYPE_VERTEXBATCH*/3;
  28667. dynBatchElement.setGeometry(SubMeshDynamicBatch.instance);
  28668. dynBatchElement.material=dynLastElement.material;
  28669. dynBatchElement.setTransform(null);
  28670. dynBatchElement.render=this.render;
  28671. dynBatchElement.vertexBatchVertexDeclaration=verDec;
  28672. var dynBatchList=dynBatchElement.vertexBatchElementList;
  28673. dynBatchList.length=0;
  28674. dynBatchList.push(dynLastElement);
  28675. dynBatchList.push(this);
  28676. elements[elements.length-1]=dynBatchElement;
  28677. }
  28678. queue.lastTransparentBatched=true;
  28679. }
  28680. }else {
  28681. elements.push(this);
  28682. queue.lastTransparentBatched=false;
  28683. }
  28684. }else {
  28685. elements.push(this);
  28686. }
  28687. queue.lastTransparentRenderElement=this;
  28688. }
  28689. /**
  28690. *@inheritDoc
  28691. */
  28692. __proto.destroy=function(){
  28693. _super.prototype.destroy.call(this);
  28694. this._dynamicWorldPositions=null;
  28695. this._dynamicWorldNormals=null;
  28696. this.staticBatch=null;
  28697. this.staticBatchElementList=null;
  28698. this.vertexBatchElementList=null;
  28699. this.vertexBatchVertexDeclaration=null;
  28700. }
  28701. SubMeshRenderElement._maxInstanceCount=1024;
  28702. __static(SubMeshRenderElement,
  28703. ['_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);}
  28704. ]);
  28705. return SubMeshRenderElement;
  28706. })(RenderElement)
  28707. /**
  28708. *<code>Vector3Keyframe</code> 类用于创建三维向量关键帧实例。
  28709. */
  28710. //class laya.d3.core.Vector3Keyframe extends laya.d3.core.Keyframe
  28711. var Vector3Keyframe=(function(_super){
  28712. function Vector3Keyframe(){
  28713. Vector3Keyframe.__super.call(this);
  28714. this.inTangent=new Vector3();
  28715. this.outTangent=new Vector3();
  28716. this.value=new Vector3();
  28717. }
  28718. __class(Vector3Keyframe,'laya.d3.core.Vector3Keyframe',_super);
  28719. var __proto=Vector3Keyframe.prototype;
  28720. /**
  28721. *克隆。
  28722. *@param destObject 克隆源。
  28723. */
  28724. __proto.cloneTo=function(dest){
  28725. _super.prototype.cloneTo.call(this,dest);
  28726. var destKeyFarme=dest;
  28727. this.inTangent.cloneTo(destKeyFarme.inTangent);
  28728. this.outTangent.cloneTo(destKeyFarme.outTangent);
  28729. this.value.cloneTo(destKeyFarme.value);
  28730. }
  28731. return Vector3Keyframe;
  28732. })(Keyframe)
  28733. /**
  28734. *<code>QuaternionKeyframe</code> 类用于创建四元数关键帧实例。
  28735. */
  28736. //class laya.d3.core.QuaternionKeyframe extends laya.d3.core.Keyframe
  28737. var QuaternionKeyframe=(function(_super){
  28738. function QuaternionKeyframe(){
  28739. QuaternionKeyframe.__super.call(this);
  28740. this.inTangent=new Vector4();
  28741. this.outTangent=new Vector4();
  28742. this.value=new Quaternion();
  28743. }
  28744. __class(QuaternionKeyframe,'laya.d3.core.QuaternionKeyframe',_super);
  28745. var __proto=QuaternionKeyframe.prototype;
  28746. /**
  28747. *克隆。
  28748. *@param destObject 克隆源。
  28749. */
  28750. __proto.cloneTo=function(dest){
  28751. _super.prototype.cloneTo.call(this,dest);
  28752. var destKeyFarme=dest;
  28753. this.inTangent.cloneTo(destKeyFarme.inTangent);
  28754. this.outTangent.cloneTo(destKeyFarme.outTangent);
  28755. this.value.cloneTo(destKeyFarme.value);
  28756. }
  28757. return QuaternionKeyframe;
  28758. })(Keyframe)
  28759. /**
  28760. *<code>FloatKeyFrame</code> 类用于创建浮点关键帧实例。
  28761. */
  28762. //class laya.d3.core.FloatKeyframe extends laya.d3.core.Keyframe
  28763. var FloatKeyframe=(function(_super){
  28764. function FloatKeyframe(){
  28765. //this.inTangent=NaN;
  28766. //this.outTangent=NaN;
  28767. //this.value=NaN;
  28768. FloatKeyframe.__super.call(this);
  28769. }
  28770. __class(FloatKeyframe,'laya.d3.core.FloatKeyframe',_super);
  28771. var __proto=FloatKeyframe.prototype;
  28772. /**
  28773. *@inheritDoc
  28774. */
  28775. __proto.cloneTo=function(destObject){
  28776. _super.prototype.cloneTo.call(this,destObject);
  28777. var destKeyFrame=destObject;
  28778. destKeyFrame.inTangent=this.inTangent;
  28779. destKeyFrame.outTangent=this.outTangent;
  28780. destKeyFrame.value=this.value;
  28781. }
  28782. return FloatKeyframe;
  28783. })(Keyframe)
  28784. /**
  28785. *<code>SkyBox</code> 类用于创建天空盒。
  28786. */
  28787. //class laya.d3.resource.models.SkyBox extends laya.d3.resource.models.SkyMesh
  28788. var SkyBox=(function(_super){
  28789. /**
  28790. *创建一个 <code>SkyBox</code> 实例。
  28791. */
  28792. function SkyBox(){
  28793. SkyBox.__super.call(this);
  28794. var halfHeight=0.5;
  28795. var halfWidth=0.5;
  28796. var halfDepth=0.5;
  28797. var vertices=new Float32Array([-halfDepth,halfHeight,-halfWidth,halfDepth,halfHeight,-halfWidth,halfDepth,halfHeight,halfWidth,-halfDepth,halfHeight,halfWidth,
  28798. -halfDepth,-halfHeight,-halfWidth,halfDepth,-halfHeight,-halfWidth,halfDepth,-halfHeight,halfWidth,-halfDepth,-halfHeight,halfWidth]);
  28799. var indices=new Uint8Array([0,1,2,2,3,0,
  28800. 4,7,6,6,5,4,
  28801. 0,3,7,7,4,0,
  28802. 1,5,6,6,2,1,
  28803. 3,2,6,6,7,3,
  28804. 0,4,5,5,1,0]);
  28805. var verDec=VertexMesh.getVertexDeclaration("POSITION");
  28806. this._vertexBuffer=new VertexBuffer3D(verDec.vertexStride *8,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,false);
  28807. this._vertexBuffer.vertexDeclaration=verDec;
  28808. this._indexBuffer=new IndexBuffer3D(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_UBYTE*/"ubyte",36,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,false);
  28809. this._vertexBuffer.setData(vertices);
  28810. this._indexBuffer.setData(indices);
  28811. var bufferState=new BufferState();
  28812. bufferState.bind();
  28813. bufferState.applyVertexBuffer(this._vertexBuffer);
  28814. bufferState.applyIndexBuffer(this._indexBuffer);
  28815. bufferState.unBind();
  28816. this._bufferState=bufferState;
  28817. }
  28818. __class(SkyBox,'laya.d3.resource.models.SkyBox',_super);
  28819. var __proto=SkyBox.prototype;
  28820. /**
  28821. *@inheritDoc
  28822. */
  28823. __proto._render=function(state){
  28824. LayaGL.instance.drawElements(/*laya.webgl.WebGLContext.TRIANGLES*/0x0004,36,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,0);
  28825. Stat.trianglesFaces+=12;
  28826. Stat.renderBatches++;
  28827. }
  28828. SkyBox.__init__=function(){
  28829. SkyBox.instance=new SkyBox();
  28830. }
  28831. SkyBox.instance=null;
  28832. return SkyBox;
  28833. })(SkyMesh)
  28834. /**
  28835. *<code>Sprite3D</code> 类用于实现3D精灵。
  28836. */
  28837. //class laya.d3.core.Sprite3D extends laya.display.Node
  28838. var Sprite3D=(function(_super){
  28839. function Sprite3D(name,isStatic){
  28840. /**@private */
  28841. //this._id=0;
  28842. /**@private */
  28843. //this._url=null;
  28844. /**@private */
  28845. //this._isStatic=false;
  28846. /**@private */
  28847. //this._layer=0;
  28848. /**@private */
  28849. //this._scripts=null;
  28850. /**@private */
  28851. //this._transform=null;
  28852. /**@private */
  28853. //this._hierarchyAnimator=null;
  28854. /**@private */
  28855. this._needProcessCollisions=false;
  28856. /**@private */
  28857. this._needProcessTriggers=false;
  28858. Sprite3D.__super.call(this);
  28859. (isStatic===void 0)&& (isStatic=false);
  28860. this._id=++Sprite3D._uniqueIDCounter;
  28861. this._transform=new Transform3D(this);
  28862. this._isStatic=isStatic;
  28863. this.layer=0;
  28864. this.name=name ? name :"New Sprite3D";
  28865. }
  28866. __class(Sprite3D,'laya.d3.core.Sprite3D',_super);
  28867. var __proto=Sprite3D.prototype;
  28868. Laya.imps(__proto,{"laya.resource.ICreateResource":true})
  28869. /**
  28870. *@private
  28871. */
  28872. __proto._setCreateURL=function(url){
  28873. this._url=URL.formatURL(url);
  28874. }
  28875. /**
  28876. *@private
  28877. */
  28878. __proto._changeAnimatorsToLinkSprite3D=function(sprite3D,isLink,path){
  28879. var animator=this.getComponent(Animator);
  28880. if (animator){
  28881. if (!animator.avatar)
  28882. sprite3D._changeAnimatorToLinkSprite3DNoAvatar(animator,isLink,path);
  28883. }
  28884. if (this._parent && (this._parent instanceof laya.d3.core.Sprite3D )){
  28885. path.unshift(this._parent.name);
  28886. var p=this._parent;
  28887. (p._hierarchyAnimator)&& (p._changeAnimatorsToLinkSprite3D(sprite3D,isLink,path));
  28888. }
  28889. }
  28890. /**
  28891. *@private
  28892. */
  28893. __proto._setHierarchyAnimator=function(animator,parentAnimator){
  28894. this._changeHierarchyAnimator(animator);
  28895. this._changeAnimatorAvatar(animator.avatar);
  28896. for (var i=0,n=this._children.length;i < n;i++){
  28897. var child=this._children[i];
  28898. (child._hierarchyAnimator==parentAnimator)&& (child._setHierarchyAnimator(animator,parentAnimator));
  28899. }
  28900. }
  28901. /**
  28902. *@private
  28903. */
  28904. __proto._clearHierarchyAnimator=function(animator,parentAnimator){
  28905. this._changeHierarchyAnimator(parentAnimator);
  28906. this._changeAnimatorAvatar(parentAnimator ? parentAnimator.avatar :null);
  28907. for (var i=0,n=this._children.length;i < n;i++){
  28908. var child=this._children[i];
  28909. (child._hierarchyAnimator==animator)&& (child._clearHierarchyAnimator(animator,parentAnimator));
  28910. }
  28911. }
  28912. /**
  28913. *@private
  28914. */
  28915. __proto._changeHierarchyAnimatorAvatar=function(animator,avatar){
  28916. this._changeAnimatorAvatar(avatar);
  28917. for (var i=0,n=this._children.length;i < n;i++){
  28918. var child=this._children[i];
  28919. (child._hierarchyAnimator==animator)&& (child._changeHierarchyAnimatorAvatar(animator,avatar));
  28920. }
  28921. }
  28922. /**
  28923. *@private
  28924. */
  28925. __proto._changeAnimatorToLinkSprite3DNoAvatar=function(animator,isLink,path){
  28926. animator._handleSpriteOwnersBySprite(isLink,path,this);
  28927. for (var i=0,n=this._children.length;i < n;i++){
  28928. var child=this._children[i];
  28929. var index=path.length;
  28930. path.push(child.name);
  28931. child._changeAnimatorToLinkSprite3DNoAvatar(animator,isLink,path);
  28932. path.splice(index,1);
  28933. }
  28934. }
  28935. /**
  28936. *@private
  28937. */
  28938. __proto._changeHierarchyAnimator=function(animator){
  28939. this._hierarchyAnimator=animator;
  28940. }
  28941. /**
  28942. *@private
  28943. */
  28944. __proto._changeAnimatorAvatar=function(avatar){}
  28945. /**
  28946. *@inheritDoc
  28947. */
  28948. __proto._onAdded=function(){
  28949. if ((this._parent instanceof laya.d3.core.Sprite3D )){
  28950. var parent3D=this._parent;
  28951. this.transform._setParent(parent3D.transform);
  28952. if (parent3D._hierarchyAnimator){
  28953. (!this._hierarchyAnimator)&& (this._setHierarchyAnimator(parent3D._hierarchyAnimator,null));
  28954. parent3D._changeAnimatorsToLinkSprite3D(this,true,/*new vector.<>*/[this.name]);
  28955. }
  28956. }
  28957. _super.prototype._onAdded.call(this);
  28958. }
  28959. /**
  28960. *@inheritDoc
  28961. */
  28962. __proto._onRemoved=function(){
  28963. _super.prototype._onRemoved.call(this);
  28964. if ((this._parent instanceof laya.d3.core.Sprite3D )){
  28965. var parent3D=this._parent;
  28966. this.transform._setParent(null);
  28967. if (parent3D._hierarchyAnimator){
  28968. (this._hierarchyAnimator==parent3D._hierarchyAnimator)&& (this._clearHierarchyAnimator(parent3D._hierarchyAnimator,null));
  28969. parent3D._changeAnimatorsToLinkSprite3D(this,false,/*new vector.<>*/[this.name]);
  28970. }
  28971. }
  28972. }
  28973. /**
  28974. *@inheritDoc
  28975. */
  28976. __proto._parse=function(data,spriteMap){
  28977. (data.isStatic!==undefined)&& (this._isStatic=data.isStatic);
  28978. (data.active!==undefined)&& (this.active=data.active);
  28979. (data.name !=undefined)&& (this.name=data.name);
  28980. if (data.position!==undefined){
  28981. var loccalPosition=this.transform.localPosition;
  28982. loccalPosition.fromArray(data.position);
  28983. this.transform.localPosition=loccalPosition;
  28984. }
  28985. if (data.rotationEuler!==undefined){
  28986. var localRotationEuler=this.transform.localRotationEuler;
  28987. localRotationEuler.fromArray(data.rotationEuler);
  28988. this.transform.localRotationEuler=localRotationEuler;
  28989. }
  28990. if (data.rotation!==undefined){
  28991. var localRotation=this.transform.localRotation;
  28992. localRotation.fromArray(data.rotation);
  28993. this.transform.localRotation=localRotation;
  28994. }
  28995. if (data.scale!==undefined){
  28996. var localScale=this.transform.localScale;
  28997. localScale.fromArray(data.scale);
  28998. this.transform.localScale=localScale;
  28999. }
  29000. (data.layer !=undefined)&& (this.layer=data.layer);
  29001. }
  29002. /**
  29003. *克隆。
  29004. *@param destObject 克隆源。
  29005. */
  29006. __proto._cloneTo=function(destObject,srcRoot,dstRoot){
  29007. if (this.destroyed)
  29008. throw new Error("Sprite3D: Can't be cloned if the Sprite3D has destroyed.");
  29009. var destSprite3D=destObject;
  29010. destSprite3D.name=this.name;
  29011. destSprite3D.destroyed=this.destroyed;
  29012. destSprite3D.active=this.active;
  29013. var destLocalPosition=destSprite3D.transform.localPosition;
  29014. this.transform.localPosition.cloneTo(destLocalPosition);
  29015. destSprite3D.transform.localPosition=destLocalPosition;
  29016. var destLocalRotation=destSprite3D.transform.localRotation;
  29017. this.transform.localRotation.cloneTo(destLocalRotation);
  29018. destSprite3D.transform.localRotation=destLocalRotation;
  29019. var destLocalScale=destSprite3D.transform.localScale;
  29020. this.transform.localScale.cloneTo(destLocalScale);
  29021. destSprite3D.transform.localScale=destLocalScale;
  29022. destSprite3D._isStatic=this._isStatic;
  29023. destSprite3D.layer=this.layer;
  29024. _super.prototype._cloneTo.call(this,destSprite3D,srcRoot,dstRoot);
  29025. }
  29026. /**
  29027. *克隆。
  29028. *@return 克隆副本。
  29029. */
  29030. __proto.clone=function(){
  29031. var dstSprite3D=Sprite3D._createSprite3DInstance(this);
  29032. Sprite3D._parseSprite3DInstance(this,dstSprite3D,this,dstSprite3D);
  29033. return dstSprite3D;
  29034. }
  29035. /**
  29036. *@inheritDoc
  29037. */
  29038. __proto.destroy=function(destroyChild){
  29039. (destroyChild===void 0)&& (destroyChild=true);
  29040. if (this.destroyed)
  29041. return;
  29042. _super.prototype.destroy.call(this,destroyChild);
  29043. this._transform=null;
  29044. this._scripts=null;
  29045. this._url && Loader.clearRes(this._url);
  29046. }
  29047. /**
  29048. *获取唯一标识ID。
  29049. *@return 唯一标识ID。
  29050. */
  29051. __getset(0,__proto,'id',function(){
  29052. return this._id;
  29053. });
  29054. /**
  29055. *获取资源的URL地址。
  29056. *@return URL地址。
  29057. */
  29058. __getset(0,__proto,'url',function(){
  29059. return this._url;
  29060. });
  29061. /**
  29062. *设置蒙版。
  29063. *@param value 蒙版。
  29064. */
  29065. /**
  29066. *获取蒙版。
  29067. *@return 蒙版。
  29068. */
  29069. __getset(0,__proto,'layer',function(){
  29070. return this._layer;
  29071. },function(value){
  29072. if (this._layer!==value){
  29073. if (value >=0 && value <=30){
  29074. this._layer=value;
  29075. }else {
  29076. throw new Error("Layer value must be 0-30.");
  29077. }
  29078. }
  29079. });
  29080. /**
  29081. *获取精灵变换。
  29082. *@return 精灵变换。
  29083. */
  29084. __getset(0,__proto,'transform',function(){
  29085. return this._transform;
  29086. });
  29087. /**
  29088. *获取是否为静态。
  29089. *@return 是否为静态。
  29090. */
  29091. __getset(0,__proto,'isStatic',function(){
  29092. return this._isStatic;
  29093. });
  29094. Sprite3D._parse=function(data,propertyParams,constructParams){
  29095. var json=data.data;
  29096. var outBatchSprits=[];
  29097. var sprite;
  29098. switch (data.version){
  29099. case "LAYAHIERARCHY:02":
  29100. sprite=Utils3D._createNodeByJson02(json,outBatchSprits);
  29101. break ;
  29102. default :
  29103. sprite=Utils3D._createNodeByJson(json,outBatchSprits);
  29104. }
  29105. StaticBatchManager.combine(sprite,outBatchSprits);
  29106. return sprite;
  29107. }
  29108. Sprite3D.__init__=function(){}
  29109. Sprite3D.instantiate=function(original,parent,worldPositionStays,position,rotation){
  29110. (worldPositionStays===void 0)&& (worldPositionStays=true);
  29111. var destSprite3D=original.clone();
  29112. (parent)&& (parent.addChild(destSprite3D));
  29113. var transform=destSprite3D.transform;
  29114. if (worldPositionStays){
  29115. var worldMatrix=transform.worldMatrix;
  29116. original.transform.worldMatrix.cloneTo(worldMatrix);
  29117. transform.worldMatrix=worldMatrix;
  29118. }else {
  29119. (position)&& (transform.position=position);
  29120. (rotation)&& (transform.rotation=rotation);
  29121. }
  29122. return destSprite3D;
  29123. }
  29124. Sprite3D.load=function(url,complete){
  29125. Laya.loader.create(url,complete,null,/*Laya3D.HIERARCHY*/"HIERARCHY");
  29126. }
  29127. Sprite3D._createSprite3DInstance=function(scrSprite){
  29128. var node=/*__JS__ */new scrSprite.constructor();
  29129. var children=scrSprite._children;
  29130. for (var i=0,n=children.length;i < n;i++){
  29131. var child=Sprite3D._createSprite3DInstance(children[i])
  29132. node.addChild(child);
  29133. }
  29134. return node;
  29135. }
  29136. Sprite3D._parseSprite3DInstance=function(srcRoot,dstRoot,scrSprite,dstSprite){
  29137. var srcChildren=scrSprite._children;
  29138. var dstChildren=dstSprite._children;
  29139. for (var i=0,n=srcChildren.length;i < n;i++)
  29140. Sprite3D._parseSprite3DInstance(srcRoot,dstRoot,srcChildren[i],dstChildren[i])
  29141. scrSprite._cloneTo(dstSprite,srcRoot,dstRoot);
  29142. }
  29143. Sprite3D._uniqueIDCounter=0;
  29144. __static(Sprite3D,
  29145. ['WORLDMATRIX',function(){return this.WORLDMATRIX=Shader3D.propertyNameToID("u_WorldMat");},'MVPMATRIX',function(){return this.MVPMATRIX=Shader3D.propertyNameToID("u_MvpMatrix");}
  29146. ]);
  29147. return Sprite3D;
  29148. })(Node)
  29149. /**
  29150. *<code>BaseMaterial</code> 类用于创建材质,抽象类,不允许实例。
  29151. */
  29152. //class laya.d3.core.material.BaseMaterial extends laya.resource.Resource
  29153. var BaseMaterial=(function(_super){
  29154. function BaseMaterial(){
  29155. /**@private */
  29156. //this._alphaTest=false;
  29157. /**@private */
  29158. //this._defineDatas=null;
  29159. /**@private */
  29160. //this._disablePublicDefineDatas=null;
  29161. /**@private */
  29162. //this._shader=null;
  29163. /**@private */
  29164. this._shaderValues=null;
  29165. /**所属渲染队列. */
  29166. //this.renderQueue=0;
  29167. BaseMaterial.__super.call(this);
  29168. this._defineDatas=new DefineDatas();
  29169. this._disablePublicDefineDatas=new DefineDatas();
  29170. this._shaderValues=new ShaderData(this);
  29171. this.renderQueue=/*CLASS CONST:laya.d3.core.material.BaseMaterial.RENDERQUEUE_OPAQUE*/2000;
  29172. this._alphaTest=false;
  29173. }
  29174. __class(BaseMaterial,'laya.d3.core.material.BaseMaterial',_super);
  29175. var __proto=BaseMaterial.prototype;
  29176. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  29177. /**
  29178. *@private
  29179. */
  29180. __proto._removeTetxureReference=function(){
  29181. var data=this._shaderValues.getData();
  29182. for (var k in data){
  29183. var value=data[k];
  29184. if (value && (value instanceof laya.resource.BaseTexture ))
  29185. (value)._removeReference();
  29186. }
  29187. }
  29188. /**
  29189. *@inheritDoc
  29190. */
  29191. __proto._addReference=function(count){
  29192. (count===void 0)&& (count=1);
  29193. _super.prototype._addReference.call(this,count);
  29194. var data=this._shaderValues.getData();
  29195. for (var k in data){
  29196. var value=data[k];
  29197. if (value && (value instanceof laya.resource.BaseTexture ))
  29198. (value)._addReference();
  29199. }
  29200. }
  29201. /**
  29202. *@inheritDoc
  29203. */
  29204. __proto._removeReference=function(count){
  29205. (count===void 0)&& (count=1);
  29206. _super.prototype._removeReference.call(this,count);
  29207. this._removeTetxureReference();
  29208. }
  29209. /**
  29210. *@inheritDoc
  29211. */
  29212. __proto._disposeResource=function(){
  29213. if (this._referenceCount > 0)
  29214. this._removeTetxureReference();
  29215. this._shaderValues=null;
  29216. }
  29217. /**
  29218. *设置使用Shader名字。
  29219. *@param name 名称。
  29220. */
  29221. __proto.setShaderName=function(name){
  29222. this._shader=Shader3D.find(name);
  29223. if (!this._shader)
  29224. throw new Error("BaseMaterial: unknown shader name.");
  29225. }
  29226. /**
  29227. *克隆。
  29228. *@param destObject 克隆源。
  29229. */
  29230. __proto.cloneTo=function(destObject){
  29231. var destBaseMaterial=destObject;
  29232. destBaseMaterial.name=this.name;
  29233. destBaseMaterial.renderQueue=this.renderQueue;
  29234. this._disablePublicDefineDatas.cloneTo(destBaseMaterial._disablePublicDefineDatas);
  29235. this._defineDatas.cloneTo(destBaseMaterial._defineDatas);
  29236. this._shaderValues.cloneTo(destBaseMaterial._shaderValues);
  29237. }
  29238. /**
  29239. *克隆。
  29240. *@return 克隆副本。
  29241. */
  29242. __proto.clone=function(){
  29243. var dest=/*__JS__ */new this.constructor();
  29244. this.cloneTo(dest);
  29245. return dest;
  29246. }
  29247. /**
  29248. *设置透明测试模式裁剪值。
  29249. *@param value 透明测试模式裁剪值。
  29250. */
  29251. /**
  29252. *获取透明测试模式裁剪值。
  29253. *@return 透明测试模式裁剪值。
  29254. */
  29255. __getset(0,__proto,'alphaTestValue',function(){
  29256. return this._shaderValues.getNumber(BaseMaterial.ALPHATESTVALUE);
  29257. },function(value){
  29258. this._shaderValues.setNumber(BaseMaterial.ALPHATESTVALUE,value);
  29259. });
  29260. /**
  29261. *设置是否透明裁剪。
  29262. *@param value 是否透明裁剪。
  29263. */
  29264. /**
  29265. *获取是否透明裁剪。
  29266. *@return 是否透明裁剪。
  29267. */
  29268. __getset(0,__proto,'alphaTest',function(){
  29269. return this._alphaTest;
  29270. },function(value){
  29271. this._alphaTest=value;
  29272. if (value)
  29273. this._defineDatas.add(laya.d3.core.material.BaseMaterial.SHADERDEFINE_ALPHATEST);
  29274. else
  29275. this._defineDatas.remove(laya.d3.core.material.BaseMaterial.SHADERDEFINE_ALPHATEST);
  29276. });
  29277. BaseMaterial.load=function(url,complete){
  29278. Laya.loader.create(url,complete,null,/*Laya3D.MATERIAL*/"MATERIAL");
  29279. }
  29280. BaseMaterial.__init__=function(){
  29281. BaseMaterial.SHADERDEFINE_ALPHATEST=BaseMaterial.shaderDefines.registerDefine("ALPHATEST");
  29282. }
  29283. BaseMaterial._parse=function(data,propertyParams,constructParams){
  29284. var jsonData=data;
  29285. var props=jsonData.props;
  29286. var material;
  29287. var classType=props.type;
  29288. var clasPaths=classType.split('.');
  29289. var clas=Browser.window;
  29290. clasPaths.forEach(function(cls){
  29291. clas=clas[cls];
  29292. });
  29293. if (typeof(clas)=='function')
  29294. material=new clas();
  29295. else
  29296. throw('_getSprite3DHierarchyInnerUrls 错误: '+data.type+' 不是类');
  29297. switch (jsonData.version){
  29298. case "LAYAMATERIAL:01":
  29299. case "LAYAMATERIAL:02":;
  29300. var i=0,n=0;
  29301. for (var key in props){
  29302. switch (key){
  29303. case "vectors":;
  29304. var vectors=props[key];
  29305. for (i=0,n=vectors.length;i < n;i++){
  29306. var vector=vectors[i];
  29307. var vectorValue=vector.value;
  29308. switch (vectorValue.length){
  29309. case 2:
  29310. material[vector.name]=new Vector2(vectorValue[0],vectorValue[1]);
  29311. break ;
  29312. case 3:
  29313. material[vector.name]=new Vector3(vectorValue[0],vectorValue[1],vectorValue[2]);
  29314. break ;
  29315. case 4:
  29316. material[vector.name]=new Vector4(vectorValue[0],vectorValue[1],vectorValue[2],vectorValue[3]);
  29317. break ;
  29318. default :
  29319. throw new Error("BaseMaterial:unkonwn color length.");
  29320. }
  29321. }
  29322. break ;
  29323. case "textures":;
  29324. var textures=props[key];
  29325. for (i=0,n=textures.length;i < n;i++){
  29326. var texture=textures[i];
  29327. var path=texture.path;
  29328. (path)&& (material[texture.name]=Loader.getRes(path));
  29329. }
  29330. break ;
  29331. case "defines":;
  29332. var defineNames=props[key];
  29333. for (i=0,n=defineNames.length;i < n;i++){
  29334. var define=material._shader.getSubShaderAt(0).getMaterialDefineByName(defineNames[i]);
  29335. material._defineDatas.add(define);
  29336. }
  29337. break ;
  29338. case "renderStates":;
  29339. var renderStatesData=props[key];
  29340. var renderStateData=renderStatesData[0];
  29341. var mat=material;
  29342. mat.blend=renderStateData.blend;
  29343. mat.cull=renderStateData.cull;
  29344. mat.depthTest=renderStateData.depthTest;
  29345. mat.depthWrite=renderStateData.depthWrite;
  29346. mat.blendSrc=renderStateData.srcBlend;
  29347. mat.blendDst=renderStateData.dstBlend;
  29348. break ;
  29349. case "cull":
  29350. (material).cull=props[key];
  29351. break ;
  29352. case "blend":
  29353. (material).blend=props[key];
  29354. break ;
  29355. case "depthWrite":
  29356. (material).depthWrite=props[key];
  29357. break ;
  29358. case "srcBlend":
  29359. (material).blendSrc=props[key];
  29360. break ;
  29361. case "dstBlend":
  29362. (material).blendDst=props[key];
  29363. break ;
  29364. default :
  29365. material[key]=props[key];
  29366. }
  29367. }
  29368. break ;
  29369. default :
  29370. throw new Error("BaseMaterial:unkonwn version.");
  29371. }
  29372. return material;
  29373. }
  29374. BaseMaterial.RENDERQUEUE_OPAQUE=2000;
  29375. BaseMaterial.RENDERQUEUE_ALPHATEST=2450;
  29376. BaseMaterial.RENDERQUEUE_TRANSPARENT=3000;
  29377. BaseMaterial.SHADERDEFINE_ALPHATEST=0;
  29378. __static(BaseMaterial,
  29379. ['ALPHATESTVALUE',function(){return this.ALPHATESTVALUE=Shader3D.propertyNameToID("u_AlphaTestValue");},'shaderDefines',function(){return this.shaderDefines=new ShaderDefines();}
  29380. ]);
  29381. return BaseMaterial;
  29382. })(Resource)
  29383. /**
  29384. *<code>Avatar</code> 类用于创建Avatar。
  29385. */
  29386. //class laya.d3.core.Avatar extends laya.resource.Resource
  29387. var Avatar=(function(_super){
  29388. function Avatar(){
  29389. /**@private */
  29390. this._rootNode=null;
  29391. /**@private [NATIVE]*/
  29392. this._nativeNodeCount=0;
  29393. /**@private [NATIVE]*/
  29394. this._nativeCurCloneCount=0;
  29395. Avatar.__super.call(this);
  29396. }
  29397. __class(Avatar,'laya.d3.core.Avatar',_super);
  29398. var __proto=Avatar.prototype;
  29399. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  29400. /**
  29401. *@private
  29402. */
  29403. __proto._initCloneToAnimator=function(destNode,destAnimator){
  29404. destAnimator._avatarNodeMap[destNode.name]=destNode;
  29405. for (var i=0,n=destNode.getChildCount();i < n;i++)
  29406. this._initCloneToAnimator(destNode.getChildByIndex(i),destAnimator);
  29407. }
  29408. /**
  29409. *@private
  29410. */
  29411. __proto._parseNode=function(nodaData,node){
  29412. var name=nodaData.props.name;
  29413. node.name=name;
  29414. var props=nodaData.props;
  29415. var transform=node.transform;
  29416. var pos=transform.localPosition;
  29417. var rot=transform.localRotation;
  29418. var sca=transform.localScale;
  29419. pos.fromArray(props.translate);
  29420. rot.fromArray(props.rotation);
  29421. sca.fromArray(props.scale);
  29422. transform.localPosition=pos;
  29423. transform.localRotation=rot;
  29424. transform.localScale=sca;
  29425. var childrenData=nodaData.child;
  29426. for (var j=0,n=childrenData.length;j < n;j++){
  29427. var childData=childrenData[j];
  29428. var childBone=new AnimationNode(new Float32Array(3),new Float32Array(4),new Float32Array(3),new Float32Array(16));
  29429. node.addChild(childBone);
  29430. if (Render.supportWebGLPlusAnimation)
  29431. this._nativeNodeCount++;
  29432. this._parseNode(childData,childBone);
  29433. }
  29434. }
  29435. /**
  29436. *克隆数据到Avatr。
  29437. *@param destObject 克隆源。
  29438. */
  29439. __proto._cloneDatasToAnimator=function(destAnimator){
  29440. var destRoot;
  29441. destRoot=this._rootNode.clone();
  29442. var transform=this._rootNode.transform;
  29443. var destTransform=destRoot.transform;
  29444. var destPosition=destTransform.localPosition;
  29445. var destRotation=destTransform.localRotation;
  29446. var destScale=destTransform.localScale;
  29447. transform.localPosition.cloneTo(destPosition);
  29448. transform.localRotation.cloneTo(destRotation);
  29449. transform.localScale.cloneTo(destScale);
  29450. destTransform.localPosition=destPosition;
  29451. destTransform.localRotation=destRotation;
  29452. destTransform.localScale=destScale;
  29453. destAnimator._avatarNodeMap={};
  29454. this._initCloneToAnimator(destRoot,destAnimator);
  29455. }
  29456. /**
  29457. *克隆。
  29458. *@param destObject 克隆源。
  29459. */
  29460. __proto.cloneTo=function(destObject){
  29461. var destAvatar=destObject;
  29462. var destRoot=this._rootNode.clone();
  29463. destAvatar._rootNode=destRoot;
  29464. }
  29465. /**
  29466. *克隆。
  29467. *@return 克隆副本。
  29468. */
  29469. __proto.clone=function(){
  29470. var dest=/*__JS__ */new this.constructor();
  29471. this.cloneTo(dest);
  29472. return dest;
  29473. }
  29474. /**
  29475. *@private [NATIVE]
  29476. */
  29477. __proto._cloneDatasToAnimatorNative=function(destAnimator){
  29478. var animationNodeLocalPositions=new Float32Array(this._nativeNodeCount *3);
  29479. var animationNodeLocalRotations=new Float32Array(this._nativeNodeCount *4);
  29480. var animationNodeLocalScales=new Float32Array(this._nativeNodeCount *3);
  29481. var animationNodeWorldMatrixs=new Float32Array(this._nativeNodeCount *16);
  29482. var animationNodeParentIndices=new Int16Array(this._nativeNodeCount);
  29483. destAnimator._animationNodeLocalPositions=animationNodeLocalPositions;
  29484. destAnimator._animationNodeLocalRotations=animationNodeLocalRotations;
  29485. destAnimator._animationNodeLocalScales=animationNodeLocalScales;
  29486. destAnimator._animationNodeWorldMatrixs=animationNodeWorldMatrixs;
  29487. destAnimator._animationNodeParentIndices=animationNodeParentIndices;
  29488. this._nativeCurCloneCount=0;
  29489. var destRoot=this._rootNode._cloneNative(animationNodeLocalPositions,animationNodeLocalRotations,animationNodeLocalScales,animationNodeWorldMatrixs,animationNodeParentIndices,-1,this);
  29490. var transform=this._rootNode.transform;
  29491. var destTransform=destRoot.transform;
  29492. var destPosition=destTransform.localPosition;
  29493. var destRotation=destTransform.localRotation;
  29494. var destScale=destTransform.localScale;
  29495. transform.localPosition.cloneTo(destPosition);
  29496. transform.localRotation.cloneTo(destRotation);
  29497. transform.localScale.cloneTo(destScale);
  29498. destTransform.localPosition=destPosition;
  29499. destTransform.localRotation=destRotation;
  29500. destTransform.localScale=destScale;
  29501. destAnimator._avatarNodeMap={};
  29502. this._initCloneToAnimator(destRoot,destAnimator);
  29503. }
  29504. Avatar._parse=function(data,propertyParams,constructParams){
  29505. var avatar=new Avatar();
  29506. avatar._rootNode=new AnimationNode(new Float32Array(3),new Float32Array(4),new Float32Array(3),new Float32Array(16));
  29507. if (Render.supportWebGLPlusAnimation)
  29508. avatar._nativeNodeCount++;
  29509. if (data.version){
  29510. var rootNode=data.rootNode;
  29511. (rootNode)&& (avatar._parseNode(rootNode,avatar._rootNode));
  29512. }
  29513. return avatar;
  29514. }
  29515. Avatar.load=function(url,complete){
  29516. Laya.loader.create(url,complete,null,/*Laya3D.AVATAR*/"AVATAR");
  29517. }
  29518. return Avatar;
  29519. })(Resource)
  29520. /**
  29521. *<code>TerrainRes</code> 类用于描述地形信息。
  29522. */
  29523. //class laya.d3.terrain.TerrainRes extends laya.resource.Resource
  29524. var TerrainRes=(function(_super){
  29525. function TerrainRes(){
  29526. this._version=NaN;
  29527. this._cameraCoordinateInverse=false;
  29528. this._gridSize=NaN;
  29529. this._chunkNumX=0;
  29530. this._chunkNumZ=0;
  29531. this._heightDataX=0;
  29532. this._heightDataZ=0;
  29533. this._heightDataBitType=0;
  29534. this._heightDataValue=NaN;
  29535. this._heightDataUrl=null;
  29536. this._detailTextureInfos=null;
  29537. this._chunkInfos=null;
  29538. this._heightData=null;
  29539. this._materialInfo=null;
  29540. this._alphaMaps=null;
  29541. this._normalMaps=null;
  29542. TerrainRes.__super.call(this);
  29543. }
  29544. __class(TerrainRes,'laya.d3.terrain.TerrainRes',_super);
  29545. var __proto=TerrainRes.prototype;
  29546. __proto.parseData=function(data){
  29547. var json=data[0];
  29548. var resouMap=data[1];
  29549. this._version=json.version;
  29550. if (this._version==1.0){
  29551. this._cameraCoordinateInverse=json.cameraCoordinateInverse;
  29552. this._gridSize=json.gridSize;
  29553. this._chunkNumX=json.chunkNumX;
  29554. this._chunkNumZ=json.chunkNumZ;
  29555. var heightData=json.heightData;
  29556. this._heightDataX=heightData.numX;
  29557. this._heightDataZ=heightData.numZ;
  29558. this._heightDataBitType=heightData.bitType;
  29559. this._heightDataValue=heightData.value;
  29560. this._heightDataUrl=resouMap[heightData.url];
  29561. this._materialInfo=new MaterialInfo();
  29562. if (json.material){
  29563. var ambient=json.material.ambient;
  29564. var diffuse=json.material.diffuse;
  29565. var specular=json.material.specular;
  29566. this._materialInfo.ambientColor=new Vector3(ambient[0],ambient[1],ambient[2]);
  29567. this._materialInfo.diffuseColor=new Vector3(diffuse[0],diffuse[1],diffuse[2]);
  29568. this._materialInfo.specularColor=new Vector4(specular[0],specular[1],specular[2],specular[3]);
  29569. };
  29570. var detailTextures=json.detailTexture;
  29571. this._detailTextureInfos=__newvec(detailTextures.length);
  29572. for (var i=0;i < detailTextures.length;i++){
  29573. var detail=detailTextures[i];
  29574. var info=new DetailTextureInfo();
  29575. info.diffuseTexture=resouMap[detail.diffuse];
  29576. info.normalTexture=detail.normal ? resouMap[detail.normal] :null;
  29577. if (detail.scale){
  29578. info.scale=new Vector2(detail.scale[0],detail.scale[1]);
  29579. }else {
  29580. info.scale=new Vector2(1,1);
  29581. }
  29582. if (detail.offset){
  29583. info.offset=new Vector2(detail.offset[0],detail.offset[1]);
  29584. }else {
  29585. info.offset=new Vector2(0,0);
  29586. }
  29587. this._detailTextureInfos[i]=info;
  29588. };
  29589. var alphaMaps=json.alphaMap;
  29590. this._alphaMaps=__newvec(alphaMaps.length);
  29591. for (i=0;i < this._alphaMaps.length;i++){
  29592. this._alphaMaps[i]=json.alphaMap[i];
  29593. };
  29594. var normalMaps=json.normalMap;
  29595. this._normalMaps=__newvec(normalMaps.length);
  29596. for (i=0;i < this._normalMaps.length;i++){
  29597. this._normalMaps[i]=json.normalMap[i];
  29598. };
  29599. var jchunks=json.chunkInfo;
  29600. if (this._chunkNumX *this._chunkNumZ !=jchunks.length){
  29601. alert("terrain data error");
  29602. return false;
  29603. }
  29604. this._chunkInfos=__newvec(jchunks.length);
  29605. for (i=0;i < jchunks.length;i++){
  29606. var jchunk=jchunks[i];
  29607. var chunkinfo=new ChunkInfo();
  29608. var nAlphaMapNum=jchunk.alphaMap.length;
  29609. var nDetailIDNum=jchunk.detailID.length;
  29610. if (nAlphaMapNum !=nDetailIDNum){
  29611. alert("terrain chunk data error");
  29612. return false;
  29613. }
  29614. chunkinfo.alphaMap=__newvec(nAlphaMapNum);
  29615. chunkinfo.detailID=__newvec(nDetailIDNum);
  29616. chunkinfo.normalMap=resouMap[this._normalMaps[jchunk.normalMap]];
  29617. for (var j=0;j < nAlphaMapNum;j++){
  29618. chunkinfo.alphaMap[j]=resouMap[this._alphaMaps[jchunk.alphaMap[j]]];
  29619. var jid=jchunk.detailID[j];
  29620. var nIDNum=jid.length;
  29621. chunkinfo.detailID[j]=new Uint8Array(nIDNum);
  29622. for (var k=0;k < nIDNum;k++){
  29623. chunkinfo.detailID[j][k]=jid[k];
  29624. }
  29625. }
  29626. this._chunkInfos[i]=chunkinfo;
  29627. }
  29628. this._heightData=Loader.getRes(this._heightDataUrl);
  29629. this.onLoadTerrainComplete(this._heightData);
  29630. }
  29631. return true;
  29632. }
  29633. __proto.onLoadTerrainComplete=function(heightData){}
  29634. TerrainRes._parse=function(data,propertyParams,constructParams){
  29635. var terrainRes=new TerrainRes();
  29636. terrainRes.parseData(data);
  29637. return terrainRes;
  29638. }
  29639. TerrainRes.load=function(url,complete){
  29640. Laya.loader.create(url,complete,null,/*Laya3D.TERRAINRES*/"TERRAIN",null,null,1,false);
  29641. }
  29642. return TerrainRes;
  29643. })(Resource)
  29644. /**
  29645. *<code>Mesh</code> 类用于创建文件网格数据模板。
  29646. */
  29647. //class laya.d3.resource.models.Mesh extends laya.resource.Resource
  29648. var Mesh=(function(_super){
  29649. function Mesh(){
  29650. /**@private */
  29651. this._nativeTriangleMesh=null;
  29652. /**@private */
  29653. this._bounds=null;
  29654. /**@private */
  29655. this._subMeshCount=0;
  29656. /**@private */
  29657. this._subMeshes=null;
  29658. /**@private */
  29659. this._vertexBuffers=null;
  29660. /**@private */
  29661. this._indexBuffer=null;
  29662. /**@private */
  29663. this._boneNames=null;
  29664. /**@private */
  29665. this._inverseBindPoses=null;
  29666. /**@private */
  29667. this._inverseBindPosesBuffer=null;
  29668. /**@private */
  29669. this._bindPoseIndices=null;
  29670. /**@private */
  29671. this._skinDataPathMarks=null;
  29672. /**@private */
  29673. this._vertexCount=0;
  29674. this._tempVector30=new Vector3()
  29675. this._tempVector31=new Vector3();
  29676. this._tempVector32=new Vector3();
  29677. this._bufferState=new BufferState();
  29678. this._instanceBufferState=new BufferState();
  29679. Mesh.__super.call(this);
  29680. this._subMeshes=[];
  29681. this._vertexBuffers=[];
  29682. this._skinDataPathMarks=[];
  29683. }
  29684. __class(Mesh,'laya.d3.resource.models.Mesh',_super);
  29685. var __proto=Mesh.prototype;
  29686. Laya.imps(__proto,{"laya.d3.core.IClone":true})
  29687. /**
  29688. *@private
  29689. */
  29690. __proto._getPositionElement=function(vertexBuffer){
  29691. var vertexElements=vertexBuffer.vertexDeclaration.vertexElements;
  29692. for (var i=0,n=vertexElements.length;i < n;i++){
  29693. var vertexElement=vertexElements[i];
  29694. if (vertexElement.elementFormat===/*laya.d3.graphics.VertexElementFormat.Vector3*/"vector3" && vertexElement.elementUsage===/*laya.d3.graphics.Vertex.VertexMesh.MESH_POSITION0*/0)
  29695. return vertexElement;
  29696. }
  29697. return null;
  29698. }
  29699. /**
  29700. *@private
  29701. */
  29702. __proto._generateBoundingObject=function(){
  29703. var min=this._tempVector30;
  29704. var max=this._tempVector31;
  29705. min.x=min.y=min.z=Number.MAX_VALUE;
  29706. max.x=max.y=max.z=-Number.MAX_VALUE;
  29707. var vertexBufferCount=this._vertexBuffers.length;
  29708. for (var i=0;i < vertexBufferCount;i++){
  29709. var vertexBuffer=this._vertexBuffers[i];
  29710. var positionElement=this._getPositionElement(vertexBuffer);
  29711. var verticesData=vertexBuffer.getData();
  29712. var floatCount=vertexBuffer.vertexDeclaration.vertexStride / 4;
  29713. var posOffset=positionElement.offset / 4;
  29714. for (var j=0,m=verticesData.length;j < m;j+=floatCount){
  29715. var ofset=j+posOffset;
  29716. var pX=verticesData[ofset];
  29717. var pY=verticesData[ofset+1];
  29718. var pZ=verticesData[ofset+2];
  29719. min.x=Math.min(min.x,pX);
  29720. min.y=Math.min(min.y,pY);
  29721. min.z=Math.min(min.z,pZ);
  29722. max.x=Math.max(max.x,pX);
  29723. max.y=Math.max(max.y,pY);
  29724. max.z=Math.max(max.z,pZ);
  29725. }
  29726. }
  29727. this._bounds=new Bounds(min,max);
  29728. }
  29729. /**
  29730. *@private
  29731. */
  29732. __proto._setSubMeshes=function(subMeshes){
  29733. this._subMeshes=subMeshes
  29734. this._subMeshCount=subMeshes.length;
  29735. for (var i=0;i < this._subMeshCount;i++)
  29736. subMeshes[i]._indexInMesh=i;
  29737. this._generateBoundingObject();
  29738. }
  29739. /**
  29740. *@inheritDoc
  29741. */
  29742. __proto._getSubMesh=function(index){
  29743. return this._subMeshes[index];
  29744. }
  29745. /**
  29746. *@private
  29747. */
  29748. __proto._setBuffer=function(vertexBuffers,indexBuffer){
  29749. var bufferState=this._bufferState;
  29750. bufferState.bind();
  29751. bufferState.applyVertexBuffers(vertexBuffers);
  29752. bufferState.applyIndexBuffer(indexBuffer);
  29753. bufferState.unBind();
  29754. var instanceBufferState=this._instanceBufferState;
  29755. instanceBufferState.bind();
  29756. instanceBufferState.applyVertexBuffers(vertexBuffers);
  29757. instanceBufferState.applyInstanceVertexBuffer(SubMeshInstanceBatch.instance.instanceWorldMatrixBuffer);
  29758. instanceBufferState.applyInstanceVertexBuffer(SubMeshInstanceBatch.instance.instanceMVPMatrixBuffer);
  29759. instanceBufferState.applyIndexBuffer(indexBuffer);
  29760. instanceBufferState.unBind();
  29761. }
  29762. /**
  29763. *@inheritDoc
  29764. */
  29765. __proto._disposeResource=function(){
  29766. for (var i=0,n=this._subMeshes.length;i < n;i++)
  29767. this._subMeshes[i].destroy();
  29768. this._nativeTriangleMesh && Laya3D._physics3D.destroy(this._nativeTriangleMesh);
  29769. for (i=0,n=this._vertexBuffers.length;i < n;i++)
  29770. this._vertexBuffers[i].destroy();
  29771. this._indexBuffer.destroy();
  29772. this._setCPUMemory(0);
  29773. this._setGPUMemory(0);
  29774. this._bufferState.destroy();
  29775. this._instanceBufferState.destroy();
  29776. this._bufferState=null;
  29777. this._instanceBufferState=null;
  29778. this._vertexBuffers=null;
  29779. this._indexBuffer=null;
  29780. this._subMeshes=null;
  29781. this._nativeTriangleMesh=null;
  29782. this._vertexBuffers=null;
  29783. this._indexBuffer=null;
  29784. this._boneNames=null;
  29785. this._inverseBindPoses=null;
  29786. }
  29787. /**
  29788. *@private
  29789. */
  29790. __proto._getPhysicMesh=function(){
  29791. if (!this._nativeTriangleMesh){
  29792. var physics3D=Laya3D._physics3D;
  29793. var triangleMesh=new physics3D.btTriangleMesh();
  29794. var nativePositio0=Mesh._nativeTempVector30;
  29795. var nativePositio1=Mesh._nativeTempVector31;
  29796. var nativePositio2=Mesh._nativeTempVector32;
  29797. var position0=this._tempVector30;
  29798. var position1=this._tempVector31;
  29799. var position2=this._tempVector32;
  29800. var vertexBuffer=this._vertexBuffers[0];
  29801. var positionElement=this._getPositionElement(vertexBuffer);
  29802. var verticesData=vertexBuffer.getData();
  29803. var floatCount=vertexBuffer.vertexDeclaration.vertexStride / 4;
  29804. var posOffset=positionElement.offset / 4;
  29805. var indices=this._indexBuffer.getData();
  29806. for (var i=0,n=indices.length;i < n;i+=3){
  29807. var p0Index=indices[i] *floatCount+posOffset;
  29808. var p1Index=indices[i+1] *floatCount+posOffset;
  29809. var p2Index=indices[i+2] *floatCount+posOffset;
  29810. position0.setValue(verticesData[p0Index],verticesData[p0Index+1],verticesData[p0Index+2]);
  29811. position1.setValue(verticesData[p1Index],verticesData[p1Index+1],verticesData[p1Index+2]);
  29812. position2.setValue(verticesData[p2Index],verticesData[p2Index+1],verticesData[p2Index+2]);
  29813. Utils3D._convertToBulletVec3(position0,nativePositio0,true);
  29814. Utils3D._convertToBulletVec3(position1,nativePositio1,true);
  29815. Utils3D._convertToBulletVec3(position2,nativePositio2,true);
  29816. triangleMesh.addTriangle(nativePositio0,nativePositio1,nativePositio2,true);
  29817. }
  29818. this._nativeTriangleMesh=triangleMesh;
  29819. }
  29820. return this._nativeTriangleMesh;
  29821. }
  29822. /**
  29823. *克隆。
  29824. *@param destObject 克隆源。
  29825. */
  29826. __proto.cloneTo=function(destObject){
  29827. var destMesh=destObject;
  29828. for (var i=0;i < this._vertexBuffers.length;i++){
  29829. var vb=this._vertexBuffers[i];
  29830. var destVB=new VertexBuffer3D(vb._byteLength,vb.bufferUsage,vb.canRead);
  29831. destVB.vertexDeclaration=vb.vertexDeclaration;
  29832. destVB.setData(vb.getData().slice());
  29833. destMesh._vertexBuffers.push(destVB);
  29834. destMesh._vertexCount+=destVB.vertexCount;
  29835. };
  29836. var ib=this._indexBuffer;
  29837. var destIB=new IndexBuffer3D(/*laya.d3.graphics.IndexBuffer3D.INDEXTYPE_USHORT*/"ushort",ib.indexCount,ib.bufferUsage,ib.canRead);
  29838. destIB.setData(ib.getData().slice());
  29839. destMesh._indexBuffer=destIB;
  29840. destMesh._setBuffer(destMesh._vertexBuffers,destIB);
  29841. destMesh._setCPUMemory(this.cpuMemory);
  29842. destMesh._setGPUMemory(this.gpuMemory);
  29843. var boneNames=this._boneNames;
  29844. var destBoneNames=destMesh._boneNames=__newvec(boneNames.length);
  29845. for (i=0;i < boneNames.length;i++)
  29846. destBoneNames[i]=boneNames[i];
  29847. var inverseBindPoses=this._inverseBindPoses;
  29848. var destInverseBindPoses=destMesh._inverseBindPoses=__newvec(inverseBindPoses.length);
  29849. for (i=0;i < inverseBindPoses.length;i++)
  29850. destInverseBindPoses[i]=inverseBindPoses[i];
  29851. destMesh._bindPoseIndices=new Uint16Array(this._bindPoseIndices);
  29852. for (i=0;i < this._skinDataPathMarks.length;i++)
  29853. destMesh._skinDataPathMarks[i]=this._skinDataPathMarks[i].slice();
  29854. for (i=0;i < this.subMeshCount;i++){
  29855. var subMesh=this._subMeshes[i];
  29856. var subIndexBufferStart=subMesh._subIndexBufferStart;
  29857. var subIndexBufferCount=subMesh._subIndexBufferCount;
  29858. var boneIndicesList=subMesh._boneIndicesList;
  29859. var destSubmesh=new SubMesh(destMesh);
  29860. destSubmesh._subIndexBufferStart.length=subIndexBufferStart.length;
  29861. destSubmesh._subIndexBufferCount.length=subIndexBufferCount.length;
  29862. destSubmesh._boneIndicesList.length=boneIndicesList.length;
  29863. for (var j=0;j < subIndexBufferStart.length;j++)
  29864. destSubmesh._subIndexBufferStart[j]=subIndexBufferStart[j];
  29865. for (j=0;j < subIndexBufferCount.length;j++)
  29866. destSubmesh._subIndexBufferCount[j]=subIndexBufferCount[j];
  29867. for (j=0;j < boneIndicesList.length;j++)
  29868. destSubmesh._boneIndicesList[j]=new Uint16Array(boneIndicesList[j]);
  29869. destSubmesh._indexBuffer=destIB;
  29870. destSubmesh._indexStart=subMesh._indexStart;
  29871. destSubmesh._indexCount=subMesh._indexCount;
  29872. destSubmesh._indices=new Uint16Array(destIB.getData().buffer,subMesh._indexStart *2,subMesh._indexCount);
  29873. var vertexBuffer=destMesh._vertexBuffers[0];
  29874. destSubmesh._vertexBuffer=vertexBuffer;
  29875. destMesh._subMeshes.push(destSubmesh);
  29876. }
  29877. destMesh._setSubMeshes(destMesh._subMeshes);
  29878. }
  29879. /**
  29880. *克隆。
  29881. *@return 克隆副本。
  29882. */
  29883. __proto.clone=function(){
  29884. var dest=/*__JS__ */new this.constructor();
  29885. this.cloneTo(dest);
  29886. return dest;
  29887. }
  29888. /**
  29889. *获取网格的全局默认绑定动作逆矩阵。
  29890. *@return 网格的全局默认绑定动作逆矩阵。
  29891. */
  29892. __getset(0,__proto,'inverseAbsoluteBindPoses',function(){
  29893. return this._inverseBindPoses;
  29894. });
  29895. /**
  29896. *获取顶点个数
  29897. */
  29898. __getset(0,__proto,'vertexCount',function(){
  29899. return this._vertexCount;
  29900. });
  29901. /**
  29902. *获取SubMesh的个数。
  29903. *@return SubMesh的个数。
  29904. */
  29905. __getset(0,__proto,'subMeshCount',function(){
  29906. return this._subMeshCount;
  29907. });
  29908. /**
  29909. *获取边界
  29910. *@return 边界。
  29911. */
  29912. __getset(0,__proto,'bounds',function(){
  29913. return this._bounds;
  29914. });
  29915. Mesh._parse=function(data,propertyParams,constructParams){
  29916. var mesh=new Mesh();
  29917. MeshReader.read(data,mesh,mesh._subMeshes);
  29918. return mesh;
  29919. }
  29920. Mesh.load=function(url,complete){
  29921. Laya.loader.create(url,complete,null,/*Laya3D.MESH*/"MESH");
  29922. }
  29923. __static(Mesh,
  29924. ['_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);}
  29925. ]);
  29926. return Mesh;
  29927. })(Resource)
  29928. /**
  29929. *<code>AnimationClip</code> 类用于动画片段资源。
  29930. */
  29931. //class laya.d3.animation.AnimationClip extends laya.resource.Resource
  29932. var AnimationClip=(function(_super){
  29933. function AnimationClip(){
  29934. /**@private */
  29935. //this._duration=NaN;
  29936. /**@private */
  29937. //this._frameRate=0;
  29938. /**@private */
  29939. //this._nodesDic=null;
  29940. /**@private */
  29941. //this._nodesMap=null;
  29942. /**@private */
  29943. //this._events=null;
  29944. /**是否循环。*/
  29945. //this.islooping=false;
  29946. AnimationClip.__super.call(this);
  29947. this._nodes=new KeyframeNodeList();
  29948. this._events=[];
  29949. }
  29950. __class(AnimationClip,'laya.d3.animation.AnimationClip',_super);
  29951. var __proto=AnimationClip.prototype;
  29952. /**
  29953. *获取动画片段时长。
  29954. */
  29955. __proto.duration=function(){
  29956. return this._duration;
  29957. }
  29958. /**
  29959. *@private
  29960. */
  29961. __proto._hermiteInterpolate=function(frame,nextFrame,t,dur){
  29962. var t0=frame.outTangent,t1=nextFrame.inTangent;
  29963. if (/*__JS__ */Number.isFinite(t0)&& Number.isFinite(t1)){
  29964. var t2=t *t;
  29965. var t3=t2 *t;
  29966. var a=2.0 *t3-3.0 *t2+1.0;
  29967. var b=t3-2.0 *t2+t;
  29968. var c=t3-t2;
  29969. var d=-2.0 *t3+3.0 *t2;
  29970. return a *frame.value+b *t0 *dur+c *t1 *dur+d *nextFrame.value;
  29971. }else
  29972. return frame.value;
  29973. }
  29974. /**
  29975. *@private
  29976. */
  29977. __proto._hermiteInterpolateVector3=function(frame,nextFrame,t,dur,out){
  29978. var p0=frame.value;
  29979. var tan0=frame.outTangent;
  29980. var p1=nextFrame.value;
  29981. var tan1=nextFrame.inTangent;
  29982. var t2=t *t;
  29983. var t3=t2 *t;
  29984. var a=2.0 *t3-3.0 *t2+1.0;
  29985. var b=t3-2.0 *t2+t;
  29986. var c=t3-t2;
  29987. var d=-2.0 *t3+3.0 *t2;
  29988. var t0=tan0.x,t1=tan1.x;
  29989. if (/*__JS__ */Number.isFinite(t0)&& Number.isFinite(t1))
  29990. out.x=a *p0.x+b *t0 *dur+c *t1 *dur+d *p1.x;
  29991. else
  29992. out.x=p0.x;
  29993. t0=tan0.y,t1=tan1.y;
  29994. if (/*__JS__ */Number.isFinite(t0)&& Number.isFinite(t1))
  29995. out.y=a *p0.y+b *t0 *dur+c *t1 *dur+d *p1.y;
  29996. else
  29997. out.y=p0.y;
  29998. t0=tan0.z,t1=tan1.z;
  29999. if (/*__JS__ */Number.isFinite(t0)&& Number.isFinite(t1))
  30000. out.z=a *p0.z+b *t0 *dur+c *t1 *dur+d *p1.z;
  30001. else
  30002. out.z=p0.z;
  30003. }
  30004. /**
  30005. *@private
  30006. */
  30007. __proto._hermiteInterpolateQuaternion=function(frame,nextFrame,t,dur,out){
  30008. var p0=frame.value;
  30009. var tan0=frame.outTangent;
  30010. var p1=nextFrame.value;
  30011. var tan1=nextFrame.inTangent;
  30012. var t2=t *t;
  30013. var t3=t2 *t;
  30014. var a=2.0 *t3-3.0 *t2+1.0;
  30015. var b=t3-2.0 *t2+t;
  30016. var c=t3-t2;
  30017. var d=-2.0 *t3+3.0 *t2;
  30018. var t0=tan0.x,t1=tan1.x;
  30019. if (/*__JS__ */Number.isFinite(t0)&& Number.isFinite(t1))
  30020. out.x=a *p0.x+b *t0 *dur+c *t1 *dur+d *p1.x;
  30021. else
  30022. out.x=p0.x;
  30023. t0=tan0.y,t1=tan1.y;
  30024. if (/*__JS__ */Number.isFinite(t0)&& Number.isFinite(t1))
  30025. out.y=a *p0.y+b *t0 *dur+c *t1 *dur+d *p1.y;
  30026. else
  30027. out.y=p0.y;
  30028. t0=tan0.z,t1=tan1.z;
  30029. if (/*__JS__ */Number.isFinite(t0)&& Number.isFinite(t1))
  30030. out.z=a *p0.z+b *t0 *dur+c *t1 *dur+d *p1.z;
  30031. else
  30032. out.z=p0.z;
  30033. t0=tan0.w,t1=tan1.w;
  30034. if (/*__JS__ */Number.isFinite(t0)&& Number.isFinite(t1))
  30035. out.w=a *p0.w+b *t0 *dur+c *t1 *dur+d *p1.w;
  30036. else
  30037. out.w=p0.w;
  30038. }
  30039. /**
  30040. *@private
  30041. */
  30042. __proto._evaluateClipDatasRealTime=function(nodes,playCurTime,realTimeCurrentFrameIndexes,addtive,frontPlay){
  30043. for (var i=0,n=nodes.count;i < n;i++){
  30044. var node=nodes.getNodeByIndex(i);
  30045. var type=node.type;
  30046. var nextFrameIndex=0;
  30047. var keyFrames=node._keyFrames;
  30048. var keyFramesCount=keyFrames.length;
  30049. var frameIndex=realTimeCurrentFrameIndexes[i];
  30050. if (frontPlay){
  30051. if ((frameIndex!==-1)&& (playCurTime < keyFrames[frameIndex].time)){
  30052. frameIndex=-1;
  30053. realTimeCurrentFrameIndexes[i]=frameIndex;
  30054. }
  30055. nextFrameIndex=frameIndex+1;
  30056. while (nextFrameIndex < keyFramesCount){
  30057. if (keyFrames[nextFrameIndex].time > playCurTime)
  30058. break ;
  30059. frameIndex++;
  30060. nextFrameIndex++;
  30061. realTimeCurrentFrameIndexes[i]=frameIndex;
  30062. }
  30063. }else {
  30064. nextFrameIndex=frameIndex+1;
  30065. if ((nextFrameIndex!==keyFramesCount)&& (playCurTime > keyFrames[nextFrameIndex].time)){
  30066. frameIndex=keyFramesCount-1;
  30067. realTimeCurrentFrameIndexes[i]=frameIndex;
  30068. }
  30069. nextFrameIndex=frameIndex+1;
  30070. while (frameIndex >-1){
  30071. if (keyFrames[frameIndex].time < playCurTime)
  30072. break ;
  30073. frameIndex--;
  30074. nextFrameIndex--;
  30075. realTimeCurrentFrameIndexes[i]=frameIndex;
  30076. }
  30077. };
  30078. var isEnd=nextFrameIndex===keyFramesCount;
  30079. switch (type){
  30080. case 0:
  30081. if (frameIndex!==-1){
  30082. var frame=keyFrames [frameIndex];
  30083. if (isEnd){
  30084. node.data=frame.value;
  30085. }else {
  30086. var nextFarme=keyFrames [nextFrameIndex];
  30087. var d=nextFarme.time-frame.time;
  30088. var t=NaN;
  30089. if (d!==0)
  30090. t=(playCurTime-frame.time)/ d;
  30091. else
  30092. t=0;
  30093. node.data=this._hermiteInterpolate(frame,nextFarme,t,d);
  30094. }
  30095. }else {
  30096. node.data=(keyFrames [0]).value;
  30097. }
  30098. if (addtive)
  30099. node.data-=(keyFrames [0]).value;
  30100. break ;
  30101. case 1:
  30102. case 4:;
  30103. var clipData=node.data;
  30104. this._evaluateFrameNodeVector3DatasRealTime(keyFrames,frameIndex,isEnd,playCurTime,clipData);
  30105. if (addtive){
  30106. var firstFrameValue=(keyFrames [0]).value;
  30107. clipData.x-=firstFrameValue.x;
  30108. clipData.y-=firstFrameValue.y;
  30109. clipData.z-=firstFrameValue.z;
  30110. }
  30111. break ;
  30112. case 2:;
  30113. var clipQuat=node.data;
  30114. this._evaluateFrameNodeQuaternionDatasRealTime(keyFrames,frameIndex,isEnd,playCurTime,clipQuat);
  30115. if (addtive){
  30116. var tempQuat=AnimationClip._tempQuaternion0;
  30117. var firstFrameValueQua=(keyFrames [0]).value;
  30118. Utils3D.quaternionConjugate(firstFrameValueQua,tempQuat);
  30119. Quaternion.multiply(tempQuat,clipQuat,clipQuat);
  30120. }
  30121. break ;
  30122. case 3:
  30123. clipData=node.data;
  30124. this._evaluateFrameNodeVector3DatasRealTime(keyFrames,frameIndex,isEnd,playCurTime,clipData);
  30125. if (addtive){
  30126. firstFrameValue=(keyFrames [0]).value;
  30127. clipData.x /=firstFrameValue.x;
  30128. clipData.y /=firstFrameValue.y;
  30129. clipData.z /=firstFrameValue.z;
  30130. }
  30131. break ;
  30132. default :
  30133. throw "AnimationClip:unknown node type.";
  30134. }
  30135. }
  30136. }
  30137. __proto._evaluateClipDatasRealTimeForNative=function(nodes,playCurTime,realTimeCurrentFrameIndexes,addtive){
  30138. LayaGL.instance.evaluateClipDatasRealTime(nodes._nativeObj,playCurTime,realTimeCurrentFrameIndexes,addtive);
  30139. }
  30140. /**
  30141. *@private
  30142. */
  30143. __proto._evaluateFrameNodeVector3DatasRealTime=function(keyFrames,frameIndex,isEnd,playCurTime,outDatas){
  30144. if (frameIndex!==-1){
  30145. var frame=keyFrames[frameIndex];
  30146. if (isEnd){
  30147. var frameData=frame.value;
  30148. outDatas.x=frameData.x;
  30149. outDatas.y=frameData.y;
  30150. outDatas.z=frameData.z;
  30151. }else {
  30152. var nextKeyFrame=keyFrames[frameIndex+1];
  30153. var t=NaN;
  30154. var startTime=frame.time;
  30155. var d=nextKeyFrame.time-startTime;
  30156. if (d!==0)
  30157. t=(playCurTime-startTime)/ d;
  30158. else
  30159. t=0;
  30160. this._hermiteInterpolateVector3(frame,nextKeyFrame,t,d,outDatas);
  30161. }
  30162. }else {
  30163. var firstFrameDatas=keyFrames[0].value;
  30164. outDatas.x=firstFrameDatas.x;
  30165. outDatas.y=firstFrameDatas.y;
  30166. outDatas.z=firstFrameDatas.z;
  30167. }
  30168. }
  30169. /**
  30170. *@private
  30171. */
  30172. __proto._evaluateFrameNodeQuaternionDatasRealTime=function(keyFrames,frameIndex,isEnd,playCurTime,outDatas){
  30173. if (frameIndex!==-1){
  30174. var frame=keyFrames[frameIndex];
  30175. if (isEnd){
  30176. var frameData=frame.value;
  30177. outDatas.x=frameData.x;
  30178. outDatas.y=frameData.y;
  30179. outDatas.z=frameData.z;
  30180. outDatas.w=frameData.w;
  30181. }else {
  30182. var nextKeyFrame=keyFrames[frameIndex+1];
  30183. var t=NaN;
  30184. var startTime=frame.time;
  30185. var d=nextKeyFrame.time-startTime;
  30186. if (d!==0)
  30187. t=(playCurTime-startTime)/ d;
  30188. else
  30189. t=0;
  30190. this._hermiteInterpolateQuaternion(frame,nextKeyFrame,t,d,outDatas);
  30191. }
  30192. }else {
  30193. var firstFrameDatas=keyFrames[0].value;
  30194. outDatas.x=firstFrameDatas.x;
  30195. outDatas.y=firstFrameDatas.y;
  30196. outDatas.z=firstFrameDatas.z;
  30197. outDatas.w=firstFrameDatas.w;
  30198. }
  30199. }
  30200. /**
  30201. *@private
  30202. */
  30203. __proto._binarySearchEventIndex=function(time){
  30204. var start=0;
  30205. var end=this._events.length-1;
  30206. var mid=0;
  30207. while (start <=end){
  30208. mid=Math.floor((start+end)/ 2);
  30209. var midValue=this._events[mid].time;
  30210. if (midValue==time)
  30211. return mid;
  30212. else if (midValue > time)
  30213. end=mid-1;
  30214. else
  30215. start=mid+1;
  30216. }
  30217. return start;
  30218. }
  30219. /**
  30220. *添加动画事件。
  30221. */
  30222. __proto.addEvent=function(event){
  30223. var index=this._binarySearchEventIndex(event.time);
  30224. this._events.splice(index,0,event);
  30225. }
  30226. /**
  30227. *@inheritDoc
  30228. */
  30229. __proto._disposeResource=function(){
  30230. this._nodes=null;
  30231. this._nodesMap=null;
  30232. }
  30233. AnimationClip._parse=function(data,propertyParams,constructParams){
  30234. var clip=new AnimationClip();
  30235. var reader=new Byte(data);
  30236. var version=reader.readUTFString();
  30237. switch (version){
  30238. case "LAYAANIMATION:03":
  30239. AnimationClipParser03.parse(clip,reader);
  30240. break ;
  30241. case "LAYAANIMATION:04":
  30242. case "LAYAANIMATION:COMPRESSION_04":
  30243. AnimationClipParser04.parse(clip,reader,version);
  30244. break ;
  30245. default :
  30246. throw "unknown animationClip version.";
  30247. }
  30248. return clip;
  30249. }
  30250. AnimationClip.load=function(url,complete){
  30251. Laya.loader.create(url,complete,null,/*Laya3D.ANIMATIONCLIP*/"ANIMATIONCLIP");
  30252. }
  30253. __static(AnimationClip,
  30254. ['_tempQuaternion0',function(){return this._tempQuaternion0=new Quaternion();}
  30255. ]);
  30256. return AnimationClip;
  30257. })(Resource)
  30258. /**
  30259. *@private
  30260. *<code>ShaderInstance</code> 类用于实现ShaderInstance。
  30261. */
  30262. //class laya.d3.shader.ShaderInstance extends laya.resource.Resource
  30263. var ShaderInstance=(function(_super){
  30264. function ShaderInstance(vs,ps,attributeMap,uniformMap,shaderPass){
  30265. /**@private */
  30266. //this._attributeMap=null;
  30267. /**@private */
  30268. //this._uniformMap=null;
  30269. /**@private */
  30270. //this._shaderPass=null;
  30271. /**@private */
  30272. //this._vs=null;
  30273. /**@private */
  30274. //this._ps=null;
  30275. /**@private */
  30276. //this._curActTexIndex=0;
  30277. /**@private */
  30278. //this._vshader=null;
  30279. /**@private */
  30280. //this._pshader=null;
  30281. /**@private */
  30282. //this._program=null;
  30283. /**@private */
  30284. //this._sceneUniformParamsMap=null;
  30285. /**@private */
  30286. //this._cameraUniformParamsMap=null;
  30287. /**@private */
  30288. //this._spriteUniformParamsMap=null;
  30289. /**@private */
  30290. //this._materialUniformParamsMap=null;
  30291. /**@private */
  30292. //this._customUniformParamsMap=null;
  30293. /**@private */
  30294. this._stateParamsMap=[];
  30295. /**@private */
  30296. this._uploadMark=-1;
  30297. /**@private */
  30298. //this._uploadMaterial=null;
  30299. /**@private */
  30300. //this._uploadRender=null;
  30301. /**@private */
  30302. this._uploadRenderType=-1;
  30303. /**@private */
  30304. //this._uploadCamera=null;
  30305. /**@private */
  30306. //this._uploadScene=null;
  30307. ShaderInstance.__super.call(this);
  30308. this._vs=vs;
  30309. this._ps=ps;
  30310. this._attributeMap=attributeMap;
  30311. this._uniformMap=uniformMap;
  30312. this._shaderPass=shaderPass;
  30313. this._create();
  30314. this.lock=true;
  30315. }
  30316. __class(ShaderInstance,'laya.d3.shader.ShaderInstance',_super);
  30317. var __proto=ShaderInstance.prototype;
  30318. /**
  30319. *@private
  30320. */
  30321. __proto._create=function(){
  30322. var gl=LayaGL.instance;
  30323. this._program=gl.createProgram();
  30324. this._vshader=this._createShader(gl,this._vs,/*laya.webgl.WebGLContext.VERTEX_SHADER*/0x8B31);
  30325. this._pshader=this._createShader(gl,this._ps,/*laya.webgl.WebGLContext.FRAGMENT_SHADER*/0x8B30);
  30326. gl.attachShader(this._program,this._vshader);
  30327. gl.attachShader(this._program,this._pshader);
  30328. for (var k in this._attributeMap)
  30329. gl.bindAttribLocation(this._program,this._attributeMap[k],k);
  30330. gl.linkProgram(this._program);
  30331. if (!Render.isConchApp && Shader3D.debugMode && !gl.getProgramParameter(this._program,/*laya.webgl.WebGLContext.LINK_STATUS*/0x8B82))
  30332. throw gl.getProgramInfoLog(this._program);
  30333. var sceneParms=[];
  30334. var cameraParms=[];
  30335. var spriteParms=[];
  30336. var materialParms=[];
  30337. var customParms=[];
  30338. this._customUniformParamsMap=[];
  30339. var nUniformNum=gl.getProgramParameter(this._program,/*laya.webgl.WebGLContext.ACTIVE_UNIFORMS*/0x8B86);
  30340. WebGLContext.useProgram(gl,this._program);
  30341. this._curActTexIndex=0;
  30342. var one,i=0,n=0;
  30343. for (i=0;i < nUniformNum;i++){
  30344. var uniformData=gl.getActiveUniform(this._program,i);
  30345. var uniName=uniformData.name;
  30346. one=new ShaderVariable();
  30347. one.location=gl.getUniformLocation(this._program,uniName);
  30348. if (uniName.indexOf('[0]')> 0){
  30349. one.name=uniName=uniName.substr(0,uniName.length-3);
  30350. one.isArray=true;
  30351. }else {
  30352. one.name=uniName;
  30353. one.isArray=false;
  30354. }
  30355. one.type=uniformData.type;
  30356. this._addShaderUnifiormFun(one);
  30357. var uniformPeriod=this._uniformMap[uniName];
  30358. if (uniformPeriod !=null){
  30359. one.dataOffset=Shader3D.propertyNameToID(uniName);
  30360. switch (uniformPeriod){
  30361. case /*laya.d3.shader.Shader3D.PERIOD_CUSTOM*/0:
  30362. customParms.push(one);
  30363. break ;
  30364. case /*laya.d3.shader.Shader3D.PERIOD_MATERIAL*/1:
  30365. materialParms.push(one);
  30366. break ;
  30367. case /*laya.d3.shader.Shader3D.PERIOD_SPRITE*/2:
  30368. spriteParms.push(one);
  30369. break ;
  30370. case /*laya.d3.shader.Shader3D.PERIOD_CAMERA*/3:
  30371. cameraParms.push(one);
  30372. break ;
  30373. case /*laya.d3.shader.Shader3D.PERIOD_SCENE*/4:
  30374. sceneParms.push(one);
  30375. break ;
  30376. default :
  30377. throw new Error("Shader3D: period is unkonw.");
  30378. }
  30379. }
  30380. }
  30381. this._sceneUniformParamsMap=LayaGL.instance.createCommandEncoder(sceneParms.length *4 *5+4,64,true);
  30382. for (i=0,n=sceneParms.length;i < n;i++)
  30383. this._sceneUniformParamsMap.addShaderUniform(sceneParms[i]);
  30384. this._cameraUniformParamsMap=LayaGL.instance.createCommandEncoder(cameraParms.length *4 *5+4,64,true);
  30385. for (i=0,n=cameraParms.length;i < n;i++)
  30386. this._cameraUniformParamsMap.addShaderUniform(cameraParms[i]);
  30387. this._spriteUniformParamsMap=LayaGL.instance.createCommandEncoder(spriteParms.length *4 *5+4,64,true);
  30388. for (i=0,n=spriteParms.length;i < n;i++)
  30389. this._spriteUniformParamsMap.addShaderUniform(spriteParms[i]);
  30390. this._materialUniformParamsMap=LayaGL.instance.createCommandEncoder(materialParms.length *4 *5+4,64,true);
  30391. for (i=0,n=materialParms.length;i < n;i++)
  30392. this._materialUniformParamsMap.addShaderUniform(materialParms[i]);
  30393. this._customUniformParamsMap.length=customParms.length;
  30394. for (i=0,n=customParms.length;i < n;i++){
  30395. var custom=customParms[i];
  30396. this._customUniformParamsMap[custom.dataOffset]=custom;
  30397. };
  30398. var stateMap=this._shaderPass._stateMap;
  30399. for (var s in stateMap)
  30400. this._stateParamsMap[stateMap[s]]=Shader3D.propertyNameToID(s);
  30401. }
  30402. /**
  30403. *@private
  30404. */
  30405. __proto._getRenderState=function(shaderDatas,stateIndex){
  30406. var stateID=this._stateParamsMap[stateIndex];
  30407. if (stateID==null)
  30408. return null;
  30409. else
  30410. return shaderDatas[stateID];
  30411. }
  30412. /**
  30413. *@inheritDoc
  30414. */
  30415. __proto._disposeResource=function(){
  30416. LayaGL.instance.deleteShader(this._vshader);
  30417. LayaGL.instance.deleteShader(this._pshader);
  30418. LayaGL.instance.deleteProgram(this._program);
  30419. this._vshader=this._pshader=this._program=null;
  30420. this._setGPUMemory(0);
  30421. this._curActTexIndex=0;
  30422. }
  30423. /**
  30424. *@private
  30425. */
  30426. __proto._addShaderUnifiormFun=function(one){
  30427. var gl=LayaGL.instance;
  30428. one.caller=this;
  30429. var isArray=one.isArray;
  30430. switch (one.type){
  30431. case /*laya.webgl.WebGLContext.BOOL*/0x8B56:
  30432. one.fun=this._uniform1i;
  30433. one.uploadedValue=new Array(1);
  30434. break ;
  30435. case /*laya.webgl.WebGLContext.INT*/0x1404:
  30436. one.fun=isArray ? this._uniform1iv :this._uniform1i;
  30437. one.uploadedValue=new Array(1);
  30438. break ;
  30439. case /*laya.webgl.WebGLContext.FLOAT*/0x1406:
  30440. one.fun=isArray ? this._uniform1fv :this._uniform1f;
  30441. one.uploadedValue=new Array(1);
  30442. break ;
  30443. case /*laya.webgl.WebGLContext.FLOAT_VEC2*/0x8B50:
  30444. one.fun=isArray ? this._uniform_vec2v :this._uniform_vec2;
  30445. one.uploadedValue=new Array(2);
  30446. break ;
  30447. case /*laya.webgl.WebGLContext.FLOAT_VEC3*/0x8B51:
  30448. one.fun=isArray ? this._uniform_vec3v :this._uniform_vec3;
  30449. one.uploadedValue=new Array(3);
  30450. break ;
  30451. case /*laya.webgl.WebGLContext.FLOAT_VEC4*/0x8B52:
  30452. one.fun=isArray ? this._uniform_vec4v :this._uniform_vec4;
  30453. one.uploadedValue=new Array(4);
  30454. break ;
  30455. case /*laya.webgl.WebGLContext.FLOAT_MAT2*/0x8B5A:
  30456. one.fun=this._uniformMatrix2fv;
  30457. break ;
  30458. case /*laya.webgl.WebGLContext.FLOAT_MAT3*/0x8B5B:
  30459. one.fun=this._uniformMatrix3fv;
  30460. break ;
  30461. case /*laya.webgl.WebGLContext.FLOAT_MAT4*/0x8B5C:
  30462. one.fun=isArray ? this._uniformMatrix4fv :this._uniformMatrix4f;
  30463. break ;
  30464. case /*laya.webgl.WebGLContext.SAMPLER_2D*/0x8B5E:
  30465. gl.uniform1i(one.location,this._curActTexIndex);
  30466. one.textureID=WebGLContext._glTextureIDs[this._curActTexIndex++];
  30467. one.fun=this._uniform_sampler2D;
  30468. break ;
  30469. case 0x8b5f:
  30470. gl.uniform1i(one.location,this._curActTexIndex);
  30471. one.textureID=WebGLContext._glTextureIDs[this._curActTexIndex++];
  30472. one.fun=this._uniform_sampler3D;
  30473. break ;
  30474. case /*laya.webgl.WebGLContext.SAMPLER_CUBE*/0x8B60:
  30475. gl.uniform1i(one.location,this._curActTexIndex);
  30476. one.textureID=WebGLContext._glTextureIDs[this._curActTexIndex++];
  30477. one.fun=this._uniform_samplerCube;
  30478. break ;
  30479. default :
  30480. throw new Error("compile shader err!");
  30481. break ;
  30482. }
  30483. }
  30484. /**
  30485. *@private
  30486. */
  30487. __proto._createShader=function(gl,str,type){
  30488. var shader=gl.createShader(type);
  30489. gl.shaderSource(shader,str);
  30490. gl.compileShader(shader);
  30491. if (Shader3D.debugMode && !gl.getShaderParameter(shader,/*laya.webgl.WebGLContext.COMPILE_STATUS*/0x8B81))
  30492. throw gl.getShaderInfoLog(shader);
  30493. return shader;
  30494. }
  30495. /**
  30496. *@private
  30497. */
  30498. __proto._uniform1f=function(one,value){
  30499. var uploadedValue=one.uploadedValue;
  30500. if (uploadedValue[0]!==value){
  30501. LayaGL.instance.uniform1f(one.location,uploadedValue[0]=value);
  30502. return 1;
  30503. }
  30504. return 0;
  30505. }
  30506. /**
  30507. *@private
  30508. */
  30509. __proto._uniform1fv=function(one,value){
  30510. if (value.length < 4){
  30511. var uploadedValue=one.uploadedValue;
  30512. if (uploadedValue[0]!==value[0] || uploadedValue[1]!==value[1] || uploadedValue[2]!==value[2] || uploadedValue[3]!==value[3]){
  30513. LayaGL.instance.uniform1fv(one.location,value);
  30514. uploadedValue[0]=value[0];
  30515. uploadedValue[1]=value[1];
  30516. uploadedValue[2]=value[2];
  30517. uploadedValue[3]=value[3];
  30518. return 1;
  30519. }
  30520. return 0;
  30521. }else {
  30522. LayaGL.instance.uniform1fv(one.location,value);
  30523. return 1;
  30524. }
  30525. }
  30526. /**
  30527. *@private
  30528. */
  30529. __proto._uniform_vec2=function(one,v){
  30530. var uploadedValue=one.uploadedValue;
  30531. if (uploadedValue[0]!==v.x || uploadedValue[1]!==v.y){
  30532. LayaGL.instance.uniform2f(one.location,uploadedValue[0]=v.x,uploadedValue[1]=v.y);
  30533. return 1;
  30534. }
  30535. return 0;
  30536. }
  30537. /**
  30538. *@private
  30539. */
  30540. __proto._uniform_vec2v=function(one,value){
  30541. if (value.length < 2){
  30542. var uploadedValue=one.uploadedValue;
  30543. if (uploadedValue[0]!==value[0] || uploadedValue[1]!==value[1] || uploadedValue[2]!==value[2] || uploadedValue[3]!==value[3]){
  30544. LayaGL.instance.uniform2fv(one.location,value);
  30545. uploadedValue[0]=value[0];
  30546. uploadedValue[1]=value[1];
  30547. uploadedValue[2]=value[2];
  30548. uploadedValue[3]=value[3];
  30549. return 1;
  30550. }
  30551. return 0;
  30552. }else {
  30553. LayaGL.instance.uniform2fv(one.location,value);
  30554. return 1;
  30555. }
  30556. }
  30557. /**
  30558. *@private
  30559. */
  30560. __proto._uniform_vec3=function(one,v){
  30561. var uploadedValue=one.uploadedValue;
  30562. if (uploadedValue[0]!==v.x || uploadedValue[1]!==v.y || uploadedValue[2]!==v.z){
  30563. LayaGL.instance.uniform3f(one.location,uploadedValue[0]=v.x,uploadedValue[1]=v.y,uploadedValue[2]=v.z);
  30564. return 1;
  30565. }
  30566. return 0;
  30567. }
  30568. /**
  30569. *@private
  30570. */
  30571. __proto._uniform_vec3v=function(one,v){
  30572. LayaGL.instance.uniform3fv(one.location,v);
  30573. return 1;
  30574. }
  30575. /**
  30576. *@private
  30577. */
  30578. __proto._uniform_vec4=function(one,v){
  30579. var uploadedValue=one.uploadedValue;
  30580. if (uploadedValue[0]!==v.x || uploadedValue[1]!==v.y || uploadedValue[2]!==v.z || uploadedValue[3]!==v.w){
  30581. LayaGL.instance.uniform4f(one.location,uploadedValue[0]=v.x,uploadedValue[1]=v.y,uploadedValue[2]=v.z,uploadedValue[3]=v.w);
  30582. return 1;
  30583. }
  30584. return 0;
  30585. }
  30586. /**
  30587. *@private
  30588. */
  30589. __proto._uniform_vec4v=function(one,v){
  30590. LayaGL.instance.uniform4fv(one.location,v);
  30591. return 1;
  30592. }
  30593. /**
  30594. *@private
  30595. */
  30596. __proto._uniformMatrix2fv=function(one,value){
  30597. LayaGL.instance.uniformMatrix2fv(one.location,false,value);
  30598. return 1;
  30599. }
  30600. /**
  30601. *@private
  30602. */
  30603. __proto._uniformMatrix3fv=function(one,value){
  30604. LayaGL.instance.uniformMatrix3fv(one.location,false,value);
  30605. return 1;
  30606. }
  30607. /**
  30608. *@private
  30609. */
  30610. __proto._uniformMatrix4f=function(one,m){
  30611. var value=m.elements;
  30612. LayaGL.instance.uniformMatrix4fv(one.location,false,value);
  30613. return 1;
  30614. }
  30615. /**
  30616. *@private
  30617. */
  30618. __proto._uniformMatrix4fv=function(one,m){
  30619. LayaGL.instance.uniformMatrix4fv(one.location,false,m);
  30620. return 1;
  30621. }
  30622. /**
  30623. *@private
  30624. */
  30625. __proto._uniform1i=function(one,value){
  30626. var uploadedValue=one.uploadedValue;
  30627. if (uploadedValue[0]!==value){
  30628. LayaGL.instance.uniform1i(one.location,uploadedValue[0]=value);
  30629. return 1;
  30630. }
  30631. return 0;
  30632. }
  30633. /**
  30634. *@private
  30635. */
  30636. __proto._uniform1iv=function(one,value){
  30637. LayaGL.instance.uniform1iv(one.location,value);
  30638. return 1;
  30639. }
  30640. /**
  30641. *@private
  30642. */
  30643. __proto._uniform_ivec2=function(one,value){
  30644. var uploadedValue=one.uploadedValue;
  30645. if (uploadedValue[0]!==value[0] || uploadedValue[1]!==value[1]){
  30646. LayaGL.instance.uniform2i(one.location,uploadedValue[0]=value[0],uploadedValue[1]=value[1]);
  30647. return 1;
  30648. }
  30649. return 0;
  30650. }
  30651. /**
  30652. *@private
  30653. */
  30654. __proto._uniform_ivec2v=function(one,value){
  30655. LayaGL.instance.uniform2iv(one.location,value);
  30656. return 1;
  30657. }
  30658. /**
  30659. *@private
  30660. */
  30661. __proto._uniform_vec3i=function(one,value){
  30662. var uploadedValue=one.uploadedValue;
  30663. if (uploadedValue[0]!==value[0] || uploadedValue[1]!==value[1] || uploadedValue[2]!==value[2]){
  30664. LayaGL.instance.uniform3i(one.location,uploadedValue[0]=value[0],uploadedValue[1]=value[1],uploadedValue[2]=value[2]);
  30665. return 1;
  30666. }
  30667. return 0;
  30668. }
  30669. /**
  30670. *@private
  30671. */
  30672. __proto._uniform_vec3vi=function(one,value){
  30673. LayaGL.instance.uniform3iv(one.location,value);
  30674. return 1;
  30675. }
  30676. /**
  30677. *@private
  30678. */
  30679. __proto._uniform_vec4i=function(one,value){
  30680. var uploadedValue=one.uploadedValue;
  30681. if (uploadedValue[0]!==value[0] || uploadedValue[1]!==value[1] || uploadedValue[2]!==value[2] || uploadedValue[3]!==value[3]){
  30682. LayaGL.instance.uniform4i(one.location,uploadedValue[0]=value[0],uploadedValue[1]=value[1],uploadedValue[2]=value[2],uploadedValue[3]=value[3]);
  30683. return 1;
  30684. }
  30685. return 0;
  30686. }
  30687. /**
  30688. *@private
  30689. */
  30690. __proto._uniform_vec4vi=function(one,value){
  30691. LayaGL.instance.uniform4iv(one.location,value);
  30692. return 1;
  30693. }
  30694. /**
  30695. *@private
  30696. */
  30697. __proto._uniform_sampler2D=function(one,texture){
  30698. var value=texture._getSource()|| texture.defaulteTexture._getSource();
  30699. var gl=LayaGL.instance;
  30700. WebGLContext.activeTexture(gl,one.textureID);
  30701. WebGLContext.bindTexture(gl,/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,value);
  30702. return 0;
  30703. }
  30704. __proto._uniform_sampler3D=function(one,texture){
  30705. var value=texture._getSource()|| texture.defaulteTexture._getSource();
  30706. var gl=LayaGL.instance;
  30707. WebGLContext.activeTexture(gl,one.textureID);
  30708. WebGLContext.bindTexture(gl,/*laya.webgl.WebGLContext.TEXTURE_3D*/0x806f,value);
  30709. return 0;
  30710. }
  30711. /**
  30712. *@private
  30713. */
  30714. __proto._uniform_samplerCube=function(one,texture){
  30715. var value=texture._getSource()|| texture.defaulteTexture._getSource();
  30716. var gl=LayaGL.instance;
  30717. WebGLContext.activeTexture(gl,one.textureID);
  30718. WebGLContext.bindTexture(gl,/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP*/0x8513,value);
  30719. return 0;
  30720. }
  30721. /**
  30722. *@private
  30723. */
  30724. __proto.bind=function(){
  30725. return WebGLContext.useProgram(LayaGL.instance,this._program);
  30726. }
  30727. /**
  30728. *@private
  30729. */
  30730. __proto.uploadUniforms=function(shaderUniform,shaderDatas,uploadUnTexture){
  30731. Stat.shaderCall+=LayaGLRunner.uploadShaderUniforms(LayaGL.instance,shaderUniform,shaderDatas,uploadUnTexture);
  30732. }
  30733. /**
  30734. *@private
  30735. */
  30736. __proto.uploadRenderStateBlendDepth=function(shaderDatas){
  30737. var gl=LayaGL.instance;
  30738. var renderState=this._shaderPass.renderState;
  30739. var datas=shaderDatas.getData();
  30740. var depthWrite=this._getRenderState(datas,/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_WRITE*/13);
  30741. var depthTest=this._getRenderState(datas,/*laya.d3.shader.Shader3D.RENDER_STATE_DEPTH_TEST*/12);
  30742. var blend=this._getRenderState(datas,/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND*/1);
  30743. depthWrite==null && (depthWrite=renderState.depthWrite);
  30744. depthTest==null && (depthTest=renderState.depthTest);
  30745. blend==null && (blend=renderState.blend);
  30746. WebGLContext.setDepthMask(gl,depthWrite);
  30747. if (depthTest===/*laya.d3.core.material.RenderState.DEPTHTEST_OFF*/0)
  30748. WebGLContext.setDepthTest(gl,false);
  30749. else {
  30750. WebGLContext.setDepthTest(gl,true);
  30751. WebGLContext.setDepthFunc(gl,depthTest);
  30752. }
  30753. switch (blend){
  30754. case /*laya.d3.core.material.RenderState.BLEND_DISABLE*/0:
  30755. WebGLContext.setBlend(gl,false);
  30756. break ;
  30757. case /*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1:
  30758. WebGLContext.setBlend(gl,true);
  30759. var srcBlend=this._getRenderState(datas,/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_SRC*/2);
  30760. srcBlend==null && (srcBlend=renderState.srcBlend);
  30761. var dstBlend=this._getRenderState(datas,/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_DST*/3);
  30762. dstBlend==null && (dstBlend=renderState.dstBlend);
  30763. WebGLContext.setBlendFunc(gl,srcBlend,dstBlend);
  30764. break ;
  30765. case /*laya.d3.core.material.RenderState.BLEND_ENABLE_SEPERATE*/2:
  30766. WebGLContext.setBlend(gl,true);
  30767. var srcRGB=this._getRenderState(datas,/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_SRC_RGB*/4);
  30768. srcRGB==null && (srcRGB=renderState.srcBlendRGB);
  30769. var dstRGB=this._getRenderState(datas,/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_DST_RGB*/5);
  30770. dstRGB==null && (dstRGB=renderState.dstBlendRGB);
  30771. var srcAlpha=this._getRenderState(datas,/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_SRC_ALPHA*/6);
  30772. srcAlpha==null && (srcAlpha=renderState.srcBlendAlpha);
  30773. var dstAlpha=this._getRenderState(datas,/*laya.d3.shader.Shader3D.RENDER_STATE_BLEND_DST_ALPHA*/7);
  30774. dstAlpha==null && (dstAlpha=renderState.dstBlendAlpha);
  30775. WebGLContext.setBlendFuncSeperate(gl,srcRGB,dstRGB,srcAlpha,dstAlpha);
  30776. break ;
  30777. }
  30778. }
  30779. /**
  30780. *@private
  30781. */
  30782. __proto.uploadRenderStateFrontFace=function(shaderDatas,isTarget,transform){
  30783. var gl=LayaGL.instance;
  30784. var renderState=this._shaderPass.renderState;
  30785. var datas=shaderDatas.getData();
  30786. var cull=this._getRenderState(datas,/*laya.d3.shader.Shader3D.RENDER_STATE_CULL*/0);
  30787. cull==null && (cull=renderState.cull);
  30788. var forntFace=0;
  30789. switch (cull){
  30790. case /*laya.d3.core.material.RenderState.CULL_NONE*/0:
  30791. WebGLContext.setCullFace(gl,false);
  30792. break ;
  30793. case /*laya.d3.core.material.RenderState.CULL_FRONT*/1:
  30794. WebGLContext.setCullFace(gl,true);
  30795. if (isTarget){
  30796. if (transform && transform._isFrontFaceInvert)
  30797. forntFace=/*laya.webgl.WebGLContext.CCW*/0x0901;
  30798. else
  30799. forntFace=/*laya.webgl.WebGLContext.CW*/0x0900;
  30800. }else {
  30801. if (transform && transform._isFrontFaceInvert)
  30802. forntFace=/*laya.webgl.WebGLContext.CW*/0x0900;
  30803. else
  30804. forntFace=/*laya.webgl.WebGLContext.CCW*/0x0901;
  30805. }
  30806. WebGLContext.setFrontFace(gl,forntFace);
  30807. break ;
  30808. case /*laya.d3.core.material.RenderState.CULL_BACK*/2:
  30809. WebGLContext.setCullFace(gl,true);
  30810. if (isTarget){
  30811. if (transform && transform._isFrontFaceInvert)
  30812. forntFace=/*laya.webgl.WebGLContext.CW*/0x0900;
  30813. else
  30814. forntFace=/*laya.webgl.WebGLContext.CCW*/0x0901;
  30815. }else {
  30816. if (transform && transform._isFrontFaceInvert)
  30817. forntFace=/*laya.webgl.WebGLContext.CCW*/0x0901;
  30818. else
  30819. forntFace=/*laya.webgl.WebGLContext.CW*/0x0900;
  30820. }
  30821. WebGLContext.setFrontFace(gl,forntFace);
  30822. break ;
  30823. }
  30824. }
  30825. /**
  30826. *@private
  30827. */
  30828. __proto.uploadCustomUniform=function(index,data){
  30829. Stat.shaderCall+=LayaGLRunner.uploadCustomUniform(LayaGL.instance,this._customUniformParamsMap,index,data);
  30830. }
  30831. /**
  30832. *@private
  30833. *[NATIVE]
  30834. */
  30835. __proto._uniformMatrix2fvForNative=function(one,value){
  30836. LayaGL.instance.uniformMatrix2fvEx(one.location,false,value);
  30837. return 1;
  30838. }
  30839. /**
  30840. *@private
  30841. *[NATIVE]
  30842. */
  30843. __proto._uniformMatrix3fvForNative=function(one,value){
  30844. LayaGL.instance.uniformMatrix3fvEx(one.location,false,value);
  30845. return 1;
  30846. }
  30847. /**
  30848. *@private
  30849. *[NATIVE]
  30850. */
  30851. __proto._uniformMatrix4fvForNative=function(one,m){
  30852. LayaGL.instance.uniformMatrix4fvEx(one.location,false,m);
  30853. return 1;
  30854. }
  30855. return ShaderInstance;
  30856. })(Resource)
  30857. /**
  30858. *<code>TerrainHeightData</code> 类用于描述地形高度信息。
  30859. */
  30860. //class laya.d3.terrain.TerrainHeightData extends laya.resource.Resource
  30861. var TerrainHeightData=(function(_super){
  30862. function TerrainHeightData(width,height,bitType,value){
  30863. this._terrainHeightData=null;
  30864. this._width=0;
  30865. this._height=0;
  30866. this._bitType=0;
  30867. this._value=NaN;
  30868. TerrainHeightData.__super.call(this);
  30869. this._width=width;
  30870. this._height=height;
  30871. this._bitType=bitType;
  30872. this._value=value;
  30873. }
  30874. __class(TerrainHeightData,'laya.d3.terrain.TerrainHeightData',_super);
  30875. TerrainHeightData._pharse=function(data,propertyParams,constructParams){
  30876. var terrainHeightData=new TerrainHeightData(constructParams[0],constructParams[1],constructParams[2],constructParams[3]);
  30877. var buffer;
  30878. var ratio=NaN;
  30879. if (terrainHeightData._bitType==8){
  30880. buffer=new Uint8Array(data);
  30881. ratio=1.0 / 255.0;
  30882. }else if (terrainHeightData._bitType==16){
  30883. buffer=new Int16Array(data);
  30884. ratio=1.0 / 32766.0;
  30885. }
  30886. terrainHeightData._terrainHeightData=new Float32Array(terrainHeightData._height *terrainHeightData._width);
  30887. for (var i=0,n=terrainHeightData._height *terrainHeightData._width;i < n;i++){
  30888. terrainHeightData._terrainHeightData[i]=(buffer[i] *ratio *terrainHeightData._value)/ 2;
  30889. }
  30890. }
  30891. TerrainHeightData.load=function(url,complete,widht,height,bitType,value){
  30892. Laya.loader.create(url,complete,null,/*Laya3D.TERRAINHEIGHTDATA*/"TERRAINHEIGHTDATA",[widht,height,bitType,value],null,1,false);
  30893. }
  30894. return TerrainHeightData;
  30895. })(Resource)
  30896. /**
  30897. *<code>ScreenQuad</code> 类用于创建全屏四边形。
  30898. */
  30899. //class laya.d3.core.render.ScreenQuad extends laya.resource.Resource
  30900. var ScreenQuad=(function(_super){
  30901. function ScreenQuad(){
  30902. /**@private */
  30903. this._vertexBuffer=null;
  30904. ScreenQuad.__super.call(this);
  30905. this._bufferState=new BufferState();
  30906. this._vertexBuffer=new VertexBuffer3D(16 *4,/*laya.webgl.WebGLContext.STATIC_DRAW*/0x88E4,false);
  30907. this._vertexBuffer.vertexDeclaration=laya.d3.core.render.ScreenQuad._vertexDeclaration;
  30908. this._vertexBuffer.setData(ScreenQuad._vertices);
  30909. this._bufferState.bind();
  30910. this._bufferState.applyVertexBuffer(this._vertexBuffer);
  30911. this._bufferState.unBind();
  30912. this._setGPUMemory(this._vertexBuffer._byteLength);
  30913. }
  30914. __class(ScreenQuad,'laya.d3.core.render.ScreenQuad',_super);
  30915. var __proto=ScreenQuad.prototype;
  30916. /**
  30917. *@private
  30918. */
  30919. __proto.render=function(){
  30920. this._bufferState.bind();
  30921. LayaGL.instance.drawArrays(/*laya.webgl.WebGLContext.TRIANGLE_STRIP*/0x0005,0,4);
  30922. Stat.renderBatches++;
  30923. }
  30924. /**
  30925. *@inheritDoc
  30926. */
  30927. __proto.destroy=function(){
  30928. _super.prototype.destroy.call(this);
  30929. this._bufferState.destroy();
  30930. this._vertexBuffer.destroy();
  30931. this._setGPUMemory(0);
  30932. }
  30933. ScreenQuad.__init__=function(){
  30934. ScreenQuad.instance=new ScreenQuad();
  30935. ScreenQuad.instance.lock=true;
  30936. }
  30937. ScreenQuad.SCREENQUAD_POSITION_UV=0;
  30938. ScreenQuad.instance=null;
  30939. __static(ScreenQuad,
  30940. ['_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]);}
  30941. ]);
  30942. return ScreenQuad;
  30943. })(Resource)
  30944. /**
  30945. *<code>MeshRenderer</code> 类用于网格渲染器。
  30946. */
  30947. //class laya.d3.core.MeshRenderer extends laya.d3.core.render.BaseRender
  30948. var MeshRenderer=(function(_super){
  30949. function MeshRenderer(owner){
  30950. /**@private */
  30951. //this._oriDefineValue=0;
  30952. /**@private */
  30953. //this._projectionViewWorldMatrix=null;
  30954. MeshRenderer.__super.call(this,owner);
  30955. this._projectionViewWorldMatrix=new Matrix4x4();
  30956. }
  30957. __class(MeshRenderer,'laya.d3.core.MeshRenderer',_super);
  30958. var __proto=MeshRenderer.prototype;
  30959. /**
  30960. *@private
  30961. */
  30962. __proto._onMeshChange=function(mesh){
  30963. this._boundsChange=true;
  30964. }
  30965. /**
  30966. *@inheritDoc
  30967. */
  30968. __proto._calculateBoundingBox=function(){
  30969. var sharedMesh=(this._owner).meshFilter.sharedMesh;
  30970. if (sharedMesh){
  30971. var worldMat=(this._owner).transform.worldMatrix;
  30972. sharedMesh.bounds._tranform(worldMat,this._bounds);
  30973. }
  30974. if (Render.supportWebGLPlusCulling){
  30975. var min=this._bounds.getMin();
  30976. var max=this._bounds.getMax();
  30977. var buffer=FrustumCulling._cullingBuffer;
  30978. buffer[this._cullingBufferIndex+1]=min.x;
  30979. buffer[this._cullingBufferIndex+2]=min.y;
  30980. buffer[this._cullingBufferIndex+3]=min.z;
  30981. buffer[this._cullingBufferIndex+4]=max.x;
  30982. buffer[this._cullingBufferIndex+5]=max.y;
  30983. buffer[this._cullingBufferIndex+6]=max.z;
  30984. }
  30985. }
  30986. /**
  30987. *@private
  30988. */
  30989. __proto._changeRenderObjectsByMesh=function(mesh){
  30990. var count=mesh.subMeshCount;
  30991. this._renderElements.length=count;
  30992. for (var i=0;i < count;i++){
  30993. var renderElement=this._renderElements[i];
  30994. if (!renderElement){
  30995. var material=this.sharedMaterials[i];
  30996. renderElement=this._renderElements[i]=new SubMeshRenderElement();
  30997. renderElement.setTransform(this._owner._transform);
  30998. renderElement.render=this;
  30999. renderElement.material=material ? material :BlinnPhongMaterial.defaultMaterial;
  31000. }
  31001. renderElement.setGeometry(mesh._getSubMesh(i));
  31002. }
  31003. }
  31004. /**
  31005. *@inheritDoc
  31006. */
  31007. __proto._needRender=function(boundFrustum){
  31008. if (boundFrustum)
  31009. return boundFrustum.containsBoundBox(this.bounds._getBoundBox())!==/*laya.d3.math.ContainmentType.Disjoint*/0;
  31010. else
  31011. return true;
  31012. }
  31013. /**
  31014. *@inheritDoc
  31015. */
  31016. __proto._renderUpdate=function(context,transform){
  31017. var element=context.renderElement;
  31018. switch (element.renderType){
  31019. case /*laya.d3.core.render.RenderElement.RENDERTYPE_NORMAL*/0:
  31020. this._shaderValues.setMatrix4x4(Sprite3D.WORLDMATRIX,transform.worldMatrix);
  31021. break ;
  31022. case /*laya.d3.core.render.RenderElement.RENDERTYPE_STATICBATCH*/1:
  31023. this._oriDefineValue=this._defineDatas.value;
  31024. if (transform)
  31025. this._shaderValues.setMatrix4x4(Sprite3D.WORLDMATRIX,transform.worldMatrix);
  31026. else
  31027. this._shaderValues.setMatrix4x4(Sprite3D.WORLDMATRIX,Matrix4x4.DEFAULT);
  31028. this._defineDatas.add(MeshSprite3D.SHADERDEFINE_UV1);
  31029. this._defineDatas.remove(RenderableSprite3D.SHADERDEFINE_SCALEOFFSETLIGHTINGMAPUV);
  31030. break ;
  31031. case /*laya.d3.core.render.RenderElement.RENDERTYPE_VERTEXBATCH*/3:
  31032. this._shaderValues.setMatrix4x4(Sprite3D.WORLDMATRIX,Matrix4x4.DEFAULT);
  31033. break ;
  31034. case /*laya.d3.core.render.RenderElement.RENDERTYPE_INSTANCEBATCH*/2:;
  31035. var worldMatrixData=SubMeshInstanceBatch.instance.instanceWorldMatrixData;
  31036. var insBatches=element.instanceBatchElementList;
  31037. var count=insBatches.length;
  31038. for (var i=0;i < count;i++)
  31039. worldMatrixData.set(insBatches[i]._transform.worldMatrix.elements,i *16);
  31040. SubMeshInstanceBatch.instance.instanceWorldMatrixBuffer.setData(worldMatrixData,0,0,count *16);
  31041. this._defineDatas.add(MeshSprite3D.SHADERDEFINE_GPU_INSTANCE);
  31042. break ;
  31043. }
  31044. }
  31045. /**
  31046. *@inheritDoc
  31047. */
  31048. __proto._renderUpdateWithCamera=function(context,transform){
  31049. var projectionView=context.projectionViewMatrix;
  31050. var element=context.renderElement;
  31051. switch (element.renderType){
  31052. case /*laya.d3.core.render.RenderElement.RENDERTYPE_NORMAL*/0:
  31053. case /*laya.d3.core.render.RenderElement.RENDERTYPE_STATICBATCH*/1:
  31054. case /*laya.d3.core.render.RenderElement.RENDERTYPE_VERTEXBATCH*/3:
  31055. if (transform){
  31056. Matrix4x4.multiply(projectionView,transform.worldMatrix,this._projectionViewWorldMatrix);
  31057. this._shaderValues.setMatrix4x4(Sprite3D.MVPMATRIX,this._projectionViewWorldMatrix);
  31058. }else {
  31059. this._shaderValues.setMatrix4x4(Sprite3D.MVPMATRIX,projectionView);
  31060. }
  31061. break ;
  31062. case /*laya.d3.core.render.RenderElement.RENDERTYPE_INSTANCEBATCH*/2:;
  31063. var mvpMatrixData=SubMeshInstanceBatch.instance.instanceMVPMatrixData;
  31064. var insBatches=element.instanceBatchElementList;
  31065. var count=insBatches.length;
  31066. for (var i=0;i < count;i++){
  31067. var worldMat=insBatches[i]._transform.worldMatrix;
  31068. Utils3D.mulMatrixByArray(projectionView.elements,0,worldMat.elements,0,mvpMatrixData,i *16);
  31069. }
  31070. SubMeshInstanceBatch.instance.instanceMVPMatrixBuffer.setData(mvpMatrixData,0,0,count *16);
  31071. break ;
  31072. }
  31073. }
  31074. /**
  31075. *@inheritDoc
  31076. */
  31077. __proto._renderUpdateWithCameraForNative=function(context,transform){
  31078. var projectionView=context.projectionViewMatrix;
  31079. var element=context.renderElement;
  31080. switch (element.renderType){
  31081. case /*laya.d3.core.render.RenderElement.RENDERTYPE_NORMAL*/0:
  31082. if (transform){
  31083. Matrix4x4.multiply(projectionView,transform.worldMatrix,this._projectionViewWorldMatrix);
  31084. this._shaderValues.setMatrix4x4(Sprite3D.MVPMATRIX,this._projectionViewWorldMatrix);
  31085. }else {
  31086. this._shaderValues.setMatrix4x4(Sprite3D.MVPMATRIX,projectionView);
  31087. }
  31088. break ;
  31089. case /*laya.d3.core.render.RenderElement.RENDERTYPE_STATICBATCH*/1:
  31090. case /*laya.d3.core.render.RenderElement.RENDERTYPE_VERTEXBATCH*/3:;
  31091. var noteValue=ShaderData._SET_RUNTIME_VALUE_MODE_REFERENCE_;
  31092. ShaderData.setRuntimeValueMode(false);
  31093. if (transform){
  31094. Matrix4x4.multiply(projectionView,transform.worldMatrix,this._projectionViewWorldMatrix);
  31095. this._shaderValues.setMatrix4x4(Sprite3D.MVPMATRIX,this._projectionViewWorldMatrix);
  31096. }else {
  31097. this._shaderValues.setMatrix4x4(Sprite3D.MVPMATRIX,projectionView);
  31098. }
  31099. ShaderData.setRuntimeValueMode(noteValue);
  31100. break ;
  31101. case /*laya.d3.core.render.RenderElement.RENDERTYPE_INSTANCEBATCH*/2:;
  31102. var mvpMatrixData=SubMeshInstanceBatch.instance.instanceMVPMatrixData;
  31103. var insBatches=element.instanceBatchElementList;
  31104. var count=insBatches.length;
  31105. for (var i=0;i < count;i++){
  31106. var worldMat=insBatches[i]._transform.worldMatrix;
  31107. Utils3D.mulMatrixByArray(projectionView.elements,0,worldMat.elements,0,mvpMatrixData,i *16);
  31108. }
  31109. SubMeshInstanceBatch.instance.instanceMVPMatrixBuffer.setData(mvpMatrixData,0,0,count *16);
  31110. break ;
  31111. }
  31112. }
  31113. /**
  31114. *@private
  31115. */
  31116. __proto._revertBatchRenderUpdate=function(context){
  31117. var element=context.renderElement;
  31118. switch (element.renderType){
  31119. case /*laya.d3.core.render.RenderElement.RENDERTYPE_STATICBATCH*/1:
  31120. this._defineDatas.value=this._oriDefineValue;
  31121. break ;
  31122. case /*laya.d3.core.render.RenderElement.RENDERTYPE_INSTANCEBATCH*/2:
  31123. this._defineDatas.remove(MeshSprite3D.SHADERDEFINE_GPU_INSTANCE);
  31124. break ;
  31125. }
  31126. }
  31127. /**
  31128. *@inheritDoc
  31129. */
  31130. __proto._destroy=function(){
  31131. (this._isPartOfStaticBatch)&& (MeshRenderStaticBatchManager.instance._destroyRenderSprite(this._owner));
  31132. _super.prototype._destroy.call(this);
  31133. }
  31134. __static(MeshRenderer,
  31135. ['_tempVector30',function(){return this._tempVector30=new Vector3();},'_tempVector31',function(){return this._tempVector31=new Vector3();}
  31136. ]);
  31137. return MeshRenderer;
  31138. })(BaseRender)
  31139. /**
  31140. *<code>MeshRender</code> 类用于网格渲染器。
  31141. */
  31142. //class laya.d3.terrain.TerrainRender extends laya.d3.core.render.BaseRender
  31143. var TerrainRender=(function(_super){
  31144. function TerrainRender(owner){
  31145. /**@private */
  31146. this._terrainSprite3DOwner=null;
  31147. /**@private */
  31148. this._projectionViewWorldMatrix=null;
  31149. TerrainRender.__super.call(this,owner);
  31150. this._terrainSprite3DOwner=owner;
  31151. this._projectionViewWorldMatrix=new Matrix4x4();
  31152. }
  31153. __class(TerrainRender,'laya.d3.terrain.TerrainRender',_super);
  31154. var __proto=TerrainRender.prototype;
  31155. /**
  31156. *@inheritDoc
  31157. */
  31158. __proto._needRender=function(boundFrustum){
  31159. if (boundFrustum)
  31160. return boundFrustum.containsBoundBox(this._bounds._getBoundBox())!==/*laya.d3.math.ContainmentType.Disjoint*/0;
  31161. else
  31162. return true;
  31163. }
  31164. /**
  31165. *@inheritDoc
  31166. */
  31167. __proto._calculateBoundingBox=function(){}
  31168. /**
  31169. *@inheritDoc
  31170. */
  31171. __proto._renderUpdate=function(context,transform){
  31172. this._shaderValues.setMatrix4x4(Sprite3D.WORLDMATRIX,transform.worldMatrix);
  31173. }
  31174. /**
  31175. *@inheritDoc
  31176. */
  31177. __proto._renderUpdateWithCamera=function(context,transform){
  31178. var projectionView=context.projectionViewMatrix;
  31179. Matrix4x4.multiply(projectionView,transform.worldMatrix,this._projectionViewWorldMatrix);
  31180. this._shaderValues.setMatrix4x4(Sprite3D.MVPMATRIX,this._projectionViewWorldMatrix);
  31181. }
  31182. /**
  31183. *@private
  31184. */
  31185. __proto._destroy=function(){
  31186. _super.prototype._destroy.call(this);
  31187. this._terrainSprite3DOwner=null;
  31188. }
  31189. return TerrainRender;
  31190. })(BaseRender)
  31191. /**
  31192. *<code>ShurikenParticleRender</code> 类用于创建3D粒子渲染器。
  31193. */
  31194. //class laya.d3.core.particleShuriKen.ShurikenParticleRenderer extends laya.d3.core.render.BaseRender
  31195. var ShurikenParticleRenderer=(function(_super){
  31196. function ShurikenParticleRenderer(owner){
  31197. /**@private */
  31198. //this._defaultBoundBox=null;
  31199. /**@private */
  31200. //this._renderMode=0;
  31201. /**@private */
  31202. //this._mesh=null;
  31203. /**拉伸广告牌模式摄像机速度缩放,暂不支持。*/
  31204. //this.stretchedBillboardCameraSpeedScale=NaN;
  31205. /**拉伸广告牌模式速度缩放。*/
  31206. //this.stretchedBillboardSpeedScale=NaN;
  31207. /**拉伸广告牌模式长度缩放。*/
  31208. //this.stretchedBillboardLengthScale=NaN;
  31209. this._finalGravity=new Vector3();
  31210. this._tempRotationMatrix=new Matrix4x4();
  31211. ShurikenParticleRenderer.__super.call(this,owner);
  31212. this._defaultBoundBox=new BoundBox(new Vector3(),new Vector3());
  31213. this._renderMode=-1;
  31214. this.stretchedBillboardCameraSpeedScale=0.0;
  31215. this.stretchedBillboardSpeedScale=0.0;
  31216. this.stretchedBillboardLengthScale=1.0;
  31217. }
  31218. __class(ShurikenParticleRenderer,'laya.d3.core.particleShuriKen.ShurikenParticleRenderer',_super);
  31219. var __proto=ShurikenParticleRenderer.prototype;
  31220. /**
  31221. *@inheritDoc
  31222. */
  31223. __proto._calculateBoundingBox=function(){
  31224. var min=this._bounds.getMin();
  31225. min.x=-Number.MAX_VALUE;
  31226. min.y=-Number.MAX_VALUE;
  31227. min.z=-Number.MAX_VALUE;
  31228. this._bounds.setMin(min);
  31229. var max=this._bounds.getMax();
  31230. max.x=Number.MAX_VALUE;
  31231. max.y=Number.MAX_VALUE;
  31232. max.z=Number.MAX_VALUE;
  31233. this._bounds.setMax(max);
  31234. if (Render.supportWebGLPlusCulling){
  31235. min=this._bounds.getMin();
  31236. max=this._bounds.getMax();
  31237. var buffer=FrustumCulling._cullingBuffer;
  31238. buffer[this._cullingBufferIndex+1]=min.x;
  31239. buffer[this._cullingBufferIndex+2]=min.y;
  31240. buffer[this._cullingBufferIndex+3]=min.z;
  31241. buffer[this._cullingBufferIndex+4]=max.x;
  31242. buffer[this._cullingBufferIndex+5]=max.y;
  31243. buffer[this._cullingBufferIndex+6]=max.z;
  31244. }
  31245. }
  31246. /**
  31247. *@inheritDoc
  31248. */
  31249. __proto._needRender=function(boundFrustum){
  31250. if (boundFrustum){
  31251. if (boundFrustum.containsBoundBox(this.bounds._getBoundBox())!==/*laya.d3.math.ContainmentType.Disjoint*/0){
  31252. if ((this._owner).particleSystem.isAlive)
  31253. return true;
  31254. else
  31255. return false;
  31256. }else {
  31257. return false;
  31258. }
  31259. }else {
  31260. return true;
  31261. }
  31262. }
  31263. /**
  31264. *@inheritDoc
  31265. */
  31266. __proto._renderUpdate=function(context,transfrom){
  31267. var particleSystem=(this._owner).particleSystem;
  31268. var sv=this._shaderValues;
  31269. var transform=this._owner.transform;
  31270. switch (particleSystem.simulationSpace){
  31271. case 0:
  31272. break ;
  31273. case 1:
  31274. sv.setVector3(ShuriKenParticle3D.WORLDPOSITION,transform.position);
  31275. sv.setQuaternion(ShuriKenParticle3D.WORLDROTATION,transform.rotation);
  31276. break ;
  31277. default :
  31278. throw new Error("ShurikenParticleMaterial: SimulationSpace value is invalid.");
  31279. }
  31280. switch (particleSystem.scaleMode){
  31281. case 0:;
  31282. var scale=transform.scale;
  31283. sv.setVector3(ShuriKenParticle3D.POSITIONSCALE,scale);
  31284. sv.setVector3(ShuriKenParticle3D.SIZESCALE,scale);
  31285. break ;
  31286. case 1:;
  31287. var localScale=transform.localScale;
  31288. sv.setVector3(ShuriKenParticle3D.POSITIONSCALE,localScale);
  31289. sv.setVector3(ShuriKenParticle3D.SIZESCALE,localScale);
  31290. break ;
  31291. case 2:
  31292. sv.setVector3(ShuriKenParticle3D.POSITIONSCALE,transform.scale);
  31293. sv.setVector3(ShuriKenParticle3D.SIZESCALE,Vector3._ONE);
  31294. break ;
  31295. }
  31296. Vector3.scale(Physics3DUtils.gravity,particleSystem.gravityModifier,this._finalGravity);
  31297. sv.setVector3(ShuriKenParticle3D.GRAVITY,this._finalGravity);
  31298. sv.setInt(ShuriKenParticle3D.SIMULATIONSPACE,particleSystem.simulationSpace);
  31299. sv.setBool(ShuriKenParticle3D.THREEDSTARTROTATION,particleSystem.threeDStartRotation);
  31300. sv.setInt(ShuriKenParticle3D.SCALINGMODE,particleSystem.scaleMode);
  31301. sv.setNumber(ShuriKenParticle3D.STRETCHEDBILLBOARDLENGTHSCALE,this.stretchedBillboardLengthScale);
  31302. sv.setNumber(ShuriKenParticle3D.STRETCHEDBILLBOARDSPEEDSCALE,this.stretchedBillboardSpeedScale);
  31303. sv.setNumber(ShuriKenParticle3D.CURRENTTIME,particleSystem._currentTime);
  31304. }
  31305. /**
  31306. *@inheritDoc
  31307. */
  31308. __proto._destroy=function(){
  31309. _super.prototype._destroy.call(this);
  31310. (this._mesh)&& (this._mesh._removeReference(),this._mesh=null);
  31311. }
  31312. /**
  31313. *设置渲染模式,0为BILLBOARD、1为STRETCHEDBILLBOARD、2为HORIZONTALBILLBOARD、3为VERTICALBILLBOARD、4为MESH。
  31314. *@param value 渲染模式。
  31315. */
  31316. /**
  31317. *获取渲染模式。
  31318. *@return 渲染模式。
  31319. */
  31320. __getset(0,__proto,'renderMode',function(){
  31321. return this._renderMode;
  31322. },function(value){
  31323. if (this._renderMode!==value){
  31324. var defineDatas=this._defineDatas;
  31325. switch (this._renderMode){
  31326. case 0:
  31327. defineDatas.remove(ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_BILLBOARD);
  31328. break ;
  31329. case 1:
  31330. defineDatas.remove(ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_STRETCHEDBILLBOARD);
  31331. break ;
  31332. case 2:
  31333. defineDatas.remove(ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_HORIZONTALBILLBOARD);
  31334. break ;
  31335. case 3:
  31336. defineDatas.remove(ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_VERTICALBILLBOARD);
  31337. break ;
  31338. case 4:
  31339. defineDatas.remove(ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_MESH);
  31340. break ;
  31341. }
  31342. this._renderMode=value;
  31343. switch (value){
  31344. case 0:
  31345. defineDatas.add(ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_BILLBOARD);
  31346. break ;
  31347. case 1:
  31348. defineDatas.add(ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_STRETCHEDBILLBOARD);
  31349. break ;
  31350. case 2:
  31351. defineDatas.add(ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_HORIZONTALBILLBOARD);
  31352. break ;
  31353. case 3:
  31354. defineDatas.add(ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_VERTICALBILLBOARD);
  31355. break ;
  31356. case 4:
  31357. defineDatas.add(ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_MESH);
  31358. break ;
  31359. default :
  31360. throw new Error("ShurikenParticleRender: unknown renderMode Value.");
  31361. }
  31362. (this._owner).particleSystem._initBufferDatas();
  31363. }
  31364. });
  31365. /**
  31366. *设置网格渲染模式所使用的Mesh,rendderMode为4时生效。
  31367. *@param value 网格模式所使用Mesh。
  31368. */
  31369. /**
  31370. *获取网格渲染模式所使用的Mesh,rendderMode为4时生效。
  31371. *@return 网格模式所使用Mesh。
  31372. */
  31373. __getset(0,__proto,'mesh',function(){
  31374. return this._mesh
  31375. },function(value){
  31376. if (this._mesh!==value){
  31377. (this._mesh)&& (this._mesh._removeReference());
  31378. this._mesh=value;
  31379. (value)&& (value._addReference());
  31380. (this._owner).particleSystem._initBufferDatas();
  31381. }
  31382. });
  31383. /**
  31384. *@inheritDoc
  31385. */
  31386. __getset(0,__proto,'bounds',function(){
  31387. if (this._boundsChange){
  31388. this._calculateBoundingBox();
  31389. this._boundsChange=false;
  31390. }
  31391. return this._bounds;
  31392. });
  31393. return ShurikenParticleRenderer;
  31394. })(BaseRender)
  31395. /**
  31396. *<code>TrailRenderer</code> 类用于创建拖尾渲染器。
  31397. */
  31398. //class laya.d3.core.trail.TrailRenderer extends laya.d3.core.render.BaseRender
  31399. var TrailRenderer=(function(_super){
  31400. function TrailRenderer(owner){
  31401. this._projectionViewWorldMatrix=new Matrix4x4();
  31402. TrailRenderer.__super.call(this,owner);
  31403. }
  31404. __class(TrailRenderer,'laya.d3.core.trail.TrailRenderer',_super);
  31405. var __proto=TrailRenderer.prototype;
  31406. /**
  31407. *@inheritDoc
  31408. */
  31409. __proto._calculateBoundingBox=function(){
  31410. var min=this._bounds.getMin();
  31411. min.x=-Number.MAX_VALUE;
  31412. min.y=-Number.MAX_VALUE;
  31413. min.z=-Number.MAX_VALUE;
  31414. this._bounds.setMin(min);
  31415. var max=this._bounds.getMax();
  31416. max.x=Number.MAX_VALUE;
  31417. max.y=Number.MAX_VALUE;
  31418. max.z=Number.MAX_VALUE;
  31419. this._bounds.setMax(max);
  31420. if (Render.supportWebGLPlusCulling){
  31421. min=this._bounds.getMin();
  31422. max=this._bounds.getMax();
  31423. var buffer=FrustumCulling._cullingBuffer;
  31424. buffer[this._cullingBufferIndex+1]=min.x;
  31425. buffer[this._cullingBufferIndex+2]=min.y;
  31426. buffer[this._cullingBufferIndex+3]=min.z;
  31427. buffer[this._cullingBufferIndex+4]=max.x;
  31428. buffer[this._cullingBufferIndex+5]=max.y;
  31429. buffer[this._cullingBufferIndex+6]=max.z;
  31430. }
  31431. }
  31432. /**
  31433. *@inheritDoc
  31434. */
  31435. __proto._needRender=function(boundFrustum){
  31436. return true;
  31437. }
  31438. /**
  31439. *@inheritDoc
  31440. */
  31441. __proto._renderUpdate=function(state,transform){
  31442. _super.prototype._renderUpdate.call(this,state,transform);
  31443. (this._owner).trailFilter._update(state);
  31444. }
  31445. /**
  31446. *@inheritDoc
  31447. */
  31448. __proto._renderUpdateWithCamera=function(context,transform){
  31449. var projectionView=context.projectionViewMatrix;
  31450. if (transform){
  31451. Matrix4x4.multiply(projectionView,transform.worldMatrix,this._projectionViewWorldMatrix);
  31452. this._shaderValues.setMatrix4x4(Sprite3D.MVPMATRIX,this._projectionViewWorldMatrix);
  31453. }else {
  31454. this._shaderValues.setMatrix4x4(Sprite3D.MVPMATRIX,projectionView);
  31455. }
  31456. }
  31457. return TrailRenderer;
  31458. })(BaseRender)
  31459. /**
  31460. *<code>PhysicsTriggerComponent</code> 类用于创建物理触发器组件。
  31461. */
  31462. //class laya.d3.physics.PhysicsTriggerComponent extends laya.d3.physics.PhysicsComponent
  31463. var PhysicsTriggerComponent=(function(_super){
  31464. function PhysicsTriggerComponent(collisionGroup,canCollideWith){
  31465. /**@private */
  31466. this._isTrigger=false;
  31467. PhysicsTriggerComponent.__super.call(this,collisionGroup,canCollideWith);
  31468. }
  31469. __class(PhysicsTriggerComponent,'laya.d3.physics.PhysicsTriggerComponent',_super);
  31470. var __proto=PhysicsTriggerComponent.prototype;
  31471. /**
  31472. *@inheritDoc
  31473. */
  31474. __proto._onAdded=function(){
  31475. _super.prototype._onAdded.call(this);
  31476. this.isTrigger=this._isTrigger;
  31477. }
  31478. /**
  31479. *@inheritDoc
  31480. */
  31481. __proto._cloneTo=function(dest){
  31482. _super.prototype._cloneTo.call(this,dest);
  31483. (dest).isTrigger=this._isTrigger;
  31484. }
  31485. /**
  31486. *设置是否为触发器。
  31487. *@param value 是否为触发器。
  31488. */
  31489. /**
  31490. *获取是否为触发器。
  31491. *@return 是否为触发器。
  31492. */
  31493. __getset(0,__proto,'isTrigger',function(){
  31494. return this._isTrigger;
  31495. },function(value){
  31496. this._isTrigger=value;
  31497. if (this._nativeColliderObject){
  31498. var flags=this._nativeColliderObject.getCollisionFlags();
  31499. if (value){
  31500. if ((flags & 4)===0)
  31501. this._nativeColliderObject.setCollisionFlags(flags | 4);
  31502. }else {
  31503. if ((flags & 4)!==0)
  31504. this._nativeColliderObject.setCollisionFlags(flags ^ 4);
  31505. }
  31506. }
  31507. });
  31508. return PhysicsTriggerComponent;
  31509. })(PhysicsComponent)
  31510. /**
  31511. *<code>PixelLineRenderer</code> 类用于线渲染器。
  31512. */
  31513. //class laya.d3.core.pixelLine.PixelLineRenderer extends laya.d3.core.render.BaseRender
  31514. var PixelLineRenderer=(function(_super){
  31515. function PixelLineRenderer(owner){
  31516. /**@private */
  31517. this._projectionViewWorldMatrix=null;
  31518. PixelLineRenderer.__super.call(this,owner);
  31519. this._projectionViewWorldMatrix=new Matrix4x4();
  31520. }
  31521. __class(PixelLineRenderer,'laya.d3.core.pixelLine.PixelLineRenderer',_super);
  31522. var __proto=PixelLineRenderer.prototype;
  31523. /**
  31524. *@inheritDoc
  31525. */
  31526. __proto._calculateBoundingBox=function(){
  31527. var min=this._bounds.getMin();
  31528. min.x=-Number.MAX_VALUE;
  31529. min.y=-Number.MAX_VALUE;
  31530. min.z=-Number.MAX_VALUE;
  31531. this._bounds.setMin(min);
  31532. var max=this._bounds.getMax();
  31533. max.x=Number.MAX_VALUE;
  31534. max.y=Number.MAX_VALUE;
  31535. max.z=Number.MAX_VALUE;
  31536. this._bounds.setMax(max);
  31537. if (Render.supportWebGLPlusCulling){
  31538. min=this._bounds.getMin();
  31539. max=this._bounds.getMax();
  31540. var buffer=FrustumCulling._cullingBuffer;
  31541. buffer[this._cullingBufferIndex+1]=min.x;
  31542. buffer[this._cullingBufferIndex+2]=min.y;
  31543. buffer[this._cullingBufferIndex+3]=min.z;
  31544. buffer[this._cullingBufferIndex+4]=max.x;
  31545. buffer[this._cullingBufferIndex+5]=max.y;
  31546. buffer[this._cullingBufferIndex+6]=max.z;
  31547. }
  31548. }
  31549. /**
  31550. *@inheritDoc
  31551. */
  31552. __proto._renderUpdateWithCamera=function(context,transform){
  31553. var projectionView=context.projectionViewMatrix;
  31554. var sv=this._shaderValues;
  31555. if (transform){
  31556. var worldMat=transform.worldMatrix;
  31557. sv.setMatrix4x4(Sprite3D.WORLDMATRIX,worldMat);
  31558. Matrix4x4.multiply(projectionView,worldMat,this._projectionViewWorldMatrix);
  31559. sv.setMatrix4x4(Sprite3D.MVPMATRIX,this._projectionViewWorldMatrix);
  31560. }else {
  31561. sv.setMatrix4x4(Sprite3D.WORLDMATRIX,Matrix4x4.DEFAULT);
  31562. sv.setMatrix4x4(Sprite3D.MVPMATRIX,projectionView);
  31563. }
  31564. }
  31565. return PixelLineRenderer;
  31566. })(BaseRender)
  31567. /**
  31568. *<code>CharacterController</code> 类用于创建角色控制器。
  31569. */
  31570. //class laya.d3.physics.CharacterController extends laya.d3.physics.PhysicsComponent
  31571. var CharacterController=(function(_super){
  31572. function CharacterController(stepheight,upAxis,collisionGroup,canCollideWith){
  31573. /**@private */
  31574. //this._stepHeight=NaN;
  31575. /**@private */
  31576. this._maxSlope=45.0;
  31577. /**@private */
  31578. this._jumpSpeed=10.0;
  31579. /**@private */
  31580. this._fallSpeed=55.0;
  31581. /**@private */
  31582. //this._nativeKinematicCharacter=null;
  31583. this._upAxis=new Vector3(0,1,0);
  31584. this._gravity=new Vector3(0,-9.8 *3,0);
  31585. (stepheight===void 0)&& (stepheight=0.1);
  31586. (collisionGroup===void 0)&& (collisionGroup=/*laya.d3.utils.Physics3DUtils.COLLISIONFILTERGROUP_DEFAULTFILTER*/0x1);
  31587. (canCollideWith===void 0)&& (canCollideWith=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  31588. this._stepHeight=stepheight;
  31589. (upAxis)&& (this._upAxis=upAxis);
  31590. CharacterController.__super.call(this,collisionGroup,canCollideWith);
  31591. }
  31592. __class(CharacterController,'laya.d3.physics.CharacterController',_super);
  31593. var __proto=CharacterController.prototype;
  31594. /**
  31595. *@private
  31596. */
  31597. __proto._constructCharacter=function(){
  31598. var physics3D=Laya3D._physics3D;
  31599. if (this._nativeKinematicCharacter)
  31600. physics3D.destroy(this._nativeKinematicCharacter);
  31601. var nativeUpAxis=CharacterController._nativeTempVector30;
  31602. nativeUpAxis.setValue(this._upAxis.x,this._upAxis.y,this._upAxis.z);
  31603. this._nativeKinematicCharacter=new physics3D.btKinematicCharacterController(this._nativeColliderObject,this._colliderShape._nativeShape,this._stepHeight,nativeUpAxis);
  31604. this.fallSpeed=this._fallSpeed;
  31605. this.maxSlope=this._maxSlope;
  31606. this.jumpSpeed=this._jumpSpeed;
  31607. this.gravity=this._gravity;
  31608. }
  31609. /**
  31610. *@inheritDoc
  31611. */
  31612. __proto._onShapeChange=function(colShape){
  31613. _super.prototype._onShapeChange.call(this,colShape);
  31614. this._constructCharacter();
  31615. }
  31616. /**
  31617. *@inheritDoc
  31618. */
  31619. __proto._onAdded=function(){
  31620. var physics3D=Laya3D._physics3D;
  31621. var ghostObject=new physics3D.btPairCachingGhostObject();
  31622. ghostObject.setUserIndex(this.id);
  31623. ghostObject.setCollisionFlags(16);
  31624. this._nativeColliderObject=ghostObject;
  31625. if (this._colliderShape)
  31626. this._constructCharacter();
  31627. _super.prototype._onAdded.call(this);
  31628. }
  31629. /**
  31630. *@inheritDoc
  31631. */
  31632. __proto._addToSimulation=function(){
  31633. this._simulation._characters.push(this);
  31634. this._simulation._addCharacter(this,this._collisionGroup,this._canCollideWith);
  31635. }
  31636. /**
  31637. *@inheritDoc
  31638. */
  31639. __proto._removeFromSimulation=function(){
  31640. this._simulation._removeCharacter(this);
  31641. var characters=this._simulation._characters;
  31642. characters.splice(characters.indexOf(this),1);
  31643. }
  31644. /**
  31645. *@inheritDoc
  31646. */
  31647. __proto._cloneTo=function(dest){
  31648. _super.prototype._cloneTo.call(this,dest);
  31649. var destCharacterController=dest;
  31650. destCharacterController.stepHeight=this._stepHeight;
  31651. destCharacterController.upAxis=this._upAxis;
  31652. destCharacterController.maxSlope=this._maxSlope;
  31653. destCharacterController.jumpSpeed=this._jumpSpeed;
  31654. destCharacterController.fallSpeed=this._fallSpeed;
  31655. destCharacterController.gravity=this._gravity;
  31656. }
  31657. /**
  31658. *@inheritDoc
  31659. */
  31660. __proto._onDestroy=function(){
  31661. Laya3D._physics3D.destroy(this._nativeKinematicCharacter);
  31662. _super.prototype._onDestroy.call(this);
  31663. this._nativeKinematicCharacter=null;
  31664. }
  31665. /**
  31666. *通过指定移动向量移动角色。
  31667. *@param movement 移动向量。
  31668. */
  31669. __proto.move=function(movement){
  31670. var nativeMovement=PhysicsComponent._nativeVector30;
  31671. nativeMovement.setValue(-movement.x,movement.y,movement.z);
  31672. this._nativeKinematicCharacter.setWalkDirection(nativeMovement);
  31673. }
  31674. /**
  31675. *跳跃。
  31676. *@param velocity 跳跃速度。
  31677. */
  31678. __proto.jump=function(velocity){
  31679. if (velocity){
  31680. var nativeVelocity=PhysicsComponent._nativeVector30;
  31681. Utils3D._convertToBulletVec3(velocity,nativeVelocity,true);
  31682. this._nativeKinematicCharacter.jump(nativeVelocity);
  31683. }else {
  31684. this._nativeKinematicCharacter.jump();
  31685. }
  31686. }
  31687. /**
  31688. *设置角色降落速度。
  31689. *@param value 角色降落速度。
  31690. */
  31691. /**
  31692. *获取角色降落速度。
  31693. *@return 角色降落速度。
  31694. */
  31695. __getset(0,__proto,'fallSpeed',function(){
  31696. return this._fallSpeed;
  31697. },function(value){
  31698. this._fallSpeed=value;
  31699. this._nativeKinematicCharacter.setFallSpeed(value);
  31700. });
  31701. /**
  31702. *设置角色行走的脚步高度,表示可跨越的最大高度。
  31703. *@param value 脚步高度。
  31704. */
  31705. /**
  31706. *获取角色行走的脚步高度,表示可跨越的最大高度。
  31707. *@return 脚步高度。
  31708. */
  31709. __getset(0,__proto,'stepHeight',function(){
  31710. return this._stepHeight;
  31711. },function(value){
  31712. this._stepHeight=value;
  31713. this._constructCharacter();
  31714. });
  31715. /**
  31716. *设置角色跳跃速度。
  31717. *@param value 角色跳跃速度。
  31718. */
  31719. /**
  31720. *获取角色跳跃速度。
  31721. *@return 角色跳跃速度。
  31722. */
  31723. __getset(0,__proto,'jumpSpeed',function(){
  31724. return this._jumpSpeed;
  31725. },function(value){
  31726. this._jumpSpeed=value;
  31727. this._nativeKinematicCharacter.setJumpSpeed(value);
  31728. });
  31729. /**
  31730. *设置重力。
  31731. *@param value 重力。
  31732. */
  31733. /**
  31734. *获取重力。
  31735. *@return 重力。
  31736. */
  31737. __getset(0,__proto,'gravity',function(){
  31738. return this._gravity;
  31739. },function(value){
  31740. this._gravity=value;
  31741. var nativeGravity=CharacterController._nativeTempVector30;
  31742. nativeGravity.setValue(-value.x,value.y,value.z);
  31743. this._nativeKinematicCharacter.setGravity(nativeGravity);
  31744. });
  31745. /**
  31746. *设置最大坡度。
  31747. *@param value 最大坡度。
  31748. */
  31749. /**
  31750. *获取最大坡度。
  31751. *@return 最大坡度。
  31752. */
  31753. __getset(0,__proto,'maxSlope',function(){
  31754. return this._maxSlope;
  31755. },function(value){
  31756. this._maxSlope=value;
  31757. this._nativeKinematicCharacter.setMaxSlope((value / 180)*Math.PI);
  31758. });
  31759. /**
  31760. *获取角色是否在地表。
  31761. */
  31762. __getset(0,__proto,'isGrounded',function(){
  31763. return this._nativeKinematicCharacter.onGround();
  31764. });
  31765. /**
  31766. *设置角色的Up轴。
  31767. *@return 角色的Up轴。
  31768. */
  31769. /**
  31770. *获取角色的Up轴。
  31771. *@return 角色的Up轴。
  31772. */
  31773. __getset(0,__proto,'upAxis',function(){
  31774. return this._upAxis;
  31775. },function(value){
  31776. this._upAxis=value;
  31777. this._constructCharacter();
  31778. });
  31779. CharacterController.UPAXIS_X=0;
  31780. CharacterController.UPAXIS_Y=1;
  31781. CharacterController.UPAXIS_Z=2;
  31782. __static(CharacterController,
  31783. ['_nativeTempVector30',function(){return this._nativeTempVector30=new Laya3D._physics3D.btVector3(0,0,0);}
  31784. ]);
  31785. return CharacterController;
  31786. })(PhysicsComponent)
  31787. /**
  31788. *<code>Scene3D</code> 类用于实现场景。
  31789. */
  31790. //class laya.d3.core.scene.Scene3D extends laya.display.Sprite
  31791. var Scene3D=(function(_super){
  31792. function Scene3D(){
  31793. /**@private */
  31794. //this._url=null;
  31795. /**@private */
  31796. //this._group=null;
  31797. /**@private */
  31798. this._reflectionMode=1;
  31799. /**@private */
  31800. this._enableLightCount=3;
  31801. /**@private */
  31802. //this._renderTargetTexture=null;
  31803. /**@private */
  31804. //this._enableFog=false;
  31805. /**@private */
  31806. //this._physicsSimulation=null;
  31807. /**@private */
  31808. //this._octree=null;
  31809. /**@private */
  31810. //this._shaderValues=null;
  31811. /**@private */
  31812. //this._defineDatas=null;
  31813. /**是否启用灯光。*/
  31814. this.enableLight=true;
  31815. //阴影相关变量
  31816. //this.parallelSplitShadowMaps=null;
  31817. /**@private */
  31818. //this._debugTool=null;
  31819. this._time=0;
  31820. /**@private [NATIVE]*/
  31821. //this._cullingBufferIndices=null;
  31822. /**@private [NATIVE]*/
  31823. //this._cullingBufferResult=null;
  31824. Scene3D.__super.call(this);
  31825. this._lights=[];
  31826. this._lightmaps=[];
  31827. this._skyRenderer=new SkyRenderer();
  31828. this._input=new Input3D();
  31829. this._timer=Laya.timer;
  31830. this._collsionTestList=[];
  31831. this._renders=new SimpleSingletonList();
  31832. this._opaqueQueue=new RenderQueue(false);
  31833. this._transparentQueue=new RenderQueue(true);
  31834. this._cameraPool=[];
  31835. this._animatorPool=new SimpleSingletonList();
  31836. this._scriptPool=new SimpleSingletonList();
  31837. this._castShadowRenders=new CastShadowList();
  31838. this.currentCreationLayer=Math.pow(2,0);
  31839. this._key=new SubmitKey();
  31840. this._pickIdToSprite=new Object();
  31841. if (Laya3D._enbalePhysics)
  31842. this._physicsSimulation=new PhysicsSimulation(Laya3D.physicsSettings);
  31843. this._defineDatas=new DefineDatas();
  31844. this._shaderValues=new ShaderData(null);
  31845. this.parallelSplitShadowMaps=[];
  31846. this.enableFog=false;
  31847. this.fogStart=300;
  31848. this.fogRange=1000;
  31849. this.fogColor=new Vector3(0.7,0.7,0.7);
  31850. this.ambientColor=new Vector3(0.212,0.227,0.259);
  31851. this.reflectionIntensity=1.0;
  31852. (WebGL.shaderHighPrecision)&& (this._defineDatas.add(Shader3D.SHADERDEFINE_HIGHPRECISION));
  31853. if (Render.supportWebGLPlusCulling){
  31854. this._cullingBufferIndices=new Int32Array(1024);
  31855. this._cullingBufferResult=new Int32Array(1024);
  31856. }
  31857. this._shaderValues.setTexture(laya.d3.core.scene.Scene3D.RANGEATTENUATIONTEXTURE,ShaderInit3D._rangeAttenTex);
  31858. this._scene=this;
  31859. if (Laya3D._enbalePhysics && !PhysicsSimulation.disableSimulation)
  31860. this._input.__init__(Render.canvas,this);
  31861. var config=Laya3D._config;
  31862. if (config.octreeCulling){
  31863. this._octree=new BoundsOctree(config.octreeInitialSize,config.octreeInitialCenter,config.octreeMinNodeSize,config.octreeLooseness);
  31864. }
  31865. if (Laya3D._config.debugFrustumCulling){
  31866. this._debugTool=new PixelLineSprite3D();
  31867. var lineMaterial=new PixelLineMaterial();
  31868. lineMaterial.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_TRANSPARENT*/3000;
  31869. lineMaterial.alphaTest=false;
  31870. lineMaterial.depthWrite=false;
  31871. lineMaterial.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  31872. lineMaterial.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  31873. lineMaterial.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_SRC_ALPHA*/0x0302;
  31874. lineMaterial.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA*/0x0303;
  31875. lineMaterial.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  31876. this._debugTool.pixelLineRenderer.sharedMaterial=lineMaterial;
  31877. }
  31878. }
  31879. __class(Scene3D,'laya.d3.core.scene.Scene3D',_super);
  31880. var __proto=Scene3D.prototype;
  31881. Laya.imps(__proto,{"laya.webgl.submit.ISubmit":true,"laya.resource.ICreateResource":true})
  31882. /**
  31883. *@private
  31884. *[Editer]
  31885. */
  31886. __proto._allotPickColorByID=function(id,pickColor){
  31887. var pickColorR=Math.floor(id / (255 *255));
  31888. id-=pickColorR *255 *255;
  31889. var pickColorG=Math.floor(id / 255);
  31890. id-=pickColorG *255;
  31891. var pickColorB=id;
  31892. pickColor.x=pickColorR / 255;
  31893. pickColor.y=pickColorG / 255;
  31894. pickColor.z=pickColorB / 255;
  31895. pickColor.w=1.0;
  31896. }
  31897. /**
  31898. *@private
  31899. *[Editer]
  31900. */
  31901. __proto._searchIDByPickColor=function(pickColor){
  31902. var id=pickColor.x *255 *255+pickColor.y *255+pickColor.z;
  31903. return id;
  31904. }
  31905. /**
  31906. *@private
  31907. */
  31908. __proto._setLightmapToChildNode=function(sprite){
  31909. if ((sprite instanceof laya.d3.core.RenderableSprite3D ))
  31910. (sprite)._render._applyLightMapParams();
  31911. var children=sprite._children;
  31912. for (var i=0,n=children.length;i < n;i++)
  31913. this._setLightmapToChildNode(children[i]);
  31914. }
  31915. /**
  31916. *@private
  31917. */
  31918. __proto._update=function(){
  31919. var delta=this.timer._delta / 1000;
  31920. this._time+=delta;
  31921. this._shaderValues.setNumber(laya.d3.core.scene.Scene3D.TIME,this._time);
  31922. var simulation=this._physicsSimulation;
  31923. if (Laya3D._enbalePhysics && !PhysicsSimulation.disableSimulation){
  31924. simulation._updatePhysicsTransformFromRender();
  31925. PhysicsComponent._addUpdateList=false;
  31926. simulation._simulate(delta);
  31927. simulation._updateCharacters();
  31928. PhysicsComponent._addUpdateList=true;
  31929. simulation._updateCollisions();
  31930. simulation._eventScripts();
  31931. this._input._update();
  31932. }
  31933. this._updateScript();
  31934. Animator._update(this);
  31935. this._lateUpdateScript();
  31936. }
  31937. /**
  31938. *@private
  31939. */
  31940. __proto._binarySearchIndexInCameraPool=function(camera){
  31941. var start=0;
  31942. var end=this._cameraPool.length-1;
  31943. var mid=0;
  31944. while (start <=end){
  31945. mid=Math.floor((start+end)/ 2);
  31946. var midValue=this._cameraPool[mid]._renderingOrder;
  31947. if (midValue==camera._renderingOrder)
  31948. return mid;
  31949. else if (midValue > camera._renderingOrder)
  31950. end=mid-1;
  31951. else
  31952. start=mid+1;
  31953. }
  31954. return start;
  31955. }
  31956. /**
  31957. *@private
  31958. */
  31959. __proto._setCreateURL=function(url){
  31960. this._url=URL.formatURL(url);
  31961. }
  31962. /**
  31963. *@private
  31964. */
  31965. __proto._getGroup=function(){
  31966. return this._group;
  31967. }
  31968. /**
  31969. *@private
  31970. */
  31971. __proto._setGroup=function(value){
  31972. this._group=value;
  31973. }
  31974. /**
  31975. *@private
  31976. */
  31977. __proto._updateScript=function(){
  31978. var pool=this._scriptPool;
  31979. var elements=pool.elements;
  31980. for (var i=0,n=pool.length;i < n;i++){
  31981. var script=elements [i];
  31982. (script && script.enabled)&& (script.onUpdate());
  31983. }
  31984. }
  31985. /**
  31986. *@private
  31987. */
  31988. __proto._lateUpdateScript=function(){
  31989. var pool=this._scriptPool;
  31990. var elements=pool.elements;
  31991. for (var i=0,n=pool.length;i < n;i++){
  31992. var script=elements [i];
  31993. (script && script.enabled)&& (script.onLateUpdate());
  31994. }
  31995. }
  31996. /**
  31997. *@private
  31998. */
  31999. __proto._preRenderScript=function(){
  32000. var pool=this._scriptPool;
  32001. var elements=pool.elements;
  32002. for (var i=0,n=pool.length;i < n;i++){
  32003. var script=elements [i];
  32004. (script && script.enabled)&& (script.onPreRender());
  32005. }
  32006. }
  32007. /**
  32008. *@private
  32009. */
  32010. __proto._postRenderScript=function(){
  32011. var pool=this._scriptPool;
  32012. var elements=pool.elements;
  32013. for (var i=0,n=pool.length;i < n;i++){
  32014. var script=elements [i];
  32015. (script && script.enabled)&& (script.onPostRender());
  32016. }
  32017. }
  32018. /**
  32019. *@private
  32020. */
  32021. __proto._prepareSceneToRender=function(){
  32022. var lightCount=this._lights.length;
  32023. if (lightCount > 0){
  32024. var renderLightCount=0;
  32025. for (var i=0;i < lightCount;i++){
  32026. if (!this._lights[i]._prepareToScene())
  32027. continue ;
  32028. renderLightCount++;
  32029. if (renderLightCount >=this._enableLightCount)
  32030. break ;
  32031. }
  32032. }
  32033. }
  32034. /**
  32035. *@private
  32036. */
  32037. __proto._addCamera=function(camera){
  32038. var index=this._binarySearchIndexInCameraPool(camera);
  32039. var order=camera._renderingOrder;
  32040. var count=this._cameraPool.length;
  32041. while (index < count && this._cameraPool[index]._renderingOrder <=order)
  32042. index++;
  32043. this._cameraPool.splice(index,0,camera);
  32044. }
  32045. /**
  32046. *@private
  32047. */
  32048. __proto._removeCamera=function(camera){
  32049. this._cameraPool.splice(this._cameraPool.indexOf(camera),1);
  32050. }
  32051. /**
  32052. *@private
  32053. */
  32054. __proto._preCulling=function(context,camera){
  32055. FrustumCulling.renderObjectCulling(camera,this,context,this._renders);
  32056. }
  32057. /**
  32058. *@private
  32059. */
  32060. __proto._clear=function(gl,state){
  32061. var viewport=state.viewport;
  32062. var camera=state.camera;
  32063. var renderTarget=camera.getRenderTexture();
  32064. var vpW=viewport.width;
  32065. var vpH=viewport.height;
  32066. var vpX=viewport.x;
  32067. var vpY=camera._getCanvasHeight()-viewport.y-vpH;
  32068. gl.viewport(vpX,vpY,vpW,vpH);
  32069. var flag=0;
  32070. var clearFlag=camera.clearFlag;
  32071. if (clearFlag===/*laya.d3.core.BaseCamera.CLEARFLAG_SKY*/1 && !(camera.skyRenderer._isAvailable()|| this._skyRenderer._isAvailable()))
  32072. clearFlag=/*laya.d3.core.BaseCamera.CLEARFLAG_SOLIDCOLOR*/0;
  32073. switch (clearFlag){
  32074. case /*laya.d3.core.BaseCamera.CLEARFLAG_SOLIDCOLOR*/0:;
  32075. var clearColor=camera.clearColor;
  32076. gl.enable(/*laya.webgl.WebGLContext.SCISSOR_TEST*/0x0C11);
  32077. gl.scissor(vpX,vpY,vpW,vpH);
  32078. if (clearColor)
  32079. gl.clearColor(clearColor.x,clearColor.y,clearColor.z,clearColor.w);
  32080. else
  32081. gl.clearColor(0,0,0,0);
  32082. if (renderTarget){
  32083. flag=/*laya.webgl.WebGLContext.COLOR_BUFFER_BIT*/0x00004000;
  32084. switch (renderTarget.depthStencilFormat){
  32085. case /*laya.resource.BaseTexture.FORMAT_DEPTH_16*/0:
  32086. flag |=/*laya.webgl.WebGLContext.DEPTH_BUFFER_BIT*/0x00000100;
  32087. break ;
  32088. case /*laya.resource.BaseTexture.FORMAT_STENCIL_8*/1:
  32089. flag |=/*laya.webgl.WebGLContext.STENCIL_BUFFER_BIT*/0x00000400;
  32090. break ;
  32091. case /*laya.resource.BaseTexture.FORMAT_DEPTHSTENCIL_16_8*/2:
  32092. flag |=/*laya.webgl.WebGLContext.DEPTH_BUFFER_BIT*/0x00000100;
  32093. flag |=/*laya.webgl.WebGLContext.STENCIL_BUFFER_BIT*/0x00000400;
  32094. break ;
  32095. }
  32096. }else {
  32097. flag=/*laya.webgl.WebGLContext.COLOR_BUFFER_BIT*/0x00004000 | /*laya.webgl.WebGLContext.DEPTH_BUFFER_BIT*/0x00000100;
  32098. }
  32099. WebGLContext.setDepthMask(gl,true);
  32100. gl.clear(flag);
  32101. gl.disable(/*laya.webgl.WebGLContext.SCISSOR_TEST*/0x0C11);
  32102. break ;
  32103. case /*laya.d3.core.BaseCamera.CLEARFLAG_SKY*/1:
  32104. case /*laya.d3.core.BaseCamera.CLEARFLAG_DEPTHONLY*/2:
  32105. gl.enable(/*laya.webgl.WebGLContext.SCISSOR_TEST*/0x0C11);
  32106. gl.scissor(vpX,vpY,vpW,vpH);
  32107. if (renderTarget){
  32108. switch (renderTarget.depthStencilFormat){
  32109. case /*laya.resource.BaseTexture.FORMAT_DEPTH_16*/0:
  32110. flag=/*laya.webgl.WebGLContext.DEPTH_BUFFER_BIT*/0x00000100;
  32111. break ;
  32112. case /*laya.resource.BaseTexture.FORMAT_STENCIL_8*/1:
  32113. flag=/*laya.webgl.WebGLContext.STENCIL_BUFFER_BIT*/0x00000400;
  32114. break ;
  32115. case /*laya.resource.BaseTexture.FORMAT_DEPTHSTENCIL_16_8*/2:
  32116. flag=/*laya.webgl.WebGLContext.DEPTH_BUFFER_BIT*/0x00000100 | /*laya.webgl.WebGLContext.STENCIL_BUFFER_BIT*/0x00000400;
  32117. break ;
  32118. }
  32119. }else {
  32120. flag=/*laya.webgl.WebGLContext.DEPTH_BUFFER_BIT*/0x00000100;
  32121. }
  32122. WebGLContext.setDepthMask(gl,true);
  32123. gl.clear(flag);
  32124. gl.disable(/*laya.webgl.WebGLContext.SCISSOR_TEST*/0x0C11);
  32125. break ;
  32126. case /*laya.d3.core.BaseCamera.CLEARFLAG_NONE*/3:
  32127. break ;
  32128. default :
  32129. throw new Error("BaseScene:camera clearFlag invalid.");
  32130. }
  32131. }
  32132. /**
  32133. *@private
  32134. */
  32135. __proto._renderScene=function(gl,state,customShader,replacementTag){
  32136. var camera=state.camera;
  32137. var position=camera.transform.position;
  32138. camera.getRenderTexture()? this._opaqueQueue._render(state,true,customShader,replacementTag):this._opaqueQueue._render(state,false,customShader,replacementTag);
  32139. if (camera.clearFlag===/*laya.d3.core.BaseCamera.CLEARFLAG_SKY*/1){
  32140. if (camera.skyRenderer._isAvailable())
  32141. camera.skyRenderer._render(state);
  32142. else if (this._skyRenderer._isAvailable())
  32143. this._skyRenderer._render(state);
  32144. }
  32145. camera.getRenderTexture()? this._transparentQueue._render(state,true,customShader,replacementTag):this._transparentQueue._render(state,false,customShader,replacementTag);
  32146. camera._applyPostProcessCommandBuffers();
  32147. if (Laya3D._config.debugFrustumCulling){
  32148. var renderElements=this._debugTool._render._renderElements;
  32149. for (var i=0,n=renderElements.length;i < n;i++){
  32150. renderElements[i]._render(state,false,customShader,replacementTag);
  32151. }
  32152. }
  32153. }
  32154. /**
  32155. *@inheritDoc
  32156. */
  32157. __proto._parse=function(data,spriteMap){
  32158. var lightMapsData=data.lightmaps;
  32159. if (lightMapsData){
  32160. var lightMapCount=lightMapsData.length;
  32161. var lightmaps=__newvec(lightMapCount);
  32162. for (var i=0;i < lightMapCount;i++)
  32163. lightmaps[i]=Loader.getRes(lightMapsData[i].path);
  32164. this.setlightmaps(lightmaps);
  32165. };
  32166. var ambientColorData=data.ambientColor;
  32167. if (ambientColorData){
  32168. var ambCol=this.ambientColor;
  32169. ambCol.fromArray(ambientColorData);
  32170. this.ambientColor=ambCol;
  32171. };
  32172. var skyData=data.sky;
  32173. if (skyData){
  32174. this._skyRenderer.material=Loader.getRes(skyData.material.path);
  32175. switch (skyData.mesh){
  32176. case "SkyBox":
  32177. this._skyRenderer.mesh=SkyBox.instance;
  32178. break ;
  32179. case "SkyDome":
  32180. this._skyRenderer.mesh=SkyDome.instance;
  32181. break ;
  32182. default :
  32183. this.skyRenderer.mesh=SkyBox.instance;
  32184. }
  32185. };
  32186. var reflectionTextureData=data.reflectionTexture;
  32187. reflectionTextureData && (this.customReflection=Loader.getRes(reflectionTextureData));
  32188. this.enableFog=data.enableFog;
  32189. this.fogStart=data.fogStart;
  32190. this.fogRange=data.fogRange;
  32191. var fogColorData=data.fogColor;
  32192. if (fogColorData){
  32193. var fogCol=this.fogColor;
  32194. fogCol.fromArray(fogColorData);
  32195. this.fogColor=fogCol;
  32196. }
  32197. }
  32198. /**
  32199. *@inheritDoc
  32200. */
  32201. __proto._onActive=function(){
  32202. laya.display.Node.prototype._onActive.call(this);
  32203. Laya.stage._scene3Ds.push(this);
  32204. }
  32205. /**
  32206. *@inheritDoc
  32207. */
  32208. __proto._onInActive=function(){
  32209. laya.display.Node.prototype._onInActive.call(this);
  32210. var scenes=Laya.stage._scene3Ds;
  32211. scenes.splice(scenes.indexOf(this),1);
  32212. }
  32213. /**
  32214. *@private
  32215. */
  32216. __proto._addLight=function(light){
  32217. if (this._lights.indexOf(light)< 0)this._lights.push(light);
  32218. }
  32219. /**
  32220. *@private
  32221. */
  32222. __proto._removeLight=function(light){
  32223. var index=this._lights.indexOf(light);
  32224. index >=0 && (this._lights.splice(index,1));
  32225. }
  32226. /**
  32227. *@private
  32228. */
  32229. __proto._addRenderObject=function(render){
  32230. if (this._octree){
  32231. this._octree.add(render);
  32232. }else {
  32233. this._renders.add(render);
  32234. if (Render.supportWebGLPlusCulling){
  32235. var indexInList=render._getIndexInList();
  32236. var length=this._cullingBufferIndices.length;
  32237. if (indexInList >=length){
  32238. var tempIndices=this._cullingBufferIndices;
  32239. var tempResult=this._cullingBufferResult;
  32240. this._cullingBufferIndices=new Int32Array(length+1024);
  32241. this._cullingBufferResult=new Int32Array(length+1024);
  32242. this._cullingBufferIndices.set(tempIndices,0);
  32243. this._cullingBufferResult.set(tempResult,0);
  32244. }
  32245. this._cullingBufferIndices[indexInList]=render._cullingBufferIndex;
  32246. }
  32247. }
  32248. }
  32249. /**
  32250. *@private
  32251. */
  32252. __proto._removeRenderObject=function(render){
  32253. if (this._octree){
  32254. this._octree.remove(render);
  32255. }else {
  32256. var endRender;
  32257. if (Render.supportWebGLPlusCulling){
  32258. endRender=this._renders.elements [this._renders.length-1];
  32259. }
  32260. this._renders.remove(render);
  32261. if (Render.supportWebGLPlusCulling){
  32262. this._cullingBufferIndices[endRender._getIndexInList()]=endRender._cullingBufferIndex;
  32263. }
  32264. }
  32265. }
  32266. /**
  32267. *@private
  32268. */
  32269. __proto._addShadowCastRenderObject=function(render){
  32270. if (this._octree){
  32271. }else {
  32272. this._castShadowRenders.add(render);
  32273. }
  32274. }
  32275. /**
  32276. *@private
  32277. */
  32278. __proto._removeShadowCastRenderObject=function(render){
  32279. if (this._octree){
  32280. }else {
  32281. this._castShadowRenders.remove(render);
  32282. }
  32283. }
  32284. /**
  32285. *@private
  32286. */
  32287. __proto._getRenderQueue=function(index){
  32288. if (index <=2500)
  32289. return this._opaqueQueue;
  32290. else
  32291. return this._transparentQueue;
  32292. }
  32293. /**
  32294. *设置光照贴图。
  32295. *@param value 光照贴图。
  32296. */
  32297. __proto.setlightmaps=function(value){
  32298. var maps=this._lightmaps;
  32299. for (var i=0,n=maps.length;i < n;i++)
  32300. maps[i]._removeReference();
  32301. if (value){
  32302. var count=value.length;
  32303. maps.length=count;
  32304. for (i=0;i < count;i++){
  32305. var lightMap=value[i];
  32306. lightMap._addReference();
  32307. maps[i]=lightMap;
  32308. }
  32309. }else {
  32310. throw new Error("Scene3D: value value can't be null.");
  32311. }
  32312. for (i=0,n=this._children.length;i < n;i++)
  32313. this._setLightmapToChildNode(this._children[i]);
  32314. }
  32315. /**
  32316. *获取光照贴图浅拷贝列表。
  32317. *@return 获取光照贴图浅拷贝列表。
  32318. */
  32319. __proto.getlightmaps=function(){
  32320. return this._lightmaps.slice();
  32321. }
  32322. /**
  32323. *@inheritDoc
  32324. */
  32325. __proto.destroy=function(destroyChild){
  32326. (destroyChild===void 0)&& (destroyChild=true);
  32327. if (this.destroyed)
  32328. return;
  32329. _super.prototype.destroy.call(this,destroyChild);
  32330. this._skyRenderer.destroy();
  32331. this._skyRenderer=null;
  32332. this._lights=null;
  32333. this._lightmaps=null;
  32334. this._renderTargetTexture=null;
  32335. this._shaderValues=null;
  32336. this._renders=null;
  32337. this._castShadowRenders=null;
  32338. this._cameraPool=null;
  32339. this._octree=null;
  32340. this.parallelSplitShadowMaps=null;
  32341. this._physicsSimulation && this._physicsSimulation._destroy();
  32342. Loader.clearRes(this.url);
  32343. }
  32344. /**
  32345. *@inheritDoc
  32346. */
  32347. __proto.render=function(ctx,x,y){
  32348. ctx._curSubmit=Submit.RENDERBASE;
  32349. this._children.length > 0 && ctx.addRenderObject(this);
  32350. }
  32351. /**
  32352. *@private
  32353. */
  32354. __proto.renderSubmit=function(){
  32355. var gl=LayaGL.instance;
  32356. this._prepareSceneToRender();
  32357. var i=0,n=0,n1=0;
  32358. for (i=0,n=this._cameraPool.length,n1=n-1;i < n;i++){
  32359. if (Render.supportWebGLPlusRendering)
  32360. ShaderData.setRuntimeValueMode((i==n1)? true :false);
  32361. var camera=this._cameraPool [i];
  32362. camera.enableRender && camera.render();
  32363. }
  32364. Context.set2DRenderConfig();
  32365. return 1;
  32366. }
  32367. /**
  32368. *@private
  32369. */
  32370. __proto.getRenderType=function(){
  32371. return 0;
  32372. }
  32373. /**
  32374. *@private
  32375. */
  32376. __proto.releaseRender=function(){}
  32377. /**
  32378. *@private
  32379. */
  32380. __proto.reUse=function(context,pos){
  32381. return 0;
  32382. }
  32383. /**
  32384. *设置雾化颜色。
  32385. *@param value 雾化颜色。
  32386. */
  32387. /**
  32388. *获取雾化颜色。
  32389. *@return 雾化颜色。
  32390. */
  32391. __getset(0,__proto,'fogColor',function(){
  32392. return this._shaderValues.getVector(laya.d3.core.scene.Scene3D.FOGCOLOR);
  32393. },function(value){
  32394. this._shaderValues.setVector3(laya.d3.core.scene.Scene3D.FOGCOLOR,value);
  32395. });
  32396. /**
  32397. *设置是否允许雾化。
  32398. *@param value 是否允许雾化。
  32399. */
  32400. /**
  32401. *获取是否允许雾化。
  32402. *@return 是否允许雾化。
  32403. */
  32404. __getset(0,__proto,'enableFog',function(){
  32405. return this._enableFog;
  32406. },function(value){
  32407. if (this._enableFog!==value){
  32408. this._enableFog=value;
  32409. if (value){
  32410. this._defineDatas.add(laya.d3.core.scene.Scene3D.SHADERDEFINE_FOG);
  32411. }else
  32412. this._defineDatas.remove(laya.d3.core.scene.Scene3D.SHADERDEFINE_FOG);
  32413. }
  32414. });
  32415. /**
  32416. *获取资源的URL地址。
  32417. *@return URL地址。
  32418. */
  32419. __getset(0,__proto,'url',function(){
  32420. return this._url;
  32421. });
  32422. /**
  32423. *设置雾化起始位置。
  32424. *@param value 雾化起始位置。
  32425. */
  32426. /**
  32427. *获取雾化起始位置。
  32428. *@return 雾化起始位置。
  32429. */
  32430. __getset(0,__proto,'fogStart',function(){
  32431. return this._shaderValues.getNumber(laya.d3.core.scene.Scene3D.FOGSTART);
  32432. },function(value){
  32433. this._shaderValues.setNumber(laya.d3.core.scene.Scene3D.FOGSTART,value);
  32434. });
  32435. /**
  32436. *设置反射强度。
  32437. *@param 反射强度。
  32438. */
  32439. /**
  32440. *获取反射强度。
  32441. *@return 反射强度。
  32442. */
  32443. __getset(0,__proto,'reflectionIntensity',function(){
  32444. return this._shaderValues.getNumber(laya.d3.core.scene.Scene3D.REFLETIONINTENSITY);
  32445. },function(value){
  32446. value=Math.max(Math.min(value,1.0),0.0);
  32447. this._shaderValues.setNumber(laya.d3.core.scene.Scene3D.REFLETIONINTENSITY,value);
  32448. });
  32449. /**
  32450. *获取天空渲染器。
  32451. *@return 天空渲染器。
  32452. */
  32453. __getset(0,__proto,'skyRenderer',function(){
  32454. return this._skyRenderer;
  32455. });
  32456. /**
  32457. *设置雾化范围。
  32458. *@param value 雾化范围。
  32459. */
  32460. /**
  32461. *获取雾化范围。
  32462. *@return 雾化范围。
  32463. */
  32464. __getset(0,__proto,'fogRange',function(){
  32465. return this._shaderValues.getNumber(laya.d3.core.scene.Scene3D.FOGRANGE);
  32466. },function(value){
  32467. this._shaderValues.setNumber(laya.d3.core.scene.Scene3D.FOGRANGE,value);
  32468. });
  32469. /**
  32470. *设置环境光颜色。
  32471. *@param value 环境光颜色。
  32472. */
  32473. /**
  32474. *获取环境光颜色。
  32475. *@return 环境光颜色。
  32476. */
  32477. __getset(0,__proto,'ambientColor',function(){
  32478. return this._shaderValues.getVector(laya.d3.core.scene.Scene3D.AMBIENTCOLOR);
  32479. },function(value){
  32480. this._shaderValues.setVector3(laya.d3.core.scene.Scene3D.AMBIENTCOLOR,value);
  32481. });
  32482. /**
  32483. *设置反射贴图。
  32484. *@param 反射贴图。
  32485. */
  32486. /**
  32487. *获取反射贴图。
  32488. *@return 反射贴图。
  32489. */
  32490. __getset(0,__proto,'customReflection',function(){
  32491. return this._shaderValues.getTexture(laya.d3.core.scene.Scene3D.REFLECTIONTEXTURE);
  32492. },function(value){
  32493. this._shaderValues.setTexture(laya.d3.core.scene.Scene3D.REFLECTIONTEXTURE,value);
  32494. if (value)
  32495. this._defineDatas.add(laya.d3.core.scene.Scene3D.SHADERDEFINE_REFLECTMAP);
  32496. else
  32497. this._defineDatas.remove(laya.d3.core.scene.Scene3D.SHADERDEFINE_REFLECTMAP);
  32498. });
  32499. /**
  32500. *获取物理模拟器。
  32501. *@return 物理模拟器。
  32502. */
  32503. __getset(0,__proto,'physicsSimulation',function(){
  32504. return this._physicsSimulation;
  32505. });
  32506. /**
  32507. *设置反射模式。
  32508. *@param value 反射模式。
  32509. */
  32510. /**
  32511. *获取反射模式。
  32512. *@return 反射模式。
  32513. */
  32514. __getset(0,__proto,'reflectionMode',function(){
  32515. return this._reflectionMode;
  32516. },function(value){
  32517. this._reflectionMode=value;
  32518. });
  32519. /**
  32520. *设置场景时钟。
  32521. */
  32522. /**
  32523. *获取场景时钟。
  32524. */
  32525. __getset(0,__proto,'timer',function(){
  32526. return this._timer;
  32527. },function(value){
  32528. this._timer=value;
  32529. });
  32530. /**
  32531. *获取输入。
  32532. *@return 输入。
  32533. */
  32534. __getset(0,__proto,'input',function(){
  32535. return this._input;
  32536. });
  32537. Scene3D._parse=function(data,propertyParams,constructParams){
  32538. var json=data.data;
  32539. var outBatchSprits=[];
  32540. var scene;
  32541. switch (data.version){
  32542. case "LAYAHIERARCHY:02":
  32543. scene=Utils3D._createNodeByJson02(json,outBatchSprits);
  32544. break ;
  32545. default :
  32546. scene=Utils3D._createNodeByJson(json,outBatchSprits);
  32547. }
  32548. StaticBatchManager.combine(null,outBatchSprits);
  32549. return scene;
  32550. }
  32551. Scene3D.load=function(url,complete){
  32552. Laya.loader.create(url,complete,null,/*Laya3D.HIERARCHY*/"HIERARCHY");
  32553. }
  32554. Scene3D.REFLECTIONMODE_SKYBOX=0;
  32555. Scene3D.REFLECTIONMODE_CUSTOM=1;
  32556. Scene3D.SHADERDEFINE_FOG=0;
  32557. Scene3D.SHADERDEFINE_DIRECTIONLIGHT=0;
  32558. Scene3D.SHADERDEFINE_POINTLIGHT=0;
  32559. Scene3D.SHADERDEFINE_SPOTLIGHT=0;
  32560. Scene3D.SHADERDEFINE_CAST_SHADOW=0;
  32561. Scene3D.SHADERDEFINE_SHADOW_PSSM1=0;
  32562. Scene3D.SHADERDEFINE_SHADOW_PSSM2=0;
  32563. Scene3D.SHADERDEFINE_SHADOW_PSSM3=0;
  32564. Scene3D.SHADERDEFINE_SHADOW_PCF_NO=0;
  32565. Scene3D.SHADERDEFINE_SHADOW_PCF1=0;
  32566. Scene3D.SHADERDEFINE_SHADOW_PCF2=0;
  32567. Scene3D.SHADERDEFINE_SHADOW_PCF3=0;
  32568. Scene3D.SHADERDEFINE_REFLECTMAP=0;
  32569. __static(Scene3D,
  32570. ['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");}
  32571. ]);
  32572. return Scene3D;
  32573. })(Sprite)
  32574. /**
  32575. *<code>RenderableSprite3D</code> 类用于可渲染3D精灵的父类,抽象类不允许实例。
  32576. */
  32577. //class laya.d3.core.RenderableSprite3D extends laya.d3.core.Sprite3D
  32578. var RenderableSprite3D=(function(_super){
  32579. function RenderableSprite3D(name){
  32580. this.pickColor=null;
  32581. /**@private */
  32582. this._render=null;
  32583. RenderableSprite3D.__super.call(this,name);
  32584. }
  32585. __class(RenderableSprite3D,'laya.d3.core.RenderableSprite3D',_super);
  32586. var __proto=RenderableSprite3D.prototype;
  32587. /**
  32588. *@inheritDoc
  32589. */
  32590. __proto._onInActive=function(){
  32591. laya.display.Node.prototype._onInActive.call(this);
  32592. var scene3D=this._scene;
  32593. scene3D._removeRenderObject(this._render);
  32594. (this._render.castShadow)&& (scene3D._removeShadowCastRenderObject(this._render));
  32595. }
  32596. /**
  32597. *@inheritDoc
  32598. */
  32599. __proto._onActive=function(){
  32600. laya.display.Node.prototype._onActive.call(this);
  32601. var scene3D=this._scene;
  32602. scene3D._addRenderObject(this._render);
  32603. (this._render.castShadow)&& (scene3D._addShadowCastRenderObject(this._render));
  32604. }
  32605. /**
  32606. *@inheritDoc
  32607. */
  32608. __proto._onActiveInScene=function(){
  32609. laya.display.Node.prototype._onActiveInScene.call(this);
  32610. if (Laya3D._editerEnvironment){
  32611. var scene=this._scene;
  32612. var pickColor=new Vector4();
  32613. scene._allotPickColorByID(this.id,pickColor);
  32614. scene._pickIdToSprite[this.id]=this;
  32615. this._render._shaderValues.setVector(laya.d3.core.RenderableSprite3D.PICKCOLOR,pickColor);
  32616. }
  32617. }
  32618. /**
  32619. *@private
  32620. */
  32621. __proto._addToInitStaticBatchManager=function(){}
  32622. /**
  32623. *@inheritDoc
  32624. */
  32625. __proto._setBelongScene=function(scene){
  32626. laya.display.Node.prototype._setBelongScene.call(this,scene);
  32627. this._render._setBelongScene(scene);
  32628. }
  32629. /**
  32630. *@inheritDoc
  32631. */
  32632. __proto._setUnBelongScene=function(){
  32633. this._render._defineDatas.remove(laya.d3.core.RenderableSprite3D.SAHDERDEFINE_LIGHTMAP);
  32634. laya.display.Node.prototype._setUnBelongScene.call(this);
  32635. }
  32636. /**
  32637. *@inheritDoc
  32638. */
  32639. __proto._changeHierarchyAnimator=function(animator){
  32640. if (this._hierarchyAnimator){
  32641. var renderableSprites=this._hierarchyAnimator._renderableSprites;
  32642. renderableSprites.splice(renderableSprites.indexOf(this),1);
  32643. }
  32644. if (animator)
  32645. animator._renderableSprites.push(this);
  32646. _super.prototype._changeHierarchyAnimator.call(this,animator);
  32647. }
  32648. /**
  32649. *@inheritDoc
  32650. */
  32651. __proto.destroy=function(destroyChild){
  32652. (destroyChild===void 0)&& (destroyChild=true);
  32653. _super.prototype.destroy.call(this,destroyChild);
  32654. this._render._destroy();
  32655. this._render=null;
  32656. }
  32657. RenderableSprite3D.__init__=function(){
  32658. RenderableSprite3D.SHADERDEFINE_RECEIVE_SHADOW=RenderableSprite3D.shaderDefines.registerDefine("RECEIVESHADOW");
  32659. RenderableSprite3D.SHADERDEFINE_SCALEOFFSETLIGHTINGMAPUV=RenderableSprite3D.shaderDefines.registerDefine("SCALEOFFSETLIGHTINGMAPUV");
  32660. RenderableSprite3D.SAHDERDEFINE_LIGHTMAP=RenderableSprite3D.shaderDefines.registerDefine("LIGHTMAP");
  32661. }
  32662. RenderableSprite3D.SHADERDEFINE_RECEIVE_SHADOW=0;
  32663. RenderableSprite3D.SHADERDEFINE_SCALEOFFSETLIGHTINGMAPUV=0;
  32664. RenderableSprite3D.SAHDERDEFINE_LIGHTMAP=0;
  32665. __static(RenderableSprite3D,
  32666. ['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();}
  32667. ]);
  32668. return RenderableSprite3D;
  32669. })(Sprite3D)
  32670. /**
  32671. *<code>TrailMaterial</code> 类用于实现拖尾材质。
  32672. */
  32673. //class laya.d3.core.trail.TrailMaterial extends laya.d3.core.material.BaseMaterial
  32674. var TrailMaterial=(function(_super){
  32675. function TrailMaterial(){
  32676. /**@private */
  32677. this._color=null;
  32678. TrailMaterial.__super.call(this);
  32679. this.setShaderName("Trail");
  32680. this._color=new Vector4(1.0,1.0,1.0,1.0);
  32681. this._shaderValues.setVector(TrailMaterial.TINTCOLOR,new Vector4(1.0,1.0,1.0,1.0));
  32682. this.renderMode=0;
  32683. }
  32684. __class(TrailMaterial,'laya.d3.core.trail.TrailMaterial',_super);
  32685. var __proto=TrailMaterial.prototype;
  32686. /**
  32687. *@private
  32688. */
  32689. /**
  32690. *@private
  32691. */
  32692. __getset(0,__proto,'_TintColorB',function(){
  32693. return this._color.z;
  32694. },function(value){
  32695. this._color.z=value;
  32696. this.color=this._color;
  32697. });
  32698. /**
  32699. *@private
  32700. */
  32701. /**
  32702. *@private
  32703. */
  32704. __getset(0,__proto,'_MainTex_STZ',function(){
  32705. return this._shaderValues.getVector(TrailMaterial.TILINGOFFSET).z;
  32706. },function(z){
  32707. var tilOff=this._shaderValues.getVector(TrailMaterial.TILINGOFFSET);
  32708. tilOff.z=z;
  32709. this.tilingOffset=tilOff;
  32710. });
  32711. /**
  32712. *设置贴图。
  32713. *@param value 贴图。
  32714. */
  32715. /**
  32716. *获取贴图。
  32717. *@return 贴图。
  32718. */
  32719. __getset(0,__proto,'texture',function(){
  32720. return this._shaderValues.getTexture(TrailMaterial.MAINTEXTURE);
  32721. },function(value){
  32722. if (value)
  32723. this._defineDatas.add(laya.d3.core.trail.TrailMaterial.SHADERDEFINE_MAINTEXTURE);
  32724. else
  32725. this._defineDatas.remove(laya.d3.core.trail.TrailMaterial.SHADERDEFINE_MAINTEXTURE);
  32726. this._shaderValues.setTexture(TrailMaterial.MAINTEXTURE,value);
  32727. });
  32728. /**
  32729. *@private
  32730. */
  32731. /**
  32732. *@private
  32733. */
  32734. __getset(0,__proto,'_TintColorR',function(){
  32735. return this._color.x;
  32736. },function(value){
  32737. this._color.x=value;
  32738. this.color=this._color;
  32739. });
  32740. /**
  32741. *@private
  32742. */
  32743. /**
  32744. *@private
  32745. */
  32746. __getset(0,__proto,'_MainTex_STW',function(){
  32747. return this._shaderValues.getVector(TrailMaterial.TILINGOFFSET).w;
  32748. },function(w){
  32749. var tilOff=this._shaderValues.getVector(TrailMaterial.TILINGOFFSET);
  32750. tilOff.w=w;
  32751. this.tilingOffset=tilOff;
  32752. });
  32753. /**
  32754. *@private
  32755. */
  32756. /**
  32757. *@private
  32758. */
  32759. __getset(0,__proto,'_TintColorG',function(){
  32760. return this._color.y;
  32761. },function(value){
  32762. this._color.y=value;
  32763. this.color=this._color;
  32764. });
  32765. /**
  32766. *@private
  32767. */
  32768. /**@private */
  32769. __getset(0,__proto,'_TintColorA',function(){
  32770. return this._color.w;
  32771. },function(value){
  32772. this._color.w=value;
  32773. this.color=this._color;
  32774. });
  32775. /**
  32776. *@private
  32777. */
  32778. /**
  32779. *@private
  32780. */
  32781. __getset(0,__proto,'_MainTex_STY',function(){
  32782. return this._shaderValues.getVector(TrailMaterial.TILINGOFFSET).y;
  32783. },function(y){
  32784. var tilOff=this._shaderValues.getVector(TrailMaterial.TILINGOFFSET);
  32785. tilOff.y=y;
  32786. this.tilingOffset=tilOff;
  32787. });
  32788. /**
  32789. *设置渲染模式。
  32790. *@return 渲染模式。
  32791. */
  32792. __getset(0,__proto,'renderMode',null,function(value){
  32793. switch (value){
  32794. case 1:
  32795. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_TRANSPARENT*/3000;
  32796. this.alphaTest=false;
  32797. this.depthWrite=false;
  32798. this.cull=/*laya.d3.core.material.RenderState.CULL_NONE*/0;
  32799. this.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  32800. this.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_SRC_ALPHA*/0x0302;
  32801. this.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE*/1;
  32802. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  32803. this._defineDatas.add(TrailMaterial.SHADERDEFINE_ADDTIVEFOG);
  32804. break ;
  32805. case 0:
  32806. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_TRANSPARENT*/3000;
  32807. this.alphaTest=false;
  32808. this.depthWrite=false;
  32809. this.cull=/*laya.d3.core.material.RenderState.CULL_NONE*/0;
  32810. this.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  32811. this.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_SRC_ALPHA*/0x0302;
  32812. this.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA*/0x0303;
  32813. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  32814. this._defineDatas.remove(TrailMaterial.SHADERDEFINE_ADDTIVEFOG);
  32815. break ;
  32816. default :
  32817. throw new Error("TrailMaterial : renderMode value error.");
  32818. }
  32819. });
  32820. /**
  32821. *@private
  32822. */
  32823. /**
  32824. *@private
  32825. */
  32826. __getset(0,__proto,'_MainTex_STX',function(){
  32827. return this._shaderValues.getVector(TrailMaterial.TILINGOFFSET).x;
  32828. },function(x){
  32829. var tilOff=this._shaderValues.getVector(TrailMaterial.TILINGOFFSET);
  32830. tilOff.x=x;
  32831. this.tilingOffset=tilOff;
  32832. });
  32833. /**
  32834. *设置颜色R分量。
  32835. *@param value 颜色R分量。
  32836. */
  32837. /**
  32838. *获取颜色R分量。
  32839. *@return 颜色R分量。
  32840. */
  32841. __getset(0,__proto,'colorR',function(){
  32842. return this._TintColorR;
  32843. },function(value){
  32844. this._TintColorR=value;
  32845. });
  32846. /**
  32847. *设置颜色G分量。
  32848. *@param value 颜色G分量。
  32849. */
  32850. /**
  32851. *获取颜色G分量。
  32852. *@return 颜色G分量。
  32853. */
  32854. __getset(0,__proto,'colorG',function(){
  32855. return this._TintColorG;
  32856. },function(value){
  32857. this._TintColorG=value;
  32858. });
  32859. /**
  32860. *设置颜色B分量。
  32861. *@param value 颜色B分量。
  32862. */
  32863. /**
  32864. *获取颜色B分量。
  32865. *@return 颜色B分量。
  32866. */
  32867. __getset(0,__proto,'colorB',function(){
  32868. return this._TintColorB;
  32869. },function(value){
  32870. this._TintColorB=value;
  32871. });
  32872. /**
  32873. *设置颜色alpha分量。
  32874. *@param value 颜色alpha分量。
  32875. */
  32876. /**
  32877. *获取颜色Z分量。
  32878. *@return 颜色Z分量。
  32879. */
  32880. __getset(0,__proto,'colorA',function(){
  32881. return this._TintColorA;
  32882. },function(value){
  32883. this._TintColorA=value;
  32884. });
  32885. /**
  32886. *设置混合方式。
  32887. *@param value 混合方式。
  32888. */
  32889. /**
  32890. *获取混合方式。
  32891. *@return 混合方式。
  32892. */
  32893. __getset(0,__proto,'blend',function(){
  32894. return this._shaderValues.getInt(TrailMaterial.BLEND);
  32895. },function(value){
  32896. this._shaderValues.setInt(TrailMaterial.BLEND,value);
  32897. });
  32898. /**
  32899. *设置颜色。
  32900. *@param value 颜色。
  32901. */
  32902. /**
  32903. *获取颜色。
  32904. *@return 颜色。
  32905. */
  32906. __getset(0,__proto,'color',function(){
  32907. return this._shaderValues.getVector(TrailMaterial.TINTCOLOR);
  32908. },function(value){
  32909. this._shaderValues.setVector(TrailMaterial.TINTCOLOR,value);
  32910. });
  32911. /**
  32912. *获取纹理平铺和偏移X分量。
  32913. *@param x 纹理平铺和偏移X分量。
  32914. */
  32915. /**
  32916. *获取纹理平铺和偏移X分量。
  32917. *@return 纹理平铺和偏移X分量。
  32918. */
  32919. __getset(0,__proto,'tilingOffsetX',function(){
  32920. return this._MainTex_STX;
  32921. },function(x){
  32922. this._MainTex_STX=x;
  32923. });
  32924. /**
  32925. *获取纹理平铺和偏移Y分量。
  32926. *@param y 纹理平铺和偏移Y分量。
  32927. */
  32928. /**
  32929. *获取纹理平铺和偏移Y分量。
  32930. *@return 纹理平铺和偏移Y分量。
  32931. */
  32932. __getset(0,__proto,'tilingOffsetY',function(){
  32933. return this._MainTex_STY;
  32934. },function(y){
  32935. this._MainTex_STY=y;
  32936. });
  32937. /**
  32938. *获取纹理平铺和偏移Z分量。
  32939. *@param z 纹理平铺和偏移Z分量。
  32940. */
  32941. /**
  32942. *获取纹理平铺和偏移Z分量。
  32943. *@return 纹理平铺和偏移Z分量。
  32944. */
  32945. __getset(0,__proto,'tilingOffsetZ',function(){
  32946. return this._MainTex_STZ;
  32947. },function(z){
  32948. this._MainTex_STZ=z;
  32949. });
  32950. /**
  32951. *设置混合源。
  32952. *@param value 混合源
  32953. */
  32954. /**
  32955. *获取混合源。
  32956. *@return 混合源。
  32957. */
  32958. __getset(0,__proto,'blendSrc',function(){
  32959. return this._shaderValues.getInt(TrailMaterial.BLEND_SRC);
  32960. },function(value){
  32961. this._shaderValues.setInt(TrailMaterial.BLEND_SRC,value);
  32962. });
  32963. /**
  32964. *获取纹理平铺和偏移W分量。
  32965. *@param w 纹理平铺和偏移W分量。
  32966. */
  32967. /**
  32968. *获取纹理平铺和偏移W分量。
  32969. *@return 纹理平铺和偏移W分量。
  32970. */
  32971. __getset(0,__proto,'tilingOffsetW',function(){
  32972. return this._MainTex_STW;
  32973. },function(w){
  32974. this._MainTex_STW=w;
  32975. });
  32976. /**
  32977. *设置纹理平铺和偏移。
  32978. *@param value 纹理平铺和偏移。
  32979. */
  32980. /**
  32981. *获取纹理平铺和偏移。
  32982. *@return 纹理平铺和偏移。
  32983. */
  32984. __getset(0,__proto,'tilingOffset',function(){
  32985. return this._shaderValues.getVector(TrailMaterial.TILINGOFFSET);
  32986. },function(value){
  32987. if (value){
  32988. if (value.x !=1 || value.y !=1 || value.z !=0 || value.w !=0)
  32989. this._defineDatas.add(laya.d3.core.trail.TrailMaterial.SHADERDEFINE_TILINGOFFSET);
  32990. else
  32991. this._defineDatas.remove(laya.d3.core.trail.TrailMaterial.SHADERDEFINE_TILINGOFFSET);
  32992. }else {
  32993. this._defineDatas.remove(laya.d3.core.trail.TrailMaterial.SHADERDEFINE_TILINGOFFSET);
  32994. }
  32995. this._shaderValues.setVector(TrailMaterial.TILINGOFFSET,value);
  32996. });
  32997. /**
  32998. *设置是否写入深度。
  32999. *@param value 是否写入深度。
  33000. */
  33001. /**
  33002. *获取是否写入深度。
  33003. *@return 是否写入深度。
  33004. */
  33005. __getset(0,__proto,'depthWrite',function(){
  33006. return this._shaderValues.getBool(TrailMaterial.DEPTH_WRITE);
  33007. },function(value){
  33008. this._shaderValues.setBool(TrailMaterial.DEPTH_WRITE,value);
  33009. });
  33010. /**
  33011. *设置剔除方式。
  33012. *@param value 剔除方式。
  33013. */
  33014. /**
  33015. *获取剔除方式。
  33016. *@return 剔除方式。
  33017. */
  33018. __getset(0,__proto,'cull',function(){
  33019. return this._shaderValues.getInt(TrailMaterial.CULL);
  33020. },function(value){
  33021. this._shaderValues.setInt(TrailMaterial.CULL,value);
  33022. });
  33023. /**
  33024. *设置混合目标。
  33025. *@param value 混合目标
  33026. */
  33027. /**
  33028. *获取混合目标。
  33029. *@return 混合目标。
  33030. */
  33031. __getset(0,__proto,'blendDst',function(){
  33032. return this._shaderValues.getInt(TrailMaterial.BLEND_DST);
  33033. },function(value){
  33034. this._shaderValues.setInt(TrailMaterial.BLEND_DST,value);
  33035. });
  33036. /**
  33037. *设置深度测试方式。
  33038. *@param value 深度测试方式
  33039. */
  33040. /**
  33041. *获取深度测试方式。
  33042. *@return 深度测试方式。
  33043. */
  33044. __getset(0,__proto,'depthTest',function(){
  33045. return this._shaderValues.getInt(TrailMaterial.DEPTH_TEST);
  33046. },function(value){
  33047. this._shaderValues.setInt(TrailMaterial.DEPTH_TEST,value);
  33048. });
  33049. TrailMaterial.__init__=function(){
  33050. TrailMaterial.SHADERDEFINE_MAINTEXTURE=TrailMaterial.shaderDefines.registerDefine("MAINTEXTURE");
  33051. TrailMaterial.SHADERDEFINE_TILINGOFFSET=TrailMaterial.shaderDefines.registerDefine("TILINGOFFSET");
  33052. TrailMaterial.SHADERDEFINE_ADDTIVEFOG=TrailMaterial.shaderDefines.registerDefine("ADDTIVEFOG");
  33053. }
  33054. TrailMaterial.RENDERMODE_ALPHABLENDED=0;
  33055. TrailMaterial.RENDERMODE_ADDTIVE=1;
  33056. TrailMaterial.SHADERDEFINE_MAINTEXTURE=0;
  33057. TrailMaterial.SHADERDEFINE_TILINGOFFSET=0;
  33058. TrailMaterial.SHADERDEFINE_ADDTIVEFOG=0;
  33059. __static(TrailMaterial,
  33060. ['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);}
  33061. ]);
  33062. return TrailMaterial;
  33063. })(BaseMaterial)
  33064. /**
  33065. *<code>PBRSpecularMaterial</code> 类用于实现PBR(Specular)材质。
  33066. */
  33067. //class laya.d3.core.material.PBRSpecularMaterial extends laya.d3.core.material.BaseMaterial
  33068. var PBRSpecularMaterial=(function(_super){
  33069. function PBRSpecularMaterial(){
  33070. /**@private */
  33071. this._albedoColor=null;
  33072. /**@private */
  33073. this._specularColor=null;
  33074. /**@private */
  33075. this._emissionColor=null;
  33076. PBRSpecularMaterial.__super.call(this);
  33077. this.setShaderName("PBRSpecular");
  33078. this._albedoColor=new Vector4(1.0,1.0,1.0,1.0);
  33079. this._shaderValues.setVector(PBRSpecularMaterial.ALBEDOCOLOR,new Vector4(1.0,1.0,1.0,1.0));
  33080. this._emissionColor=new Vector4(0.0,0.0,0.0,0.0);
  33081. this._shaderValues.setVector(PBRSpecularMaterial.EMISSIONCOLOR,new Vector4(0.0,0.0,0.0,0.0));
  33082. this._specularColor=new Vector4(0.2,0.2,0.2,0.2);
  33083. this._shaderValues.setVector(PBRSpecularMaterial.SPECULARCOLOR,new Vector4(0.2,0.2,0.2,0.2));
  33084. this._shaderValues.setNumber(PBRSpecularMaterial.SMOOTHNESS,0.5);
  33085. this._shaderValues.setNumber(PBRSpecularMaterial.SMOOTHNESSSCALE,1.0);
  33086. this._shaderValues.setNumber(PBRSpecularMaterial.SMOOTHNESSSOURCE,0);
  33087. this._shaderValues.setNumber(PBRSpecularMaterial.OCCLUSIONSTRENGTH,1.0);
  33088. this._shaderValues.setNumber(PBRSpecularMaterial.NORMALSCALE,1.0);
  33089. this._shaderValues.setNumber(PBRSpecularMaterial.PARALLAXSCALE,0.001);
  33090. this._shaderValues.setBool(PBRSpecularMaterial.ENABLEEMISSION,false);
  33091. this._shaderValues.setNumber(BaseMaterial.ALPHATESTVALUE,0.5);
  33092. this.renderMode=0;
  33093. }
  33094. __class(PBRSpecularMaterial,'laya.d3.core.material.PBRSpecularMaterial',_super);
  33095. var __proto=PBRSpecularMaterial.prototype;
  33096. /**
  33097. *@inheritDoc
  33098. */
  33099. __proto.cloneTo=function(destObject){
  33100. _super.prototype.cloneTo.call(this,destObject);
  33101. var destMaterial=destObject;
  33102. this._albedoColor.cloneTo(destMaterial._albedoColor);
  33103. this._specularColor.cloneTo(destMaterial._specularColor);
  33104. this._emissionColor.cloneTo(destMaterial._emissionColor);
  33105. }
  33106. /**
  33107. *设置放射贴图。
  33108. *@param value 放射贴图。
  33109. */
  33110. /**
  33111. *获取放射贴图。
  33112. *@return 放射贴图。
  33113. */
  33114. __getset(0,__proto,'emissionTexture',function(){
  33115. return this._shaderValues.getTexture(PBRSpecularMaterial.EMISSIONTEXTURE);
  33116. },function(value){
  33117. if (value)
  33118. this._defineDatas.add(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_EMISSIONTEXTURE);
  33119. else
  33120. this._defineDatas.remove(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_EMISSIONTEXTURE);
  33121. this._shaderValues.setTexture(PBRSpecularMaterial.EMISSIONTEXTURE,value);
  33122. });
  33123. /**
  33124. *@private
  33125. */
  33126. /**
  33127. *@private
  33128. */
  33129. __getset(0,__proto,'_SpecColorG',function(){
  33130. return this._specularColor.y;
  33131. },function(value){
  33132. this._specularColor.y=value;
  33133. this.specularColor=this._specularColor;
  33134. });
  33135. /**
  33136. *@private
  33137. */
  33138. /**
  33139. *@private
  33140. */
  33141. __getset(0,__proto,'_ColorB',function(){
  33142. return this._albedoColor.z;
  33143. },function(value){
  33144. this._albedoColor.z=value;
  33145. this.albedoColor=this._albedoColor;
  33146. });
  33147. /**
  33148. *@private
  33149. */
  33150. /**
  33151. *@private
  33152. */
  33153. __getset(0,__proto,'_ColorR',function(){
  33154. return this._albedoColor.x;
  33155. },function(value){
  33156. this._albedoColor.x=value;
  33157. this.albedoColor=this._albedoColor;
  33158. });
  33159. /**
  33160. *设置反射率颜色A分量。
  33161. *@param value 反射率颜色A分量。
  33162. */
  33163. /**
  33164. *获取反射率颜色A分量。
  33165. *@return 反射率颜色A分量。
  33166. */
  33167. __getset(0,__proto,'albedoColorA',function(){
  33168. return this._ColorA;
  33169. },function(value){
  33170. this._ColorA=value;
  33171. });
  33172. /**
  33173. *@private
  33174. */
  33175. /**
  33176. *@private
  33177. */
  33178. __getset(0,__proto,'_MainTex_STX',function(){
  33179. return this._shaderValues.getVector(PBRSpecularMaterial.TILINGOFFSET).x;
  33180. },function(x){
  33181. var tilOff=this._shaderValues.getVector(PBRSpecularMaterial.TILINGOFFSET);
  33182. tilOff.x=x;
  33183. this.tilingOffset=tilOff;
  33184. });
  33185. /**
  33186. *@private
  33187. */
  33188. /**
  33189. *@private
  33190. */
  33191. __getset(0,__proto,'_SpecColorB',function(){
  33192. return this._specularColor.z;
  33193. },function(value){
  33194. this._specularColor.z=value;
  33195. this.specularColor=this._specularColor;
  33196. });
  33197. /**
  33198. *设置渲染模式。
  33199. *@return 渲染模式。
  33200. */
  33201. __getset(0,__proto,'renderMode',null,function(value){
  33202. switch (value){
  33203. case 0:
  33204. this.alphaTest=false;
  33205. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_OPAQUE*/2000;
  33206. this.depthWrite=true;
  33207. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  33208. this.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  33209. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  33210. this._defineDatas.remove(PBRSpecularMaterial.SHADERDEFINE_ALPHAPREMULTIPLY);
  33211. break ;
  33212. case 1:
  33213. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_ALPHATEST*/2450;
  33214. this.alphaTest=true;
  33215. this.depthWrite=true;
  33216. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  33217. this.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  33218. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  33219. this._defineDatas.remove(PBRSpecularMaterial.SHADERDEFINE_ALPHAPREMULTIPLY);
  33220. break ;
  33221. case 2:
  33222. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_TRANSPARENT*/3000;
  33223. this.alphaTest=false;
  33224. this.depthWrite=false;
  33225. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  33226. this.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  33227. this.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_SRC_ALPHA*/0x0302;
  33228. this.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA*/0x0303;
  33229. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  33230. this._defineDatas.remove(PBRSpecularMaterial.SHADERDEFINE_ALPHAPREMULTIPLY);
  33231. break ;
  33232. break ;
  33233. case 3:
  33234. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_TRANSPARENT*/3000;
  33235. this.alphaTest=false;
  33236. this.depthWrite=false;
  33237. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  33238. this.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  33239. this.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE*/1;
  33240. this.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA*/0x0303;
  33241. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  33242. this._defineDatas.add(PBRSpecularMaterial.SHADERDEFINE_ALPHAPREMULTIPLY);
  33243. break ;
  33244. default :
  33245. throw new Error("PBRSpecularMaterial : renderMode value error.");
  33246. }
  33247. });
  33248. /**
  33249. *@private
  33250. */
  33251. /**
  33252. *@private
  33253. */
  33254. __getset(0,__proto,'_SpecColorR',function(){
  33255. return this._specularColor.x;
  33256. },function(value){
  33257. this._specularColor.x=value;
  33258. this.specularColor=this._specularColor;
  33259. });
  33260. /**
  33261. *@private
  33262. */
  33263. /**
  33264. *@private
  33265. */
  33266. __getset(0,__proto,'_ColorG',function(){
  33267. return this._albedoColor.y;
  33268. },function(value){
  33269. this._albedoColor.y=value;
  33270. this.albedoColor=this._albedoColor;
  33271. });
  33272. /**
  33273. *@private
  33274. */
  33275. /**
  33276. *@private
  33277. */
  33278. __getset(0,__proto,'_Glossiness',function(){
  33279. return this._shaderValues.getNumber(PBRSpecularMaterial.SMOOTHNESS);
  33280. },function(value){
  33281. this._shaderValues.setNumber(PBRSpecularMaterial.SMOOTHNESS,value);
  33282. });
  33283. /**
  33284. *@private
  33285. */
  33286. /**
  33287. *@private
  33288. */
  33289. __getset(0,__proto,'_ColorA',function(){
  33290. return this._albedoColor.w;
  33291. },function(value){
  33292. this._albedoColor.w=value;
  33293. this.albedoColor=this._albedoColor;
  33294. });
  33295. /**
  33296. *设置高光颜色。
  33297. *@param value 高光颜色。
  33298. */
  33299. /**
  33300. *获取高光颜色。
  33301. *@return 高光颜色。
  33302. */
  33303. __getset(0,__proto,'specularColor',function(){
  33304. return this._shaderValues.getVector(PBRSpecularMaterial.SPECULARCOLOR);
  33305. },function(value){
  33306. this._shaderValues.setVector(PBRSpecularMaterial.SPECULARCOLOR,value);
  33307. });
  33308. /**
  33309. *设置反射率颜色B分量。
  33310. *@param value 反射率颜色B分量。
  33311. */
  33312. /**
  33313. *获取反射率颜色B分量。
  33314. *@return 反射率颜色B分量。
  33315. */
  33316. __getset(0,__proto,'albedoColorB',function(){
  33317. return this._ColorB;
  33318. },function(value){
  33319. this._ColorB=value;
  33320. });
  33321. /**
  33322. *@private
  33323. */
  33324. /**
  33325. *@private
  33326. */
  33327. __getset(0,__proto,'_SpecColorA',function(){
  33328. return this._specularColor.w;
  33329. },function(value){
  33330. this._specularColor.w=value;
  33331. this.specularColor=this._specularColor;
  33332. });
  33333. /**
  33334. *@private
  33335. */
  33336. /**
  33337. *@private
  33338. */
  33339. __getset(0,__proto,'_GlossMapScale',function(){
  33340. return this._shaderValues.getNumber(PBRSpecularMaterial.SMOOTHNESSSCALE);
  33341. },function(value){
  33342. this._shaderValues.setNumber(PBRSpecularMaterial.SMOOTHNESSSCALE,value);
  33343. });
  33344. /**
  33345. *@private
  33346. */
  33347. /**
  33348. *@private
  33349. */
  33350. __getset(0,__proto,'_BumpScale',function(){
  33351. return this._shaderValues.getNumber(PBRSpecularMaterial.NORMALSCALE);
  33352. },function(value){
  33353. this._shaderValues.setNumber(PBRSpecularMaterial.NORMALSCALE,value);
  33354. });
  33355. /**
  33356. *@private
  33357. */
  33358. /**@private */
  33359. __getset(0,__proto,'_Parallax',function(){
  33360. return this._shaderValues.getNumber(PBRSpecularMaterial.PARALLAXSCALE);
  33361. },function(value){
  33362. this._shaderValues.setNumber(PBRSpecularMaterial.PARALLAXSCALE,value);
  33363. });
  33364. /**
  33365. *@private
  33366. */
  33367. /**@private */
  33368. __getset(0,__proto,'_OcclusionStrength',function(){
  33369. return this._shaderValues.getNumber(PBRSpecularMaterial.OCCLUSIONSTRENGTH);
  33370. },function(value){
  33371. this._shaderValues.setNumber(PBRSpecularMaterial.OCCLUSIONSTRENGTH,value);
  33372. });
  33373. /**
  33374. *@private
  33375. */
  33376. /**
  33377. *@private
  33378. */
  33379. __getset(0,__proto,'_EmissionColorR',function(){
  33380. return this._emissionColor.x;
  33381. },function(value){
  33382. this._emissionColor.x=value;
  33383. this.emissionColor=this._emissionColor;
  33384. });
  33385. /**
  33386. *获取纹理平铺和偏移。
  33387. *@param value 纹理平铺和偏移。
  33388. */
  33389. /**
  33390. *获取纹理平铺和偏移。
  33391. *@return 纹理平铺和偏移。
  33392. */
  33393. __getset(0,__proto,'tilingOffset',function(){
  33394. return this._shaderValues.getVector(PBRSpecularMaterial.TILINGOFFSET);
  33395. },function(value){
  33396. if (value){
  33397. if (value.x !=1 || value.y !=1 || value.z !=0 || value.w !=0)
  33398. this._defineDatas.add(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_TILINGOFFSET);
  33399. else
  33400. this._defineDatas.remove(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_TILINGOFFSET);
  33401. }else {
  33402. this._defineDatas.remove(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_TILINGOFFSET);
  33403. }
  33404. this._shaderValues.setVector(PBRSpecularMaterial.TILINGOFFSET,value);
  33405. });
  33406. /**
  33407. *@private
  33408. */
  33409. /**
  33410. *@private
  33411. */
  33412. __getset(0,__proto,'_EmissionColorG',function(){
  33413. return this._emissionColor.y;
  33414. },function(value){
  33415. this._emissionColor.y=value;
  33416. this.emissionColor=this._emissionColor;
  33417. });
  33418. /**
  33419. *设置混合源。
  33420. *@param value 混合源
  33421. */
  33422. /**
  33423. *获取混合源。
  33424. *@return 混合源。
  33425. */
  33426. __getset(0,__proto,'blendSrc',function(){
  33427. return this._shaderValues.getInt(PBRSpecularMaterial.BLEND_SRC);
  33428. },function(value){
  33429. this._shaderValues.setInt(PBRSpecularMaterial.BLEND_SRC,value);
  33430. });
  33431. /**
  33432. *获取纹理平铺和偏移W分量。
  33433. *@param w 纹理平铺和偏移W分量。
  33434. */
  33435. /**
  33436. *获取纹理平铺和偏移W分量。
  33437. *@return 纹理平铺和偏移W分量。
  33438. */
  33439. __getset(0,__proto,'tilingOffsetW',function(){
  33440. return this._MainTex_STW;
  33441. },function(w){
  33442. this._MainTex_STW=w;
  33443. });
  33444. /**
  33445. *@private
  33446. */
  33447. /**
  33448. *@private
  33449. */
  33450. __getset(0,__proto,'_EmissionColorB',function(){
  33451. return this._emissionColor.z;
  33452. },function(value){
  33453. this._emissionColor.z=value;
  33454. this.emissionColor=this._emissionColor;
  33455. });
  33456. /**
  33457. *@private
  33458. */
  33459. /**
  33460. *@private
  33461. */
  33462. __getset(0,__proto,'_EmissionColorA',function(){
  33463. return this._emissionColor.w;
  33464. },function(value){
  33465. this._emissionColor.w=value;
  33466. this.emissionColor=this._emissionColor;
  33467. });
  33468. /**
  33469. *@private
  33470. */
  33471. /**
  33472. *@private
  33473. */
  33474. __getset(0,__proto,'_MainTex_STY',function(){
  33475. return this._shaderValues.getVector(PBRSpecularMaterial.TILINGOFFSET).y;
  33476. },function(y){
  33477. var tilOff=this._shaderValues.getVector(PBRSpecularMaterial.TILINGOFFSET);
  33478. tilOff.y=y;
  33479. this.tilingOffset=tilOff;
  33480. });
  33481. /**
  33482. *@private
  33483. */
  33484. /**
  33485. *@private
  33486. */
  33487. __getset(0,__proto,'_MainTex_STZ',function(){
  33488. return this._shaderValues.getVector(PBRSpecularMaterial.TILINGOFFSET).z;
  33489. },function(z){
  33490. var tilOff=this._shaderValues.getVector(PBRSpecularMaterial.TILINGOFFSET);
  33491. tilOff.z=z;
  33492. this.tilingOffset=tilOff;
  33493. });
  33494. /**
  33495. *@private
  33496. */
  33497. /**
  33498. *@private
  33499. */
  33500. __getset(0,__proto,'_Cutoff',function(){
  33501. return this.alphaTestValue;
  33502. },function(value){
  33503. this.alphaTestValue=value;
  33504. });
  33505. /**
  33506. *@private
  33507. */
  33508. /**
  33509. *@private
  33510. */
  33511. __getset(0,__proto,'_MainTex_STW',function(){
  33512. return this._shaderValues.getVector(PBRSpecularMaterial.TILINGOFFSET).w;
  33513. },function(w){
  33514. var tilOff=this._shaderValues.getVector(PBRSpecularMaterial.TILINGOFFSET);
  33515. tilOff.w=w;
  33516. this.tilingOffset=tilOff;
  33517. });
  33518. /**
  33519. *设置反射率颜色R分量。
  33520. *@param value 反射率颜色R分量。
  33521. */
  33522. /**
  33523. *获取反射率颜色R分量。
  33524. *@return 反射率颜色R分量。
  33525. */
  33526. __getset(0,__proto,'albedoColorR',function(){
  33527. return this._ColorR;
  33528. },function(value){
  33529. this._ColorR=value;
  33530. });
  33531. /**
  33532. *设置反射率颜色G分量。
  33533. *@param value 反射率颜色G分量。
  33534. */
  33535. /**
  33536. *获取反射率颜色G分量。
  33537. *@return 反射率颜色G分量。
  33538. */
  33539. __getset(0,__proto,'albedoColorG',function(){
  33540. return this._ColorG;
  33541. },function(value){
  33542. this._ColorG=value;
  33543. });
  33544. /**
  33545. *获取纹理平铺和偏移X分量。
  33546. *@param x 纹理平铺和偏移X分量。
  33547. */
  33548. /**
  33549. *获取纹理平铺和偏移X分量。
  33550. *@return 纹理平铺和偏移X分量。
  33551. */
  33552. __getset(0,__proto,'tilingOffsetX',function(){
  33553. return this._MainTex_STX;
  33554. },function(x){
  33555. this._MainTex_STX=x;
  33556. });
  33557. /**
  33558. *设置反射率颜色。
  33559. *@param value 反射率颜色。
  33560. */
  33561. /**
  33562. *获取反射率颜色。
  33563. *@return 反射率颜色。
  33564. */
  33565. __getset(0,__proto,'albedoColor',function(){
  33566. return this._albedoColor;
  33567. },function(value){
  33568. this._albedoColor=value;
  33569. this._shaderValues.setVector(PBRSpecularMaterial.ALBEDOCOLOR,value);
  33570. });
  33571. /**
  33572. *设置漫反射贴图。
  33573. *@param value 漫反射贴图。
  33574. */
  33575. /**
  33576. *获取漫反射贴图。
  33577. *@return 漫反射贴图。
  33578. */
  33579. __getset(0,__proto,'albedoTexture',function(){
  33580. return this._shaderValues.getTexture(PBRSpecularMaterial.ALBEDOTEXTURE);
  33581. },function(value){
  33582. if (value){
  33583. this._defineDatas.add(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_ALBEDOTEXTURE);
  33584. }else {
  33585. this._defineDatas.remove(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_ALBEDOTEXTURE);
  33586. }
  33587. this._shaderValues.setTexture(PBRSpecularMaterial.ALBEDOTEXTURE,value);
  33588. });
  33589. /**
  33590. *设置剔除方式。
  33591. *@param value 剔除方式。
  33592. */
  33593. /**
  33594. *获取剔除方式。
  33595. *@return 剔除方式。
  33596. */
  33597. __getset(0,__proto,'cull',function(){
  33598. return this._shaderValues.getInt(PBRSpecularMaterial.CULL);
  33599. },function(value){
  33600. this._shaderValues.setInt(PBRSpecularMaterial.CULL,value);
  33601. });
  33602. /**
  33603. *设置视差贴图。
  33604. *@param value 视察贴图。
  33605. */
  33606. /**
  33607. *获取视差贴图。
  33608. *@return 视察贴图。
  33609. */
  33610. __getset(0,__proto,'parallaxTexture',function(){
  33611. return this._shaderValues.getTexture(PBRSpecularMaterial.PARALLAXTEXTURE);
  33612. },function(value){
  33613. if (value){
  33614. this._defineDatas.add(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_PARALLAXTEXTURE);
  33615. }else {
  33616. this._defineDatas.remove(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_PARALLAXTEXTURE);
  33617. }
  33618. this._shaderValues.setTexture(PBRSpecularMaterial.PARALLAXTEXTURE,value);
  33619. });
  33620. /**
  33621. *设置法线贴图。
  33622. *@param value 法线贴图。
  33623. */
  33624. /**
  33625. *获取法线贴图。
  33626. *@return 法线贴图。
  33627. */
  33628. __getset(0,__proto,'normalTexture',function(){
  33629. return this._shaderValues.getTexture(PBRSpecularMaterial.NORMALTEXTURE);
  33630. },function(value){
  33631. if (value){
  33632. this._defineDatas.add(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_NORMALTEXTURE);
  33633. }else {
  33634. this._defineDatas.remove(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_NORMALTEXTURE);
  33635. }
  33636. this._shaderValues.setTexture(PBRSpecularMaterial.NORMALTEXTURE,value);
  33637. });
  33638. /**
  33639. *设置放射颜色。
  33640. *@param value 放射颜色。
  33641. */
  33642. /**
  33643. *获取放射颜色。
  33644. *@return 放射颜色。
  33645. */
  33646. __getset(0,__proto,'emissionColor',function(){
  33647. return this._shaderValues.getVector(PBRSpecularMaterial.EMISSIONCOLOR);
  33648. },function(value){
  33649. this._shaderValues.setVector(PBRSpecularMaterial.EMISSIONCOLOR,value);
  33650. });
  33651. /**
  33652. *设置视差贴图缩放系数。
  33653. *@param value 视差缩放系数。
  33654. */
  33655. /**
  33656. *获取视差贴图缩放系数。
  33657. *@return 视差缩放系数。
  33658. */
  33659. __getset(0,__proto,'parallaxTextureScale',function(){
  33660. return this._Parallax;
  33661. },function(value){
  33662. this._Parallax=Math.max(0.005,Math.min(0.08,value));
  33663. });
  33664. /**
  33665. *设置法线贴图缩放系数。
  33666. *@param value 法线贴图缩放系数。
  33667. */
  33668. /**
  33669. *获取法线贴图缩放系数。
  33670. *@return 法线贴图缩放系数。
  33671. */
  33672. __getset(0,__proto,'normalTextureScale',function(){
  33673. return this._BumpScale;
  33674. },function(value){
  33675. this._BumpScale=value;
  33676. });
  33677. /**
  33678. *获取纹理平铺和偏移Z分量。
  33679. *@param z 纹理平铺和偏移Z分量。
  33680. */
  33681. /**
  33682. *获取纹理平铺和偏移Z分量。
  33683. *@return 纹理平铺和偏移Z分量。
  33684. */
  33685. __getset(0,__proto,'tilingOffsetZ',function(){
  33686. return this._MainTex_STZ;
  33687. },function(z){
  33688. this._MainTex_STZ=z;
  33689. });
  33690. /**
  33691. *设置遮挡贴图。
  33692. *@param value 遮挡贴图。
  33693. */
  33694. /**
  33695. *获取遮挡贴图。
  33696. *@return 遮挡贴图。
  33697. */
  33698. __getset(0,__proto,'occlusionTexture',function(){
  33699. return this._shaderValues.getTexture(PBRSpecularMaterial.OCCLUSIONTEXTURE);
  33700. },function(value){
  33701. if (value){
  33702. this._defineDatas.add(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_OCCLUSIONTEXTURE);
  33703. }else {
  33704. this._defineDatas.remove(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_OCCLUSIONTEXTURE);
  33705. }
  33706. this._shaderValues.setTexture(PBRSpecularMaterial.OCCLUSIONTEXTURE,value);
  33707. });
  33708. /**
  33709. *设置遮挡贴图强度。
  33710. *@param value 遮挡贴图强度,范围为0到1。
  33711. */
  33712. /**
  33713. *获取遮挡贴图强度。
  33714. *@return 遮挡贴图强度,范围为0到1。
  33715. */
  33716. __getset(0,__proto,'occlusionTextureStrength',function(){
  33717. return this._OcclusionStrength;
  33718. },function(value){
  33719. this._OcclusionStrength=Math.max(0.0,Math.min(1.0,value));
  33720. });
  33721. /**
  33722. *设置高光贴图。
  33723. *@param value 高光贴图。
  33724. */
  33725. /**
  33726. *获取高光贴图。
  33727. *@return 高光贴图。
  33728. */
  33729. __getset(0,__proto,'specularTexture',function(){
  33730. return this._shaderValues.getTexture(PBRSpecularMaterial.SPECULARTEXTURE);
  33731. },function(value){
  33732. if (value){
  33733. this._defineDatas.add(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_SPECULARTEXTURE);
  33734. }else {
  33735. this._defineDatas.remove(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_SPECULARTEXTURE);
  33736. }
  33737. this._shaderValues.setTexture(PBRSpecularMaterial.SPECULARTEXTURE,value);
  33738. });
  33739. /**
  33740. *设置高光颜色R分量。
  33741. *@param value 高光颜色R分量。
  33742. */
  33743. /**
  33744. *获取高光颜色R分量。
  33745. *@return 高光颜色R分量。
  33746. */
  33747. __getset(0,__proto,'specularColorR',function(){
  33748. return this._SpecColorR;
  33749. },function(value){
  33750. this._SpecColorR=value;
  33751. });
  33752. /**
  33753. *设置光滑度。
  33754. *@param value 光滑度,范围为0到1。
  33755. */
  33756. /**
  33757. *获取光滑度。
  33758. *@return 光滑度,范围为0到1。
  33759. */
  33760. __getset(0,__proto,'smoothness',function(){
  33761. return this._Glossiness;
  33762. },function(value){
  33763. this._Glossiness=Math.max(0.0,Math.min(1.0,value));
  33764. });
  33765. /**
  33766. *设置高光颜色G分量。
  33767. *@param value 高光颜色G分量。
  33768. */
  33769. /**
  33770. *获取高光颜色G分量。
  33771. *@return 高光颜色G分量。
  33772. */
  33773. __getset(0,__proto,'specularColorG',function(){
  33774. return this._SpecColorG;
  33775. },function(value){
  33776. this._SpecColorG=value;
  33777. });
  33778. /**
  33779. *设置高光颜色B分量。
  33780. *@param value 高光颜色B分量。
  33781. */
  33782. /**
  33783. *获取高光颜色B分量。
  33784. *@return 高光颜色B分量。
  33785. */
  33786. __getset(0,__proto,'specularColorB',function(){
  33787. return this._SpecColorB;
  33788. },function(value){
  33789. this._SpecColorB=value;
  33790. });
  33791. /**
  33792. *设置高光颜色A分量。
  33793. *@param value 高光颜色A分量。
  33794. */
  33795. /**
  33796. *获取高光颜色A分量。
  33797. *@return 高光颜色A分量。
  33798. */
  33799. __getset(0,__proto,'specularColorA',function(){
  33800. return this._SpecColorA;
  33801. },function(value){
  33802. this._SpecColorA=value;
  33803. });
  33804. /**
  33805. *设置混合目标。
  33806. *@param value 混合目标
  33807. */
  33808. /**
  33809. *获取混合目标。
  33810. *@return 混合目标。
  33811. */
  33812. __getset(0,__proto,'blendDst',function(){
  33813. return this._shaderValues.getInt(PBRSpecularMaterial.BLEND_DST);
  33814. },function(value){
  33815. this._shaderValues.setInt(PBRSpecularMaterial.BLEND_DST,value);
  33816. });
  33817. /**
  33818. *设置光滑度缩放系数。
  33819. *@param value 光滑度缩放系数,范围为0到1。
  33820. */
  33821. /**
  33822. *获取光滑度缩放系数。
  33823. *@return 光滑度缩放系数,范围为0到1。
  33824. */
  33825. __getset(0,__proto,'smoothnessTextureScale',function(){
  33826. return this._GlossMapScale;
  33827. },function(value){
  33828. this._GlossMapScale=Math.max(0.0,Math.min(1.0,value));
  33829. });
  33830. /**
  33831. *设置是否写入深度。
  33832. *@param value 是否写入深度。
  33833. */
  33834. /**
  33835. *获取是否写入深度。
  33836. *@return 是否写入深度。
  33837. */
  33838. __getset(0,__proto,'depthWrite',function(){
  33839. return this._shaderValues.getBool(PBRSpecularMaterial.DEPTH_WRITE);
  33840. },function(value){
  33841. this._shaderValues.setBool(PBRSpecularMaterial.DEPTH_WRITE,value);
  33842. });
  33843. /**
  33844. *设置光滑度数据源。
  33845. *@param value 光滑滑度数据源,0或1。
  33846. */
  33847. /**
  33848. *获取光滑度数据源
  33849. *@return 光滑滑度数据源,0或1。
  33850. */
  33851. __getset(0,__proto,'smoothnessSource',function(){
  33852. return this._shaderValues.getInt(PBRSpecularMaterial.SMOOTHNESSSOURCE);
  33853. },function(value){
  33854. if (value){
  33855. this._defineDatas.add(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA);
  33856. this._shaderValues.setInt(PBRSpecularMaterial.SMOOTHNESSSOURCE,1);
  33857. }else {
  33858. this._defineDatas.remove(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA);
  33859. this._shaderValues.setInt(PBRSpecularMaterial.SMOOTHNESSSOURCE,0);
  33860. }
  33861. });
  33862. /**
  33863. *设置是否激活放射属性。
  33864. *@param value 是否激活放射属性
  33865. */
  33866. /**
  33867. *获取是否激活放射属性。
  33868. *@return 是否激活放射属性。
  33869. */
  33870. __getset(0,__proto,'enableEmission',function(){
  33871. return this._shaderValues.getBool(PBRSpecularMaterial.ENABLEEMISSION);
  33872. },function(value){
  33873. if (value)
  33874. this._defineDatas.add(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_EMISSION);
  33875. else {
  33876. this._defineDatas.remove(laya.d3.core.material.PBRSpecularMaterial.SHADERDEFINE_EMISSION);
  33877. }
  33878. this._shaderValues.setBool(PBRSpecularMaterial.ENABLEEMISSION,value);
  33879. });
  33880. /**
  33881. *设置是否开启反射。
  33882. *@param value 是否开启反射。
  33883. */
  33884. /**
  33885. *获取是否开启反射。
  33886. *@return 是否开启反射。
  33887. */
  33888. __getset(0,__proto,'enableReflection',function(){
  33889. return this._shaderValues.getBool(PBRSpecularMaterial.ENABLEREFLECT);
  33890. },function(value){
  33891. this._shaderValues.setBool(PBRSpecularMaterial.ENABLEREFLECT,true);
  33892. if (value)
  33893. this._disablePublicDefineDatas.remove(Scene3D.SHADERDEFINE_REFLECTMAP);
  33894. else
  33895. this._disablePublicDefineDatas.add(Scene3D.SHADERDEFINE_REFLECTMAP);
  33896. });
  33897. /**
  33898. *获取纹理平铺和偏移Y分量。
  33899. *@param y 纹理平铺和偏移Y分量。
  33900. */
  33901. /**
  33902. *获取纹理平铺和偏移Y分量。
  33903. *@return 纹理平铺和偏移Y分量。
  33904. */
  33905. __getset(0,__proto,'tilingOffsetY',function(){
  33906. return this._MainTex_STY;
  33907. },function(y){
  33908. this._MainTex_STY=y;
  33909. });
  33910. /**
  33911. *设置混合方式。
  33912. *@param value 混合方式。
  33913. */
  33914. /**
  33915. *获取混合方式。
  33916. *@return 混合方式。
  33917. */
  33918. __getset(0,__proto,'blend',function(){
  33919. return this._shaderValues.getInt(PBRSpecularMaterial.BLEND);
  33920. },function(value){
  33921. this._shaderValues.setInt(PBRSpecularMaterial.BLEND,value);
  33922. });
  33923. /**
  33924. *设置深度测试方式。
  33925. *@param value 深度测试方式
  33926. */
  33927. /**
  33928. *获取深度测试方式。
  33929. *@return 深度测试方式。
  33930. */
  33931. __getset(0,__proto,'depthTest',function(){
  33932. return this._shaderValues.getInt(PBRSpecularMaterial.DEPTH_TEST);
  33933. },function(value){
  33934. this._shaderValues.setInt(PBRSpecularMaterial.DEPTH_TEST,value);
  33935. });
  33936. PBRSpecularMaterial.__init__=function(){
  33937. PBRSpecularMaterial.SHADERDEFINE_ALBEDOTEXTURE=PBRSpecularMaterial.shaderDefines.registerDefine("ALBEDOTEXTURE");
  33938. PBRSpecularMaterial.SHADERDEFINE_SPECULARTEXTURE=PBRSpecularMaterial.shaderDefines.registerDefine("SPECULARTEXTURE");
  33939. PBRSpecularMaterial.SHADERDEFINE_SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA=PBRSpecularMaterial.shaderDefines.registerDefine("SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA");
  33940. PBRSpecularMaterial.SHADERDEFINE_NORMALTEXTURE=PBRSpecularMaterial.shaderDefines.registerDefine("NORMALTEXTURE");
  33941. PBRSpecularMaterial.SHADERDEFINE_PARALLAXTEXTURE=PBRSpecularMaterial.shaderDefines.registerDefine("PARALLAXTEXTURE");
  33942. PBRSpecularMaterial.SHADERDEFINE_OCCLUSIONTEXTURE=PBRSpecularMaterial.shaderDefines.registerDefine("OCCLUSIONTEXTURE");
  33943. PBRSpecularMaterial.SHADERDEFINE_EMISSION=PBRSpecularMaterial.shaderDefines.registerDefine("EMISSION");
  33944. PBRSpecularMaterial.SHADERDEFINE_EMISSIONTEXTURE=PBRSpecularMaterial.shaderDefines.registerDefine("EMISSIONTEXTURE");
  33945. PBRSpecularMaterial.SHADERDEFINE_TILINGOFFSET=PBRSpecularMaterial.shaderDefines.registerDefine("TILINGOFFSET");
  33946. PBRSpecularMaterial.SHADERDEFINE_ALPHAPREMULTIPLY=PBRSpecularMaterial.shaderDefines.registerDefine("ALPHAPREMULTIPLY");
  33947. }
  33948. PBRSpecularMaterial.SmoothnessSource_SpecularTexture_Alpha=0;
  33949. PBRSpecularMaterial.SmoothnessSource_AlbedoTexture_Alpha=1;
  33950. PBRSpecularMaterial.RENDERMODE_OPAQUE=0;
  33951. PBRSpecularMaterial.RENDERMODE_CUTOUT=1;
  33952. PBRSpecularMaterial.RENDERMODE_FADE=2;
  33953. PBRSpecularMaterial.RENDERMODE_TRANSPARENT=3;
  33954. PBRSpecularMaterial.SHADERDEFINE_ALBEDOTEXTURE=0;
  33955. PBRSpecularMaterial.SHADERDEFINE_NORMALTEXTURE=0;
  33956. PBRSpecularMaterial.SHADERDEFINE_SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA=0;
  33957. PBRSpecularMaterial.SHADERDEFINE_SPECULARTEXTURE=0;
  33958. PBRSpecularMaterial.SHADERDEFINE_OCCLUSIONTEXTURE=0;
  33959. PBRSpecularMaterial.SHADERDEFINE_PARALLAXTEXTURE=0;
  33960. PBRSpecularMaterial.SHADERDEFINE_EMISSION=0;
  33961. PBRSpecularMaterial.SHADERDEFINE_EMISSIONTEXTURE=0;
  33962. PBRSpecularMaterial.SHADERDEFINE_TILINGOFFSET=0;
  33963. PBRSpecularMaterial.SHADERDEFINE_ALPHAPREMULTIPLY=0;
  33964. PBRSpecularMaterial.SMOOTHNESSSOURCE=-1;
  33965. PBRSpecularMaterial.ENABLEEMISSION=-1;
  33966. PBRSpecularMaterial.ENABLEREFLECT=-1;
  33967. __static(PBRSpecularMaterial,
  33968. ['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);}
  33969. ]);
  33970. return PBRSpecularMaterial;
  33971. })(BaseMaterial)
  33972. /**
  33973. *<code>LightSprite</code> 类用于创建灯光的父类。
  33974. */
  33975. //class laya.d3.core.light.LightSprite extends laya.d3.core.Sprite3D
  33976. var LightSprite=(function(_super){
  33977. function LightSprite(){
  33978. /**@private */
  33979. this._intensityColor=null;
  33980. /**@private */
  33981. this._intensity=NaN;
  33982. /**@private */
  33983. this._shadow=false;
  33984. /**@private */
  33985. this._shadowFarPlane=0;
  33986. /**@private */
  33987. this._shadowMapSize=0;
  33988. /**@private */
  33989. this._shadowMapCount=0;
  33990. /**@private */
  33991. this._shadowMapPCFType=0;
  33992. /**@private */
  33993. this._parallelSplitShadowMap=null;
  33994. /**@private */
  33995. this._lightmapBakedType=0;
  33996. /**灯光颜色。 */
  33997. this.color=null;
  33998. LightSprite.__super.call(this);
  33999. this._intensity=1.0;
  34000. this._intensityColor=new Vector3();
  34001. this.color=new Vector3(1.0,1.0,1.0);
  34002. this._shadow=false;
  34003. this._shadowFarPlane=8;
  34004. this._shadowMapSize=512;
  34005. this._shadowMapCount=1;
  34006. this._shadowMapPCFType=0;
  34007. this._lightmapBakedType=LightSprite.LIGHTMAPBAKEDTYPE_REALTIME;
  34008. }
  34009. __class(LightSprite,'laya.d3.core.light.LightSprite',_super);
  34010. var __proto=LightSprite.prototype;
  34011. /**
  34012. *@inheritDoc
  34013. */
  34014. __proto._parse=function(data,spriteMap){
  34015. _super.prototype._parse.call(this,data,spriteMap);
  34016. var colorData=data.color;
  34017. this.color.fromArray(colorData);
  34018. this.intensity=data.intensity;
  34019. this.lightmapBakedType=data.lightmapBakedType;
  34020. }
  34021. /**
  34022. *@inheritDoc
  34023. */
  34024. __proto._onActive=function(){
  34025. laya.display.Node.prototype._onActive.call(this);
  34026. (this.lightmapBakedType!==LightSprite.LIGHTMAPBAKEDTYPE_BAKED)&& ((this._scene)._addLight(this));
  34027. }
  34028. /**
  34029. *@inheritDoc
  34030. */
  34031. __proto._onInActive=function(){
  34032. laya.display.Node.prototype._onInActive.call(this);
  34033. (this.lightmapBakedType!==LightSprite.LIGHTMAPBAKEDTYPE_BAKED)&& ((this._scene)._removeLight(this));
  34034. }
  34035. /**
  34036. *更新灯光相关渲染状态参数。
  34037. *@param state 渲染状态参数。
  34038. */
  34039. __proto._prepareToScene=function(){
  34040. return false;
  34041. }
  34042. /**
  34043. *设置灯光烘培类型。
  34044. */
  34045. /**
  34046. *获取灯光烘培类型。
  34047. */
  34048. __getset(0,__proto,'lightmapBakedType',function(){
  34049. return this._lightmapBakedType;
  34050. },function(value){
  34051. if (this._lightmapBakedType!==value){
  34052. this._lightmapBakedType=value;
  34053. if (this.activeInHierarchy){
  34054. if (value!==LightSprite.LIGHTMAPBAKEDTYPE_BAKED)
  34055. (this._scene)._addLight(this);
  34056. else
  34057. (this._scene)._removeLight(this);
  34058. }
  34059. }
  34060. });
  34061. /**
  34062. *设置阴影PCF类型。
  34063. *@param value PCF类型。
  34064. */
  34065. /**
  34066. *获取阴影PCF类型。
  34067. *@return PCF类型。
  34068. */
  34069. __getset(0,__proto,'shadowPCFType',function(){
  34070. return this._shadowMapPCFType;
  34071. },function(value){
  34072. this._shadowMapPCFType=value;
  34073. (this._parallelSplitShadowMap)&& (this._parallelSplitShadowMap.setPCFType(value));
  34074. });
  34075. /**
  34076. *设置灯光强度。
  34077. *@param value 灯光强度
  34078. */
  34079. /**
  34080. *获取灯光强度。
  34081. *@return 灯光强度
  34082. */
  34083. __getset(0,__proto,'intensity',function(){
  34084. return this._intensity;
  34085. },function(value){
  34086. this._intensity=value;
  34087. });
  34088. /**
  34089. *设置是否产生阴影。
  34090. *@param value 是否产生阴影。
  34091. */
  34092. /**
  34093. *获取是否产生阴影。
  34094. *@return 是否产生阴影。
  34095. */
  34096. __getset(0,__proto,'shadow',function(){
  34097. return this._shadow;
  34098. },function(value){
  34099. throw new Error("LightSprite: must override it.");
  34100. });
  34101. /**
  34102. *设置阴影最远范围。
  34103. *@param value 阴影最远范围。
  34104. */
  34105. /**
  34106. *获取阴影最远范围。
  34107. *@return 阴影最远范围。
  34108. */
  34109. __getset(0,__proto,'shadowDistance',function(){
  34110. return this._shadowFarPlane;
  34111. },function(value){
  34112. this._shadowFarPlane=value;
  34113. (this._parallelSplitShadowMap)&& (this._parallelSplitShadowMap.setFarDistance(value));
  34114. });
  34115. /**
  34116. *设置阴影分段数。
  34117. *@param value 阴影分段数。
  34118. */
  34119. /**
  34120. *获取阴影分段数。
  34121. *@return 阴影分段数。
  34122. */
  34123. __getset(0,__proto,'shadowPSSMCount',function(){
  34124. return this._shadowMapCount;
  34125. },function(value){
  34126. this._shadowMapCount=value;
  34127. (this._parallelSplitShadowMap)&& (this._parallelSplitShadowMap.shadowMapCount=value);
  34128. });
  34129. /**
  34130. *设置阴影贴图尺寸。
  34131. *@param value 阴影贴图尺寸。
  34132. */
  34133. /**
  34134. *获取阴影贴图尺寸。
  34135. *@return 阴影贴图尺寸。
  34136. */
  34137. __getset(0,__proto,'shadowResolution',function(){
  34138. return this._shadowMapSize;
  34139. },function(value){
  34140. this._shadowMapSize=value;
  34141. (this._parallelSplitShadowMap)&& (this._parallelSplitShadowMap.setShadowMapTextureSize(value));
  34142. });
  34143. /**
  34144. *设置灯光的漫反射颜色。
  34145. *@param value 灯光的漫反射颜色。
  34146. */
  34147. /**
  34148. *获取灯光的漫反射颜色。
  34149. *@return 灯光的漫反射颜色。
  34150. */
  34151. __getset(0,__proto,'diffuseColor',function(){
  34152. console.log("LightSprite: discard property,please use color property instead.");
  34153. return this.color;
  34154. },function(value){
  34155. console.log("LightSprite: discard property,please use color property instead.");
  34156. this.color=value;
  34157. });
  34158. LightSprite.LIGHTMAPBAKEDTYPE_REALTIME=0;
  34159. LightSprite.LIGHTMAPBAKEDTYPE_MIXED=1;
  34160. LightSprite.LIGHTMAPBAKEDTYPE_BAKED=2;
  34161. return LightSprite;
  34162. })(Sprite3D)
  34163. /**
  34164. *...
  34165. *@author
  34166. */
  34167. //class laya.d3.core.pixelLine.PixelLineMaterial extends laya.d3.core.material.BaseMaterial
  34168. var PixelLineMaterial=(function(_super){
  34169. function PixelLineMaterial(){
  34170. PixelLineMaterial.__super.call(this);
  34171. this.setShaderName("LineShader");
  34172. this._shaderValues.setVector(PixelLineMaterial.COLOR,new Vector4(1.0,1.0,1.0,1.0));
  34173. }
  34174. __class(PixelLineMaterial,'laya.d3.core.pixelLine.PixelLineMaterial',_super);
  34175. var __proto=PixelLineMaterial.prototype;
  34176. /**
  34177. *设置混合方式。
  34178. *@param value 混合方式。
  34179. */
  34180. /**
  34181. *获取混合方式。
  34182. *@return 混合方式。
  34183. */
  34184. __getset(0,__proto,'blend',function(){
  34185. return this._shaderValues.getInt(PixelLineMaterial.BLEND);
  34186. },function(value){
  34187. this._shaderValues.setInt(PixelLineMaterial.BLEND,value);
  34188. });
  34189. /**
  34190. *设置颜色。
  34191. *@param value 颜色。
  34192. */
  34193. /**
  34194. *获取颜色。
  34195. *@return 颜色。
  34196. */
  34197. __getset(0,__proto,'color',function(){
  34198. return this._shaderValues.getVector(PixelLineMaterial.COLOR);
  34199. },function(value){
  34200. this._shaderValues.setVector(PixelLineMaterial.COLOR,value);
  34201. });
  34202. /**
  34203. *设置剔除方式。
  34204. *@param value 剔除方式。
  34205. */
  34206. /**
  34207. *获取剔除方式。
  34208. *@return 剔除方式。
  34209. */
  34210. __getset(0,__proto,'cull',function(){
  34211. return this._shaderValues.getInt(PixelLineMaterial.CULL);
  34212. },function(value){
  34213. this._shaderValues.setInt(PixelLineMaterial.CULL,value);
  34214. });
  34215. /**
  34216. *设置是否写入深度。
  34217. *@param value 是否写入深度。
  34218. */
  34219. /**
  34220. *获取是否写入深度。
  34221. *@return 是否写入深度。
  34222. */
  34223. __getset(0,__proto,'depthWrite',function(){
  34224. return this._shaderValues.getBool(PixelLineMaterial.DEPTH_WRITE);
  34225. },function(value){
  34226. this._shaderValues.setBool(PixelLineMaterial.DEPTH_WRITE,value);
  34227. });
  34228. /**
  34229. *设置混合源。
  34230. *@param value 混合源
  34231. */
  34232. /**
  34233. *获取混合源。
  34234. *@return 混合源。
  34235. */
  34236. __getset(0,__proto,'blendSrc',function(){
  34237. return this._shaderValues.getInt(PixelLineMaterial.BLEND_SRC);
  34238. },function(value){
  34239. this._shaderValues.setInt(PixelLineMaterial.BLEND_SRC,value);
  34240. });
  34241. /**
  34242. *设置混合目标。
  34243. *@param value 混合目标
  34244. */
  34245. /**
  34246. *获取混合目标。
  34247. *@return 混合目标。
  34248. */
  34249. __getset(0,__proto,'blendDst',function(){
  34250. return this._shaderValues.getInt(PixelLineMaterial.BLEND_DST);
  34251. },function(value){
  34252. this._shaderValues.setInt(PixelLineMaterial.BLEND_DST,value);
  34253. });
  34254. /**
  34255. *设置深度测试方式。
  34256. *@param value 深度测试方式
  34257. */
  34258. /**
  34259. *获取深度测试方式。
  34260. *@return 深度测试方式。
  34261. */
  34262. __getset(0,__proto,'depthTest',function(){
  34263. return this._shaderValues.getInt(PixelLineMaterial.DEPTH_TEST);
  34264. },function(value){
  34265. this._shaderValues.setInt(PixelLineMaterial.DEPTH_TEST,value);
  34266. });
  34267. __static(PixelLineMaterial,
  34268. ['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");}
  34269. ]);
  34270. return PixelLineMaterial;
  34271. })(BaseMaterial)
  34272. /**
  34273. *<code>SkyBoxMaterial</code> 类用于实现SkyBoxMaterial材质。
  34274. */
  34275. //class laya.d3.core.material.SkyBoxMaterial extends laya.d3.core.material.BaseMaterial
  34276. var SkyBoxMaterial=(function(_super){
  34277. /**
  34278. *创建一个 <code>SkyBoxMaterial</code> 实例。
  34279. */
  34280. function SkyBoxMaterial(){
  34281. SkyBoxMaterial.__super.call(this);
  34282. this.setShaderName("SkyBox");
  34283. }
  34284. __class(SkyBoxMaterial,'laya.d3.core.material.SkyBoxMaterial',_super);
  34285. var __proto=SkyBoxMaterial.prototype;
  34286. /**
  34287. *设置颜色。
  34288. *@param value 颜色。
  34289. */
  34290. /**
  34291. *获取颜色。
  34292. *@return 颜色。
  34293. */
  34294. __getset(0,__proto,'tintColor',function(){
  34295. return this._shaderValues.getVector(SkyBoxMaterial.TINTCOLOR);
  34296. },function(value){
  34297. this._shaderValues.setVector(SkyBoxMaterial.TINTCOLOR,value);
  34298. });
  34299. /**
  34300. *设置曝光强度。
  34301. *@param value 曝光强度。
  34302. */
  34303. /**
  34304. *获取曝光强度。
  34305. *@return 曝光强度。
  34306. */
  34307. __getset(0,__proto,'exposure',function(){
  34308. return this._shaderValues.getNumber(SkyBoxMaterial.EXPOSURE);
  34309. },function(value){
  34310. this._shaderValues.setNumber(SkyBoxMaterial.EXPOSURE,value);
  34311. });
  34312. /**
  34313. *设置曝光强度。
  34314. *@param value 曝光强度。
  34315. */
  34316. /**
  34317. *获取曝光强度。
  34318. *@return 曝光强度。
  34319. */
  34320. __getset(0,__proto,'rotation',function(){
  34321. return this._shaderValues.getNumber(SkyBoxMaterial.ROTATION);
  34322. },function(value){
  34323. this._shaderValues.setNumber(SkyBoxMaterial.ROTATION,value);
  34324. });
  34325. /**
  34326. *设置天空盒纹理。
  34327. */
  34328. /**
  34329. *获取天空盒纹理。
  34330. */
  34331. __getset(0,__proto,'textureCube',function(){
  34332. return this._shaderValues.getTexture(SkyBoxMaterial.TEXTURECUBE);
  34333. },function(value){
  34334. this._shaderValues.setTexture(SkyBoxMaterial.TEXTURECUBE,value);
  34335. });
  34336. __static(SkyBoxMaterial,
  34337. ['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();}
  34338. ]);
  34339. return SkyBoxMaterial;
  34340. })(BaseMaterial)
  34341. /**
  34342. *...
  34343. *@author ...
  34344. */
  34345. //class laya.d3.core.material.ExtendTerrainMaterial extends laya.d3.core.material.BaseMaterial
  34346. var ExtendTerrainMaterial=(function(_super){
  34347. function ExtendTerrainMaterial(){
  34348. /**@private */
  34349. this._enableLighting=true;
  34350. ExtendTerrainMaterial.__super.call(this);
  34351. this.setShaderName("ExtendTerrain");
  34352. this.renderMode=1;
  34353. }
  34354. __class(ExtendTerrainMaterial,'laya.d3.core.material.ExtendTerrainMaterial',_super);
  34355. var __proto=ExtendTerrainMaterial.prototype;
  34356. __proto._setDetailNum=function(value){
  34357. switch (value){
  34358. case 1:
  34359. this._defineDatas.add(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM1);
  34360. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM2);
  34361. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM3);
  34362. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM4);
  34363. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM5);
  34364. break ;
  34365. case 2:
  34366. this._defineDatas.add(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM2);
  34367. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM1);
  34368. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM3);
  34369. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM4);
  34370. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM5);
  34371. break ;
  34372. case 3:
  34373. this._defineDatas.add(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM3);
  34374. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM1);
  34375. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM2);
  34376. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM4);
  34377. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM5);
  34378. break ;
  34379. case 4:
  34380. this._defineDatas.add(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM4);
  34381. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM1);
  34382. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM2);
  34383. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM3);
  34384. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM5);
  34385. break ;
  34386. case 5:
  34387. this._defineDatas.add(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM5);
  34388. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM1);
  34389. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM2);
  34390. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM3);
  34391. this._defineDatas.remove(laya.d3.core.material.ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM4);
  34392. break ;
  34393. }
  34394. }
  34395. __getset(0,__proto,'diffuseScaleOffset2',null,function(scaleOffset2){
  34396. this._shaderValues.setVector(ExtendTerrainMaterial.DIFFUSESCALEOFFSET2,scaleOffset2);
  34397. });
  34398. /**
  34399. *设置splatAlpha贴图。
  34400. *@param value splatAlpha贴图。
  34401. */
  34402. /**
  34403. *获取splatAlpha贴图。
  34404. *@return splatAlpha贴图。
  34405. */
  34406. __getset(0,__proto,'splatAlphaTexture',function(){
  34407. return this._shaderValues.getTexture(ExtendTerrainMaterial.SPLATALPHATEXTURE);
  34408. },function(value){
  34409. this._shaderValues.setTexture(ExtendTerrainMaterial.SPLATALPHATEXTURE,value);
  34410. });
  34411. __getset(0,__proto,'diffuseScaleOffset3',null,function(scaleOffset3){
  34412. this._shaderValues.setVector(ExtendTerrainMaterial.DIFFUSESCALEOFFSET3,scaleOffset3);
  34413. });
  34414. /**
  34415. *设置第一层贴图。
  34416. *@param value 第一层贴图。
  34417. */
  34418. __getset(0,__proto,'diffuseTexture1',null,function(value){
  34419. this._shaderValues.setTexture(ExtendTerrainMaterial.DIFFUSETEXTURE1,value);
  34420. this._setDetailNum(1);
  34421. });
  34422. /**
  34423. *设置渲染模式。
  34424. *@return 渲染模式。
  34425. */
  34426. __getset(0,__proto,'renderMode',null,function(value){
  34427. switch (value){
  34428. case 1:
  34429. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_OPAQUE*/2000;
  34430. this.depthWrite=true;
  34431. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  34432. this.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  34433. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  34434. break ;
  34435. case 2:
  34436. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_OPAQUE*/2000;
  34437. this.depthWrite=false;
  34438. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  34439. this.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  34440. this.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_SRC_ALPHA*/0x0302;
  34441. this.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA*/0x0303;
  34442. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LEQUAL*/0x0203;
  34443. break ;
  34444. default :
  34445. throw new Error("ExtendTerrainMaterial:renderMode value error.");
  34446. }
  34447. });
  34448. /**
  34449. *设置第二层贴图。
  34450. *@param value 第二层贴图。
  34451. */
  34452. /**
  34453. *获取第二层贴图。
  34454. *@return 第二层贴图。
  34455. */
  34456. __getset(0,__proto,'diffuseTexture2',function(){
  34457. return this._shaderValues.getTexture(ExtendTerrainMaterial.DIFFUSETEXTURE2);
  34458. },function(value){
  34459. this._shaderValues.setTexture(ExtendTerrainMaterial.DIFFUSETEXTURE2,value);
  34460. this._setDetailNum(2);
  34461. });
  34462. __getset(0,__proto,'diffuseScaleOffset1',null,function(scaleOffset1){
  34463. this._shaderValues.setVector(ExtendTerrainMaterial.DIFFUSESCALEOFFSET1,scaleOffset1);
  34464. });
  34465. /**
  34466. *设置第三层贴图。
  34467. *@param value 第三层贴图。
  34468. */
  34469. /**
  34470. *获取第三层贴图。
  34471. *@return 第三层贴图。
  34472. */
  34473. __getset(0,__proto,'diffuseTexture3',function(){
  34474. return this._shaderValues.getTexture(ExtendTerrainMaterial.DIFFUSETEXTURE3);
  34475. },function(value){
  34476. this._shaderValues.setTexture(ExtendTerrainMaterial.DIFFUSETEXTURE3,value);
  34477. this._setDetailNum(3);
  34478. });
  34479. /**
  34480. *设置第四层贴图。
  34481. *@param value 第四层贴图。
  34482. */
  34483. /**
  34484. *获取第四层贴图。
  34485. *@return 第四层贴图。
  34486. */
  34487. __getset(0,__proto,'diffuseTexture4',function(){
  34488. return this._shaderValues.getTexture(ExtendTerrainMaterial.DIFFUSETEXTURE4);
  34489. },function(value){
  34490. this._shaderValues.setTexture(ExtendTerrainMaterial.DIFFUSETEXTURE4,value);
  34491. this._setDetailNum(4);
  34492. });
  34493. /**
  34494. *设置第五层贴图。
  34495. *@param value 第五层贴图。
  34496. */
  34497. /**
  34498. *获取第五层贴图。
  34499. *@return 第五层贴图。
  34500. */
  34501. __getset(0,__proto,'diffuseTexture5',function(){
  34502. return this._shaderValues.getTexture(ExtendTerrainMaterial.DIFFUSETEXTURE5);
  34503. },function(value){
  34504. this._shaderValues.setTexture(ExtendTerrainMaterial.DIFFUSETEXTURE5,value);
  34505. this._setDetailNum(5);
  34506. });
  34507. __getset(0,__proto,'diffuseScaleOffset4',null,function(scaleOffset4){
  34508. this._shaderValues.setVector(ExtendTerrainMaterial.DIFFUSESCALEOFFSET4,scaleOffset4);
  34509. });
  34510. __getset(0,__proto,'diffuseScaleOffset5',null,function(scaleOffset5){
  34511. this._shaderValues.setVector(ExtendTerrainMaterial.DIFFUSESCALEOFFSET5,scaleOffset5);
  34512. });
  34513. /**
  34514. *设置混合源。
  34515. *@param value 混合源
  34516. */
  34517. /**
  34518. *获取混合源。
  34519. *@return 混合源。
  34520. */
  34521. __getset(0,__proto,'blendSrc',function(){
  34522. return this._shaderValues.getInt(ExtendTerrainMaterial.BLEND_SRC);
  34523. },function(value){
  34524. this._shaderValues.setInt(ExtendTerrainMaterial.BLEND_SRC,value);
  34525. });
  34526. /**
  34527. *设置是否启用光照。
  34528. *@param value 是否启用光照。
  34529. */
  34530. /**
  34531. *获取是否启用光照。
  34532. *@return 是否启用光照。
  34533. */
  34534. __getset(0,__proto,'enableLighting',function(){
  34535. return this._enableLighting;
  34536. },function(value){
  34537. if (this._enableLighting!==value){
  34538. if (value)
  34539. this._disablePublicDefineDatas.remove(Scene3D.SHADERDEFINE_POINTLIGHT | Scene3D.SHADERDEFINE_SPOTLIGHT | Scene3D.SHADERDEFINE_DIRECTIONLIGHT);
  34540. else
  34541. this._disablePublicDefineDatas.add(Scene3D.SHADERDEFINE_POINTLIGHT | Scene3D.SHADERDEFINE_SPOTLIGHT | Scene3D.SHADERDEFINE_DIRECTIONLIGHT);
  34542. this._enableLighting=value;
  34543. }
  34544. });
  34545. /**
  34546. *设置是否写入深度。
  34547. *@param value 是否写入深度。
  34548. */
  34549. /**
  34550. *获取是否写入深度。
  34551. *@return 是否写入深度。
  34552. */
  34553. __getset(0,__proto,'depthWrite',function(){
  34554. return this._shaderValues.getBool(ExtendTerrainMaterial.DEPTH_WRITE);
  34555. },function(value){
  34556. this._shaderValues.setBool(ExtendTerrainMaterial.DEPTH_WRITE,value);
  34557. });
  34558. /**
  34559. *设置剔除方式。
  34560. *@param value 剔除方式。
  34561. */
  34562. /**
  34563. *获取剔除方式。
  34564. *@return 剔除方式。
  34565. */
  34566. __getset(0,__proto,'cull',function(){
  34567. return this._shaderValues.getInt(ExtendTerrainMaterial.CULL);
  34568. },function(value){
  34569. this._shaderValues.setInt(ExtendTerrainMaterial.CULL,value);
  34570. });
  34571. /**
  34572. *设置混合方式。
  34573. *@param value 混合方式。
  34574. */
  34575. /**
  34576. *获取混合方式。
  34577. *@return 混合方式。
  34578. */
  34579. __getset(0,__proto,'blend',function(){
  34580. return this._shaderValues.getInt(ExtendTerrainMaterial.BLEND);
  34581. },function(value){
  34582. this._shaderValues.setInt(ExtendTerrainMaterial.BLEND,value);
  34583. });
  34584. /**
  34585. *设置混合目标。
  34586. *@param value 混合目标
  34587. */
  34588. /**
  34589. *获取混合目标。
  34590. *@return 混合目标。
  34591. */
  34592. __getset(0,__proto,'blendDst',function(){
  34593. return this._shaderValues.getInt(ExtendTerrainMaterial.BLEND_DST);
  34594. },function(value){
  34595. this._shaderValues.setInt(ExtendTerrainMaterial.BLEND_DST,value);
  34596. });
  34597. /**
  34598. *设置深度测试方式。
  34599. *@param value 深度测试方式
  34600. */
  34601. /**
  34602. *获取深度测试方式。
  34603. *@return 深度测试方式。
  34604. */
  34605. __getset(0,__proto,'depthTest',function(){
  34606. return this._shaderValues.getInt(ExtendTerrainMaterial.DEPTH_TEST);
  34607. },function(value){
  34608. this._shaderValues.setInt(ExtendTerrainMaterial.DEPTH_TEST,value);
  34609. });
  34610. ExtendTerrainMaterial.__init__=function(){
  34611. ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM1=ExtendTerrainMaterial.shaderDefines.registerDefine("ExtendTerrain_DETAIL_NUM1");
  34612. ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM2=ExtendTerrainMaterial.shaderDefines.registerDefine("ExtendTerrain_DETAIL_NUM2");
  34613. ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM3=ExtendTerrainMaterial.shaderDefines.registerDefine("ExtendTerrain_DETAIL_NUM3");
  34614. ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM4=ExtendTerrainMaterial.shaderDefines.registerDefine("ExtendTerrain_DETAIL_NUM4");
  34615. ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM5=ExtendTerrainMaterial.shaderDefines.registerDefine("ExtendTerrain_DETAIL_NUM5");
  34616. }
  34617. ExtendTerrainMaterial.RENDERMODE_OPAQUE=1;
  34618. ExtendTerrainMaterial.RENDERMODE_TRANSPARENT=2;
  34619. ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM1=0;
  34620. ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM2=0;
  34621. ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM3=0;
  34622. ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM4=0;
  34623. ExtendTerrainMaterial.SHADERDEFINE_DETAIL_NUM5=0;
  34624. __static(ExtendTerrainMaterial,
  34625. ['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);}
  34626. ]);
  34627. return ExtendTerrainMaterial;
  34628. })(BaseMaterial)
  34629. /**
  34630. *...
  34631. *@author
  34632. */
  34633. //class laya.d3.core.material.WaterPrimaryMaterial extends laya.d3.core.material.BaseMaterial
  34634. var WaterPrimaryMaterial=(function(_super){
  34635. function WaterPrimaryMaterial(){
  34636. WaterPrimaryMaterial.__super.call(this);
  34637. this.setShaderName("WaterPrimary");
  34638. this._shaderValues.setVector(WaterPrimaryMaterial.HORIZONCOLOR,new Vector4(0.172 ,0.463 ,0.435 ,0));
  34639. this._shaderValues.setNumber(WaterPrimaryMaterial.WAVESCALE,0.15);
  34640. this._shaderValues.setVector(WaterPrimaryMaterial.WAVESPEED,new Vector4(19,9,-16,-7));
  34641. }
  34642. __class(WaterPrimaryMaterial,'laya.d3.core.material.WaterPrimaryMaterial',_super);
  34643. var __proto=WaterPrimaryMaterial.prototype;
  34644. /**
  34645. *设置波动速率。
  34646. *@param value 波动速率。
  34647. */
  34648. /**
  34649. *获取波动速率。
  34650. *@return 波动速率。
  34651. */
  34652. __getset(0,__proto,'waveSpeed',function(){
  34653. return this._shaderValues.getVector(WaterPrimaryMaterial.WAVESPEED);
  34654. },function(value){
  34655. this._shaderValues.setVector(WaterPrimaryMaterial.WAVESPEED,value);
  34656. });
  34657. /**
  34658. *设置地平线颜色。
  34659. *@param value 地平线颜色。
  34660. */
  34661. /**
  34662. *获取地平线颜色。
  34663. *@return 地平线颜色。
  34664. */
  34665. __getset(0,__proto,'horizonColor',function(){
  34666. return this._shaderValues.getVector(WaterPrimaryMaterial.HORIZONCOLOR);
  34667. },function(value){
  34668. this._shaderValues.setVector(WaterPrimaryMaterial.HORIZONCOLOR,value);
  34669. });
  34670. /**
  34671. *设置主贴图。
  34672. *@param value 主贴图。
  34673. */
  34674. /**
  34675. *获取主贴图。
  34676. *@return 主贴图。
  34677. */
  34678. __getset(0,__proto,'mainTexture',function(){
  34679. return this._shaderValues.getTexture(WaterPrimaryMaterial.MAINTEXTURE);
  34680. },function(value){
  34681. if (value)
  34682. this._defineDatas.add(laya.d3.core.material.WaterPrimaryMaterial.SHADERDEFINE_MAINTEXTURE);
  34683. else
  34684. this._defineDatas.remove(laya.d3.core.material.WaterPrimaryMaterial.SHADERDEFINE_MAINTEXTURE);
  34685. this._shaderValues.setTexture(WaterPrimaryMaterial.MAINTEXTURE,value);
  34686. });
  34687. /**
  34688. *设置法线贴图。
  34689. *@param value 法线贴图。
  34690. */
  34691. /**
  34692. *获取法线贴图。
  34693. *@return 法线贴图。
  34694. */
  34695. __getset(0,__proto,'normalTexture',function(){
  34696. return this._shaderValues.getTexture(WaterPrimaryMaterial.NORMALTEXTURE);
  34697. },function(value){
  34698. if (value)
  34699. this._defineDatas.add(laya.d3.core.material.WaterPrimaryMaterial.SHADERDEFINE_NORMALTEXTURE);
  34700. else
  34701. this._defineDatas.remove(laya.d3.core.material.WaterPrimaryMaterial.SHADERDEFINE_NORMALTEXTURE);
  34702. this._shaderValues.setTexture(WaterPrimaryMaterial.NORMALTEXTURE,value);
  34703. });
  34704. /**
  34705. *设置波动缩放系数。
  34706. *@param value 波动缩放系数。
  34707. */
  34708. /**
  34709. *获取波动缩放系数。
  34710. *@return 波动缩放系数。
  34711. */
  34712. __getset(0,__proto,'waveScale',function(){
  34713. return this._shaderValues.getNumber(WaterPrimaryMaterial.WAVESCALE);
  34714. },function(value){
  34715. this._shaderValues.setNumber(WaterPrimaryMaterial.WAVESCALE,value);
  34716. });
  34717. WaterPrimaryMaterial.__init__=function(){
  34718. WaterPrimaryMaterial.SHADERDEFINE_MAINTEXTURE=WaterPrimaryMaterial.shaderDefines.registerDefine("MAINTEXTURE");
  34719. WaterPrimaryMaterial.SHADERDEFINE_NORMALTEXTURE=WaterPrimaryMaterial.shaderDefines.registerDefine("NORMALTEXTURE");
  34720. }
  34721. WaterPrimaryMaterial.SHADERDEFINE_MAINTEXTURE=0;
  34722. WaterPrimaryMaterial.SHADERDEFINE_NORMALTEXTURE=0;
  34723. __static(WaterPrimaryMaterial,
  34724. ['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);}
  34725. ]);
  34726. return WaterPrimaryMaterial;
  34727. })(BaseMaterial)
  34728. /**
  34729. *<code>UnlitMaterial</code> 类用于实现不受光照影响的材质。
  34730. */
  34731. //class laya.d3.core.material.UnlitMaterial extends laya.d3.core.material.BaseMaterial
  34732. var UnlitMaterial=(function(_super){
  34733. function UnlitMaterial(){
  34734. /**@private */
  34735. this._albedoIntensity=1.0;
  34736. /**@private */
  34737. this._enableVertexColor=false;
  34738. this._albedoColor=new Vector4(1.0,1.0,1.0,1.0);
  34739. UnlitMaterial.__super.call(this);
  34740. this.setShaderName("Unlit");
  34741. this._shaderValues.setVector(UnlitMaterial.ALBEDOCOLOR,new Vector4(1.0,1.0,1.0,1.0));
  34742. this.renderMode=0;
  34743. }
  34744. __class(UnlitMaterial,'laya.d3.core.material.UnlitMaterial',_super);
  34745. var __proto=UnlitMaterial.prototype;
  34746. /**
  34747. *@private
  34748. */
  34749. /**
  34750. *@private
  34751. */
  34752. __getset(0,__proto,'_ColorB',function(){
  34753. return this._albedoColor.z;
  34754. },function(value){
  34755. this._albedoColor.z=value;
  34756. this.albedoColor=this._albedoColor;
  34757. });
  34758. /**
  34759. *@private
  34760. */
  34761. /**
  34762. *@private
  34763. */
  34764. __getset(0,__proto,'_ColorR',function(){
  34765. return this._albedoColor.x;
  34766. },function(value){
  34767. this._albedoColor.x=value;
  34768. this.albedoColor=this._albedoColor;
  34769. });
  34770. /**
  34771. *设置反照率颜色alpha分量。
  34772. *@param value 反照率颜色alpha分量。
  34773. */
  34774. /**
  34775. *获取反照率颜色Z分量。
  34776. *@return 反照率颜色Z分量。
  34777. */
  34778. __getset(0,__proto,'albedoColorA',function(){
  34779. return this._ColorA;
  34780. },function(value){
  34781. this._ColorA=value;
  34782. });
  34783. /**
  34784. *@private
  34785. */
  34786. /**
  34787. *@private
  34788. */
  34789. __getset(0,__proto,'_MainTex_STX',function(){
  34790. return this._shaderValues.getVector(UnlitMaterial.TILINGOFFSET).x;
  34791. },function(x){
  34792. var tilOff=this._shaderValues.getVector(UnlitMaterial.TILINGOFFSET);
  34793. tilOff.x=x;
  34794. this.tilingOffset=tilOff;
  34795. });
  34796. /**
  34797. *@private
  34798. */
  34799. /**
  34800. *@private
  34801. */
  34802. __getset(0,__proto,'_ColorG',function(){
  34803. return this._albedoColor.y;
  34804. },function(value){
  34805. this._albedoColor.y=value;
  34806. this.albedoColor=this._albedoColor;
  34807. });
  34808. /**
  34809. *@private
  34810. */
  34811. /**@private */
  34812. __getset(0,__proto,'_ColorA',function(){
  34813. return this._albedoColor.w;
  34814. },function(value){
  34815. this._albedoColor.w=value;
  34816. this.albedoColor=this._albedoColor;
  34817. });
  34818. /**
  34819. *@private
  34820. */
  34821. /**
  34822. *@private
  34823. */
  34824. __getset(0,__proto,'_AlbedoIntensity',function(){
  34825. return this._albedoIntensity;
  34826. },function(value){
  34827. if (this._albedoIntensity!==value){
  34828. var finalAlbedo=this._shaderValues.getVector(UnlitMaterial.ALBEDOCOLOR);
  34829. Vector4.scale(this._albedoColor,value,finalAlbedo);
  34830. this._albedoIntensity=value;
  34831. this._shaderValues.setVector(UnlitMaterial.ALBEDOCOLOR,finalAlbedo);
  34832. }
  34833. });
  34834. /**
  34835. *@private
  34836. */
  34837. /**
  34838. *@private
  34839. */
  34840. __getset(0,__proto,'_MainTex_STZ',function(){
  34841. return this._shaderValues.getVector(UnlitMaterial.TILINGOFFSET).z;
  34842. },function(z){
  34843. var tilOff=this._shaderValues.getVector(UnlitMaterial.TILINGOFFSET);
  34844. tilOff.z=z;
  34845. this.tilingOffset=tilOff;
  34846. });
  34847. /**
  34848. *@private
  34849. */
  34850. /**
  34851. *@private
  34852. */
  34853. __getset(0,__proto,'_MainTex_STY',function(){
  34854. return this._shaderValues.getVector(UnlitMaterial.TILINGOFFSET).y;
  34855. },function(y){
  34856. var tilOff=this._shaderValues.getVector(UnlitMaterial.TILINGOFFSET);
  34857. tilOff.y=y;
  34858. this.tilingOffset=tilOff;
  34859. });
  34860. /**
  34861. *@private
  34862. */
  34863. /**
  34864. *@private
  34865. */
  34866. __getset(0,__proto,'_Cutoff',function(){
  34867. return this.alphaTestValue;
  34868. },function(value){
  34869. this.alphaTestValue=value;
  34870. });
  34871. /**
  34872. *@private
  34873. */
  34874. /**
  34875. *@private
  34876. */
  34877. __getset(0,__proto,'_MainTex_STW',function(){
  34878. return this._shaderValues.getVector(UnlitMaterial.TILINGOFFSET).w;
  34879. },function(w){
  34880. var tilOff=this._shaderValues.getVector(UnlitMaterial.TILINGOFFSET);
  34881. tilOff.w=w;
  34882. this.tilingOffset=tilOff;
  34883. });
  34884. /**
  34885. *设置反照率颜色R分量。
  34886. *@param value 反照率颜色R分量。
  34887. */
  34888. /**
  34889. *获取反照率颜色R分量。
  34890. *@return 反照率颜色R分量。
  34891. */
  34892. __getset(0,__proto,'albedoColorR',function(){
  34893. return this._ColorR;
  34894. },function(value){
  34895. this._ColorR=value;
  34896. });
  34897. /**
  34898. *设置反照率颜色G分量。
  34899. *@param value 反照率颜色G分量。
  34900. */
  34901. /**
  34902. *获取反照率颜色G分量。
  34903. *@return 反照率颜色G分量。
  34904. */
  34905. __getset(0,__proto,'albedoColorG',function(){
  34906. return this._ColorG;
  34907. },function(value){
  34908. this._ColorG=value;
  34909. });
  34910. /**
  34911. *设置反照率颜色B分量。
  34912. *@param value 反照率颜色B分量。
  34913. */
  34914. /**
  34915. *获取反照率颜色B分量。
  34916. *@return 反照率颜色B分量。
  34917. */
  34918. __getset(0,__proto,'albedoColorB',function(){
  34919. return this._ColorB;
  34920. },function(value){
  34921. this._ColorB=value;
  34922. });
  34923. /**
  34924. *获取纹理平铺和偏移X分量。
  34925. *@param x 纹理平铺和偏移X分量。
  34926. */
  34927. /**
  34928. *获取纹理平铺和偏移X分量。
  34929. *@return 纹理平铺和偏移X分量。
  34930. */
  34931. __getset(0,__proto,'tilingOffsetX',function(){
  34932. return this._MainTex_STX;
  34933. },function(x){
  34934. this._MainTex_STX=x;
  34935. });
  34936. /**
  34937. *设置反照率颜色。
  34938. *@param value 反照率颜色。
  34939. */
  34940. /**
  34941. *获取反照率颜色。
  34942. *@return 反照率颜色。
  34943. */
  34944. __getset(0,__proto,'albedoColor',function(){
  34945. return this._albedoColor;
  34946. },function(value){
  34947. var finalAlbedo=this._shaderValues.getVector(UnlitMaterial.ALBEDOCOLOR);
  34948. Vector4.scale(value,this._albedoIntensity,finalAlbedo);
  34949. this._albedoColor=value;
  34950. this._shaderValues.setVector(UnlitMaterial.ALBEDOCOLOR,finalAlbedo);
  34951. });
  34952. /**
  34953. *设置反照率强度。
  34954. *@param value 反照率强度。
  34955. */
  34956. /**
  34957. *获取反照率强度。
  34958. *@return 反照率强度。
  34959. */
  34960. __getset(0,__proto,'albedoIntensity',function(){
  34961. return this._albedoIntensity;
  34962. },function(value){
  34963. this._AlbedoIntensity=value;
  34964. });
  34965. /**
  34966. *设置是否支持顶点色。
  34967. *@param value 是否支持顶点色。
  34968. */
  34969. /**
  34970. *获取是否支持顶点色。
  34971. *@return 是否支持顶点色。
  34972. */
  34973. __getset(0,__proto,'enableVertexColor',function(){
  34974. return this._enableVertexColor;
  34975. },function(value){
  34976. this._enableVertexColor=value;
  34977. if (value)
  34978. this._defineDatas.add(laya.d3.core.material.UnlitMaterial.SHADERDEFINE_ENABLEVERTEXCOLOR);
  34979. else
  34980. this._defineDatas.remove(laya.d3.core.material.UnlitMaterial.SHADERDEFINE_ENABLEVERTEXCOLOR);
  34981. });
  34982. /**
  34983. *设置反照率贴图。
  34984. *@param value 反照率贴图。
  34985. */
  34986. /**
  34987. *获取反照率贴图。
  34988. *@return 反照率贴图。
  34989. */
  34990. __getset(0,__proto,'albedoTexture',function(){
  34991. return this._shaderValues.getTexture(UnlitMaterial.ALBEDOTEXTURE);
  34992. },function(value){
  34993. if (value)
  34994. this._defineDatas.add(laya.d3.core.material.UnlitMaterial.SHADERDEFINE_ALBEDOTEXTURE);
  34995. else
  34996. this._defineDatas.remove(laya.d3.core.material.UnlitMaterial.SHADERDEFINE_ALBEDOTEXTURE);
  34997. this._shaderValues.setTexture(UnlitMaterial.ALBEDOTEXTURE,value);
  34998. });
  34999. /**
  35000. *获取纹理平铺和偏移Y分量。
  35001. *@param y 纹理平铺和偏移Y分量。
  35002. */
  35003. /**
  35004. *获取纹理平铺和偏移Y分量。
  35005. *@return 纹理平铺和偏移Y分量。
  35006. */
  35007. __getset(0,__proto,'tilingOffsetY',function(){
  35008. return this._MainTex_STY;
  35009. },function(y){
  35010. this._MainTex_STY=y;
  35011. });
  35012. /**
  35013. *获取纹理平铺和偏移Z分量。
  35014. *@param z 纹理平铺和偏移Z分量。
  35015. */
  35016. /**
  35017. *获取纹理平铺和偏移Z分量。
  35018. *@return 纹理平铺和偏移Z分量。
  35019. */
  35020. __getset(0,__proto,'tilingOffsetZ',function(){
  35021. return this._MainTex_STZ;
  35022. },function(z){
  35023. this._MainTex_STZ=z;
  35024. });
  35025. /**
  35026. *设置混合源。
  35027. *@param value 混合源
  35028. */
  35029. /**
  35030. *获取混合源。
  35031. *@return 混合源。
  35032. */
  35033. __getset(0,__proto,'blendSrc',function(){
  35034. return this._shaderValues.getInt(UnlitMaterial.BLEND_SRC);
  35035. },function(value){
  35036. this._shaderValues.setInt(UnlitMaterial.BLEND_SRC,value);
  35037. });
  35038. /**
  35039. *获取纹理平铺和偏移W分量。
  35040. *@param w 纹理平铺和偏移W分量。
  35041. */
  35042. /**
  35043. *获取纹理平铺和偏移W分量。
  35044. *@return 纹理平铺和偏移W分量。
  35045. */
  35046. __getset(0,__proto,'tilingOffsetW',function(){
  35047. return this._MainTex_STW;
  35048. },function(w){
  35049. this._MainTex_STW=w;
  35050. });
  35051. /**
  35052. *获取纹理平铺和偏移。
  35053. *@param value 纹理平铺和偏移。
  35054. */
  35055. /**
  35056. *获取纹理平铺和偏移。
  35057. *@return 纹理平铺和偏移。
  35058. */
  35059. __getset(0,__proto,'tilingOffset',function(){
  35060. return this._shaderValues.getVector(UnlitMaterial.TILINGOFFSET);
  35061. },function(value){
  35062. if (value){
  35063. if (value.x !=1 || value.y !=1 || value.z !=0 || value.w !=0)
  35064. this._defineDatas.add(laya.d3.core.material.UnlitMaterial.SHADERDEFINE_TILINGOFFSET);
  35065. else
  35066. this._defineDatas.remove(laya.d3.core.material.UnlitMaterial.SHADERDEFINE_TILINGOFFSET);
  35067. }else {
  35068. this._defineDatas.remove(laya.d3.core.material.UnlitMaterial.SHADERDEFINE_TILINGOFFSET);
  35069. }
  35070. this._shaderValues.setVector(UnlitMaterial.TILINGOFFSET,value);
  35071. });
  35072. /**
  35073. *设置渲染模式。
  35074. *@return 渲染模式。
  35075. */
  35076. __getset(0,__proto,'renderMode',null,function(value){
  35077. switch (value){
  35078. case 0:
  35079. this.alphaTest=false;
  35080. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_OPAQUE*/2000;
  35081. this.depthWrite=true;
  35082. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  35083. this.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  35084. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  35085. break ;
  35086. case 1:
  35087. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_ALPHATEST*/2450;
  35088. this.alphaTest=true;
  35089. this.depthWrite=true;
  35090. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  35091. this.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  35092. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  35093. break ;
  35094. case 2:
  35095. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_TRANSPARENT*/3000;
  35096. this.alphaTest=false;
  35097. this.depthWrite=false;
  35098. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  35099. this.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  35100. this.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_SRC_ALPHA*/0x0302;
  35101. this.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA*/0x0303;
  35102. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  35103. break ;
  35104. default :
  35105. throw new Error("UnlitMaterial : renderMode value error.");
  35106. }
  35107. });
  35108. /**
  35109. *设置是否写入深度。
  35110. *@param value 是否写入深度。
  35111. */
  35112. /**
  35113. *获取是否写入深度。
  35114. *@return 是否写入深度。
  35115. */
  35116. __getset(0,__proto,'depthWrite',function(){
  35117. return this._shaderValues.getBool(UnlitMaterial.DEPTH_WRITE);
  35118. },function(value){
  35119. this._shaderValues.setBool(UnlitMaterial.DEPTH_WRITE,value);
  35120. });
  35121. /**
  35122. *设置剔除方式。
  35123. *@param value 剔除方式。
  35124. */
  35125. /**
  35126. *获取剔除方式。
  35127. *@return 剔除方式。
  35128. */
  35129. __getset(0,__proto,'cull',function(){
  35130. return this._shaderValues.getInt(UnlitMaterial.CULL);
  35131. },function(value){
  35132. this._shaderValues.setInt(UnlitMaterial.CULL,value);
  35133. });
  35134. /**
  35135. *设置混合方式。
  35136. *@param value 混合方式。
  35137. */
  35138. /**
  35139. *获取混合方式。
  35140. *@return 混合方式。
  35141. */
  35142. __getset(0,__proto,'blend',function(){
  35143. return this._shaderValues.getInt(UnlitMaterial.BLEND);
  35144. },function(value){
  35145. this._shaderValues.setInt(UnlitMaterial.BLEND,value);
  35146. });
  35147. /**
  35148. *设置混合目标。
  35149. *@param value 混合目标
  35150. */
  35151. /**
  35152. *获取混合目标。
  35153. *@return 混合目标。
  35154. */
  35155. __getset(0,__proto,'blendDst',function(){
  35156. return this._shaderValues.getInt(UnlitMaterial.BLEND_DST);
  35157. },function(value){
  35158. this._shaderValues.setInt(UnlitMaterial.BLEND_DST,value);
  35159. });
  35160. /**
  35161. *设置深度测试方式。
  35162. *@param value 深度测试方式
  35163. */
  35164. /**
  35165. *获取深度测试方式。
  35166. *@return 深度测试方式。
  35167. */
  35168. __getset(0,__proto,'depthTest',function(){
  35169. return this._shaderValues.getInt(UnlitMaterial.DEPTH_TEST);
  35170. },function(value){
  35171. this._shaderValues.setInt(UnlitMaterial.DEPTH_TEST,value);
  35172. });
  35173. UnlitMaterial.__init__=function(){
  35174. UnlitMaterial.SHADERDEFINE_ALBEDOTEXTURE=UnlitMaterial.shaderDefines.registerDefine("ALBEDOTEXTURE");
  35175. UnlitMaterial.SHADERDEFINE_TILINGOFFSET=UnlitMaterial.shaderDefines.registerDefine("TILINGOFFSET");
  35176. UnlitMaterial.SHADERDEFINE_ENABLEVERTEXCOLOR=UnlitMaterial.shaderDefines.registerDefine("ENABLEVERTEXCOLOR");
  35177. }
  35178. UnlitMaterial.RENDERMODE_OPAQUE=0;
  35179. UnlitMaterial.RENDERMODE_CUTOUT=1;
  35180. UnlitMaterial.RENDERMODE_TRANSPARENT=2;
  35181. UnlitMaterial.RENDERMODE_ADDTIVE=3;
  35182. UnlitMaterial.SHADERDEFINE_ALBEDOTEXTURE=0;
  35183. UnlitMaterial.SHADERDEFINE_TILINGOFFSET=0;
  35184. UnlitMaterial.SHADERDEFINE_ENABLEVERTEXCOLOR=0;
  35185. __static(UnlitMaterial,
  35186. ['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);}
  35187. ]);
  35188. return UnlitMaterial;
  35189. })(BaseMaterial)
  35190. /**
  35191. *<code>PBRStandardMaterial</code> 类用于实现PBR(Standard)材质。
  35192. */
  35193. //class laya.d3.core.material.PBRStandardMaterial extends laya.d3.core.material.BaseMaterial
  35194. var PBRStandardMaterial=(function(_super){
  35195. function PBRStandardMaterial(){
  35196. /**@private */
  35197. this._albedoColor=null;
  35198. /**@private */
  35199. this._emissionColor=null;
  35200. PBRStandardMaterial.__super.call(this);
  35201. this.setShaderName("PBRStandard");
  35202. this._albedoColor=new Vector4(1.0,1.0,1.0,1.0);
  35203. this._shaderValues.setVector(PBRStandardMaterial.ALBEDOCOLOR,new Vector4(1.0,1.0,1.0,1.0));
  35204. this._emissionColor=new Vector4(0.0,0.0,0.0,0.0);
  35205. this._shaderValues.setVector(PBRStandardMaterial.EMISSIONCOLOR,new Vector4(0.0,0.0,0.0,0.0));
  35206. this._shaderValues.setNumber(PBRStandardMaterial.METALLIC,0.0);
  35207. this._shaderValues.setNumber(PBRStandardMaterial.SMOOTHNESS,0.5);
  35208. this._shaderValues.setNumber(PBRStandardMaterial.SMOOTHNESSSCALE,1.0);
  35209. this._shaderValues.setNumber(PBRStandardMaterial.SMOOTHNESSSOURCE,0);
  35210. this._shaderValues.setNumber(PBRStandardMaterial.OCCLUSIONSTRENGTH,1.0);
  35211. this._shaderValues.setNumber(PBRStandardMaterial.NORMALSCALE,1.0);
  35212. this._shaderValues.setNumber(PBRStandardMaterial.PARALLAXSCALE,0.001);
  35213. this._shaderValues.setBool(PBRStandardMaterial.ENABLEEMISSION,false);
  35214. this._shaderValues.setBool(PBRStandardMaterial.ENABLEREFLECT,true);
  35215. this._shaderValues.setNumber(BaseMaterial.ALPHATESTVALUE,0.5);
  35216. this._disablePublicDefineDatas.remove(Scene3D.SHADERDEFINE_REFLECTMAP);
  35217. this.renderMode=0;
  35218. }
  35219. __class(PBRStandardMaterial,'laya.d3.core.material.PBRStandardMaterial',_super);
  35220. var __proto=PBRStandardMaterial.prototype;
  35221. /**
  35222. *@inheritDoc
  35223. */
  35224. __proto.cloneTo=function(destObject){
  35225. _super.prototype.cloneTo.call(this,destObject);
  35226. var destMaterial=destObject;
  35227. this._albedoColor.cloneTo(destMaterial._albedoColor);
  35228. this._emissionColor.cloneTo(destMaterial._emissionColor);
  35229. }
  35230. /**
  35231. *@private
  35232. */
  35233. /**@private */
  35234. __getset(0,__proto,'_Parallax',function(){
  35235. return this._shaderValues.getNumber(PBRStandardMaterial.PARALLAXSCALE);
  35236. },function(value){
  35237. this._shaderValues.setNumber(PBRStandardMaterial.PARALLAXSCALE,value);
  35238. });
  35239. /**
  35240. *@private
  35241. */
  35242. /**
  35243. *@private
  35244. */
  35245. __getset(0,__proto,'_ColorB',function(){
  35246. return this._albedoColor.z;
  35247. },function(value){
  35248. this._albedoColor.z=value;
  35249. this.albedoColor=this._albedoColor;
  35250. });
  35251. /**
  35252. *@private
  35253. */
  35254. /**
  35255. *@private
  35256. */
  35257. __getset(0,__proto,'_ColorR',function(){
  35258. return this._albedoColor.x;
  35259. },function(value){
  35260. this._albedoColor.x=value;
  35261. this.albedoColor=this._albedoColor;
  35262. });
  35263. /**
  35264. *@private
  35265. */
  35266. /**
  35267. *@private
  35268. */
  35269. __getset(0,__proto,'_ColorG',function(){
  35270. return this._albedoColor.y;
  35271. },function(value){
  35272. this._albedoColor.y=value;
  35273. this.albedoColor=this._albedoColor;
  35274. });
  35275. /**
  35276. *设置金属度。
  35277. *@param value 金属度,范围为0到1。
  35278. */
  35279. /**
  35280. *获取金属度。
  35281. *@return 金属度,范围为0到1。
  35282. */
  35283. __getset(0,__proto,'metallic',function(){
  35284. return this._Metallic;
  35285. },function(value){
  35286. this._Metallic=Math.max(0.0,Math.min(1.0,value));
  35287. });
  35288. /**
  35289. *@private
  35290. */
  35291. /**
  35292. *@private
  35293. */
  35294. __getset(0,__proto,'_GlossMapScale',function(){
  35295. return this._shaderValues.getNumber(PBRStandardMaterial.SMOOTHNESSSCALE);
  35296. },function(value){
  35297. this._shaderValues.setNumber(PBRStandardMaterial.SMOOTHNESSSCALE,value);
  35298. });
  35299. /**
  35300. *@private
  35301. */
  35302. /**
  35303. *@private
  35304. */
  35305. __getset(0,__proto,'_Glossiness',function(){
  35306. return this._shaderValues.getNumber(PBRStandardMaterial.SMOOTHNESS);
  35307. },function(value){
  35308. this._shaderValues.setNumber(PBRStandardMaterial.SMOOTHNESS,value);
  35309. });
  35310. /**
  35311. *@private
  35312. */
  35313. /**
  35314. *@private
  35315. */
  35316. __getset(0,__proto,'_ColorA',function(){
  35317. return this._albedoColor.w;
  35318. },function(value){
  35319. this._albedoColor.w=value;
  35320. this.albedoColor=this._albedoColor;
  35321. });
  35322. /**
  35323. *设置是否开启反射。
  35324. *@param value 是否开启反射。
  35325. */
  35326. /**
  35327. *获取是否开启反射。
  35328. *@return 是否开启反射。
  35329. */
  35330. __getset(0,__proto,'enableReflection',function(){
  35331. return this._shaderValues.getBool(PBRStandardMaterial.ENABLEREFLECT);
  35332. },function(value){
  35333. this._shaderValues.setBool(PBRStandardMaterial.ENABLEREFLECT,true);
  35334. if (value){
  35335. this._disablePublicDefineDatas.remove(Scene3D.SHADERDEFINE_REFLECTMAP);
  35336. }else {
  35337. this._disablePublicDefineDatas.add(Scene3D.SHADERDEFINE_REFLECTMAP);
  35338. }
  35339. });
  35340. /**
  35341. *@private
  35342. */
  35343. /**
  35344. *@private
  35345. */
  35346. __getset(0,__proto,'_Metallic',function(){
  35347. return this._shaderValues.getNumber(PBRStandardMaterial.METALLIC);
  35348. },function(value){
  35349. this._shaderValues.setNumber(PBRStandardMaterial.METALLIC,value);
  35350. });
  35351. /**
  35352. *@private
  35353. */
  35354. /**
  35355. *@private
  35356. */
  35357. __getset(0,__proto,'_BumpScale',function(){
  35358. return this._shaderValues.getNumber(PBRStandardMaterial.NORMALSCALE);
  35359. },function(value){
  35360. this._shaderValues.setNumber(PBRStandardMaterial.NORMALSCALE,value);
  35361. });
  35362. /**
  35363. *@private
  35364. */
  35365. /**@private */
  35366. __getset(0,__proto,'_OcclusionStrength',function(){
  35367. return this._shaderValues.getNumber(PBRStandardMaterial.OCCLUSIONSTRENGTH);
  35368. },function(value){
  35369. this._shaderValues.setNumber(PBRStandardMaterial.OCCLUSIONSTRENGTH,value);
  35370. });
  35371. /**
  35372. *@private
  35373. */
  35374. /**
  35375. *@private
  35376. */
  35377. __getset(0,__proto,'_EmissionColorR',function(){
  35378. return this._emissionColor.x;
  35379. },function(value){
  35380. this._emissionColor.x=value;
  35381. this.emissionColor=this._emissionColor;
  35382. });
  35383. /**
  35384. *获取纹理平铺和偏移。
  35385. *@param value 纹理平铺和偏移。
  35386. */
  35387. /**
  35388. *获取纹理平铺和偏移。
  35389. *@return 纹理平铺和偏移。
  35390. */
  35391. __getset(0,__proto,'tilingOffset',function(){
  35392. return this._shaderValues.getVector(PBRStandardMaterial.TILINGOFFSET);
  35393. },function(value){
  35394. if (value){
  35395. if (value.x !=1 || value.y !=1 || value.z !=0 || value.w !=0){
  35396. this._defineDatas.add(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_TILINGOFFSET);
  35397. }else {
  35398. this._defineDatas.remove(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_TILINGOFFSET);
  35399. }
  35400. }else {
  35401. this._defineDatas.remove(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_TILINGOFFSET);
  35402. }
  35403. this._shaderValues.setVector(PBRStandardMaterial.TILINGOFFSET,value);
  35404. });
  35405. /**
  35406. *@private
  35407. */
  35408. /**
  35409. *@private
  35410. */
  35411. __getset(0,__proto,'_EmissionColorG',function(){
  35412. return this._emissionColor.y;
  35413. },function(value){
  35414. this._emissionColor.y=value;
  35415. this.emissionColor=this._emissionColor;
  35416. });
  35417. /**
  35418. *设置混合源。
  35419. *@param value 混合源
  35420. */
  35421. /**
  35422. *获取混合源。
  35423. *@return 混合源。
  35424. */
  35425. __getset(0,__proto,'blendSrc',function(){
  35426. return this._shaderValues.getInt(PBRStandardMaterial.BLEND_SRC);
  35427. },function(value){
  35428. this._shaderValues.setInt(PBRStandardMaterial.BLEND_SRC,value);
  35429. });
  35430. /**
  35431. *获取纹理平铺和偏移W分量。
  35432. *@param w 纹理平铺和偏移W分量。
  35433. */
  35434. /**
  35435. *获取纹理平铺和偏移W分量。
  35436. *@return 纹理平铺和偏移W分量。
  35437. */
  35438. __getset(0,__proto,'tilingOffsetW',function(){
  35439. return this._MainTex_STW;
  35440. },function(w){
  35441. this._MainTex_STW=w;
  35442. });
  35443. /**
  35444. *@private
  35445. */
  35446. /**
  35447. *@private
  35448. */
  35449. __getset(0,__proto,'_EmissionColorB',function(){
  35450. return this._emissionColor.z;
  35451. },function(value){
  35452. this._emissionColor.z=value;
  35453. this.emissionColor=this._emissionColor;
  35454. });
  35455. /**
  35456. *@private
  35457. */
  35458. /**
  35459. *@private
  35460. */
  35461. __getset(0,__proto,'_EmissionColorA',function(){
  35462. return this._emissionColor.w;
  35463. },function(value){
  35464. this._emissionColor.w=value;
  35465. this.emissionColor=this._emissionColor;
  35466. });
  35467. /**
  35468. *设置反射率颜色alpha分量。
  35469. *@param value 反射率颜色alpha分量。
  35470. */
  35471. /**
  35472. *获取反射率颜色Z分量。
  35473. *@return 反射率颜色Z分量。
  35474. */
  35475. __getset(0,__proto,'albedoColorA',function(){
  35476. return this._ColorA;
  35477. },function(value){
  35478. this._ColorA=value;
  35479. });
  35480. /**
  35481. *@private
  35482. */
  35483. /**
  35484. *@private
  35485. */
  35486. __getset(0,__proto,'_MainTex_STX',function(){
  35487. return this._shaderValues.getVector(PBRStandardMaterial.TILINGOFFSET).x;
  35488. },function(x){
  35489. var tilOff=this._shaderValues.getVector(PBRStandardMaterial.TILINGOFFSET);
  35490. tilOff.x=x;
  35491. this.tilingOffset=tilOff;
  35492. });
  35493. /**
  35494. *@private
  35495. */
  35496. /**
  35497. *@private
  35498. */
  35499. __getset(0,__proto,'_MainTex_STY',function(){
  35500. return this._shaderValues.getVector(PBRStandardMaterial.TILINGOFFSET).y;
  35501. },function(y){
  35502. var tilOff=this._shaderValues.getVector(PBRStandardMaterial.TILINGOFFSET);
  35503. tilOff.y=y;
  35504. this.tilingOffset=tilOff;
  35505. });
  35506. /**
  35507. *@private
  35508. */
  35509. /**
  35510. *@private
  35511. */
  35512. __getset(0,__proto,'_MainTex_STZ',function(){
  35513. return this._shaderValues.getVector(PBRStandardMaterial.TILINGOFFSET).z;
  35514. },function(z){
  35515. var tilOff=this._shaderValues.getVector(PBRStandardMaterial.TILINGOFFSET);
  35516. tilOff.z=z;
  35517. this.tilingOffset=tilOff;
  35518. });
  35519. /**
  35520. *@private
  35521. */
  35522. /**
  35523. *@private
  35524. */
  35525. __getset(0,__proto,'_Cutoff',function(){
  35526. return this.alphaTestValue;
  35527. },function(value){
  35528. this.alphaTestValue=value;
  35529. });
  35530. /**
  35531. *@private
  35532. */
  35533. /**
  35534. *@private
  35535. */
  35536. __getset(0,__proto,'_MainTex_STW',function(){
  35537. return this._shaderValues.getVector(PBRStandardMaterial.TILINGOFFSET).w;
  35538. },function(w){
  35539. var tilOff=this._shaderValues.getVector(PBRStandardMaterial.TILINGOFFSET);
  35540. tilOff.w=w;
  35541. this.tilingOffset=tilOff;
  35542. });
  35543. /**
  35544. *设置反射率颜色R分量。
  35545. *@param value 反射率颜色R分量。
  35546. */
  35547. /**
  35548. *获取反射率颜色R分量。
  35549. *@return 反射率颜色R分量。
  35550. */
  35551. __getset(0,__proto,'albedoColorR',function(){
  35552. return this._ColorR;
  35553. },function(value){
  35554. this._ColorR=value;
  35555. });
  35556. /**
  35557. *设置反射率颜色G分量。
  35558. *@param value 反射率颜色G分量。
  35559. */
  35560. /**
  35561. *获取反射率颜色G分量。
  35562. *@return 反射率颜色G分量。
  35563. */
  35564. __getset(0,__proto,'albedoColorG',function(){
  35565. return this._ColorG;
  35566. },function(value){
  35567. this._ColorG=value;
  35568. });
  35569. /**
  35570. *设置反射率颜色B分量。
  35571. *@param value 反射率颜色B分量。
  35572. */
  35573. /**
  35574. *获取反射率颜色B分量。
  35575. *@return 反射率颜色B分量。
  35576. */
  35577. __getset(0,__proto,'albedoColorB',function(){
  35578. return this._ColorB;
  35579. },function(value){
  35580. this._ColorB=value;
  35581. });
  35582. /**
  35583. *获取纹理平铺和偏移X分量。
  35584. *@param x 纹理平铺和偏移X分量。
  35585. */
  35586. /**
  35587. *获取纹理平铺和偏移X分量。
  35588. *@return 纹理平铺和偏移X分量。
  35589. */
  35590. __getset(0,__proto,'tilingOffsetX',function(){
  35591. return this._MainTex_STX;
  35592. },function(x){
  35593. this._MainTex_STX=x;
  35594. });
  35595. /**
  35596. *设置漫反射颜色。
  35597. *@param value 漫反射颜色。
  35598. */
  35599. /**
  35600. *获取漫反射颜色。
  35601. *@return 漫反射颜色。
  35602. */
  35603. __getset(0,__proto,'albedoColor',function(){
  35604. return this._albedoColor;
  35605. },function(value){
  35606. this._albedoColor=value;
  35607. this._shaderValues.setVector(PBRStandardMaterial.ALBEDOCOLOR,value);
  35608. });
  35609. /**
  35610. *设置漫反射贴图。
  35611. *@param value 漫反射贴图。
  35612. */
  35613. /**
  35614. *获取漫反射贴图。
  35615. *@return 漫反射贴图。
  35616. */
  35617. __getset(0,__proto,'albedoTexture',function(){
  35618. return this._shaderValues.getTexture(PBRStandardMaterial.ALBEDOTEXTURE);
  35619. },function(value){
  35620. if (value){
  35621. this._defineDatas.add(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_ALBEDOTEXTURE);
  35622. }else {
  35623. this._defineDatas.remove(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_ALBEDOTEXTURE);
  35624. }
  35625. this._shaderValues.setTexture(PBRStandardMaterial.ALBEDOTEXTURE,value);
  35626. });
  35627. /**
  35628. *设置剔除方式。
  35629. *@param value 剔除方式。
  35630. */
  35631. /**
  35632. *获取剔除方式。
  35633. *@return 剔除方式。
  35634. */
  35635. __getset(0,__proto,'cull',function(){
  35636. return this._shaderValues.getInt(PBRStandardMaterial.CULL);
  35637. },function(value){
  35638. this._shaderValues.setInt(PBRStandardMaterial.CULL,value);
  35639. });
  35640. /**
  35641. *设置视差贴图。
  35642. *@param value 视察贴图。
  35643. */
  35644. /**
  35645. *获取视差贴图。
  35646. *@return 视察贴图。
  35647. */
  35648. __getset(0,__proto,'parallaxTexture',function(){
  35649. return this._shaderValues.getTexture(PBRStandardMaterial.PARALLAXTEXTURE);
  35650. },function(value){
  35651. if (value){
  35652. this._defineDatas.add(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_PARALLAXTEXTURE);
  35653. }else {
  35654. this._defineDatas.remove(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_PARALLAXTEXTURE);
  35655. }
  35656. this._shaderValues.setTexture(PBRStandardMaterial.PARALLAXTEXTURE,value);
  35657. });
  35658. /**
  35659. *设置法线贴图。
  35660. *@param value 法线贴图。
  35661. */
  35662. /**
  35663. *获取法线贴图。
  35664. *@return 法线贴图。
  35665. */
  35666. __getset(0,__proto,'normalTexture',function(){
  35667. return this._shaderValues.getTexture(PBRStandardMaterial.NORMALTEXTURE);
  35668. },function(value){
  35669. if (value){
  35670. this._defineDatas.add(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_NORMALTEXTURE);
  35671. }else {
  35672. this._defineDatas.remove(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_NORMALTEXTURE);
  35673. }
  35674. this._shaderValues.setTexture(PBRStandardMaterial.NORMALTEXTURE,value);
  35675. });
  35676. /**
  35677. *设置放射颜色。
  35678. *@param value 放射颜色。
  35679. */
  35680. /**
  35681. *获取放射颜色。
  35682. *@return 放射颜色。
  35683. */
  35684. __getset(0,__proto,'emissionColor',function(){
  35685. return this._shaderValues.getVector(PBRStandardMaterial.EMISSIONCOLOR);
  35686. },function(value){
  35687. this._shaderValues.setVector(PBRStandardMaterial.EMISSIONCOLOR,value);
  35688. });
  35689. /**
  35690. *设置视差贴图缩放系数。
  35691. *@param value 视差缩放系数。
  35692. */
  35693. /**
  35694. *获取视差贴图缩放系数。
  35695. *@return 视差缩放系数。
  35696. */
  35697. __getset(0,__proto,'parallaxTextureScale',function(){
  35698. return this._Parallax;
  35699. },function(value){
  35700. this._Parallax=Math.max(0.005,Math.min(0.08,value));
  35701. });
  35702. /**
  35703. *设置法线贴图缩放系数。
  35704. *@param value 法线贴图缩放系数。
  35705. */
  35706. /**
  35707. *获取法线贴图缩放系数。
  35708. *@return 法线贴图缩放系数。
  35709. */
  35710. __getset(0,__proto,'normalTextureScale',function(){
  35711. return this._BumpScale;
  35712. },function(value){
  35713. this._BumpScale=value;
  35714. });
  35715. /**
  35716. *获取纹理平铺和偏移Z分量。
  35717. *@param z 纹理平铺和偏移Z分量。
  35718. */
  35719. /**
  35720. *获取纹理平铺和偏移Z分量。
  35721. *@return 纹理平铺和偏移Z分量。
  35722. */
  35723. __getset(0,__proto,'tilingOffsetZ',function(){
  35724. return this._MainTex_STZ;
  35725. },function(z){
  35726. this._MainTex_STZ=z;
  35727. });
  35728. /**
  35729. *设置遮挡贴图。
  35730. *@param value 遮挡贴图。
  35731. */
  35732. /**
  35733. *获取遮挡贴图。
  35734. *@return 遮挡贴图。
  35735. */
  35736. __getset(0,__proto,'occlusionTexture',function(){
  35737. return this._shaderValues.getTexture(PBRStandardMaterial.OCCLUSIONTEXTURE);
  35738. },function(value){
  35739. if (value){
  35740. this._defineDatas.add(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_OCCLUSIONTEXTURE);
  35741. }else {
  35742. this._defineDatas.remove(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_OCCLUSIONTEXTURE);
  35743. }
  35744. this._shaderValues.setTexture(PBRStandardMaterial.OCCLUSIONTEXTURE,value);
  35745. });
  35746. /**
  35747. *设置遮挡贴图强度。
  35748. *@param value 遮挡贴图强度,范围为0到1。
  35749. */
  35750. /**
  35751. *获取遮挡贴图强度。
  35752. *@return 遮挡贴图强度,范围为0到1。
  35753. */
  35754. __getset(0,__proto,'occlusionTextureStrength',function(){
  35755. return this._OcclusionStrength;
  35756. },function(value){
  35757. this._OcclusionStrength=Math.max(0.0,Math.min(1.0,value));
  35758. });
  35759. /**
  35760. *设置是否激活放射属性。
  35761. *@param value 是否激活放射属性
  35762. */
  35763. /**
  35764. *获取是否激活放射属性。
  35765. *@return 是否激活放射属性。
  35766. */
  35767. __getset(0,__proto,'enableEmission',function(){
  35768. return this._shaderValues.getBool(PBRStandardMaterial.ENABLEEMISSION);
  35769. },function(value){
  35770. if (value){
  35771. this._defineDatas.add(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_EMISSION);
  35772. }else {
  35773. this._defineDatas.remove(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_EMISSION);
  35774. }
  35775. this._shaderValues.setBool(PBRStandardMaterial.ENABLEEMISSION,value);
  35776. });
  35777. /**
  35778. *设置金属光滑度贴图。
  35779. *@param value 金属光滑度贴图。
  35780. */
  35781. /**
  35782. *获取金属光滑度贴图。
  35783. *@return 金属光滑度贴图。
  35784. */
  35785. __getset(0,__proto,'metallicGlossTexture',function(){
  35786. return this._shaderValues.getTexture(PBRStandardMaterial.METALLICGLOSSTEXTURE);
  35787. },function(value){
  35788. if (value){
  35789. this._defineDatas.add(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_METALLICGLOSSTEXTURE);
  35790. }else {
  35791. this._defineDatas.remove(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_METALLICGLOSSTEXTURE);
  35792. }
  35793. this._shaderValues.setTexture(PBRStandardMaterial.METALLICGLOSSTEXTURE,value);
  35794. });
  35795. /**
  35796. *设置放射颜色A分量。
  35797. *@param value 放射颜色A分量。
  35798. */
  35799. /**
  35800. *获取放射颜色A分量。
  35801. *@return 放射颜色A分量。
  35802. */
  35803. __getset(0,__proto,'emissionColorA',function(){
  35804. return this._EmissionColorA;
  35805. },function(value){
  35806. this._EmissionColorA=value;
  35807. });
  35808. /**
  35809. *设置光滑度。
  35810. *@param value 光滑度,范围为0到1。
  35811. */
  35812. /**
  35813. *获取光滑度。
  35814. *@return 光滑度,范围为0到1。
  35815. */
  35816. __getset(0,__proto,'smoothness',function(){
  35817. return this._Glossiness;
  35818. },function(value){
  35819. this._Glossiness=Math.max(0.0,Math.min(1.0,value));
  35820. });
  35821. /**
  35822. *设置混合目标。
  35823. *@param value 混合目标
  35824. */
  35825. /**
  35826. *获取混合目标。
  35827. *@return 混合目标。
  35828. */
  35829. __getset(0,__proto,'blendDst',function(){
  35830. return this._shaderValues.getInt(PBRStandardMaterial.BLEND_DST);
  35831. },function(value){
  35832. this._shaderValues.setInt(PBRStandardMaterial.BLEND_DST,value);
  35833. });
  35834. /**
  35835. *设置光滑度缩放系数。
  35836. *@param value 光滑度缩放系数,范围为0到1。
  35837. */
  35838. /**
  35839. *获取光滑度缩放系数。
  35840. *@return 光滑度缩放系数,范围为0到1。
  35841. */
  35842. __getset(0,__proto,'smoothnessTextureScale',function(){
  35843. return this._GlossMapScale;
  35844. },function(value){
  35845. this._GlossMapScale=Math.max(0.0,Math.min(1.0,value));
  35846. });
  35847. /**
  35848. *设置是否写入深度。
  35849. *@param value 是否写入深度。
  35850. */
  35851. /**
  35852. *获取是否写入深度。
  35853. *@return 是否写入深度。
  35854. */
  35855. __getset(0,__proto,'depthWrite',function(){
  35856. return this._shaderValues.getBool(PBRStandardMaterial.DEPTH_WRITE);
  35857. },function(value){
  35858. this._shaderValues.setBool(PBRStandardMaterial.DEPTH_WRITE,value);
  35859. });
  35860. /**
  35861. *设置光滑度数据源。
  35862. *@param value 光滑滑度数据源,0或1。
  35863. */
  35864. /**
  35865. *获取光滑度数据源
  35866. *@return 光滑滑度数据源,0或1。
  35867. */
  35868. __getset(0,__proto,'smoothnessSource',function(){
  35869. return this._shaderValues.getInt(PBRStandardMaterial.SMOOTHNESSSOURCE);
  35870. },function(value){
  35871. if (value){
  35872. this._defineDatas.add(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA);
  35873. this._shaderValues.setInt(PBRStandardMaterial.SMOOTHNESSSOURCE,1);
  35874. }else {
  35875. this._defineDatas.remove(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA);
  35876. this._shaderValues.setInt(PBRStandardMaterial.SMOOTHNESSSOURCE,0);
  35877. }
  35878. });
  35879. /**
  35880. *设置放射颜色R分量。
  35881. *@param value 放射颜色R分量。
  35882. */
  35883. /**
  35884. *获取放射颜色R分量。
  35885. *@return 放射颜色R分量。
  35886. */
  35887. __getset(0,__proto,'emissionColorR',function(){
  35888. return this._EmissionColorR;
  35889. },function(value){
  35890. this._EmissionColorR=value;
  35891. });
  35892. /**
  35893. *设置放射颜色G分量。
  35894. *@param value 放射颜色G分量。
  35895. */
  35896. /**
  35897. *获取放射颜色G分量。
  35898. *@return 放射颜色G分量。
  35899. */
  35900. __getset(0,__proto,'emissionColorG',function(){
  35901. return this._EmissionColorG;
  35902. },function(value){
  35903. this._EmissionColorG=value;
  35904. });
  35905. /**
  35906. *设置放射颜色B分量。
  35907. *@param value 放射颜色B分量。
  35908. */
  35909. /**
  35910. *获取放射颜色B分量。
  35911. *@return 放射颜色B分量。
  35912. */
  35913. __getset(0,__proto,'emissionColorB',function(){
  35914. return this._EmissionColorB;
  35915. },function(value){
  35916. this._EmissionColorB=value;
  35917. });
  35918. /**
  35919. *设置放射贴图。
  35920. *@param value 放射贴图。
  35921. */
  35922. /**
  35923. *获取放射贴图。
  35924. *@return 放射贴图。
  35925. */
  35926. __getset(0,__proto,'emissionTexture',function(){
  35927. return this._shaderValues.getTexture(PBRStandardMaterial.EMISSIONTEXTURE);
  35928. },function(value){
  35929. if (value){
  35930. this._defineDatas.add(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_EMISSIONTEXTURE);
  35931. }else {
  35932. this._defineDatas.remove(laya.d3.core.material.PBRStandardMaterial.SHADERDEFINE_EMISSIONTEXTURE);
  35933. }
  35934. this._shaderValues.setTexture(PBRStandardMaterial.EMISSIONTEXTURE,value);
  35935. });
  35936. /**
  35937. *获取纹理平铺和偏移Y分量。
  35938. *@param y 纹理平铺和偏移Y分量。
  35939. */
  35940. /**
  35941. *获取纹理平铺和偏移Y分量。
  35942. *@return 纹理平铺和偏移Y分量。
  35943. */
  35944. __getset(0,__proto,'tilingOffsetY',function(){
  35945. return this._MainTex_STY;
  35946. },function(y){
  35947. this._MainTex_STY=y;
  35948. });
  35949. /**
  35950. *设置渲染模式。
  35951. *@return 渲染模式。
  35952. */
  35953. __getset(0,__proto,'renderMode',null,function(value){
  35954. switch (value){
  35955. case 0:
  35956. this.alphaTest=false;
  35957. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_OPAQUE*/2000;
  35958. this.depthWrite=true;
  35959. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  35960. this.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  35961. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  35962. this._defineDatas.remove(PBRStandardMaterial.SHADERDEFINE_ALPHAPREMULTIPLY);
  35963. break ;
  35964. case 1:
  35965. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_ALPHATEST*/2450;
  35966. this.alphaTest=true;
  35967. this.depthWrite=true;
  35968. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  35969. this.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  35970. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  35971. this._defineDatas.remove(PBRStandardMaterial.SHADERDEFINE_ALPHAPREMULTIPLY);
  35972. break ;
  35973. case 2:
  35974. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_TRANSPARENT*/3000;
  35975. this.alphaTest=false;
  35976. this.depthWrite=false;
  35977. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  35978. this.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  35979. this.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_SRC_ALPHA*/0x0302;
  35980. this.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA*/0x0303;
  35981. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  35982. this._defineDatas.remove(PBRStandardMaterial.SHADERDEFINE_ALPHAPREMULTIPLY);
  35983. break ;
  35984. break ;
  35985. case 3:
  35986. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_TRANSPARENT*/3000;
  35987. this.alphaTest=false;
  35988. this.depthWrite=false;
  35989. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  35990. this.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  35991. this.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE*/1;
  35992. this.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA*/0x0303;
  35993. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  35994. this._defineDatas.add(PBRStandardMaterial.SHADERDEFINE_ALPHAPREMULTIPLY);
  35995. break ;
  35996. default :
  35997. throw new Error("PBRSpecularMaterial : renderMode value error.");
  35998. }
  35999. });
  36000. /**
  36001. *设置混合方式。
  36002. *@param value 混合方式。
  36003. */
  36004. /**
  36005. *获取混合方式。
  36006. *@return 混合方式。
  36007. */
  36008. __getset(0,__proto,'blend',function(){
  36009. return this._shaderValues.getInt(PBRStandardMaterial.BLEND);
  36010. },function(value){
  36011. this._shaderValues.setInt(PBRStandardMaterial.BLEND,value);
  36012. });
  36013. /**
  36014. *设置深度测试方式。
  36015. *@param value 深度测试方式
  36016. */
  36017. /**
  36018. *获取深度测试方式。
  36019. *@return 深度测试方式。
  36020. */
  36021. __getset(0,__proto,'depthTest',function(){
  36022. return this._shaderValues.getInt(PBRStandardMaterial.DEPTH_TEST);
  36023. },function(value){
  36024. this._shaderValues.setInt(PBRStandardMaterial.DEPTH_TEST,value);
  36025. });
  36026. PBRStandardMaterial.__init__=function(){
  36027. PBRStandardMaterial.SHADERDEFINE_ALBEDOTEXTURE=PBRStandardMaterial.shaderDefines.registerDefine("ALBEDOTEXTURE");
  36028. PBRStandardMaterial.SHADERDEFINE_METALLICGLOSSTEXTURE=PBRStandardMaterial.shaderDefines.registerDefine("METALLICGLOSSTEXTURE");
  36029. PBRStandardMaterial.SHADERDEFINE_SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA=PBRStandardMaterial.shaderDefines.registerDefine("SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA");
  36030. PBRStandardMaterial.SHADERDEFINE_NORMALTEXTURE=PBRStandardMaterial.shaderDefines.registerDefine("NORMALTEXTURE");
  36031. PBRStandardMaterial.SHADERDEFINE_PARALLAXTEXTURE=PBRStandardMaterial.shaderDefines.registerDefine("PARALLAXTEXTURE");
  36032. PBRStandardMaterial.SHADERDEFINE_OCCLUSIONTEXTURE=PBRStandardMaterial.shaderDefines.registerDefine("OCCLUSIONTEXTURE");
  36033. PBRStandardMaterial.SHADERDEFINE_EMISSION=PBRStandardMaterial.shaderDefines.registerDefine("EMISSION");
  36034. PBRStandardMaterial.SHADERDEFINE_EMISSIONTEXTURE=PBRStandardMaterial.shaderDefines.registerDefine("EMISSIONTEXTURE");
  36035. PBRStandardMaterial.SHADERDEFINE_REFLECTMAP=PBRStandardMaterial.shaderDefines.registerDefine("REFLECTMAP");
  36036. PBRStandardMaterial.SHADERDEFINE_TILINGOFFSET=PBRStandardMaterial.shaderDefines.registerDefine("TILINGOFFSET");
  36037. PBRStandardMaterial.SHADERDEFINE_ALPHAPREMULTIPLY=PBRStandardMaterial.shaderDefines.registerDefine("ALPHAPREMULTIPLY");
  36038. }
  36039. PBRStandardMaterial.SmoothnessSource_MetallicGlossTexture_Alpha=0;
  36040. PBRStandardMaterial.SmoothnessSource_AlbedoTexture_Alpha=1;
  36041. PBRStandardMaterial.RENDERMODE_OPAQUE=0;
  36042. PBRStandardMaterial.RENDERMODE_CUTOUT=1;
  36043. PBRStandardMaterial.RENDERMODE_FADE=2;
  36044. PBRStandardMaterial.RENDERMODE_TRANSPARENT=3;
  36045. PBRStandardMaterial.SHADERDEFINE_ALBEDOTEXTURE=0;
  36046. PBRStandardMaterial.SHADERDEFINE_NORMALTEXTURE=0;
  36047. PBRStandardMaterial.SHADERDEFINE_SMOOTHNESSSOURCE_ALBEDOTEXTURE_ALPHA=0;
  36048. PBRStandardMaterial.SHADERDEFINE_METALLICGLOSSTEXTURE=0;
  36049. PBRStandardMaterial.SHADERDEFINE_OCCLUSIONTEXTURE=0;
  36050. PBRStandardMaterial.SHADERDEFINE_PARALLAXTEXTURE=0;
  36051. PBRStandardMaterial.SHADERDEFINE_EMISSION=0;
  36052. PBRStandardMaterial.SHADERDEFINE_EMISSIONTEXTURE=0;
  36053. PBRStandardMaterial.SHADERDEFINE_REFLECTMAP=0;
  36054. PBRStandardMaterial.SHADERDEFINE_TILINGOFFSET=0;
  36055. PBRStandardMaterial.SHADERDEFINE_ALPHAPREMULTIPLY=0;
  36056. PBRStandardMaterial.SMOOTHNESSSOURCE=-1;
  36057. PBRStandardMaterial.ENABLEEMISSION=-1;
  36058. PBRStandardMaterial.ENABLEREFLECT=-1;
  36059. __static(PBRStandardMaterial,
  36060. ['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);}
  36061. ]);
  36062. return PBRStandardMaterial;
  36063. })(BaseMaterial)
  36064. /**
  36065. *<code>BaseCamera</code> 类用于创建摄像机的父类。
  36066. */
  36067. //class laya.d3.core.BaseCamera extends laya.d3.core.Sprite3D
  36068. var BaseCamera=(function(_super){
  36069. function BaseCamera(nearPlane,farPlane){
  36070. /**@private 渲染顺序。*/
  36071. //this._renderingOrder=0;
  36072. /**@private 近裁剪面。*/
  36073. //this._nearPlane=NaN;
  36074. /**@private 远裁剪面。*/
  36075. //this._farPlane=NaN;
  36076. /**@private 视野。*/
  36077. //this._fieldOfView=NaN;
  36078. /**@private 正交投影的垂直尺寸。*/
  36079. //this._orthographicVerticalSize=NaN;
  36080. /**@private */
  36081. //this._orthographic=false;
  36082. /**@private 是否使用用户自定义投影矩阵,如果使用了用户投影矩阵,摄像机投影矩阵相关的参数改变则不改变投影矩阵的值,需调用ResetProjectionMatrix方法。*/
  36083. //this._useUserProjectionMatrix=false;
  36084. /**@private */
  36085. //this._shaderValues=null;
  36086. /**清楚标记。*/
  36087. //this.clearFlag=0;
  36088. /**可视层位标记遮罩值,支持混合 例:cullingMask=Math.pow(2,0)|Math.pow(2,1)为第0层和第1层可见。*/
  36089. //this.cullingMask=0;
  36090. /**渲染时是否用遮挡剔除。 */
  36091. //this.useOcclusionCulling=false;
  36092. BaseCamera.__super.call(this);
  36093. this._skyRenderer=new SkyRenderer();
  36094. this._forward=new Vector3();
  36095. this._up=new Vector3();
  36096. this.clearColor=new Vector4(100 / 255,149 / 255,237 / 255,255 / 255);
  36097. (nearPlane===void 0)&& (nearPlane=0.3);
  36098. (farPlane===void 0)&& (farPlane=1000);
  36099. this._shaderValues=new ShaderData(null);
  36100. this._fieldOfView=60;
  36101. this._useUserProjectionMatrix=false;
  36102. this._orthographic=false;
  36103. this._orthographicVerticalSize=10;
  36104. this.renderingOrder=0;
  36105. this._nearPlane=nearPlane;
  36106. this._farPlane=farPlane;
  36107. this.cullingMask=2147483647;
  36108. this.clearFlag=/*CLASS CONST:laya.d3.core.BaseCamera.CLEARFLAG_SOLIDCOLOR*/0;
  36109. this.useOcclusionCulling=true;
  36110. this._calculateProjectionMatrix();
  36111. Laya.stage.on(/*laya.events.Event.RESIZE*/"resize",this,this._onScreenSizeChanged);
  36112. }
  36113. __class(BaseCamera,'laya.d3.core.BaseCamera',_super);
  36114. var __proto=BaseCamera.prototype;
  36115. /**
  36116. *通过RenderingOrder属性对摄像机机型排序。
  36117. */
  36118. __proto._sortCamerasByRenderingOrder=function(){
  36119. if (this.displayedInStage){
  36120. var cameraPool=this.scene._cameraPool;
  36121. var n=cameraPool.length-1;
  36122. for (var i=0;i < n;i++){
  36123. if (cameraPool[i].renderingOrder > cameraPool[n].renderingOrder){
  36124. var tempCamera=cameraPool[i];
  36125. cameraPool[i]=cameraPool[n];
  36126. cameraPool[n]=tempCamera;
  36127. }
  36128. }
  36129. }
  36130. }
  36131. /**
  36132. *@private
  36133. */
  36134. __proto._calculateProjectionMatrix=function(){}
  36135. /**
  36136. *@private
  36137. */
  36138. __proto._onScreenSizeChanged=function(){
  36139. this._calculateProjectionMatrix();
  36140. }
  36141. /**
  36142. *@private
  36143. */
  36144. __proto._prepareCameraToRender=function(){
  36145. this.transform.getForward(this._forward);
  36146. this.transform.getUp(this._up);
  36147. var cameraSV=this._shaderValues;
  36148. cameraSV.setVector3(laya.d3.core.BaseCamera.CAMERAPOS,this.transform.position);
  36149. cameraSV.setVector3(laya.d3.core.BaseCamera.CAMERADIRECTION,this._forward);
  36150. cameraSV.setVector3(laya.d3.core.BaseCamera.CAMERAUP,this._up);
  36151. }
  36152. /**
  36153. *@private
  36154. */
  36155. __proto._prepareCameraViewProject=function(vieMat,proMat,viewProject,vieProNoTraSca){
  36156. var shaderData=this._shaderValues;
  36157. shaderData.setMatrix4x4(laya.d3.core.BaseCamera.VIEWMATRIX,vieMat);
  36158. shaderData.setMatrix4x4(laya.d3.core.BaseCamera.PROJECTMATRIX,proMat);
  36159. shaderData.setMatrix4x4(laya.d3.core.BaseCamera.VIEWPROJECTMATRIX,viewProject);
  36160. this.transform.worldMatrix.cloneTo(BaseCamera._tempMatrix4x40);
  36161. BaseCamera._tempMatrix4x40.transpose();
  36162. Matrix4x4.multiply(proMat,BaseCamera._tempMatrix4x40,vieProNoTraSca);
  36163. shaderData.setMatrix4x4(laya.d3.core.BaseCamera.VPMATRIX_NO_TRANSLATE,vieProNoTraSca);
  36164. }
  36165. /**
  36166. *相机渲染。
  36167. *@param shader 着色器。
  36168. *@param replacementTag 着色器替换标记。
  36169. */
  36170. __proto.render=function(shader,replacementTag){}
  36171. /**
  36172. *增加可视图层,layer值为0到31层。
  36173. *@param layer 图层。
  36174. */
  36175. __proto.addLayer=function(layer){
  36176. this.cullingMask |=Math.pow(2,layer);
  36177. }
  36178. /**
  36179. *移除可视图层,layer值为0到31层。
  36180. *@param layer 图层。
  36181. */
  36182. __proto.removeLayer=function(layer){
  36183. this.cullingMask &=~Math.pow(2,layer);
  36184. }
  36185. /**
  36186. *增加所有图层。
  36187. */
  36188. __proto.addAllLayers=function(){
  36189. this.cullingMask=2147483647;
  36190. }
  36191. /**
  36192. *移除所有图层。
  36193. */
  36194. __proto.removeAllLayers=function(){
  36195. this.cullingMask=0;
  36196. }
  36197. __proto.resetProjectionMatrix=function(){
  36198. this._useUserProjectionMatrix=false;
  36199. this._calculateProjectionMatrix();
  36200. }
  36201. /**
  36202. *@inheritDoc
  36203. */
  36204. __proto._onActive=function(){
  36205. (this._scene)._addCamera(this);
  36206. laya.display.Node.prototype._onActive.call(this);
  36207. }
  36208. /**
  36209. *@inheritDoc
  36210. */
  36211. __proto._onInActive=function(){
  36212. (this._scene)._removeCamera(this);
  36213. laya.display.Node.prototype._onInActive.call(this);
  36214. }
  36215. /**
  36216. *@inheritDoc
  36217. */
  36218. __proto._parse=function(data,spriteMap){
  36219. _super.prototype._parse.call(this,data,spriteMap);
  36220. var clearFlagData=data.clearFlag;
  36221. (clearFlagData!==undefined)&& (this.clearFlag=clearFlagData);
  36222. this.orthographic=data.orthographic;
  36223. this.fieldOfView=data.fieldOfView;
  36224. this.nearPlane=data.nearPlane;
  36225. this.farPlane=data.farPlane;
  36226. var color=data.clearColor;
  36227. this.clearColor=new Vector4(color[0],color[1],color[2],color[3]);
  36228. var skyboxMaterial=data.skyboxMaterial;
  36229. if (skyboxMaterial){
  36230. this._skyRenderer.material=Loader.getRes(skyboxMaterial.path);
  36231. }
  36232. }
  36233. /**
  36234. *@inheritDoc
  36235. */
  36236. __proto.destroy=function(destroyChild){
  36237. (destroyChild===void 0)&& (destroyChild=true);
  36238. this._skyRenderer.destroy();
  36239. this._skyRenderer=null;
  36240. Laya.stage.off(/*laya.events.Event.RESIZE*/"resize",this,this._onScreenSizeChanged);
  36241. _super.prototype.destroy.call(this,destroyChild);
  36242. }
  36243. __getset(0,__proto,'renderingOrder',function(){
  36244. return this._renderingOrder;
  36245. },function(value){
  36246. this._renderingOrder=value;
  36247. this._sortCamerasByRenderingOrder();
  36248. });
  36249. /**
  36250. *获取天空渲染器。
  36251. *@return 天空渲染器。
  36252. */
  36253. __getset(0,__proto,'skyRenderer',function(){
  36254. return this._skyRenderer;
  36255. });
  36256. /**
  36257. *设置是否正交投影矩阵。
  36258. *@param 是否正交投影矩阵。
  36259. */
  36260. /**
  36261. *获取是否正交投影矩阵。
  36262. *@return 是否正交投影矩阵。
  36263. */
  36264. __getset(0,__proto,'orthographic',function(){
  36265. return this._orthographic;
  36266. },function(vaule){
  36267. this._orthographic=vaule;
  36268. this._calculateProjectionMatrix();
  36269. });
  36270. /**
  36271. *设置视野。
  36272. *@param value 视野。
  36273. */
  36274. /**
  36275. *获取视野。
  36276. *@return 视野。
  36277. */
  36278. __getset(0,__proto,'fieldOfView',function(){
  36279. return this._fieldOfView;
  36280. },function(value){
  36281. this._fieldOfView=value;
  36282. this._calculateProjectionMatrix();
  36283. });
  36284. /**
  36285. *设置近裁面。
  36286. *@param value 近裁面。
  36287. */
  36288. /**
  36289. *获取近裁面。
  36290. *@return 近裁面。
  36291. */
  36292. __getset(0,__proto,'nearPlane',function(){
  36293. return this._nearPlane;
  36294. },function(value){
  36295. this._nearPlane=value;
  36296. this._calculateProjectionMatrix();
  36297. });
  36298. /**
  36299. *设置远裁面。
  36300. *@param value 远裁面。
  36301. */
  36302. /**
  36303. *获取远裁面。
  36304. *@return 远裁面。
  36305. */
  36306. __getset(0,__proto,'farPlane',function(){
  36307. return this._farPlane;
  36308. },function(vaule){
  36309. this._farPlane=vaule;
  36310. this._calculateProjectionMatrix();
  36311. });
  36312. /**
  36313. *设置正交投影垂直矩阵尺寸。
  36314. *@param 正交投影垂直矩阵尺寸。
  36315. */
  36316. /**
  36317. *获取正交投影垂直矩阵尺寸。
  36318. *@return 正交投影垂直矩阵尺寸。
  36319. */
  36320. __getset(0,__proto,'orthographicVerticalSize',function(){
  36321. return this._orthographicVerticalSize;
  36322. },function(vaule){
  36323. this._orthographicVerticalSize=vaule;
  36324. this._calculateProjectionMatrix();
  36325. });
  36326. BaseCamera.RENDERINGTYPE_DEFERREDLIGHTING="DEFERREDLIGHTING";
  36327. BaseCamera.RENDERINGTYPE_FORWARDRENDERING="FORWARDRENDERING";
  36328. BaseCamera.CLEARFLAG_SOLIDCOLOR=0;
  36329. BaseCamera.CLEARFLAG_SKY=1;
  36330. BaseCamera.CLEARFLAG_DEPTHONLY=2;
  36331. BaseCamera.CLEARFLAG_NONE=3;
  36332. __static(BaseCamera,
  36333. ['_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();}
  36334. ]);
  36335. return BaseCamera;
  36336. })(Sprite3D)
  36337. /**
  36338. *<code>Terrain</code> 类用于创建地块。
  36339. */
  36340. //class laya.d3.terrain.Terrain extends laya.d3.core.Sprite3D
  36341. var Terrain=(function(_super){
  36342. function Terrain(terrainRes){
  36343. //地形资源
  36344. this._terrainRes=null;
  36345. this._lightmapScaleOffset=null;
  36346. Terrain.__super.call(this);
  36347. this._lightmapScaleOffset=new Vector4(1,1,0,0);
  36348. if (terrainRes){
  36349. this._terrainRes=terrainRes;
  36350. this.buildTerrain(terrainRes);
  36351. }
  36352. }
  36353. __class(Terrain,'laya.d3.terrain.Terrain',_super);
  36354. var __proto=Terrain.prototype;
  36355. /**
  36356. *@inheritDoc
  36357. */
  36358. __proto._parse=function(data,spriteMap){
  36359. _super.prototype._parse.call(this,data,spriteMap);
  36360. this.terrainRes=Loader.getRes(data.dataPath);
  36361. var lightmapIndex=data.lightmapIndex;
  36362. if (lightmapIndex !=null)
  36363. this.setLightmapIndex(lightmapIndex);
  36364. var lightmapScaleOffsetArray=data.lightmapScaleOffset;
  36365. if (lightmapScaleOffsetArray)
  36366. this.setLightmapScaleOffset(new Vector4(lightmapScaleOffsetArray[0],lightmapScaleOffsetArray[1],lightmapScaleOffsetArray[2],lightmapScaleOffsetArray[3]));
  36367. }
  36368. __proto.setLightmapIndex=function(value){
  36369. for (var i=0;i < this._children.length;i++){
  36370. var terrainChunk=this._children[i];
  36371. terrainChunk.terrainRender.lightmapIndex=value;
  36372. }
  36373. }
  36374. __proto.setLightmapScaleOffset=function(value){
  36375. if (!value)return;
  36376. value.cloneTo(this._lightmapScaleOffset);
  36377. for (var i=0;i < this._children.length;i++){
  36378. var terrainChunk=this._children[i];
  36379. terrainChunk.terrainRender.lightmapScaleOffset=this._lightmapScaleOffset;
  36380. }
  36381. }
  36382. __proto.disableLight=function(){
  36383. for (var i=0,n=this._children.length;i < n;i++){
  36384. var terrainChunk=this._children[i];
  36385. for (var j=0,m=terrainChunk._render.sharedMaterials.length;j < m;j++){
  36386. var terrainMaterial=terrainChunk._render.sharedMaterials [j];
  36387. terrainMaterial.disableLight();
  36388. }
  36389. }
  36390. }
  36391. //建筑地形
  36392. __proto.buildTerrain=function(terrainRes){
  36393. var chunkNumX=terrainRes._chunkNumX;
  36394. var chunkNumZ=terrainRes._chunkNumZ;
  36395. var heightData=terrainRes._heightData;
  36396. var n=0;
  36397. for (var i=0;i < chunkNumZ;i++){
  36398. for (var j=0;j < chunkNumX;j++){
  36399. var terrainChunk=new TerrainChunk(j,i,terrainRes._gridSize,heightData._terrainHeightData,heightData._width,heightData._height,terrainRes._cameraCoordinateInverse);
  36400. var chunkInfo=terrainRes._chunkInfos[n++];
  36401. for (var k=0;k < chunkInfo.alphaMap.length;k++){
  36402. var nNum=chunkInfo.detailID[k].length;
  36403. var sDetialTextureUrl1=(nNum > 0)? terrainRes._detailTextureInfos[chunkInfo.detailID[k][0]].diffuseTexture :null;
  36404. var sDetialTextureUrl2=(nNum > 1)? terrainRes._detailTextureInfos[chunkInfo.detailID[k][1]].diffuseTexture :null;
  36405. var sDetialTextureUrl3=(nNum > 2)? terrainRes._detailTextureInfos[chunkInfo.detailID[k][2]].diffuseTexture :null;
  36406. var sDetialTextureUrl4=(nNum > 3)? terrainRes._detailTextureInfos[chunkInfo.detailID[k][3]].diffuseTexture :null;
  36407. var detialScale1=(nNum > 0)? terrainRes._detailTextureInfos[chunkInfo.detailID[k][0]].scale :null;
  36408. var detialScale2=(nNum > 1)? terrainRes._detailTextureInfos[chunkInfo.detailID[k][1]].scale :null;
  36409. var detialScale3=(nNum > 2)? terrainRes._detailTextureInfos[chunkInfo.detailID[k][2]].scale :null;
  36410. var detialScale4=(nNum > 3)? terrainRes._detailTextureInfos[chunkInfo.detailID[k][3]].scale :null;
  36411. 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);
  36412. }
  36413. terrainChunk.terrainRender.receiveShadow=true;
  36414. terrainChunk.terrainRender.lightmapScaleOffset=this._lightmapScaleOffset;
  36415. this.addChild(terrainChunk);
  36416. }
  36417. }
  36418. }
  36419. /**
  36420. *获取地形X轴长度。
  36421. *@return 地形X轴长度。
  36422. */
  36423. __proto.width=function(){
  36424. return this._terrainRes._chunkNumX *TerrainLeaf.CHUNK_GRID_NUM *this._terrainRes._gridSize;
  36425. }
  36426. /**
  36427. *获取地形Z轴长度。
  36428. *@return 地形Z轴长度。
  36429. */
  36430. __proto.depth=function(){
  36431. return this._terrainRes._chunkNumZ *TerrainLeaf.CHUNK_GRID_NUM *this._terrainRes._gridSize;
  36432. }
  36433. /**
  36434. *获取地形高度。
  36435. *@param x X轴坐标。
  36436. *@param z Z轴坐标。
  36437. */
  36438. __proto.getHeightXZ=function(x,z){
  36439. if (!this._terrainRes)
  36440. return NaN;
  36441. x-=this.transform.position.x;
  36442. z-=this.transform.position.z;
  36443. if (!Terrain.__VECTOR3__){
  36444. Terrain.__VECTOR3__=new Vector3();
  36445. }
  36446. Terrain.__VECTOR3__.x=x;
  36447. Terrain.__VECTOR3__.y=0;
  36448. Terrain.__VECTOR3__.z=z;
  36449. Vector3.transformV3ToV3(Terrain.__VECTOR3__,TerrainLeaf.__ADAPT_MATRIX_INV__,Terrain.__VECTOR3__);
  36450. x=Terrain.__VECTOR3__.x;
  36451. z=Terrain.__VECTOR3__.z;
  36452. if (x < 0 || x > this.width()|| z < 0 || z > this.depth())
  36453. return NaN;
  36454. var gridSize=this._terrainRes._gridSize;
  36455. var nIndexX=parseInt(""+x / gridSize);
  36456. var nIndexZ=parseInt(""+z / gridSize);
  36457. var offsetX=x-nIndexX *gridSize;
  36458. var offsetZ=z-nIndexZ *gridSize;
  36459. var h1=NaN;
  36460. var h2=NaN;
  36461. var h3=NaN;
  36462. var u=NaN;
  36463. var v=NaN;
  36464. var heightData=this._terrainRes._heightData;
  36465. if (offsetX+offsetZ > gridSize){
  36466. h1=heightData._terrainHeightData[(nIndexZ+1-1)*heightData._width+nIndexX+1];
  36467. h2=heightData._terrainHeightData[(nIndexZ+1-1)*heightData._width+nIndexX];
  36468. h3=heightData._terrainHeightData[(nIndexZ-1)*heightData._width+nIndexX+1];
  36469. u=(gridSize-offsetX)/ gridSize;
  36470. v=(gridSize-offsetZ)/ gridSize;
  36471. return h1+(h2-h1)*u+(h3-h1)*v;
  36472. }else {
  36473. h1=heightData._terrainHeightData[Math.max(0.0,nIndexZ-1)*heightData._width+nIndexX];
  36474. h2=heightData._terrainHeightData[Math.min(heightData._width *heightData._height-1,(nIndexZ+1-1)*heightData._width+nIndexX)];
  36475. h3=heightData._terrainHeightData[Math.min(heightData._width *heightData._height-1,Math.max(0.0,nIndexZ-1)*heightData._width+nIndexX+1)];
  36476. u=offsetX / gridSize;
  36477. v=offsetZ / gridSize;
  36478. return h1+(h2-h1)*v+(h3-h1)*u;
  36479. }
  36480. }
  36481. __getset(0,__proto,'terrainRes',null,function(value){
  36482. if (value){
  36483. this._terrainRes=value;
  36484. this.buildTerrain(value);
  36485. }
  36486. });
  36487. Terrain.load=function(url){
  36488. Laya.loader.create(url,null,null,/*Laya3D.TERRAINRES*/"TERRAIN",null,null,1,false);
  36489. }
  36490. Terrain.RENDER_LINE_MODEL=false;
  36491. Terrain.LOD_TOLERANCE_VALUE=4;
  36492. Terrain.LOD_DISTANCE_FACTOR=2.0;
  36493. Terrain.__VECTOR3__=null;
  36494. return Terrain;
  36495. })(Sprite3D)
  36496. /**
  36497. *<code>SkyProceduralMaterial</code> 类用于实现SkyProceduralMaterial材质。
  36498. */
  36499. //class laya.d3.core.material.SkyProceduralMaterial extends laya.d3.core.material.BaseMaterial
  36500. var SkyProceduralMaterial=(function(_super){
  36501. function SkyProceduralMaterial(){
  36502. /**@private */
  36503. this._sunDisk=0;
  36504. SkyProceduralMaterial.__super.call(this);
  36505. this.setShaderName("SkyBoxProcedural");
  36506. this.sunDisk=1;
  36507. this.sunSize=0.04;
  36508. this.sunSizeConvergence=5;
  36509. this.atmosphereThickness=1.0;
  36510. this.skyTint=new Vector4(0.5,0.5,0.5,1.0);
  36511. this.groundTint=new Vector4(0.369,0.349,0.341,1.0);
  36512. this.exposure=1.3;
  36513. }
  36514. __class(SkyProceduralMaterial,'laya.d3.core.material.SkyProceduralMaterial',_super);
  36515. var __proto=SkyProceduralMaterial.prototype;
  36516. /**
  36517. *设置曝光强度,范围是0到8。
  36518. *@param value 曝光强度。
  36519. */
  36520. /**
  36521. *获取曝光强度,范围是0到8。
  36522. *@return 曝光强度。
  36523. */
  36524. __getset(0,__proto,'exposure',function(){
  36525. return this._shaderValues.getNumber(SkyProceduralMaterial.EXPOSURE);
  36526. },function(value){
  36527. value=Math.min(Math.max(0.0,value),8.0);
  36528. this._shaderValues.setNumber(SkyProceduralMaterial.EXPOSURE,value);
  36529. });
  36530. /**
  36531. *设置太阳尺寸,范围是0到1。
  36532. *@param value 太阳尺寸。
  36533. */
  36534. /**
  36535. *获取太阳尺寸,范围是0到1。
  36536. *@return 太阳尺寸。
  36537. */
  36538. __getset(0,__proto,'sunSize',function(){
  36539. return this._shaderValues.getNumber(SkyProceduralMaterial.SUNSIZE);
  36540. },function(value){
  36541. value=Math.min(Math.max(0.0,value),1.0);
  36542. this._shaderValues.setNumber(SkyProceduralMaterial.SUNSIZE,value);
  36543. });
  36544. /**
  36545. *设置太阳状态。
  36546. *@param value 太阳状态。
  36547. */
  36548. /**
  36549. *获取太阳状态。
  36550. *@return 太阳状态。
  36551. */
  36552. __getset(0,__proto,'sunDisk',function(){
  36553. return this._sunDisk;
  36554. },function(value){
  36555. switch (value){
  36556. case 1:
  36557. this._defineDatas.remove(SkyProceduralMaterial.SHADERDEFINE_SUN_SIMPLE);
  36558. this._defineDatas.add(SkyProceduralMaterial.SHADERDEFINE_SUN_HIGH_QUALITY);
  36559. break ;
  36560. case 2:
  36561. this._defineDatas.remove(SkyProceduralMaterial.SHADERDEFINE_SUN_HIGH_QUALITY);
  36562. this._defineDatas.add(SkyProceduralMaterial.SHADERDEFINE_SUN_SIMPLE);
  36563. break ;
  36564. case 0:
  36565. this._defineDatas.remove(SkyProceduralMaterial.SHADERDEFINE_SUN_HIGH_QUALITY);
  36566. this._defineDatas.remove(SkyProceduralMaterial.SHADERDEFINE_SUN_SIMPLE);
  36567. break ;
  36568. default :
  36569. throw "SkyBoxProceduralMaterial: unknown sun value.";
  36570. }
  36571. this._sunDisk=value;
  36572. });
  36573. /**
  36574. *设置太阳尺寸收缩,范围是0到20。
  36575. *@param value 太阳尺寸收缩。
  36576. */
  36577. /**
  36578. *获取太阳尺寸收缩,范围是0到20。
  36579. *@return 太阳尺寸收缩。
  36580. */
  36581. __getset(0,__proto,'sunSizeConvergence',function(){
  36582. return this._shaderValues.getNumber(SkyProceduralMaterial.SUNSIZECONVERGENCE);
  36583. },function(value){
  36584. value=Math.min(Math.max(0.0,value),20.0);
  36585. this._shaderValues.setNumber(SkyProceduralMaterial.SUNSIZECONVERGENCE,value);
  36586. });
  36587. /**
  36588. *设置大气厚度,范围是0到5。
  36589. *@param value 大气厚度。
  36590. */
  36591. /**
  36592. *获取大气厚度,范围是0到5。
  36593. *@return 大气厚度。
  36594. */
  36595. __getset(0,__proto,'atmosphereThickness',function(){
  36596. return this._shaderValues.getNumber(SkyProceduralMaterial.ATMOSPHERETHICKNESS);
  36597. },function(value){
  36598. value=Math.min(Math.max(0.0,value),5.0);
  36599. this._shaderValues.setNumber(SkyProceduralMaterial.ATMOSPHERETHICKNESS,value);
  36600. });
  36601. /**
  36602. *设置地面颜色。
  36603. *@param value 地面颜色。
  36604. */
  36605. /**
  36606. *获取地面颜色。
  36607. *@return 地面颜色。
  36608. */
  36609. __getset(0,__proto,'groundTint',function(){
  36610. return this._shaderValues.getVector(SkyProceduralMaterial.GROUNDTINT);
  36611. },function(value){
  36612. this._shaderValues.setVector(SkyProceduralMaterial.GROUNDTINT,value);
  36613. });
  36614. /**
  36615. *设置天空颜色。
  36616. *@param value 天空颜色。
  36617. */
  36618. /**
  36619. *获取天空颜色。
  36620. *@return 天空颜色。
  36621. */
  36622. __getset(0,__proto,'skyTint',function(){
  36623. return this._shaderValues.getVector(SkyProceduralMaterial.SKYTINT);
  36624. },function(value){
  36625. this._shaderValues.setVector(SkyProceduralMaterial.SKYTINT,value);
  36626. });
  36627. SkyProceduralMaterial.__init__=function(){
  36628. SkyProceduralMaterial.SHADERDEFINE_SUN_HIGH_QUALITY=SkyProceduralMaterial.shaderDefines.registerDefine("SUN_HIGH_QUALITY");
  36629. SkyProceduralMaterial.SHADERDEFINE_SUN_SIMPLE=SkyProceduralMaterial.shaderDefines.registerDefine("SUN_SIMPLE");
  36630. }
  36631. SkyProceduralMaterial.SUN_NODE=0;
  36632. SkyProceduralMaterial.SUN_HIGH_QUALITY=1;
  36633. SkyProceduralMaterial.SUN_SIMPLE=2;
  36634. SkyProceduralMaterial.SHADERDEFINE_SUN_HIGH_QUALITY=0;
  36635. SkyProceduralMaterial.SHADERDEFINE_SUN_SIMPLE=0;
  36636. __static(SkyProceduralMaterial,
  36637. ['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);}
  36638. ]);
  36639. return SkyProceduralMaterial;
  36640. })(BaseMaterial)
  36641. /**
  36642. *<code>ShurikenParticleMaterial</code> 类用于实现粒子材质。
  36643. */
  36644. //class laya.d3.core.particleShuriKen.ShurikenParticleMaterial extends laya.d3.core.material.BaseMaterial
  36645. var ShurikenParticleMaterial=(function(_super){
  36646. function ShurikenParticleMaterial(){
  36647. /**@private */
  36648. //this._color=null;
  36649. ShurikenParticleMaterial.__super.call(this);
  36650. this.setShaderName("PARTICLESHURIKEN");
  36651. this._color=new Vector4(1.0,1.0,1.0,1.0);
  36652. this.renderMode=0;
  36653. }
  36654. __class(ShurikenParticleMaterial,'laya.d3.core.particleShuriKen.ShurikenParticleMaterial',_super);
  36655. var __proto=ShurikenParticleMaterial.prototype;
  36656. /**
  36657. *@private
  36658. */
  36659. /**
  36660. *@private
  36661. */
  36662. __getset(0,__proto,'_TintColorB',function(){
  36663. return this._color.z;
  36664. },function(value){
  36665. this._color.z=value;
  36666. this.color=this._color;
  36667. });
  36668. /**
  36669. *@private
  36670. */
  36671. /**
  36672. *@private
  36673. */
  36674. __getset(0,__proto,'_MainTex_STZ',function(){
  36675. return this._shaderValues.getVector(ShurikenParticleMaterial.TILINGOFFSET).z;
  36676. },function(z){
  36677. var tilOff=this._shaderValues.getVector(ShurikenParticleMaterial.TILINGOFFSET);
  36678. tilOff.z=z;
  36679. this.tilingOffset=tilOff;
  36680. });
  36681. /**
  36682. *设置漫反射贴图。
  36683. *@param value 漫反射贴图。
  36684. */
  36685. /**
  36686. *获取漫反射贴图。
  36687. *@return 漫反射贴图。
  36688. */
  36689. __getset(0,__proto,'texture',function(){
  36690. return this._shaderValues.getTexture(ShurikenParticleMaterial.DIFFUSETEXTURE);
  36691. },function(value){
  36692. if (value)
  36693. this._defineDatas.add(laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SHADERDEFINE_DIFFUSEMAP);
  36694. else
  36695. this._defineDatas.remove(laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SHADERDEFINE_DIFFUSEMAP);
  36696. this._shaderValues.setTexture(ShurikenParticleMaterial.DIFFUSETEXTURE,value);
  36697. });
  36698. /**
  36699. *@private
  36700. */
  36701. /**
  36702. *@private
  36703. */
  36704. __getset(0,__proto,'_TintColorR',function(){
  36705. return this._color.x;
  36706. },function(value){
  36707. this._color.x=value;
  36708. this.color=this._color;
  36709. });
  36710. /**
  36711. *@private
  36712. */
  36713. /**
  36714. *@private
  36715. */
  36716. __getset(0,__proto,'_MainTex_STW',function(){
  36717. return this._shaderValues.getVector(ShurikenParticleMaterial.TILINGOFFSET).w;
  36718. },function(w){
  36719. var tilOff=this._shaderValues.getVector(ShurikenParticleMaterial.TILINGOFFSET);
  36720. tilOff.w=w;
  36721. this.tilingOffset=tilOff;
  36722. });
  36723. /**
  36724. *@private
  36725. */
  36726. /**
  36727. *@private
  36728. */
  36729. __getset(0,__proto,'_TintColorG',function(){
  36730. return this._color.y;
  36731. },function(value){
  36732. this._color.y=value;
  36733. this.color=this._color;
  36734. });
  36735. /**
  36736. *@private
  36737. */
  36738. /**@private */
  36739. __getset(0,__proto,'_TintColorA',function(){
  36740. return this._color.w;
  36741. },function(value){
  36742. this._color.w=value;
  36743. this.color=this._color;
  36744. });
  36745. /**
  36746. *@private
  36747. */
  36748. /**
  36749. *@private
  36750. */
  36751. __getset(0,__proto,'_MainTex_STY',function(){
  36752. return this._shaderValues.getVector(ShurikenParticleMaterial.TILINGOFFSET).y;
  36753. },function(y){
  36754. var tilOff=this._shaderValues.getVector(ShurikenParticleMaterial.TILINGOFFSET);
  36755. tilOff.y=y;
  36756. this.tilingOffset=tilOff;
  36757. });
  36758. /**
  36759. *设置渲染模式。
  36760. *@return 渲染模式。
  36761. */
  36762. __getset(0,__proto,'renderMode',null,function(value){
  36763. switch (value){
  36764. case 1:
  36765. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_TRANSPARENT*/3000;
  36766. this.depthWrite=false;
  36767. this.cull=/*laya.d3.core.material.RenderState.CULL_NONE*/0;
  36768. this.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  36769. this.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_SRC_ALPHA*/0x0302;
  36770. this.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE*/1;
  36771. this.alphaTest=false;
  36772. this._defineDatas.add(ShurikenParticleMaterial.SHADERDEFINE_ADDTIVEFOG);
  36773. break ;
  36774. case 0:
  36775. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_TRANSPARENT*/3000;
  36776. this.depthWrite=false;
  36777. this.cull=/*laya.d3.core.material.RenderState.CULL_NONE*/0;
  36778. this.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  36779. this.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_SRC_ALPHA*/0x0302;
  36780. this.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA*/0x0303;
  36781. this.alphaTest=false;
  36782. this._defineDatas.remove(ShurikenParticleMaterial.SHADERDEFINE_ADDTIVEFOG);
  36783. break ;
  36784. default :
  36785. throw new Error("ShurikenParticleMaterial : renderMode value error.");
  36786. }
  36787. });
  36788. /**
  36789. *@private
  36790. */
  36791. /**
  36792. *@private
  36793. */
  36794. __getset(0,__proto,'_MainTex_STX',function(){
  36795. return this._shaderValues.getVector(ShurikenParticleMaterial.TILINGOFFSET).x;
  36796. },function(x){
  36797. var tilOff=this._shaderValues.getVector(ShurikenParticleMaterial.TILINGOFFSET);
  36798. tilOff.x=x;
  36799. this.tilingOffset=tilOff;
  36800. });
  36801. /**
  36802. *设置颜色R分量。
  36803. *@param value 颜色R分量。
  36804. */
  36805. /**
  36806. *获取颜色R分量。
  36807. *@return 颜色R分量。
  36808. */
  36809. __getset(0,__proto,'colorR',function(){
  36810. return this._TintColorR;
  36811. },function(value){
  36812. this._TintColorR=value;
  36813. });
  36814. /**
  36815. *设置颜色G分量。
  36816. *@param value 颜色G分量。
  36817. */
  36818. /**
  36819. *获取颜色G分量。
  36820. *@return 颜色G分量。
  36821. */
  36822. __getset(0,__proto,'colorG',function(){
  36823. return this._TintColorG;
  36824. },function(value){
  36825. this._TintColorG=value;
  36826. });
  36827. /**
  36828. *设置颜色B分量。
  36829. *@param value 颜色B分量。
  36830. */
  36831. /**
  36832. *获取颜色B分量。
  36833. *@return 颜色B分量。
  36834. */
  36835. __getset(0,__proto,'colorB',function(){
  36836. return this._TintColorB;
  36837. },function(value){
  36838. this._TintColorB=value;
  36839. });
  36840. /**
  36841. *设置颜色alpha分量。
  36842. *@param value 颜色alpha分量。
  36843. */
  36844. /**
  36845. *获取颜色Z分量。
  36846. *@return 颜色Z分量。
  36847. */
  36848. __getset(0,__proto,'colorA',function(){
  36849. return this._TintColorA;
  36850. },function(value){
  36851. this._TintColorA=value;
  36852. });
  36853. /**
  36854. *设置混合方式。
  36855. *@param value 混合方式。
  36856. */
  36857. /**
  36858. *获取混合方式。
  36859. *@return 混合方式。
  36860. */
  36861. __getset(0,__proto,'blend',function(){
  36862. return this._shaderValues.getInt(ShurikenParticleMaterial.BLEND);
  36863. },function(value){
  36864. this._shaderValues.setInt(ShurikenParticleMaterial.BLEND,value);
  36865. });
  36866. /**
  36867. *设置颜色。
  36868. *@param value 颜色。
  36869. */
  36870. /**
  36871. *获取颜色。
  36872. *@return 颜色。
  36873. */
  36874. __getset(0,__proto,'color',function(){
  36875. return this._shaderValues.getVector(ShurikenParticleMaterial.TINTCOLOR);
  36876. },function(value){
  36877. if (value)
  36878. this._defineDatas.add(laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SHADERDEFINE_TINTCOLOR);
  36879. else
  36880. this._defineDatas.remove(laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SHADERDEFINE_TINTCOLOR);
  36881. this._shaderValues.setVector(ShurikenParticleMaterial.TINTCOLOR,value);
  36882. });
  36883. /**
  36884. *获取纹理平铺和偏移X分量。
  36885. *@param x 纹理平铺和偏移X分量。
  36886. */
  36887. /**
  36888. *获取纹理平铺和偏移X分量。
  36889. *@return 纹理平铺和偏移X分量。
  36890. */
  36891. __getset(0,__proto,'tilingOffsetX',function(){
  36892. return this._MainTex_STX;
  36893. },function(x){
  36894. this._MainTex_STX=x;
  36895. });
  36896. /**
  36897. *获取纹理平铺和偏移Y分量。
  36898. *@param y 纹理平铺和偏移Y分量。
  36899. */
  36900. /**
  36901. *获取纹理平铺和偏移Y分量。
  36902. *@return 纹理平铺和偏移Y分量。
  36903. */
  36904. __getset(0,__proto,'tilingOffsetY',function(){
  36905. return this._MainTex_STY;
  36906. },function(y){
  36907. this._MainTex_STY=y;
  36908. });
  36909. /**
  36910. *获取纹理平铺和偏移Z分量。
  36911. *@param z 纹理平铺和偏移Z分量。
  36912. */
  36913. /**
  36914. *获取纹理平铺和偏移Z分量。
  36915. *@return 纹理平铺和偏移Z分量。
  36916. */
  36917. __getset(0,__proto,'tilingOffsetZ',function(){
  36918. return this._MainTex_STZ;
  36919. },function(z){
  36920. this._MainTex_STZ=z;
  36921. });
  36922. /**
  36923. *设置混合源。
  36924. *@param value 混合源
  36925. */
  36926. /**
  36927. *获取混合源。
  36928. *@return 混合源。
  36929. */
  36930. __getset(0,__proto,'blendSrc',function(){
  36931. return this._shaderValues.getInt(ShurikenParticleMaterial.BLEND_SRC);
  36932. },function(value){
  36933. this._shaderValues.setInt(ShurikenParticleMaterial.BLEND_SRC,value);
  36934. });
  36935. /**
  36936. *获取纹理平铺和偏移W分量。
  36937. *@param w 纹理平铺和偏移W分量。
  36938. */
  36939. /**
  36940. *获取纹理平铺和偏移W分量。
  36941. *@return 纹理平铺和偏移W分量。
  36942. */
  36943. __getset(0,__proto,'tilingOffsetW',function(){
  36944. return this._MainTex_STW;
  36945. },function(w){
  36946. this._MainTex_STW=w;
  36947. });
  36948. /**
  36949. *获取纹理平铺和偏移。
  36950. *@param value 纹理平铺和偏移。
  36951. */
  36952. /**
  36953. *获取纹理平铺和偏移。
  36954. *@return 纹理平铺和偏移。
  36955. */
  36956. __getset(0,__proto,'tilingOffset',function(){
  36957. return this._shaderValues.getVector(ShurikenParticleMaterial.TILINGOFFSET);
  36958. },function(value){
  36959. if (value){
  36960. if (value.x !=1 || value.y !=1 || value.z !=0 || value.w !=0)
  36961. this._defineDatas.add(laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SHADERDEFINE_TILINGOFFSET);
  36962. else
  36963. this._defineDatas.remove(laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SHADERDEFINE_TILINGOFFSET);
  36964. }else {
  36965. this._defineDatas.remove(laya.d3.core.particleShuriKen.ShurikenParticleMaterial.SHADERDEFINE_TILINGOFFSET);
  36966. }
  36967. this._shaderValues.setVector(ShurikenParticleMaterial.TILINGOFFSET,value);
  36968. });
  36969. /**
  36970. *设置是否写入深度。
  36971. *@param value 是否写入深度。
  36972. */
  36973. /**
  36974. *获取是否写入深度。
  36975. *@return 是否写入深度。
  36976. */
  36977. __getset(0,__proto,'depthWrite',function(){
  36978. return this._shaderValues.getBool(ShurikenParticleMaterial.DEPTH_WRITE);
  36979. },function(value){
  36980. this._shaderValues.setBool(ShurikenParticleMaterial.DEPTH_WRITE,value);
  36981. });
  36982. /**
  36983. *设置剔除方式。
  36984. *@param value 剔除方式。
  36985. */
  36986. /**
  36987. *获取剔除方式。
  36988. *@return 剔除方式。
  36989. */
  36990. __getset(0,__proto,'cull',function(){
  36991. return this._shaderValues.getInt(ShurikenParticleMaterial.CULL);
  36992. },function(value){
  36993. this._shaderValues.setInt(ShurikenParticleMaterial.CULL,value);
  36994. });
  36995. /**
  36996. *设置混合目标。
  36997. *@param value 混合目标
  36998. */
  36999. /**
  37000. *获取混合目标。
  37001. *@return 混合目标。
  37002. */
  37003. __getset(0,__proto,'blendDst',function(){
  37004. return this._shaderValues.getInt(ShurikenParticleMaterial.BLEND_DST);
  37005. },function(value){
  37006. this._shaderValues.setInt(ShurikenParticleMaterial.BLEND_DST,value);
  37007. });
  37008. /**
  37009. *设置深度测试方式。
  37010. *@param value 深度测试方式
  37011. */
  37012. /**
  37013. *获取深度测试方式。
  37014. *@return 深度测试方式。
  37015. */
  37016. __getset(0,__proto,'depthTest',function(){
  37017. return this._shaderValues.getInt(ShurikenParticleMaterial.DEPTH_TEST);
  37018. },function(value){
  37019. this._shaderValues.setInt(ShurikenParticleMaterial.DEPTH_TEST,value);
  37020. });
  37021. ShurikenParticleMaterial.__init__=function(){
  37022. ShurikenParticleMaterial.SHADERDEFINE_DIFFUSEMAP=ShurikenParticleMaterial.shaderDefines.registerDefine("DIFFUSEMAP");
  37023. ShurikenParticleMaterial.SHADERDEFINE_TINTCOLOR=ShurikenParticleMaterial.shaderDefines.registerDefine("TINTCOLOR");
  37024. ShurikenParticleMaterial.SHADERDEFINE_ADDTIVEFOG=ShurikenParticleMaterial.shaderDefines.registerDefine("ADDTIVEFOG");
  37025. ShurikenParticleMaterial.SHADERDEFINE_TILINGOFFSET=ShurikenParticleMaterial.shaderDefines.registerDefine("TILINGOFFSET");
  37026. }
  37027. ShurikenParticleMaterial.RENDERMODE_ALPHABLENDED=0;
  37028. ShurikenParticleMaterial.RENDERMODE_ADDTIVE=1;
  37029. ShurikenParticleMaterial.SHADERDEFINE_DIFFUSEMAP=0;
  37030. ShurikenParticleMaterial.SHADERDEFINE_TINTCOLOR=0;
  37031. ShurikenParticleMaterial.SHADERDEFINE_TILINGOFFSET=0;
  37032. ShurikenParticleMaterial.SHADERDEFINE_ADDTIVEFOG=0;
  37033. __static(ShurikenParticleMaterial,
  37034. ['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);}
  37035. ]);
  37036. return ShurikenParticleMaterial;
  37037. })(BaseMaterial)
  37038. /**
  37039. *...
  37040. *@author ...
  37041. */
  37042. //class laya.d3.core.material.TerrainMaterial extends laya.d3.core.material.BaseMaterial
  37043. var TerrainMaterial=(function(_super){
  37044. function TerrainMaterial(){
  37045. this._diffuseScale1=null;
  37046. this._diffuseScale2=null;
  37047. this._diffuseScale3=null;
  37048. this._diffuseScale4=null;
  37049. TerrainMaterial.__super.call(this);
  37050. this.setShaderName("Terrain");
  37051. this.renderMode=1;
  37052. this._diffuseScale1=new Vector2();
  37053. this._diffuseScale2=new Vector2();
  37054. this._diffuseScale3=new Vector2();
  37055. this._diffuseScale4=new Vector2();
  37056. this.ambientColor=new Vector3(0.6,0.6,0.6);
  37057. this.diffuseColor=new Vector3(1.0,1.0,1.0);
  37058. this.specularColor=new Vector4(0.2,0.2,0.2,32.0);
  37059. }
  37060. __class(TerrainMaterial,'laya.d3.core.material.TerrainMaterial',_super);
  37061. var __proto=TerrainMaterial.prototype;
  37062. __proto.setDiffuseScale1=function(x,y){
  37063. this._diffuseScale1.x=x;
  37064. this._diffuseScale1.y=y;
  37065. this._shaderValues.setVector2(6,this._diffuseScale1);
  37066. }
  37067. __proto.setDiffuseScale2=function(x,y){
  37068. this._diffuseScale2.x=x;
  37069. this._diffuseScale2.y=y;
  37070. this._shaderValues.setVector2(7,this._diffuseScale2);
  37071. }
  37072. __proto.setDiffuseScale3=function(x,y){
  37073. this._diffuseScale3.x=x;
  37074. this._diffuseScale3.y=y;
  37075. this._shaderValues.setVector2(8,this._diffuseScale3);
  37076. }
  37077. __proto.setDiffuseScale4=function(x,y){
  37078. this._diffuseScale4.x=x;
  37079. this._diffuseScale4.y=y;
  37080. this._shaderValues.setVector2(9,this._diffuseScale4);
  37081. }
  37082. __proto.setDetailNum=function(value){
  37083. switch (value){
  37084. case 1:
  37085. this._defineDatas.add(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM1);
  37086. this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM2);
  37087. this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM3);
  37088. this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM4);
  37089. break ;
  37090. case 2:
  37091. this._defineDatas.add(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM2);
  37092. this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM1);
  37093. this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM3);
  37094. this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM4);
  37095. break ;
  37096. case 3:
  37097. this._defineDatas.add(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM3);
  37098. this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM1);
  37099. this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM2);
  37100. this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM4);
  37101. break ;
  37102. case 4:
  37103. this._defineDatas.add(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM4);
  37104. this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM1);
  37105. this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM2);
  37106. this._defineDatas.remove(laya.d3.core.material.TerrainMaterial.SHADERDEFINE_DETAIL_NUM3);
  37107. break ;
  37108. }
  37109. }
  37110. __proto.disableLight=function(){
  37111. this._disablePublicDefineDatas.add(Scene3D.SHADERDEFINE_POINTLIGHT | Scene3D.SHADERDEFINE_SPOTLIGHT | Scene3D.SHADERDEFINE_DIRECTIONLIGHT);
  37112. }
  37113. /**
  37114. *@inheritDoc
  37115. */
  37116. __proto.setShaderName=function(name){
  37117. _super.prototype.setShaderName.call(this,name);
  37118. }
  37119. /**
  37120. *设置渲染模式。
  37121. *@return 渲染模式。
  37122. */
  37123. __getset(0,__proto,'renderMode',null,function(value){
  37124. switch (value){
  37125. case 1:
  37126. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_OPAQUE*/2000;
  37127. this.depthWrite=true;
  37128. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  37129. this.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  37130. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  37131. break ;
  37132. case 2:
  37133. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_OPAQUE*/2000;
  37134. this.depthWrite=false;
  37135. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  37136. this.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  37137. this.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_SRC_ALPHA*/0x0302;
  37138. this.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA*/0x0303;
  37139. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LEQUAL*/0x0203;
  37140. break ;
  37141. default :
  37142. throw new Error("TerrainMaterial:renderMode value error.");
  37143. }
  37144. });
  37145. /**
  37146. *设置第二层贴图。
  37147. *@param value 第二层贴图。
  37148. */
  37149. /**
  37150. *获取第二层贴图。
  37151. *@return 第二层贴图。
  37152. */
  37153. __getset(0,__proto,'diffuseTexture2',function(){
  37154. return this._shaderValues.getTexture(3);
  37155. },function(value){
  37156. this._shaderValues.setTexture(3,value);
  37157. });
  37158. __getset(0,__proto,'ambientColor',function(){
  37159. return this._shaderValues.getVector(10);
  37160. },function(value){
  37161. this._shaderValues.setVector3(10,value);
  37162. });
  37163. /**
  37164. *设置第四层贴图。
  37165. *@param value 第四层贴图。
  37166. */
  37167. /**
  37168. *获取第四层贴图。
  37169. *@return 第四层贴图。
  37170. */
  37171. __getset(0,__proto,'diffuseTexture4',function(){
  37172. return this._shaderValues.getTexture(5);
  37173. },function(value){
  37174. this._shaderValues.setTexture(5,value);
  37175. });
  37176. __getset(0,__proto,'diffuseColor',function(){
  37177. return this._shaderValues.getVector(11);
  37178. },function(value){
  37179. this._shaderValues.setVector3(11,value);
  37180. });
  37181. /**
  37182. *设置第一层贴图。
  37183. *@param value 第一层贴图。
  37184. */
  37185. /**
  37186. *获取第一层贴图。
  37187. *@return 第一层贴图。
  37188. */
  37189. __getset(0,__proto,'diffuseTexture1',function(){
  37190. return this._shaderValues.getTexture(2);
  37191. },function(value){
  37192. this._shaderValues.setTexture(2,value);
  37193. });
  37194. __getset(0,__proto,'specularColor',function(){
  37195. return this._shaderValues.getVector(12);
  37196. },function(value){
  37197. this._shaderValues.setVector(12,value);
  37198. });
  37199. /**
  37200. *设置第三层贴图。
  37201. *@param value 第三层贴图。
  37202. */
  37203. /**
  37204. *获取第三层贴图。
  37205. *@return 第三层贴图。
  37206. */
  37207. __getset(0,__proto,'diffuseTexture3',function(){
  37208. return this._shaderValues.getTexture(4);
  37209. },function(value){
  37210. this._shaderValues.setTexture(4,value);
  37211. });
  37212. /**
  37213. *设置splatAlpha贴图。
  37214. *@param value splatAlpha贴图。
  37215. */
  37216. /**
  37217. *获取splatAlpha贴图。
  37218. *@return splatAlpha贴图。
  37219. */
  37220. __getset(0,__proto,'splatAlphaTexture',function(){
  37221. return this._shaderValues.getTexture(0);
  37222. },function(value){
  37223. this._shaderValues.setTexture(0,value);
  37224. });
  37225. /**
  37226. *设置剔除方式。
  37227. *@param value 剔除方式。
  37228. */
  37229. /**
  37230. *获取剔除方式。
  37231. *@return 剔除方式。
  37232. */
  37233. __getset(0,__proto,'cull',function(){
  37234. return this._shaderValues.getInt(TerrainMaterial.CULL);
  37235. },function(value){
  37236. this._shaderValues.setInt(TerrainMaterial.CULL,value);
  37237. });
  37238. __getset(0,__proto,'normalTexture',function(){
  37239. return this._shaderValues.getTexture(1);
  37240. },function(value){
  37241. this._shaderValues.setTexture(1,value);
  37242. });
  37243. /**
  37244. *设置是否写入深度。
  37245. *@param value 是否写入深度。
  37246. */
  37247. /**
  37248. *获取是否写入深度。
  37249. *@return 是否写入深度。
  37250. */
  37251. __getset(0,__proto,'depthWrite',function(){
  37252. return this._shaderValues.getBool(TerrainMaterial.DEPTH_WRITE);
  37253. },function(value){
  37254. this._shaderValues.setBool(TerrainMaterial.DEPTH_WRITE,value);
  37255. });
  37256. /**
  37257. *设置混合方式。
  37258. *@param value 混合方式。
  37259. */
  37260. /**
  37261. *获取混合方式。
  37262. *@return 混合方式。
  37263. */
  37264. __getset(0,__proto,'blend',function(){
  37265. return this._shaderValues.getInt(TerrainMaterial.BLEND);
  37266. },function(value){
  37267. this._shaderValues.setInt(TerrainMaterial.BLEND,value);
  37268. });
  37269. /**
  37270. *设置混合源。
  37271. *@param value 混合源
  37272. */
  37273. /**
  37274. *获取混合源。
  37275. *@return 混合源。
  37276. */
  37277. __getset(0,__proto,'blendSrc',function(){
  37278. return this._shaderValues.getInt(TerrainMaterial.BLEND_SRC);
  37279. },function(value){
  37280. this._shaderValues.setInt(TerrainMaterial.BLEND_SRC,value);
  37281. });
  37282. /**
  37283. *设置混合目标。
  37284. *@param value 混合目标
  37285. */
  37286. /**
  37287. *获取混合目标。
  37288. *@return 混合目标。
  37289. */
  37290. __getset(0,__proto,'blendDst',function(){
  37291. return this._shaderValues.getInt(TerrainMaterial.BLEND_DST);
  37292. },function(value){
  37293. this._shaderValues.setInt(TerrainMaterial.BLEND_DST,value);
  37294. });
  37295. /**
  37296. *设置深度测试方式。
  37297. *@param value 深度测试方式
  37298. */
  37299. /**
  37300. *获取深度测试方式。
  37301. *@return 深度测试方式。
  37302. */
  37303. __getset(0,__proto,'depthTest',function(){
  37304. return this._shaderValues.getInt(TerrainMaterial.DEPTH_TEST);
  37305. },function(value){
  37306. this._shaderValues.setInt(TerrainMaterial.DEPTH_TEST,value);
  37307. });
  37308. TerrainMaterial.__init__=function(){
  37309. TerrainMaterial.SHADERDEFINE_DETAIL_NUM1=TerrainMaterial.shaderDefines.registerDefine("DETAIL_NUM1");
  37310. TerrainMaterial.SHADERDEFINE_DETAIL_NUM2=TerrainMaterial.shaderDefines.registerDefine("DETAIL_NUM2");
  37311. TerrainMaterial.SHADERDEFINE_DETAIL_NUM4=TerrainMaterial.shaderDefines.registerDefine("DETAIL_NUM4");
  37312. TerrainMaterial.SHADERDEFINE_DETAIL_NUM3=TerrainMaterial.shaderDefines.registerDefine("DETAIL_NUM3");
  37313. }
  37314. TerrainMaterial.RENDERMODE_OPAQUE=1;
  37315. TerrainMaterial.RENDERMODE_TRANSPARENT=2;
  37316. TerrainMaterial.SPLATALPHATEXTURE=0;
  37317. TerrainMaterial.NORMALTEXTURE=1;
  37318. TerrainMaterial.DIFFUSETEXTURE1=2;
  37319. TerrainMaterial.DIFFUSETEXTURE2=3;
  37320. TerrainMaterial.DIFFUSETEXTURE3=4;
  37321. TerrainMaterial.DIFFUSETEXTURE4=5;
  37322. TerrainMaterial.DIFFUSESCALE1=6;
  37323. TerrainMaterial.DIFFUSESCALE2=7;
  37324. TerrainMaterial.DIFFUSESCALE3=8;
  37325. TerrainMaterial.DIFFUSESCALE4=9;
  37326. TerrainMaterial.MATERIALAMBIENT=10;
  37327. TerrainMaterial.MATERIALDIFFUSE=11;
  37328. TerrainMaterial.MATERIALSPECULAR=12;
  37329. TerrainMaterial.SHADERDEFINE_DETAIL_NUM1=0;
  37330. TerrainMaterial.SHADERDEFINE_DETAIL_NUM2=0;
  37331. TerrainMaterial.SHADERDEFINE_DETAIL_NUM3=0;
  37332. TerrainMaterial.SHADERDEFINE_DETAIL_NUM4=0;
  37333. __static(TerrainMaterial,
  37334. ['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);}
  37335. ]);
  37336. return TerrainMaterial;
  37337. })(BaseMaterial)
  37338. /**
  37339. *<code>BlinnPhongMaterial</code> 类用于实现Blinn-Phong材质。
  37340. */
  37341. //class laya.d3.core.material.BlinnPhongMaterial extends laya.d3.core.material.BaseMaterial
  37342. var BlinnPhongMaterial=(function(_super){
  37343. function BlinnPhongMaterial(){
  37344. /**@private */
  37345. //this._albedoColor=null;
  37346. /**@private */
  37347. //this._albedoIntensity=NaN;
  37348. /**@private */
  37349. //this._enableLighting=false;
  37350. /**@private */
  37351. this._enableVertexColor=false;
  37352. BlinnPhongMaterial.__super.call(this);
  37353. this.setShaderName("BLINNPHONG");
  37354. this._albedoIntensity=1.0;
  37355. this._albedoColor=new Vector4(1.0,1.0,1.0,1.0);
  37356. var sv=this._shaderValues;
  37357. sv.setVector(BlinnPhongMaterial.ALBEDOCOLOR,new Vector4(1.0,1.0,1.0,1.0));
  37358. sv.setVector(BlinnPhongMaterial.MATERIALSPECULAR,new Vector4(1.0,1.0,1.0,1.0));
  37359. sv.setNumber(BlinnPhongMaterial.SHININESS,0.078125);
  37360. sv.setNumber(BaseMaterial.ALPHATESTVALUE,0.5);
  37361. sv.setVector(BlinnPhongMaterial.TILINGOFFSET,new Vector4(1.0,1.0,0.0,0.0));
  37362. this._enableLighting=true;
  37363. this.renderMode=0;
  37364. }
  37365. __class(BlinnPhongMaterial,'laya.d3.core.material.BlinnPhongMaterial',_super);
  37366. var __proto=BlinnPhongMaterial.prototype;
  37367. /**
  37368. *禁用雾化。
  37369. */
  37370. __proto.disableFog=function(){
  37371. this._disablePublicDefineDatas.add(Scene3D.SHADERDEFINE_FOG);
  37372. }
  37373. /**
  37374. *@inheritDoc
  37375. */
  37376. __proto.cloneTo=function(destObject){
  37377. _super.prototype.cloneTo.call(this,destObject);
  37378. var destMaterial=destObject;
  37379. destMaterial._enableLighting=this._enableLighting;
  37380. destMaterial._albedoIntensity=this._albedoIntensity;
  37381. destMaterial._enableVertexColor=this._enableVertexColor;
  37382. this._albedoColor.cloneTo(destMaterial._albedoColor);
  37383. }
  37384. /**
  37385. *@private
  37386. */
  37387. /**
  37388. *@private
  37389. */
  37390. __getset(0,__proto,'_SpecColorG',function(){
  37391. return this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).y;
  37392. },function(value){
  37393. this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).y=value;
  37394. });
  37395. /**
  37396. *@private
  37397. */
  37398. /**
  37399. *@private
  37400. */
  37401. __getset(0,__proto,'_ColorB',function(){
  37402. return this._albedoColor.z;
  37403. },function(value){
  37404. this._albedoColor.z=value;
  37405. this.albedoColor=this._albedoColor;
  37406. });
  37407. /**
  37408. *@private
  37409. */
  37410. /**
  37411. *@private
  37412. */
  37413. __getset(0,__proto,'_ColorR',function(){
  37414. return this._albedoColor.x;
  37415. },function(value){
  37416. this._albedoColor.x=value;
  37417. this.albedoColor=this._albedoColor;
  37418. });
  37419. /**
  37420. *设置反照率颜色alpha分量。
  37421. *@param value 反照率颜色alpha分量。
  37422. */
  37423. /**
  37424. *获取反照率颜色Z分量。
  37425. *@return 反照率颜色Z分量。
  37426. */
  37427. __getset(0,__proto,'albedoColorA',function(){
  37428. return this._ColorA;
  37429. },function(value){
  37430. this._ColorA=value;
  37431. });
  37432. /**
  37433. *@private
  37434. */
  37435. /**
  37436. *@private
  37437. */
  37438. __getset(0,__proto,'_MainTex_STX',function(){
  37439. return this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET).x;
  37440. },function(x){
  37441. var tilOff=this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET);
  37442. tilOff.x=x;
  37443. this.tilingOffset=tilOff;
  37444. });
  37445. /**
  37446. *@private
  37447. */
  37448. /**
  37449. *@private
  37450. */
  37451. __getset(0,__proto,'_SpecColorB',function(){
  37452. return this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).z;
  37453. },function(value){
  37454. this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).z=value;
  37455. });
  37456. /**
  37457. *设置渲染模式。
  37458. *@return 渲染模式。
  37459. */
  37460. __getset(0,__proto,'renderMode',null,function(value){
  37461. switch (value){
  37462. case 0:
  37463. this.alphaTest=false;
  37464. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_OPAQUE*/2000;
  37465. this.depthWrite=true;
  37466. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  37467. this.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  37468. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  37469. break ;
  37470. case 1:
  37471. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_ALPHATEST*/2450;
  37472. this.alphaTest=true;
  37473. this.depthWrite=true;
  37474. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  37475. this.blend=/*laya.d3.core.material.RenderState.BLEND_DISABLE*/0;
  37476. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  37477. break ;
  37478. case 2:
  37479. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_TRANSPARENT*/3000;
  37480. this.alphaTest=false;
  37481. this.depthWrite=false;
  37482. this.cull=/*laya.d3.core.material.RenderState.CULL_BACK*/2;
  37483. this.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  37484. this.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_SRC_ALPHA*/0x0302;
  37485. this.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA*/0x0303;
  37486. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  37487. break ;
  37488. default :
  37489. throw new Error("Material:renderMode value error.");
  37490. }
  37491. });
  37492. /**
  37493. *@private
  37494. */
  37495. /**
  37496. *@private
  37497. */
  37498. __getset(0,__proto,'_SpecColorR',function(){
  37499. return this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).x;
  37500. },function(value){
  37501. this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).x=value;
  37502. });
  37503. /**
  37504. *@private
  37505. */
  37506. /**
  37507. *@private
  37508. */
  37509. __getset(0,__proto,'_ColorG',function(){
  37510. return this._albedoColor.y;
  37511. },function(value){
  37512. this._albedoColor.y=value;
  37513. this.albedoColor=this._albedoColor;
  37514. });
  37515. /**
  37516. *@private
  37517. */
  37518. /**@private */
  37519. __getset(0,__proto,'_ColorA',function(){
  37520. return this._albedoColor.w;
  37521. },function(value){
  37522. this._albedoColor.w=value;
  37523. this.albedoColor=this._albedoColor;
  37524. });
  37525. /**
  37526. *设置高光颜色。
  37527. *@param value 高光颜色。
  37528. */
  37529. /**
  37530. *获取高光颜色。
  37531. *@return 高光颜色。
  37532. */
  37533. __getset(0,__proto,'specularColor',function(){
  37534. return this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR);
  37535. },function(value){
  37536. this._shaderValues.setVector(BlinnPhongMaterial.MATERIALSPECULAR,value);
  37537. });
  37538. /**
  37539. *设置反照率颜色B分量。
  37540. *@param value 反照率颜色B分量。
  37541. */
  37542. /**
  37543. *获取反照率颜色B分量。
  37544. *@return 反照率颜色B分量。
  37545. */
  37546. __getset(0,__proto,'albedoColorB',function(){
  37547. return this._ColorB;
  37548. },function(value){
  37549. this._ColorB=value;
  37550. });
  37551. /**
  37552. *@private
  37553. */
  37554. /**
  37555. *@private
  37556. */
  37557. __getset(0,__proto,'_SpecColorA',function(){
  37558. return this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).w;
  37559. },function(value){
  37560. this._shaderValues.getVector(BlinnPhongMaterial.MATERIALSPECULAR).w=value;
  37561. });
  37562. /**
  37563. *@private
  37564. */
  37565. /**
  37566. *@private
  37567. */
  37568. __getset(0,__proto,'_MainTex_STZ',function(){
  37569. return this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET).z;
  37570. },function(z){
  37571. var tilOff=this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET);
  37572. tilOff.z=z;
  37573. this.tilingOffset=tilOff;
  37574. });
  37575. /**
  37576. *@private
  37577. */
  37578. /**
  37579. *@private
  37580. */
  37581. __getset(0,__proto,'_AlbedoIntensity',function(){
  37582. return this._albedoIntensity;
  37583. },function(value){
  37584. if (this._albedoIntensity!==value){
  37585. var finalAlbedo=this._shaderValues.getVector(BlinnPhongMaterial.ALBEDOCOLOR);
  37586. Vector4.scale(this._albedoColor,value,finalAlbedo);
  37587. this._albedoIntensity=value;
  37588. this._shaderValues.setVector(BlinnPhongMaterial.ALBEDOCOLOR,finalAlbedo);
  37589. }
  37590. });
  37591. /**
  37592. *设置高光颜色A分量。
  37593. *@param value 高光颜色A分量。
  37594. */
  37595. /**
  37596. *获取高光颜色A分量。
  37597. *@return 高光颜色A分量。
  37598. */
  37599. __getset(0,__proto,'specularColorA',function(){
  37600. return this._SpecColorA;
  37601. },function(value){
  37602. this._SpecColorA=value;
  37603. });
  37604. /**
  37605. *@private
  37606. */
  37607. /**
  37608. *@private
  37609. */
  37610. __getset(0,__proto,'_Shininess',function(){
  37611. return this._shaderValues.getNumber(BlinnPhongMaterial.SHININESS);
  37612. },function(value){
  37613. value=Math.max(0.0,Math.min(1.0,value));
  37614. this._shaderValues.setNumber(BlinnPhongMaterial.SHININESS,value);
  37615. });
  37616. /**
  37617. *@private
  37618. */
  37619. /**
  37620. *@private
  37621. */
  37622. __getset(0,__proto,'_MainTex_STY',function(){
  37623. return this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET).y;
  37624. },function(y){
  37625. var tilOff=this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET);
  37626. tilOff.y=y;
  37627. this.tilingOffset=tilOff;
  37628. });
  37629. /**
  37630. *@private
  37631. */
  37632. /**
  37633. *@private
  37634. */
  37635. __getset(0,__proto,'_Cutoff',function(){
  37636. return this.alphaTestValue;
  37637. },function(value){
  37638. this.alphaTestValue=value;
  37639. });
  37640. /**
  37641. *@private
  37642. */
  37643. /**
  37644. *@private
  37645. */
  37646. __getset(0,__proto,'_MainTex_STW',function(){
  37647. return this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET).w;
  37648. },function(w){
  37649. var tilOff=this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET);
  37650. tilOff.w=w;
  37651. this.tilingOffset=tilOff;
  37652. });
  37653. /**
  37654. *设置反照率贴图。
  37655. *@param value 反照率贴图。
  37656. */
  37657. /**
  37658. *获取反照率贴图。
  37659. *@return 反照率贴图。
  37660. */
  37661. __getset(0,__proto,'albedoTexture',function(){
  37662. return this._shaderValues.getTexture(BlinnPhongMaterial.ALBEDOTEXTURE);
  37663. },function(value){
  37664. if (value)
  37665. this._defineDatas.add(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_DIFFUSEMAP);
  37666. else
  37667. this._defineDatas.remove(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_DIFFUSEMAP);
  37668. this._shaderValues.setTexture(BlinnPhongMaterial.ALBEDOTEXTURE,value);
  37669. });
  37670. /**
  37671. *设置是否支持顶点色。
  37672. *@param value 是否支持顶点色。
  37673. */
  37674. /**
  37675. *获取是否支持顶点色。
  37676. *@return 是否支持顶点色。
  37677. */
  37678. __getset(0,__proto,'enableVertexColor',function(){
  37679. return this._enableVertexColor;
  37680. },function(value){
  37681. this._enableVertexColor=value;
  37682. if (value)
  37683. this._defineDatas.add(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_ENABLEVERTEXCOLOR);
  37684. else
  37685. this._defineDatas.remove(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_ENABLEVERTEXCOLOR);
  37686. });
  37687. /**
  37688. *设置反照率颜色。
  37689. *@param value 反照率颜色。
  37690. */
  37691. /**
  37692. *获取反照率颜色。
  37693. *@return 反照率颜色。
  37694. */
  37695. __getset(0,__proto,'albedoColor',function(){
  37696. return this._albedoColor;
  37697. },function(value){
  37698. var finalAlbedo=this._shaderValues.getVector(BlinnPhongMaterial.ALBEDOCOLOR);
  37699. Vector4.scale(value,this._albedoIntensity,finalAlbedo);
  37700. this._albedoColor=value;
  37701. this._shaderValues.setVector(BlinnPhongMaterial.ALBEDOCOLOR,finalAlbedo);
  37702. });
  37703. /**
  37704. *获取纹理平铺和偏移X分量。
  37705. *@param x 纹理平铺和偏移X分量。
  37706. */
  37707. /**
  37708. *获取纹理平铺和偏移X分量。
  37709. *@return 纹理平铺和偏移X分量。
  37710. */
  37711. __getset(0,__proto,'tilingOffsetX',function(){
  37712. return this._MainTex_STX;
  37713. },function(x){
  37714. this._MainTex_STX=x;
  37715. });
  37716. /**
  37717. *获取纹理平铺和偏移Y分量。
  37718. *@param y 纹理平铺和偏移Y分量。
  37719. */
  37720. /**
  37721. *获取纹理平铺和偏移Y分量。
  37722. *@return 纹理平铺和偏移Y分量。
  37723. */
  37724. __getset(0,__proto,'tilingOffsetY',function(){
  37725. return this._MainTex_STY;
  37726. },function(y){
  37727. this._MainTex_STY=y;
  37728. });
  37729. /**
  37730. *获取纹理平铺和偏移Z分量。
  37731. *@param z 纹理平铺和偏移Z分量。
  37732. */
  37733. /**
  37734. *获取纹理平铺和偏移Z分量。
  37735. *@return 纹理平铺和偏移Z分量。
  37736. */
  37737. __getset(0,__proto,'tilingOffsetZ',function(){
  37738. return this._MainTex_STZ;
  37739. },function(z){
  37740. this._MainTex_STZ=z;
  37741. });
  37742. /**
  37743. *设置混合源。
  37744. *@param value 混合源
  37745. */
  37746. /**
  37747. *获取混合源。
  37748. *@return 混合源。
  37749. */
  37750. __getset(0,__proto,'blendSrc',function(){
  37751. return this._shaderValues.getInt(BlinnPhongMaterial.BLEND_SRC);
  37752. },function(value){
  37753. this._shaderValues.setInt(BlinnPhongMaterial.BLEND_SRC,value);
  37754. });
  37755. /**
  37756. *设置是否启用光照。
  37757. *@param value 是否启用光照。
  37758. */
  37759. /**
  37760. *获取是否启用光照。
  37761. *@return 是否启用光照。
  37762. */
  37763. __getset(0,__proto,'enableLighting',function(){
  37764. return this._enableLighting;
  37765. },function(value){
  37766. if (this._enableLighting!==value){
  37767. if (value)
  37768. this._disablePublicDefineDatas.remove(Scene3D.SHADERDEFINE_POINTLIGHT | Scene3D.SHADERDEFINE_SPOTLIGHT | Scene3D.SHADERDEFINE_DIRECTIONLIGHT);
  37769. else
  37770. this._disablePublicDefineDatas.add(Scene3D.SHADERDEFINE_POINTLIGHT | Scene3D.SHADERDEFINE_SPOTLIGHT | Scene3D.SHADERDEFINE_DIRECTIONLIGHT);
  37771. this._enableLighting=value;
  37772. }
  37773. });
  37774. /**
  37775. *获取纹理平铺和偏移W分量。
  37776. *@param w 纹理平铺和偏移W分量。
  37777. */
  37778. /**
  37779. *获取纹理平铺和偏移W分量。
  37780. *@return 纹理平铺和偏移W分量。
  37781. */
  37782. __getset(0,__proto,'tilingOffsetW',function(){
  37783. return this._MainTex_STW;
  37784. },function(w){
  37785. this._MainTex_STW=w;
  37786. });
  37787. /**
  37788. *获取纹理平铺和偏移。
  37789. *@param value 纹理平铺和偏移。
  37790. */
  37791. /**
  37792. *获取纹理平铺和偏移。
  37793. *@return 纹理平铺和偏移。
  37794. */
  37795. __getset(0,__proto,'tilingOffset',function(){
  37796. return this._shaderValues.getVector(BlinnPhongMaterial.TILINGOFFSET);
  37797. },function(value){
  37798. if (value){
  37799. if (value.x !=1 || value.y !=1 || value.z !=0 || value.w !=0)
  37800. this._defineDatas.add(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_TILINGOFFSET);
  37801. else
  37802. this._defineDatas.remove(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_TILINGOFFSET);
  37803. }else {
  37804. this._defineDatas.remove(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_TILINGOFFSET);
  37805. }
  37806. this._shaderValues.setVector(BlinnPhongMaterial.TILINGOFFSET,value);
  37807. });
  37808. /**
  37809. *设置反照率颜色R分量。
  37810. *@param value 反照率颜色R分量。
  37811. */
  37812. /**
  37813. *获取反照率颜色R分量。
  37814. *@return 反照率颜色R分量。
  37815. */
  37816. __getset(0,__proto,'albedoColorR',function(){
  37817. return this._ColorR;
  37818. },function(value){
  37819. this._ColorR=value;
  37820. });
  37821. /**
  37822. *设置反照率颜色G分量。
  37823. *@param value 反照率颜色G分量。
  37824. */
  37825. /**
  37826. *获取反照率颜色G分量。
  37827. *@return 反照率颜色G分量。
  37828. */
  37829. __getset(0,__proto,'albedoColorG',function(){
  37830. return this._ColorG;
  37831. },function(value){
  37832. this._ColorG=value;
  37833. });
  37834. /**
  37835. *设置反照率强度。
  37836. *@param value 反照率强度。
  37837. */
  37838. /**
  37839. *获取反照率强度。
  37840. *@return 反照率强度。
  37841. */
  37842. __getset(0,__proto,'albedoIntensity',function(){
  37843. return this._albedoIntensity;
  37844. },function(value){
  37845. this._AlbedoIntensity=value;
  37846. });
  37847. /**
  37848. *设置高光颜色R分量。
  37849. *@param value 高光颜色R分量。
  37850. */
  37851. /**
  37852. *获取高光颜色R轴分量。
  37853. *@return 高光颜色R轴分量。
  37854. */
  37855. __getset(0,__proto,'specularColorR',function(){
  37856. return this._SpecColorR;
  37857. },function(value){
  37858. this._SpecColorR=value;
  37859. });
  37860. /**
  37861. *设置高光颜色G分量。
  37862. *@param value 高光颜色G分量。
  37863. */
  37864. /**
  37865. *获取高光颜色G分量。
  37866. *@return 高光颜色G分量。
  37867. */
  37868. __getset(0,__proto,'specularColorG',function(){
  37869. return this._SpecColorG;
  37870. },function(value){
  37871. this._SpecColorG=value;
  37872. });
  37873. /**
  37874. *设置高光颜色B分量。
  37875. *@param value 高光颜色B分量。
  37876. */
  37877. /**
  37878. *获取高光颜色B分量。
  37879. *@return 高光颜色B分量。
  37880. */
  37881. __getset(0,__proto,'specularColorB',function(){
  37882. return this._SpecColorB;
  37883. },function(value){
  37884. this._SpecColorB=value;
  37885. });
  37886. /**
  37887. *设置混合目标。
  37888. *@param value 混合目标
  37889. */
  37890. /**
  37891. *获取混合目标。
  37892. *@return 混合目标。
  37893. */
  37894. __getset(0,__proto,'blendDst',function(){
  37895. return this._shaderValues.getInt(BlinnPhongMaterial.BLEND_DST);
  37896. },function(value){
  37897. this._shaderValues.setInt(BlinnPhongMaterial.BLEND_DST,value);
  37898. });
  37899. /**
  37900. *设置高光强度,范围为0到1。
  37901. *@param value 高光强度。
  37902. */
  37903. /**
  37904. *获取高光强度,范围为0到1。
  37905. *@return 高光强度。
  37906. */
  37907. __getset(0,__proto,'shininess',function(){
  37908. return this._Shininess;
  37909. },function(value){
  37910. this._Shininess=value;
  37911. });
  37912. /**
  37913. *设置剔除方式。
  37914. *@param value 剔除方式。
  37915. */
  37916. /**
  37917. *获取剔除方式。
  37918. *@return 剔除方式。
  37919. */
  37920. __getset(0,__proto,'cull',function(){
  37921. return this._shaderValues.getInt(BlinnPhongMaterial.CULL);
  37922. },function(value){
  37923. this._shaderValues.setInt(BlinnPhongMaterial.CULL,value);
  37924. });
  37925. /**
  37926. *设置法线贴图。
  37927. *@param value 法线贴图。
  37928. */
  37929. /**
  37930. *获取法线贴图。
  37931. *@return 法线贴图。
  37932. */
  37933. __getset(0,__proto,'normalTexture',function(){
  37934. return this._shaderValues.getTexture(BlinnPhongMaterial.NORMALTEXTURE);
  37935. },function(value){
  37936. if (value)
  37937. this._defineDatas.add(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_NORMALMAP);
  37938. else
  37939. this._defineDatas.remove(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_NORMALMAP);
  37940. this._shaderValues.setTexture(BlinnPhongMaterial.NORMALTEXTURE,value);
  37941. });
  37942. /**
  37943. *设置高光贴图,高光强度则从该贴图RGB值中获取,如果该值为空则从漫反射贴图的Alpha通道获取。
  37944. *@param value 高光贴图。
  37945. */
  37946. /**
  37947. *获取高光贴图。
  37948. *@return 高光贴图。
  37949. */
  37950. __getset(0,__proto,'specularTexture',function(){
  37951. return this._shaderValues.getTexture(BlinnPhongMaterial.SPECULARTEXTURE);
  37952. },function(value){
  37953. if (value)
  37954. this._defineDatas.add(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_SPECULARMAP);
  37955. else
  37956. this._defineDatas.remove(laya.d3.core.material.BlinnPhongMaterial.SHADERDEFINE_SPECULARMAP);
  37957. this._shaderValues.setTexture(BlinnPhongMaterial.SPECULARTEXTURE,value);
  37958. });
  37959. /**
  37960. *设置是否写入深度。
  37961. *@param value 是否写入深度。
  37962. */
  37963. /**
  37964. *获取是否写入深度。
  37965. *@return 是否写入深度。
  37966. */
  37967. __getset(0,__proto,'depthWrite',function(){
  37968. return this._shaderValues.getBool(BlinnPhongMaterial.DEPTH_WRITE);
  37969. },function(value){
  37970. this._shaderValues.setBool(BlinnPhongMaterial.DEPTH_WRITE,value);
  37971. });
  37972. /**
  37973. *设置混合方式。
  37974. *@param value 混合方式。
  37975. */
  37976. /**
  37977. *获取混合方式。
  37978. *@return 混合方式。
  37979. */
  37980. __getset(0,__proto,'blend',function(){
  37981. return this._shaderValues.getInt(BlinnPhongMaterial.BLEND);
  37982. },function(value){
  37983. this._shaderValues.setInt(BlinnPhongMaterial.BLEND,value);
  37984. });
  37985. /**
  37986. *设置深度测试方式。
  37987. *@param value 深度测试方式
  37988. */
  37989. /**
  37990. *获取深度测试方式。
  37991. *@return 深度测试方式。
  37992. */
  37993. __getset(0,__proto,'depthTest',function(){
  37994. return this._shaderValues.getInt(BlinnPhongMaterial.DEPTH_TEST);
  37995. },function(value){
  37996. this._shaderValues.setInt(BlinnPhongMaterial.DEPTH_TEST,value);
  37997. });
  37998. BlinnPhongMaterial.__init__=function(){
  37999. BlinnPhongMaterial.SHADERDEFINE_DIFFUSEMAP=BlinnPhongMaterial.shaderDefines.registerDefine("DIFFUSEMAP");
  38000. BlinnPhongMaterial.SHADERDEFINE_NORMALMAP=BlinnPhongMaterial.shaderDefines.registerDefine("NORMALMAP");
  38001. BlinnPhongMaterial.SHADERDEFINE_SPECULARMAP=BlinnPhongMaterial.shaderDefines.registerDefine("SPECULARMAP");
  38002. BlinnPhongMaterial.SHADERDEFINE_TILINGOFFSET=BlinnPhongMaterial.shaderDefines.registerDefine("TILINGOFFSET");
  38003. BlinnPhongMaterial.SHADERDEFINE_ENABLEVERTEXCOLOR=BlinnPhongMaterial.shaderDefines.registerDefine("ENABLEVERTEXCOLOR");
  38004. }
  38005. BlinnPhongMaterial.SPECULARSOURCE_DIFFUSEMAPALPHA=0;
  38006. BlinnPhongMaterial.SPECULARSOURCE_SPECULARMAP=0;
  38007. BlinnPhongMaterial.RENDERMODE_OPAQUE=0;
  38008. BlinnPhongMaterial.RENDERMODE_CUTOUT=1;
  38009. BlinnPhongMaterial.RENDERMODE_TRANSPARENT=2;
  38010. BlinnPhongMaterial.SHADERDEFINE_DIFFUSEMAP=0;
  38011. BlinnPhongMaterial.SHADERDEFINE_NORMALMAP=0;
  38012. BlinnPhongMaterial.SHADERDEFINE_SPECULARMAP=0;
  38013. BlinnPhongMaterial.SHADERDEFINE_TILINGOFFSET=0;
  38014. BlinnPhongMaterial.SHADERDEFINE_ENABLEVERTEXCOLOR=0;
  38015. __static(BlinnPhongMaterial,
  38016. ['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);}
  38017. ]);
  38018. return BlinnPhongMaterial;
  38019. })(BaseMaterial)
  38020. /**
  38021. *<code>EffectMaterial</code> 类用于实现Mesh特效材质。
  38022. */
  38023. //class laya.d3.core.material.EffectMaterial extends laya.d3.core.material.BaseMaterial
  38024. var EffectMaterial=(function(_super){
  38025. function EffectMaterial(){
  38026. /**@private */
  38027. this._color=null;
  38028. EffectMaterial.__super.call(this);
  38029. this.setShaderName("Effect");
  38030. this._color=new Vector4(1.0,1.0,1.0,1.0);
  38031. this._shaderValues.setVector(EffectMaterial.TINTCOLOR,new Vector4(1.0,1.0,1.0,1.0));
  38032. this.renderMode=0;
  38033. }
  38034. __class(EffectMaterial,'laya.d3.core.material.EffectMaterial',_super);
  38035. var __proto=EffectMaterial.prototype;
  38036. /**
  38037. *@private
  38038. */
  38039. /**
  38040. *@private
  38041. */
  38042. __getset(0,__proto,'_TintColorB',function(){
  38043. return this._color.z;
  38044. },function(value){
  38045. this._color.z=value;
  38046. this.color=this._color;
  38047. });
  38048. /**
  38049. *@private
  38050. */
  38051. /**
  38052. *@private
  38053. */
  38054. __getset(0,__proto,'_MainTex_STZ',function(){
  38055. return this._shaderValues.getVector(EffectMaterial.TILINGOFFSET).z;
  38056. },function(z){
  38057. var tilOff=this._shaderValues.getVector(EffectMaterial.TILINGOFFSET);
  38058. tilOff.z=z;
  38059. this.tilingOffset=tilOff;
  38060. });
  38061. /**
  38062. *设置贴图。
  38063. *@param value 贴图。
  38064. */
  38065. /**
  38066. *获取贴图。
  38067. *@return 贴图。
  38068. */
  38069. __getset(0,__proto,'texture',function(){
  38070. return this._shaderValues.getTexture(EffectMaterial.MAINTEXTURE);
  38071. },function(value){
  38072. if (value)
  38073. this._defineDatas.add(laya.d3.core.material.EffectMaterial.SHADERDEFINE_MAINTEXTURE);
  38074. else
  38075. this._defineDatas.remove(laya.d3.core.material.EffectMaterial.SHADERDEFINE_MAINTEXTURE);
  38076. this._shaderValues.setTexture(EffectMaterial.MAINTEXTURE,value);
  38077. });
  38078. /**
  38079. *@private
  38080. */
  38081. /**
  38082. *@private
  38083. */
  38084. __getset(0,__proto,'_TintColorR',function(){
  38085. return this._color.x;
  38086. },function(value){
  38087. this._color.x=value;
  38088. this.color=this._color;
  38089. });
  38090. /**
  38091. *@private
  38092. */
  38093. /**
  38094. *@private
  38095. */
  38096. __getset(0,__proto,'_MainTex_STW',function(){
  38097. return this._shaderValues.getVector(EffectMaterial.TILINGOFFSET).w;
  38098. },function(w){
  38099. var tilOff=this._shaderValues.getVector(EffectMaterial.TILINGOFFSET);
  38100. tilOff.w=w;
  38101. this.tilingOffset=tilOff;
  38102. });
  38103. /**
  38104. *@private
  38105. */
  38106. /**
  38107. *@private
  38108. */
  38109. __getset(0,__proto,'_TintColorG',function(){
  38110. return this._color.y;
  38111. },function(value){
  38112. this._color.y=value;
  38113. this.color=this._color;
  38114. });
  38115. /**
  38116. *@private
  38117. */
  38118. /**@private */
  38119. __getset(0,__proto,'_TintColorA',function(){
  38120. return this._color.w;
  38121. },function(value){
  38122. this._color.w=value;
  38123. this.color=this._color;
  38124. });
  38125. /**
  38126. *@private
  38127. */
  38128. /**
  38129. *@private
  38130. */
  38131. __getset(0,__proto,'_MainTex_STY',function(){
  38132. return this._shaderValues.getVector(EffectMaterial.TILINGOFFSET).y;
  38133. },function(y){
  38134. var tilOff=this._shaderValues.getVector(EffectMaterial.TILINGOFFSET);
  38135. tilOff.y=y;
  38136. this.tilingOffset=tilOff;
  38137. });
  38138. /**
  38139. *设置渲染模式。
  38140. *@return 渲染模式。
  38141. */
  38142. __getset(0,__proto,'renderMode',null,function(value){
  38143. switch (value){
  38144. case 0:
  38145. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_TRANSPARENT*/3000;
  38146. this.alphaTest=false;
  38147. this.depthWrite=false;
  38148. this.cull=/*laya.d3.core.material.RenderState.CULL_NONE*/0;
  38149. this.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  38150. this.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_SRC_ALPHA*/0x0302;
  38151. this.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE*/1;
  38152. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  38153. this._defineDatas.add(EffectMaterial.SHADERDEFINE_ADDTIVEFOG);
  38154. break ;
  38155. case 1:
  38156. this.renderQueue=/*laya.d3.core.material.BaseMaterial.RENDERQUEUE_TRANSPARENT*/3000;
  38157. this.alphaTest=false;
  38158. this.depthWrite=false;
  38159. this.cull=/*laya.d3.core.material.RenderState.CULL_NONE*/0;
  38160. this.blend=/*laya.d3.core.material.RenderState.BLEND_ENABLE_ALL*/1;
  38161. this.blendSrc=/*laya.d3.core.material.RenderState.BLENDPARAM_SRC_ALPHA*/0x0302;
  38162. this.blendDst=/*laya.d3.core.material.RenderState.BLENDPARAM_ONE_MINUS_SRC_ALPHA*/0x0303;
  38163. this.depthTest=/*laya.d3.core.material.RenderState.DEPTHTEST_LESS*/0x0201;
  38164. this._defineDatas.remove(EffectMaterial.SHADERDEFINE_ADDTIVEFOG);
  38165. break ;
  38166. default :
  38167. throw new Error("MeshEffectMaterial : renderMode value error.");
  38168. }
  38169. });
  38170. /**
  38171. *@private
  38172. */
  38173. /**
  38174. *@private
  38175. */
  38176. __getset(0,__proto,'_MainTex_STX',function(){
  38177. return this._shaderValues.getVector(EffectMaterial.TILINGOFFSET).x;
  38178. },function(x){
  38179. var tilOff=this._shaderValues.getVector(EffectMaterial.TILINGOFFSET);
  38180. tilOff.x=x;
  38181. this.tilingOffset=tilOff;
  38182. });
  38183. /**
  38184. *设置颜色R分量。
  38185. *@param value 颜色R分量。
  38186. */
  38187. /**
  38188. *获取颜色R分量。
  38189. *@return 颜色R分量。
  38190. */
  38191. __getset(0,__proto,'colorR',function(){
  38192. return this._TintColorR;
  38193. },function(value){
  38194. this._TintColorR=value;
  38195. });
  38196. /**
  38197. *设置颜色G分量。
  38198. *@param value 颜色G分量。
  38199. */
  38200. /**
  38201. *获取颜色G分量。
  38202. *@return 颜色G分量。
  38203. */
  38204. __getset(0,__proto,'colorG',function(){
  38205. return this._TintColorG;
  38206. },function(value){
  38207. this._TintColorG=value;
  38208. });
  38209. /**
  38210. *设置颜色B分量。
  38211. *@param value 颜色B分量。
  38212. */
  38213. /**
  38214. *获取颜色B分量。
  38215. *@return 颜色B分量。
  38216. */
  38217. __getset(0,__proto,'colorB',function(){
  38218. return this._TintColorB;
  38219. },function(value){
  38220. this._TintColorB=value;
  38221. });
  38222. /**
  38223. *设置颜色alpha分量。
  38224. *@param value 颜色alpha分量。
  38225. */
  38226. /**
  38227. *获取颜色Z分量。
  38228. *@return 颜色Z分量。
  38229. */
  38230. __getset(0,__proto,'colorA',function(){
  38231. return this._TintColorA;
  38232. },function(value){
  38233. this._TintColorA=value;
  38234. });
  38235. /**
  38236. *设置混合方式。
  38237. *@param value 混合方式。
  38238. */
  38239. /**
  38240. *获取混合方式。
  38241. *@return 混合方式。
  38242. */
  38243. __getset(0,__proto,'blend',function(){
  38244. return this._shaderValues.getInt(EffectMaterial.BLEND);
  38245. },function(value){
  38246. this._shaderValues.setInt(EffectMaterial.BLEND,value);
  38247. });
  38248. /**
  38249. *设置颜色。
  38250. *@param value 颜色。
  38251. */
  38252. /**
  38253. *获取颜色。
  38254. *@return 颜色。
  38255. */
  38256. __getset(0,__proto,'color',function(){
  38257. return this._shaderValues.getVector(EffectMaterial.TINTCOLOR);
  38258. },function(value){
  38259. this._shaderValues.setVector(EffectMaterial.TINTCOLOR,value);
  38260. });
  38261. /**
  38262. *获取纹理平铺和偏移X分量。
  38263. *@param x 纹理平铺和偏移X分量。
  38264. */
  38265. /**
  38266. *获取纹理平铺和偏移X分量。
  38267. *@return 纹理平铺和偏移X分量。
  38268. */
  38269. __getset(0,__proto,'tilingOffsetX',function(){
  38270. return this._MainTex_STX;
  38271. },function(x){
  38272. this._MainTex_STX=x;
  38273. });
  38274. /**
  38275. *获取纹理平铺和偏移Y分量。
  38276. *@param y 纹理平铺和偏移Y分量。
  38277. */
  38278. /**
  38279. *获取纹理平铺和偏移Y分量。
  38280. *@return 纹理平铺和偏移Y分量。
  38281. */
  38282. __getset(0,__proto,'tilingOffsetY',function(){
  38283. return this._MainTex_STY;
  38284. },function(y){
  38285. this._MainTex_STY=y;
  38286. });
  38287. /**
  38288. *获取纹理平铺和偏移Z分量。
  38289. *@param z 纹理平铺和偏移Z分量。
  38290. */
  38291. /**
  38292. *获取纹理平铺和偏移Z分量。
  38293. *@return 纹理平铺和偏移Z分量。
  38294. */
  38295. __getset(0,__proto,'tilingOffsetZ',function(){
  38296. return this._MainTex_STZ;
  38297. },function(z){
  38298. this._MainTex_STZ=z;
  38299. });
  38300. /**
  38301. *设置混合源。
  38302. *@param value 混合源
  38303. */
  38304. /**
  38305. *获取混合源。
  38306. *@return 混合源。
  38307. */
  38308. __getset(0,__proto,'blendSrc',function(){
  38309. return this._shaderValues.getInt(EffectMaterial.BLEND_SRC);
  38310. },function(value){
  38311. this._shaderValues.setInt(EffectMaterial.BLEND_SRC,value);
  38312. });
  38313. /**
  38314. *获取纹理平铺和偏移W分量。
  38315. *@param w 纹理平铺和偏移W分量。
  38316. */
  38317. /**
  38318. *获取纹理平铺和偏移W分量。
  38319. *@return 纹理平铺和偏移W分量。
  38320. */
  38321. __getset(0,__proto,'tilingOffsetW',function(){
  38322. return this._MainTex_STW;
  38323. },function(w){
  38324. this._MainTex_STW=w;
  38325. });
  38326. /**
  38327. *设置纹理平铺和偏移。
  38328. *@param value 纹理平铺和偏移。
  38329. */
  38330. /**
  38331. *获取纹理平铺和偏移。
  38332. *@return 纹理平铺和偏移。
  38333. */
  38334. __getset(0,__proto,'tilingOffset',function(){
  38335. return this._shaderValues.getVector(EffectMaterial.TILINGOFFSET);
  38336. },function(value){
  38337. if (value){
  38338. if (value.x !=1 || value.y !=1 || value.z !=0 || value.w !=0)
  38339. this._defineDatas.add(laya.d3.core.material.EffectMaterial.SHADERDEFINE_TILINGOFFSET);
  38340. else
  38341. this._defineDatas.remove(laya.d3.core.material.EffectMaterial.SHADERDEFINE_TILINGOFFSET);
  38342. }else {
  38343. this._defineDatas.remove(laya.d3.core.material.EffectMaterial.SHADERDEFINE_TILINGOFFSET);
  38344. }
  38345. this._shaderValues.setVector(EffectMaterial.TILINGOFFSET,value);
  38346. });
  38347. /**
  38348. *设置是否写入深度。
  38349. *@param value 是否写入深度。
  38350. */
  38351. /**
  38352. *获取是否写入深度。
  38353. *@return 是否写入深度。
  38354. */
  38355. __getset(0,__proto,'depthWrite',function(){
  38356. return this._shaderValues.getBool(EffectMaterial.DEPTH_WRITE);
  38357. },function(value){
  38358. this._shaderValues.setBool(EffectMaterial.DEPTH_WRITE,value);
  38359. });
  38360. /**
  38361. *设置剔除方式。
  38362. *@param value 剔除方式。
  38363. */
  38364. /**
  38365. *获取剔除方式。
  38366. *@return 剔除方式。
  38367. */
  38368. __getset(0,__proto,'cull',function(){
  38369. return this._shaderValues.getInt(EffectMaterial.CULL);
  38370. },function(value){
  38371. this._shaderValues.setInt(EffectMaterial.CULL,value);
  38372. });
  38373. /**
  38374. *设置混合目标。
  38375. *@param value 混合目标
  38376. */
  38377. /**
  38378. *获取混合目标。
  38379. *@return 混合目标。
  38380. */
  38381. __getset(0,__proto,'blendDst',function(){
  38382. return this._shaderValues.getInt(EffectMaterial.BLEND_DST);
  38383. },function(value){
  38384. this._shaderValues.setInt(EffectMaterial.BLEND_DST,value);
  38385. });
  38386. /**
  38387. *设置深度测试方式。
  38388. *@param value 深度测试方式
  38389. */
  38390. /**
  38391. *获取深度测试方式。
  38392. *@return 深度测试方式。
  38393. */
  38394. __getset(0,__proto,'depthTest',function(){
  38395. return this._shaderValues.getInt(EffectMaterial.DEPTH_TEST);
  38396. },function(value){
  38397. this._shaderValues.setInt(EffectMaterial.DEPTH_TEST,value);
  38398. });
  38399. EffectMaterial.__init__=function(){
  38400. EffectMaterial.SHADERDEFINE_MAINTEXTURE=EffectMaterial.shaderDefines.registerDefine("MAINTEXTURE");
  38401. EffectMaterial.SHADERDEFINE_TILINGOFFSET=EffectMaterial.shaderDefines.registerDefine("TILINGOFFSET");
  38402. EffectMaterial.SHADERDEFINE_ADDTIVEFOG=EffectMaterial.shaderDefines.registerDefine("ADDTIVEFOG");
  38403. }
  38404. EffectMaterial.RENDERMODE_ADDTIVE=0;
  38405. EffectMaterial.RENDERMODE_ALPHABLENDED=1;
  38406. EffectMaterial.SHADERDEFINE_MAINTEXTURE=0;
  38407. EffectMaterial.SHADERDEFINE_TILINGOFFSET=0;
  38408. EffectMaterial.SHADERDEFINE_ADDTIVEFOG=0;
  38409. __static(EffectMaterial,
  38410. ['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);}
  38411. ]);
  38412. return EffectMaterial;
  38413. })(BaseMaterial)
  38414. /**
  38415. *<code>SkinMeshRenderer</code> 类用于蒙皮渲染器。
  38416. */
  38417. //class laya.d3.core.SkinnedMeshRenderer extends laya.d3.core.MeshRenderer
  38418. var SkinnedMeshRenderer=(function(_super){
  38419. function SkinnedMeshRenderer(owner){
  38420. /**@private */
  38421. //this._cacheMesh=null;
  38422. /**@private */
  38423. //this._skinnedData=null;
  38424. /**@private */
  38425. //this._cacheAnimator=null;
  38426. /**@private */
  38427. //this._cacheRootBone=null;
  38428. /**@private */
  38429. //this._rootBone=null;
  38430. /**@private */
  38431. //this._cacheAvatar=null;
  38432. /**@private */
  38433. //this._cacheRootAnimationNode=null;
  38434. /**@private [NATIVE]*/
  38435. //this._cacheAnimationNodeIndices=null;
  38436. this._bones=[];
  38437. this._skinnedDataLoopMarks=[];
  38438. this._localBounds=new Bounds(Vector3._ZERO,Vector3._ZERO);
  38439. this._cacheAnimationNode=[];
  38440. SkinnedMeshRenderer.__super.call(this,owner);
  38441. }
  38442. __class(SkinnedMeshRenderer,'laya.d3.core.SkinnedMeshRenderer',_super);
  38443. var __proto=SkinnedMeshRenderer.prototype;
  38444. /**
  38445. *@private
  38446. */
  38447. __proto._computeSkinnedData=function(){
  38448. if (this._cacheMesh && this._cacheAvatar || this._cacheMesh && this._cacheRootBone){
  38449. var bindPoses=this._cacheMesh._inverseBindPoses;
  38450. var meshBindPoseIndices=this._cacheMesh._bindPoseIndices;
  38451. var pathMarks=this._cacheMesh._skinDataPathMarks;
  38452. for (var i=0,n=this._cacheMesh.subMeshCount;i < n;i++){
  38453. var subMeshBoneIndices=(this._cacheMesh._getSubMesh(i))._boneIndicesList;
  38454. var subData=this._skinnedData[i];
  38455. for (var j=0,m=subMeshBoneIndices.length;j < m;j++){
  38456. var boneIndices=subMeshBoneIndices[j];
  38457. if (Render.supportWebGLPlusAnimation)
  38458. this._computeSubSkinnedDataNative(this._cacheAnimator._animationNodeWorldMatrixs,this._cacheAnimationNodeIndices,this._cacheMesh._inverseBindPosesBuffer,boneIndices,meshBindPoseIndices,subData[j]);
  38459. else
  38460. this._computeSubSkinnedData(bindPoses,boneIndices,meshBindPoseIndices,subData[j],pathMarks);
  38461. }
  38462. }
  38463. }
  38464. }
  38465. /**
  38466. *@private
  38467. */
  38468. __proto._computeSubSkinnedData=function(bindPoses,boneIndices,meshBindPoseInices,data,pathMarks){
  38469. for (var k=0,q=boneIndices.length;k < q;k++){
  38470. var index=boneIndices[k];
  38471. if (this._skinnedDataLoopMarks[index]===Stat.loopCount){
  38472. var p=pathMarks[index];
  38473. var preData=this._skinnedData[p[0]][p[1]];
  38474. var srcIndex=p[2] *16;
  38475. var dstIndex=k *16;
  38476. for (var d=0;d < 16;d++)
  38477. data[dstIndex+d]=preData[srcIndex+d];
  38478. }else {
  38479. if (this._cacheRootBone){
  38480. var boneIndex=meshBindPoseInices[index];
  38481. Utils3D._mulMatrixArray(this._bones[boneIndex].transform.worldMatrix.elements,bindPoses[boneIndex],data,k *16);
  38482. }
  38483. else{
  38484. Utils3D._mulMatrixArray(this._cacheAnimationNode[index].transform.getWorldMatrix(),bindPoses[meshBindPoseInices[index]],data,k *16);
  38485. }
  38486. this._skinnedDataLoopMarks[index]=Stat.loopCount;
  38487. }
  38488. }
  38489. }
  38490. /**
  38491. *@private
  38492. */
  38493. __proto._boundChange=function(){
  38494. this._boundsChange=true;
  38495. }
  38496. /**
  38497. *@private
  38498. */
  38499. __proto._onMeshChange=function(value){
  38500. _super.prototype._onMeshChange.call(this,value);
  38501. this._cacheMesh=value;
  38502. var subMeshCount=value.subMeshCount;
  38503. this._skinnedData=__newvec(subMeshCount);
  38504. this._skinnedDataLoopMarks.length=(value)._bindPoseIndices.length;
  38505. for (var i=0;i < subMeshCount;i++){
  38506. var subBoneIndices=(value._getSubMesh(i))._boneIndicesList;
  38507. var subCount=subBoneIndices.length;
  38508. var subData=this._skinnedData[i]=__newvec(subCount);
  38509. for (var j=0;j < subCount;j++)
  38510. subData[j]=new Float32Array(subBoneIndices[j].length *16);
  38511. }
  38512. if (!this._bones)
  38513. (this._cacheAvatar && value)&& (this._getCacheAnimationNodes());
  38514. }
  38515. /**
  38516. *@private
  38517. */
  38518. __proto._setCacheAnimator=function(animator){
  38519. this._cacheAnimator=animator;
  38520. this._defineDatas.add(SkinnedMeshSprite3D.SHADERDEFINE_BONE);
  38521. this._setRootNode();
  38522. }
  38523. /**
  38524. *@inheritDoc
  38525. */
  38526. __proto._calculateBoundingBox=function(){
  38527. if (this._cacheRootBone){
  38528. this._localBounds._tranform(this._cacheRootBone.transform.worldMatrix,this._bounds);
  38529. }else {
  38530. if (this._cacheAnimator && this._rootBone){
  38531. var worldMat=SkinnedMeshRenderer._tempMatrix4x4;
  38532. Utils3D.matrix4x4MultiplyMFM((this._cacheAnimator.owner).transform.worldMatrix,this._cacheRootAnimationNode.transform.getWorldMatrix(),worldMat);
  38533. this._localBounds._tranform(worldMat,this._bounds);
  38534. }else {
  38535. _super.prototype._calculateBoundingBox.call(this);
  38536. }
  38537. }
  38538. if (Render.supportWebGLPlusCulling){
  38539. var min=this._bounds.getMin();
  38540. var max=this._bounds.getMax();
  38541. var buffer=FrustumCulling._cullingBuffer;
  38542. buffer[this._cullingBufferIndex+1]=min.x;
  38543. buffer[this._cullingBufferIndex+2]=min.y;
  38544. buffer[this._cullingBufferIndex+3]=min.z;
  38545. buffer[this._cullingBufferIndex+4]=max.x;
  38546. buffer[this._cullingBufferIndex+5]=max.y;
  38547. buffer[this._cullingBufferIndex+6]=max.z;
  38548. }
  38549. }
  38550. /**
  38551. *@inheritDoc
  38552. */
  38553. __proto._changeRenderObjectsByMesh=function(mesh){
  38554. var count=mesh.subMeshCount;
  38555. this._renderElements.length=count;
  38556. for (var i=0;i < count;i++){
  38557. var renderElement=this._renderElements[i];
  38558. if (!renderElement){
  38559. var material=this.sharedMaterials[i];
  38560. renderElement=this._renderElements[i]=new RenderElement();
  38561. renderElement.setTransform(this._owner._transform);
  38562. renderElement.render=this;
  38563. renderElement.material=material ? material :BlinnPhongMaterial.defaultMaterial;
  38564. }
  38565. renderElement.setGeometry(mesh._getSubMesh(i));
  38566. }
  38567. }
  38568. /**
  38569. *@inheritDoc
  38570. */
  38571. __proto._renderUpdate=function(context,transform){
  38572. if (this._cacheAnimator){
  38573. this._computeSkinnedData();
  38574. if (this._cacheRootBone){
  38575. this._shaderValues.setMatrix4x4(Sprite3D.WORLDMATRIX,Matrix4x4.DEFAULT);
  38576. }else {
  38577. var aniOwnerTrans=(this._cacheAnimator.owner)._transform;
  38578. this._shaderValues.setMatrix4x4(Sprite3D.WORLDMATRIX,aniOwnerTrans.worldMatrix);
  38579. }
  38580. }else {
  38581. this._shaderValues.setMatrix4x4(Sprite3D.WORLDMATRIX,transform.worldMatrix);
  38582. }
  38583. }
  38584. /**
  38585. *@inheritDoc
  38586. */
  38587. __proto._renderUpdateWithCamera=function(context,transform){
  38588. var projectionView=context.projectionViewMatrix;
  38589. if (this._cacheRootBone){
  38590. this._shaderValues.setMatrix4x4(Sprite3D.MVPMATRIX,projectionView);
  38591. }else {
  38592. if (this._cacheAnimator){
  38593. var aniOwnerTrans=(this._cacheAnimator.owner)._transform;
  38594. Matrix4x4.multiply(projectionView,aniOwnerTrans.worldMatrix,this._projectionViewWorldMatrix);
  38595. }else {
  38596. Matrix4x4.multiply(projectionView,transform.worldMatrix,this._projectionViewWorldMatrix);
  38597. }
  38598. this._shaderValues.setMatrix4x4(Sprite3D.MVPMATRIX,this._projectionViewWorldMatrix);
  38599. }
  38600. }
  38601. /**
  38602. *@inheritDoc
  38603. */
  38604. __proto._destroy=function(){
  38605. _super.prototype._destroy.call(this);
  38606. if (this._cacheRootBone){
  38607. this._cacheRootBone.transform.off(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this,this._boundChange);
  38608. }else {
  38609. if (this._cacheRootAnimationNode)
  38610. this._cacheRootAnimationNode.transform.off(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this,this._boundChange);
  38611. }
  38612. }
  38613. /**
  38614. *@private
  38615. */
  38616. __proto._setRootBone=function(name){
  38617. this._rootBone=name;
  38618. this._setRootNode();
  38619. }
  38620. /**
  38621. *@private
  38622. */
  38623. __proto._setRootNode=function(){
  38624. var rootNode;
  38625. if (this._cacheAnimator && this._rootBone && this._cacheAvatar)
  38626. rootNode=this._cacheAnimator._avatarNodeMap[this._rootBone];
  38627. else
  38628. rootNode=null;
  38629. if (this._cacheRootAnimationNode !=rootNode){
  38630. this._boundChange();
  38631. if (this._cacheRootAnimationNode)
  38632. this._cacheRootAnimationNode.transform.off(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this,this._boundChange);
  38633. (rootNode)&&(rootNode.transform.on(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this,this._boundChange));
  38634. this._cacheRootAnimationNode=rootNode;
  38635. }
  38636. }
  38637. /**
  38638. *@private
  38639. */
  38640. __proto._getCacheAnimationNodes=function(){
  38641. var meshBoneNames=this._cacheMesh._boneNames;
  38642. var bindPoseIndices=this._cacheMesh._bindPoseIndices;
  38643. var innerBindPoseCount=bindPoseIndices.length;
  38644. if (!Render.supportWebGLPlusAnimation){
  38645. this._cacheAnimationNode.length=innerBindPoseCount;
  38646. var nodeMap=this._cacheAnimator._avatarNodeMap;
  38647. for (var i=0;i < innerBindPoseCount;i++){
  38648. var node=nodeMap[meshBoneNames[bindPoseIndices[i]]];
  38649. this._cacheAnimationNode[i]=node;
  38650. }
  38651. }else {
  38652. this._cacheAnimationNodeIndices=new Uint16Array(innerBindPoseCount);
  38653. var nodeMapC=this._cacheAnimator._avatarNodeMap;
  38654. for (i=0;i < innerBindPoseCount;i++){
  38655. var nodeC=nodeMapC[meshBoneNames[bindPoseIndices[i]]];
  38656. this._cacheAnimationNodeIndices[i]=nodeC._worldMatrixIndex;
  38657. }
  38658. }
  38659. }
  38660. /**
  38661. *@private
  38662. */
  38663. __proto._setCacheAvatar=function(value){
  38664. if (this._cacheAvatar!==value){
  38665. if (this._cacheMesh){
  38666. this._cacheAvatar=value;
  38667. if (value){
  38668. this._defineDatas.add(SkinnedMeshSprite3D.SHADERDEFINE_BONE);
  38669. this._getCacheAnimationNodes();
  38670. }
  38671. }else {
  38672. this._cacheAvatar=value;
  38673. }
  38674. this._setRootNode();
  38675. }
  38676. }
  38677. /**
  38678. *@private [NATIVE]
  38679. */
  38680. __proto._computeSubSkinnedDataNative=function(worldMatrixs,cacheAnimationNodeIndices,inverseBindPosesBuffer,boneIndices,bindPoseInices,data){
  38681. LayaGL.instance.computeSubSkinnedData(worldMatrixs,cacheAnimationNodeIndices,inverseBindPosesBuffer,boneIndices,bindPoseInices,data);
  38682. }
  38683. /**
  38684. *设置局部边界。
  38685. *@param value 边界
  38686. */
  38687. /**
  38688. *获取局部边界。
  38689. *@return 边界。
  38690. */
  38691. __getset(0,__proto,'localBounds',function(){
  38692. return this._localBounds;
  38693. },function(value){
  38694. this._localBounds=value;
  38695. });
  38696. /**
  38697. *设置根节点。
  38698. *@param value 根节点。
  38699. */
  38700. /**
  38701. *获取根节点。
  38702. *@return 根节点。
  38703. */
  38704. __getset(0,__proto,'rootBone',function(){
  38705. return this._cacheRootBone;
  38706. },function(value){
  38707. if (this._cacheRootBone !=value){
  38708. if (this._cacheRootBone)
  38709. this._cacheRootBone.transform.off(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this,this._boundChange);
  38710. value.transform.on(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this,this._boundChange);
  38711. this._cacheRootBone=value;
  38712. this._boundChange();
  38713. }
  38714. });
  38715. /**
  38716. *用于蒙皮的骨骼。
  38717. */
  38718. __getset(0,__proto,'bones',function(){
  38719. return this._bones;
  38720. });
  38721. __getset(0,__proto,'bounds',function(){
  38722. if (this._boundsChange || this._cacheAvatar){
  38723. this._calculateBoundingBox();
  38724. this._boundsChange=false;
  38725. }
  38726. return this._bounds;
  38727. });
  38728. __static(SkinnedMeshRenderer,
  38729. ['_tempMatrix4x4',function(){return this._tempMatrix4x4=new Matrix4x4();}
  38730. ]);
  38731. return SkinnedMeshRenderer;
  38732. })(MeshRenderer)
  38733. /**
  38734. *<code>PhysicsCollider</code> 类用于创建物理碰撞器。
  38735. */
  38736. //class laya.d3.physics.PhysicsCollider extends laya.d3.physics.PhysicsTriggerComponent
  38737. var PhysicsCollider=(function(_super){
  38738. /**
  38739. *创建一个 <code>PhysicsCollider</code> 实例。
  38740. *@param collisionGroup 所属碰撞组。
  38741. *@param canCollideWith 可产生碰撞的碰撞组。
  38742. */
  38743. function PhysicsCollider(collisionGroup,canCollideWith){
  38744. (collisionGroup===void 0)&& (collisionGroup=/*laya.d3.utils.Physics3DUtils.COLLISIONFILTERGROUP_DEFAULTFILTER*/0x1);
  38745. (canCollideWith===void 0)&& (canCollideWith=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  38746. PhysicsCollider.__super.call(this,collisionGroup,canCollideWith);
  38747. }
  38748. __class(PhysicsCollider,'laya.d3.physics.PhysicsCollider',_super);
  38749. var __proto=PhysicsCollider.prototype;
  38750. /**
  38751. *@inheritDoc
  38752. */
  38753. __proto._addToSimulation=function(){
  38754. this._simulation._addPhysicsCollider(this,this._collisionGroup,this._canCollideWith);
  38755. }
  38756. /**
  38757. *@inheritDoc
  38758. */
  38759. __proto._removeFromSimulation=function(){
  38760. this._simulation._removePhysicsCollider(this);
  38761. }
  38762. /**
  38763. *@inheritDoc
  38764. */
  38765. __proto._onTransformChanged=function(flag){
  38766. flag &=/*laya.d3.core.Transform3D.TRANSFORM_WORLDPOSITION*/0x08 | /*laya.d3.core.Transform3D.TRANSFORM_WORLDQUATERNION*/0x10 | /*laya.d3.core.Transform3D.TRANSFORM_WORLDSCALE*/0x20;
  38767. if (flag){
  38768. this._transformFlag |=flag;
  38769. if (this._isValid()&& this._inPhysicUpdateListIndex===-1)
  38770. this._simulation._physicsUpdateList.add(this);
  38771. }
  38772. }
  38773. /**
  38774. *@inheritDoc
  38775. */
  38776. __proto._parse=function(data){
  38777. (data.friction !=null)&& (this.friction=data.friction);
  38778. (data.rollingFriction !=null)&& (this.rollingFriction=data.rollingFriction);
  38779. (data.restitution !=null)&& (this.restitution=data.restitution);
  38780. (data.isTrigger !=null)&& (this.isTrigger=data.isTrigger);
  38781. laya.d3.physics.PhysicsComponent.prototype._parse.call(this,data);
  38782. this._parseShape(data.shapes);
  38783. }
  38784. /**
  38785. *@inheritDoc
  38786. */
  38787. __proto._onAdded=function(){
  38788. var physics3D=Laya3D._physics3D;
  38789. var btColObj=new physics3D.btCollisionObject();
  38790. btColObj.setUserIndex(this.id);
  38791. btColObj.forceActivationState(5);
  38792. var flags=btColObj.getCollisionFlags();
  38793. if ((this.owner).isStatic){
  38794. if ((flags & 2)> 0)
  38795. flags=flags ^ 2;
  38796. flags=flags | 1;
  38797. }else {
  38798. if ((flags & 1)> 0)
  38799. flags=flags ^ 1;
  38800. flags=flags | 2;
  38801. }
  38802. btColObj.setCollisionFlags(flags);
  38803. this._nativeColliderObject=btColObj;
  38804. _super.prototype._onAdded.call(this);
  38805. }
  38806. return PhysicsCollider;
  38807. })(PhysicsTriggerComponent)
  38808. /**
  38809. *<code>Rigidbody3D</code> 类用于创建刚体碰撞器。
  38810. */
  38811. //class laya.d3.physics.Rigidbody3D extends laya.d3.physics.PhysicsTriggerComponent
  38812. var Rigidbody3D=(function(_super){
  38813. function Rigidbody3D(collisionGroup,canCollideWith){
  38814. /**@private */
  38815. //this._nativeMotionState=null;
  38816. /**@private */
  38817. this._isKinematic=false;
  38818. /**@private */
  38819. this._mass=1.0;
  38820. /**@private */
  38821. this._angularDamping=0.0;
  38822. /**@private */
  38823. this._linearDamping=0.0;
  38824. /**@private */
  38825. this._overrideGravity=false;
  38826. /**@private */
  38827. this._detectCollisions=true;
  38828. this._gravity=new Vector3(0,-10,0);
  38829. this._totalTorque=new Vector3(0,0,0);
  38830. this._linearVelocity=new Vector3();
  38831. this._angularVelocity=new Vector3();
  38832. this._linearFactor=new Vector3(1,1,1);
  38833. this._angularFactor=new Vector3(1,1,1);
  38834. (collisionGroup===void 0)&& (collisionGroup=/*laya.d3.utils.Physics3DUtils.COLLISIONFILTERGROUP_DEFAULTFILTER*/0x1);
  38835. (canCollideWith===void 0)&& (canCollideWith=Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER);
  38836. Rigidbody3D.__super.call(this,collisionGroup,canCollideWith);
  38837. }
  38838. __class(Rigidbody3D,'laya.d3.physics.Rigidbody3D',_super);
  38839. var __proto=Rigidbody3D.prototype;
  38840. /**
  38841. *@private
  38842. */
  38843. __proto._updateMass=function(mass){
  38844. if (this._nativeColliderObject && this._colliderShape){
  38845. this._colliderShape._nativeShape.calculateLocalInertia(mass,Rigidbody3D._nativeInertia);
  38846. this._nativeColliderObject.setMassProps(mass,Rigidbody3D._nativeInertia);
  38847. this._nativeColliderObject.updateInertiaTensor();
  38848. }
  38849. }
  38850. /**
  38851. *@private
  38852. *Dynamic刚体,初始化时调用一次。
  38853. *Kinematic刚体,每次物理tick时调用(如果未进入睡眠状态),让物理引擎知道刚体位置。
  38854. */
  38855. __proto._delegateMotionStateGetWorldTransform=function(worldTransPointer){}
  38856. /**
  38857. *@private
  38858. *Dynamic刚体,物理引擎每帧调用一次,用于更新渲染矩阵。
  38859. */
  38860. __proto._delegateMotionStateSetWorldTransform=function(worldTransPointer){
  38861. var rigidBody=/*__JS__ */this._rigidbody;
  38862. rigidBody._simulation._updatedRigidbodies++;
  38863. var physics3D=Laya3D._physics3D;
  38864. var worldTrans=physics3D.wrapPointer(worldTransPointer,physics3D.btTransform);
  38865. rigidBody._updateTransformComponent(worldTrans);
  38866. }
  38867. /**
  38868. *@private
  38869. *Dynamic刚体,初始化时调用一次。
  38870. *Kinematic刚体,每次物理tick时调用(如果未进入睡眠状态),让物理引擎知道刚体位置。
  38871. *该函数只有在runtime下调用
  38872. */
  38873. __proto._delegateMotionStateGetWorldTransformNative=function(ridgidBody3D,worldTransPointer){}
  38874. /**
  38875. *@private
  38876. *Dynamic刚体,物理引擎每帧调用一次,用于更新渲染矩阵。
  38877. *该函数只有在runtime下调用
  38878. */
  38879. __proto._delegateMotionStateSetWorldTransformNative=function(rigidBody3D,worldTransPointer){
  38880. var rigidBody=rigidBody3D;
  38881. rigidBody._simulation._updatedRigidbodies++;
  38882. var physics3D=Laya3D._physics3D;
  38883. var worldTrans=physics3D.wrapPointer(worldTransPointer,physics3D.btTransform);
  38884. rigidBody._updateTransformComponent(worldTrans);
  38885. }
  38886. /**
  38887. *@inheritDoc
  38888. */
  38889. __proto._onScaleChange=function(scale){
  38890. laya.d3.physics.PhysicsComponent.prototype._onScaleChange.call(this,scale);
  38891. this._updateMass(this._isKinematic ? 0 :this._mass);
  38892. }
  38893. /**
  38894. *@private
  38895. */
  38896. __proto._delegateMotionStateClear=function(){
  38897. /*__JS__ */this._rigidbody=null;
  38898. }
  38899. /**
  38900. *@inheritDoc
  38901. */
  38902. __proto._onAdded=function(){
  38903. var physics3D=Laya3D._physics3D;
  38904. var motionState=new physics3D.LayaMotionState();
  38905. var isConchApp=/*__JS__ */(window.conch !=null);
  38906. if (isConchApp && physics3D.LayaMotionState.prototype.setRigidbody){
  38907. motionState.setRigidbody(this);
  38908. motionState.setNativeGetWorldTransform(this._delegateMotionStateGetWorldTransformNative);
  38909. motionState.setNativeSetWorldTransform(this._delegateMotionStateSetWorldTransformNative);
  38910. }else {
  38911. motionState.getWorldTransform=this._delegateMotionStateGetWorldTransform;
  38912. motionState.setWorldTransform=this._delegateMotionStateSetWorldTransform;
  38913. }
  38914. motionState.clear=this._delegateMotionStateClear;
  38915. motionState._rigidbody=this;
  38916. this._nativeMotionState=motionState;
  38917. var constructInfo=new physics3D.btRigidBodyConstructionInfo(0.0,motionState,null,Rigidbody3D._nativeVector3Zero);
  38918. var btRigid=new physics3D.btRigidBody(constructInfo);
  38919. btRigid.setUserIndex(this.id);
  38920. this._nativeColliderObject=btRigid;
  38921. _super.prototype._onAdded.call(this);
  38922. this.mass=this._mass;
  38923. this.linearFactor=this._linearFactor;
  38924. this.angularFactor=this._angularFactor;
  38925. this.linearDamping=this._linearDamping;
  38926. this.angularDamping=this._angularDamping;
  38927. this.overrideGravity=this._overrideGravity;
  38928. this.gravity=this._gravity;
  38929. this.isKinematic=this._isKinematic;
  38930. physics3D.destroy(constructInfo);
  38931. }
  38932. /**
  38933. *@inheritDoc
  38934. */
  38935. __proto._onShapeChange=function(colShape){
  38936. laya.d3.physics.PhysicsComponent.prototype._onShapeChange.call(this,colShape);
  38937. if (this._isKinematic){
  38938. this._updateMass(0);
  38939. }else {
  38940. this._nativeColliderObject.setCenterOfMassTransform(this._nativeColliderObject.getWorldTransform());
  38941. this._updateMass(this._mass);
  38942. }
  38943. }
  38944. /**
  38945. *@inheritDoc
  38946. */
  38947. __proto._parse=function(data){
  38948. (data.friction !=null)&& (this.friction=data.friction);
  38949. (data.rollingFriction !=null)&& (this.rollingFriction=data.rollingFriction);
  38950. (data.restitution !=null)&& (this.restitution=data.restitution);
  38951. (data.isTrigger !=null)&& (this.isTrigger=data.isTrigger);
  38952. (data.mass !=null)&& (this.mass=data.mass);
  38953. (data.isKinematic !=null)&& (this.isKinematic=data.isKinematic);
  38954. (data.linearDamping !=null)&& (this.linearDamping=data.linearDamping);
  38955. (data.angularDamping !=null)&& (this.angularDamping=data.angularDamping);
  38956. (data.overrideGravity !=null)&& (this.overrideGravity=data.overrideGravity);
  38957. if (data.gravity){
  38958. this.gravity.fromArray(data.gravity);
  38959. this.gravity=this.gravity;
  38960. }
  38961. laya.d3.physics.PhysicsComponent.prototype._parse.call(this,data);
  38962. this._parseShape(data.shapes);
  38963. }
  38964. /**
  38965. *@inheritDoc
  38966. */
  38967. __proto._onDestroy=function(){
  38968. var physics3D=Laya3D._physics3D;
  38969. this._nativeMotionState.clear();
  38970. physics3D.destroy(this._nativeMotionState);
  38971. laya.d3.physics.PhysicsComponent.prototype._onDestroy.call(this);
  38972. this._nativeMotionState=null;
  38973. this._gravity=null;
  38974. this._totalTorque=null;
  38975. this._linearVelocity=null;
  38976. this._angularVelocity=null;
  38977. this._linearFactor=null;
  38978. this._angularFactor=null;
  38979. }
  38980. /**
  38981. *@inheritDoc
  38982. */
  38983. __proto._addToSimulation=function(){
  38984. this._simulation._addRigidBody(this,this._collisionGroup,this._detectCollisions ? this._canCollideWith :0);
  38985. }
  38986. /**
  38987. *@inheritDoc
  38988. */
  38989. __proto._removeFromSimulation=function(){
  38990. this._simulation._removeRigidBody(this);
  38991. }
  38992. /**
  38993. *@inheritDoc
  38994. */
  38995. __proto._cloneTo=function(dest){
  38996. _super.prototype._cloneTo.call(this,dest);
  38997. var destRigidbody3D=dest;
  38998. destRigidbody3D.isKinematic=this._isKinematic;
  38999. destRigidbody3D.mass=this._mass;
  39000. destRigidbody3D.gravity=this._gravity;
  39001. destRigidbody3D.angularDamping=this._angularDamping;
  39002. destRigidbody3D.linearDamping=this._linearDamping;
  39003. destRigidbody3D.overrideGravity=this._overrideGravity;
  39004. destRigidbody3D.linearVelocity=this._linearVelocity;
  39005. destRigidbody3D.angularVelocity=this._angularVelocity;
  39006. destRigidbody3D.linearFactor=this._linearFactor;
  39007. destRigidbody3D.angularFactor=this._angularFactor;
  39008. destRigidbody3D.detectCollisions=this._detectCollisions;
  39009. }
  39010. /**
  39011. *应用作用力。
  39012. *@param force 作用力。
  39013. *@param localOffset 偏移,如果为null则为中心点
  39014. */
  39015. __proto.applyForce=function(force,localOffset){
  39016. if (this._nativeColliderObject==null)
  39017. throw "Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";
  39018. var nativeForce=Rigidbody3D._nativeTempVector30;
  39019. nativeForce.setValue(-force.x,force.y,force.z);
  39020. if (localOffset){
  39021. var nativeOffset=Rigidbody3D._nativeTempVector31;
  39022. nativeOffset.setValue(-localOffset.x,localOffset.y,localOffset.z);
  39023. this._nativeColliderObject.applyForce(nativeForce,nativeOffset);
  39024. }else {
  39025. this._nativeColliderObject.applyCentralForce(nativeForce);
  39026. }
  39027. }
  39028. /**
  39029. *应用扭转力。
  39030. *@param torque 扭转力。
  39031. */
  39032. __proto.applyTorque=function(torque){
  39033. if (this._nativeColliderObject==null)
  39034. throw "Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";
  39035. var nativeTorque=Rigidbody3D._nativeTempVector30;
  39036. nativeTorque.setValue(-torque.x,torque.y,torque.z);
  39037. this._nativeColliderObject.applyTorque(nativeTorque);
  39038. }
  39039. /**
  39040. *应用冲量。
  39041. *@param impulse 冲量。
  39042. *@param localOffset 偏移,如果为null则为中心点。
  39043. */
  39044. __proto.applyImpulse=function(impulse,localOffset){
  39045. if (this._nativeColliderObject==null)
  39046. throw "Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";
  39047. Rigidbody3D._nativeImpulse.setValue(-impulse.x,impulse.y,impulse.z);
  39048. if (localOffset){
  39049. Rigidbody3D._nativeImpulseOffset.setValue(-localOffset.x,localOffset.y,localOffset.z);
  39050. this._nativeColliderObject.applyImpulse(Rigidbody3D._nativeImpulse,Rigidbody3D._nativeImpulseOffset);
  39051. }else {
  39052. this._nativeColliderObject.applyCentralImpulse(Rigidbody3D._nativeImpulse);
  39053. }
  39054. }
  39055. /**
  39056. *应用扭转冲量。
  39057. *@param torqueImpulse
  39058. */
  39059. __proto.applyTorqueImpulse=function(torqueImpulse){
  39060. if (this._nativeColliderObject==null)
  39061. throw "Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";
  39062. var nativeTorqueImpulse=Rigidbody3D._nativeTempVector30;
  39063. nativeTorqueImpulse.setValue(-torqueImpulse.x,torqueImpulse.y,torqueImpulse.z);
  39064. this._nativeColliderObject.applyTorqueImpulse(nativeTorqueImpulse);
  39065. }
  39066. /**
  39067. *唤醒刚体。
  39068. */
  39069. __proto.wakeUp=function(){
  39070. this._nativeColliderObject && (this._nativeColliderObject.activate(false));
  39071. }
  39072. /**
  39073. *清除应用到刚体上的所有力。
  39074. */
  39075. __proto.clearForces=function(){
  39076. var rigidBody=this._nativeColliderObject;
  39077. if (rigidBody==null)
  39078. throw "Attempted to call a Physics function that is avaliable only when the Entity has been already added to the Scene.";
  39079. rigidBody.clearForces();
  39080. var nativeZero=Rigidbody3D._nativeVector3Zero;
  39081. rigidBody.setInterpolationAngularVelocity(nativeZero);
  39082. rigidBody.setLinearVelocity(nativeZero);
  39083. rigidBody.setInterpolationAngularVelocity(nativeZero);
  39084. rigidBody.setAngularVelocity(nativeZero);
  39085. }
  39086. /**
  39087. *设置刚体的角阻力。
  39088. *@param value 角阻力。
  39089. */
  39090. /**
  39091. *获取刚体的角阻力。
  39092. *@return 角阻力。
  39093. */
  39094. __getset(0,__proto,'angularDamping',function(){
  39095. return this._angularDamping;
  39096. },function(value){
  39097. this._angularDamping=value;
  39098. if (this._nativeColliderObject)
  39099. this._nativeColliderObject.setDamping(this._linearDamping,value);
  39100. });
  39101. /**
  39102. *设置质量。
  39103. *@param value 质量。
  39104. */
  39105. /**
  39106. *获取质量。
  39107. *@return 质量。
  39108. */
  39109. __getset(0,__proto,'mass',function(){
  39110. return this._mass;
  39111. },function(value){
  39112. value=Math.max(value,1e-07);
  39113. this._mass=value;
  39114. (this._isKinematic)|| (this._updateMass(value));
  39115. });
  39116. /**
  39117. *设置刚体的线阻力。
  39118. *@param value 线阻力。
  39119. */
  39120. /**
  39121. *获取刚体的线阻力。
  39122. *@return 线阻力。
  39123. */
  39124. __getset(0,__proto,'linearDamping',function(){
  39125. return this._linearDamping;
  39126. },function(value){
  39127. this._linearDamping=value;
  39128. if (this._nativeColliderObject)
  39129. this._nativeColliderObject.setDamping(value,this._angularDamping);
  39130. });
  39131. /**
  39132. *设置是否为运动物体,如果为true仅可通过transform属性移动物体,而非其他力相关属性。
  39133. *@param value 是否为运动物体。
  39134. */
  39135. /**
  39136. *获取是否为运动物体,如果为true仅可通过transform属性移动物体,而非其他力相关属性。
  39137. *@return 是否为运动物体。
  39138. */
  39139. __getset(0,__proto,'isKinematic',function(){
  39140. return this._isKinematic;
  39141. },function(value){
  39142. this._isKinematic=value;
  39143. var canInSimulation=!!(this._simulation && this._enabled && this._colliderShape);
  39144. canInSimulation && this._removeFromSimulation();
  39145. var natColObj=this._nativeColliderObject;
  39146. var flags=natColObj.getCollisionFlags();
  39147. if (value){
  39148. flags=flags | 2;
  39149. natColObj.setCollisionFlags(flags);
  39150. this._nativeColliderObject.forceActivationState(4);
  39151. this._enableProcessCollisions=false;
  39152. this._updateMass(0);
  39153. }else {
  39154. if ((flags & 2)> 0)
  39155. flags=flags ^ 2;
  39156. natColObj.setCollisionFlags(flags);
  39157. this._nativeColliderObject.setActivationState(1);
  39158. this._enableProcessCollisions=true;
  39159. this._updateMass(this._mass);
  39160. };
  39161. var nativeZero=Rigidbody3D._nativeVector3Zero;
  39162. natColObj.setInterpolationLinearVelocity(nativeZero);
  39163. natColObj.setLinearVelocity(nativeZero);
  39164. natColObj.setInterpolationAngularVelocity(nativeZero);
  39165. natColObj.setAngularVelocity(nativeZero);
  39166. canInSimulation && this._addToSimulation();
  39167. });
  39168. /**
  39169. *设置重力。
  39170. *@param value 重力。
  39171. */
  39172. /**
  39173. *获取重力。
  39174. *@return 重力。
  39175. */
  39176. __getset(0,__proto,'gravity',function(){
  39177. return this._gravity;
  39178. },function(value){
  39179. this._gravity=value;
  39180. Rigidbody3D._nativeGravity.setValue(-value.x,value.y,value.z);
  39181. this._nativeColliderObject.setGravity(Rigidbody3D._nativeGravity);
  39182. });
  39183. /**
  39184. *设置是否重载重力。
  39185. *@param value 是否重载重力。
  39186. */
  39187. /**
  39188. *获取是否重载重力。
  39189. *@return 是否重载重力。
  39190. */
  39191. __getset(0,__proto,'overrideGravity',function(){
  39192. return this._overrideGravity;
  39193. },function(value){
  39194. this._overrideGravity=value;
  39195. if (this._nativeColliderObject){
  39196. var flag=this._nativeColliderObject.getFlags();
  39197. if (value){
  39198. if ((flag & 1)===0)
  39199. this._nativeColliderObject.setFlags(flag | 1);
  39200. }else {
  39201. if ((flag & 1)> 0)
  39202. this._nativeColliderObject.setFlags(flag ^ 1);
  39203. }
  39204. }
  39205. });
  39206. /**
  39207. *获取总力。
  39208. */
  39209. __getset(0,__proto,'totalForce',function(){
  39210. if (this._nativeColliderObject)
  39211. return this._nativeColliderObject.getTotalForce();
  39212. return null;
  39213. });
  39214. /**
  39215. *设置线速度。
  39216. *@param 线速度。
  39217. */
  39218. /**
  39219. *获取线速度
  39220. *@return 线速度
  39221. */
  39222. __getset(0,__proto,'linearVelocity',function(){
  39223. if (this._nativeColliderObject)
  39224. Utils3D._convertToLayaVec3(this._nativeColliderObject.getLinearVelocity(),this._linearVelocity,true);
  39225. return this._linearVelocity;
  39226. },function(value){
  39227. this._linearVelocity=value;
  39228. if (this._nativeColliderObject){
  39229. var nativeValue=Rigidbody3D._nativeTempVector30;
  39230. Utils3D._convertToBulletVec3(value,nativeValue,true);
  39231. (this.isSleeping)&& (this.wakeUp());
  39232. this._nativeColliderObject.setLinearVelocity(nativeValue);
  39233. }
  39234. });
  39235. /**
  39236. *设置是否进行碰撞检测。
  39237. *@param value 是否进行碰撞检测。
  39238. */
  39239. /**
  39240. *获取是否进行碰撞检测。
  39241. *@return 是否进行碰撞检测。
  39242. */
  39243. __getset(0,__proto,'detectCollisions',function(){
  39244. return this._detectCollisions;
  39245. },function(value){
  39246. if (this._detectCollisions!==value){
  39247. this._detectCollisions=value;
  39248. if (this._colliderShape && this._enabled && this._simulation){
  39249. this._simulation._removeRigidBody(this);
  39250. this._simulation._addRigidBody(this,this._collisionGroup,value ? this._canCollideWith :0);
  39251. }
  39252. }
  39253. });
  39254. /**
  39255. *设置性因子。
  39256. */
  39257. /**
  39258. *获取性因子。
  39259. */
  39260. __getset(0,__proto,'linearFactor',function(){
  39261. if (this._nativeColliderObject)
  39262. return this._linearFactor;
  39263. return null;
  39264. },function(value){
  39265. this._linearFactor=value;
  39266. if (this._nativeColliderObject){
  39267. var nativeValue=Rigidbody3D._nativeTempVector30;
  39268. Utils3D._convertToBulletVec3(value,nativeValue,false);
  39269. this._nativeColliderObject.setLinearFactor(nativeValue);
  39270. }
  39271. });
  39272. /**
  39273. *设置角因子。
  39274. */
  39275. /**
  39276. *获取角因子。
  39277. */
  39278. __getset(0,__proto,'angularFactor',function(){
  39279. if (this._nativeColliderObject)
  39280. return this._angularFactor;
  39281. return null;
  39282. },function(value){
  39283. this._angularFactor=value;
  39284. if (this._nativeColliderObject){
  39285. var nativeValue=Rigidbody3D._nativeTempVector30;
  39286. Utils3D._convertToBulletVec3(value,nativeValue,false);
  39287. this._nativeColliderObject.setAngularFactor(nativeValue);
  39288. }
  39289. });
  39290. /**
  39291. *设置角速度。
  39292. *@param 角速度
  39293. */
  39294. /**
  39295. *获取角速度。
  39296. *@return 角速度。
  39297. */
  39298. __getset(0,__proto,'angularVelocity',function(){
  39299. if (this._nativeColliderObject)
  39300. Utils3D._convertToLayaVec3(this._nativeColliderObject.getAngularVelocity(),this._angularVelocity,true);
  39301. return this._angularVelocity;
  39302. },function(value){
  39303. this._angularVelocity=value;
  39304. if (this._nativeColliderObject){
  39305. var nativeValue=Rigidbody3D._nativeTempVector30;
  39306. Utils3D._convertToBulletVec3(value,nativeValue,true);
  39307. (this.isSleeping)&& (this.wakeUp());
  39308. this._nativeColliderObject.setAngularVelocity(nativeValue);
  39309. }
  39310. });
  39311. /**
  39312. *获取刚体所有扭力。
  39313. */
  39314. __getset(0,__proto,'totalTorque',function(){
  39315. if (this._nativeColliderObject){
  39316. var nativeTotalTorque=this._nativeColliderObject.getTotalTorque();
  39317. var totalTorque=this._totalTorque;
  39318. totalTorque.x=-nativeTotalTorque.x;
  39319. totalTorque.y=nativeTotalTorque.y;
  39320. totalTorque.z=nativeTotalTorque.z;
  39321. }
  39322. return null;
  39323. });
  39324. /**
  39325. *获取是否处于睡眠状态。
  39326. *@return 是否处于睡眠状态。
  39327. */
  39328. __getset(0,__proto,'isSleeping',function(){
  39329. if (this._nativeColliderObject)
  39330. return this._nativeColliderObject.getActivationState()===/*laya.d3.physics.PhysicsComponent.ACTIVATIONSTATE_ISLAND_SLEEPING*/2;
  39331. return false;
  39332. });
  39333. /**
  39334. *设置刚体睡眠的线速度阈值。
  39335. *@param value 刚体睡眠的线速度阈值。
  39336. */
  39337. /**
  39338. *获取刚体睡眠的线速度阈值。
  39339. *@return 刚体睡眠的线速度阈值。
  39340. */
  39341. __getset(0,__proto,'sleepLinearVelocity',function(){
  39342. return this._nativeColliderObject.getLinearSleepingThreshold();
  39343. },function(value){
  39344. this._nativeColliderObject.setSleepingThresholds(value,this._nativeColliderObject.getAngularSleepingThreshold());
  39345. });
  39346. /**
  39347. *设置刚体睡眠的角速度阈值。
  39348. *@param value 刚体睡眠的角速度阈值。
  39349. */
  39350. /**
  39351. *获取刚体睡眠的角速度阈值。
  39352. *@return 刚体睡眠的角速度阈值。
  39353. */
  39354. __getset(0,__proto,'sleepAngularVelocity',function(){
  39355. return this._nativeColliderObject.getAngularSleepingThreshold();
  39356. },function(value){
  39357. this._nativeColliderObject.setSleepingThresholds(this._nativeColliderObject.getLinearSleepingThreshold(),value);
  39358. });
  39359. Rigidbody3D.TYPE_STATIC=0;
  39360. Rigidbody3D.TYPE_DYNAMIC=1;
  39361. Rigidbody3D.TYPE_KINEMATIC=2;
  39362. Rigidbody3D._BT_DISABLE_WORLD_GRAVITY=1;
  39363. Rigidbody3D._BT_ENABLE_GYROPSCOPIC_FORCE=2;
  39364. __static(Rigidbody3D,
  39365. ['_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);}
  39366. ]);
  39367. return Rigidbody3D;
  39368. })(PhysicsTriggerComponent)
  39369. /**
  39370. *<code>TextureCube</code> 类用于生成立方体纹理。
  39371. */
  39372. //class laya.d3.resource.TextureCube extends laya.resource.BaseTexture
  39373. var TextureCube=(function(_super){
  39374. function TextureCube(format,mipmap){
  39375. /**@private */
  39376. //this._premultiplyAlpha=0;
  39377. (format===void 0)&& (format=0);
  39378. (mipmap===void 0)&& (mipmap=false);
  39379. TextureCube.__super.call(this,format,mipmap);
  39380. this._glTextureType=/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP*/0x8513;
  39381. }
  39382. __class(TextureCube,'laya.d3.resource.TextureCube',_super);
  39383. var __proto=TextureCube.prototype;
  39384. /**
  39385. *通过六张图片源填充纹理。
  39386. *@param 图片源数组。
  39387. */
  39388. __proto.setSixSideImageSources=function(source,premultiplyAlpha){
  39389. (premultiplyAlpha===void 0)&& (premultiplyAlpha=false);
  39390. var width=0;
  39391. var height=0;
  39392. for (var i=0;i < 6;i++){
  39393. var img=source[i];
  39394. if (!img){
  39395. console.log("TextureCube: image Source can't be null.");
  39396. return;
  39397. };
  39398. var nextWidth=img.width;
  39399. var nextHeight=img.height;
  39400. if (i > 0){
  39401. if (width!==nextWidth){
  39402. console.log("TextureCube: each side image's width and height must same.");
  39403. return;
  39404. }
  39405. }
  39406. width=nextWidth;
  39407. height=nextHeight;
  39408. if (width!==height){
  39409. console.log("TextureCube: each side image's width and height must same.");
  39410. return;
  39411. }
  39412. }
  39413. this._width=width;
  39414. this._height=height;
  39415. var gl=LayaGL.instance;
  39416. WebGLContext.bindTexture(gl,this._glTextureType,this._glTexture);
  39417. var glFormat=this._getGLFormat();
  39418. if (!Render.isConchApp){
  39419. (premultiplyAlpha)&& (gl.pixelStorei(/*laya.webgl.WebGLContext.UNPACK_PREMULTIPLY_ALPHA_WEBGL*/0x9241,true));
  39420. gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_POSITIVE_Z*/0x8519,0,glFormat,glFormat,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,source[0]);
  39421. gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_NEGATIVE_Z*/0x851A,0,glFormat,glFormat,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,source[1]);
  39422. gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_POSITIVE_X*/0x8515,0,glFormat,glFormat,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,source[2]);
  39423. gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_NEGATIVE_X*/0x8516,0,glFormat,glFormat,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,source[3]);
  39424. gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_POSITIVE_Y*/0x8517,0,glFormat,glFormat,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,source[4]);
  39425. gl.texImage2D(/*laya.webgl.WebGLContext.TEXTURE_CUBE_MAP_NEGATIVE_Y*/0x8518,0,glFormat,glFormat,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,source[5]);
  39426. (premultiplyAlpha)&& (gl.pixelStorei(/*laya.webgl.WebGLContext.UNPACK_PREMULTIPLY_ALPHA_WEBGL*/0x9241,false));
  39427. }else {
  39428. if (premultiplyAlpha==true){
  39429. for (var j=0;j < 6;j++)
  39430. source[j].setPremultiplyAlpha(premultiplyAlpha);
  39431. }
  39432. 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]);
  39433. 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]);
  39434. 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]);
  39435. 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]);
  39436. 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]);
  39437. 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]);
  39438. }
  39439. if (this._mipmap && this._isPot(width)&& this._isPot(height)){
  39440. gl.generateMipmap(this._glTextureType);
  39441. this._setGPUMemory(width *height *4 *(1+1 / 3)*6);
  39442. }else {
  39443. this._setGPUMemory(width *height *4 *6);
  39444. }
  39445. this._setWarpMode(/*laya.webgl.WebGLContext.TEXTURE_WRAP_S*/0x2802,this._wrapModeU);
  39446. this._setWarpMode(/*laya.webgl.WebGLContext.TEXTURE_WRAP_T*/0x2803,this._wrapModeV);
  39447. this._setFilterMode(this._filterMode);
  39448. this._readyed=true;
  39449. this._activeResource();
  39450. }
  39451. /**
  39452. *通过六张图片源填充纹理。
  39453. *@param 图片源数组。
  39454. */
  39455. __proto.setSixSidePixels=function(width,height,pixels){
  39456. if (width <=0 || height <=0)
  39457. throw new Error("TextureCube:width or height must large than 0.");
  39458. if (!pixels)
  39459. throw new Error("TextureCube:pixels can't be null.");
  39460. this._width=width;
  39461. this._height=height;
  39462. var gl=LayaGL.instance;
  39463. WebGLContext.bindTexture(gl,this._glTextureType,this._glTexture);
  39464. var glFormat=this._getGLFormat();
  39465. 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]);
  39466. 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]);
  39467. 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]);
  39468. 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]);
  39469. 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]);
  39470. 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]);
  39471. if (this._mipmap && this._isPot(width)&& this._isPot(height)){
  39472. gl.generateMipmap(this._glTextureType);
  39473. this._setGPUMemory(width *height *4 *(1+1 / 3)*6);
  39474. }else {
  39475. this._setGPUMemory(width *height *4 *6);
  39476. }
  39477. this._setWarpMode(/*laya.webgl.WebGLContext.TEXTURE_WRAP_S*/0x2802,this._wrapModeU);
  39478. this._setWarpMode(/*laya.webgl.WebGLContext.TEXTURE_WRAP_T*/0x2803,this._wrapModeV);
  39479. this._setFilterMode(this._filterMode);
  39480. this._readyed=true;
  39481. this._activeResource();
  39482. }
  39483. /**
  39484. *@inheritDoc
  39485. */
  39486. __proto._recoverResource=function(){}
  39487. /**
  39488. *@inheritDoc
  39489. */
  39490. __getset(0,__proto,'defaulteTexture',function(){
  39491. return TextureCube.grayTexture;
  39492. });
  39493. TextureCube.__init__=function(){
  39494. var pixels=new Uint8Array(3);
  39495. pixels[0]=128;
  39496. pixels[1]=128;
  39497. pixels[2]=128;
  39498. TextureCube.grayTexture=new TextureCube(0,false);
  39499. TextureCube.grayTexture.setSixSidePixels(1,1,[pixels,pixels,pixels,pixels,pixels,pixels]);
  39500. TextureCube.grayTexture.lock=true;
  39501. }
  39502. TextureCube._parse=function(data,propertyParams,constructParams){
  39503. var texture=constructParams ? new TextureCube(constructParams[0],constructParams[1]):new TextureCube();
  39504. texture.setSixSideImageSources(data);
  39505. return texture;
  39506. }
  39507. TextureCube.load=function(url,complete){
  39508. Laya.loader.create(url,complete,null,/*Laya3D.TEXTURECUBE*/"TEXTURECUBE");
  39509. }
  39510. TextureCube.grayTexture=null;
  39511. return TextureCube;
  39512. })(BaseTexture)
  39513. /**
  39514. //*<code>RenderTexture</code> 类用于创建渲染目标。
  39515. */
  39516. //class laya.d3.resource.RenderTexture extends laya.resource.BaseTexture
  39517. var RenderTexture=(function(_super){
  39518. function RenderTexture(width,height,format,depthStencilFormat){
  39519. /**@private */
  39520. //this._frameBuffer=null;
  39521. /**@private */
  39522. //this._depthStencilBuffer=null;
  39523. /**@private */
  39524. //this._depthStencilFormat=0;
  39525. (format===void 0)&& (format=0);
  39526. (depthStencilFormat===void 0)&& (depthStencilFormat=/*laya.resource.BaseTexture.FORMAT_DEPTH_16*/0);
  39527. RenderTexture.__super.call(this,format,false);
  39528. this._glTextureType=/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1;
  39529. this._width=width;
  39530. this._height=height;
  39531. this._depthStencilFormat=depthStencilFormat;
  39532. this._create(width,height);
  39533. }
  39534. __class(RenderTexture,'laya.d3.resource.RenderTexture',_super);
  39535. var __proto=RenderTexture.prototype;
  39536. /**
  39537. *@private
  39538. */
  39539. __proto._create=function(width,height){
  39540. var gl=LayaGL.instance;
  39541. this._frameBuffer=gl.createFramebuffer();
  39542. WebGLContext.bindTexture(gl,this._glTextureType,this._glTexture);
  39543. var glFormat=this._getGLFormat();
  39544. gl.texImage2D(this._glTextureType,0,glFormat,width,height,0,glFormat,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,null);
  39545. this._setGPUMemory(width *height *4);
  39546. gl.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,this._frameBuffer);
  39547. gl.framebufferTexture2D(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,/*laya.webgl.WebGLContext.COLOR_ATTACHMENT0*/0x8CE0,/*laya.webgl.WebGLContext.TEXTURE_2D*/0x0DE1,this._glTexture,0);
  39548. if (this._depthStencilFormat!==/*laya.resource.BaseTexture.FORMAT_DEPTHSTENCIL_NONE*/3){
  39549. this._depthStencilBuffer=gl.createRenderbuffer();
  39550. gl.bindRenderbuffer(/*laya.webgl.WebGLContext.RENDERBUFFER*/0x8D41,this._depthStencilBuffer);
  39551. switch (this._depthStencilFormat){
  39552. case /*laya.resource.BaseTexture.FORMAT_DEPTH_16*/0:
  39553. gl.renderbufferStorage(/*laya.webgl.WebGLContext.RENDERBUFFER*/0x8D41,/*laya.webgl.WebGLContext.DEPTH_COMPONENT16*/0x81A5,width,height);
  39554. gl.framebufferRenderbuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,/*laya.webgl.WebGLContext.DEPTH_ATTACHMENT*/0x8D00,/*laya.webgl.WebGLContext.RENDERBUFFER*/0x8D41,this._depthStencilBuffer);
  39555. break ;
  39556. case /*laya.resource.BaseTexture.FORMAT_STENCIL_8*/1:
  39557. gl.renderbufferStorage(/*laya.webgl.WebGLContext.RENDERBUFFER*/0x8D41,/*laya.webgl.WebGLContext.STENCIL_INDEX8*/0x8D48,width,height);
  39558. gl.framebufferRenderbuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,/*laya.webgl.WebGLContext.STENCIL_ATTACHMENT*/0x8D20,/*laya.webgl.WebGLContext.RENDERBUFFER*/0x8D41,this._depthStencilBuffer);
  39559. break ;
  39560. case /*laya.resource.BaseTexture.FORMAT_DEPTHSTENCIL_16_8*/2:
  39561. gl.renderbufferStorage(/*laya.webgl.WebGLContext.RENDERBUFFER*/0x8D41,/*laya.webgl.WebGLContext.DEPTH_STENCIL*/0x84F9,width,height);
  39562. gl.framebufferRenderbuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,/*laya.webgl.WebGLContext.DEPTH_STENCIL_ATTACHMENT*/0x821A,/*laya.webgl.WebGLContext.RENDERBUFFER*/0x8D41,this._depthStencilBuffer);
  39563. break ;
  39564. default :
  39565. throw "RenderTexture: unkonw depth format.";
  39566. }
  39567. }
  39568. gl.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,null);
  39569. gl.bindRenderbuffer(/*laya.webgl.WebGLContext.RENDERBUFFER*/0x8D41,null);
  39570. this._setWarpMode(/*laya.webgl.WebGLContext.TEXTURE_WRAP_S*/0x2802,this._wrapModeU);
  39571. this._setWarpMode(/*laya.webgl.WebGLContext.TEXTURE_WRAP_T*/0x2803,this._wrapModeV);
  39572. this._setFilterMode(this._filterMode);
  39573. this._setAnisotropy(this._anisoLevel);
  39574. this._readyed=true;
  39575. this._activeResource();
  39576. }
  39577. /**
  39578. *@private
  39579. */
  39580. __proto._start=function(){
  39581. LayaGL.instance.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,this._frameBuffer);
  39582. RenderTexture._currentActive=this;
  39583. this._readyed=false;
  39584. }
  39585. /**
  39586. *@private
  39587. */
  39588. __proto._end=function(){
  39589. LayaGL.instance.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,null);
  39590. RenderTexture._currentActive=null;
  39591. this._readyed=true;
  39592. }
  39593. /**
  39594. *获得像素数据。
  39595. *@param x X像素坐标。
  39596. *@param y Y像素坐标。
  39597. *@param width 宽度。
  39598. *@param height 高度。
  39599. *@return 像素数据。
  39600. */
  39601. __proto.getData=function(x,y,width,height,out){
  39602. if (Render.isConchApp && /*__JS__ */conchConfig.threadMode==2){
  39603. throw "native 2 thread mode use getDataAsync";
  39604. };
  39605. var gl=LayaGL.instance;
  39606. gl.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,this._frameBuffer);
  39607. var canRead=(gl.checkFramebufferStatus(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40)===/*laya.webgl.WebGLContext.FRAMEBUFFER_COMPLETE*/0x8CD5);
  39608. if (!canRead){
  39609. gl.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,null);
  39610. return null;
  39611. }
  39612. gl.readPixels(x,y,width,height,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,out);
  39613. gl.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,null);
  39614. return out;
  39615. }
  39616. /**
  39617. *native多线程
  39618. */
  39619. __proto.getDataAsync=function(x,y,width,height,callBack){
  39620. var gl=LayaGL.instance;
  39621. gl.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,this._frameBuffer);
  39622. gl.readPixelsAsync(x,y,width,height,/*laya.webgl.WebGLContext.RGBA*/0x1908,/*laya.webgl.WebGLContext.UNSIGNED_BYTE*/0x1401,function(data){
  39623. /*__JS__ */callBack(new Uint8Array(data));
  39624. });
  39625. gl.bindFramebuffer(/*laya.webgl.WebGLContext.FRAMEBUFFER*/0x8D40,null);
  39626. }
  39627. /**
  39628. *@inheritDoc
  39629. */
  39630. __proto._disposeResource=function(){
  39631. if (this._frameBuffer){
  39632. var gl=LayaGL.instance;
  39633. gl.deleteTexture(this._glTexture);
  39634. gl.deleteFramebuffer(this._frameBuffer);
  39635. gl.deleteRenderbuffer(this._depthStencilBuffer);
  39636. this._glTexture=null;
  39637. this._frameBuffer=null;
  39638. this._depthStencilBuffer=null;
  39639. this._setGPUMemory(0);
  39640. }
  39641. }
  39642. /**
  39643. *获取深度格式。
  39644. *@return 深度格式。
  39645. */
  39646. __getset(0,__proto,'depthStencilFormat',function(){
  39647. return this._depthStencilFormat;
  39648. });
  39649. /**
  39650. *@inheritDoc
  39651. */
  39652. __getset(0,__proto,'defaulteTexture',function(){
  39653. return Texture2D.grayTexture;
  39654. });
  39655. /**
  39656. *获取当前激活的Rendertexture。
  39657. */
  39658. __getset(1,RenderTexture,'currentActive',function(){
  39659. return RenderTexture._currentActive;
  39660. },laya.resource.BaseTexture._$SET_currentActive);
  39661. RenderTexture.getTemporary=function(width,height,format,depthStencilFormat,filterMode){
  39662. (format===void 0)&& (format=/*laya.resource.BaseTexture.FORMAT_R8G8B8*/0);
  39663. (depthStencilFormat===void 0)&& (depthStencilFormat=/*laya.resource.BaseTexture.FORMAT_DEPTH_16*/0);
  39664. (filterMode===void 0)&& (filterMode=/*laya.resource.BaseTexture.FILTERMODE_BILINEAR*/1);
  39665. var key=filterMode *10000000+depthStencilFormat *1000000+format *100000+10000 *height+width;
  39666. var textures=RenderTexture._temporaryMap[key];
  39667. if (!textures || textures && textures.length===0){
  39668. var renderTexture=new RenderTexture(width,height,format,depthStencilFormat);
  39669. renderTexture.filterMode=filterMode;
  39670. return renderTexture;
  39671. }else {
  39672. return textures.pop();
  39673. }
  39674. }
  39675. RenderTexture.setReleaseTemporary=function(renderTexture){
  39676. var key=renderTexture.filterMode *10000000+renderTexture.depthStencilFormat *1000000+renderTexture.format *100000+10000 *renderTexture.height+renderTexture.width;
  39677. var textures=RenderTexture._temporaryMap[key];
  39678. (textures)|| (RenderTexture._temporaryMap[key]=textures=[]);
  39679. textures.push(renderTexture);
  39680. }
  39681. RenderTexture._temporaryMap={};
  39682. RenderTexture._currentActive=null;
  39683. return RenderTexture;
  39684. })(BaseTexture)
  39685. /**
  39686. *<code>TerrainChunk</code> 类用于创建地块。
  39687. */
  39688. //class laya.d3.terrain.TerrainChunk extends laya.d3.core.RenderableSprite3D
  39689. var TerrainChunk=(function(_super){
  39690. function TerrainChunk(chunkOffsetX,chunkOffsetZ,girdSize,terrainHeightData,heightDataWidth,heightDataHeight,cameraCoordinateInverse,name){
  39691. /**@private */
  39692. this._terrainFilter=null;
  39693. TerrainChunk.__super.call(this,name);
  39694. this._terrainFilter=new TerrainFilter(this,chunkOffsetX,chunkOffsetZ,girdSize,terrainHeightData,heightDataWidth,heightDataHeight,cameraCoordinateInverse);
  39695. this._render=new TerrainRender(this);
  39696. }
  39697. __class(TerrainChunk,'laya.d3.terrain.TerrainChunk',_super);
  39698. var __proto=TerrainChunk.prototype;
  39699. __proto.buildRenderElementAndMaterial=function(detailNum,normalMap,alphaMapUrl,detailUrl1,detailUrl2,detailUrl3,detailUrl4,ambientColor,diffuseColor,specularColor,sx1,sy1,sx2,sy2,sx3,sy3,sx4,sy4){
  39700. (sx1===void 0)&& (sx1=1);
  39701. (sy1===void 0)&& (sy1=1);
  39702. (sx2===void 0)&& (sx2=1);
  39703. (sy2===void 0)&& (sy2=1);
  39704. (sx3===void 0)&& (sx3=1);
  39705. (sy3===void 0)&& (sy3=1);
  39706. (sx4===void 0)&& (sx4=1);
  39707. (sy4===void 0)&& (sy4=1);
  39708. var terrainMaterial=new TerrainMaterial();
  39709. if (diffuseColor)terrainMaterial.diffuseColor=diffuseColor;
  39710. if (ambientColor)terrainMaterial.ambientColor=ambientColor;
  39711. if (specularColor)terrainMaterial.specularColor=specularColor;
  39712. terrainMaterial.splatAlphaTexture=Loader.getRes(alphaMapUrl);
  39713. terrainMaterial.normalTexture=normalMap ? Loader.getRes(normalMap):null;
  39714. terrainMaterial.diffuseTexture1=detailUrl1 ? Loader.getRes(detailUrl1):null;
  39715. terrainMaterial.diffuseTexture2=detailUrl2 ? Loader.getRes(detailUrl2):null;
  39716. terrainMaterial.diffuseTexture3=detailUrl3 ? Loader.getRes(detailUrl3):null;
  39717. terrainMaterial.diffuseTexture4=detailUrl4 ? Loader.getRes(detailUrl4):null;
  39718. terrainMaterial.setDiffuseScale1(sx1,sy1);
  39719. terrainMaterial.setDiffuseScale2(sx2,sy2);
  39720. terrainMaterial.setDiffuseScale3(sx3,sy3);
  39721. terrainMaterial.setDiffuseScale4(sx4,sy4);
  39722. terrainMaterial.setDetailNum(detailNum);
  39723. if (this._render._renderElements.length !=0){
  39724. terrainMaterial.renderMode=/*laya.d3.core.material.TerrainMaterial.RENDERMODE_TRANSPARENT*/2;
  39725. };
  39726. var renderElement=new RenderElement();
  39727. renderElement.setTransform(this._transform);
  39728. renderElement.render=this._render;
  39729. renderElement.setGeometry(this._terrainFilter);
  39730. this._render._renderElements.push(renderElement);
  39731. this._render.sharedMaterial=terrainMaterial;
  39732. }
  39733. __proto._cloneTo=function(destObject,srcSprite,dstSprite){
  39734. console.log("Terrain Chunk can't clone");
  39735. }
  39736. __proto.destroy=function(destroyChild){
  39737. (destroyChild===void 0)&& (destroyChild=true);
  39738. if (this.destroyed)
  39739. return;
  39740. _super.prototype.destroy.call(this,destroyChild);
  39741. this._terrainFilter.destroy();
  39742. this._terrainFilter=null;
  39743. }
  39744. /**
  39745. *获取地形过滤器。
  39746. *@return 地形过滤器。
  39747. */
  39748. __getset(0,__proto,'terrainFilter',function(){
  39749. return this._terrainFilter;
  39750. });
  39751. /**
  39752. *获取地形渲染器。
  39753. *@return 地形渲染器。
  39754. */
  39755. __getset(0,__proto,'terrainRender',function(){
  39756. return this._render;
  39757. });
  39758. return TerrainChunk;
  39759. })(RenderableSprite3D)
  39760. /**
  39761. *<code>MeshSprite3D</code> 类用于创建网格。
  39762. */
  39763. //class laya.d3.core.MeshSprite3D extends laya.d3.core.RenderableSprite3D
  39764. var MeshSprite3D=(function(_super){
  39765. function MeshSprite3D(mesh,name){
  39766. /**@private */
  39767. //this._meshFilter=null;
  39768. MeshSprite3D.__super.call(this,name);
  39769. this._meshFilter=new MeshFilter(this);
  39770. this._render=new MeshRenderer(this);
  39771. (mesh)&& (this._meshFilter.sharedMesh=mesh);
  39772. }
  39773. __class(MeshSprite3D,'laya.d3.core.MeshSprite3D',_super);
  39774. var __proto=MeshSprite3D.prototype;
  39775. /**
  39776. *@inheritDoc
  39777. */
  39778. __proto._parse=function(data,spriteMap){
  39779. laya.d3.core.Sprite3D.prototype._parse.call(this,data,spriteMap);
  39780. var render=this.meshRenderer;
  39781. var lightmapIndex=data.lightmapIndex;
  39782. (lightmapIndex !=null)&& (render.lightmapIndex=lightmapIndex);
  39783. var lightmapScaleOffsetArray=data.lightmapScaleOffset;
  39784. (lightmapScaleOffsetArray)&& (render.lightmapScaleOffset=new Vector4(lightmapScaleOffsetArray[0],lightmapScaleOffsetArray[1],lightmapScaleOffsetArray[2],lightmapScaleOffsetArray[3]));
  39785. (data.meshPath !=undefined)&& (this.meshFilter.sharedMesh=Loader.getRes(data.meshPath));
  39786. (data.enableRender !=undefined)&& (this.meshRenderer.enable=data.enableRender);
  39787. var materials=data.materials;
  39788. if (materials){
  39789. var sharedMaterials=render.sharedMaterials;
  39790. var materialCount=materials.length;
  39791. sharedMaterials.length=materialCount;
  39792. for (var i=0;i < materialCount;i++){
  39793. sharedMaterials[i]=Loader.getRes(materials[i].path);
  39794. }
  39795. render.sharedMaterials=sharedMaterials;
  39796. }
  39797. }
  39798. /**
  39799. *@inheritDoc
  39800. */
  39801. __proto._addToInitStaticBatchManager=function(){
  39802. MeshRenderStaticBatchManager.instance._addBatchSprite(this);
  39803. }
  39804. /**
  39805. *@inheritDoc
  39806. */
  39807. __proto._cloneTo=function(destObject,rootSprite,dstSprite){
  39808. var meshSprite3D=destObject;
  39809. meshSprite3D._meshFilter.sharedMesh=this._meshFilter.sharedMesh;
  39810. var meshRender=this._render;
  39811. var destMeshRender=meshSprite3D._render;
  39812. destMeshRender.enable=meshRender.enable;
  39813. destMeshRender.sharedMaterials=meshRender.sharedMaterials;
  39814. destMeshRender.castShadow=meshRender.castShadow;
  39815. var lightmapScaleOffset=meshRender.lightmapScaleOffset;
  39816. lightmapScaleOffset && (destMeshRender.lightmapScaleOffset=lightmapScaleOffset.clone());
  39817. destMeshRender.lightmapIndex=meshRender.lightmapIndex;
  39818. destMeshRender.receiveShadow=meshRender.receiveShadow;
  39819. destMeshRender.sortingFudge=meshRender.sortingFudge;
  39820. laya.d3.core.Sprite3D.prototype._cloneTo.call(this,destObject,rootSprite,dstSprite);
  39821. }
  39822. /**
  39823. *@inheritDoc
  39824. */
  39825. __proto.destroy=function(destroyChild){
  39826. (destroyChild===void 0)&& (destroyChild=true);
  39827. if (this.destroyed)
  39828. return;
  39829. _super.prototype.destroy.call(this,destroyChild);
  39830. this._meshFilter.destroy();
  39831. }
  39832. /**
  39833. *获取网格过滤器。
  39834. *@return 网格过滤器。
  39835. */
  39836. __getset(0,__proto,'meshFilter',function(){
  39837. return this._meshFilter;
  39838. });
  39839. /**
  39840. *获取网格渲染器。
  39841. *@return 网格渲染器。
  39842. */
  39843. __getset(0,__proto,'meshRenderer',function(){
  39844. return this._render;
  39845. });
  39846. MeshSprite3D.__init__=function(){
  39847. MeshSprite3D.SHADERDEFINE_UV0=MeshSprite3D.shaderDefines.registerDefine("UV");
  39848. MeshSprite3D.SHADERDEFINE_COLOR=MeshSprite3D.shaderDefines.registerDefine("COLOR");
  39849. MeshSprite3D.SHADERDEFINE_UV1=MeshSprite3D.shaderDefines.registerDefine("UV1");
  39850. MeshSprite3D.SHADERDEFINE_GPU_INSTANCE=MeshSprite3D.shaderDefines.registerDefine("GPU_INSTANCE");
  39851. StaticBatchManager._registerManager(MeshRenderStaticBatchManager.instance);
  39852. DynamicBatchManager._registerManager(MeshRenderDynamicBatchManager.instance);
  39853. }
  39854. MeshSprite3D.SHADERDEFINE_UV0=0;
  39855. MeshSprite3D.SHADERDEFINE_COLOR=0;
  39856. MeshSprite3D.SHADERDEFINE_UV1=0;
  39857. MeshSprite3D.SHADERDEFINE_GPU_INSTANCE=0;
  39858. __static(MeshSprite3D,
  39859. ['shaderDefines',function(){return this.shaderDefines=new ShaderDefines(RenderableSprite3D.shaderDefines);}
  39860. ]);
  39861. return MeshSprite3D;
  39862. })(RenderableSprite3D)
  39863. /**
  39864. *<code>SpotLight</code> 类用于创建聚光。
  39865. */
  39866. //class laya.d3.core.light.SpotLight extends laya.d3.core.light.LightSprite
  39867. var SpotLight=(function(_super){
  39868. function SpotLight(){
  39869. /**@private */
  39870. this._direction=null;
  39871. /**@private */
  39872. this._spotAngle=NaN;
  39873. /**@private */
  39874. this._range=NaN;
  39875. SpotLight.__super.call(this);
  39876. this._spotAngle=30.0;
  39877. this._range=10.0;
  39878. this._direction=new Vector3();
  39879. }
  39880. __class(SpotLight,'laya.d3.core.light.SpotLight',_super);
  39881. var __proto=SpotLight.prototype;
  39882. /**
  39883. *@inheritDoc
  39884. */
  39885. __proto._onActive=function(){
  39886. _super.prototype._onActive.call(this);
  39887. (this._lightmapBakedType!==LightSprite.LIGHTMAPBAKEDTYPE_BAKED)&&((this.scene)._defineDatas.add(Scene3D.SHADERDEFINE_SPOTLIGHT));
  39888. }
  39889. /**
  39890. *@inheritDoc
  39891. */
  39892. __proto._onInActive=function(){
  39893. _super.prototype._onInActive.call(this);
  39894. (this._lightmapBakedType!==LightSprite.LIGHTMAPBAKEDTYPE_BAKED)&&((this.scene)._defineDatas.remove(Scene3D.SHADERDEFINE_SPOTLIGHT));
  39895. }
  39896. /**
  39897. *更新聚光相关渲染状态参数。
  39898. *@param state 渲染状态参数。
  39899. */
  39900. __proto._prepareToScene=function(){
  39901. var scene=this._scene;
  39902. if (scene.enableLight && this.activeInHierarchy){
  39903. var defineDatas=scene._defineDatas;
  39904. var shaderValue=scene._shaderValues;
  39905. Vector3.scale(this.color,this._intensity,this._intensityColor);
  39906. shaderValue.setVector3(Scene3D.SPOTLIGHTCOLOR,this._intensityColor);
  39907. shaderValue.setVector3(Scene3D.SPOTLIGHTPOS,this.transform.position);
  39908. this.transform.worldMatrix.getForward(this._direction);
  39909. Vector3.normalize(this._direction,this._direction);
  39910. shaderValue.setVector3(Scene3D.SPOTLIGHTDIRECTION,this._direction);
  39911. shaderValue.setNumber(Scene3D.SPOTLIGHTRANGE,this.range);
  39912. shaderValue.setNumber(Scene3D.SPOTLIGHTSPOTANGLE,this.spotAngle *Math.PI / 180);
  39913. return true;
  39914. }else {
  39915. return false;
  39916. }
  39917. }
  39918. /**
  39919. *@inheritDoc
  39920. */
  39921. __proto._parse=function(data,spriteMap){
  39922. _super.prototype._parse.call(this,data,spriteMap);
  39923. this.range=data.range;
  39924. this.spotAngle=data.spotAngle;
  39925. }
  39926. /**
  39927. *设置聚光灯的锥形角度。
  39928. *@param value 聚光灯的锥形角度。
  39929. */
  39930. /**
  39931. *获取聚光灯的锥形角度。
  39932. *@return 聚光灯的锥形角度。
  39933. */
  39934. __getset(0,__proto,'spotAngle',function(){
  39935. return this._spotAngle;
  39936. },function(value){
  39937. this._spotAngle=Math.max(Math.min(value,180),0);
  39938. });
  39939. /**
  39940. *设置聚光的范围。
  39941. *@param value 聚光的范围值。
  39942. */
  39943. /**
  39944. *获取聚光的范围。
  39945. *@return 聚光的范围值。
  39946. */
  39947. __getset(0,__proto,'range',function(){
  39948. return this._range;
  39949. },function(value){
  39950. this._range=value;
  39951. });
  39952. __static(SpotLight,
  39953. ['_tempMatrix0',function(){return this._tempMatrix0=new Matrix4x4();},'_tempMatrix1',function(){return this._tempMatrix1=new Matrix4x4();}
  39954. ]);
  39955. return SpotLight;
  39956. })(LightSprite)
  39957. /**
  39958. *<code>TrailSprite3D</code> 类用于创建拖尾渲染精灵。
  39959. */
  39960. //class laya.d3.core.trail.TrailSprite3D extends laya.d3.core.RenderableSprite3D
  39961. var TrailSprite3D=(function(_super){
  39962. function TrailSprite3D(){
  39963. /**@private */
  39964. //this._geometryFilter=null;
  39965. TrailSprite3D.__super.call(this,this.name);
  39966. this._render=new TrailRenderer(this);
  39967. this._geometryFilter=new TrailFilter(this);
  39968. }
  39969. __class(TrailSprite3D,'laya.d3.core.trail.TrailSprite3D',_super);
  39970. var __proto=TrailSprite3D.prototype;
  39971. /**
  39972. *@inheritDoc
  39973. */
  39974. __proto._parse=function(data,spriteMap){
  39975. laya.d3.core.Sprite3D.prototype._parse.call(this,data,spriteMap);
  39976. var render=this._render;
  39977. var filter=this._geometryFilter;
  39978. var i=0,j=0;
  39979. var materials=data.materials;
  39980. if (materials){
  39981. var sharedMaterials=render.sharedMaterials;
  39982. var materialCount=materials.length;
  39983. sharedMaterials.length=materialCount;
  39984. for (i=0;i < materialCount;i++)
  39985. sharedMaterials[i]=Loader.getRes(materials[i].path);
  39986. render.sharedMaterials=sharedMaterials;
  39987. }
  39988. filter.time=data.time;
  39989. filter.minVertexDistance=data.minVertexDistance;
  39990. filter.widthMultiplier=data.widthMultiplier;
  39991. filter.textureMode=data.textureMode;
  39992. (data.alignment !=null)&& (filter.alignment=data.alignment);
  39993. var widthCurve=[];
  39994. var widthCurveData=data.widthCurve;
  39995. for (i=0,j=widthCurveData.length;i < j;i++){
  39996. var trailkeyframe=new FloatKeyframe();
  39997. trailkeyframe.time=widthCurveData[i].time;
  39998. trailkeyframe.inTangent=widthCurveData[i].inTangent;
  39999. trailkeyframe.outTangent=widthCurveData[i].outTangent;
  40000. trailkeyframe.value=widthCurveData[i].value;
  40001. widthCurve.push(trailkeyframe);
  40002. }
  40003. filter.widthCurve=widthCurve;
  40004. var colorGradientData=data.colorGradient;
  40005. var colorKeys=colorGradientData.colorKeys;
  40006. var alphaKeys=colorGradientData.alphaKeys;
  40007. var colorGradient=new Gradient(colorKeys.length,alphaKeys.length);
  40008. colorGradient.mode=colorGradientData.mode;
  40009. for (i=0,j=colorKeys.length;i < j;i++){
  40010. var colorKey=colorKeys[i];
  40011. colorGradient.addColorRGB(colorKey.time,new Color(colorKey.value[0],colorKey.value[1],colorKey.value[2],1.0));
  40012. }
  40013. for (i=0,j=alphaKeys.length;i < j;i++){
  40014. var alphaKey=alphaKeys[i];
  40015. colorGradient.addColorAlpha(alphaKey.time,alphaKey.value);
  40016. }
  40017. filter.colorGradient=colorGradient;
  40018. }
  40019. /**
  40020. *@inheritDoc
  40021. */
  40022. __proto._onActive=function(){
  40023. _super.prototype._onActive.call(this);
  40024. this._transform.position.cloneTo(this._geometryFilter._lastPosition);
  40025. }
  40026. /**
  40027. *@inheritDoc
  40028. */
  40029. __proto._cloneTo=function(destObject,srcSprite,dstSprite){
  40030. laya.d3.core.Sprite3D.prototype._cloneTo.call(this,destObject,srcSprite,dstSprite);
  40031. var i=0,j=0;
  40032. var destTrailSprite3D=destObject;
  40033. var destTrailFilter=destTrailSprite3D.trailFilter;
  40034. destTrailFilter.time=this.trailFilter.time;
  40035. destTrailFilter.minVertexDistance=this.trailFilter.minVertexDistance;
  40036. destTrailFilter.widthMultiplier=this.trailFilter.widthMultiplier;
  40037. destTrailFilter.textureMode=this.trailFilter.textureMode;
  40038. var widthCurveData=this.trailFilter.widthCurve;
  40039. var widthCurve=[];
  40040. for (i=0,j=widthCurveData.length;i < j;i++){
  40041. var keyFrame=new FloatKeyframe();
  40042. widthCurveData[i].cloneTo(keyFrame);
  40043. widthCurve.push(keyFrame);
  40044. }
  40045. destTrailFilter.widthCurve=widthCurve;
  40046. var destColorGradient=new Gradient(this.trailFilter.colorGradient.maxColorRGBKeysCount,this.trailFilter.colorGradient.maxColorAlphaKeysCount);
  40047. this.trailFilter.colorGradient.cloneTo(destColorGradient);
  40048. destTrailFilter.colorGradient=destColorGradient;
  40049. var destTrailRender=destTrailSprite3D.trailRenderer;
  40050. destTrailRender.sharedMaterial=this.trailRenderer.sharedMaterial;
  40051. }
  40052. /**
  40053. *<p>销毁此对象。</p>
  40054. *@param destroyChild 是否同时销毁子节点,若值为true,则销毁子节点,否则不销毁子节点。
  40055. */
  40056. __proto.destroy=function(destroyChild){
  40057. (destroyChild===void 0)&& (destroyChild=true);
  40058. if (this.destroyed)
  40059. return;
  40060. _super.prototype.destroy.call(this,destroyChild);
  40061. (this._geometryFilter).destroy();
  40062. this._geometryFilter=null;
  40063. }
  40064. /**
  40065. *获取Trail过滤器。
  40066. *@return Trail过滤器。
  40067. */
  40068. __getset(0,__proto,'trailFilter',function(){
  40069. return this._geometryFilter;
  40070. });
  40071. /**
  40072. *获取Trail渲染器。
  40073. *@return Trail渲染器。
  40074. */
  40075. __getset(0,__proto,'trailRenderer',function(){
  40076. return this._render;
  40077. });
  40078. TrailSprite3D.__init__=function(){
  40079. TrailSprite3D.SHADERDEFINE_GRADIENTMODE_BLEND=TrailSprite3D.shaderDefines.registerDefine("GRADIENTMODE_BLEND");
  40080. }
  40081. TrailSprite3D.SHADERDEFINE_GRADIENTMODE_BLEND=0;
  40082. __static(TrailSprite3D,
  40083. ['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);}
  40084. ]);
  40085. return TrailSprite3D;
  40086. })(RenderableSprite3D)
  40087. /**
  40088. *<code>PointLight</code> 类用于创建点光。
  40089. */
  40090. //class laya.d3.core.light.PointLight extends laya.d3.core.light.LightSprite
  40091. var PointLight=(function(_super){
  40092. function PointLight(){
  40093. /**@private */
  40094. this._range=NaN;
  40095. this._lightMatrix=new Matrix4x4();
  40096. PointLight.__super.call(this);
  40097. this._range=6.0;
  40098. }
  40099. __class(PointLight,'laya.d3.core.light.PointLight',_super);
  40100. var __proto=PointLight.prototype;
  40101. /**
  40102. *@inheritDoc
  40103. */
  40104. __proto._onActive=function(){
  40105. _super.prototype._onActive.call(this);
  40106. (this._lightmapBakedType!==LightSprite.LIGHTMAPBAKEDTYPE_BAKED)&&((this._scene)._defineDatas.add(Scene3D.SHADERDEFINE_POINTLIGHT));
  40107. }
  40108. /**
  40109. *@inheritDoc
  40110. */
  40111. __proto._onInActive=function(){
  40112. _super.prototype._onInActive.call(this);
  40113. (this._lightmapBakedType!==LightSprite.LIGHTMAPBAKEDTYPE_BAKED)&&((this._scene)._defineDatas.remove(Scene3D.SHADERDEFINE_POINTLIGHT));
  40114. }
  40115. /**
  40116. *更新点光相关渲染状态参数。
  40117. *@param state 渲染状态参数。
  40118. */
  40119. __proto._prepareToScene=function(){
  40120. var scene=this._scene;
  40121. if (scene.enableLight && this.activeInHierarchy){
  40122. var defineDatas=scene._defineDatas;
  40123. var shaderValue=scene._shaderValues;
  40124. Vector3.scale(this.color,this._intensity,this._intensityColor);
  40125. shaderValue.setVector3(Scene3D.POINTLIGHTCOLOR,this._intensityColor);
  40126. shaderValue.setVector3(Scene3D.POINTLIGHTPOS,this.transform.position);
  40127. shaderValue.setNumber(Scene3D.POINTLIGHTRANGE,this.range);
  40128. var lightMatrix=this._lightMatrix;
  40129. var lightMatrixE=lightMatrix.elements;
  40130. lightMatrix.identity();
  40131. lightMatrixE[0]=lightMatrixE[5]=lightMatrixE[10]=1.0 / this._range;
  40132. var toLightMatrix=PointLight._tempMatrix0;
  40133. this.transform.worldMatrix.invert(toLightMatrix);
  40134. Matrix4x4.multiply(lightMatrix,toLightMatrix,lightMatrix);
  40135. shaderValue.setMatrix4x4(Scene3D.POINTLIGHTMATRIX,lightMatrix);
  40136. return true;
  40137. }else {
  40138. return false;
  40139. }
  40140. }
  40141. /**
  40142. *@inheritDoc
  40143. */
  40144. __proto._parse=function(data,spriteMap){
  40145. _super.prototype._parse.call(this,data,spriteMap);
  40146. this.range=data.range;
  40147. }
  40148. /**
  40149. *设置点光的范围。
  40150. *@param value 点光的范围。
  40151. */
  40152. /**
  40153. *获取点光的范围。
  40154. *@return 点光的范围。
  40155. */
  40156. __getset(0,__proto,'range',function(){
  40157. return this._range;
  40158. },function(value){
  40159. this._range=value;
  40160. });
  40161. __static(PointLight,
  40162. ['_tempMatrix0',function(){return this._tempMatrix0=new Matrix4x4();}
  40163. ]);
  40164. return PointLight;
  40165. })(LightSprite)
  40166. /**
  40167. *<code>SkinnedMeshSprite3D</code> 类用于创建网格。
  40168. */
  40169. //class laya.d3.core.SkinnedMeshSprite3D extends laya.d3.core.RenderableSprite3D
  40170. var SkinnedMeshSprite3D=(function(_super){
  40171. function SkinnedMeshSprite3D(mesh,name){
  40172. /**@private */
  40173. //this._meshFilter=null;
  40174. SkinnedMeshSprite3D.__super.call(this,name);
  40175. this._meshFilter=new MeshFilter(this);
  40176. this._render=new SkinnedMeshRenderer(this);
  40177. (mesh)&& (this._meshFilter.sharedMesh=mesh);
  40178. }
  40179. __class(SkinnedMeshSprite3D,'laya.d3.core.SkinnedMeshSprite3D',_super);
  40180. var __proto=SkinnedMeshSprite3D.prototype;
  40181. /**
  40182. *@inheritDoc
  40183. */
  40184. __proto._parse=function(data,spriteMap){
  40185. laya.d3.core.Sprite3D.prototype._parse.call(this,data,spriteMap);
  40186. var render=this.skinnedMeshRenderer;
  40187. var lightmapIndex=data.lightmapIndex;
  40188. (lightmapIndex !=null)&& (render.lightmapIndex=lightmapIndex);
  40189. var lightmapScaleOffsetArray=data.lightmapScaleOffset;
  40190. (lightmapScaleOffsetArray)&& (render.lightmapScaleOffset=new Vector4(lightmapScaleOffsetArray[0],lightmapScaleOffsetArray[1],lightmapScaleOffsetArray[2],lightmapScaleOffsetArray[3]));
  40191. var meshPath;
  40192. meshPath=data.meshPath;
  40193. if (meshPath){
  40194. var mesh=Loader.getRes(meshPath);
  40195. (mesh)&& (this.meshFilter.sharedMesh=mesh);
  40196. };
  40197. var materials=data.materials;
  40198. if (materials){
  40199. var sharedMaterials=render.sharedMaterials;
  40200. var materialCount=materials.length;
  40201. sharedMaterials.length=materialCount;
  40202. for (var i=0;i < materialCount;i++){
  40203. sharedMaterials[i]=Loader.getRes(materials[i].path);
  40204. }
  40205. render.sharedMaterials=sharedMaterials;
  40206. };
  40207. var boundBox=data.boundBox;
  40208. var min=boundBox.min;
  40209. var max=boundBox.max;
  40210. render.localBounds.setMin(new Vector3(min[0],min[1],min[2]));
  40211. render.localBounds.setMax(new Vector3(max[0],max[1],max[2]));
  40212. if (spriteMap){
  40213. var rootBoneData=data.rootBone;
  40214. render.rootBone=spriteMap[rootBoneData];
  40215. var bonesData=data.bones;
  40216. var n=0;
  40217. for (i=0,n=bonesData.length;i < n;i++)
  40218. render.bones.push(spriteMap[bonesData[i]]);
  40219. }else {
  40220. (data.rootBone)&& (render._setRootBone(data.rootBone));
  40221. }
  40222. }
  40223. /**
  40224. *@inheritDoc
  40225. */
  40226. __proto._changeHierarchyAnimator=function(animator){
  40227. _super.prototype._changeHierarchyAnimator.call(this,animator);
  40228. this.skinnedMeshRenderer._setCacheAnimator(animator);
  40229. }
  40230. /**
  40231. *@inheritDoc
  40232. */
  40233. __proto._changeAnimatorAvatar=function(avatar){
  40234. this.skinnedMeshRenderer._setCacheAvatar(avatar);
  40235. }
  40236. /**
  40237. *@inheritDoc
  40238. */
  40239. __proto._cloneTo=function(destObject,srcRoot,dstRoot){
  40240. var meshSprite3D=destObject;
  40241. meshSprite3D.meshFilter.sharedMesh=this.meshFilter.sharedMesh;
  40242. var meshRender=this._render;
  40243. var destMeshRender=meshSprite3D._render;
  40244. destMeshRender.enable=meshRender.enable;
  40245. destMeshRender.sharedMaterials=meshRender.sharedMaterials;
  40246. destMeshRender.castShadow=meshRender.castShadow;
  40247. var lightmapScaleOffset=meshRender.lightmapScaleOffset;
  40248. lightmapScaleOffset && (destMeshRender.lightmapScaleOffset=lightmapScaleOffset.clone());
  40249. destMeshRender.receiveShadow=meshRender.receiveShadow;
  40250. destMeshRender.sortingFudge=meshRender.sortingFudge;
  40251. destMeshRender._rootBone=meshRender._rootBone;
  40252. var bones=meshRender.bones;
  40253. var destBones=destMeshRender.bones;
  40254. var bonesCount=bones.length;
  40255. destBones.length=bonesCount;
  40256. var rootBone=meshRender.rootBone;
  40257. if (rootBone){
  40258. var pathes=Utils3D._getHierarchyPath(srcRoot,rootBone,SkinnedMeshSprite3D._tempArray0);
  40259. if (pathes)
  40260. destMeshRender.rootBone=Utils3D._getNodeByHierarchyPath(dstRoot,pathes);
  40261. else
  40262. destMeshRender.rootBone=rootBone;
  40263. }
  40264. for (var i=0;i < bones.length;i++){
  40265. pathes=Utils3D._getHierarchyPath(srcRoot,bones[i],SkinnedMeshSprite3D._tempArray0);
  40266. if (pathes)
  40267. destBones[i]=Utils3D._getNodeByHierarchyPath(dstRoot,pathes);
  40268. else
  40269. destBones[i]=bones[i];
  40270. };
  40271. var lbb=meshRender.localBounds;
  40272. (lbb)&& (lbb.cloneTo(destMeshRender.localBounds));
  40273. laya.d3.core.Sprite3D.prototype._cloneTo.call(this,destObject,srcRoot,dstRoot);
  40274. }
  40275. /**
  40276. *@inheritDoc
  40277. */
  40278. __proto.destroy=function(destroyChild){
  40279. (destroyChild===void 0)&& (destroyChild=true);
  40280. if (this.destroyed)
  40281. return;
  40282. _super.prototype.destroy.call(this,destroyChild);
  40283. this._meshFilter.destroy();
  40284. }
  40285. /**
  40286. *获取网格过滤器。
  40287. *@return 网格过滤器。
  40288. */
  40289. __getset(0,__proto,'meshFilter',function(){
  40290. return this._meshFilter;
  40291. });
  40292. /**
  40293. *获取网格渲染器。
  40294. *@return 网格渲染器。
  40295. */
  40296. __getset(0,__proto,'skinnedMeshRenderer',function(){
  40297. return this._render;
  40298. });
  40299. SkinnedMeshSprite3D.__init__=function(){
  40300. SkinnedMeshSprite3D.SHADERDEFINE_BONE=SkinnedMeshSprite3D.shaderDefines.registerDefine("BONE");
  40301. }
  40302. SkinnedMeshSprite3D._tempArray0=[];
  40303. SkinnedMeshSprite3D.SHADERDEFINE_BONE=0;
  40304. __static(SkinnedMeshSprite3D,
  40305. ['BONES',function(){return this.BONES=Shader3D.propertyNameToID("u_Bones");},'shaderDefines',function(){return this.shaderDefines=new ShaderDefines(MeshSprite3D.shaderDefines);}
  40306. ]);
  40307. return SkinnedMeshSprite3D;
  40308. })(RenderableSprite3D)
  40309. /**
  40310. *<code>PixelLineSprite3D</code> 类用于像素线渲染精灵。
  40311. */
  40312. //class laya.d3.core.pixelLine.PixelLineSprite3D extends laya.d3.core.RenderableSprite3D
  40313. var PixelLineSprite3D=(function(_super){
  40314. function PixelLineSprite3D(maxCount,name){
  40315. /**@private */
  40316. this._geometryFilter=null;
  40317. (maxCount===void 0)&& (maxCount=2);
  40318. PixelLineSprite3D.__super.call(this,name);
  40319. this._geometryFilter=new PixelLineFilter(this,maxCount);
  40320. this._render=new PixelLineRenderer(this);
  40321. this._changeRenderObjects(this._render,0,PixelLineMaterial.defaultMaterial);
  40322. }
  40323. __class(PixelLineSprite3D,'laya.d3.core.pixelLine.PixelLineSprite3D',_super);
  40324. var __proto=PixelLineSprite3D.prototype;
  40325. /**
  40326. *@inheritDoc
  40327. */
  40328. __proto._changeRenderObjects=function(sender,index,material){
  40329. var renderObjects=this._render._renderElements;
  40330. (material)|| (material=PixelLineMaterial.defaultMaterial);
  40331. var renderElement=renderObjects[index];
  40332. (renderElement)|| (renderElement=renderObjects[index]=new RenderElement());
  40333. renderElement.setTransform(this._transform);
  40334. renderElement.setGeometry(this._geometryFilter);
  40335. renderElement.render=this._render;
  40336. renderElement.material=material;
  40337. }
  40338. /**
  40339. *增加一条线。
  40340. *@param startPosition 初始点位置
  40341. *@param endPosition 结束点位置
  40342. *@param startColor 初始点颜色
  40343. *@param endColor 结束点颜色
  40344. */
  40345. __proto.addLine=function(startPosition,endPosition,startColor,endColor){
  40346. if (this._geometryFilter._lineCount!==this._geometryFilter._maxLineCount)
  40347. this._geometryFilter._updateLineData(this._geometryFilter._lineCount++,startPosition,endPosition,startColor,endColor);
  40348. else
  40349. throw "PixelLineSprite3D: lineCount has equal with maxLineCount.";
  40350. }
  40351. /**
  40352. *添加多条线段。
  40353. *@param lines 线段数据
  40354. */
  40355. __proto.addLines=function(lines){
  40356. var lineCount=this._geometryFilter._lineCount;
  40357. var addCount=lines.length;
  40358. if (lineCount+addCount > this._geometryFilter._maxLineCount){
  40359. throw "PixelLineSprite3D: lineCount plus lines count must less than maxLineCount.";
  40360. }else {
  40361. this._geometryFilter._updateLineDatas(lineCount,lines);
  40362. this._geometryFilter._lineCount+=addCount;
  40363. }
  40364. }
  40365. /**
  40366. *移除一条线段。
  40367. *@param index 索引。
  40368. */
  40369. __proto.removeLine=function(index){
  40370. if (index < this._geometryFilter._lineCount)
  40371. this._geometryFilter._removeLineData(index);
  40372. else
  40373. throw "PixelLineSprite3D: index must less than lineCount.";
  40374. }
  40375. /**
  40376. *更新线
  40377. *@param index 索引
  40378. *@param startPosition 初始点位置
  40379. *@param endPosition 结束点位置
  40380. *@param startColor 初始点颜色
  40381. *@param endColor 结束点颜色
  40382. */
  40383. __proto.setLine=function(index,startPosition,endPosition,startColor,endColor){
  40384. if (index < this._geometryFilter._lineCount)
  40385. this._geometryFilter._updateLineData(index,startPosition,endPosition,startColor,endColor);
  40386. else
  40387. throw "PixelLineSprite3D: index must less than lineCount.";
  40388. }
  40389. /**
  40390. *获取线段数据
  40391. *@param out 线段数据。
  40392. */
  40393. __proto.getLine=function(index,out){
  40394. if (index < this.lineCount)
  40395. this._geometryFilter._getLineData(index,out);
  40396. else
  40397. throw "PixelLineSprite3D: index must less than lineCount.";
  40398. }
  40399. /**
  40400. *清除所有线段。
  40401. */
  40402. __proto.clear=function(){
  40403. this._geometryFilter._lineCount=0;
  40404. }
  40405. /**
  40406. *设置最大线数量
  40407. *@param value 最大线数量。
  40408. */
  40409. /**
  40410. *获取最大线数量
  40411. *@return 最大线数量。
  40412. */
  40413. __getset(0,__proto,'maxLineCount',function(){
  40414. return this._geometryFilter._maxLineCount;
  40415. },function(value){
  40416. this._geometryFilter._resizeLineData(value);
  40417. this._geometryFilter._lineCount=Math.min(this._geometryFilter._lineCount,value);
  40418. });
  40419. /**
  40420. *获取line渲染器。
  40421. *@return line渲染器。
  40422. */
  40423. __getset(0,__proto,'pixelLineRenderer',function(){
  40424. return this._render;
  40425. });
  40426. /**
  40427. *设置获取线数量。
  40428. *@param value 线段数量。
  40429. */
  40430. /**
  40431. *获取线数量。
  40432. *@return 线段数量。
  40433. */
  40434. __getset(0,__proto,'lineCount',function(){
  40435. return this._geometryFilter._lineCount;
  40436. },function(value){
  40437. if (value > this.maxLineCount)
  40438. throw "PixelLineSprite3D: lineCount can't large than maxLineCount";
  40439. else
  40440. this._geometryFilter._lineCount=value;
  40441. });
  40442. return PixelLineSprite3D;
  40443. })(RenderableSprite3D)
  40444. /**
  40445. *<code>DirectionLight</code> 类用于创建平行光。
  40446. */
  40447. //class laya.d3.core.light.DirectionLight extends laya.d3.core.light.LightSprite
  40448. var DirectionLight=(function(_super){
  40449. function DirectionLight(){
  40450. /**@private */
  40451. this._direction=null;
  40452. DirectionLight.__super.call(this);
  40453. this._direction=new Vector3();
  40454. }
  40455. __class(DirectionLight,'laya.d3.core.light.DirectionLight',_super);
  40456. var __proto=DirectionLight.prototype;
  40457. /**
  40458. *@private
  40459. */
  40460. __proto._initShadow=function(){
  40461. if (this._shadow){
  40462. this._parallelSplitShadowMap=new ParallelSplitShadowMap();
  40463. this.scene.parallelSplitShadowMaps.push(this._parallelSplitShadowMap);
  40464. this.transform.worldMatrix.getForward(this._direction);
  40465. Vector3.normalize(this._direction,this._direction);
  40466. this._parallelSplitShadowMap.setInfo(this.scene,this._shadowFarPlane,this._direction,this._shadowMapSize,this._shadowMapCount,this._shadowMapPCFType);
  40467. }else {
  40468. var defineDatas=(this._scene)._defineDatas;
  40469. var parallelSplitShadowMaps=this.scene.parallelSplitShadowMaps;
  40470. parallelSplitShadowMaps.splice(parallelSplitShadowMaps.indexOf(this._parallelSplitShadowMap),1);
  40471. this._parallelSplitShadowMap.disposeAllRenderTarget();
  40472. this._parallelSplitShadowMap=null;
  40473. defineDatas.remove(Scene3D.SHADERDEFINE_SHADOW_PSSM1);
  40474. defineDatas.remove(Scene3D.SHADERDEFINE_SHADOW_PSSM2);
  40475. defineDatas.remove(Scene3D.SHADERDEFINE_SHADOW_PSSM3);
  40476. }
  40477. }
  40478. /**
  40479. *@inheritDoc
  40480. */
  40481. __proto._onActive=function(){
  40482. _super.prototype._onActive.call(this);
  40483. this._shadow && (this._initShadow());
  40484. (this._lightmapBakedType!==LightSprite.LIGHTMAPBAKEDTYPE_BAKED)&&((this._scene)._defineDatas.add(Scene3D.SHADERDEFINE_DIRECTIONLIGHT));
  40485. }
  40486. /**
  40487. *@inheritDoc
  40488. */
  40489. __proto._onInActive=function(){
  40490. _super.prototype._onInActive.call(this);
  40491. (this._lightmapBakedType!==LightSprite.LIGHTMAPBAKEDTYPE_BAKED)&&((this._scene)._defineDatas.remove(Scene3D.SHADERDEFINE_DIRECTIONLIGHT));
  40492. }
  40493. /**
  40494. *更新平行光相关渲染状态参数。
  40495. *@param state 渲染状态参数。
  40496. */
  40497. __proto._prepareToScene=function(){
  40498. var scene=this._scene;
  40499. if (scene.enableLight && this.activeInHierarchy){
  40500. var defineDatas=scene._defineDatas;
  40501. var shaderValue=scene._shaderValues;
  40502. Vector3.scale(this.color,this._intensity,this._intensityColor);
  40503. shaderValue.setVector3(Scene3D.LIGHTDIRCOLOR,this._intensityColor);
  40504. this.transform.worldMatrix.getForward(this._direction);
  40505. Vector3.normalize(this._direction,this._direction);
  40506. shaderValue.setVector3(Scene3D.LIGHTDIRECTION,this._direction);
  40507. return true;
  40508. }else {
  40509. return false;
  40510. }
  40511. }
  40512. /**
  40513. *@inheritDoc
  40514. */
  40515. __getset(0,__proto,'shadow',_super.prototype._$get_shadow,function(value){
  40516. if (this._shadow!==value){
  40517. this._shadow=value;
  40518. (this.scene)&& (this._initShadow());
  40519. }
  40520. });
  40521. return DirectionLight;
  40522. })(LightSprite)
  40523. /**
  40524. *<code>ShuriKenParticle3D</code> 3D粒子。
  40525. */
  40526. //class laya.d3.core.particleShuriKen.ShuriKenParticle3D extends laya.d3.core.RenderableSprite3D
  40527. var ShuriKenParticle3D=(function(_super){
  40528. function ShuriKenParticle3D(){
  40529. /**@private */
  40530. //this._particleSystem=null;
  40531. ShuriKenParticle3D.__super.call(this,null);
  40532. this._render=new ShurikenParticleRenderer(this);
  40533. this._particleSystem=new ShurikenParticleSystem(this);
  40534. var elements=this._render._renderElements;
  40535. var element=elements[0]=new RenderElement();
  40536. element.setTransform(this._transform);
  40537. element.render=this._render;
  40538. element.setGeometry(this._particleSystem);
  40539. element.material=ShurikenParticleMaterial.defaultMaterial;
  40540. }
  40541. __class(ShuriKenParticle3D,'laya.d3.core.particleShuriKen.ShuriKenParticle3D',_super);
  40542. var __proto=ShuriKenParticle3D.prototype;
  40543. /**
  40544. *@private
  40545. */
  40546. __proto._initParticleVelocity=function(gradientData){
  40547. var gradient=new GradientDataNumber();
  40548. var velocitysData=gradientData.velocitys;
  40549. for (var i=0,n=velocitysData.length;i < n;i++){
  40550. var valueData=velocitysData[i];
  40551. gradient.add(valueData.key,valueData.value);
  40552. }
  40553. return gradient;
  40554. }
  40555. /**
  40556. *@private
  40557. */
  40558. __proto._initParticleColor=function(gradientColorData){
  40559. var gradientColor=new Gradient(4,4);
  40560. var alphasData=gradientColorData.alphas;
  40561. var i=0,n=0;
  40562. for (i=0,n=alphasData.length;i < n;i++){
  40563. var alphaData=alphasData[i];
  40564. if ((i===3)&& ((alphaData.key!==1))){
  40565. alphaData.key=1;
  40566. console.log("GradientDataColor warning:the forth key is be force set to 1.");
  40567. }
  40568. gradientColor.addColorAlpha(alphaData.key,alphaData.value);
  40569. };
  40570. var rgbsData=gradientColorData.rgbs;
  40571. for (i=0,n=rgbsData.length;i < n;i++){
  40572. var rgbData=rgbsData[i];
  40573. var rgbValue=rgbData.value;
  40574. if ((i===3)&& ((rgbData.key!==1))){
  40575. rgbData.key=1;
  40576. console.log("GradientDataColor warning:the forth key is be force set to 1.");
  40577. }
  40578. gradientColor.addColorRGB(rgbData.key,new Color(rgbValue[0],rgbValue[1],rgbValue[2],1.0));
  40579. }
  40580. return gradientColor;
  40581. }
  40582. /**
  40583. *@private
  40584. */
  40585. __proto._initParticleSize=function(gradientSizeData){
  40586. var gradientSize=new GradientDataNumber();
  40587. var sizesData=gradientSizeData.sizes;
  40588. for (var i=0,n=sizesData.length;i < n;i++){
  40589. var valueData=sizesData[i];
  40590. gradientSize.add(valueData.key,valueData.value);
  40591. }
  40592. return gradientSize;
  40593. }
  40594. /**
  40595. *@private
  40596. */
  40597. __proto._initParticleRotation=function(gradientData){
  40598. var gradient=new GradientDataNumber();
  40599. var angularVelocitysData=gradientData.angularVelocitys;
  40600. for (var i=0,n=angularVelocitysData.length;i < n;i++){
  40601. var valueData=angularVelocitysData[i];
  40602. gradient.add(valueData.key,valueData.value / 180.0 *Math.PI);
  40603. }
  40604. return gradient;
  40605. }
  40606. /**
  40607. *@private
  40608. */
  40609. __proto._initParticleFrame=function(overTimeFramesData){
  40610. var overTimeFrame=new GradientDataInt();
  40611. var framesData=overTimeFramesData.frames;
  40612. for (var i=0,n=framesData.length;i < n;i++){
  40613. var frameData=framesData[i];
  40614. overTimeFrame.add(frameData.key,frameData.value);
  40615. }
  40616. return overTimeFrame;
  40617. }
  40618. /**
  40619. *@inheritDoc
  40620. */
  40621. __proto._parse=function(data,spriteMap){
  40622. laya.d3.core.Sprite3D.prototype._parse.call(this,data,spriteMap);
  40623. var anglelToRad=Math.PI / 180.0;
  40624. var i=0,n=0;
  40625. var particleRender=this.particleRenderer;
  40626. var material;
  40627. var materialData=data.material;
  40628. (materialData)&& (material=Loader.getRes(materialData.path));
  40629. particleRender.sharedMaterial=material;
  40630. var meshPath=data.meshPath;
  40631. (meshPath)&& (particleRender.mesh=Loader.getRes(meshPath));
  40632. particleRender.renderMode=data.renderMode;
  40633. particleRender.stretchedBillboardCameraSpeedScale=data.stretchedBillboardCameraSpeedScale;
  40634. particleRender.stretchedBillboardSpeedScale=data.stretchedBillboardSpeedScale;
  40635. particleRender.stretchedBillboardLengthScale=data.stretchedBillboardLengthScale;
  40636. particleRender.sortingFudge=data.sortingFudge ? data.sortingFudge :0.0;
  40637. var particleSystem=this.particleSystem;
  40638. particleSystem.isPerformanceMode=data.isPerformanceMode;
  40639. particleSystem.duration=data.duration;
  40640. particleSystem.looping=data.looping;
  40641. particleSystem.prewarm=data.prewarm;
  40642. particleSystem.startDelayType=data.startDelayType;
  40643. particleSystem.startDelay=data.startDelay;
  40644. particleSystem.startDelayMin=data.startDelayMin;
  40645. particleSystem.startDelayMax=data.startDelayMax;
  40646. particleSystem.startLifetimeType=data.startLifetimeType;
  40647. particleSystem.startLifetimeConstant=data.startLifetimeConstant;
  40648. particleSystem.startLifeTimeGradient=ShuriKenParticle3D._initStartLife(data.startLifetimeGradient);
  40649. particleSystem.startLifetimeConstantMin=data.startLifetimeConstantMin;
  40650. particleSystem.startLifetimeConstantMax=data.startLifetimeConstantMax;
  40651. particleSystem.startLifeTimeGradientMin=ShuriKenParticle3D._initStartLife(data.startLifetimeGradientMin);
  40652. particleSystem.startLifeTimeGradientMax=ShuriKenParticle3D._initStartLife(data.startLifetimeGradientMax);
  40653. particleSystem.startSpeedType=data.startSpeedType;
  40654. particleSystem.startSpeedConstant=data.startSpeedConstant;
  40655. particleSystem.startSpeedConstantMin=data.startSpeedConstantMin;
  40656. particleSystem.startSpeedConstantMax=data.startSpeedConstantMax;
  40657. particleSystem.threeDStartSize=data.threeDStartSize;
  40658. particleSystem.startSizeType=data.startSizeType;
  40659. particleSystem.startSizeConstant=data.startSizeConstant;
  40660. var startSizeConstantSeparateArray=data.startSizeConstantSeparate;
  40661. var startSizeConstantSeparateElement=particleSystem.startSizeConstantSeparate;
  40662. startSizeConstantSeparateElement.x=startSizeConstantSeparateArray[0];
  40663. startSizeConstantSeparateElement.y=startSizeConstantSeparateArray[1];
  40664. startSizeConstantSeparateElement.z=startSizeConstantSeparateArray[2];
  40665. particleSystem.startSizeConstantMin=data.startSizeConstantMin;
  40666. particleSystem.startSizeConstantMax=data.startSizeConstantMax;
  40667. var startSizeConstantMinSeparateArray=data.startSizeConstantMinSeparate;
  40668. var startSizeConstantMinSeparateElement=particleSystem.startSizeConstantMinSeparate;
  40669. startSizeConstantMinSeparateElement.x=startSizeConstantMinSeparateArray[0];
  40670. startSizeConstantMinSeparateElement.y=startSizeConstantMinSeparateArray[1];
  40671. startSizeConstantMinSeparateElement.z=startSizeConstantMinSeparateArray[2];
  40672. var startSizeConstantMaxSeparateArray=data.startSizeConstantMaxSeparate;
  40673. var startSizeConstantMaxSeparateElement=particleSystem.startSizeConstantMaxSeparate;
  40674. startSizeConstantMaxSeparateElement.x=startSizeConstantMaxSeparateArray[0];
  40675. startSizeConstantMaxSeparateElement.y=startSizeConstantMaxSeparateArray[1];
  40676. startSizeConstantMaxSeparateElement.z=startSizeConstantMaxSeparateArray[2];
  40677. particleSystem.threeDStartRotation=data.threeDStartRotation;
  40678. particleSystem.startRotationType=data.startRotationType;
  40679. particleSystem.startRotationConstant=data.startRotationConstant *anglelToRad;
  40680. var startRotationConstantSeparateArray=data.startRotationConstantSeparate;
  40681. var startRotationConstantSeparateElement=particleSystem.startRotationConstantSeparate;
  40682. startRotationConstantSeparateElement.x=startRotationConstantSeparateArray[0] *anglelToRad;
  40683. startRotationConstantSeparateElement.y=startRotationConstantSeparateArray[1] *anglelToRad;
  40684. startRotationConstantSeparateElement.z=startRotationConstantSeparateArray[2] *anglelToRad;
  40685. particleSystem.startRotationConstantMin=data.startRotationConstantMin *anglelToRad;
  40686. particleSystem.startRotationConstantMax=data.startRotationConstantMax *anglelToRad;
  40687. var startRotationConstantMinSeparateArray=data.startRotationConstantMinSeparate;
  40688. var startRotationConstantMinSeparateElement=particleSystem.startRotationConstantMinSeparate;
  40689. startRotationConstantMinSeparateElement.x=startRotationConstantMinSeparateArray[0] *anglelToRad;
  40690. startRotationConstantMinSeparateElement.y=startRotationConstantMinSeparateArray[1] *anglelToRad;
  40691. startRotationConstantMinSeparateElement.z=startRotationConstantMinSeparateArray[2] *anglelToRad;
  40692. var startRotationConstantMaxSeparateArray=data.startRotationConstantMaxSeparate;
  40693. var startRotationConstantMaxSeparateElement=particleSystem.startRotationConstantMaxSeparate;
  40694. startRotationConstantMaxSeparateElement.x=startRotationConstantMaxSeparateArray[0] *anglelToRad;
  40695. startRotationConstantMaxSeparateElement.y=startRotationConstantMaxSeparateArray[1] *anglelToRad;
  40696. startRotationConstantMaxSeparateElement.z=startRotationConstantMaxSeparateArray[2] *anglelToRad;
  40697. particleSystem.randomizeRotationDirection=data.randomizeRotationDirection;
  40698. particleSystem.startColorType=data.startColorType;
  40699. var startColorConstantArray=data.startColorConstant;
  40700. var startColorConstantElement=particleSystem.startColorConstant;
  40701. startColorConstantElement.x=startColorConstantArray[0];
  40702. startColorConstantElement.y=startColorConstantArray[1];
  40703. startColorConstantElement.z=startColorConstantArray[2];
  40704. startColorConstantElement.w=startColorConstantArray[3];
  40705. var startColorConstantMinArray=data.startColorConstantMin;
  40706. var startColorConstantMinElement=particleSystem.startColorConstantMin;
  40707. startColorConstantMinElement.x=startColorConstantMinArray[0];
  40708. startColorConstantMinElement.y=startColorConstantMinArray[1];
  40709. startColorConstantMinElement.z=startColorConstantMinArray[2];
  40710. startColorConstantMinElement.w=startColorConstantMinArray[3];
  40711. var startColorConstantMaxArray=data.startColorConstantMax;
  40712. var startColorConstantMaxElement=particleSystem.startColorConstantMax;
  40713. startColorConstantMaxElement.x=startColorConstantMaxArray[0];
  40714. startColorConstantMaxElement.y=startColorConstantMaxArray[1];
  40715. startColorConstantMaxElement.z=startColorConstantMaxArray[2];
  40716. startColorConstantMaxElement.w=startColorConstantMaxArray[3];
  40717. particleSystem.gravityModifier=data.gravityModifier;
  40718. particleSystem.simulationSpace=data.simulationSpace;
  40719. particleSystem.scaleMode=data.scaleMode;
  40720. particleSystem.playOnAwake=data.playOnAwake;
  40721. particleSystem.maxParticles=data.maxParticles;
  40722. var autoRandomSeed=data.autoRandomSeed;
  40723. (autoRandomSeed !=null)&& (particleSystem.autoRandomSeed=autoRandomSeed);
  40724. var randomSeed=data.randomSeed;
  40725. (randomSeed !=null)&& (particleSystem.randomSeed[0]=randomSeed);
  40726. var emissionData=data.emission;
  40727. var emission=particleSystem.emission;
  40728. if (emissionData){
  40729. emission.emissionRate=emissionData.emissionRate;
  40730. var burstsData=emissionData.bursts;
  40731. if (burstsData)
  40732. for (i=0,n=burstsData.length;i < n;i++){
  40733. var brust=burstsData[i];
  40734. emission.addBurst(new Burst(brust.time,brust.min,brust.max));
  40735. }
  40736. emission.enbale=emissionData.enable;
  40737. }else {
  40738. emission.enbale=false;
  40739. };
  40740. var shapeData=data.shape;
  40741. if (shapeData){
  40742. var shape;
  40743. switch (shapeData.shapeType){
  40744. case 0:;
  40745. var sphereShape;
  40746. shape=sphereShape=new SphereShape();
  40747. sphereShape.radius=shapeData.sphereRadius;
  40748. sphereShape.emitFromShell=shapeData.sphereEmitFromShell;
  40749. sphereShape.randomDirection=shapeData.sphereRandomDirection;
  40750. break ;
  40751. case 1:;
  40752. var hemiSphereShape;
  40753. shape=hemiSphereShape=new HemisphereShape();
  40754. hemiSphereShape.radius=shapeData.hemiSphereRadius;
  40755. hemiSphereShape.emitFromShell=shapeData.hemiSphereEmitFromShell;
  40756. hemiSphereShape.randomDirection=shapeData.hemiSphereRandomDirection;
  40757. break ;
  40758. case 2:;
  40759. var coneShape;
  40760. shape=coneShape=new ConeShape();
  40761. coneShape.angle=shapeData.coneAngle *anglelToRad;
  40762. coneShape.radius=shapeData.coneRadius;
  40763. coneShape.length=shapeData.coneLength;
  40764. coneShape.emitType=shapeData.coneEmitType;
  40765. coneShape.randomDirection=shapeData.coneRandomDirection;
  40766. break ;
  40767. case 3:;
  40768. var boxShape;
  40769. shape=boxShape=new BoxShape();
  40770. boxShape.x=shapeData.boxX;
  40771. boxShape.y=shapeData.boxY;
  40772. boxShape.z=shapeData.boxZ;
  40773. boxShape.randomDirection=shapeData.boxRandomDirection;
  40774. break ;
  40775. case 7:;
  40776. var circleShape;
  40777. shape=circleShape=new CircleShape();
  40778. circleShape.radius=shapeData.circleRadius;
  40779. circleShape.arc=shapeData.circleArc *anglelToRad;
  40780. circleShape.emitFromEdge=shapeData.circleEmitFromEdge;
  40781. circleShape.randomDirection=shapeData.circleRandomDirection;
  40782. break ;
  40783. default :;
  40784. var tempShape;
  40785. shape=tempShape=new CircleShape();
  40786. tempShape.radius=shapeData.circleRadius;
  40787. tempShape.arc=shapeData.circleArc *anglelToRad;
  40788. tempShape.emitFromEdge=shapeData.circleEmitFromEdge;
  40789. tempShape.randomDirection=shapeData.circleRandomDirection;
  40790. break ;
  40791. }
  40792. shape.enable=shapeData.enable;
  40793. particleSystem.shape=shape;
  40794. };
  40795. var velocityOverLifetimeData=data.velocityOverLifetime;
  40796. if (velocityOverLifetimeData){
  40797. var velocityData=velocityOverLifetimeData.velocity;
  40798. var velocity;
  40799. switch (velocityData.type){
  40800. case 0:;
  40801. var constantData=velocityData.constant;
  40802. velocity=GradientVelocity.createByConstant(new Vector3(constantData[0],constantData[1],constantData[2]));
  40803. break ;
  40804. case 1:
  40805. velocity=GradientVelocity.createByGradient(this._initParticleVelocity(velocityData.gradientX),this._initParticleVelocity(velocityData.gradientY),this._initParticleVelocity(velocityData.gradientZ));
  40806. break ;
  40807. case 2:;
  40808. var constantMinData=velocityData.constantMin;
  40809. var constantMaxData=velocityData.constantMax;
  40810. velocity=GradientVelocity.createByRandomTwoConstant(new Vector3(constantMinData[0],constantMinData[1],constantMinData[2]),new Vector3(constantMaxData[0],constantMaxData[1],constantMaxData[2]));
  40811. break ;
  40812. case 3:
  40813. 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));
  40814. break ;
  40815. };
  40816. var velocityOverLifetime=new VelocityOverLifetime(velocity);
  40817. velocityOverLifetime.space=velocityOverLifetimeData.space;
  40818. velocityOverLifetime.enbale=velocityOverLifetimeData.enable;
  40819. particleSystem.velocityOverLifetime=velocityOverLifetime;
  40820. };
  40821. var colorOverLifetimeData=data.colorOverLifetime;
  40822. if (colorOverLifetimeData){
  40823. var colorData=colorOverLifetimeData.color;
  40824. var color;
  40825. switch (colorData.type){
  40826. case 0:;
  40827. var constColorData=colorData.constant;
  40828. color=GradientColor.createByConstant(new Vector4(constColorData[0],constColorData[1],constColorData[2],constColorData[3]));
  40829. break ;
  40830. case 1:
  40831. color=GradientColor.createByGradient(this._initParticleColor(colorData.gradient));
  40832. break ;
  40833. case 2:;
  40834. var minConstColorData=colorData.constantMin;
  40835. var maxConstColorData=colorData.constantMax;
  40836. color=GradientColor.createByRandomTwoConstant(new Vector4(minConstColorData[0],minConstColorData[1],minConstColorData[2],minConstColorData[3]),new Vector4(maxConstColorData[0],maxConstColorData[1],maxConstColorData[2],maxConstColorData[3]));
  40837. break ;
  40838. case 3:
  40839. color=GradientColor.createByRandomTwoGradient(this._initParticleColor(colorData.gradientMin),this._initParticleColor(colorData.gradientMax));
  40840. break ;
  40841. };
  40842. var colorOverLifetime=new ColorOverLifetime(color);
  40843. colorOverLifetime.enbale=colorOverLifetimeData.enable;
  40844. particleSystem.colorOverLifetime=colorOverLifetime;
  40845. };
  40846. var sizeOverLifetimeData=data.sizeOverLifetime;
  40847. if (sizeOverLifetimeData){
  40848. var sizeData=sizeOverLifetimeData.size;
  40849. var size;
  40850. switch (sizeData.type){
  40851. case 0:
  40852. if (sizeData.separateAxes){
  40853. size=GradientSize.createByGradientSeparate(this._initParticleSize(sizeData.gradientX),this._initParticleSize(sizeData.gradientY),this._initParticleSize(sizeData.gradientZ));
  40854. }else {
  40855. size=GradientSize.createByGradient(this._initParticleSize(sizeData.gradient));
  40856. }
  40857. break ;
  40858. case 1:
  40859. if (sizeData.separateAxes){
  40860. var constantMinSeparateData=sizeData.constantMinSeparate;
  40861. var constantMaxSeparateData=sizeData.constantMaxSeparate;
  40862. size=GradientSize.createByRandomTwoConstantSeparate(new Vector3(constantMinSeparateData[0],constantMinSeparateData[1],constantMinSeparateData[2]),new Vector3(constantMaxSeparateData[0],constantMaxSeparateData[1],constantMaxSeparateData[2]));
  40863. }else {
  40864. size=GradientSize.createByRandomTwoConstant(sizeData.constantMin,sizeData.constantMax);
  40865. }
  40866. break ;
  40867. case 2:
  40868. if (sizeData.separateAxes){
  40869. 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));
  40870. }else {
  40871. size=GradientSize.createByRandomTwoGradient(this._initParticleSize(sizeData.gradientMin),this._initParticleSize(sizeData.gradientMax));
  40872. }
  40873. break ;
  40874. };
  40875. var sizeOverLifetime=new SizeOverLifetime(size);
  40876. sizeOverLifetime.enbale=sizeOverLifetimeData.enable;
  40877. particleSystem.sizeOverLifetime=sizeOverLifetime;
  40878. };
  40879. var rotationOverLifetimeData=data.rotationOverLifetime;
  40880. if (rotationOverLifetimeData){
  40881. var angularVelocityData=rotationOverLifetimeData.angularVelocity;
  40882. var angularVelocity;
  40883. switch (angularVelocityData.type){
  40884. case 0:
  40885. if (angularVelocityData.separateAxes){
  40886. var conSep=angularVelocityData.constantSeparate;
  40887. angularVelocity=GradientAngularVelocity.createByConstantSeparate(new Vector3(conSep[0]*anglelToRad,conSep[1]*anglelToRad,conSep[2]*anglelToRad));
  40888. }else {
  40889. angularVelocity=GradientAngularVelocity.createByConstant(angularVelocityData.constant *anglelToRad);
  40890. }
  40891. break ;
  40892. case 1:
  40893. if (angularVelocityData.separateAxes){
  40894. angularVelocity=GradientAngularVelocity.createByGradientSeparate(this._initParticleRotation(angularVelocityData.gradientX),this._initParticleRotation(angularVelocityData.gradientY),this._initParticleRotation(angularVelocityData.gradientZ));
  40895. }else {
  40896. angularVelocity=GradientAngularVelocity.createByGradient(this._initParticleRotation(angularVelocityData.gradient));
  40897. }
  40898. break ;
  40899. case 2:
  40900. if (angularVelocityData.separateAxes){
  40901. var minSep=angularVelocityData.constantMinSeparate;
  40902. var maxSep=angularVelocityData.constantMaxSeparate;
  40903. 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));
  40904. }else {
  40905. angularVelocity=GradientAngularVelocity.createByRandomTwoConstant(angularVelocityData.constantMin *anglelToRad,angularVelocityData.constantMax *anglelToRad);
  40906. }
  40907. break ;
  40908. case 3:
  40909. if (angularVelocityData.separateAxes){
  40910. }else {
  40911. angularVelocity=GradientAngularVelocity.createByRandomTwoGradient(this._initParticleRotation(angularVelocityData.gradientMin),this._initParticleRotation(angularVelocityData.gradientMax));
  40912. }
  40913. break ;
  40914. };
  40915. var rotationOverLifetime=new RotationOverLifetime(angularVelocity);
  40916. rotationOverLifetime.enbale=rotationOverLifetimeData.enable;
  40917. particleSystem.rotationOverLifetime=rotationOverLifetime;
  40918. };
  40919. var textureSheetAnimationData=data.textureSheetAnimation;
  40920. if (textureSheetAnimationData){
  40921. var frameData=textureSheetAnimationData.frame;
  40922. var frameOverTime;
  40923. switch (frameData.type){
  40924. case 0:
  40925. frameOverTime=FrameOverTime.createByConstant(frameData.constant);
  40926. break ;
  40927. case 1:
  40928. frameOverTime=FrameOverTime.createByOverTime(this._initParticleFrame(frameData.overTime));
  40929. break ;
  40930. case 2:
  40931. frameOverTime=FrameOverTime.createByRandomTwoConstant(frameData.constantMin,frameData.constantMax);
  40932. break ;
  40933. case 3:
  40934. frameOverTime=FrameOverTime.createByRandomTwoOverTime(this._initParticleFrame(frameData.overTimeMin),this._initParticleFrame(frameData.overTimeMax));
  40935. break ;
  40936. };
  40937. var startFrameData=textureSheetAnimationData.startFrame;
  40938. var startFrame;
  40939. switch (startFrameData.type){
  40940. case 0:
  40941. startFrame=StartFrame.createByConstant(startFrameData.constant);
  40942. break ;
  40943. case 1:
  40944. startFrame=StartFrame.createByRandomTwoConstant(startFrameData.constantMin,startFrameData.constantMax);
  40945. break ;
  40946. };
  40947. var textureSheetAnimation=new TextureSheetAnimation(frameOverTime,startFrame);
  40948. textureSheetAnimation.enable=textureSheetAnimationData.enable;
  40949. var tilesData=textureSheetAnimationData.tiles;
  40950. textureSheetAnimation.tiles=new Vector2(tilesData[0],tilesData[1]);
  40951. textureSheetAnimation.type=textureSheetAnimationData.type;
  40952. textureSheetAnimation.randomRow=textureSheetAnimationData.randomRow;
  40953. var rowIndex=textureSheetAnimationData.rowIndex;
  40954. (rowIndex!==undefined)&& (textureSheetAnimation.rowIndex=rowIndex);
  40955. textureSheetAnimation.cycles=textureSheetAnimationData.cycles;
  40956. particleSystem.textureSheetAnimation=textureSheetAnimation;
  40957. }
  40958. }
  40959. /**
  40960. *@inheritDoc
  40961. */
  40962. __proto._activeHierarchy=function(activeChangeComponents){
  40963. laya.display.Node.prototype._activeHierarchy.call(this,activeChangeComponents);
  40964. (this.particleSystem.playOnAwake)&& (this.particleSystem.play());
  40965. }
  40966. /**
  40967. *@inheritDoc
  40968. */
  40969. __proto._inActiveHierarchy=function(activeChangeComponents){
  40970. laya.display.Node.prototype._inActiveHierarchy.call(this,activeChangeComponents);
  40971. (this.particleSystem.isAlive)&& (this.particleSystem.simulate(0,true));
  40972. }
  40973. /**
  40974. *@private
  40975. */
  40976. __proto._cloneTo=function(destObject,srcSprite,dstSprite){
  40977. var destShuriKenParticle3D=destObject;
  40978. var destParticleSystem=destShuriKenParticle3D._particleSystem;
  40979. this._particleSystem.cloneTo(destParticleSystem);
  40980. var destParticleRender=destShuriKenParticle3D._render;
  40981. var particleRender=this._render;
  40982. destParticleRender.sharedMaterials=particleRender.sharedMaterials;
  40983. destParticleRender.enable=particleRender.enable;
  40984. destParticleRender.renderMode=particleRender.renderMode;
  40985. destParticleRender.mesh=particleRender.mesh;
  40986. destParticleRender.stretchedBillboardCameraSpeedScale=particleRender.stretchedBillboardCameraSpeedScale;
  40987. destParticleRender.stretchedBillboardSpeedScale=particleRender.stretchedBillboardSpeedScale;
  40988. destParticleRender.stretchedBillboardLengthScale=particleRender.stretchedBillboardLengthScale;
  40989. destParticleRender.sortingFudge=particleRender.sortingFudge;
  40990. laya.d3.core.Sprite3D.prototype._cloneTo.call(this,destObject,srcSprite,dstSprite);
  40991. }
  40992. /**
  40993. *<p>销毁此对象。</p>
  40994. *@param destroyChild 是否同时销毁子节点,若值为true,则销毁子节点,否则不销毁子节点。
  40995. */
  40996. __proto.destroy=function(destroyChild){
  40997. (destroyChild===void 0)&& (destroyChild=true);
  40998. if (this.destroyed)
  40999. return;
  41000. _super.prototype.destroy.call(this,destroyChild);
  41001. this._particleSystem.destroy();
  41002. this._particleSystem=null;
  41003. }
  41004. /**
  41005. *获取粒子系统。
  41006. *@return 粒子系统。
  41007. */
  41008. __getset(0,__proto,'particleSystem',function(){
  41009. return this._particleSystem;
  41010. });
  41011. /**
  41012. *获取粒子渲染器。
  41013. *@return 粒子渲染器。
  41014. */
  41015. __getset(0,__proto,'particleRenderer',function(){
  41016. return this._render;
  41017. });
  41018. ShuriKenParticle3D.__init__=function(){
  41019. ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_BILLBOARD=ShuriKenParticle3D.shaderDefines.registerDefine("SPHERHBILLBOARD");
  41020. ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_STRETCHEDBILLBOARD=ShuriKenParticle3D.shaderDefines.registerDefine("STRETCHEDBILLBOARD");
  41021. ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_HORIZONTALBILLBOARD=ShuriKenParticle3D.shaderDefines.registerDefine("HORIZONTALBILLBOARD");
  41022. ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_VERTICALBILLBOARD=ShuriKenParticle3D.shaderDefines.registerDefine("VERTICALBILLBOARD");
  41023. ShuriKenParticle3D.SHADERDEFINE_COLOROVERLIFETIME=ShuriKenParticle3D.shaderDefines.registerDefine("COLOROVERLIFETIME");
  41024. ShuriKenParticle3D.SHADERDEFINE_RANDOMCOLOROVERLIFETIME=ShuriKenParticle3D.shaderDefines.registerDefine("RANDOMCOLOROVERLIFETIME");
  41025. ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMECONSTANT=ShuriKenParticle3D.shaderDefines.registerDefine("VELOCITYOVERLIFETIMECONSTANT");
  41026. ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMECURVE=ShuriKenParticle3D.shaderDefines.registerDefine("VELOCITYOVERLIFETIMECURVE");
  41027. ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCONSTANT=ShuriKenParticle3D.shaderDefines.registerDefine("VELOCITYOVERLIFETIMERANDOMCONSTANT");
  41028. ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCURVE=ShuriKenParticle3D.shaderDefines.registerDefine("VELOCITYOVERLIFETIMERANDOMCURVE");
  41029. ShuriKenParticle3D.SHADERDEFINE_TEXTURESHEETANIMATIONCURVE=ShuriKenParticle3D.shaderDefines.registerDefine("TEXTURESHEETANIMATIONCURVE");
  41030. ShuriKenParticle3D.SHADERDEFINE_TEXTURESHEETANIMATIONRANDOMCURVE=ShuriKenParticle3D.shaderDefines.registerDefine("TEXTURESHEETANIMATIONRANDOMCURVE");
  41031. ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIME=ShuriKenParticle3D.shaderDefines.registerDefine("ROTATIONOVERLIFETIME");
  41032. ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE=ShuriKenParticle3D.shaderDefines.registerDefine("ROTATIONOVERLIFETIMESEPERATE");
  41033. ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT=ShuriKenParticle3D.shaderDefines.registerDefine("ROTATIONOVERLIFETIMECONSTANT");
  41034. ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE=ShuriKenParticle3D.shaderDefines.registerDefine("ROTATIONOVERLIFETIMECURVE");
  41035. ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS=ShuriKenParticle3D.shaderDefines.registerDefine("ROTATIONOVERLIFETIMERANDOMCONSTANTS");
  41036. ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES=ShuriKenParticle3D.shaderDefines.registerDefine("ROTATIONOVERLIFETIMERANDOMCURVES");
  41037. ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMECURVE=ShuriKenParticle3D.shaderDefines.registerDefine("SIZEOVERLIFETIMECURVE");
  41038. ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMECURVESEPERATE=ShuriKenParticle3D.shaderDefines.registerDefine("SIZEOVERLIFETIMECURVESEPERATE");
  41039. ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVES=ShuriKenParticle3D.shaderDefines.registerDefine("SIZEOVERLIFETIMERANDOMCURVES");
  41040. ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVESSEPERATE=ShuriKenParticle3D.shaderDefines.registerDefine("SIZEOVERLIFETIMERANDOMCURVESSEPERATE");
  41041. ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_MESH=ShuriKenParticle3D.shaderDefines.registerDefine("RENDERMODE_MESH");
  41042. ShuriKenParticle3D.SHADERDEFINE_SHAPE=ShuriKenParticle3D.shaderDefines.registerDefine("SHAPE");
  41043. }
  41044. ShuriKenParticle3D._initStartLife=function(gradientData){
  41045. var gradient=new GradientDataNumber();
  41046. var startLifetimesData=gradientData.startLifetimes;
  41047. for (var i=0,n=startLifetimesData.length;i < n;i++){
  41048. var valueData=startLifetimesData[i];
  41049. gradient.add(valueData.key,valueData.value);
  41050. }
  41051. return gradient
  41052. }
  41053. ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_BILLBOARD=0;
  41054. ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_STRETCHEDBILLBOARD=0;
  41055. ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_HORIZONTALBILLBOARD=0;
  41056. ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_VERTICALBILLBOARD=0;
  41057. ShuriKenParticle3D.SHADERDEFINE_COLOROVERLIFETIME=0;
  41058. ShuriKenParticle3D.SHADERDEFINE_RANDOMCOLOROVERLIFETIME=0;
  41059. ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMECONSTANT=0;
  41060. ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMECURVE=0;
  41061. ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCONSTANT=0;
  41062. ShuriKenParticle3D.SHADERDEFINE_VELOCITYOVERLIFETIMERANDOMCURVE=0;
  41063. ShuriKenParticle3D.SHADERDEFINE_TEXTURESHEETANIMATIONCURVE=0;
  41064. ShuriKenParticle3D.SHADERDEFINE_TEXTURESHEETANIMATIONRANDOMCURVE=0;
  41065. ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIME=0;
  41066. ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMESEPERATE=0;
  41067. ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMECONSTANT=0;
  41068. ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMECURVE=0;
  41069. ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCONSTANTS=0;
  41070. ShuriKenParticle3D.SHADERDEFINE_ROTATIONOVERLIFETIMERANDOMCURVES=0;
  41071. ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMECURVE=0;
  41072. ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMECURVESEPERATE=0;
  41073. ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVES=0;
  41074. ShuriKenParticle3D.SHADERDEFINE_SIZEOVERLIFETIMERANDOMCURVESSEPERATE=0;
  41075. ShuriKenParticle3D.SHADERDEFINE_RENDERMODE_MESH=0;
  41076. ShuriKenParticle3D.SHADERDEFINE_SHAPE=0;
  41077. __static(ShuriKenParticle3D,
  41078. ['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);}
  41079. ]);
  41080. return ShuriKenParticle3D;
  41081. })(RenderableSprite3D)
  41082. /**
  41083. *<code>Camera</code> 类用于创建摄像机。
  41084. */
  41085. //class laya.d3.core.Camera extends laya.d3.core.BaseCamera
  41086. var Camera=(function(_super){
  41087. function Camera(aspectRatio,nearPlane,farPlane){
  41088. /**@private */
  41089. //this._aspectRatio=NaN;
  41090. /**@private */
  41091. //this._viewport=null;
  41092. /**@private */
  41093. //this._normalizedViewport=null;
  41094. /**@private */
  41095. //this._viewMatrix=null;
  41096. /**@private */
  41097. //this._projectionMatrix=null;
  41098. /**@private */
  41099. //this._projectionViewMatrix=null;
  41100. /**@private */
  41101. //this._projectionViewMatrixNoTranslateScale=null;
  41102. /**@private */
  41103. //this._boundFrustum=null;
  41104. /**@private */
  41105. this._updateViewMatrix=true;
  41106. /**@private 渲染目标。*/
  41107. this._offScreenRenderTexture=null;
  41108. /**@private */
  41109. this._alwaysUseRenderTexture=false;
  41110. /**@private */
  41111. this._renderTexture=null;
  41112. /**@private */
  41113. this._postProcess=null;
  41114. /**是否允许渲染。*/
  41115. this.enableRender=true;
  41116. /**@private [NATIVE]*/
  41117. //this._boundFrustumBuffer=null;
  41118. this._screenShaderData=new ShaderData();
  41119. this._postProcessCommandBuffers=[];
  41120. (aspectRatio===void 0)&& (aspectRatio=0);
  41121. (nearPlane===void 0)&& (nearPlane=0.3);
  41122. (farPlane===void 0)&& (farPlane=1000);
  41123. this._viewMatrix=new Matrix4x4();
  41124. this._projectionMatrix=new Matrix4x4();
  41125. this._projectionViewMatrix=new Matrix4x4();
  41126. this._projectionViewMatrixNoTranslateScale=new Matrix4x4();
  41127. this._viewport=new Viewport(0,0,0,0);
  41128. this._normalizedViewport=new Viewport(0,0,1,1);
  41129. this._aspectRatio=aspectRatio;
  41130. this._boundFrustum=new BoundFrustum(Matrix4x4.DEFAULT);
  41131. if (Render.supportWebGLPlusCulling)
  41132. this._boundFrustumBuffer=new Float32Array(24);
  41133. Camera.__super.call(this,nearPlane,farPlane);
  41134. this.transform.on(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this,this._onTransformChanged);
  41135. }
  41136. __class(Camera,'laya.d3.core.Camera',_super);
  41137. var __proto=Camera.prototype;
  41138. /**
  41139. *通过蒙版值获取蒙版是否显示。
  41140. *@param layer 层。
  41141. *@return 是否显示。
  41142. */
  41143. __proto._isLayerVisible=function(layer){
  41144. return (Math.pow(2,layer)& this.cullingMask)!=0;
  41145. }
  41146. /**
  41147. *@private
  41148. */
  41149. __proto._onTransformChanged=function(flag){
  41150. flag &=/*laya.d3.core.Transform3D.TRANSFORM_WORLDMATRIX*/0x40;
  41151. (flag)&& (this._updateViewMatrix=true);
  41152. }
  41153. /**
  41154. *@private
  41155. */
  41156. __proto._calculationViewport=function(normalizedViewport,width,height){
  41157. var lx=normalizedViewport.x *width;
  41158. var ly=normalizedViewport.y *height;
  41159. var rx=lx+Math.max(normalizedViewport.width *width,0);
  41160. var ry=ly+Math.max(normalizedViewport.height *height,0);
  41161. var ceilLeftX=Math.ceil(lx);
  41162. var ceilLeftY=Math.ceil(ly);
  41163. var floorRightX=Math.floor(rx);
  41164. var floorRightY=Math.floor(ry);
  41165. var pixelLeftX=ceilLeftX-lx >=0.5 ? Math.floor(lx):ceilLeftX;
  41166. var pixelLeftY=ceilLeftY-ly >=0.5 ? Math.floor(ly):ceilLeftY;
  41167. var pixelRightX=rx-floorRightX >=0.5 ? Math.ceil(rx):floorRightX;
  41168. var pixelRightY=ry-floorRightY >=0.5 ? Math.ceil(ry):floorRightY;
  41169. this._viewport.x=pixelLeftX;
  41170. this._viewport.y=pixelLeftY;
  41171. this._viewport.width=pixelRightX-pixelLeftX;
  41172. this._viewport.height=pixelRightY-pixelLeftY;
  41173. }
  41174. /**
  41175. *@inheritDoc
  41176. */
  41177. __proto._parse=function(data,spriteMap){
  41178. _super.prototype._parse.call(this,data,spriteMap);
  41179. var viewport=data.viewport;
  41180. this.normalizedViewport=new Viewport(viewport[0],viewport[1],viewport[2],viewport[3]);
  41181. }
  41182. /**
  41183. *@inheritDoc
  41184. */
  41185. __proto._calculateProjectionMatrix=function(){
  41186. if (!this._useUserProjectionMatrix){
  41187. if (this._orthographic){
  41188. var halfWidth=this.orthographicVerticalSize *this.aspectRatio *0.5;
  41189. var halfHeight=this.orthographicVerticalSize *0.5;
  41190. Matrix4x4.createOrthoOffCenter(-halfWidth,halfWidth,-halfHeight,halfHeight,this.nearPlane,this.farPlane,this._projectionMatrix);
  41191. }else {
  41192. Matrix4x4.createPerspective(3.1416 *this.fieldOfView / 180.0,this.aspectRatio,this.nearPlane,this.farPlane,this._projectionMatrix);
  41193. }
  41194. }
  41195. }
  41196. /**
  41197. *@private
  41198. */
  41199. __proto._getCanvasHeight=function(){
  41200. if (this._offScreenRenderTexture)
  41201. return this._offScreenRenderTexture.height;
  41202. else
  41203. return RenderContext3D.clientHeight;
  41204. }
  41205. /**
  41206. *@private
  41207. */
  41208. __proto._applyPostProcessCommandBuffers=function(){
  41209. for (var i=0,n=this._postProcessCommandBuffers.length;i < n;i++)
  41210. this._postProcessCommandBuffers[i]._apply();
  41211. }
  41212. /**
  41213. *@private
  41214. */
  41215. __proto._needForceSetRenderTexture=function(){
  41216. return this._alwaysUseRenderTexture && !this._offScreenRenderTexture;
  41217. }
  41218. /**
  41219. *@inheritDoc
  41220. */
  41221. __proto.render=function(shader,replacementTag){
  41222. if (!this._scene)
  41223. return;
  41224. var forceSetRenderTexture=this._needForceSetRenderTexture();
  41225. if (forceSetRenderTexture)
  41226. 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);
  41227. var gl=LayaGL.instance;
  41228. var context=RenderContext3D._instance;
  41229. var scene=context.scene=this._scene;
  41230. if (scene.parallelSplitShadowMaps[0]){
  41231. ShaderData.setRuntimeValueMode(false);
  41232. var parallelSplitShadowMap=scene.parallelSplitShadowMaps[0];
  41233. parallelSplitShadowMap._calcAllLightCameraInfo(this);
  41234. scene._defineDatas.add(Scene3D.SHADERDEFINE_CAST_SHADOW);
  41235. for (var i=0,n=parallelSplitShadowMap.shadowMapCount;i < n;i++){
  41236. var smCamera=parallelSplitShadowMap.cameras[i];
  41237. context.camera=smCamera;
  41238. context.projectionViewMatrix=smCamera.projectionViewMatrix;
  41239. FrustumCulling.renderObjectCulling(smCamera,scene,context,scene._castShadowRenders);
  41240. var shadowMap=parallelSplitShadowMap.cameras[i+1].renderTarget;
  41241. shadowMap._start();
  41242. context.camera=smCamera;
  41243. context.viewport=smCamera.viewport;
  41244. smCamera._prepareCameraToRender();
  41245. smCamera._prepareCameraViewProject(smCamera.viewMatrix,smCamera.projectionMatrix,context.projectionViewMatrix,smCamera._projectionViewMatrixNoTranslateScale);
  41246. scene._clear(gl,context);
  41247. var queue=scene._opaqueQueue;
  41248. queue._render(context,false);
  41249. shadowMap._end();
  41250. }
  41251. scene._defineDatas.remove(Scene3D.SHADERDEFINE_CAST_SHADOW);
  41252. ShaderData.setRuntimeValueMode(true);
  41253. }
  41254. context.camera=this;
  41255. scene._preRenderScript();
  41256. var viewMat,projectMat;
  41257. viewMat=context.viewMatrix=this.viewMatrix;
  41258. var renderTar=this._renderTexture;
  41259. if (renderTar){
  41260. renderTar._start();
  41261. Matrix4x4.multiply(BaseCamera._invertYScaleMatrix,this._projectionMatrix,BaseCamera._invertYProjectionMatrix);
  41262. Matrix4x4.multiply(BaseCamera._invertYScaleMatrix,this.projectionViewMatrix,BaseCamera._invertYProjectionViewMatrix);
  41263. projectMat=context.projectionMatrix=BaseCamera._invertYProjectionMatrix;
  41264. context.projectionViewMatrix=BaseCamera._invertYProjectionViewMatrix;
  41265. }else {
  41266. projectMat=context.projectionMatrix=this._projectionMatrix;
  41267. context.projectionViewMatrix=this.projectionViewMatrix;
  41268. }
  41269. context.viewport=this.viewport;
  41270. this._prepareCameraToRender();
  41271. this._prepareCameraViewProject(viewMat,projectMat,context.projectionViewMatrix,this._projectionViewMatrixNoTranslateScale);
  41272. scene._preCulling(context,this);
  41273. scene._clear(gl,context);
  41274. scene._renderScene(gl,context,shader,replacementTag);
  41275. scene._postRenderScript();
  41276. (renderTar)&& (renderTar._end());
  41277. (this._postProcess)&& (this._postProcess._render());
  41278. if (forceSetRenderTexture){
  41279. var blit=BlitCMD.create(this._renderTexture,null,CommandBuffer.screenShader,this._screenShaderData);
  41280. blit.run();
  41281. blit.recover();
  41282. RenderTexture.setReleaseTemporary(this._renderTexture);
  41283. }
  41284. }
  41285. /**
  41286. *计算从屏幕空间生成的射线。
  41287. *@param point 屏幕空间的位置位置。
  41288. *@return out 输出射线。
  41289. */
  41290. __proto.viewportPointToRay=function(point,out){
  41291. Picker.calculateCursorRay(point,this.viewport,this._projectionMatrix,this.viewMatrix,null,out);
  41292. }
  41293. /**
  41294. *计算从裁切空间生成的射线。
  41295. *@param point 裁切空间的位置。。
  41296. *@return out 输出射线。
  41297. */
  41298. __proto.normalizedViewportPointToRay=function(point,out){
  41299. var finalPoint=Camera._tempVector20;
  41300. var vp=this.viewport;
  41301. finalPoint.x=point.x *vp.width;
  41302. finalPoint.y=point.y *vp.height;
  41303. Picker.calculateCursorRay(finalPoint,this.viewport,this._projectionMatrix,this.viewMatrix,null,out);
  41304. }
  41305. /**
  41306. *计算从世界空间准换三维坐标到屏幕空间。
  41307. *@param position 世界空间的位置。
  41308. *@return out 输出位置。
  41309. */
  41310. __proto.worldToViewportPoint=function(position,out){
  41311. Matrix4x4.multiply(this._projectionMatrix,this._viewMatrix,this._projectionViewMatrix);
  41312. this.viewport.project(position,this._projectionViewMatrix,out);
  41313. out.x=out.x / Laya.stage.clientScaleX;
  41314. out.y=out.y / Laya.stage.clientScaleY;
  41315. }
  41316. /**
  41317. *计算从世界空间准换三维坐标到裁切空间。
  41318. *@param position 世界空间的位置。
  41319. *@return out 输出位置。
  41320. */
  41321. __proto.worldToNormalizedViewportPoint=function(position,out){
  41322. Matrix4x4.multiply(this._projectionMatrix,this._viewMatrix,this._projectionViewMatrix);
  41323. this.normalizedViewport.project(position,this._projectionViewMatrix,out);
  41324. out.x=out.x / Laya.stage.clientScaleX;
  41325. out.y=out.y / Laya.stage.clientScaleY;
  41326. }
  41327. /**
  41328. *转换2D屏幕坐标系统到3D正交投影下的坐标系统,注:只有正交模型下有效。
  41329. *@param source 源坐标。
  41330. *@param out 输出坐标。
  41331. *@return 是否转换成功。
  41332. */
  41333. __proto.convertScreenCoordToOrthographicCoord=function(source,out){
  41334. if (this._orthographic){
  41335. var clientWidth=RenderContext3D.clientWidth;
  41336. var clientHeight=RenderContext3D.clientHeight;
  41337. var ratioX=this.orthographicVerticalSize *this.aspectRatio / clientWidth;
  41338. var ratioY=this.orthographicVerticalSize / clientHeight;
  41339. out.x=(-clientWidth / 2+source.x)*ratioX;
  41340. out.y=(clientHeight / 2-source.y)*ratioY;
  41341. out.z=(this.nearPlane-this.farPlane)*(source.z+1)/ 2-this.nearPlane;
  41342. Vector3.transformCoordinate(out,this.transform.worldMatrix,out);
  41343. return true;
  41344. }else {
  41345. return false;
  41346. }
  41347. }
  41348. /**
  41349. *@inheritDoc
  41350. */
  41351. __proto.destroy=function(destroyChild){
  41352. (destroyChild===void 0)&& (destroyChild=true);
  41353. this._offScreenRenderTexture=null;
  41354. this.transform.off(/*laya.events.Event.TRANSFORM_CHANGED*/"transformchanged",this,this._onTransformChanged);
  41355. _super.prototype.destroy.call(this,destroyChild);
  41356. }
  41357. /**
  41358. *在特定渲染管线阶段添加指令缓存。
  41359. */
  41360. __proto.addCommandBuffer=function(event,commandBuffer){
  41361. switch (event){
  41362. case 0:
  41363. this._postProcessCommandBuffers.push(commandBuffer);
  41364. break ;
  41365. default :
  41366. throw "Camera:unknown event.";
  41367. }
  41368. }
  41369. /**
  41370. *在特定渲染管线阶段移除指令缓存。
  41371. */
  41372. __proto.removeCommandBuffer=function(event,commandBuffer){
  41373. switch (event){
  41374. case 0:;
  41375. var index=this._postProcessCommandBuffers.indexOf(commandBuffer);
  41376. if (index!==-1)
  41377. this._postProcessCommandBuffers.splice(index,1);
  41378. break ;
  41379. default :
  41380. throw "Camera:unknown event.";
  41381. }
  41382. }
  41383. /**
  41384. *在特定渲染管线阶段移除所有指令缓存。
  41385. */
  41386. __proto.removeCommandBuffers=function(event){
  41387. switch (event){
  41388. case 0:
  41389. this._postProcessCommandBuffers.length=0;
  41390. break ;
  41391. default :
  41392. throw "Camera:unknown event.";
  41393. }
  41394. }
  41395. /**
  41396. *获取渲染结果纹理。
  41397. *@return 渲染结果纹理。
  41398. */
  41399. __proto.getRenderTexture=function(){
  41400. return this._renderTexture;
  41401. }
  41402. /**
  41403. *设置自定义渲染场景的渲染目标。
  41404. *@param value 自定义渲染场景的渲染目标。
  41405. */
  41406. /**
  41407. *获取自定义渲染场景的渲染目标。
  41408. *@return 自定义渲染场景的渲染目标。
  41409. */
  41410. __getset(0,__proto,'renderTarget',function(){
  41411. return this._offScreenRenderTexture;
  41412. },function(value){
  41413. if (this._offScreenRenderTexture!==value){
  41414. this._offScreenRenderTexture=value;
  41415. this._renderTexture=value;
  41416. this._calculateProjectionMatrix();
  41417. }
  41418. });
  41419. /**
  41420. *获取视图投影矩阵。
  41421. *@return 视图投影矩阵。
  41422. */
  41423. __getset(0,__proto,'projectionViewMatrix',function(){
  41424. Matrix4x4.multiply(this.projectionMatrix,this.viewMatrix,this._projectionViewMatrix);
  41425. return this._projectionViewMatrix;
  41426. });
  41427. /**
  41428. *设置横纵比。
  41429. *@param value 横纵比。
  41430. */
  41431. /**
  41432. *获取横纵比。
  41433. *@return 横纵比。
  41434. */
  41435. __getset(0,__proto,'aspectRatio',function(){
  41436. if (this._aspectRatio===0){
  41437. var vp=this.viewport;
  41438. return vp.width / vp.height;
  41439. }
  41440. return this._aspectRatio;
  41441. },function(value){
  41442. if (value < 0)
  41443. throw new Error("Camera: the aspect ratio has to be a positive real number.");
  41444. this._aspectRatio=value;
  41445. this._calculateProjectionMatrix();
  41446. });
  41447. /**
  41448. *获取摄像机视锥。
  41449. */
  41450. __getset(0,__proto,'boundFrustum',function(){
  41451. this._boundFrustum.matrix=this.projectionViewMatrix;
  41452. if (Render.supportWebGLPlusCulling){
  41453. var near=this._boundFrustum.near;
  41454. var far=this._boundFrustum.far;
  41455. var left=this._boundFrustum.left;
  41456. var right=this._boundFrustum.right;
  41457. var top=this._boundFrustum.top;
  41458. var bottom=this._boundFrustum.bottom;
  41459. var nearNE=near.normal;
  41460. var farNE=far.normal;
  41461. var leftNE=left.normal;
  41462. var rightNE=right.normal;
  41463. var topNE=top.normal;
  41464. var bottomNE=bottom.normal;
  41465. var buffer=this._boundFrustumBuffer;
  41466. buffer[0]=nearNE.x,buffer[1]=nearNE.y,buffer[2]=nearNE.z,buffer[3]=near.distance;
  41467. buffer[4]=farNE.x,buffer[5]=farNE.y,buffer[6]=farNE.z,buffer[7]=far.distance;
  41468. buffer[8]=leftNE.x,buffer[9]=leftNE.y,buffer[10]=leftNE.z,buffer[11]=left.distance;
  41469. buffer[12]=rightNE.x,buffer[13]=rightNE.y,buffer[14]=rightNE.z,buffer[15]=right.distance;
  41470. buffer[16]=topNE.x,buffer[17]=topNE.y,buffer[18]=topNE.z,buffer[19]=top.distance;
  41471. buffer[20]=bottomNE.x,buffer[21]=bottomNE.y,buffer[22]=bottomNE.z,buffer[23]=bottom.distance;
  41472. }
  41473. return this._boundFrustum;
  41474. });
  41475. /**
  41476. *设置屏幕像素坐标的视口。
  41477. *@param 屏幕像素坐标的视口。
  41478. */
  41479. /**
  41480. *获取屏幕像素坐标的视口。
  41481. *@return 屏幕像素坐标的视口。
  41482. */
  41483. __getset(0,__proto,'viewport',function(){
  41484. if (this._offScreenRenderTexture)
  41485. this._calculationViewport(this._normalizedViewport,this._offScreenRenderTexture.width,this._offScreenRenderTexture.height);
  41486. else
  41487. this._calculationViewport(this._normalizedViewport,RenderContext3D.clientWidth,RenderContext3D.clientHeight);
  41488. return this._viewport;
  41489. },function(value){
  41490. var width=0;
  41491. var height=0;
  41492. if (this._offScreenRenderTexture){
  41493. width=this._offScreenRenderTexture.width;
  41494. height=this._offScreenRenderTexture.height;
  41495. }else {
  41496. width=RenderContext3D.clientWidth;
  41497. height=RenderContext3D.clientHeight;
  41498. }
  41499. this._normalizedViewport.x=value.x / width;
  41500. this._normalizedViewport.y=value.y / height;
  41501. this._normalizedViewport.width=value.width / width;
  41502. this._normalizedViewport.height=value.height / height;
  41503. this._calculationViewport(this._normalizedViewport,width,height);
  41504. this._calculateProjectionMatrix();
  41505. });
  41506. /**
  41507. *设置是否始终使用渲染纹理,在某些渲染配置下会直接将渲染结果渲染到屏幕上,getRenderTexture()方法的返回值为空,如需使用getRenderTexture()可开启此属性。
  41508. *@param value 渲染纹理。
  41509. */
  41510. /**
  41511. *获取是否始终使用渲染纹理,在某些渲染配置下会直接将渲染结果渲染到屏幕上,getRenderTexture()方法的返回值为空,如需使用getRenderTexture()可开启此属性。
  41512. *@return 渲染纹理。
  41513. */
  41514. __getset(0,__proto,'alwaysUseRenderTexture',function(){
  41515. return this._alwaysUseRenderTexture;
  41516. },function(value){
  41517. this._alwaysUseRenderTexture=value;
  41518. });
  41519. /**
  41520. *设置裁剪空间的视口。
  41521. *@return 裁剪空间的视口。
  41522. */
  41523. /**
  41524. *获取裁剪空间的视口。
  41525. *@return 裁剪空间的视口。
  41526. */
  41527. __getset(0,__proto,'normalizedViewport',function(){
  41528. return this._normalizedViewport;
  41529. },function(value){
  41530. var width=0;
  41531. var height=0;
  41532. if (this._offScreenRenderTexture){
  41533. width=this._offScreenRenderTexture.width;
  41534. height=this._offScreenRenderTexture.height;
  41535. }else {
  41536. width=RenderContext3D.clientWidth;
  41537. height=RenderContext3D.clientHeight;
  41538. }
  41539. if (this._normalizedViewport!==value)
  41540. value.cloneTo(this._normalizedViewport);
  41541. this._calculationViewport(value,width,height);
  41542. this._calculateProjectionMatrix();
  41543. });
  41544. /**设置投影矩阵。*/
  41545. /**获取投影矩阵。*/
  41546. __getset(0,__proto,'projectionMatrix',function(){
  41547. return this._projectionMatrix;
  41548. },function(value){
  41549. this._projectionMatrix=value;
  41550. this._useUserProjectionMatrix=true;
  41551. });
  41552. /**
  41553. *获取视图矩阵。
  41554. *@return 视图矩阵。
  41555. */
  41556. __getset(0,__proto,'viewMatrix',function(){
  41557. if (this._updateViewMatrix){
  41558. var scale=this.transform.scale;
  41559. var scaleX=scale.x;
  41560. var scaleY=scale.y;
  41561. var scaleZ=scale.z;
  41562. var viewMatE=this._viewMatrix.elements;
  41563. this.transform.worldMatrix.cloneTo(this._viewMatrix)
  41564. viewMatE[0] /=scaleX;
  41565. viewMatE[1] /=scaleX;
  41566. viewMatE[2] /=scaleX;
  41567. viewMatE[4] /=scaleY;
  41568. viewMatE[5] /=scaleY;
  41569. viewMatE[6] /=scaleY;
  41570. viewMatE[8] /=scaleZ;
  41571. viewMatE[9] /=scaleZ;
  41572. viewMatE[10] /=scaleZ;
  41573. this._viewMatrix.invert(this._viewMatrix);
  41574. this._updateViewMatrix=false;
  41575. }
  41576. return this._viewMatrix;
  41577. });
  41578. /**
  41579. *设置后期处理。
  41580. *@param value 后期处理。
  41581. */
  41582. /**
  41583. *获取后期处理。
  41584. *@return 后期处理。
  41585. */
  41586. __getset(0,__proto,'postProcess',function(){
  41587. return this._postProcess;
  41588. },function(value){
  41589. this._postProcess=value;
  41590. this.alwaysUseRenderTexture=true;
  41591. var postProcessCommandBuffer=new CommandBuffer();
  41592. this.addCommandBuffer(/*CLASS CONST:laya.d3.core.Camera.CAMERAEVENT_POSTPROCESS*/0,postProcessCommandBuffer);
  41593. value._init(this,postProcessCommandBuffer);
  41594. });
  41595. Camera.CAMERAEVENT_POSTPROCESS=0;
  41596. Camera._updateMark=0;
  41597. __static(Camera,
  41598. ['_tempVector20',function(){return this._tempVector20=new Vector2();}
  41599. ]);
  41600. return Camera;
  41601. })(BaseCamera)
  41602. /**
  41603. *<code>TerrainMeshSprite3D</code> 类用于创建网格。
  41604. */
  41605. //class laya.d3.core.MeshTerrainSprite3D extends laya.d3.core.MeshSprite3D
  41606. var MeshTerrainSprite3D=(function(_super){
  41607. function MeshTerrainSprite3D(mesh,heightMap,name){
  41608. /**@private */
  41609. this._minX=NaN;
  41610. /**@private */
  41611. this._minZ=NaN;
  41612. /**@private */
  41613. this._cellSize=null;
  41614. /**@private */
  41615. this._heightMap=null;
  41616. MeshTerrainSprite3D.__super.call(this,mesh,name);
  41617. this._heightMap=heightMap;
  41618. this._cellSize=new Vector2();
  41619. }
  41620. __class(MeshTerrainSprite3D,'laya.d3.core.MeshTerrainSprite3D',_super);
  41621. var __proto=MeshTerrainSprite3D.prototype;
  41622. /**
  41623. *@private
  41624. */
  41625. __proto._disableRotation=function(){
  41626. var rotation=this.transform.rotation;
  41627. rotation.x=0;
  41628. rotation.y=0;
  41629. rotation.z=0;
  41630. rotation.w=1;
  41631. this.transform.rotation=rotation;
  41632. }
  41633. /**
  41634. *@private
  41635. */
  41636. __proto._getScaleX=function(){
  41637. var worldMat=this.transform.worldMatrix;
  41638. var worldMatE=worldMat.elements;
  41639. var m11=worldMatE[0];
  41640. var m12=worldMatE[1];
  41641. var m13=worldMatE[2];
  41642. return Math.sqrt((m11 *m11)+(m12 *m12)+(m13 *m13));
  41643. }
  41644. /**
  41645. *@private
  41646. */
  41647. __proto._getScaleZ=function(){
  41648. var worldMat=this.transform.worldMatrix;
  41649. var worldMatE=worldMat.elements;
  41650. var m31=worldMatE[8];
  41651. var m32=worldMatE[9];
  41652. var m33=worldMatE[10];
  41653. return Math.sqrt((m31 *m31)+(m32 *m32)+(m33 *m33));
  41654. }
  41655. /**
  41656. *@private
  41657. */
  41658. __proto._initCreateFromMesh=function(heightMapWidth,heightMapHeight){
  41659. this._heightMap=HeightMap.creatFromMesh(this.meshFilter.sharedMesh,heightMapWidth,heightMapHeight,this._cellSize);
  41660. var boundingBox=this.meshFilter.sharedMesh.bounds;
  41661. var min=boundingBox.getMin();
  41662. var max=boundingBox.getMax();
  41663. this._minX=min.x;
  41664. this._minZ=min.z;
  41665. }
  41666. /**
  41667. *@private
  41668. */
  41669. __proto._initCreateFromMeshHeightMap=function(texture,minHeight,maxHeight){
  41670. var boundingBox=this.meshFilter.sharedMesh.bounds;
  41671. this._heightMap=HeightMap.createFromImage(texture,minHeight,maxHeight);
  41672. this._computeCellSize(boundingBox);
  41673. var min=boundingBox.getMin();
  41674. var max=boundingBox.getMax();
  41675. this._minX=min.x;
  41676. this._minZ=min.z;
  41677. }
  41678. /**
  41679. *@private
  41680. */
  41681. __proto._computeCellSize=function(boundingBox){
  41682. var min=boundingBox.getMin();
  41683. var max=boundingBox.getMax();
  41684. var minX=min.x;
  41685. var minZ=min.z;
  41686. var maxX=max.x;
  41687. var maxZ=max.z;
  41688. var widthSize=maxX-minX;
  41689. var heightSize=maxZ-minZ;
  41690. this._cellSize.x=widthSize / (this._heightMap.width-1);
  41691. this._cellSize.y=heightSize / (this._heightMap.height-1);
  41692. }
  41693. /**
  41694. *@private
  41695. */
  41696. __proto._update=function(state){
  41697. this._disableRotation();
  41698. }
  41699. /**
  41700. *获取地形高度。
  41701. *@param x X轴坐标。
  41702. *@param z Z轴坐标。
  41703. */
  41704. __proto.getHeight=function(x,z){
  41705. MeshTerrainSprite3D._tempVector3.x=x;
  41706. MeshTerrainSprite3D._tempVector3.y=0;
  41707. MeshTerrainSprite3D._tempVector3.z=z;
  41708. this._disableRotation();
  41709. var worldMat=this.transform.worldMatrix;
  41710. worldMat.invert(MeshTerrainSprite3D._tempMatrix4x4);
  41711. Vector3.transformCoordinate(MeshTerrainSprite3D._tempVector3,MeshTerrainSprite3D._tempMatrix4x4,MeshTerrainSprite3D._tempVector3);
  41712. x=MeshTerrainSprite3D._tempVector3.x;
  41713. z=MeshTerrainSprite3D._tempVector3.z;
  41714. var c=(x-this._minX)/ this._cellSize.x;
  41715. var d=(z-this._minZ)/ this._cellSize.y;
  41716. var row=Math.floor(d);
  41717. var col=Math.floor(c);
  41718. var s=c-col;
  41719. var t=d-row;
  41720. var uy=NaN;
  41721. var vy=NaN;
  41722. var worldMatE=worldMat.elements;
  41723. var m21=worldMatE[4];
  41724. var m22=worldMatE[5];
  41725. var m23=worldMatE[6];
  41726. var scaleY=Math.sqrt((m21 *m21)+(m22 *m22)+(m23 *m23));
  41727. var translateY=worldMatE[13];
  41728. var h01=this._heightMap.getHeight(row,col+1);
  41729. var h10=this._heightMap.getHeight((row+1),col);
  41730. if (isNaN(h01)|| isNaN(h10))
  41731. return NaN;
  41732. if (s+t <=1.0){
  41733. var h00=this._heightMap.getHeight(row,col);
  41734. if (isNaN(h00))
  41735. return NaN;
  41736. uy=h01-h00;
  41737. vy=h10-h00;
  41738. return (h00+s *uy+t *vy)*scaleY+translateY;
  41739. }else {
  41740. var h11=this._heightMap.getHeight((row+1),col+1);
  41741. if (isNaN(h11))
  41742. return NaN;
  41743. uy=h10-h11;
  41744. vy=h01-h11;
  41745. return (h11+(1.0-s)*uy+(1.0-t)*vy)*scaleY+translateY;
  41746. }
  41747. }
  41748. /**
  41749. *获取地形X轴最小位置。
  41750. *@return 地形X轴最小位置。
  41751. */
  41752. __getset(0,__proto,'minX',function(){
  41753. var worldMat=this.transform.worldMatrix;
  41754. var worldMatE=worldMat.elements;
  41755. return this._minX *this._getScaleX()+worldMatE[12];
  41756. });
  41757. /**
  41758. *获取地形X轴长度。
  41759. *@return 地形X轴长度。
  41760. */
  41761. __getset(0,__proto,'width',function(){
  41762. return (this._heightMap.width-1)*this._cellSize.x *this._getScaleX();
  41763. });
  41764. /**
  41765. *获取地形Z轴最小位置。
  41766. *@return 地形X轴最小位置。
  41767. */
  41768. __getset(0,__proto,'minZ',function(){
  41769. var worldMat=this.transform.worldMatrix;
  41770. var worldMatE=worldMat.elements;
  41771. return this._minZ *this._getScaleZ()+worldMatE[14];
  41772. });
  41773. /**
  41774. *获取地形Z轴长度。
  41775. *@return 地形Z轴长度。
  41776. */
  41777. __getset(0,__proto,'depth',function(){
  41778. return (this._heightMap.height-1)*this._cellSize.y *this._getScaleZ();
  41779. });
  41780. MeshTerrainSprite3D.createFromMesh=function(mesh,heightMapWidth,heightMapHeight,name){
  41781. var meshTerrainSprite3D=new MeshTerrainSprite3D(mesh,null,name);
  41782. meshTerrainSprite3D._initCreateFromMesh(heightMapWidth,heightMapHeight);
  41783. return meshTerrainSprite3D;
  41784. }
  41785. MeshTerrainSprite3D.createFromMeshAndHeightMap=function(mesh,texture,minHeight,maxHeight,name){
  41786. var meshTerrainSprite3D=new MeshTerrainSprite3D(mesh,null,name);
  41787. meshTerrainSprite3D._initCreateFromMeshHeightMap(texture,minHeight,maxHeight);
  41788. return meshTerrainSprite3D;
  41789. }
  41790. __static(MeshTerrainSprite3D,
  41791. ['_tempVector3',function(){return this._tempVector3=new Vector3();},'_tempMatrix4x4',function(){return this._tempMatrix4x4=new Matrix4x4();}
  41792. ]);
  41793. return MeshTerrainSprite3D;
  41794. })(MeshSprite3D)
  41795. })(window,document,Laya);